From 68a256c89270ef9e97bca6097967a9ed2b050f4a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 4 Oct 2021 12:11:39 -0700 Subject: Update from Gnulib Make the following changes by hand, and run 'admin/merge-gnulib'. * .gitignore: Add lib/malloc/*.gl.h. * admin/merge-gnulib: Copy lib/af_alg.h and lib/save-cwd.h directly from Gnulib, without worrying about Gnulib modules, as these files are special cases. (AVOIDED_MODULES): Remove malloc-posix. * lib/malloc.c, lib/realloc.c, m4/malloc.m4, m4/realloc.m4: * m4/year2038.m4: New files, copied from Gnulib. * lib/malloca.c, lib/malloca.h: * m4/close-stream.m4, m4/glibc21.m4, m4/malloca.m4: Remove. These are either no longer present in Gnulib, or are no longer needed by modules that Emacs uses. * oldXMenu/AddPane.c, oldXmenu/Addsel.c: Include XmenuInt.h first; needed for new Gnulib. * src/xmenu.c: Call emacs_abort, not abort. --- m4/close-stream.m4 | 11 --- m4/dirent_h.m4 | 45 ++++++--- m4/environ.m4 | 5 +- m4/explicit_bzero.m4 | 2 +- m4/extern-inline.m4 | 7 +- m4/fcntl_h.m4 | 39 +++++--- m4/free.m4 | 7 +- m4/gettimeofday.m4 | 6 +- m4/glibc21.m4 | 34 ------- m4/gnulib-common.m4 | 269 +++++++++++++++++++++++++++++++++++++++++++++----- m4/gnulib-comp.m4 | 157 ++++++++++++++++++++++++----- m4/inttypes.m4 | 31 ++++-- m4/largefile.m4 | 28 +++--- m4/limits-h.m4 | 3 +- m4/malloc.m4 | 174 ++++++++++++++++++++++++++++++++ m4/malloca.m4 | 14 --- m4/manywarnings.m4 | 12 +-- m4/memmem.m4 | 5 +- m4/mempcpy.m4 | 4 +- m4/memrchr.m4 | 4 +- m4/mktime.m4 | 4 +- m4/pselect.m4 | 4 +- m4/pthread_sigmask.m4 | 10 +- m4/rawmemchr.m4 | 4 +- m4/realloc.m4 | 63 ++++++++++++ m4/regex.m4 | 44 ++++++++- m4/sigdescr_np.m4 | 4 +- m4/signal_h.m4 | 33 +++++-- m4/stdalign.m4 | 4 +- m4/stddef_h.m4 | 23 ++++- m4/stdint.m4 | 6 +- m4/stdio_h.m4 | 168 +++++++++++++++---------------- m4/stdlib_h.m4 | 122 ++++++++++++++--------- m4/stpcpy.m4 | 4 +- m4/string_h.m4 | 126 ++++++++++++----------- m4/strnlen.m4 | 4 +- m4/strtoll.m4 | 36 ++++++- m4/sys_random_h.m4 | 25 ++++- m4/sys_select_h.m4 | 29 ++++-- m4/sys_socket_h.m4 | 53 ++++++---- m4/sys_stat_h.m4 | 65 +++++++----- m4/sys_time_h.m4 | 34 ++++--- m4/sys_types_h.m4 | 16 ++- m4/time_h.m4 | 62 +++++++----- m4/time_r.m4 | 2 +- m4/time_rz.m4 | 2 +- m4/timegm.m4 | 4 +- m4/timer_time.m4 | 11 ++- m4/unistd_h.m4 | 194 +++++++++++++++++++----------------- m4/unlocked-io.m4 | 7 +- m4/year2038.m4 | 124 +++++++++++++++++++++++ 51 files changed, 1530 insertions(+), 614 deletions(-) delete mode 100644 m4/close-stream.m4 delete mode 100644 m4/glibc21.m4 create mode 100644 m4/malloc.m4 delete mode 100644 m4/malloca.m4 create mode 100644 m4/realloc.m4 create mode 100644 m4/year2038.m4 (limited to 'm4') diff --git a/m4/close-stream.m4 b/m4/close-stream.m4 deleted file mode 100644 index feeb4eae5d3..00000000000 --- a/m4/close-stream.m4 +++ /dev/null @@ -1,11 +0,0 @@ -#serial 4 -dnl Copyright (C) 2006-2007, 2009-2021 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. - -dnl Prerequisites of lib/close-stream.c. -AC_DEFUN([gl_CLOSE_STREAM], -[ - : -]) diff --git a/m4/dirent_h.m4 b/m4/dirent_h.m4 index 6d861425855..17e2a20c5d4 100644 --- a/m4/dirent_h.m4 +++ b/m4/dirent_h.m4 @@ -1,4 +1,4 @@ -# dirent_h.m4 serial 16 +# dirent_h.m4 serial 19 dnl Copyright (C) 2008-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,10 +6,10 @@ dnl with or without modifications, as long as this notice is preserved. dnl Written by Bruno Haible. -AC_DEFUN([gl_DIRENT_H], +AC_DEFUN_ONCE([gl_DIRENT_H], [ - dnl Use AC_REQUIRE here, so that the default behavior below is expanded - dnl once only, before all statements that occur in other macros. + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) dnl is always overridden, because of GNULIB_POSIXCHECK. @@ -27,26 +27,41 @@ AC_DEFUN([gl_DIRENT_H], ]], [alphasort closedir dirfd fdopendir opendir readdir rewinddir scandir]) ]) +# gl_DIRENT_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. AC_DEFUN([gl_DIRENT_MODULE_INDICATOR], [ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) + dnl Ensure to expand the default settings once only. + gl_DIRENT_H_REQUIRE_DEFAULTS gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_DIRENT_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_DIRENT_H_MODULE_INDICATOR_DEFAULTS], [ + gl_UNISTD_H_REQUIRE_DEFAULTS dnl for REPLACE_FCHDIR + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPENDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REWINDDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CLOSEDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DIRFD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDOPENDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCANDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALPHASORT]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_DIRENT_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) +]) + AC_DEFUN([gl_DIRENT_H_DEFAULTS], [ - AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR - GNULIB_OPENDIR=0; AC_SUBST([GNULIB_OPENDIR]) - GNULIB_READDIR=0; AC_SUBST([GNULIB_READDIR]) - GNULIB_REWINDDIR=0; AC_SUBST([GNULIB_REWINDDIR]) - GNULIB_CLOSEDIR=0; AC_SUBST([GNULIB_CLOSEDIR]) - GNULIB_DIRFD=0; AC_SUBST([GNULIB_DIRFD]) - GNULIB_FDOPENDIR=0; AC_SUBST([GNULIB_FDOPENDIR]) - GNULIB_SCANDIR=0; AC_SUBST([GNULIB_SCANDIR]) - GNULIB_ALPHASORT=0; AC_SUBST([GNULIB_ALPHASORT]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_OPENDIR=1; AC_SUBST([HAVE_OPENDIR]) HAVE_READDIR=1; AC_SUBST([HAVE_READDIR]) diff --git a/m4/environ.m4 b/m4/environ.m4 index d971770860c..ae5329108e9 100644 --- a/m4/environ.m4 +++ b/m4/environ.m4 @@ -1,4 +1,4 @@ -# environ.m4 serial 7 +# environ.m4 serial 8 dnl Copyright (C) 2001-2004, 2006-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -33,7 +33,8 @@ AC_DEFUN([gt_CHECK_VAR_DECL], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[$1 - extern struct { int foo; } $2;]], + typedef struct { int foo; } foo_t; + extern foo_t $2;]], [[$2.foo = 1;]])], [gt_cv_var=no], [gt_cv_var=yes])]) diff --git a/m4/explicit_bzero.m4 b/m4/explicit_bzero.m4 index d77ec5a3a5e..8c86d69e054 100644 --- a/m4/explicit_bzero.m4 +++ b/m4/explicit_bzero.m4 @@ -5,7 +5,7 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_EXPLICIT_BZERO], [ - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_REQUIRE([gl_STRING_H_DEFAULTS]) dnl Persuade glibc to declare explicit_bzero. AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) diff --git a/m4/extern-inline.m4 b/m4/extern-inline.m4 index a2acf126c87..a4ac5ea532a 100644 --- a/m4/extern-inline.m4 +++ b/m4/extern-inline.m4 @@ -17,7 +17,8 @@ AC_DEFUN([gl_EXTERN_INLINE], mishandles inline functions that call each other. E.g., for 'inline void f (void) { } inline void g (void) { f (); }', c99 incorrectly complains 'reference to static identifier "f" in extern inline function'. - This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16. + This bug was observed with Oracle Developer Studio 12.6 + (Sun C 5.15 SunOS_sparc 2017/05/30). Suppress extern inline (with or without __attribute__ ((__gnu_inline__))) on configurations that mistakenly use 'static inline' to implement @@ -83,8 +84,8 @@ AC_DEFUN([gl_EXTERN_INLINE], # define _GL_EXTERN_INLINE extern # define _GL_EXTERN_INLINE_IN_USE #else -# define _GL_INLINE static _GL_UNUSED -# define _GL_EXTERN_INLINE static _GL_UNUSED +# define _GL_INLINE _GL_UNUSED static +# define _GL_EXTERN_INLINE _GL_UNUSED static #endif /* In GCC 4.6 (inclusive) to 5.1 (exclusive), diff --git a/m4/fcntl_h.m4 b/m4/fcntl_h.m4 index e63a82f10a2..aba44735d14 100644 --- a/m4/fcntl_h.m4 +++ b/m4/fcntl_h.m4 @@ -1,4 +1,4 @@ -# serial 17 +# serial 20 # Configure fcntl.h. dnl Copyright (C) 2006-2007, 2009-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation @@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. dnl Written by Paul Eggert. -AC_DEFUN([gl_FCNTL_H], +AC_DEFUN_ONCE([gl_FCNTL_H], [ AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) AC_REQUIRE([gl_FCNTL_O_FLAGS]) @@ -26,25 +26,40 @@ AC_DEFUN([gl_FCNTL_H], ]], [fcntl openat]) ]) +# gl_FCNTL_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. AC_DEFUN([gl_FCNTL_MODULE_INDICATOR], [ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) + dnl Ensure to expand the default settings once only. + gl_FCNTL_H_REQUIRE_DEFAULTS gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_FCNTL_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_FCNTL_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CREAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCNTL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NONBLOCKING]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPENAT]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CREAT], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_OPEN], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_FCNTL_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) +]) + AC_DEFUN([gl_FCNTL_H_DEFAULTS], [ - GNULIB_CREAT=0; AC_SUBST([GNULIB_CREAT]) - GNULIB_FCNTL=0; AC_SUBST([GNULIB_FCNTL]) - GNULIB_NONBLOCKING=0; AC_SUBST([GNULIB_NONBLOCKING]) - GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN]) - GNULIB_OPENAT=0; AC_SUBST([GNULIB_OPENAT]) - dnl Support Microsoft deprecated alias function names by default. - GNULIB_MDA_CREAT=1; AC_SUBST([GNULIB_MDA_CREAT]) - GNULIB_MDA_OPEN=1; AC_SUBST([GNULIB_MDA_OPEN]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_FCNTL=1; AC_SUBST([HAVE_FCNTL]) HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT]) diff --git a/m4/free.m4 b/m4/free.m4 index d671376b0bb..a7923b90590 100644 --- a/m4/free.m4 +++ b/m4/free.m4 @@ -1,4 +1,4 @@ -# free.m4 serial 5 +# free.m4 serial 6 # Copyright (C) 2003-2005, 2009-2021 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -40,7 +40,10 @@ AC_DEFUN([gl_FUNC_FREE], ]) case $gl_cv_func_free_preserves_errno in - *yes) ;; + *yes) + AC_DEFINE([HAVE_FREE_POSIX], [1], + [Define if the 'free' function is guaranteed to preserve errno.]) + ;; *) REPLACE_FREE=1 ;; esac ]) diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4 index 3c200815740..37c54404bb5 100644 --- a/m4/gettimeofday.m4 +++ b/m4/gettimeofday.m4 @@ -1,4 +1,4 @@ -# serial 28 +# serial 29 # Copyright (C) 2001-2003, 2005, 2007, 2009-2021 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -9,10 +9,10 @@ dnl From Jim Meyering. AC_DEFUN([gl_FUNC_GETTIMEOFDAY], [ - AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) + AC_REQUIRE([gl_SYS_TIME_H_DEFAULTS]) AC_REQUIRE([AC_C_RESTRICT]) AC_REQUIRE([AC_CANONICAL_HOST]) - AC_REQUIRE([gl_HEADER_SYS_TIME_H]) + AC_REQUIRE([gl_SYS_TIME_H]) AC_CHECK_FUNCS_ONCE([gettimeofday]) gl_gettimeofday_timezone=void diff --git a/m4/glibc21.m4 b/m4/glibc21.m4 deleted file mode 100644 index 74a781aa1c9..00000000000 --- a/m4/glibc21.m4 +++ /dev/null @@ -1,34 +0,0 @@ -# glibc21.m4 serial 5 -dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2021 Free Software -dnl 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. - -# Test for the GNU C Library, version 2.1 or newer, or uClibc. -# From Bruno Haible. - -AC_DEFUN([gl_GLIBC21], - [ - AC_CACHE_CHECK([whether we are using the GNU C Library >= 2.1 or uClibc], - [ac_cv_gnu_library_2_1], - [AC_EGREP_CPP([Lucky], - [ -#include -#ifdef __GNU_LIBRARY__ - #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) - Lucky GNU user - #endif -#endif -#ifdef __UCLIBC__ - Lucky user -#endif - ], - [ac_cv_gnu_library_2_1=yes], - [ac_cv_gnu_library_2_1=no]) - ] - ) - AC_SUBST([GLIBC21]) - GLIBC21="$ac_cv_gnu_library_2_1" - ] -) diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index f2eff10de6d..12b19dbcb44 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 63 +# gnulib-common.m4 serial 67 dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -85,12 +85,12 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0) # define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7) # define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6) +# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0) # ifdef _ICC # define _GL_ATTR_may_alias 0 # else # define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3) # endif -# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0) # define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1) # define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3) # define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0) @@ -103,26 +103,47 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4) #endif +#ifdef __has_c_attribute +# define _GL_HAS_C_ATTRIBUTE(attr) __has_c_attribute (__##attr##__) +#else +# define _GL_HAS_C_ATTRIBUTE(attr) 0 +#endif + ]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's _Alignas instead. [ +/* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function + is the size of the returned memory block. + _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied + by the Nth argument of the function is the size of the returned memory block. + */ +/* Applies to: function, pointer to function, function types. */ #if _GL_HAS_ATTRIBUTE (alloc_size) # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) #else # define _GL_ATTRIBUTE_ALLOC_SIZE(args) #endif +/* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the + function and report an error if it cannot do so. */ +/* Applies to: function. */ #if _GL_HAS_ATTRIBUTE (always_inline) # define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) #else # define _GL_ATTRIBUTE_ALWAYS_INLINE #endif +/* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show + in stack traces when debugging. The compiler should omit the function from + stack traces. */ +/* Applies to: function. */ #if _GL_HAS_ATTRIBUTE (artificial) # define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__)) #else # define _GL_ATTRIBUTE_ARTIFICIAL #endif +/* _GL_ATTRIBUTE_COLD declares that the function is rarely executed. */ +/* Applies to: functions. */ /* Avoid __attribute__ ((cold)) on MinGW; see thread starting at . Also, Oracle Studio 12.6 requires 'cold' not '__cold__'. */ @@ -136,13 +157,41 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_ATTRIBUTE_COLD #endif +/* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate + calls to the function with the same arguments. + This attribute is safe for a function that neither depends on nor affects + observable state, and always returns exactly once - e.g., does not loop + forever, and does not call longjmp. + (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (const) # define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) #else # define _GL_ATTRIBUTE_CONST #endif -#if 201710L < __STDC_VERSION__ +/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers + that can be freed by passing them as the Ith argument to the + function F. + _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that + can be freed via 'free'; it can be used only after declaring 'free'. */ +/* Applies to: functions. Cannot be used on inline functions. */ +#if _GL_GNUC_PREREQ (11, 0) +# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) +#else +# define _GL_ATTRIBUTE_DEALLOC(f, i) +#endif +#define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1) + +/* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated. + The compiler may warn if the entity is used. */ +/* Applies to: + - function, variable, + - struct, union, struct/union member, + - enumeration, enumeration item, + - typedef, + in C++ also: namespace, class, template specialization. */ +#if _GL_HAS_C_ATTRIBUTE (deprecated) # define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] #elif _GL_HAS_ATTRIBUTE (deprecated) # define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__)) @@ -150,6 +199,11 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_ATTRIBUTE_DEPRECATED #endif +/* _GL_ATTRIBUTE_ERROR(msg) requests an error if a function is called and + the function call is not optimized away. + _GL_ATTRIBUTE_WARNING(msg) requests a warning if a function is called and + the function call is not optimized away. */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (error) # define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg))) # define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg))) @@ -161,14 +215,21 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_ATTRIBUTE_WARNING(msg) #endif +/* _GL_ATTRIBUTE_EXTERNALLY_VISIBLE declares that the entity should remain + visible to debuggers etc., even with '-fwhole-program'. */ +/* Applies to: functions, variables. */ #if _GL_HAS_ATTRIBUTE (externally_visible) # define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible)) #else # define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE #endif -/* FALLTHROUGH is special, because it always expands to something. */ -#if 201710L < __STDC_VERSION__ +/* _GL_ATTRIBUTE_FALLTHROUGH declares that it is not a programming mistake if + the control flow falls through to the immediately following 'case' or + 'default' label. The compiler should not warn in this case. */ +/* Applies to: Empty statement (;), inside a 'switch' statement. */ +/* Always expands to something. */ +#if _GL_HAS_C_ATTRIBUTE (fallthrough) # define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]] #elif _GL_HAS_ATTRIBUTE (fallthrough) # define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__)) @@ -176,18 +237,47 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0) #endif +/* _GL_ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) + declares that the STRING-INDEXth function argument is a format string of + style ARCHETYPE, which is one of: + printf, gnu_printf + scanf, gnu_scanf, + strftime, gnu_strftime, + strfmon, + or the same thing prefixed and suffixed with '__'. + If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK + are suitable for the format string. */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (format) # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) #else # define _GL_ATTRIBUTE_FORMAT(spec) #endif +/* _GL_ATTRIBUTE_LEAF declares that if the function is called from some other + compilation unit, it executes code from that unit only by return or by + exception handling. This declaration lets the compiler optimize that unit + more aggressively. */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (leaf) # define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__)) #else # define _GL_ATTRIBUTE_LEAF #endif +/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly + allocated memory. */ +/* Applies to: functions. */ +#if _GL_HAS_ATTRIBUTE (malloc) +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +#else +# define _GL_ATTRIBUTE_MALLOC +#endif + +/* _GL_ATTRIBUTE_MAY_ALIAS declares that pointers to the type may point to the + same storage as pointers to other types. Thus this declaration disables + strict aliasing optimization. */ +/* Applies to: types. */ /* Oracle Studio 12.6 mishandles may_alias despite __has_attribute OK. */ #if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C # define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__)) @@ -195,24 +285,33 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_ATTRIBUTE_MAY_ALIAS #endif -#if 201710L < __STDC_VERSION__ +/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if + the entity is not used. The compiler should not warn if the entity is not + used. */ +/* Applies to: + - function, variable, + - struct, union, struct/union member, + - enumeration, enumeration item, + - typedef, + in C++ also: class. */ +/* In C++ and C2x, this is spelled [[__maybe_unused__]]. + GCC's syntax is __attribute__ ((__unused__)). + clang supports both syntaxes. */ +#if _GL_HAS_C_ATTRIBUTE (maybe_unused) # define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] -#elif _GL_HAS_ATTRIBUTE (unused) -# define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__)) #else -# define _GL_ATTRIBUTE_MAYBE_UNUSED +# define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED #endif -/* Earlier spellings of this macro. */ +/* Alternative spelling of this macro, for convenience. */ #define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED +/* Earlier spellings of this macro. */ #define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED -#if _GL_HAS_ATTRIBUTE (malloc) -# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) -#else -# define _GL_ATTRIBUTE_MALLOC -#endif - -#if 201710L < __STDC_VERSION__ +/* _GL_ATTRIBUTE_NODISCARD declares that the caller of the function should not + discard the return value. The compiler may warn if the caller does not use + the return value, unless the caller uses something like ignore_value. */ +/* Applies to: function, enumeration, class. */ +#if _GL_HAS_C_ATTRIBUTE (nodiscard) # define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] #elif _GL_HAS_ATTRIBUTE (warn_unused_result) # define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__)) @@ -220,18 +319,30 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_ATTRIBUTE_NODISCARD #endif +/* _GL_ATTRIBUTE_NOINLINE tells that the compiler should not inline the + function. */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (noinline) # define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__)) #else # define _GL_ATTRIBUTE_NOINLINE #endif +/* _GL_ATTRIBUTE_NONNULL ((N1, N2,...)) declares that the arguments N1, N2,... + must not be NULL. + _GL_ATTRIBUTE_NONNULL () declares that all pointer arguments must not be + null. */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (nonnull) # define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args)) #else # define _GL_ATTRIBUTE_NONNULL(args) #endif +/* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is + not meant to be NUL-terminated. */ +/* Applies to: struct/union members and variables that are arrays of element + type '[[un]signed] char'. */ #if _GL_HAS_ATTRIBUTE (nonstring) # define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__)) #else @@ -240,41 +351,77 @@ AC_DEFUN([gl_COMMON_BODY], [ /* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */ +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) #else # define _GL_ATTRIBUTE_NOTHROW #endif +/* _GL_ATTRIBUTE_PACKED declares: + For struct members: The member has the smallest possible alignment. + For struct, union, class: All members have the smallest possible alignment, + minimizing the memory required. */ +/* Applies to: struct members, struct, union, + in C++ also: class. */ #if _GL_HAS_ATTRIBUTE (packed) # define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) #else # define _GL_ATTRIBUTE_PACKED #endif +/* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate + calls to the function with the same arguments if observable state is not + changed between calls. + This attribute is safe for a function that does not affect + observable state, and always returns exactly once. + (This attribute is looser than _GL_ATTRIBUTE_CONST.) */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (pure) # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) #else # define _GL_ATTRIBUTE_PURE #endif +/* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value is + a non-NULL pointer. */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (returns_nonnull) # define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__)) #else # define _GL_ATTRIBUTE_RETURNS_NONNULL #endif +/* _GL_ATTRIBUTE_SENTINEL(pos) declares that the variadic function expects a + trailing NULL argument. + _GL_ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99). + _GL_ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (sentinel) # define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos)) #else # define _GL_ATTRIBUTE_SENTINEL(pos) #endif +/* A helper macro. Don't use it directly. */ +#if _GL_HAS_ATTRIBUTE (unused) +# define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +#else +# define _GL_ATTRIBUTE_UNUSED +#endif + ]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead. [ -/* To support C++ as well as C, use _GL_UNUSED_LABEL with trailing ';'. */ -#if !defined __cplusplus || _GL_GNUC_PREREQ (4, 5) -# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_MAYBE_UNUSED +/* _GL_UNUSED_LABEL; declares that it is not a programming mistake if the + immediately preceding label is not used. The compiler should not warn + if the label is not used. */ +/* Applies to: label (both in C and C++). */ +/* Note that g++ < 4.5 does not support the '__attribute__ ((__unused__)) ;' + syntax. But clang does. */ +#if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang__ +# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED #else # define _GL_UNUSED_LABEL #endif @@ -357,6 +504,16 @@ AC_DEFUN([gl_COMMON_BODY], [ export LIBC_FATAL_STDERR_ ]) +# gl_MODULE_INDICATOR_INIT_VARIABLE([variablename]) +# gl_MODULE_INDICATOR_INIT_VARIABLE([variablename], [initialvalue]) +# initializes the shell variable that indicates the presence of the given module +# as a C preprocessor expression. +AC_DEFUN([gl_MODULE_INDICATOR_INIT_VARIABLE], +[ + GL_MODULE_INDICATOR_PREFIX[]_[$1]=m4_if([$2], , [0], [$2]) + AC_SUBST(GL_MODULE_INDICATOR_PREFIX[]_[$1]) +]) + # gl_MODULE_INDICATOR_CONDITION # expands to a C preprocessor expression that evaluates to 1 or 0, depending # whether a gnulib module that has been requested shall be considered present @@ -369,9 +526,9 @@ m4_define([gl_MODULE_INDICATOR_CONDITION], [1]) AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE], [ gl_MODULE_INDICATOR_SET_VARIABLE_AUX( - [GNULIB_[]m4_translit([[$1]], - [abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])], + [GL_MODULE_INDICATOR_PREFIX[]_GNULIB_[]m4_translit([[$1]], + [abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])], [gl_MODULE_INDICATOR_CONDITION]) ]) @@ -656,6 +813,72 @@ AC_DEFUN([gl_CACHE_VAL_SILENT], ]) ]) +# gl_CC_ALLOW_WARNINGS +# sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) option +# that reverts a preceding '-Werror' option, if available. +# This is expected to be '-Wno-error' on gcc, clang (except clang/MSVC), xlclang +# and empty otherwise. +AC_DEFUN([gl_CC_ALLOW_WARNINGS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_CACHE_CHECK([for C compiler option to allow warnings], + [gl_cv_cc_wallow], + [rm -f conftest* + echo 'int dummy;' > conftest.c + AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null + AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2>conftest2.err]) >/dev/null + dnl Test the number of error output lines, because AIX xlc accepts the + dnl option '-Wno-error', just to produce a warning + dnl "Option -Wno-error was incorrectly specified. The option will be ignored." + dnl afterwards. + if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then + gl_cv_cc_wallow='-Wno-error' + else + gl_cv_cc_wallow=none + fi + rm -f conftest* + ]) + case "$gl_cv_cc_wallow" in + none) GL_CFLAG_ALLOW_WARNINGS='' ;; + *) GL_CFLAG_ALLOW_WARNINGS="$gl_cv_cc_wallow" ;; + esac + AC_SUBST([GL_CFLAG_ALLOW_WARNINGS]) +]) + +# gl_CXX_ALLOW_WARNINGS +# sets and substitutes a variable GL_CXXFLAG_ALLOW_WARNINGS, to a $(CC) option +# that reverts a preceding '-Werror' option, if available. +AC_DEFUN([gl_CXX_ALLOW_WARNINGS], +[ + dnl Requires AC_PROG_CXX or gl_PROG_ANSI_CXX. + if test -n "$CXX" && test "$CXX" != no; then + AC_CACHE_CHECK([for C++ compiler option to allow warnings], + [gl_cv_cxx_wallow], + [rm -f conftest* + echo 'int dummy;' > conftest.cc + AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null + AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c conftest.cc 2>conftest2.err]) >/dev/null + dnl Test the number of error output lines, because AIX xlC accepts the + dnl option '-Wno-error', just to produce a warning + dnl "Option -Wno-error was incorrectly specified. The option will be ignored." + dnl afterwards. + if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then + gl_cv_cxx_wallow='-Wno-error' + else + gl_cv_cxx_wallow=none + fi + rm -f conftest* + ]) + case "$gl_cv_cxx_wallow" in + none) GL_CXXFLAG_ALLOW_WARNINGS='' ;; + *) GL_CXXFLAG_ALLOW_WARNINGS="$gl_cv_cxx_wallow" ;; + esac + else + GL_CXXFLAG_ALLOW_WARNINGS='' + fi + AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS]) +]) + dnl Expands to some code for use in .c programs that, on native Windows, defines dnl the Microsoft deprecated alias function names to the underscore-prefixed dnl actual function names. With this macro, these function names are available diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 05e7faa9937..dd5bde8d797 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -121,11 +121,13 @@ AC_DEFUN([gl_EARLY], # Code from module inttypes-incomplete: # Code from module largefile: AC_REQUIRE([AC_SYS_LARGEFILE]) + AC_REQUIRE([gl_YEAR2038_EARLY]) # Code from module lchmod: # Code from module libc-config: # Code from module libgmp: # Code from module limits-h: # Code from module lstat: + # Code from module malloc-posix: # Code from module manywarnings: # Code from module memmem-simple: # Code from module mempcpy: @@ -147,6 +149,8 @@ AC_DEFUN([gl_EARLY], # Code from module rawmemchr: # Code from module readlink: # Code from module readlinkat: + # Code from module realloc-gnu: + # Code from module realloc-posix: # Code from module regex: # Code from module root-uid: # Code from module scratch_buffer: @@ -189,6 +193,7 @@ AC_DEFUN([gl_EARLY], # Code from module u64: # Code from module unistd: # Code from module unlocked-io: + # Code from module unlocked-io-internal: # Code from module update-copyright: # Code from module utimens: # Code from module utimensat: @@ -213,6 +218,8 @@ AC_DEFUN([gl_INIT], m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES])) m4_pushdef([gl_LIBSOURCES_LIST], []) m4_pushdef([gl_LIBSOURCES_DIR], []) + m4_pushdef([GL_MACRO_PREFIX], [gl]) + m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL]) gl_COMMON gl_source_base='lib' gl_FUNC_ACL @@ -245,6 +252,7 @@ AC_DEFUN([gl_INIT], gl_SHA512 gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE gl_DIRENT_H + gl_DIRENT_H_REQUIRE_DEFAULTS gl_DOUBLE_SLASH_ROOT gl_FUNC_DUP2 if test $REPLACE_DUP2 = 1; then @@ -282,6 +290,7 @@ AC_DEFUN([gl_INIT], fi gl_FCNTL_MODULE_INDICATOR([fcntl]) gl_FCNTL_H + gl_FCNTL_H_REQUIRE_DEFAULTS gl_FUNC_FDOPENDIR if test $HAVE_FDOPENDIR = 0 || test $REPLACE_FDOPENDIR = 1; then AC_LIBOBJ([fdopendir]) @@ -337,10 +346,10 @@ AC_DEFUN([gl_INIT], if test $REPLACE_GETOPT = 1; then AC_LIBOBJ([getopt]) AC_LIBOBJ([getopt1]) - dnl Arrange for unistd.h to include getopt.h. - GNULIB_GL_UNISTD_H_GETOPT=1 + dnl Define the substituted variable GNULIB_UNISTD_H_GETOPT to 1. + gl_UNISTD_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT], [1]) fi - AC_SUBST([GNULIB_GL_UNISTD_H_GETOPT]) gl_UNISTD_MODULE_INDICATOR([getopt-posix]) AC_REQUIRE([AC_CANONICAL_HOST]) gl_FUNC_GETRANDOM @@ -357,6 +366,7 @@ AC_DEFUN([gl_INIT], gl_SYS_TIME_MODULE_INDICATOR([gettimeofday]) gl_IEEE754_H gl_INTTYPES_INCOMPLETE + gl_INTTYPES_H_REQUIRE_DEFAULTS AC_REQUIRE([gl_LARGEFILE]) gl___INLINE gl_LIBGMP @@ -444,22 +454,50 @@ AC_DEFUN([gl_INIT], fi gl_STRING_MODULE_INDICATOR([sigdescr_np]) gl_SIGNAL_H + gl_SIGNAL_H_REQUIRE_DEFAULTS gl_TYPE_SOCKLEN_T gt_TYPE_SSIZE_T gl_STAT_TIME gl_STAT_BIRTHTIME gl_STDALIGN_H gl_STDDEF_H + gl_STDDEF_H_REQUIRE_DEFAULTS gl_STDINT_H gl_STDIO_H + gl_STDIO_H_REQUIRE_DEFAULTS + dnl No need to create extra modules for these functions. Everyone who uses + dnl likely needs them. + gl_STDIO_MODULE_INDICATOR([fscanf]) + gl_MODULE_INDICATOR([fscanf]) + gl_STDIO_MODULE_INDICATOR([scanf]) + gl_MODULE_INDICATOR([scanf]) + gl_STDIO_MODULE_INDICATOR([fgetc]) + gl_STDIO_MODULE_INDICATOR([getc]) + gl_STDIO_MODULE_INDICATOR([getchar]) + gl_STDIO_MODULE_INDICATOR([fgets]) + gl_STDIO_MODULE_INDICATOR([fread]) + dnl No need to create extra modules for these functions. Everyone who uses + dnl likely needs them. + gl_STDIO_MODULE_INDICATOR([fprintf]) + gl_STDIO_MODULE_INDICATOR([printf]) + gl_STDIO_MODULE_INDICATOR([vfprintf]) + gl_STDIO_MODULE_INDICATOR([vprintf]) + gl_STDIO_MODULE_INDICATOR([fputc]) + gl_STDIO_MODULE_INDICATOR([putc]) + gl_STDIO_MODULE_INDICATOR([putchar]) + gl_STDIO_MODULE_INDICATOR([fputs]) + gl_STDIO_MODULE_INDICATOR([puts]) + gl_STDIO_MODULE_INDICATOR([fwrite]) gl_STDLIB_H + gl_STDLIB_H_REQUIRE_DEFAULTS gl_FUNC_STPCPY if test $HAVE_STPCPY = 0; then AC_LIBOBJ([stpcpy]) gl_PREREQ_STPCPY fi gl_STRING_MODULE_INDICATOR([stpcpy]) - gl_HEADER_STRING_H + gl_STRING_H + gl_STRING_H_REQUIRE_DEFAULTS gl_FUNC_STRNLEN if test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1; then AC_LIBOBJ([strnlen]) @@ -477,19 +515,25 @@ AC_DEFUN([gl_INIT], AC_LIBOBJ([symlink]) fi gl_UNISTD_MODULE_INDICATOR([symlink]) - gl_HEADER_SYS_RANDOM + gl_SYS_RANDOM_H + gl_SYS_RANDOM_H_REQUIRE_DEFAULTS AC_PROG_MKDIR_P - AC_REQUIRE([gl_HEADER_SYS_SELECT]) + gl_SYS_SELECT_H + gl_SYS_SELECT_H_REQUIRE_DEFAULTS AC_PROG_MKDIR_P - gl_HEADER_SYS_STAT_H + gl_SYS_STAT_H + gl_SYS_STAT_H_REQUIRE_DEFAULTS AC_PROG_MKDIR_P - gl_HEADER_SYS_TIME_H + gl_SYS_TIME_H + gl_SYS_TIME_H_REQUIRE_DEFAULTS AC_PROG_MKDIR_P gl_SYS_TYPES_H + gl_SYS_TYPES_H_REQUIRE_DEFAULTS AC_PROG_MKDIR_P gl_FUNC_GEN_TEMPNAME gl_MODULE_INDICATOR([tempname]) - gl_HEADER_TIME_H + gl_TIME_H + gl_TIME_H_REQUIRE_DEFAULTS gl_TIME_R if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then AC_LIBOBJ([time_r]) @@ -510,6 +554,17 @@ AC_DEFUN([gl_INIT], gl_TIMER_TIME gl_TIMESPEC gl_UNISTD_H + gl_UNISTD_H_REQUIRE_DEFAULTS + AC_DEFINE([GNULIB_STDIO_SINGLE_THREAD], [1], + [Define to 1 if you want the FILE stream functions getc, putc, etc. + to use unlocked I/O if available, throughout the package. + Unlocked I/O can improve performance, sometimes dramatically. + But unlocked I/O is safe only in single-threaded programs, + as well as in multithreaded programs for which you can guarantee that + every FILE stream, including stdin, stdout, stderr, is used only + in a single thread.]) + AC_DEFINE([USE_UNLOCKED_IO], [GNULIB_STDIO_SINGLE_THREAD], + [An alias of GNULIB_STDIO_SINGLE_THREAD.]) gl_FUNC_GLIBC_UNLOCKED_IO gl_FUNC_UTIMENSAT if test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1; then @@ -527,12 +582,14 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_getgroups=false gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false - gl_gnulib_enabled_idx=false gl_gnulib_enabled_lchmod=false + gl_gnulib_enabled_ef455225c00f5049c808c2eda3e76866=false gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false gl_gnulib_enabled_open=false gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=false gl_gnulib_enabled_rawmemchr=false + gl_gnulib_enabled_d3b2383720ee0e541357aa2aac598e2b=false + gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4=false gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false gl_gnulib_enabled_scratch_buffer=false gl_gnulib_enabled_strtoll=false @@ -571,6 +628,7 @@ AC_DEFUN([gl_INIT], func_gl_gnulib_m4code_dynarray () { if ! $gl_gnulib_enabled_dynarray; then + AC_PROG_MKDIR_P gl_gnulib_enabled_dynarray=true fi } @@ -617,6 +675,9 @@ AC_DEFUN([gl_INIT], fi gl_UNISTD_MODULE_INDICATOR([getgroups]) gl_gnulib_enabled_getgroups=true + if test $HAVE_GETGROUPS = 0 || test $REPLACE_GETGROUPS = 1; then + func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866 + fi fi } func_gl_gnulib_m4code_be453cec5eecf5731a274f2de7f2db36 () @@ -641,16 +702,10 @@ AC_DEFUN([gl_INIT], func_gl_gnulib_m4code_getgroups fi if test $HAVE_GROUP_MEMBER = 0; then - func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec + func_gl_gnulib_m4code_d3b2383720ee0e541357aa2aac598e2b fi fi } - func_gl_gnulib_m4code_idx () - { - if ! $gl_gnulib_enabled_idx; then - gl_gnulib_enabled_idx=true - fi - } func_gl_gnulib_m4code_lchmod () { if ! $gl_gnulib_enabled_lchmod; then @@ -663,6 +718,20 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_lchmod=true fi } + func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866 () + { + if ! $gl_gnulib_enabled_ef455225c00f5049c808c2eda3e76866; then + AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) + if test $REPLACE_MALLOC = 1; then + AC_LIBOBJ([malloc]) + fi + gl_STDLIB_MODULE_INDICATOR([malloc-posix]) + gl_gnulib_enabled_ef455225c00f5049c808c2eda3e76866=true + if test $REPLACE_MALLOC = 1; then + func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec + fi + fi + } func_gl_gnulib_m4code_5264294aa0a5557541b53c8c741f7f31 () { if ! $gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31; then @@ -707,6 +776,34 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_rawmemchr=true fi } + func_gl_gnulib_m4code_d3b2383720ee0e541357aa2aac598e2b () + { + if ! $gl_gnulib_enabled_d3b2383720ee0e541357aa2aac598e2b; then + gl_FUNC_REALLOC_GNU + if test $REPLACE_REALLOC = 1; then + AC_LIBOBJ([realloc]) + fi + gl_gnulib_enabled_d3b2383720ee0e541357aa2aac598e2b=true + func_gl_gnulib_m4code_61bcaca76b3e6f9ae55d57a1c3193bc4 + fi + } + func_gl_gnulib_m4code_61bcaca76b3e6f9ae55d57a1c3193bc4 () + { + if ! $gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4; then + gl_FUNC_REALLOC_POSIX + if test $REPLACE_REALLOC = 1; then + AC_LIBOBJ([realloc]) + fi + gl_STDLIB_MODULE_INDICATOR([realloc-posix]) + gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4=true + if test $REPLACE_REALLOC = 1; then + func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866 + fi + if test $REPLACE_REALLOC = 1; then + func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec + fi + fi + } func_gl_gnulib_m4code_6099e9737f757db36c47fa9d9f02e88c () { if ! $gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c; then @@ -716,14 +813,17 @@ AC_DEFUN([gl_INIT], func_gl_gnulib_m4code_scratch_buffer () { if ! $gl_gnulib_enabled_scratch_buffer; then + AC_PROG_MKDIR_P gl_gnulib_enabled_scratch_buffer=true + func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866 + func_gl_gnulib_m4code_61bcaca76b3e6f9ae55d57a1c3193bc4 fi } func_gl_gnulib_m4code_strtoll () { if ! $gl_gnulib_enabled_strtoll; then gl_FUNC_STRTOLL - if test $HAVE_STRTOLL = 0; then + if test $HAVE_STRTOLL = 0 || test $REPLACE_STRTOLL = 1; then AC_LIBOBJ([strtoll]) gl_PREREQ_STRTOLL fi @@ -747,9 +847,6 @@ AC_DEFUN([gl_INIT], if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then func_gl_gnulib_m4code_925677f0343de64b89a9f0c790b4104c fi - if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then - func_gl_gnulib_m4code_idx - fi if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then func_gl_gnulib_m4code_rawmemchr fi @@ -813,9 +910,6 @@ AC_DEFUN([gl_INIT], if { test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test $ac_cv_type_long_long_int = yes; then func_gl_gnulib_m4code_strtoll fi - if test $HAVE_TIMEZONE_T = 0; then - func_gl_gnulib_m4code_idx - fi if test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1; then func_gl_gnulib_m4code_5264294aa0a5557541b53c8c741f7f31 fi @@ -839,12 +933,14 @@ AC_DEFUN([gl_INIT], AM_CONDITIONAL([gl_GNULIB_ENABLED_getgroups], [$gl_gnulib_enabled_getgroups]) AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36]) AM_CONDITIONAL([gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1], [$gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1]) - AM_CONDITIONAL([gl_GNULIB_ENABLED_idx], [$gl_gnulib_enabled_idx]) AM_CONDITIONAL([gl_GNULIB_ENABLED_lchmod], [$gl_gnulib_enabled_lchmod]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_ef455225c00f5049c808c2eda3e76866], [$gl_gnulib_enabled_ef455225c00f5049c808c2eda3e76866]) AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31]) AM_CONDITIONAL([gl_GNULIB_ENABLED_open], [$gl_gnulib_enabled_open]) AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [$gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7]) AM_CONDITIONAL([gl_GNULIB_ENABLED_rawmemchr], [$gl_gnulib_enabled_rawmemchr]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_d3b2383720ee0e541357aa2aac598e2b], [$gl_gnulib_enabled_d3b2383720ee0e541357aa2aac598e2b]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4], [$gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4]) AM_CONDITIONAL([gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c], [$gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c]) AM_CONDITIONAL([gl_GNULIB_ENABLED_scratch_buffer], [$gl_gnulib_enabled_scratch_buffer]) AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll]) @@ -862,6 +958,8 @@ AC_DEFUN([gl_INIT], m4_if(m4_sysval, [0], [], [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) ]) + m4_popdef([GL_MODULE_INDICATOR_PREFIX]) + m4_popdef([GL_MACRO_PREFIX]) m4_popdef([gl_LIBSOURCES_DIR]) m4_popdef([gl_LIBSOURCES_LIST]) m4_popdef([AC_LIBSOURCES]) @@ -888,6 +986,8 @@ AC_DEFUN([gl_INIT], m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES])) m4_pushdef([gltests_LIBSOURCES_LIST], []) m4_pushdef([gltests_LIBSOURCES_DIR], []) + m4_pushdef([GL_MACRO_PREFIX], [gltests]) + m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL]) gl_COMMON gl_source_base='tests' changequote(,)dnl @@ -909,6 +1009,8 @@ changequote([, ])dnl m4_if(m4_sysval, [0], [], [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) ]) + m4_popdef([GL_MODULE_INDICATOR_PREFIX]) + m4_popdef([GL_MACRO_PREFIX]) m4_popdef([gltests_LIBSOURCES_DIR]) m4_popdef([gltests_LIBSOURCES_LIST]) m4_popdef([AC_LIBSOURCES]) @@ -1092,6 +1194,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/libc-config.h lib/limits.in.h lib/lstat.c + lib/malloc.c lib/malloc/dynarray-skeleton.c lib/malloc/dynarray.h lib/malloc/dynarray_at_failure.c @@ -1130,6 +1233,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/rawmemchr.valgrind lib/readlink.c lib/readlinkat.c + lib/realloc.c lib/regcomp.c lib/regex.c lib/regex.h @@ -1250,6 +1354,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/libgmp.m4 m4/limits-h.m4 m4/lstat.m4 + m4/malloc.m4 m4/manywarnings-c++.m4 m4/manywarnings.m4 m4/mbstate_t.m4 @@ -1276,6 +1381,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/rawmemchr.m4 m4/readlink.m4 m4/readlinkat.m4 + m4/realloc.m4 m4/regex.m4 m4/sha1.m4 m4/sha256.m4 @@ -1322,5 +1428,6 @@ AC_DEFUN([gl_FILE_LIST], [ m4/warnings.m4 m4/wchar_t.m4 m4/wint_t.m4 + m4/year2038.m4 m4/zzgnulib.m4 ]) diff --git a/m4/inttypes.m4 b/m4/inttypes.m4 index f56e94a8881..64b1de5c42a 100644 --- a/m4/inttypes.m4 +++ b/m4/inttypes.m4 @@ -1,4 +1,4 @@ -# inttypes.m4 serial 32 +# inttypes.m4 serial 35 dnl Copyright (C) 2006-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. dnl From Derek Price, Bruno Haible. dnl Test whether is supported or must be substituted. -AC_DEFUN([gl_INTTYPES_H], +AC_DEFUN_ONCE([gl_INTTYPES_H], [ AC_REQUIRE([gl_INTTYPES_INCOMPLETE]) gl_INTTYPES_PRI_SCN @@ -136,19 +136,34 @@ AC_DEFUN([gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION], AC_SUBST([$1]) ]) +# gl_INTTYPES_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. AC_DEFUN([gl_INTTYPES_MODULE_INDICATOR], [ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_INTTYPES_H_DEFAULTS]) + dnl Ensure to expand the default settings once only. + gl_INTTYPES_H_REQUIRE_DEFAULTS gl_MODULE_INDICATOR_SET_VARIABLE([$1]) ]) +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_INTTYPES_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_INTTYPES_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_IMAXABS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_IMAXDIV]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOIMAX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOUMAX]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_INTTYPES_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_INTTYPES_H_DEFAULTS]) +]) + AC_DEFUN([gl_INTTYPES_H_DEFAULTS], [ - GNULIB_IMAXABS=0; AC_SUBST([GNULIB_IMAXABS]) - GNULIB_IMAXDIV=0; AC_SUBST([GNULIB_IMAXDIV]) - GNULIB_STRTOIMAX=0; AC_SUBST([GNULIB_STRTOIMAX]) - GNULIB_STRTOUMAX=0; AC_SUBST([GNULIB_STRTOUMAX]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_DECL_IMAXABS=1; AC_SUBST([HAVE_DECL_IMAXABS]) HAVE_DECL_IMAXDIV=1; AC_SUBST([HAVE_DECL_IMAXDIV]) diff --git a/m4/largefile.m4 b/m4/largefile.m4 index cadb16dc972..fbde5e66471 100644 --- a/m4/largefile.m4 +++ b/m4/largefile.m4 @@ -22,7 +22,8 @@ AC_DEFUN([gl_SET_LARGEFILE_SOURCE], esac ]) -# The following implementation works around a problem in autoconf <= 2.69; +# Work around a problem in Autoconf through at least 2.71 on glibc 2.34+ +# with _TIME_BITS. Also, work around a problem in autoconf <= 2.69: # AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5, # or configures them incorrectly in some cases. m4_version_prereq([2.70], [], [ @@ -40,6 +41,7 @@ m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]];[]dnl ]) +])# m4_version_prereq 2.70 # _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, @@ -54,7 +56,8 @@ m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE], [AC_LANG_PROGRAM([$5], [$6])], [$3=no; break]) m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])( - [AC_LANG_PROGRAM([#define $1 $2 + [AC_LANG_PROGRAM([#undef $1 +#define $1 $2 $5], [$6])], [$3=$2; break]) $3=unknown @@ -80,9 +83,8 @@ rm -rf conftest*[]dnl AC_DEFUN([AC_SYS_LARGEFILE], [AC_ARG_ENABLE(largefile, [ --disable-largefile omit support for large files]) -if test "$enable_largefile" != no; then - - AC_CACHE_CHECK([for special C compiler options needed for large files], +AS_IF([test "$enable_largefile" != no], + [AC_CACHE_CHECK([for special C compiler options needed for large files], ac_cv_sys_largefile_CC, [ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then @@ -107,15 +109,15 @@ if test "$enable_largefile" != no; then ac_cv_sys_file_offset_bits, [Number of bits in a file offset, on hosts where this is settable.], [_AC_SYS_LARGEFILE_TEST_INCLUDES]) - if test $ac_cv_sys_file_offset_bits = unknown; then - _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, - ac_cv_sys_large_files, - [Define for large files, on AIX-style hosts.], - [_AC_SYS_LARGEFILE_TEST_INCLUDES]) - fi -fi + AS_CASE([$ac_cv_sys_file_offset_bits], + [unknown], + [_AC_SYS_LARGEFILE_MACRO_VALUE([_LARGE_FILES], [1], + [ac_cv_sys_large_files], + [Define for large files, on AIX-style hosts.], + [_AC_SYS_LARGEFILE_TEST_INCLUDES])], + [64], + [gl_YEAR2038_BODY([])])]) ])# AC_SYS_LARGEFILE -])# m4_version_prereq 2.70 # Enable large files on systems where this is implemented by Gnulib, not by the # system headers. diff --git a/m4/limits-h.m4 b/m4/limits-h.m4 index 70dbb7dcfa0..00c9fe9e50a 100644 --- a/m4/limits-h.m4 +++ b/m4/limits-h.m4 @@ -11,7 +11,7 @@ AC_DEFUN_ONCE([gl_LIMITS_H], [ gl_CHECK_NEXT_HEADERS([limits.h]) - AC_CACHE_CHECK([whether limits.h has LLONG_MAX, WORD_BIT, ULLONG_WIDTH etc.], + AC_CACHE_CHECK([whether limits.h has WORD_BIT, BOOL_WIDTH etc.], [gl_cv_header_limits_width], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( @@ -22,6 +22,7 @@ AC_DEFUN_ONCE([gl_LIMITS_H], long long llm = LLONG_MAX; int wb = WORD_BIT; int ullw = ULLONG_WIDTH; + int bw = BOOL_WIDTH; ]])], [gl_cv_header_limits_width=yes], [gl_cv_header_limits_width=no])]) diff --git a/m4/malloc.m4 b/m4/malloc.m4 new file mode 100644 index 00000000000..972e808ab7e --- /dev/null +++ b/m4/malloc.m4 @@ -0,0 +1,174 @@ +# malloc.m4 serial 27 +dnl Copyright (C) 2007, 2009-2021 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. + +# This is adapted with modifications from upstream Autoconf here: +# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n949 +AC_DEFUN([_AC_FUNC_MALLOC_IF], +[ + AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles + AC_CACHE_CHECK([whether malloc (0) returns nonnull], + [ac_cv_func_malloc_0_nonnull], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[void *p = malloc (0); + int result = !p; + free (p); + return result;]]) + ], + [ac_cv_func_malloc_0_nonnull=yes], + [ac_cv_func_malloc_0_nonnull=no], + [case "$host_os" in + # Guess yes on platforms where we know the result. + *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ + | gnu* | *-musl* | midnightbsd* \ + | hpux* | solaris* | cygwin* | mingw* | msys* ) + ac_cv_func_malloc_0_nonnull="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) ac_cv_func_malloc_0_nonnull="$gl_cross_guess_normal" ;; + esac + ]) + ]) + AS_CASE([$ac_cv_func_malloc_0_nonnull], [*yes], [$1], [$2]) +])# _AC_FUNC_MALLOC_IF + +# gl_FUNC_MALLOC_GNU +# ------------------ +# Replace malloc if it is not compatible with GNU libc. +AC_DEFUN([gl_FUNC_MALLOC_GNU], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) + if test $REPLACE_MALLOC = 0; then + _AC_FUNC_MALLOC_IF([], [REPLACE_MALLOC=1]) + fi +]) + +# gl_FUNC_MALLOC_PTRDIFF +# ---------------------- +# Test whether malloc (N) reliably fails when N exceeds PTRDIFF_MAX, +# and replace malloc otherwise. +AC_DEFUN([gl_FUNC_MALLOC_PTRDIFF], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF]) + test "$gl_cv_malloc_ptrdiff" = yes || REPLACE_MALLOC=1 +]) + +# Test whether malloc, realloc, calloc refuse to create objects +# larger than what can be expressed in ptrdiff_t. +# Set gl_cv_func_malloc_gnu to yes or no accordingly. +AC_DEFUN([gl_CHECK_MALLOC_PTRDIFF], +[ + AC_CACHE_CHECK([whether malloc is ptrdiff_t safe], + [gl_cv_malloc_ptrdiff], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[/* 64-bit ptrdiff_t is so wide that no practical platform + can exceed it. */ + #define WIDE_PTRDIFF (PTRDIFF_MAX >> 31 >> 31 != 0) + + /* On rare machines where size_t fits in ptrdiff_t there + is no problem. */ + #define NARROW_SIZE (SIZE_MAX <= PTRDIFF_MAX) + + /* glibc 2.30 and later malloc refuses to exceed ptrdiff_t + bounds even on 32-bit platforms. We don't know which + non-glibc systems are safe. */ + #define KNOWN_SAFE (2 < __GLIBC__ + (30 <= __GLIBC_MINOR__)) + + #if WIDE_PTRDIFF || NARROW_SIZE || KNOWN_SAFE + return 0; + #else + #error "malloc might not be ptrdiff_t safe" + syntax error + #endif + ]])], + [gl_cv_malloc_ptrdiff=yes], + [gl_cv_malloc_ptrdiff=no]) + ]) +]) + +# gl_FUNC_MALLOC_POSIX +# -------------------- +# Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it +# fails, and doesn't mess up with ptrdiff_t overflow), and replace +# malloc if it is not. +AC_DEFUN([gl_FUNC_MALLOC_POSIX], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_MALLOC_PTRDIFF]) + AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) + if test "$gl_cv_func_malloc_posix" = yes; then + AC_DEFINE([HAVE_MALLOC_POSIX], [1], + [Define if malloc, realloc, and calloc set errno on allocation failure.]) + else + REPLACE_MALLOC=1 + fi +]) + +# Test whether malloc, realloc, calloc set errno to ENOMEM on failure. +# Set gl_cv_func_malloc_posix to yes or no accordingly. +AC_DEFUN([gl_CHECK_MALLOC_POSIX], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CACHE_CHECK([whether malloc, realloc, calloc set errno on failure], + [gl_cv_func_malloc_posix], + [ + dnl It is too dangerous to try to allocate a large amount of memory: + dnl some systems go to their knees when you do that. So assume that + dnl all Unix implementations of the function set errno on failure, + dnl except on those platforms where we have seen 'test-malloc-gnu', + dnl 'test-realloc-gnu', 'test-calloc-gnu' fail. + case "$host_os" in + mingw*) + gl_cv_func_malloc_posix=no ;; + irix* | solaris*) + dnl On IRIX 6.5, the three functions return NULL with errno unset + dnl when the argument is larger than PTRDIFF_MAX. + dnl On Solaris 11.3, the three functions return NULL with errno set + dnl to EAGAIN, not ENOMEM, when the argument is larger than + dnl PTRDIFF_MAX. + dnl Here is a test program: +m4_divert_push([KILL]) +#include +#include +#include +#define ptrdiff_t long +#ifndef PTRDIFF_MAX +# define PTRDIFF_MAX ((ptrdiff_t) ((1UL << (8 * sizeof (ptrdiff_t) - 1)) - 1)) +#endif + +int main () +{ + void *p; + + fprintf (stderr, "PTRDIFF_MAX = %lu\n", (unsigned long) PTRDIFF_MAX); + + errno = 0; + p = malloc ((unsigned long) PTRDIFF_MAX + 1); + fprintf (stderr, "p=%p errno=%d\n", p, errno); + + errno = 0; + p = calloc (PTRDIFF_MAX / 2 + 1, 2); + fprintf (stderr, "p=%p errno=%d\n", p, errno); + + errno = 0; + p = realloc (NULL, (unsigned long) PTRDIFF_MAX + 1); + fprintf (stderr, "p=%p errno=%d\n", p, errno); + + return 0; +} +m4_divert_pop([KILL]) + gl_cv_func_malloc_posix=no ;; + *) + gl_cv_func_malloc_posix=yes ;; + esac + ]) +]) diff --git a/m4/malloca.m4 b/m4/malloca.m4 deleted file mode 100644 index 7ee33773d25..00000000000 --- a/m4/malloca.m4 +++ /dev/null @@ -1,14 +0,0 @@ -# malloca.m4 serial 2 -dnl Copyright (C) 2003-2004, 2006-2007, 2009-2021 Free Software -dnl 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. - -AC_DEFUN([gl_MALLOCA], -[ - dnl Use the autoconf tests for alloca(), but not the AC_SUBSTed variables - dnl @ALLOCA@ and @LTALLOCA@. - dnl gl_FUNC_ALLOCA dnl Already brought in by the module dependencies. - AC_REQUIRE([gl_EEMALLOC]) -]) diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4 index 53ab1534036..872ea58e62a 100644 --- a/m4/manywarnings.m4 +++ b/m4/manywarnings.m4 @@ -1,4 +1,4 @@ -# manywarnings.m4 serial 21 +# manywarnings.m4 serial 23 dnl Copyright (C) 2008-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -195,15 +195,9 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C)], gl_AS_VAR_APPEND([$1], [' -Wno-uninitialized']) fi - # Some warnings have too many false alarms in GCC 10.1. - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93695 - gl_AS_VAR_APPEND([$1], [' -Wno-analyzer-double-free']) - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94458 + # This warning have too many false alarms in GCC 11.2.1. + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101713 gl_AS_VAR_APPEND([$1], [' -Wno-analyzer-malloc-leak']) - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94851 - gl_AS_VAR_APPEND([$1], [' -Wno-analyzer-null-dereference']) - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95758 - gl_AS_VAR_APPEND([$1], [' -Wno-analyzer-use-after-free']) AC_LANG_POP([C]) ]) diff --git a/m4/memmem.m4 b/m4/memmem.m4 index e2a785f48d4..6dac7661283 100644 --- a/m4/memmem.m4 +++ b/m4/memmem.m4 @@ -1,4 +1,4 @@ -# memmem.m4 serial 27 +# memmem.m4 serial 29 dnl Copyright (C) 2002-2004, 2007-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,7 +10,7 @@ AC_DEFUN([gl_FUNC_MEMMEM_SIMPLE], dnl Persuade glibc to declare memmem(). AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_REQUIRE([gl_STRING_H_DEFAULTS]) AC_CHECK_FUNCS([memmem]) if test $ac_cv_func_memmem = yes; then HAVE_MEMMEM=1 @@ -50,6 +50,7 @@ AC_DEFUN([gl_FUNC_MEMMEM_SIMPLE], dnl Assume that it works on all other platforms (even if not linear). AC_EGREP_CPP([Lucky user], [ +#include /* for __GNU_LIBRARY__ */ #ifdef __GNU_LIBRARY__ #include #if ((__GLIBC__ == 2 && ((__GLIBC_MINOR > 0 && __GLIBC_MINOR__ < 9) \ diff --git a/m4/mempcpy.m4 b/m4/mempcpy.m4 index c5ee2af8ccd..f9d9ec8f308 100644 --- a/m4/mempcpy.m4 +++ b/m4/mempcpy.m4 @@ -1,4 +1,4 @@ -# mempcpy.m4 serial 11 +# mempcpy.m4 serial 12 dnl Copyright (C) 2003-2004, 2006-2007, 2009-2021 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -13,7 +13,7 @@ AC_DEFUN([gl_FUNC_MEMPCPY], dnl The mempcpy() declaration in lib/string.in.h uses 'restrict'. AC_REQUIRE([AC_C_RESTRICT]) - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_REQUIRE([gl_STRING_H_DEFAULTS]) AC_CHECK_FUNCS([mempcpy]) if test $ac_cv_func_mempcpy = no; then HAVE_MEMPCPY=0 diff --git a/m4/memrchr.m4 b/m4/memrchr.m4 index d0c05896e54..40f61c5ac0a 100644 --- a/m4/memrchr.m4 +++ b/m4/memrchr.m4 @@ -1,4 +1,4 @@ -# memrchr.m4 serial 10 +# memrchr.m4 serial 11 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2021 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -10,7 +10,7 @@ AC_DEFUN([gl_FUNC_MEMRCHR], dnl Persuade glibc to declare memrchr(). AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_REQUIRE([gl_STRING_H_DEFAULTS]) AC_CHECK_DECLS_ONCE([memrchr]) if test $ac_cv_have_decl_memrchr = no; then HAVE_DECL_MEMRCHR=0 diff --git a/m4/mktime.m4 b/m4/mktime.m4 index 245649e774a..721189af56e 100644 --- a/m4/mktime.m4 +++ b/m4/mktime.m4 @@ -1,4 +1,4 @@ -# serial 35 +# serial 36 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2021 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -255,7 +255,7 @@ main () dnl Main macro of module 'mktime'. AC_DEFUN([gl_FUNC_MKTIME], [ - AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) + AC_REQUIRE([gl_TIME_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([gl_FUNC_MKTIME_WORKS]) diff --git a/m4/pselect.m4 b/m4/pselect.m4 index 538fe7dc122..9de63baf990 100644 --- a/m4/pselect.m4 +++ b/m4/pselect.m4 @@ -1,4 +1,4 @@ -# pselect.m4 serial 9 +# pselect.m4 serial 10 dnl Copyright (C) 2011-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,7 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_PSELECT], [ - AC_REQUIRE([gl_HEADER_SYS_SELECT]) + AC_REQUIRE([gl_SYS_SELECT_H]) AC_REQUIRE([AC_C_RESTRICT]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CHECK_FUNCS_ONCE([pselect]) diff --git a/m4/pthread_sigmask.m4 b/m4/pthread_sigmask.m4 index eb4c7849655..ff7fa9610e2 100644 --- a/m4/pthread_sigmask.m4 +++ b/m4/pthread_sigmask.m4 @@ -1,4 +1,4 @@ -# pthread_sigmask.m4 serial 19 +# pthread_sigmask.m4 serial 21 dnl Copyright (C) 2011-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -111,9 +111,9 @@ AC_DEFUN([gl_FUNC_PTHREAD_SIGMASK], AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - dnl On FreeBSD 6.4, HP-UX 11.31, Solaris 9, in programs that are not linked - dnl with -lpthread, the pthread_sigmask() function always returns 0 and has - dnl no effect. + dnl On FreeBSD 13.0, MidnightBSD 1.1, HP-UX 11.31, Solaris 9, in programs + dnl that are not linked with -lpthread, the pthread_sigmask() function + dnl always returns 0 and has no effect. if test -z "$LIB_PTHREAD_SIGMASK"; then case " $LIBS " in *' -pthread '*) ;; @@ -138,7 +138,7 @@ AC_DEFUN([gl_FUNC_PTHREAD_SIGMASK], [ changequote(,)dnl case "$host_os" in - freebsd* | hpux* | solaris | solaris2.[2-9]*) + freebsd* | midnightbsd* | hpux* | solaris | solaris2.[2-9]*) gl_cv_func_pthread_sigmask_in_libc_works="guessing no";; *) gl_cv_func_pthread_sigmask_in_libc_works="guessing yes";; diff --git a/m4/rawmemchr.m4 b/m4/rawmemchr.m4 index f92846543cc..452fab18f13 100644 --- a/m4/rawmemchr.m4 +++ b/m4/rawmemchr.m4 @@ -1,4 +1,4 @@ -# rawmemchr.m4 serial 2 +# rawmemchr.m4 serial 3 dnl Copyright (C) 2003, 2007-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_RAWMEMCHR], dnl Persuade glibc to declare rawmemchr(). AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_REQUIRE([gl_STRING_H_DEFAULTS]) AC_CHECK_FUNCS([rawmemchr]) if test $ac_cv_func_rawmemchr = no; then HAVE_RAWMEMCHR=0 diff --git a/m4/realloc.m4 b/m4/realloc.m4 new file mode 100644 index 00000000000..0abc4185ed0 --- /dev/null +++ b/m4/realloc.m4 @@ -0,0 +1,63 @@ +# realloc.m4 serial 24 +dnl Copyright (C) 2007, 2009-2021 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. + +# This is adapted with modifications from upstream Autoconf here: +# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n1455 +AC_DEFUN([_AC_FUNC_REALLOC_IF], +[ + AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles + AC_CACHE_CHECK([whether realloc (0, 0) returns nonnull], + [ac_cv_func_realloc_0_nonnull], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[void *p = realloc (0, 0); + int result = !p; + free (p); + return result;]]) + ], + [ac_cv_func_realloc_0_nonnull=yes], + [ac_cv_func_realloc_0_nonnull=no], + [case "$host_os" in + # Guess yes on platforms where we know the result. + *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ + | gnu* | *-musl* | midnightbsd* \ + | hpux* | solaris* | cygwin* | mingw* | msys* ) + ac_cv_func_realloc_0_nonnull="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) ac_cv_func_realloc_0_nonnull="$gl_cross_guess_normal" ;; + esac + ]) + ]) + AS_CASE([$ac_cv_func_realloc_0_nonnull], [*yes], [$1], [$2]) +])# AC_FUNC_REALLOC + +# gl_FUNC_REALLOC_GNU +# ------------------- +# Replace realloc if it is not compatible with GNU libc. +AC_DEFUN([gl_FUNC_REALLOC_GNU], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_REALLOC_POSIX]) + if test $REPLACE_REALLOC = 0; then + _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC=1]) + fi +])# gl_FUNC_REALLOC_GNU + +# gl_FUNC_REALLOC_POSIX +# --------------------- +# Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it +# fails, and doesn't mess up with ptrdiff_t overflow), +# and replace realloc if it is not. +AC_DEFUN([gl_FUNC_REALLOC_POSIX], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) + if test $REPLACE_MALLOC = 1; then + REPLACE_REALLOC=1 + fi +]) diff --git a/m4/regex.m4 b/m4/regex.m4 index 850c572228a..1c7e562f6c6 100644 --- a/m4/regex.m4 +++ b/m4/regex.m4 @@ -1,4 +1,4 @@ -# serial 71 +# serial 73 # Copyright (C) 1996-2001, 2003-2021 Free Software Foundation, Inc. # @@ -246,7 +246,7 @@ AC_DEFUN([gl_REGEX], & ~RE_CONTEXT_INVALID_DUP & ~RE_NO_EMPTY_RANGES); memset (®ex, 0, sizeof regex); - s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, ®ex); + s = re_compile_pattern ("[[:alnum:]_-]\\\\+\$", 16, ®ex); if (s) result |= 32; else @@ -264,14 +264,50 @@ AC_DEFUN([gl_REGEX], back reference. */ re_set_syntax (RE_SYNTAX_POSIX_EGREP); memset (®ex, 0, sizeof regex); - s = re_compile_pattern ("0|()0|\\1|0", 10, ®ex); + s = re_compile_pattern ("0|()0|\\\\1|0", 10, ®ex); if (!s) - result |= 64; + { + memset (®s, 0, sizeof regs); + i = re_search (®ex, "x", 1, 0, 1, ®s); + if (i != -1) + result |= 64; + if (0 <= i) + { + free (regs.start); + free (regs.end); + } + regfree (®ex); + } else { if (strcmp (s, "Invalid back reference")) result |= 64; + } + + /* glibc bug 11053. */ + re_set_syntax (RE_SYNTAX_POSIX_BASIC); + memset (®ex, 0, sizeof regex); + static char const pat_sub2[] = "\\\\(a*\\\\)*a*\\\\1"; + s = re_compile_pattern (pat_sub2, sizeof pat_sub2 - 1, ®ex); + if (s) + result |= 64; + else + { + memset (®s, 0, sizeof regs); + static char const data[] = "a"; + int datalen = sizeof data - 1; + i = re_search (®ex, data, datalen, 0, datalen, ®s); + if (i != 0) + result |= 64; + else if (regs.num_regs < 2) + result |= 64; + else if (! (regs.start[0] == 0 && regs.end[0] == 1)) + result |= 64; + else if (! (regs.start[1] == 0 && regs.end[1] == 0)) + result |= 64; regfree (®ex); + free (regs.start); + free (regs.end); } #if 0 diff --git a/m4/sigdescr_np.m4 b/m4/sigdescr_np.m4 index f6fa63140c4..17c22506cca 100644 --- a/m4/sigdescr_np.m4 +++ b/m4/sigdescr_np.m4 @@ -1,4 +1,4 @@ -# sigdescr_np.m4 serial 1 +# sigdescr_np.m4 serial 2 dnl Copyright (C) 2020-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_SIGDESCR_NP], dnl Persuade glibc to declare sigdescr_np(). AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_REQUIRE([gl_STRING_H_DEFAULTS]) AC_CHECK_FUNCS([sigdescr_np]) if test $ac_cv_func_sigdescr_np = no; then HAVE_SIGDESCR_NP=0 diff --git a/m4/signal_h.m4 b/m4/signal_h.m4 index ff9f0251fd9..8b938809b7c 100644 --- a/m4/signal_h.m4 +++ b/m4/signal_h.m4 @@ -1,10 +1,10 @@ -# signal_h.m4 serial 19 +# signal_h.m4 serial 22 dnl Copyright (C) 2007-2021 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. -AC_DEFUN([gl_SIGNAL_H], +AC_DEFUN_ONCE([gl_SIGNAL_H], [ AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) AC_REQUIRE([gl_CHECK_TYPE_SIGSET_T]) @@ -52,22 +52,37 @@ AC_DEFUN([gl_CHECK_TYPE_SIGSET_T], fi ]) +# gl_SIGNAL_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. AC_DEFUN([gl_SIGNAL_MODULE_INDICATOR], [ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) + dnl Ensure to expand the default settings once only. + gl_SIGNAL_H_REQUIRE_DEFAULTS gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SIGNAL_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SIGNAL_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_SIGMASK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RAISE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGNAL_H_SIGPIPE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGPROCMASK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGACTION]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SIGNAL_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) +]) + AC_DEFUN([gl_SIGNAL_H_DEFAULTS], [ - GNULIB_PTHREAD_SIGMASK=0; AC_SUBST([GNULIB_PTHREAD_SIGMASK]) - GNULIB_RAISE=0; AC_SUBST([GNULIB_RAISE]) - GNULIB_SIGNAL_H_SIGPIPE=0; AC_SUBST([GNULIB_SIGNAL_H_SIGPIPE]) - GNULIB_SIGPROCMASK=0; AC_SUBST([GNULIB_SIGPROCMASK]) - GNULIB_SIGACTION=0; AC_SUBST([GNULIB_SIGACTION]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_POSIX_SIGNALBLOCKING=1; AC_SUBST([HAVE_POSIX_SIGNALBLOCKING]) HAVE_PTHREAD_SIGMASK=1; AC_SUBST([HAVE_PTHREAD_SIGMASK]) diff --git a/m4/stdalign.m4 b/m4/stdalign.m4 index 8dcb634d55b..e22d7f78c06 100644 --- a/m4/stdalign.m4 +++ b/m4/stdalign.m4 @@ -13,7 +13,8 @@ AC_DEFUN([gl_STDALIGN_H], [gl_cv_header_working_stdalign_h], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( - [[#include + [[#include + #include #include /* Test that alignof yields a result consistent with offsetof. @@ -32,6 +33,7 @@ AC_DEFUN([gl_STDALIGN_H], /* Test _Alignas only on platforms where gnulib can help. */ #if \ ((defined __cplusplus && 201103 <= __cplusplus) \ + || (__TINYC__ && defined __attribute__) \ || (defined __APPLE__ && defined __MACH__ \ ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \ : __GNUC__) \ diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4 index cd666c4a58c..1303d2e06c7 100644 --- a/m4/stddef_h.m4 +++ b/m4/stddef_h.m4 @@ -1,4 +1,4 @@ -# stddef_h.m4 serial 9 +# stddef_h.m4 serial 11 dnl Copyright (C) 2009-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,7 @@ dnl with or without modifications, as long as this notice is preserved. dnl A placeholder for , for platforms that have issues. -AC_DEFUN([gl_STDDEF_H], +AC_DEFUN_ONCE([gl_STDDEF_H], [ AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) AC_REQUIRE([gt_TYPE_WCHAR_T]) @@ -68,13 +68,28 @@ AC_DEFUN([gl_STDDEF_H], fi ]) +# gl_STDDEF_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. AC_DEFUN([gl_STDDEF_MODULE_INDICATOR], [ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) + dnl Ensure to expand the default settings once only. + gl_STDDEF_H_REQUIRE_DEFAULTS gl_MODULE_INDICATOR_SET_VARIABLE([$1]) ]) +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_STDDEF_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDDEF_H_MODULE_INDICATOR_DEFAULTS], [ + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_STDDEF_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) +]) + AC_DEFUN([gl_STDDEF_H_DEFAULTS], [ dnl Assume proper GNU behavior unless another module says otherwise. diff --git a/m4/stdint.m4 b/m4/stdint.m4 index a785b44ed17..2eb1652d8e2 100644 --- a/m4/stdint.m4 +++ b/m4/stdint.m4 @@ -1,4 +1,4 @@ -# stdint.m4 serial 58 +# stdint.m4 serial 60 dnl Copyright (C) 2001-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -170,7 +170,7 @@ struct s { PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t) && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t) ? 1 : -1; - /* Detect bug in FreeBSD 6.0 / ia64. */ + /* Detect bug in FreeBSD 6.0/ia64 and FreeBSD 13.0/arm64. */ int check_SIG_ATOMIC: SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t) && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t) @@ -527,7 +527,7 @@ AC_DEFUN([gl_STDINT_TYPE_PROPERTIES], dnl requirement that wint_t is "unchanged by default argument promotions". dnl In this case gnulib's and override wint_t. dnl Set the variable BITSIZEOF_WINT_T accordingly. - if test $GNULIB_OVERRIDES_WINT_T = 1; then + if test $GNULIBHEADERS_OVERRIDE_WINT_T = 1; then BITSIZEOF_WINT_T=32 fi ]) diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4 index 4c3f24accaa..e704383862d 100644 --- a/m4/stdio_h.m4 +++ b/m4/stdio_h.m4 @@ -1,11 +1,12 @@ -# stdio_h.m4 serial 52 +# stdio_h.m4 serial 56 dnl Copyright (C) 2007-2021 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. -AC_DEFUN([gl_STDIO_H], +AC_DEFUN_ONCE([gl_STDIO_H], [ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) AH_VERBATIM([MINGW_ANSI_STDIO], [/* Use GNU style printf and scanf. */ #ifndef __USE_MINGW_ANSI_STDIO @@ -13,7 +14,6 @@ AC_DEFUN([gl_STDIO_H], #endif ]) AC_DEFINE([__USE_MINGW_ANSI_STDIO]) - AC_REQUIRE([gl_STDIO_H_DEFAULTS]) gl_NEXT_HEADERS([stdio.h]) dnl Determine whether __USE_MINGW_ANSI_STDIO makes printf and @@ -40,17 +40,6 @@ AC_DEFUN([gl_STDIO_H], attribute "__gnu_printf__" instead of "__printf__"]) fi - dnl No need to create extra modules for these functions. Everyone who uses - dnl likely needs them. - GNULIB_FSCANF=1 - gl_MODULE_INDICATOR([fscanf]) - GNULIB_SCANF=1 - gl_MODULE_INDICATOR([scanf]) - GNULIB_FGETC=1 - GNULIB_GETC=1 - GNULIB_GETCHAR=1 - GNULIB_FGETS=1 - GNULIB_FREAD=1 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-read.c" dnl "expected source file, required through AC_LIBSOURCES, not found". It is dnl also an optimization, to avoid performing a configure check whose result @@ -64,18 +53,6 @@ AC_DEFUN([gl_STDIO_H], fi ]) - dnl No need to create extra modules for these functions. Everyone who uses - dnl likely needs them. - GNULIB_FPRINTF=1 - GNULIB_PRINTF=1 - GNULIB_VFPRINTF=1 - GNULIB_VPRINTF=1 - GNULIB_FPUTC=1 - GNULIB_PUTC=1 - GNULIB_PUTCHAR=1 - GNULIB_FPUTS=1 - GNULIB_PUTS=1 - GNULIB_FWRITE=1 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c" dnl "expected source file, required through AC_LIBSOURCES, not found". It is dnl also an optimization, to avoid performing a configure check whose result @@ -116,77 +93,92 @@ AC_DEFUN([gl_STDIO_H], fi ]) +# gl_STDIO_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. AC_DEFUN([gl_STDIO_MODULE_INDICATOR], [ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + dnl Ensure to expand the default settings once only. + gl_STDIO_H_REQUIRE_DEFAULTS gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_STDIO_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDIO_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCLOSE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDOPEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFLUSH]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPURGE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPUTC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPUTS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREAD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREOPEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSCANF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSEEK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSEEKO]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELLO]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FWRITE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETCHAR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDELIM]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLINE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PCLOSE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PERROR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POPEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PRINTF_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTCHAR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMOVE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RENAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RENAMEAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCANF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SNPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SPRINTF_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_NONBLOCKING]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_SIGPIPE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TMPFILE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VASPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFSCANF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSCANF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VDPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSNPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSPRINTF_POSIX]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FCLOSEALL], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FDOPEN], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FILENO], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETW], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_PUTW], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TEMPNAM], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_STDIO_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) +]) + AC_DEFUN([gl_STDIO_H_DEFAULTS], [ - GNULIB_DPRINTF=0; AC_SUBST([GNULIB_DPRINTF]) - GNULIB_FCLOSE=0; AC_SUBST([GNULIB_FCLOSE]) - GNULIB_FDOPEN=0; AC_SUBST([GNULIB_FDOPEN]) - GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH]) - GNULIB_FGETC=0; AC_SUBST([GNULIB_FGETC]) - GNULIB_FGETS=0; AC_SUBST([GNULIB_FGETS]) - GNULIB_FOPEN=0; AC_SUBST([GNULIB_FOPEN]) - GNULIB_FPRINTF=0; AC_SUBST([GNULIB_FPRINTF]) - GNULIB_FPRINTF_POSIX=0; AC_SUBST([GNULIB_FPRINTF_POSIX]) - GNULIB_FPURGE=0; AC_SUBST([GNULIB_FPURGE]) - GNULIB_FPUTC=0; AC_SUBST([GNULIB_FPUTC]) - GNULIB_FPUTS=0; AC_SUBST([GNULIB_FPUTS]) - GNULIB_FREAD=0; AC_SUBST([GNULIB_FREAD]) - GNULIB_FREOPEN=0; AC_SUBST([GNULIB_FREOPEN]) - GNULIB_FSCANF=0; AC_SUBST([GNULIB_FSCANF]) - GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK]) - GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO]) - GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL]) - GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO]) - GNULIB_FWRITE=0; AC_SUBST([GNULIB_FWRITE]) - GNULIB_GETC=0; AC_SUBST([GNULIB_GETC]) - GNULIB_GETCHAR=0; AC_SUBST([GNULIB_GETCHAR]) - GNULIB_GETDELIM=0; AC_SUBST([GNULIB_GETDELIM]) - GNULIB_GETLINE=0; AC_SUBST([GNULIB_GETLINE]) - GNULIB_OBSTACK_PRINTF=0; AC_SUBST([GNULIB_OBSTACK_PRINTF]) - GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX]) - GNULIB_PCLOSE=0; AC_SUBST([GNULIB_PCLOSE]) - GNULIB_PERROR=0; AC_SUBST([GNULIB_PERROR]) - GNULIB_POPEN=0; AC_SUBST([GNULIB_POPEN]) - GNULIB_PRINTF=0; AC_SUBST([GNULIB_PRINTF]) - GNULIB_PRINTF_POSIX=0; AC_SUBST([GNULIB_PRINTF_POSIX]) - GNULIB_PUTC=0; AC_SUBST([GNULIB_PUTC]) - GNULIB_PUTCHAR=0; AC_SUBST([GNULIB_PUTCHAR]) - GNULIB_PUTS=0; AC_SUBST([GNULIB_PUTS]) - GNULIB_REMOVE=0; AC_SUBST([GNULIB_REMOVE]) - GNULIB_RENAME=0; AC_SUBST([GNULIB_RENAME]) - GNULIB_RENAMEAT=0; AC_SUBST([GNULIB_RENAMEAT]) - GNULIB_SCANF=0; AC_SUBST([GNULIB_SCANF]) - GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF]) - GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX]) - GNULIB_STDIO_H_NONBLOCKING=0; AC_SUBST([GNULIB_STDIO_H_NONBLOCKING]) - GNULIB_STDIO_H_SIGPIPE=0; AC_SUBST([GNULIB_STDIO_H_SIGPIPE]) - GNULIB_TMPFILE=0; AC_SUBST([GNULIB_TMPFILE]) - GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF]) - GNULIB_VFSCANF=0; AC_SUBST([GNULIB_VFSCANF]) - GNULIB_VSCANF=0; AC_SUBST([GNULIB_VSCANF]) - GNULIB_VDPRINTF=0; AC_SUBST([GNULIB_VDPRINTF]) - GNULIB_VFPRINTF=0; AC_SUBST([GNULIB_VFPRINTF]) - GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX]) - GNULIB_VPRINTF=0; AC_SUBST([GNULIB_VPRINTF]) - GNULIB_VPRINTF_POSIX=0; AC_SUBST([GNULIB_VPRINTF_POSIX]) - GNULIB_VSNPRINTF=0; AC_SUBST([GNULIB_VSNPRINTF]) - GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX]) - dnl Support Microsoft deprecated alias function names by default. - GNULIB_MDA_FCLOSEALL=1; AC_SUBST([GNULIB_MDA_FCLOSEALL]) - GNULIB_MDA_FDOPEN=1; AC_SUBST([GNULIB_MDA_FDOPEN]) - GNULIB_MDA_FILENO=1; AC_SUBST([GNULIB_MDA_FILENO]) - GNULIB_MDA_GETW=1; AC_SUBST([GNULIB_MDA_GETW]) - GNULIB_MDA_PUTW=1; AC_SUBST([GNULIB_MDA_PUTW]) - GNULIB_MDA_TEMPNAM=1; AC_SUBST([GNULIB_MDA_TEMPNAM]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_DECL_FCLOSEALL=1; AC_SUBST([HAVE_DECL_FCLOSEALL]) HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE]) diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4 index 5a02972e05d..9c1d1c76c13 100644 --- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -1,10 +1,10 @@ -# stdlib_h.m4 serial 55 +# stdlib_h.m4 serial 63 dnl Copyright (C) 2007-2021 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. -AC_DEFUN([gl_STDLIB_H], +AC_DEFUN_ONCE([gl_STDLIB_H], [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) gl_NEXT_HEADERS([stdlib.h]) @@ -28,7 +28,7 @@ AC_DEFUN([gl_STDLIB_H], posix_memalign posix_openpt ptsname ptsname_r qsort_r random random_r reallocarray realpath rpmatch secure_getenv setenv setstate setstate_r srandom srandom_r - strtod strtold strtoll strtoull unlockpt unsetenv]) + strtod strtol strtold strtoll strtoul strtoull unlockpt unsetenv]) AC_REQUIRE([AC_C_RESTRICT]) @@ -46,61 +46,78 @@ AC_DEFUN([gl_STDLIB_H], fi ]) +# gl_STDLIB_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], [ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + dnl Ensure to expand the default settings once only. + gl_STDLIB_H_REQUIRE_DEFAULTS gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB__EXIT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALIGNED_ALLOC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATOLL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CANONICALIZE_FILE_NAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREE_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOADAVG]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSUBOPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GRANTPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBTOWC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDTEMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMPS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKSTEMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKSTEMPS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_MEMALIGN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_OPENPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTSNAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTSNAME_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTENV]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_QSORT_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOCARRAY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALPATH]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RPMATCH]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SECURE_GETENV]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETENV]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOUL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOULL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYSTEM_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLOCKPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNSETENV]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTOMB]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ECVT], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FCVT], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GCVT], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MKTEMP], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_PUTENV], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) +]) + AC_DEFUN([gl_STDLIB_H_DEFAULTS], [ - GNULIB__EXIT=0; AC_SUBST([GNULIB__EXIT]) - GNULIB_ALIGNED_ALLOC=0; AC_SUBST([GNULIB_ALIGNED_ALLOC]) - GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL]) - GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX]) - GNULIB_CANONICALIZE_FILE_NAME=0; AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME]) - GNULIB_FREE_POSIX=0; AC_SUBST([GNULIB_FREE_POSIX]) - GNULIB_GETLOADAVG=0; AC_SUBST([GNULIB_GETLOADAVG]) - GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT]) - GNULIB_GRANTPT=0; AC_SUBST([GNULIB_GRANTPT]) - GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX]) - GNULIB_MBTOWC=0; AC_SUBST([GNULIB_MBTOWC]) - GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP]) - GNULIB_MKOSTEMP=0; AC_SUBST([GNULIB_MKOSTEMP]) - GNULIB_MKOSTEMPS=0; AC_SUBST([GNULIB_MKOSTEMPS]) - GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP]) - GNULIB_MKSTEMPS=0; AC_SUBST([GNULIB_MKSTEMPS]) - GNULIB_POSIX_MEMALIGN=0;AC_SUBST([GNULIB_POSIX_MEMALIGN]) - GNULIB_POSIX_OPENPT=0; AC_SUBST([GNULIB_POSIX_OPENPT]) - GNULIB_PTSNAME=0; AC_SUBST([GNULIB_PTSNAME]) - GNULIB_PTSNAME_R=0; AC_SUBST([GNULIB_PTSNAME_R]) - GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV]) - GNULIB_QSORT_R=0; AC_SUBST([GNULIB_QSORT_R]) - GNULIB_RANDOM=0; AC_SUBST([GNULIB_RANDOM]) - GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R]) - GNULIB_REALLOCARRAY=0; AC_SUBST([GNULIB_REALLOCARRAY]) - GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX]) - GNULIB_REALPATH=0; AC_SUBST([GNULIB_REALPATH]) - GNULIB_RPMATCH=0; AC_SUBST([GNULIB_RPMATCH]) - GNULIB_SECURE_GETENV=0; AC_SUBST([GNULIB_SECURE_GETENV]) - GNULIB_SETENV=0; AC_SUBST([GNULIB_SETENV]) - GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD]) - GNULIB_STRTOLD=0; AC_SUBST([GNULIB_STRTOLD]) - GNULIB_STRTOLL=0; AC_SUBST([GNULIB_STRTOLL]) - GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL]) - GNULIB_SYSTEM_POSIX=0; AC_SUBST([GNULIB_SYSTEM_POSIX]) - GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT]) - GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV]) - GNULIB_WCTOMB=0; AC_SUBST([GNULIB_WCTOMB]) - dnl Support Microsoft deprecated alias function names by default. - GNULIB_MDA_ECVT=1; AC_SUBST([GNULIB_MDA_ECVT]) - GNULIB_MDA_FCVT=1; AC_SUBST([GNULIB_MDA_FCVT]) - GNULIB_MDA_GCVT=1; AC_SUBST([GNULIB_MDA_GCVT]) - GNULIB_MDA_MKTEMP=1; AC_SUBST([GNULIB_MDA_MKTEMP]) - GNULIB_MDA_PUTENV=1; AC_SUBST([GNULIB_MDA_PUTENV]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE__EXIT=1; AC_SUBST([HAVE__EXIT]) HAVE_ALIGNED_ALLOC=1; AC_SUBST([HAVE_ALIGNED_ALLOC]) @@ -137,8 +154,10 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_SETSTATE=1; AC_SUBST([HAVE_SETSTATE]) HAVE_DECL_SETSTATE=1; AC_SUBST([HAVE_DECL_SETSTATE]) HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD]) + HAVE_STRTOL=1; AC_SUBST([HAVE_STRTOL]) HAVE_STRTOLD=1; AC_SUBST([HAVE_STRTOLD]) HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL]) + HAVE_STRTOUL=1; AC_SUBST([HAVE_STRTOUL]) HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL]) HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA]) HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H]) @@ -160,11 +179,16 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], REPLACE_RANDOM=0; AC_SUBST([REPLACE_RANDOM]) REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R]) REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC]) + REPLACE_REALLOCARRAY=0; AC_SUBST([REPLACE_REALLOCARRAY]) REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV]) REPLACE_SETSTATE=0; AC_SUBST([REPLACE_SETSTATE]) REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD]) + REPLACE_STRTOL=0; AC_SUBST([REPLACE_STRTOL]) REPLACE_STRTOLD=0; AC_SUBST([REPLACE_STRTOLD]) + REPLACE_STRTOLL=0; AC_SUBST([REPLACE_STRTOLL]) + REPLACE_STRTOUL=0; AC_SUBST([REPLACE_STRTOUL]) + REPLACE_STRTOULL=0; AC_SUBST([REPLACE_STRTOULL]) REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV]) REPLACE_WCTOMB=0; AC_SUBST([REPLACE_WCTOMB]) ]) diff --git a/m4/stpcpy.m4 b/m4/stpcpy.m4 index 28db4f45dfe..eb44f03adba 100644 --- a/m4/stpcpy.m4 +++ b/m4/stpcpy.m4 @@ -1,4 +1,4 @@ -# stpcpy.m4 serial 8 +# stpcpy.m4 serial 9 dnl Copyright (C) 2002, 2007, 2009-2021 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,7 +12,7 @@ AC_DEFUN([gl_FUNC_STPCPY], dnl The stpcpy() declaration in lib/string.in.h uses 'restrict'. AC_REQUIRE([AC_C_RESTRICT]) - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_REQUIRE([gl_STRING_H_DEFAULTS]) AC_CHECK_FUNCS([stpcpy]) if test $ac_cv_func_stpcpy = no; then HAVE_STPCPY=0 diff --git a/m4/string_h.m4 b/m4/string_h.m4 index a4cc5b43783..e88ac9ca853 100644 --- a/m4/string_h.m4 +++ b/m4/string_h.m4 @@ -5,20 +5,15 @@ # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 29 +# serial 34 # Written by Paul Eggert. -AC_DEFUN([gl_HEADER_STRING_H], +AC_DEFUN_ONCE([gl_STRING_H], [ - dnl Use AC_REQUIRE here, so that the default behavior below is expanded - dnl once only, before all statements that occur in other macros. - AC_REQUIRE([gl_HEADER_STRING_H_BODY]) -]) - -AC_DEFUN([gl_HEADER_STRING_H_BODY], -[ - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_STRING_H_DEFAULTS]) gl_NEXT_HEADERS([string.h]) dnl Check for declarations of anything we want to poison if the @@ -33,62 +28,79 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY], AC_REQUIRE([AC_C_RESTRICT]) ]) +# gl_STRING_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. AC_DEFUN([gl_STRING_MODULE_INDICATOR], [ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + dnl Ensure to expand the default settings once only. + gl_STRING_H_REQUIRE_DEFAULTS gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) -AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_STRING_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_STRING_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPLICIT_BZERO]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFSL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFSLL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMCHR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMMEM]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMPCPY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMRCHR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RAWMEMCHR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STPCPY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STPNCPY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCHRNUL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRDUP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNCAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNDUP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNLEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPBRK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSEP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSTR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCASESTR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOK_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSLEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNLEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCHR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSRCHR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSTR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCASECMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNCASECMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSPCASECMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCASESTR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCSPN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSPBRK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSPN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSEP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSTOK_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERRORNAME_NP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGABBREV_NP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGDESCR_NP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSIGNAL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRVERSCMP]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MEMCCPY], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_STRDUP], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_STRING_H_MODULE_INDICATOR_DEFAULTS]) + dnl Make sure the shell variable for GNULIB_FREE_POSIX is initialized. + gl_STDLIB_H_REQUIRE_DEFAULTS + AC_REQUIRE([gl_STRING_H_DEFAULTS]) +]) + +AC_DEFUN([gl_STRING_H_DEFAULTS], [ - GNULIB_EXPLICIT_BZERO=0; AC_SUBST([GNULIB_EXPLICIT_BZERO]) - GNULIB_FFSL=0; AC_SUBST([GNULIB_FFSL]) - GNULIB_FFSLL=0; AC_SUBST([GNULIB_FFSLL]) - GNULIB_MEMCHR=0; AC_SUBST([GNULIB_MEMCHR]) - GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM]) - GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY]) - GNULIB_MEMRCHR=0; AC_SUBST([GNULIB_MEMRCHR]) - GNULIB_RAWMEMCHR=0; AC_SUBST([GNULIB_RAWMEMCHR]) - GNULIB_STPCPY=0; AC_SUBST([GNULIB_STPCPY]) - GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY]) - GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL]) - GNULIB_STRDUP=0; AC_SUBST([GNULIB_STRDUP]) - GNULIB_STRNCAT=0; AC_SUBST([GNULIB_STRNCAT]) - GNULIB_STRNDUP=0; AC_SUBST([GNULIB_STRNDUP]) - GNULIB_STRNLEN=0; AC_SUBST([GNULIB_STRNLEN]) - GNULIB_STRPBRK=0; AC_SUBST([GNULIB_STRPBRK]) - GNULIB_STRSEP=0; AC_SUBST([GNULIB_STRSEP]) - GNULIB_STRSTR=0; AC_SUBST([GNULIB_STRSTR]) - GNULIB_STRCASESTR=0; AC_SUBST([GNULIB_STRCASESTR]) - GNULIB_STRTOK_R=0; AC_SUBST([GNULIB_STRTOK_R]) - GNULIB_MBSLEN=0; AC_SUBST([GNULIB_MBSLEN]) - GNULIB_MBSNLEN=0; AC_SUBST([GNULIB_MBSNLEN]) - GNULIB_MBSCHR=0; AC_SUBST([GNULIB_MBSCHR]) - GNULIB_MBSRCHR=0; AC_SUBST([GNULIB_MBSRCHR]) - GNULIB_MBSSTR=0; AC_SUBST([GNULIB_MBSSTR]) - GNULIB_MBSCASECMP=0; AC_SUBST([GNULIB_MBSCASECMP]) - GNULIB_MBSNCASECMP=0; AC_SUBST([GNULIB_MBSNCASECMP]) - GNULIB_MBSPCASECMP=0; AC_SUBST([GNULIB_MBSPCASECMP]) - GNULIB_MBSCASESTR=0; AC_SUBST([GNULIB_MBSCASESTR]) - GNULIB_MBSCSPN=0; AC_SUBST([GNULIB_MBSCSPN]) - GNULIB_MBSPBRK=0; AC_SUBST([GNULIB_MBSPBRK]) - GNULIB_MBSSPN=0; AC_SUBST([GNULIB_MBSSPN]) - GNULIB_MBSSEP=0; AC_SUBST([GNULIB_MBSSEP]) - GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R]) - GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR]) - GNULIB_STRERROR_R=0; AC_SUBST([GNULIB_STRERROR_R]) - GNULIB_STRERRORNAME_NP=0; AC_SUBST([GNULIB_STRERRORNAME_NP]) - GNULIB_SIGABBREV_NP=0; AC_SUBST([GNULIB_SIGABBREV_NP]) - GNULIB_SIGDESCR_NP=0; AC_SUBST([GNULIB_SIGDESCR_NP]) - GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL]) - GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP]) HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN]) - dnl Support Microsoft deprecated alias function names by default. - GNULIB_MDA_MEMCCPY=1; AC_SUBST([GNULIB_MDA_MEMCCPY]) - GNULIB_MDA_STRDUP=1; AC_SUBST([GNULIB_MDA_STRDUP]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_EXPLICIT_BZERO=1; AC_SUBST([HAVE_EXPLICIT_BZERO]) HAVE_FFSL=1; AC_SUBST([HAVE_FFSL]) diff --git a/m4/strnlen.m4 b/m4/strnlen.m4 index bb9a680fdc4..1d4f10616e2 100644 --- a/m4/strnlen.m4 +++ b/m4/strnlen.m4 @@ -1,4 +1,4 @@ -# strnlen.m4 serial 13 +# strnlen.m4 serial 14 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2021 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_STRNLEN], [ - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_REQUIRE([gl_STRING_H_DEFAULTS]) dnl Persuade glibc to declare strnlen(). AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) diff --git a/m4/strtoll.m4 b/m4/strtoll.m4 index d2c9e5310d1..14455dc3db9 100644 --- a/m4/strtoll.m4 +++ b/m4/strtoll.m4 @@ -1,4 +1,4 @@ -# strtoll.m4 serial 8 +# strtoll.m4 serial 9 dnl Copyright (C) 2002, 2004, 2006, 2008-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,8 +7,40 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_STRTOLL], [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) AC_CHECK_FUNCS([strtoll]) - if test $ac_cv_func_strtoll = no; then + if test $ac_cv_func_strtoll = yes; then + AC_CACHE_CHECK([whether strtoll works], + [gl_cv_func_strtoll_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[int result = 0; + char *term; + /* This test fails on Minix and native Windows. */ + { + const char input[] = "0x"; + (void) strtoll (input, &term, 16); + if (term != input + 1) + result |= 1; + } + return result; + ]]) + ], + [gl_cv_func_strtoll_works=yes], + [gl_cv_func_strtoll_works=no], + [case "$host_os" in + # Guess no on native Windows. + mingw*) gl_cv_func_strtoll_works="guessing no" ;; + *) gl_cv_func_strtoll_works="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case "$gl_cv_func_strtoll_works" in + *yes) ;; + *) REPLACE_STRTOLL=1 ;; + esac + else HAVE_STRTOLL=0 fi ]) diff --git a/m4/sys_random_h.m4 b/m4/sys_random_h.m4 index 45e0469ba05..37bc31606bd 100644 --- a/m4/sys_random_h.m4 +++ b/m4/sys_random_h.m4 @@ -1,10 +1,10 @@ -# sys_random_h.m4 serial 5 +# sys_random_h.m4 serial 8 dnl Copyright (C) 2020-2021 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. -AC_DEFUN([gl_HEADER_SYS_RANDOM], +AC_DEFUN_ONCE([gl_SYS_RANDOM_H], [ AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS]) dnl is always overridden, because of GNULIB_POSIXCHECK. @@ -35,18 +35,33 @@ AC_DEFUN([gl_HEADER_SYS_RANDOM], [getrandom]) ]) +# gl_SYS_RANDOM_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. AC_DEFUN([gl_SYS_RANDOM_MODULE_INDICATOR], [ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS]) + dnl Ensure to expand the default settings once only. + gl_SYS_RANDOM_H_REQUIRE_DEFAULTS gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SYS_RANDOM_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_RANDOM_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETRANDOM]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_RANDOM_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS]) +]) + AC_DEFUN([gl_SYS_RANDOM_H_DEFAULTS], [ - GNULIB_GETRANDOM=0; AC_SUBST([GNULIB_GETRANDOM]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_GETRANDOM=1; AC_SUBST([HAVE_GETRANDOM]) REPLACE_GETRANDOM=0; AC_SUBST([REPLACE_GETRANDOM]) diff --git a/m4/sys_select_h.m4 b/m4/sys_select_h.m4 index 4b33d312e55..2e7d140dee2 100644 --- a/m4/sys_select_h.m4 +++ b/m4/sys_select_h.m4 @@ -1,13 +1,13 @@ -# sys_select_h.m4 serial 20 +# sys_select_h.m4 serial 23 dnl Copyright (C) 2006-2021 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. -AC_DEFUN([gl_HEADER_SYS_SELECT], +AC_DEFUN_ONCE([gl_SYS_SELECT_H], [ - AC_REQUIRE([AC_C_RESTRICT]) AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS]) + AC_REQUIRE([AC_C_RESTRICT]) AC_CACHE_CHECK([whether is self-contained], [gl_cv_header_sys_select_h_selfcontained], [ @@ -75,19 +75,34 @@ AC_DEFUN([gl_HEADER_SYS_SELECT], ]], [pselect select]) ]) +# gl_SYS_SELECT_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. AC_DEFUN([gl_SYS_SELECT_MODULE_INDICATOR], [ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS]) + dnl Ensure to expand the default settings once only. + gl_SYS_SELECT_H_REQUIRE_DEFAULTS gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SYS_SELECT_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_SELECT_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PSELECT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SELECT]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_SELECT_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS]) +]) + AC_DEFUN([gl_SYS_SELECT_H_DEFAULTS], [ - GNULIB_PSELECT=0; AC_SUBST([GNULIB_PSELECT]) - GNULIB_SELECT=0; AC_SUBST([GNULIB_SELECT]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_PSELECT=1; AC_SUBST([HAVE_PSELECT]) REPLACE_PSELECT=0; AC_SUBST([REPLACE_PSELECT]) diff --git a/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4 index 503cb9668b7..5676a0d2170 100644 --- a/m4/sys_socket_h.m4 +++ b/m4/sys_socket_h.m4 @@ -1,4 +1,4 @@ -# sys_socket_h.m4 serial 25 +# sys_socket_h.m4 serial 28 dnl Copyright (C) 2005-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,7 @@ dnl with or without modifications, as long as this notice is preserved. dnl From Simon Josefsson. -AC_DEFUN([gl_HEADER_SYS_SOCKET], +AC_DEFUN_ONCE([gl_SYS_SOCKET_H], [ AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) @@ -156,32 +156,47 @@ AC_DEFUN([gl_PREREQ_SYS_H_WS2TCPIP], AC_SUBST([HAVE_WS2TCPIP_H]) ]) +# gl_SYS_SOCKET_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR], [ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) + dnl Ensure to expand the default settings once only. + gl_SYS_SOCKET_H_REQUIRE_DEFAULTS gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SYS_SOCKET_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_SOCKET_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SOCKET]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CONNECT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCEPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_BIND]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPEERNAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSOCKNAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSOCKOPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LISTEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RECV]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SEND]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RECVFROM]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SENDTO]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETSOCKOPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SHUTDOWN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCEPT4]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_SOCKET_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) +]) + AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS], [ - GNULIB_SOCKET=0; AC_SUBST([GNULIB_SOCKET]) - GNULIB_CONNECT=0; AC_SUBST([GNULIB_CONNECT]) - GNULIB_ACCEPT=0; AC_SUBST([GNULIB_ACCEPT]) - GNULIB_BIND=0; AC_SUBST([GNULIB_BIND]) - GNULIB_GETPEERNAME=0; AC_SUBST([GNULIB_GETPEERNAME]) - GNULIB_GETSOCKNAME=0; AC_SUBST([GNULIB_GETSOCKNAME]) - GNULIB_GETSOCKOPT=0; AC_SUBST([GNULIB_GETSOCKOPT]) - GNULIB_LISTEN=0; AC_SUBST([GNULIB_LISTEN]) - GNULIB_RECV=0; AC_SUBST([GNULIB_RECV]) - GNULIB_SEND=0; AC_SUBST([GNULIB_SEND]) - GNULIB_RECVFROM=0; AC_SUBST([GNULIB_RECVFROM]) - GNULIB_SENDTO=0; AC_SUBST([GNULIB_SENDTO]) - GNULIB_SETSOCKOPT=0; AC_SUBST([GNULIB_SETSOCKOPT]) - GNULIB_SHUTDOWN=0; AC_SUBST([GNULIB_SHUTDOWN]) - GNULIB_ACCEPT4=0; AC_SUBST([GNULIB_ACCEPT4]) HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE]) HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY]) diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4 index 23cbdd28eb2..ac91d425bbb 100644 --- a/m4/sys_stat_h.m4 +++ b/m4/sys_stat_h.m4 @@ -1,4 +1,4 @@ -# sys_stat_h.m4 serial 38 -*- Autoconf -*- +# sys_stat_h.m4 serial 41 -*- Autoconf -*- dnl Copyright (C) 2006-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. dnl From Eric Blake. dnl Provide a GNU-like . -AC_DEFUN([gl_HEADER_SYS_STAT_H], +AC_DEFUN_ONCE([gl_SYS_STAT_H], [ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) @@ -52,38 +52,53 @@ AC_DEFUN([gl_HEADER_SYS_STAT_H], AC_REQUIRE([AC_C_RESTRICT]) ]) +# gl_SYS_STAT_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR], [ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + dnl Ensure to expand the default settings once only. + gl_SYS_STAT_H_REQUIRE_DEFAULTS gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SYS_STAT_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_STAT_H_MODULE_INDICATOR_DEFAULTS], [ + gl_UNISTD_H_REQUIRE_DEFAULTS dnl for REPLACE_FCHDIR + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHMODAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTATAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FUTIMENS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETUMASK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LCHMOD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LSTAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDIRAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKFIFO]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKFIFOAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKNOD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKNODAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UTIMENSAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OVERRIDES_STRUCT_STAT]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CHMOD], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MKDIR], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_UMASK], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_STAT_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) +]) + AC_DEFUN([gl_SYS_STAT_H_DEFAULTS], [ - AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR - GNULIB_FCHMODAT=0; AC_SUBST([GNULIB_FCHMODAT]) - GNULIB_FSTAT=0; AC_SUBST([GNULIB_FSTAT]) - GNULIB_FSTATAT=0; AC_SUBST([GNULIB_FSTATAT]) - GNULIB_FUTIMENS=0; AC_SUBST([GNULIB_FUTIMENS]) - GNULIB_GETUMASK=0; AC_SUBST([GNULIB_GETUMASK]) - GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD]) - GNULIB_LSTAT=0; AC_SUBST([GNULIB_LSTAT]) - GNULIB_MKDIR=0; AC_SUBST([GNULIB_MKDIR]) - GNULIB_MKDIRAT=0; AC_SUBST([GNULIB_MKDIRAT]) - GNULIB_MKFIFO=0; AC_SUBST([GNULIB_MKFIFO]) - GNULIB_MKFIFOAT=0; AC_SUBST([GNULIB_MKFIFOAT]) - GNULIB_MKNOD=0; AC_SUBST([GNULIB_MKNOD]) - GNULIB_MKNODAT=0; AC_SUBST([GNULIB_MKNODAT]) - GNULIB_STAT=0; AC_SUBST([GNULIB_STAT]) - GNULIB_UTIMENSAT=0; AC_SUBST([GNULIB_UTIMENSAT]) - GNULIB_OVERRIDES_STRUCT_STAT=0; AC_SUBST([GNULIB_OVERRIDES_STRUCT_STAT]) - dnl Support Microsoft deprecated alias function names by default. - GNULIB_MDA_CHMOD=1; AC_SUBST([GNULIB_MDA_CHMOD]) - GNULIB_MDA_MKDIR=1; AC_SUBST([GNULIB_MDA_MKDIR]) - GNULIB_MDA_UMASK=1; AC_SUBST([GNULIB_MDA_UMASK]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT]) HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT]) diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4 index 64f133d5133..c425a9639a1 100644 --- a/m4/sys_time_h.m4 +++ b/m4/sys_time_h.m4 @@ -1,5 +1,5 @@ # Configure a replacement for . -# serial 9 +# serial 12 # Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -8,18 +8,13 @@ # Written by Paul Eggert and Martin Lambers. -AC_DEFUN([gl_HEADER_SYS_TIME_H], +AC_DEFUN_ONCE([gl_SYS_TIME_H], [ dnl Use AC_REQUIRE here, so that the REPLACE_GETTIMEOFDAY=0 statement dnl below is expanded once only, before all REPLACE_GETTIMEOFDAY=1 dnl statements that occur in other macros. - AC_REQUIRE([gl_HEADER_SYS_TIME_H_BODY]) -]) - -AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY], -[ + AC_REQUIRE([gl_SYS_TIME_H_DEFAULTS]) AC_REQUIRE([AC_C_RESTRICT]) - AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) AC_CHECK_HEADERS_ONCE([sys/time.h]) gl_CHECK_NEXT_HEADERS([sys/time.h]) @@ -89,18 +84,33 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY], ]], [gettimeofday]) ]) +# gl_SYS_TIME_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. AC_DEFUN([gl_SYS_TIME_MODULE_INDICATOR], [ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) + dnl Ensure to expand the default settings once only. + gl_SYS_TIME_H_REQUIRE_DEFAULTS gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) -AC_DEFUN([gl_HEADER_SYS_TIME_H_DEFAULTS], +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SYS_TIME_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_TIME_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETTIMEOFDAY]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_TIME_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SYS_TIME_H_DEFAULTS]) +]) + +AC_DEFUN([gl_SYS_TIME_H_DEFAULTS], [ - GNULIB_GETTIMEOFDAY=0; AC_SUBST([GNULIB_GETTIMEOFDAY]) dnl Assume POSIX behavior unless another module says otherwise. HAVE_GETTIMEOFDAY=1; AC_SUBST([HAVE_GETTIMEOFDAY]) HAVE_STRUCT_TIMEVAL=1; AC_SUBST([HAVE_STRUCT_TIMEVAL]) diff --git a/m4/sys_types_h.m4 b/m4/sys_types_h.m4 index 2172c836d95..6dd6fee10c8 100644 --- a/m4/sys_types_h.m4 +++ b/m4/sys_types_h.m4 @@ -1,4 +1,4 @@ -# sys_types_h.m4 serial 11 +# sys_types_h.m4 serial 13 dnl Copyright (C) 2011-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,10 +6,11 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN_ONCE([gl_SYS_TYPES_H], [ + AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS]) + dnl Use sane struct stat types in OpenVMS 8.2 and later. AC_DEFINE([_USE_STD_STAT], 1, [For standard stat data types on VMS.]) - AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS]) gl_NEXT_HEADERS([sys/types.h]) dnl Ensure the type pid_t gets defined. @@ -30,6 +31,17 @@ AC_DEFUN_ONCE([gl_SYS_TYPES_H], AC_SUBST([WINDOWS_STAT_INODES]) ]) +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SYS_TYPES_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_TYPE_H_MODULE_INDICATOR_DEFAULTS], [ + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_TYPE_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS]) +]) + AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS], [ ]) diff --git a/m4/time_h.m4 b/m4/time_h.m4 index b6a1aa3bc0f..b57474b48b3 100644 --- a/m4/time_h.m4 +++ b/m4/time_h.m4 @@ -2,7 +2,7 @@ # Copyright (C) 2000-2001, 2003-2007, 2009-2021 Free Software Foundation, Inc. -# serial 15 +# serial 18 # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -10,16 +10,11 @@ # Written by Paul Eggert and Jim Meyering. -AC_DEFUN([gl_HEADER_TIME_H], +AC_DEFUN_ONCE([gl_TIME_H], [ - dnl Use AC_REQUIRE here, so that the default behavior below is expanded - dnl once only, before all statements that occur in other macros. - AC_REQUIRE([gl_HEADER_TIME_H_BODY]) -]) - -AC_DEFUN([gl_HEADER_TIME_H_BODY], -[ - AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_TIME_H_DEFAULTS]) gl_NEXT_HEADERS([time.h]) AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC]) @@ -111,30 +106,45 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], AC_SUBST([UNISTD_H_DEFINES_STRUCT_TIMESPEC]) ]) +# gl_TIME_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. AC_DEFUN([gl_TIME_MODULE_INDICATOR], [ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) + dnl Ensure to expand the default settings once only. + gl_TIME_H_REQUIRE_DEFAULTS gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) -AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_TIME_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_TIME_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CTIME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKTIME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALTIME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NANOSLEEP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRFTIME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPTIME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMEGM]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GET]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_RZ]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TZSET]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TZSET], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_TIME_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_TIME_H_DEFAULTS]) +]) + +AC_DEFUN([gl_TIME_H_DEFAULTS], [ - GNULIB_CTIME=0; AC_SUBST([GNULIB_CTIME]) - GNULIB_MKTIME=0; AC_SUBST([GNULIB_MKTIME]) - GNULIB_LOCALTIME=0; AC_SUBST([GNULIB_LOCALTIME]) - GNULIB_NANOSLEEP=0; AC_SUBST([GNULIB_NANOSLEEP]) - GNULIB_STRFTIME=0; AC_SUBST([GNULIB_STRFTIME]) - GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME]) - GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM]) - GNULIB_TIMESPEC_GET=0; AC_SUBST([GNULIB_TIMESPEC_GET]) - GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R]) - GNULIB_TIME_RZ=0; AC_SUBST([GNULIB_TIME_RZ]) - GNULIB_TZSET=0; AC_SUBST([GNULIB_TZSET]) - dnl Support Microsoft deprecated alias function names by default. - GNULIB_MDA_TZSET=1; AC_SUBST([GNULIB_MDA_TZSET]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R]) HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) diff --git a/m4/time_r.m4 b/m4/time_r.m4 index 713e93ac263..2d49b64f12c 100644 --- a/m4/time_r.m4 +++ b/m4/time_r.m4 @@ -12,7 +12,7 @@ AC_DEFUN([gl_TIME_R], dnl Persuade glibc and Solaris to declare localtime_r. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) + AC_REQUIRE([gl_TIME_H_DEFAULTS]) AC_REQUIRE([AC_C_RESTRICT]) dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is diff --git a/m4/time_rz.m4 b/m4/time_rz.m4 index 34ef0bab4b9..c5e85dc625e 100644 --- a/m4/time_rz.m4 +++ b/m4/time_rz.m4 @@ -10,7 +10,7 @@ dnl Written by Paul Eggert. AC_DEFUN([gl_TIME_RZ], [ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) + AC_REQUIRE([gl_TIME_H_DEFAULTS]) AC_REQUIRE([AC_STRUCT_TIMEZONE]) # On Mac OS X 10.6, localtime loops forever with some time_t values. diff --git a/m4/timegm.m4 b/m4/timegm.m4 index 098c857e7f2..58123beb0cc 100644 --- a/m4/timegm.m4 +++ b/m4/timegm.m4 @@ -1,4 +1,4 @@ -# timegm.m4 serial 12 +# timegm.m4 serial 13 dnl Copyright (C) 2003, 2007, 2009-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,7 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_TIMEGM], [ - AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) + AC_REQUIRE([gl_TIME_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_MKTIME_WORKS]) REPLACE_TIMEGM=0 AC_CHECK_FUNCS_ONCE([timegm]) diff --git a/m4/timer_time.m4 b/m4/timer_time.m4 index f0e5785e9aa..003e36e9d14 100644 --- a/m4/timer_time.m4 +++ b/m4/timer_time.m4 @@ -1,4 +1,4 @@ -# timer_time.m4 serial 4 +# timer_time.m4 serial 5 dnl Copyright (C) 2011-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -18,9 +18,13 @@ AC_DEFUN([gl_TIMER_TIME], dnl the threadlib.m4 file that is installed in $PREFIX/share/aclocal/. m4_ifdef([gl_][PTHREADLIB], [AC_REQUIRE([gl_][PTHREADLIB])]) + AC_CHECK_DECL([timer_settime], [], [], + [[#include + ]]) LIB_TIMER_TIME= AC_SUBST([LIB_TIMER_TIME]) - gl_saved_libs=$LIBS + AS_IF([test "$ac_cv_have_decl_timer_settime" = yes], [ + gl_saved_libs=$LIBS AC_SEARCH_LIBS([timer_settime], [rt posix4], [test "$ac_cv_search_timer_settime" = "none required" || LIB_TIMER_TIME=$ac_cv_search_timer_settime]) @@ -40,5 +44,6 @@ AC_DEFUN([gl_TIMER_TIME], ], [LIB_TIMER_TIME="$LIB_TIMER_TIME $LIBPMULTITHREAD"])]) AC_CHECK_FUNCS([timer_settime]) - LIBS=$gl_saved_libs + LIBS=$gl_saved_libs + ]) ]) diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index 0f26fb908d3..0ce4ea4511f 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 85 +# unistd_h.m4 serial 89 dnl Copyright (C) 2006-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,10 +6,10 @@ dnl with or without modifications, as long as this notice is preserved. dnl Written by Simon Josefsson, Bruno Haible. -AC_DEFUN([gl_UNISTD_H], +AC_DEFUN_ONCE([gl_UNISTD_H], [ - dnl Use AC_REQUIRE here, so that the default behavior below is expanded - dnl once only, before all statements that occur in other macros. + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) gl_CHECK_NEXT_HEADERS([unistd.h]) @@ -59,100 +59,116 @@ AC_DEFUN([gl_UNISTD_H], fi ]) +# gl_UNISTD_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], [ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + dnl Ensure to expand the default settings once only. + gl_UNISTD_H_REQUIRE_DEFAULTS gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_UNISTD_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_UNISTD_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCESS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHOWN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CLOSE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPY_FILE_RANGE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP2]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP3]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ENVIRON]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EUIDACCESS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECLE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECLP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECV]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVPE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FACCESSAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHOWNAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDATASYNC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSYNC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTRUNCATE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETCWD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDOMAINNAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDTABLESIZE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETENTROPY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETGROUPS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETHOSTNAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOGIN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOGIN_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETOPT_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPAGESIZE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPASS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETUSERSHELL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GROUP_MEMBER]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISATTY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LCHOWN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LINK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LINKAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LSEEK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PIPE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PIPE2]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PREAD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PWRITE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READ]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READLINK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READLINKAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RMDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETHOSTNAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SLEEP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYMLINK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYMLINKAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCATE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TTYNAME_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_NONBLOCKING]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_SIGPIPE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLINK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLINKAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_USLEEP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WRITE]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ACCESS], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CHDIR], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CLOSE], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_DUP], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_DUP2], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECL], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECLE], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECLP], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECV], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVE], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVP], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVPE], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETCWD], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETPID], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ISATTY], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_LSEEK], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_READ], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_RMDIR], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_SWAB], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_UNLINK], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_WRITE], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_UNISTD_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) +]) + AC_DEFUN([gl_UNISTD_H_DEFAULTS], [ - GNULIB_ACCESS=0; AC_SUBST([GNULIB_ACCESS]) - GNULIB_CHDIR=0; AC_SUBST([GNULIB_CHDIR]) - GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN]) - GNULIB_CLOSE=0; AC_SUBST([GNULIB_CLOSE]) - GNULIB_COPY_FILE_RANGE=0; AC_SUBST([GNULIB_COPY_FILE_RANGE]) - GNULIB_DUP=0; AC_SUBST([GNULIB_DUP]) - GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2]) - GNULIB_DUP3=0; AC_SUBST([GNULIB_DUP3]) - GNULIB_ENVIRON=0; AC_SUBST([GNULIB_ENVIRON]) - GNULIB_EUIDACCESS=0; AC_SUBST([GNULIB_EUIDACCESS]) - GNULIB_EXECL=0; AC_SUBST([GNULIB_EXECL]) - GNULIB_EXECLE=0; AC_SUBST([GNULIB_EXECLE]) - GNULIB_EXECLP=0; AC_SUBST([GNULIB_EXECLP]) - GNULIB_EXECV=0; AC_SUBST([GNULIB_EXECV]) - GNULIB_EXECVE=0; AC_SUBST([GNULIB_EXECVE]) - GNULIB_EXECVP=0; AC_SUBST([GNULIB_EXECVP]) - GNULIB_EXECVPE=0; AC_SUBST([GNULIB_EXECVPE]) - GNULIB_FACCESSAT=0; AC_SUBST([GNULIB_FACCESSAT]) - GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR]) - GNULIB_FCHOWNAT=0; AC_SUBST([GNULIB_FCHOWNAT]) - GNULIB_FDATASYNC=0; AC_SUBST([GNULIB_FDATASYNC]) - GNULIB_FSYNC=0; AC_SUBST([GNULIB_FSYNC]) - GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE]) - GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD]) - GNULIB_GETDOMAINNAME=0; AC_SUBST([GNULIB_GETDOMAINNAME]) - GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE]) - GNULIB_GETENTROPY=0; AC_SUBST([GNULIB_GETENTROPY]) - GNULIB_GETGROUPS=0; AC_SUBST([GNULIB_GETGROUPS]) - GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME]) - GNULIB_GETLOGIN=0; AC_SUBST([GNULIB_GETLOGIN]) - GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R]) - GNULIB_GETOPT_POSIX=0; AC_SUBST([GNULIB_GETOPT_POSIX]) - GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE]) - GNULIB_GETPASS=0; AC_SUBST([GNULIB_GETPASS]) - GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL]) - GNULIB_GROUP_MEMBER=0; AC_SUBST([GNULIB_GROUP_MEMBER]) - GNULIB_ISATTY=0; AC_SUBST([GNULIB_ISATTY]) - GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN]) - GNULIB_LINK=0; AC_SUBST([GNULIB_LINK]) - GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT]) - GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK]) - GNULIB_PIPE=0; AC_SUBST([GNULIB_PIPE]) - GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2]) - GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD]) - GNULIB_PWRITE=0; AC_SUBST([GNULIB_PWRITE]) - GNULIB_READ=0; AC_SUBST([GNULIB_READ]) - GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK]) - GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT]) - GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR]) - GNULIB_SETHOSTNAME=0; AC_SUBST([GNULIB_SETHOSTNAME]) - GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP]) - GNULIB_SYMLINK=0; AC_SUBST([GNULIB_SYMLINK]) - GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT]) - GNULIB_TRUNCATE=0; AC_SUBST([GNULIB_TRUNCATE]) - GNULIB_TTYNAME_R=0; AC_SUBST([GNULIB_TTYNAME_R]) - GNULIB_UNISTD_H_NONBLOCKING=0; AC_SUBST([GNULIB_UNISTD_H_NONBLOCKING]) - GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE]) - GNULIB_UNLINK=0; AC_SUBST([GNULIB_UNLINK]) - GNULIB_UNLINKAT=0; AC_SUBST([GNULIB_UNLINKAT]) - GNULIB_USLEEP=0; AC_SUBST([GNULIB_USLEEP]) - GNULIB_WRITE=0; AC_SUBST([GNULIB_WRITE]) - dnl Support Microsoft deprecated alias function names by default. - GNULIB_MDA_ACCESS=1; AC_SUBST([GNULIB_MDA_ACCESS]) - GNULIB_MDA_CHDIR=1; AC_SUBST([GNULIB_MDA_CHDIR]) - GNULIB_MDA_CLOSE=1; AC_SUBST([GNULIB_MDA_CLOSE]) - GNULIB_MDA_DUP=1; AC_SUBST([GNULIB_MDA_DUP]) - GNULIB_MDA_DUP2=1; AC_SUBST([GNULIB_MDA_DUP2]) - GNULIB_MDA_EXECL=1; AC_SUBST([GNULIB_MDA_EXECL]) - GNULIB_MDA_EXECLE=1; AC_SUBST([GNULIB_MDA_EXECLE]) - GNULIB_MDA_EXECLP=1; AC_SUBST([GNULIB_MDA_EXECLP]) - GNULIB_MDA_EXECV=1; AC_SUBST([GNULIB_MDA_EXECV]) - GNULIB_MDA_EXECVE=1; AC_SUBST([GNULIB_MDA_EXECVE]) - GNULIB_MDA_EXECVP=1; AC_SUBST([GNULIB_MDA_EXECVP]) - GNULIB_MDA_EXECVPE=1; AC_SUBST([GNULIB_MDA_EXECVPE]) - GNULIB_MDA_GETCWD=1; AC_SUBST([GNULIB_MDA_GETCWD]) - GNULIB_MDA_GETPID=1; AC_SUBST([GNULIB_MDA_GETPID]) - GNULIB_MDA_ISATTY=1; AC_SUBST([GNULIB_MDA_ISATTY]) - GNULIB_MDA_LSEEK=1; AC_SUBST([GNULIB_MDA_LSEEK]) - GNULIB_MDA_READ=1; AC_SUBST([GNULIB_MDA_READ]) - GNULIB_MDA_RMDIR=1; AC_SUBST([GNULIB_MDA_RMDIR]) - GNULIB_MDA_SWAB=1; AC_SUBST([GNULIB_MDA_SWAB]) - GNULIB_MDA_UNLINK=1; AC_SUBST([GNULIB_MDA_UNLINK]) - GNULIB_MDA_WRITE=1; AC_SUBST([GNULIB_MDA_WRITE]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN]) HAVE_COPY_FILE_RANGE=1; AC_SUBST([HAVE_COPY_FILE_RANGE]) diff --git a/m4/unlocked-io.m4 b/m4/unlocked-io.m4 index a2dc8a144af..b689020ff49 100644 --- a/m4/unlocked-io.m4 +++ b/m4/unlocked-io.m4 @@ -1,4 +1,4 @@ -# unlocked-io.m4 serial 15 +# unlocked-io.m4 serial 16 # Copyright (C) 1998-2006, 2009-2021 Free Software Foundation, Inc. # @@ -16,11 +16,6 @@ dnl on Solaris 2.6). AC_DEFUN([gl_FUNC_GLIBC_UNLOCKED_IO], [ - AC_DEFINE([USE_UNLOCKED_IO], [1], - [Define to 1 if you want getc etc. to use unlocked I/O if available. - Unlocked I/O can improve performance in unithreaded apps, - but it is not safe for multithreaded apps.]) - dnl Persuade glibc and Solaris to declare dnl fgets_unlocked(), fputs_unlocked() etc. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) diff --git a/m4/year2038.m4 b/m4/year2038.m4 new file mode 100644 index 00000000000..da0f8d73030 --- /dev/null +++ b/m4/year2038.m4 @@ -0,0 +1,124 @@ +# year2038.m4 serial 7 +dnl Copyright (C) 2017-2021 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. + +dnl Attempt to ensure that 'time_t' can go past the year 2038 and that +dnl the functions 'time', 'stat', etc. work with post-2038 timestamps. + +AC_DEFUN([gl_YEAR2038_EARLY], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw*) + AC_DEFINE([__MINGW_USE_VC2005_COMPAT], [1], + [For 64-bit time_t on 32-bit mingw.]) + ;; + esac +]) + +# gl_YEAR2038_TEST_INCLUDES +# ------------------------- +AC_DEFUN([gl_YEAR2038_TEST_INCLUDES], +[[ + #include + /* Check that time_t can represent 2**32 - 1 correctly. */ + #define LARGE_TIME_T \\ + ((time_t) (((time_t) 1 << 30) - 1 + 3 * ((time_t) 1 << 30))) + int verify_time_t_range[(LARGE_TIME_T / 65537 == 65535 + && LARGE_TIME_T % 65537 == 0) + ? 1 : -1]; +]]) + +# gl_YEAR2038_BODY(REQUIRE-YEAR2038-SAFE) +----------------------------------------- +AC_DEFUN([gl_YEAR2038_BODY], +[ + AC_ARG_ENABLE([year2038], + [ --disable-year2038 omit support for timestamps past the year 2038]) + AS_IF([test "$enable_year2038" != no], + [ + dnl On many systems, time_t is already a 64-bit type. + dnl On those systems where time_t is still 32-bit, it requires kernel + dnl and libc support to make it 64-bit. For glibc 2.34 and later on Linux, + dnl defining _TIME_BITS=64 and _FILE_OFFSET_BITS=64 is needed on x86 and ARM. + dnl + dnl On native Windows, the system include files define types __time32_t + dnl and __time64_t. By default, time_t is an alias of + dnl - __time32_t on 32-bit mingw, + dnl - __time64_t on 64-bit mingw and on MSVC (since MSVC 8). + dnl But when compiling with -D__MINGW_USE_VC2005_COMPAT, time_t is an + dnl alias of __time64_t. + dnl And when compiling with -D_USE_32BIT_TIME_T, time_t is an alias of + dnl __time32_t. + AC_CACHE_CHECK([for time_t past the year 2038], [gl_cv_type_time_t_y2038], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([gl_YEAR2038_TEST_INCLUDES])], + [gl_cv_type_time_t_y2038=yes], [gl_cv_type_time_t_y2038=no]) + ]) + if test "$gl_cv_type_time_t_y2038" = no; then + AC_CACHE_CHECK([for 64-bit time_t with _TIME_BITS=64], + [gl_cv_type_time_t_bits_macro], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[#define _TIME_BITS 64 + #define _FILE_OFFSET_BITS 64 + ]gl_YEAR2038_TEST_INCLUDES])], + [gl_cv_type_time_t_bits_macro=yes], + [gl_cv_type_time_t_bits_macro=no]) + ]) + if test "$gl_cv_type_time_t_bits_macro" = yes; then + AC_DEFINE([_TIME_BITS], [64], + [Number of bits in a timestamp, on hosts where this is settable.]) + dnl AC_SYS_LARGFILE also defines this; it's OK if we do too. + AC_DEFINE([_FILE_OFFSET_BITS], [64], + [Number of bits in a file offset, on hosts where this is settable.]) + gl_cv_type_time_t_y2038=yes + fi + fi + if test $gl_cv_type_time_t_y2038 = no; then + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#ifdef _USE_32BIT_TIME_T + int ok; + #else + error fail + #endif + ]])], + [AC_MSG_FAILURE( + [The 'time_t' type stops working after January 2038. + Remove _USE_32BIT_TIME_T from the compiler flags.])], + [# If not cross-compiling and $1 says we should check, + # and 'touch' works with a large timestamp, then evidently wider time_t + # is desired and supported, so fail and ask the builder to fix the + # problem. Otherwise, just warn the builder. + m4_ifval([$1], + [if test $cross_compiling = no \ + && TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null; then + case `TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null` in + *'Feb 7 2106'* | *'Feb 7 17:10'*) + AC_MSG_FAILURE( + [The 'time_t' type stops working after January 2038, + and your system appears to support a wider 'time_t'. + Try configuring with 'CC="${CC} -m64"'. + To build with a 32-bit time_t anyway (not recommended), + configure with '--disable-year2038'.]);; + esac + rm -f conftest.time + fi]) + if test "$gl_warned_about_y2038" != yes; then + AC_MSG_WARN( + [The 'time_t' type stops working after January 2038, + and this package needs a wider 'time_t' type + if there is any way to access timestamps after that. + Configure with 'CC="${CC} -m64"' perhaps?]) + gl_warned_about_y2038=yes + fi + ]) + fi]) +]) + +AC_DEFUN([gl_YEAR2038], +[ + gl_YEAR2038_BODY([require-year2038-safe]) +]) -- cgit v1.2.3