Paul Eggert wrote: > @@ -10,6 +10,11 @@ AC_PREREQ([2.61]) > AC_DEFUN_ONCE([gl_HEADER_ERRNO_H], > [ > AC_REQUIRE([AC_PROG_CC]) > + > + dnl Persuade AIX 7.3 errno.h to make EEXIST != ENOTEMPTY. > + AC_DEFINE([_LINUX_SOURCE_COMPAT], [1], > + [Define so that AIX headers are more compatible with GNU/Linux.]) > + > AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [ > AC_EGREP_CPP([booboo],[
Defining _LINUX_SOURCE_COMPAT like this, in the middle of the main configure phase, is dangerous, because this macro has other effects as well: from the 'time_t' type to the gethostbyaddr_r function. The configure script might run some tests without the _LINUX_SOURCE_COMPAT being defined, while in the build later _LINUX_SOURCE_COMPAT will be defined. It is better to define such a macro in the "early" phase of configure, like we do for the 'extensions' module. (Well, actually, the 'extensions' module does it in a "pre-early" phase, but that is a detail.) So that _LINUX_SOURCE_COMPAT is defined, consistently, across all configure tests and the build. 2024-08-01 Bruno Haible <br...@clisp.org> Ensure consistent effects of _LINUX_SOURCE_COMPAT. * modules/extensions (configure.ac-early): New section. * m4/extensions-aix.m4: New file. * modules/extensions-aix: New file. * m4/errno_h.m4 (gl_HEADER_ERRNO_H): Require gl_USE_AIX_EXTENSIONS, instead of defining _LINUX_SOURCE_COMPAT at this stage. * m4/malloc.m4 (gl_FUNC_MALLOC_GNU): Likewise. * m4/calloc.m4 (gl_FUNC_CALLOC_GNU): Likewise. * m4/realloc.m4 (gl_FUNC_REALLOC_GNU): Likewise. * m4/scandir.m4 (gl_FUNC_SCANDIR): Likewise. * modules/errno (Depends-on): Add extensions-aix. * modules/malloc-gnu (Depends-on): Likewise. * modules/calloc-gnu (Depends-on): Likewise. * modules/realloc-gnu (Depends-on): Likewise. * modules/scandir (Depends-on): Likewise. diff --git a/m4/calloc.m4 b/m4/calloc.m4 index 0fbd0d8090..6d9a808dbf 100644 --- a/m4/calloc.m4 +++ b/m4/calloc.m4 @@ -1,5 +1,5 @@ # calloc.m4 -# serial 32 +# serial 33 dnl Copyright (C) 2004-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -60,8 +60,7 @@ AC_DEFUN([gl_FUNC_CALLOC_GNU] AC_REQUIRE([gl_FUNC_CALLOC_POSIX]) dnl This helps if !(__VEC__ || __AIXVEC), and shouldn't hurt otherwise. - AC_DEFINE([_LINUX_SOURCE_COMPAT], [1], - [Define so that AIX headers are more compatible with GNU/Linux.]) + AC_REQUIRE([gl_USE_AIX_EXTENSIONS]) REPLACE_CALLOC_FOR_CALLOC_GNU="$REPLACE_CALLOC_FOR_CALLOC_POSIX" if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 0; then diff --git a/m4/errno_h.m4 b/m4/errno_h.m4 index f6a2e81b5d..9738a49f19 100644 --- a/m4/errno_h.m4 +++ b/m4/errno_h.m4 @@ -1,5 +1,5 @@ # errno_h.m4 -# serial 15 +# serial 16 dnl Copyright (C) 2004, 2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,8 +12,7 @@ AC_DEFUN_ONCE([gl_HEADER_ERRNO_H] AC_REQUIRE([AC_PROG_CC]) dnl Persuade AIX 7.3 errno.h to make EEXIST != ENOTEMPTY. - AC_DEFINE([_LINUX_SOURCE_COMPAT], [1], - [Define so that AIX headers are more compatible with GNU/Linux.]) + AC_REQUIRE([gl_USE_AIX_EXTENSIONS]) AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [ AC_EGREP_CPP([booboo],[ diff --git a/m4/extensions-aix.m4 b/m4/extensions-aix.m4 new file mode 100644 index 0000000000..990a7ac3ef --- /dev/null +++ b/m4/extensions-aix.m4 @@ -0,0 +1,25 @@ +# extensions-aix.m4 +# serial 1 +dnl Copyright (C) 2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# On AIX, most extensions are already enabled through the _ALL_SOURCE macro, +# defined by gl_USE_SYSTEM_EXTENSIONS. gl_USE_AIX_EXTENSIONS additionally +# activates more GNU and Linux-like behaviours, affecting +# - the time_t type, +# - errno values in <errno.h>: ENOTEMPTY +# - functions in <stdlib.h>: malloc calloc realloc valloc +# <https://www.ibm.com/docs/en/aix/7.3?topic=m-malloc-free-realloc-calloc-mallopt-mallinfo-mallinfo-heap-alloca-valloc-posix-memalign-subroutine> +# - functions in <string.h>: strerror_r (returns 'char *', like glibc) +# - functions in <dirent.h>: scandir, alphasort, readdir_r +# - functions in <netdb.h>: gethostbyname_r gethostbyaddr_r +# - declarations in <unistd.h>: sbrk +# and a couple of secondary <sys/*> header files. + +AC_DEFUN_ONCE([gl_USE_AIX_EXTENSIONS], +[ + AC_DEFINE([_LINUX_SOURCE_COMPAT], [1], + [Define so that AIX headers are more compatible with GNU/Linux.]) +]) diff --git a/m4/malloc.m4 b/m4/malloc.m4 index a410a5c24f..4a71b060b9 100644 --- a/m4/malloc.m4 +++ b/m4/malloc.m4 @@ -1,5 +1,5 @@ # malloc.m4 -# serial 32 +# serial 33 dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -47,8 +47,7 @@ AC_DEFUN([gl_FUNC_MALLOC_GNU] AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) dnl This helps if !(__VEC__ || __AIXVEC), and shouldn't hurt otherwise. - AC_DEFINE([_LINUX_SOURCE_COMPAT], [1], - [Define so that AIX headers are more compatible with GNU/Linux.]) + AC_REQUIRE([gl_USE_AIX_EXTENSIONS]) REPLACE_MALLOC_FOR_MALLOC_GNU="$REPLACE_MALLOC_FOR_MALLOC_POSIX" if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 0; then diff --git a/m4/realloc.m4 b/m4/realloc.m4 index 13bb28ce9d..b3ec43a8a7 100644 --- a/m4/realloc.m4 +++ b/m4/realloc.m4 @@ -1,5 +1,5 @@ # realloc.m4 -# serial 30 +# serial 31 dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -47,8 +47,7 @@ AC_DEFUN([gl_FUNC_REALLOC_GNU] AC_REQUIRE([gl_FUNC_REALLOC_POSIX]) dnl This helps if !(__VEC__ || __AIXVEC), and shouldn't hurt otherwise. - AC_DEFINE([_LINUX_SOURCE_COMPAT], [1], - [Define so that AIX headers are more compatible with GNU/Linux.]) + AC_REQUIRE([gl_USE_AIX_EXTENSIONS]) if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 0; then _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC_FOR_REALLOC_GNU=1]) diff --git a/m4/scandir.m4 b/m4/scandir.m4 index 192ac5f154..c8673fc880 100644 --- a/m4/scandir.m4 +++ b/m4/scandir.m4 @@ -1,5 +1,5 @@ # scandir.m4 -# serial 3 +# serial 4 dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,8 +12,7 @@ AC_DEFUN([gl_FUNC_SCANDIR] dnl Persuade glibc and Solaris <dirent.h> to declare scandir(). AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - AC_DEFINE([_LINUX_SOURCE_COMPAT], [1], - [Define so that AIX headers are more compatible with GNU/Linux.]) + AC_REQUIRE([gl_USE_AIX_EXTENSIONS]) AC_CHECK_FUNCS([scandir]) if test $ac_cv_func_scandir = no; then diff --git a/modules/calloc-gnu b/modules/calloc-gnu index 278df7325e..f3fb393e53 100644 --- a/modules/calloc-gnu +++ b/modules/calloc-gnu @@ -7,6 +7,7 @@ m4/calloc.m4 Depends-on: calloc-posix +extensions-aix xalloc-oversized [test $REPLACE_CALLOC_FOR_CALLOC_GNU = 1] configure.ac: diff --git a/modules/errno b/modules/errno index e245492124..385985feab 100644 --- a/modules/errno +++ b/modules/errno @@ -8,6 +8,7 @@ m4/errno_h.m4 Depends-on: gen-header include_next +extensions-aix configure.ac: gl_HEADER_ERRNO_H diff --git a/modules/extensions b/modules/extensions index b7e37bb4f5..85e7421edb 100644 --- a/modules/extensions +++ b/modules/extensions @@ -6,6 +6,10 @@ m4/extensions.m4 Depends-on: +configure.ac-early: +# This is actually already done in the pre-early phase. +# AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + configure.ac: Makefile.am: diff --git a/modules/extensions-aix b/modules/extensions-aix new file mode 100644 index 0000000000..783dc4955d --- /dev/null +++ b/modules/extensions-aix @@ -0,0 +1,22 @@ +Description: +Enable extensions in AIX standard headers + +Files: +m4/extensions-aix.m4 + +Depends-on: + +configure.ac-early: +AC_REQUIRE([gl_USE_AIX_EXTENSIONS]) + +configure.ac: + +Makefile.am: + +Include: + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/malloc-gnu b/modules/malloc-gnu index b0fa1739e8..95227241d0 100644 --- a/modules/malloc-gnu +++ b/modules/malloc-gnu @@ -6,6 +6,7 @@ lib/malloc.c Depends-on: malloc-posix +extensions-aix xalloc-oversized [test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1] configure.ac: diff --git a/modules/realloc-gnu b/modules/realloc-gnu index b06a237dd3..ff0f838b99 100644 --- a/modules/realloc-gnu +++ b/modules/realloc-gnu @@ -6,6 +6,7 @@ lib/realloc.c Depends-on: realloc-posix +extensions-aix free-posix [test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1] malloc-gnu [test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1] xalloc-oversized [test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1] diff --git a/modules/scandir b/modules/scandir index eefdfa7cff..fa58900904 100644 --- a/modules/scandir +++ b/modules/scandir @@ -10,6 +10,7 @@ builtin-expect closedir dirent extensions +extensions-aix largefile opendir readdir