[m-rev.] for post-commit review: Handle ENOTEMPTY == EEXIST in MR_errno_name().

Peter Wang novalazy at gmail.com
Wed Apr 30 11:53:27 AEST 2025


On AIX, both ENOTEMPTY and EEXIST are defined to the same value,
which caused the code generated for MR_errno_name() to fail to compile.

tools/generate_errno_name:
    Handle the case that ENOTEMPTY == EEXIST in the generated function.

    Likewise for other errno name aliases.

runtime/mercury_errno_name.c:
    Regenerate this file.

diff --git a/runtime/mercury_errno_name.c b/runtime/mercury_errno_name.c
index fb5931cbe..9c94a5854 100644
--- a/runtime/mercury_errno_name.c
+++ b/runtime/mercury_errno_name.c
@@ -1,6 +1,6 @@
 // vim: ts=4 sw=4 expandtab ft=c
 
-// Copyright (C) 2022 The Mercury team.
+// Copyright (C) 2022, 2025 The Mercury team.
 // This file is distributed under the terms specified in COPYING.LIB.
 
 // Generated by generate_errno_name.
@@ -131,9 +131,6 @@ MR_errno_name(int errnum)
 #ifdef ENOLCK
     case ENOLCK: return "ENOLCK";
 #endif
-#ifdef ENOTEMPTY
-    case ENOTEMPTY: return "ENOTEMPTY";
-#endif
 #ifdef ELOOP
     case ELOOP: return "ELOOP";
 #endif
@@ -458,14 +455,17 @@ MR_errno_name(int errnum)
 #ifdef EBFONT
     case EBFONT: return "EBFONT";
 #endif
-#if defined(EWOULDBLOCK) && !defined(EAGAIN)
+#if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
     case EWOULDBLOCK: return "EWOULDBLOCK";
 #endif
-#if defined(EDEADLOCK) && !defined(EDEADLK)
+#if defined(EDEADLOCK) && (EDEADLOCK != EDEADLK)
     case EDEADLOCK: return "EDEADLOCK";
 #endif
-#if defined(ENOTSUP) && !defined(EOPNOTSUPP)
+#if defined(ENOTSUP) && (ENOTSUP != EOPNOTSUPP)
     case ENOTSUP: return "ENOTSUP";
+#endif
+#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
+    case ENOTEMPTY: return "ENOTEMPTY";
 #endif
     default: return NULL;
     }
diff --git a/tools/generate_errno_name b/tools/generate_errno_name
index 2337815b2..089deb3d9 100755
--- a/tools/generate_errno_name
+++ b/tools/generate_errno_name
@@ -49,7 +49,6 @@ ERANGE
 EDEADLK
 ENAMETOOLONG
 ENOLCK
-ENOTEMPTY
 ELOOP
 ENOMSG
 EIDRM
@@ -163,7 +162,7 @@ EBFONT
 cat <<EOF
 // vim: ts=4 sw=4 expandtab ft=c
 
-// Copyright (C) 2022 The Mercury team.
+// Copyright (C) 2022, 2025 The Mercury team.
 // This file is distributed under the terms specified in COPYING.LIB.
 
 // Generated by generate_errno_name.
@@ -189,14 +188,16 @@ done
 # - EWOULDBLOCK should be the same as EAGAIN
 # - EDEADLOCK should be the same as EDEADLK
 # - ENOTSUP may be the same as EOPNOTSUPP on some platforms
+# - ENOTEMPTY may be the same as EEXIST on some platforms
 handle_alias() {
-    echo "#if defined($1) && !defined($2)"
+    echo "#if defined($1) && ($1 != $2)"
     echo "    case $1: return \"$1\";"
     echo "#endif"
 }
 handle_alias EWOULDBLOCK EAGAIN
 handle_alias EDEADLOCK EDEADLK
 handle_alias ENOTSUP EOPNOTSUPP
+handle_alias ENOTEMPTY EEXIST
 
 cat <<EOF
     default: return NULL;
-- 
2.49.0



More information about the reviews mailing list