On AIX in a testdir of all modules, using './configure --disable-year2038 && make' with GCC 10.3 I see the following warning:
immutable.c:278: warning: "ALIGNMENT" redefined 278 | # define ALIGNMENT sizeof (void *) | In file included from ./sys/socket.h:58, from ./netdb.h:47, from ./unistd.h:144, from ./stdlib.h:121, from immutable.c:26: /usr/include/sys/socket.h:803: note: this is the location of the previous definition 803 | #define ALIGNMENT(p) ((ulong)(p) % MACHINE_ALIGNMENT) | It is mostly harmless since the correct definition comes later. But the C standard disallows redefining macros without using #undef, unless the definitions are identical, see C23 ยง 6.10.5 [1]. And I like to avoid warnings that GCC enables by default. I have pushed the attach two patches fixing this, and a similar one in the aligned-malloc tests. Collin [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf
>From 83a07409b06600750ad194aed8989ae1df3f6140 Mon Sep 17 00:00:00 2001 From: Collin Funk <collin.fu...@gmail.com> Date: Sat, 12 Apr 2025 12:30:30 -0700 Subject: [PATCH 1/2] immutable: Avoid redefining macros on AIX. * lib/immutable.c (ALIGNMENT): Undefine any definition from system headers. --- ChangeLog | 6 ++++++ lib/immutable.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0fac61a31e..bfea3baf12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2025-04-12 Collin Funk <collin.fu...@gmail.com> + + immutable: Avoid redefining macros on AIX. + * lib/immutable.c (ALIGNMENT): Undefine any definition from system + headers. + 2025-04-12 Bruno Haible <br...@clisp.org> is*_l, fnmatch tests: Avoid test failures on macOS 15.4. diff --git a/lib/immutable.c b/lib/immutable.c index 42adc24615..012740703b 100644 --- a/lib/immutable.c +++ b/lib/immutable.c @@ -275,6 +275,10 @@ 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 # define ALIGNMENT sizeof (void *) # define PAGE_RESERVED_HEADER_SIZE SHARED_LINK_HEADER_SIZE -- 2.49.0
>From 9b2ad07978832af97d0104ea8ea591aba58abf4c Mon Sep 17 00:00:00 2001 From: Collin Funk <collin.fu...@gmail.com> Date: Sat, 12 Apr 2025 12:36:10 -0700 Subject: [PATCH 2/2] aligned-malloc tests: Avoid redefining macros on AIX. * tests/test-aligned-malloc.c (ALIGNMENT): Undefine any definition from system headers. --- ChangeLog | 4 ++++ tests/test-aligned-malloc.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index bfea3baf12..0733b2b95a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2025-04-12 Collin Funk <collin.fu...@gmail.com> + aligned-malloc tests: Avoid redefining macros on AIX. + * tests/test-aligned-malloc.c (ALIGNMENT): Undefine any definition from + system headers. + immutable: Avoid redefining macros on AIX. * lib/immutable.c (ALIGNMENT): Undefine any definition from system headers. diff --git a/tests/test-aligned-malloc.c b/tests/test-aligned-malloc.c index fdb9371a9b..e577804d22 100644 --- a/tests/test-aligned-malloc.c +++ b/tests/test-aligned-malloc.c @@ -22,6 +22,10 @@ #include <stdint.h> #include <stdlib.h> +/* Avoid redefinition on AIX. */ +#ifdef ALIGNMENT +# undef ALIGNMENT +#endif #define ALIGNMENT 4 #define aligned_malloc aligned4_malloc #define aligned_free aligned4_free -- 2.49.0