Hi Bruno,

Bruno Haible <br...@clisp.org> writes:
> Yes, since we don't have a CI build for AIX, we need to occasionally check
> it manually.

Yep, that is what I was doing. All the tests that I have run so far seem
to pass fine, excluding year-2038 since the cfarm machine is 32-bits and
many skipped locale tests.

My testdir got stuck on test-fts though, which takes an unreasonably
long time on this platform. So I will probably have to run again with
'gnulib-tool --without-longrunning-tests ...'.

>> +# ifdef ALIGNMENT
>> +#  undef ALIGNMENT
>> +# endif
>
> A single-line
>   # undef ALIGNMENT
> does it as well and is shorter.

Yes, not sure why I did the #ifdef. You are right.

>> /* Avoid redefined macro on AIX.  */
>
> Well, with your change, the code still redefines the macro. Only, it does
> so without triggering a compiler warning.
> How about this?
>
> /* AIX defines a macro ALIGNMENT in <sys/socket.h>.  Undefine it.  */

That description is more accurate. Applied the attached patches with
your suggestions. Thanks!

Collin

>From 3827476ac89e400a2383107a2c1919e36970f486 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sat, 12 Apr 2025 15:02:33 -0700
Subject: [PATCH 1/2] immutable: Simplify a macro definition and improve
 comment.

Suggested by Bruno Haible.

* lib/immutable.c (ALIGNMENT): Undefine without checking. Mention that
the #undef is for AIX which defines it beforehand in <sys/socket.h>.
---
 ChangeLog       | 7 +++++++
 lib/immutable.c | 6 ++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index dbd51b5402..f94208c5f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-04-12  Collin Funk  <collin.fu...@gmail.com>
+
+	immutable: Simplify a macro definition and improve comment.
+	Suggested by Bruno Haible.
+	* lib/immutable.c (ALIGNMENT): Undefine without checking. Mention that
+	the #undef is for AIX which defines it beforehand in <sys/socket.h>.
+
 2025-04-12  Bruno Haible  <br...@clisp.org>
 
 	vasnprintf tests: Add a test case that showcases a Solaris bug.
diff --git a/lib/immutable.c b/lib/immutable.c
index 012740703b..d38419b374 100644
--- a/lib/immutable.c
+++ b/lib/immutable.c
@@ -275,10 +275,8 @@ free_pages (uintptr_t pages, size_t size)
 
 # define ALLOC_PAGES alloc_pages
 # define FREE_PAGES free_pages
-/* Avoid redefined macro on AIX.  */
-# ifdef ALIGNMENT
-#  undef ALIGNMENT
-# endif
+/* AIX defines a macro ALIGNMENT in <sys/socket.h>.  Undefine it.  */
+# undef ALIGNMENT
 # define ALIGNMENT sizeof (void *)
 # define PAGE_RESERVED_HEADER_SIZE SHARED_LINK_HEADER_SIZE
 
-- 
2.49.0

>From ef8651fe73502a91c53e68705e25adfd105bc364 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sat, 12 Apr 2025 15:03:41 -0700
Subject: [PATCH 2/2] aligned-malloc tests: Simplify a macro definition and
 improve comment.

Suggested by Bruno Haible.

* tests/test-aligned-malloc.c (ALIGNMENT): Undefine without checking.
Mention that the #undef is for AIX which defines it beforehand in
<sys/socket.h>.
---
 ChangeLog                   | 6 ++++++
 tests/test-aligned-malloc.c | 6 ++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f94208c5f7..d8b202df02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2025-04-12  Collin Funk  <collin.fu...@gmail.com>
 
+	aligned-malloc tests: Simplify a macro definition and improve comment.
+	Suggested by Bruno Haible.
+	* tests/test-aligned-malloc.c (ALIGNMENT): Undefine without checking.
+	Mention that the #undef is for AIX which defines it beforehand in
+	<sys/socket.h>.
+
 	immutable: Simplify a macro definition and improve comment.
 	Suggested by Bruno Haible.
 	* lib/immutable.c (ALIGNMENT): Undefine without checking. Mention that
diff --git a/tests/test-aligned-malloc.c b/tests/test-aligned-malloc.c
index e577804d22..1a1795f051 100644
--- a/tests/test-aligned-malloc.c
+++ b/tests/test-aligned-malloc.c
@@ -22,10 +22,8 @@
 #include <stdint.h>
 #include <stdlib.h>
 
-/* Avoid redefinition on AIX.  */
-#ifdef ALIGNMENT
-# undef ALIGNMENT
-#endif
+/* AIX defines a macro ALIGNMENT in <sys/socket.h>.  Undefine it.  */
+#undef ALIGNMENT
 #define ALIGNMENT 4
 #define aligned_malloc aligned4_malloc
 #define aligned_free aligned4_free
-- 
2.49.0

Reply via email to