From 1a13c5e63e1eb8fcf15c53ae4ed0caca8b928a3b Mon Sep 17 00:00:00 2001 From: Po Lu Date: Thu, 5 Sep 2024 08:41:11 +0800 Subject: [PATCH] ; Update from Gnulib * configure.ac: * src/conf_post.h: Remove workarounds now rendered redundant by Gnulib. --- admin/merge-gnulib | 4 +- build-aux/config.guess | 11 +- build-aux/config.sub | 729 ++++++++++++++++++++++++++-------- build-aux/gitlog-to-changelog | 19 +- configure.ac | 4 - lib/_Noreturn.h | 2 +- lib/acl.h | 14 +- lib/attribute.h | 49 ++- lib/c++defs.h | 41 +- lib/cdefs.h | 4 +- lib/diffseq.h | 10 +- lib/dirent.in.h | 45 ++- lib/errno.in.h | 9 +- lib/fcntl.in.h | 8 +- lib/file-has-acl.c | 6 +- lib/gnulib.mk.in | 29 +- lib/intprops-internal.h | 4 +- lib/inttypes.in.h | 8 +- lib/libc-config.h | 5 + lib/md5-stream.c | 7 - lib/mini-gmp-gnulib.c | 4 +- lib/sig2str.c | 4 +- lib/sig2str.h | 21 - lib/signal.in.h | 53 ++- lib/stddef.in.h | 4 +- lib/stdio.in.h | 290 +++++++------- lib/stdlib.in.h | 337 +++++++++------- lib/strftime.c | 2 +- lib/strftime.h | 18 +- lib/string.in.h | 126 +++--- lib/sys_random.in.h | 11 +- lib/sys_select.in.h | 6 +- lib/sys_stat.in.h | 90 +++-- lib/sys_time.in.h | 4 +- lib/time.in.h | 89 ++++- lib/time_rz.c | 57 ++- lib/unistd.in.h | 289 ++++++++------ lib/verify.h | 9 +- lib/warn-on-use.h | 8 +- lib/xalloc-oversized.h | 3 +- m4/builtin-expect.m4 | 4 +- m4/errno_h.m4 | 10 +- m4/extensions-aix.m4 | 25 ++ m4/fchmodat.m4 | 14 +- m4/fpieee.m4 | 2 +- m4/gnulib-common.m4 | 223 ++++++++++- m4/gnulib-comp.m4 | 17 +- m4/locale-en.m4 | 137 +++++++ m4/malloc.m4 | 7 +- m4/realloc.m4 | 7 +- m4/sig2str.m4 | 11 +- m4/signal_h.m4 | 8 +- m4/std-gnu11.m4 | 8 +- m4/stdlib_h.m4 | 18 +- m4/time_h.m4 | 7 +- m4/time_rz.m4 | 30 +- src/conf_post.h | 12 - 57 files changed, 2048 insertions(+), 925 deletions(-) create mode 100644 m4/extensions-aix.m4 create mode 100644 m4/locale-en.m4 diff --git a/admin/merge-gnulib b/admin/merge-gnulib index 65e098c7123..c265b53684e 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -54,7 +54,8 @@ GNULIB_MODULES=' AVOIDED_MODULES=' access btowc chmod close crypto/af_alg dup fchdir fstat - iswblank iswctype iswdigit iswxdigit langinfo localename-unsafe-limited lock + iswblank iswctype iswdigit iswxdigit langinfo libgmp-mpq + localename-unsafe-limited lock mbrtowc mbsinit memchr mkdir msvc-inval msvc-nothrow nl_langinfo openat-die opendir pthread-h raise save-cwd select setenv sigprocmask stat stdarg @@ -125,7 +126,6 @@ rm -- "$src"lib/gl_openssl.h \ "$src"m4/fcntl-o.m4 \ "$src"m4/gl-openssl.m4 \ "$src"m4/gnulib-cache.m4 "$src"m4/gnulib-tool.m4 \ - "$src"m4/locale-fr.m4 \ "$src"m4/manywarnings-c++.m4 \ "$src"m4/off64_t.m4 \ "$src"m4/warn-on-use.m4 "$src"m4/wint_t.m4 && diff --git a/build-aux/config.guess b/build-aux/config.guess index f6d217a49f8..48a684601bd 100755 --- a/build-aux/config.guess +++ b/build-aux/config.guess @@ -4,7 +4,7 @@ # shellcheck disable=SC2006,SC2268 # see below for rationale -timestamp='2024-01-01' +timestamp='2024-07-27' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -123,7 +123,7 @@ set_cc_for_build() { dummy=$tmp/dummy case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in ,,) echo "int x;" > "$dummy.c" - for driver in cc gcc c89 c99 ; do + for driver in cc gcc c17 c99 c89 ; do if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD=$driver break @@ -634,7 +634,8 @@ EOF sed 's/^ //' << EOF > "$dummy.c" #include - main() + int + main () { if (!__power_pc()) exit(1); @@ -718,7 +719,8 @@ EOF #include #include - int main () + int + main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); @@ -1621,6 +1623,7 @@ cat > "$dummy.c" <&2 exit 1 ;; - kfreebsd*-gnu*- | kopensolaris*-gnu*-) + kfreebsd*-gnu*- | knetbsd*-gnu*- | netbsd*-gnu*- | kopensolaris*-gnu*-) ;; vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-) ;; @@ -1864,6 +2245,8 @@ case $kernel-$os-$obj in ;; os2-emx-) ;; + rtmk-nova-) + ;; *-eabi*- | *-gnueabi*-) ;; none--*) @@ -1890,7 +2273,7 @@ case $vendor in *-riscix*) vendor=acorn ;; - *-sunos*) + *-sunos* | *-solaris*) vendor=sun ;; *-cnk* | *-aix*) diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog index a2c348e2cf0..90a53ef71ed 100755 --- a/build-aux/gitlog-to-changelog +++ b/build-aux/gitlog-to-changelog @@ -35,12 +35,14 @@ eval 'exec perl -wSx "$0" "$@"' if 0; -my $VERSION = '2024-07-04 10:56'; # UTC +my $VERSION = '2024-07-17 02:20'; # UTC # The definition above must lie within the first 8 lines in order # for the Emacs time-stamp write hook (at end) to update it. # If you change this file with Emacs, please let the write hook # do its job. Otherwise, update this string manually. +(my $copyright_year = $VERSION) =~ s/^(\d*)-.*$/$1/; + use strict; use warnings; use Getopt::Long; @@ -138,11 +140,24 @@ s/all tile types/all file types/ # Change the author to be Paul. Note the escaped "@": s,Jim .*>,Paul Eggert , +Send patches and bug reports to . EOF } exit $exit_code; } +sub print_version () +{ + print "$ME version $VERSION\n"; + print "Copyright (C) $copyright_year Free Software Foundation, Inc.\n"; + print "License GPLv3+: GNU GPL version 3 or later \n" + . "This is free software: you are free to change and redistribute it.\n" + . "There is NO WARRANTY, to the extent permitted by law.\n"; + print "\n"; + my $author = "Jim Meyering"; + print "Written by $author.\n"; +} + # If the string $S is a well-behaved file name, simply return it. # If it contains white space, quotes, etc., quote it, and return the new string. sub shell_quote($) @@ -253,7 +268,7 @@ sub git_dir_option($) GetOptions ( help => sub { usage 0 }, - version => sub { print "$ME version $VERSION\n"; exit }, + version => sub { print_version; exit }, 'since=s' => \$since_date, 'until=s' => \$until_date, 'format=s' => \$format_string, diff --git a/configure.ac b/configure.ac index 28361be4211..e79a822fcae 100644 --- a/configure.ac +++ b/configure.ac @@ -49,10 +49,6 @@ if test "$XCONFIGURE" = "android"; then CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=32" enable_largefile=no enable_year2038=no]) - # Prevent Gnulib from enabling time_rz.c on old Android releases, till - # Gnulib itself is fixed. - AS_IF([test "$ANDROID_SDK" -lt "35"], - [ac_cv_type_timezone_t=no]) fi dnl Set emacs_config_options to the options of 'configure', quoted for the shell, diff --git a/lib/_Noreturn.h b/lib/_Noreturn.h index 7326bd47733..9806f2b1a09 100644 --- a/lib/_Noreturn.h +++ b/lib/_Noreturn.h @@ -34,7 +34,7 @@ # elif ((!defined __cplusplus || defined __clang__) \ && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ || (!defined __STRICT_ANSI__ \ - && (4 < __GNUC__ + (7 <= __GNUC_MINOR__) \ + && (4 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __clang__ \ || (defined __apple_build_version__ \ ? 6000000 <= __apple_build_version__ \ : 3 < __clang_major__ + (5 <= __clang_minor__)))))) diff --git a/lib/acl.h b/lib/acl.h index 0bf78a654d2..475231c2db7 100644 --- a/lib/acl.h +++ b/lib/acl.h @@ -20,7 +20,7 @@ #ifndef _GL_ACL_H #define _GL_ACL_H 1 -/* This file uses _GL_ATTRIBUTE_CONST. */ +/* This file uses _GL_ATTRIBUTE_CONST, _GL_ATTRIBUTE_DEPRECATED. */ #if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif @@ -35,10 +35,18 @@ extern "C" { bool acl_errno_valid (int) _GL_ATTRIBUTE_CONST; int file_has_acl (char const *, struct stat const *); + int qset_acl (char const *, int, mode_t); -int set_acl (char const *, int, mode_t); +int xset_acl (char const *, int, mode_t); +/* Old name of xset_acl. */ +_GL_ATTRIBUTE_DEPRECATED int set_acl (char const *, int, mode_t); + int qcopy_acl (char const *, int, char const *, int, mode_t); -int copy_acl (char const *, int, char const *, int, mode_t); +int xcopy_acl (char const *, int, char const *, int, mode_t); +/* Old name of xcopy_acl. */ +_GL_ATTRIBUTE_DEPRECATED int copy_acl (char const *, int, char const *, int, + mode_t); + int chmod_or_fchmod (char const *, int, mode_t); diff --git a/lib/attribute.h b/lib/attribute.h index 604965a6d18..186faa55265 100644 --- a/lib/attribute.h +++ b/lib/attribute.h @@ -20,12 +20,49 @@ /* Provide public ATTRIBUTE_* names for the private _GL_ATTRIBUTE_* macros used within Gnulib. */ -/* These attributes can be placed in two ways: - - At the start of a declaration (i.e. even before storage-class - specifiers!); then they apply to all entities that are declared - by the declaration. - - Immediately after the name of an entity being declared by the - declaration; then they apply to that entity only. */ +/* The placement of these attributes depends on the kind of declaration + and, in some cases, also on the programming language (C vs. C++). + + In function declarations and function definitions: + + * ATTRIBUTE_NOTHROW must come after the parameter list. + + * The macros + ATTRIBUTE_CONST + ATTRIBUTE_PURE + DEPRECATED + MAYBE_UNUSED + NODISCARD + REPRODUCIBLE + UNSEQUENCED + must come before the return type, and more precisely: + - In a function declaration/definition without a storage-class + specifier: at the beginning of the declaration/definition. + - In a function declaration/definition with a storage-class + specifier: + - In C: before the storage-class specifier. + - In C++: between the storage-class specifier and the return type. + + * The other macros can be placed + - Either + - In a function declaration/definition without a storage-class + specifier: at the beginning of the declaration/definition. + - In a function declaration/definition with a storage-class + specifier: between the storage-class specifier and the return + type. + - Or after the parameter list, + ∙ but after ATTRIBUTE_NOTHROW if present. + + In other declarations, such as variable declarations: + + * Either + - In C: before the storage-class specifier. + - In C++: between the storage-class specifier and the return type. + Then they apply to all entities that are declared by the declaration. + + * Or immediately after the name of an entity being declared by the + declaration. Then they apply to that entity only. + */ #ifndef _GL_ATTRIBUTE_H #define _GL_ATTRIBUTE_H diff --git a/lib/c++defs.h b/lib/c++defs.h index eb66967b09b..7082af3fc28 100644 --- a/lib/c++defs.h +++ b/lib/c++defs.h @@ -93,11 +93,22 @@ # define _GL_EXTERN_C extern #endif -/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); +/* _GL_EXTERN_C_FUNC declaration; + performs the declaration of a function with C linkage. */ +#if defined __cplusplus +# define _GL_EXTERN_C_FUNC extern "C" +#else +/* In C mode, omit the 'extern' keyword, because attributes in bracket syntax + are not allowed between 'extern' and the return type (see gnulib-common.m4). + */ +# define _GL_EXTERN_C_FUNC +#endif + +/* _GL_FUNCDECL_RPL (func, rettype, parameters[, attributes]); declares a replacement function, named rpl_func, with the given prototype, consisting of return type, parameters, and attributes. Example: - _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) + _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...), _GL_ARG_NONNULL ((1))); Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front @@ -105,21 +116,27 @@ because [[...]] extern "C" ; is invalid syntax in C++.) - */ -#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ - _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) -#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ - _GL_EXTERN_C rettype rpl_func parameters_and_attributes -/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); + Note: The attribute _GL_ATTRIBUTE_NOTHROW, if needed, must be placed outside + of the _GL_FUNCDECL_RPL invocation, at the end of the declaration. + */ +#define _GL_FUNCDECL_RPL(func,rettype,parameters,...) \ + _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters, __VA_ARGS__) +#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters,...) \ + _GL_EXTERN_C_FUNC __VA_ARGS__ rettype rpl_func parameters + +/* _GL_FUNCDECL_SYS (func, rettype, parameters[, attributes]); declares the system function, named func, with the given prototype, consisting of return type, parameters, and attributes. Example: - _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) + _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...), _GL_ARG_NONNULL ((1))); + + Note: The attribute _GL_ATTRIBUTE_NOTHROW, if needed, must be placed outside + of the _GL_FUNCDECL_SYS invocation, at the end of the declaration. */ -#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ - _GL_EXTERN_C rettype func parameters_and_attributes +#define _GL_FUNCDECL_SYS(func,rettype,parameters,...) \ + _GL_EXTERN_C_FUNC __VA_ARGS__ rettype func parameters /* _GL_CXXALIAS_RPL (func, rettype, parameters); declares a C++ alias called GNULIB_NAMESPACE::func @@ -297,7 +314,7 @@ _GL_WARN_ON_USE (func, \ "The symbol ::" #func " refers to the system function. " \ "Use " #namespace "::" #func " instead.") -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING # define _GL_CXXALIASWARN_2(func,namespace) \ extern __typeof__ (func) func # else diff --git a/lib/cdefs.h b/lib/cdefs.h index 02fcabce722..9c49eeb413e 100644 --- a/lib/cdefs.h +++ b/lib/cdefs.h @@ -83,7 +83,7 @@ # define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct # define __NTHNL(fct) __attribute__ ((__nothrow__)) fct # else -# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4) +# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4) # if __cplusplus >= 201103L # define __THROW noexcept (true) # else @@ -497,7 +497,7 @@ # endif #endif -/* ISO C99 also allows declaring arrays as non-overlapping. The syntax is +/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is array_name[restrict] GCC 3.1 and clang support this. This syntax is not usable in C++ mode. */ diff --git a/lib/diffseq.h b/lib/diffseq.h index 0c5bc9cbc6d..c9369e44100 100644 --- a/lib/diffseq.h +++ b/lib/diffseq.h @@ -93,10 +93,14 @@ #endif /* Suppress gcc's "...may be used before initialized" warnings, - generated by GCC versions up to at least GCC 13.2. */ -#if __GNUC__ + (__GNUC_MINOR__ >= 7) > 4 + generated by GCC versions up to at least GCC 14.2. + Likewise for gcc -fanalyzer's "use of uninitialized value" warnings. */ +#if _GL_GNUC_PREREQ (4, 7) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +# if _GL_GNUC_PREREQ (13, 0) +# pragma GCC diagnostic ignored "-Wanalyzer-use-of-uninitialized-value" +# endif #endif /* @@ -554,7 +558,7 @@ compareseq (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim, #undef XREF_YREF_EQUAL } -#if __GNUC__ + (__GNUC_MINOR__ >= 7) > 4 +#if _GL_GNUC_PREREQ (4, 7) # pragma GCC diagnostic pop #endif diff --git a/lib/dirent.in.h b/lib/dirent.in.h index f05b880077f..7ba8fc64d89 100644 --- a/lib/dirent.in.h +++ b/lib/dirent.in.h @@ -78,7 +78,7 @@ typedef struct gl_directory DIR; that can be freed by passing them as the Ith argument to the function F. */ #ifndef _GL_ATTRIBUTE_DEALLOC -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) # else # define _GL_ATTRIBUTE_DEALLOC(f, i) @@ -122,11 +122,11 @@ typedef struct gl_directory DIR; # define closedir rpl_closedir # define GNULIB_defined_closedir 1 # endif -_GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (closedir, int, (DIR *dirp), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (closedir, int, (DIR *dirp)); # else # if !@HAVE_CLOSEDIR@ -_GL_FUNCDECL_SYS (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (closedir, int, (DIR *dirp), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (closedir, int, (DIR *dirp)); # endif @@ -147,14 +147,14 @@ _GL_WARN_ON_USE (closedir, "closedir is not portable - " # define GNULIB_defined_opendir 1 # endif _GL_FUNCDECL_RPL (opendir, DIR *, - (const char *dir_name) + (const char *dir_name), _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1)); _GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name)); # else -# if !@HAVE_OPENDIR@ || __GNUC__ >= 11 +# if !@HAVE_OPENDIR@ || (__GNUC__ >= 11 && !defined __clang__) _GL_FUNCDECL_SYS (opendir, DIR *, - (const char *dir_name) + (const char *dir_name), _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1)); # endif @@ -162,11 +162,12 @@ _GL_CXXALIAS_SYS (opendir, DIR *, (const char *dir_name)); # endif _GL_CXXALIASWARN (opendir); #else -# if @GNULIB_CLOSEDIR@ && !GNULIB_defined_DIR && __GNUC__ >= 11 && !defined opendir +# if @GNULIB_CLOSEDIR@ && !GNULIB_defined_DIR \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined opendir /* For -Wmismatched-dealloc: Associate opendir with closedir or rpl_closedir. */ _GL_FUNCDECL_SYS (opendir, DIR *, - (const char *dir_name) + (const char *dir_name), _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1)); # endif @@ -185,11 +186,11 @@ _GL_WARN_ON_USE (opendir, "opendir is not portable - " # undef readdir # define readdir rpl_readdir # endif -_GL_FUNCDECL_RPL (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (readdir, struct dirent *, (DIR *dirp), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (readdir, struct dirent *, (DIR *dirp)); # else # if !@HAVE_READDIR@ -_GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (readdir, struct dirent *, (DIR *dirp)); # endif @@ -208,11 +209,11 @@ _GL_WARN_ON_USE (readdir, "readdir is not portable - " # undef rewinddir # define rewinddir rpl_rewinddir # endif -_GL_FUNCDECL_RPL (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (rewinddir, void, (DIR *dirp), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (rewinddir, void, (DIR *dirp)); # else # if !@HAVE_REWINDDIR@ -_GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (rewinddir, void, (DIR *dirp)); # endif @@ -234,7 +235,7 @@ _GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - " # undef dirfd # define dirfd rpl_dirfd # endif -_GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (dirfd, int, (DIR *), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (dirfd, int, (DIR *)); # else @@ -245,7 +246,7 @@ static inline int (dirfd) (DIR *dp) { return dirfd (dp); } # undef dirfd # endif # if !(@HAVE_DECL_DIRFD@ || defined dirfd) -_GL_FUNCDECL_SYS (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (dirfd, int, (DIR *), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (dirfd, int, (DIR *)); # endif @@ -270,24 +271,26 @@ _GL_WARN_ON_USE (dirfd, "dirfd is unportable - " # define fdopendir rpl_fdopendir # endif _GL_FUNCDECL_RPL (fdopendir, DIR *, - (int fd) + (int fd), _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1)); _GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd)); # else -# if !@HAVE_FDOPENDIR@ || !@HAVE_DECL_FDOPENDIR@ || __GNUC__ >= 11 +# if !@HAVE_FDOPENDIR@ || !@HAVE_DECL_FDOPENDIR@ \ + || (__GNUC__ >= 11 && !defined __clang__) _GL_FUNCDECL_SYS (fdopendir, DIR *, - (int fd) + (int fd), _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1)); # endif _GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd)); # endif _GL_CXXALIASWARN (fdopendir); #else -# if @GNULIB_CLOSEDIR@ && __GNUC__ >= 11 && !defined fdopendir +# if @GNULIB_CLOSEDIR@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined fdopendir /* For -Wmismatched-dealloc: Associate fdopendir with closedir or rpl_closedir. */ _GL_FUNCDECL_SYS (fdopendir, DIR *, - (int fd) + (int fd), _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1)); # endif # if defined GNULIB_POSIXCHECK @@ -308,7 +311,7 @@ _GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - " _GL_FUNCDECL_SYS (scandir, int, (const char *dir, struct dirent ***namelist, int (*filter) (const struct dirent *), - int (*cmp) (const struct dirent **, const struct dirent **)) + int (*cmp) (const struct dirent **, const struct dirent **)), _GL_ARG_NONNULL ((1, 2, 4))); # endif /* Need to cast, because on glibc systems, the fourth parameter is @@ -330,7 +333,7 @@ _GL_WARN_ON_USE (scandir, "scandir is unportable - " /* Compare two 'struct dirent' entries alphabetically. */ # if !@HAVE_ALPHASORT@ _GL_FUNCDECL_SYS (alphasort, int, - (const struct dirent **, const struct dirent **) + (const struct dirent **, const struct dirent **), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); # endif diff --git a/lib/errno.in.h b/lib/errno.in.h index aa658e62708..18eb8a0c582 100644 --- a/lib/errno.in.h +++ b/lib/errno.in.h @@ -133,7 +133,7 @@ /* These are intentionally the same values as the WSA* error numbers, defined in . */ -# define ESOCKTNOSUPPORT 10044 /* not required by POSIX */ +# define ESOCKTNOSUPPORT 10044 # define EPFNOSUPPORT 10046 /* not required by POSIX */ # define ESHUTDOWN 10058 /* not required by POSIX */ # define ETOOMANYREFS 10059 /* not required by POSIX */ @@ -270,10 +270,17 @@ # define GNULIB_defined_ENOTRECOVERABLE 1 # endif +/* On LynxOS, the macro EILSEQ is not defined. */ # ifndef EILSEQ # define EILSEQ 2015 # define GNULIB_defined_EILSEQ 1 # endif +/* On Haiku, the macro ESOCKTNOSUPPORT is not defined. */ +# ifndef ESOCKTNOSUPPORT +# define ESOCKTNOSUPPORT 2016 +# define GNULIB_defined_ESOCKTNOSUPPORT 1 +# endif + #endif /* _@GUARD_PREFIX@_ERRNO_H */ #endif /* _@GUARD_PREFIX@_ERRNO_H */ diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h index 1465ce594d7..8b8274295a5 100644 --- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h @@ -100,7 +100,7 @@ # undef creat # define creat rpl_creat # endif -_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode) +_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode)); # elif defined _WIN32 && !defined __CYGWIN__ @@ -170,7 +170,7 @@ _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - " # undef open # define open rpl_open # endif -_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) +_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); # elif defined _WIN32 && !defined __CYGWIN__ @@ -217,14 +217,14 @@ _GL_CXXALIASWARN (open); # define openat rpl_openat # endif _GL_FUNCDECL_RPL (openat, int, - (int fd, char const *file, int flags, /* mode_t mode */ ...) + (int fd, char const *file, int flags, /* mode_t mode */ ...), _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (openat, int, (int fd, char const *file, int flags, /* mode_t mode */ ...)); # else # if !@HAVE_OPENAT@ _GL_FUNCDECL_SYS (openat, int, - (int fd, char const *file, int flags, /* mode_t mode */ ...) + (int fd, char const *file, int flags, /* mode_t mode */ ...), _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (openat, int, diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c index 898fb030d1d..06759a4948c 100644 --- a/lib/file-has-acl.c +++ b/lib/file-has-acl.c @@ -17,14 +17,14 @@ Written by Paul Eggert, Andreas Grünbacher, and Bruno Haible. */ +#include + /* Without this pragma, gcc 4.7.0 20120126 may suggest that the file_has_acl function might be candidate for attribute 'const' */ -#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ +#if _GL_GNUC_PREREQ (4, 6) # pragma GCC diagnostic ignored "-Wsuggest-attribute=const" #endif -#include - #include "acl.h" #include "acl-internal.h" diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index cebde64d117..5e541d9af1f 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -47,6 +47,7 @@ # --avoid=iswdigit \ # --avoid=iswxdigit \ # --avoid=langinfo \ +# --avoid=libgmp-mpq \ # --avoid=localename-unsafe-limited \ # --avoid=lock \ # --avoid=mbrtowc \ @@ -226,6 +227,7 @@ CAIRO_XCB_CFLAGS = @CAIRO_XCB_CFLAGS@ CAIRO_XCB_LIBS = @CAIRO_XCB_LIBS@ CAIRO_XLIB_CFLAGS = @CAIRO_XLIB_CFLAGS@ CAIRO_XLIB_LIBS = @CAIRO_XLIB_LIBS@ +CAN_PRINT_STACK_TRACE = @CAN_PRINT_STACK_TRACE@ CC = @CC@ CFLAGS = @CFLAGS@ CFLAGS_SOUND = @CFLAGS_SOUND@ @@ -597,6 +599,7 @@ GL_GNULIB_SECURE_GETENV = @GL_GNULIB_SECURE_GETENV@ GL_GNULIB_SELECT = @GL_GNULIB_SELECT@ GL_GNULIB_SETENV = @GL_GNULIB_SETENV@ GL_GNULIB_SETHOSTNAME = @GL_GNULIB_SETHOSTNAME@ +GL_GNULIB_SIG2STR = @GL_GNULIB_SIG2STR@ GL_GNULIB_SIGABBREV_NP = @GL_GNULIB_SIGABBREV_NP@ GL_GNULIB_SIGACTION = @GL_GNULIB_SIGACTION@ GL_GNULIB_SIGDESCR_NP = @GL_GNULIB_SIGDESCR_NP@ @@ -606,6 +609,7 @@ GL_GNULIB_SLEEP = @GL_GNULIB_SLEEP@ GL_GNULIB_SNPRINTF = @GL_GNULIB_SNPRINTF@ GL_GNULIB_SNZPRINTF = @GL_GNULIB_SNZPRINTF@ GL_GNULIB_SPRINTF_POSIX = @GL_GNULIB_SPRINTF_POSIX@ +GL_GNULIB_STACK_TRACE = @GL_GNULIB_STACK_TRACE@ GL_GNULIB_STAT = @GL_GNULIB_STAT@ GL_GNULIB_STDIO_H_NONBLOCKING = @GL_GNULIB_STDIO_H_NONBLOCKING@ GL_GNULIB_STDIO_H_SIGPIPE = @GL_GNULIB_STDIO_H_SIGPIPE@ @@ -886,6 +890,7 @@ HAVE_SECURE_GETENV = @HAVE_SECURE_GETENV@ HAVE_SETENV = @HAVE_SETENV@ HAVE_SETHOSTNAME = @HAVE_SETHOSTNAME@ HAVE_SETSTATE = @HAVE_SETSTATE@ +HAVE_SIG2STR = @HAVE_SIG2STR@ HAVE_SIGABBREV_NP = @HAVE_SIGABBREV_NP@ HAVE_SIGACTION = @HAVE_SIGACTION@ HAVE_SIGDESCR_NP = @HAVE_SIGDESCR_NP@ @@ -900,6 +905,7 @@ HAVE_SPAWN_H = @HAVE_SPAWN_H@ HAVE_STDINT_H = @HAVE_STDINT_H@ HAVE_STPCPY = @HAVE_STPCPY@ HAVE_STPNCPY = @HAVE_STPNCPY@ +HAVE_STR2SIG = @HAVE_STR2SIG@ HAVE_STRCASESTR = @HAVE_STRCASESTR@ HAVE_STRCHRNUL = @HAVE_STRCHRNUL@ HAVE_STRERRORNAME_NP = @HAVE_STRERRORNAME_NP@ @@ -933,6 +939,7 @@ HAVE_TIMESPEC_GET = @HAVE_TIMESPEC_GET@ HAVE_TIMESPEC_GETRES = @HAVE_TIMESPEC_GETRES@ HAVE_TIMEZONE_T = @HAVE_TIMEZONE_T@ HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ +HAVE_TZALLOC = @HAVE_TZALLOC@ HAVE_UNISTD_H = @HAVE_UNISTD_H@ HAVE_UNLINKAT = @HAVE_UNLINKAT@ HAVE_UNLOCKPT = @HAVE_UNLOCKPT@ @@ -1057,6 +1064,7 @@ NDK_BUILD_MODULES = @NDK_BUILD_MODULES@ NDK_BUILD_NASM = @NDK_BUILD_NASM@ NDK_BUILD_READELF = @NDK_BUILD_READELF@ NDK_BUILD_SDK = @NDK_BUILD_SDK@ +NDK_BUILD_SO_LDFLAGS = @NDK_BUILD_SO_LDFLAGS@ NEXT_ASSERT_H = @NEXT_ASSERT_H@ NEXT_AS_FIRST_DIRECTIVE_ASSERT_H = @NEXT_AS_FIRST_DIRECTIVE_ASSERT_H@ NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@ @@ -1218,6 +1226,7 @@ REPLACE_LINK = @REPLACE_LINK@ REPLACE_LINKAT = @REPLACE_LINKAT@ REPLACE_LOCALTIME = @REPLACE_LOCALTIME@ REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ +REPLACE_LOCALTIME_RZ = @REPLACE_LOCALTIME_RZ@ REPLACE_LSEEK = @REPLACE_LSEEK@ REPLACE_LSTAT = @REPLACE_LSTAT@ REPLACE_MALLOC_FOR_MALLOC_GNU = @REPLACE_MALLOC_FOR_MALLOC_GNU@ @@ -1238,6 +1247,7 @@ REPLACE_MKOSTEMP = @REPLACE_MKOSTEMP@ REPLACE_MKOSTEMPS = @REPLACE_MKOSTEMPS@ REPLACE_MKSTEMP = @REPLACE_MKSTEMP@ REPLACE_MKTIME = @REPLACE_MKTIME@ +REPLACE_MKTIME_Z = @REPLACE_MKTIME_Z@ REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@ REPLACE_NULL = @REPLACE_NULL@ REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@ @@ -2592,8 +2602,8 @@ EXTRA_DIST += cdefs.h libc-config.h endif ## end gnulib module libc-config -## begin gnulib module libgmp -ifeq (,$(OMIT_GNULIB_MODULE_libgmp)) +## begin gnulib module libgmp-mpz +ifeq (,$(OMIT_GNULIB_MODULE_libgmp-mpz)) BUILT_SOURCES += $(GMP_H) @@ -2602,6 +2612,9 @@ ifneq (,$(GL_GENERATE_MINI_GMP_H_CONDITION)) # Build gmp.h as a wrapper for mini-gmp.h when using mini-gmp. gmp.h: $(top_builddir)/config.status echo '#include "mini-gmp.h"' > $@-t + echo '#if GNULIB_LIBGMP_MPQ' >> $@-t + echo '# include "mini-mpq.h"' >> $@-t + echo '#endif' >> $@-t mv $@-t $@ endif ifneq (,$(GL_GENERATE_GMP_GMP_H_CONDITION)) @@ -2625,7 +2638,7 @@ EXTRA_DIST += mini-gmp.c mini-gmp.h EXTRA_libgnu_a_SOURCES += mini-gmp.c endif -## end gnulib module libgmp +## end gnulib module libgmp-mpz ## begin gnulib module limits-h ifeq (,$(OMIT_GNULIB_MODULE_limits-h)) @@ -3001,15 +3014,18 @@ signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''NEXT_SIGNAL_H''@|$(NEXT_SIGNAL_H)|g' \ -e 's/@''GNULIB_PTHREAD_SIGMASK''@/$(GL_GNULIB_PTHREAD_SIGMASK)/g' \ -e 's/@''GNULIB_RAISE''@/$(GL_GNULIB_RAISE)/g' \ + -e 's/@''GNULIB_SIG2STR''@/$(GL_GNULIB_SIG2STR)/g' \ -e 's/@''GNULIB_SIGNAL_H_SIGPIPE''@/$(GL_GNULIB_SIGNAL_H_SIGPIPE)/g' \ -e 's/@''GNULIB_SIGPROCMASK''@/$(GL_GNULIB_SIGPROCMASK)/g' \ -e 's/@''GNULIB_SIGACTION''@/$(GL_GNULIB_SIGACTION)/g' \ -e 's|@''HAVE_POSIX_SIGNALBLOCKING''@|$(HAVE_POSIX_SIGNALBLOCKING)|g' \ -e 's|@''HAVE_PTHREAD_SIGMASK''@|$(HAVE_PTHREAD_SIGMASK)|g' \ -e 's|@''HAVE_RAISE''@|$(HAVE_RAISE)|g' \ + -e 's|@''HAVE_SIG2STR''@|$(HAVE_SIG2STR)|g' \ -e 's|@''HAVE_SIGSET_T''@|$(HAVE_SIGSET_T)|g' \ -e 's|@''HAVE_SIGINFO_T''@|$(HAVE_SIGINFO_T)|g' \ -e 's|@''HAVE_SIGACTION''@|$(HAVE_SIGACTION)|g' \ + -e 's|@''HAVE_STR2SIG''@|$(HAVE_STR2SIG)|g' \ -e 's|@''HAVE_STRUCT_SIGACTION_SA_SIGACTION''@|$(HAVE_STRUCT_SIGACTION_SA_SIGACTION)|g' \ -e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \ -e 's|@''HAVE_SIGHANDLER_T''@|$(HAVE_SIGHANDLER_T)|g' \ @@ -3491,6 +3507,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's/@''GNULIB_RPMATCH''@/$(GL_GNULIB_RPMATCH)/g' \ -e 's/@''GNULIB_SECURE_GETENV''@/$(GL_GNULIB_SECURE_GETENV)/g' \ -e 's/@''GNULIB_SETENV''@/$(GL_GNULIB_SETENV)/g' \ + -e 's/@''GNULIB_STACK_TRACE''@/$(GL_GNULIB_STACK_TRACE)/g' \ -e 's/@''GNULIB_STRTOD''@/$(GL_GNULIB_STRTOD)/g' \ -e 's/@''GNULIB_STRTOF''@/$(GL_GNULIB_STRTOF)/g' \ -e 's/@''GNULIB_STRTOL''@/$(GL_GNULIB_STRTOL)/g' \ @@ -3600,6 +3617,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's|@''REPLACE_STRTOULL''@|$(REPLACE_STRTOULL)|g' \ -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \ -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \ + -e 's|@''CAN_PRINT_STACK_TRACE''@|$(CAN_PRINT_STACK_TRACE)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _Noreturn/r $(_NORETURN_H)' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ @@ -3960,6 +3978,7 @@ sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU $(srcdir)/sys_time.in.h > $@-t $(AM_V_at)mv $@-t $@ MOSTLYCLEANFILES += sys/time.h sys/time.h-t +MOSTLYCLEANDIRS += sys EXTRA_DIST += sys_time.in.h @@ -3987,6 +4006,7 @@ sys/types.h: sys_types.in.h $(top_builddir)/config.status $(srcdir)/sys_types.in.h > $@-t $(AM_V_at)mv $@-t $@ MOSTLYCLEANFILES += sys/types.h sys/types.h-t +MOSTLYCLEANDIRS += sys EXTRA_DIST += sys_types.in.h @@ -4039,11 +4059,14 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''HAVE_TIMESPEC_GET''@|$(HAVE_TIMESPEC_GET)|g' \ -e 's|@''HAVE_TIMESPEC_GETRES''@|$(HAVE_TIMESPEC_GETRES)|g' \ -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \ + -e 's|@''HAVE_TZALLOC''@|$(HAVE_TZALLOC)|g' \ -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \ -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \ -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \ -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \ + -e 's|@''REPLACE_LOCALTIME_RZ''@|$(REPLACE_LOCALTIME_RZ)|g' \ -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ + -e 's|@''REPLACE_MKTIME_Z''@|$(REPLACE_MKTIME_Z)|g' \ -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \ -e 's|@''REPLACE_TIME''@|$(REPLACE_TIME)|g' \ diff --git a/lib/intprops-internal.h b/lib/intprops-internal.h index 443024c6657..c8cc0e20194 100644 --- a/lib/intprops-internal.h +++ b/lib/intprops-internal.h @@ -21,7 +21,7 @@ #include /* Pacify GCC 13.2 in some calls to _GL_EXPR_SIGNED. */ -#if defined __GNUC__ && 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) && !defined __clang__ # pragma GCC diagnostic ignored "-Wtype-limits" #endif @@ -163,7 +163,7 @@ #if _GL_HAS_BUILTIN_MUL_OVERFLOW # if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \ || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \ - && !defined __EDG__) + && !defined __clang__ && !defined __EDG__) # define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r) # else /* Work around GCC bug 91450. */ diff --git a/lib/inttypes.in.h b/lib/inttypes.in.h index b9ab8a4b424..e9c80f3dca5 100644 --- a/lib/inttypes.in.h +++ b/lib/inttypes.in.h @@ -970,7 +970,7 @@ _GL_WARN_ON_USE (imaxdiv, "imaxdiv is unportable - " # define strtoimax rpl_strtoimax # endif _GL_FUNCDECL_RPL (strtoimax, intmax_t, - (const char *restrict, char **restrict, int) + (const char *restrict, char **restrict, int), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strtoimax, intmax_t, (const char *restrict, char **restrict, int)); @@ -978,7 +978,7 @@ _GL_CXXALIAS_RPL (strtoimax, intmax_t, # if !@HAVE_DECL_STRTOIMAX@ # undef strtoimax _GL_FUNCDECL_SYS (strtoimax, intmax_t, - (const char *restrict, char **restrict, int) + (const char *restrict, char **restrict, int), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strtoimax, intmax_t, @@ -1000,7 +1000,7 @@ _GL_WARN_ON_USE (strtoimax, "strtoimax is unportable - " # define strtoumax rpl_strtoumax # endif _GL_FUNCDECL_RPL (strtoumax, uintmax_t, - (const char *restrict, char **restrict, int) + (const char *restrict, char **restrict, int), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strtoumax, uintmax_t, (const char *restrict, char **restrict, int)); @@ -1008,7 +1008,7 @@ _GL_CXXALIAS_RPL (strtoumax, uintmax_t, # if !@HAVE_DECL_STRTOUMAX@ # undef strtoumax _GL_FUNCDECL_SYS (strtoumax, uintmax_t, - (const char *restrict, char **restrict, int) + (const char *restrict, char **restrict, int), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strtoumax, uintmax_t, diff --git a/lib/libc-config.h b/lib/libc-config.h index 70114608fb1..33bdb73660c 100644 --- a/lib/libc-config.h +++ b/lib/libc-config.h @@ -48,6 +48,11 @@ /* From glibc . */ +#if defined __clang__ + /* clang really only groks GNU C 4.2, regardless of its value of __GNUC__. */ +# undef __GNUC_PREREQ +# define __GNUC_PREREQ(maj, min) ((maj) < 4 + ((min) <= 2)) +#endif #ifndef __GNUC_PREREQ # if defined __GNUC__ && defined __GNUC_MINOR__ # define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__)) diff --git a/lib/md5-stream.c b/lib/md5-stream.c index c82f18145e0..fdd2bd8b4bf 100644 --- a/lib/md5-stream.c +++ b/lib/md5-stream.c @@ -132,10 +132,3 @@ md5_stream (FILE *stream, void *resblock) free (buffer); return 0; } - -/* - * Hey Emacs! - * Local Variables: - * coding: utf-8 - * End: - */ diff --git a/lib/mini-gmp-gnulib.c b/lib/mini-gmp-gnulib.c index 6e02d3cefb6..764323f8f78 100644 --- a/lib/mini-gmp-gnulib.c +++ b/lib/mini-gmp-gnulib.c @@ -31,11 +31,11 @@ #include "mini-gmp.h" /* Pacify GCC -Wsuggest-attribute=const, pure, malloc. */ -#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) +#if _GL_GNUC_PREREQ (4, 6) # pragma GCC diagnostic ignored "-Wsuggest-attribute=const" # pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" #endif -#if 8 <= __GNUC__ +#if _GL_GNUC_PREREQ (8, 0) # pragma GCC diagnostic ignored "-Wsuggest-attribute=malloc" #endif diff --git a/lib/sig2str.c b/lib/sig2str.c index c6b91e38498..2dad2cd5a3c 100644 --- a/lib/sig2str.c +++ b/lib/sig2str.c @@ -19,8 +19,10 @@ #include -#include +/* Specification. */ #include + +#include #include #include #include diff --git a/lib/sig2str.h b/lib/sig2str.h index 391da4b1d1c..1abdb140e5a 100644 --- a/lib/sig2str.h +++ b/lib/sig2str.h @@ -19,27 +19,6 @@ #include -/* Don't override system declarations of SIG2STR_MAX, sig2str, str2sig. */ -#ifndef SIG2STR_MAX - -# include "intprops.h" - -/* Size of a buffer needed to hold a signal name like "HUP". */ -# define SIG2STR_MAX (sizeof "SIGRTMAX" + INT_STRLEN_BOUND (int) - 1) - -#ifdef __cplusplus -extern "C" { -#endif - -int sig2str (int, char *); -int str2sig (char const *, int *); - -#ifdef __cplusplus -} -#endif - -#endif - /* An upper bound on signal numbers allowed by the system. */ #if defined _sys_nsig diff --git a/lib/signal.in.h b/lib/signal.in.h index 107226e3dcf..a0effa21ba1 100644 --- a/lib/signal.in.h +++ b/lib/signal.in.h @@ -139,6 +139,47 @@ typedef void (*sighandler_t) (int); #endif +/* Maximum size of a signal name returned by sig2str(), including the + terminating NUL byte. */ +#ifndef SIG2STR_MAX +/* The longest one: "RTMAX", then "+" or "-", then up to 10 digits, then NUL. + Add + 2 as a reserve for the future. */ +# define SIG2STR_MAX (5 + 1 + 10 + 1 + 2) +#endif + +#if @GNULIB_SIG2STR@ +# if !@HAVE_SIG2STR@ +_GL_FUNCDECL_SYS (sig2str, int, (int signo, char *str)); +# endif +_GL_CXXALIAS_SYS (sig2str, int, (int signo, char *str)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (sig2str); +# endif +#elif defined GNULIB_POSIXCHECK +# undef sig2str +# if HAVE_RAW_DECL_SIG2STR +_GL_WARN_ON_USE (sig2str, "sig2str is not portable - " + "use gnulib module sig2str for portability"); +# endif +#endif + +#if @GNULIB_SIG2STR@ +# if !@HAVE_STR2SIG@ +_GL_FUNCDECL_SYS (str2sig, int, (char const *str, int *signo_p)); +# endif +_GL_CXXALIAS_SYS (str2sig, int, (char const *str, int *signo_p)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (str2sig); +# endif +#elif defined GNULIB_POSIXCHECK +# undef str2sig +# if HAVE_RAW_DECL_STR2SIG +_GL_WARN_ON_USE (str2sig, "str2sig is not portable - " + "use gnulib module sig2str for portability"); +# endif +#endif + + #if @GNULIB_PTHREAD_SIGMASK@ # if @REPLACE_PTHREAD_SIGMASK@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -243,7 +284,7 @@ typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1]; # undef sigismember # endif # else -_GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig) +_GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (sigismember, int, (const sigset_t *set, int sig)); @@ -256,7 +297,7 @@ _GL_CXXALIASWARN (sigismember); # undef sigemptyset # endif # else -_GL_FUNCDECL_SYS (sigemptyset, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (sigemptyset, int, (sigset_t *set), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (sigemptyset, int, (sigset_t *set)); _GL_CXXALIASWARN (sigemptyset); @@ -268,7 +309,7 @@ _GL_CXXALIASWARN (sigemptyset); # undef sigaddset # endif # else -_GL_FUNCDECL_SYS (sigaddset, int, (sigset_t *set, int sig) +_GL_FUNCDECL_SYS (sigaddset, int, (sigset_t *set, int sig), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (sigaddset, int, (sigset_t *set, int sig)); @@ -281,7 +322,7 @@ _GL_CXXALIASWARN (sigaddset); # undef sigdelset # endif # else -_GL_FUNCDECL_SYS (sigdelset, int, (sigset_t *set, int sig) +_GL_FUNCDECL_SYS (sigdelset, int, (sigset_t *set, int sig), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (sigdelset, int, (sigset_t *set, int sig)); @@ -294,14 +335,14 @@ _GL_CXXALIASWARN (sigdelset); # undef sigfillset # endif # else -_GL_FUNCDECL_SYS (sigfillset, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (sigfillset, int, (sigset_t *set), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (sigfillset, int, (sigset_t *set)); _GL_CXXALIASWARN (sigfillset); /* Return the set of those blocked signals that are pending. */ # if !@HAVE_POSIX_SIGNALBLOCKING@ -_GL_FUNCDECL_SYS (sigpending, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (sigpending, int, (sigset_t *set), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (sigpending, int, (sigset_t *set)); _GL_CXXALIASWARN (sigpending); diff --git a/lib/stddef.in.h b/lib/stddef.in.h index 0abc4497043..e39268c60c9 100644 --- a/lib/stddef.in.h +++ b/lib/stddef.in.h @@ -131,7 +131,7 @@ typedef long max_align_t; */ #ifndef _GL_ATTRIBUTE_NOTHROW # if defined __cplusplus -# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4 # if __cplusplus >= 201103L # define _GL_ATTRIBUTE_NOTHROW noexcept (true) # else @@ -194,7 +194,7 @@ typedef union # ifndef _GL_HAS_BUILTIN_UNREACHABLE # if defined __clang_major__ && __clang_major__ < 5 # define _GL_HAS_BUILTIN_UNREACHABLE 0 -# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) +# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) && !defined __clang__ # define _GL_HAS_BUILTIN_UNREACHABLE 1 # elif defined __has_builtin # define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) diff --git a/lib/stdio.in.h b/lib/stdio.in.h index 38572382d46..36fd6a72ceb 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -64,8 +64,8 @@ #define _@GUARD_PREFIX@_STDIO_H /* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT, - _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NOTHROW, GNULIB_POSIXCHECK, - HAVE_RAW_DECL_*. */ + _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW, + GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ #if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif @@ -120,7 +120,7 @@ that can be freed by passing them as the Ith argument to the function F. */ #ifndef _GL_ATTRIBUTE_DEALLOC -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) # else # define _GL_ATTRIBUTE_DEALLOC(f, i) @@ -155,7 +155,7 @@ */ #ifndef _GL_ATTRIBUTE_NOTHROW # if defined __cplusplus -# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4 # if __cplusplus >= 201103L # define _GL_ATTRIBUTE_NOTHROW noexcept (true) # else @@ -178,7 +178,7 @@ standardized by ISO C99 and POSIX. _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */ /* __gnu_printf__ is supported in GCC >= 4.4. */ -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) +#if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4) && !defined __clang__ # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__ #else # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__ @@ -289,7 +289,7 @@ directives nor widths, the only possible failure codes are ENOMEM and the possible failure codes from write(), excluding EINTR. */ _GL_FUNCDECL_SYS (dzprintf, off64_t, - (int fd, const char *restrict format, ...) + (int fd, const char *restrict format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_SYS (dzprintf, off64_t, @@ -304,13 +304,13 @@ _GL_CXXALIAS_SYS (dzprintf, off64_t, # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define dprintf rpl_dprintf # endif -_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...) +_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...)); # else # if !@HAVE_DPRINTF@ -_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...) +_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) _GL_ARG_NONNULL ((2))); # endif @@ -333,7 +333,7 @@ _GL_WARN_ON_USE (dprintf, "dprintf is unportable - " # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define fclose rpl_fclose # endif -_GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (fclose, int, (FILE *stream), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (fclose, int, (FILE *stream)); # else _GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); @@ -380,9 +380,10 @@ _GL_CXXALIASWARN (fcloseall); # define fdopen rpl_fdopen # endif _GL_FUNCDECL_RPL (fdopen, FILE *, - (int fd, const char *mode) + (int fd, const char *mode), _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) - _GL_ATTRIBUTE_MALLOC); + _GL_ATTRIBUTE_MALLOC + _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); # elif defined _WIN32 && !defined __CYGWIN__ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -391,36 +392,38 @@ _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); # endif _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode)); # else -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (fdopen, FILE *, - (int fd, const char *mode) - _GL_ATTRIBUTE_NOTHROW + (int fd, const char *mode), _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) - _GL_ATTRIBUTE_MALLOC); + _GL_ATTRIBUTE_MALLOC + _GL_ATTRIBUTE_NODISCARD) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (fdopen, FILE *, - (int fd, const char *mode) + (int fd, const char *mode), _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) - _GL_ATTRIBUTE_MALLOC); + _GL_ATTRIBUTE_MALLOC + _GL_ATTRIBUTE_NODISCARD); # endif # endif _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); # endif _GL_CXXALIASWARN (fdopen); #else -# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen +# if @GNULIB_FCLOSE@ && (__GNUC__ >= 11 && !defined __clang__) && !defined fdopen /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (fdopen, FILE *, - (int fd, const char *mode) - _GL_ATTRIBUTE_NOTHROW + (int fd, const char *mode), _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) - _GL_ATTRIBUTE_MALLOC); + _GL_ATTRIBUTE_MALLOC) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (fdopen, FILE *, - (int fd, const char *mode) + (int fd, const char *mode), _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) _GL_ATTRIBUTE_MALLOC); # endif @@ -479,7 +482,7 @@ _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - " # undef fgetc # define fgetc rpl_fgetc # endif -_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream)); # else _GL_CXXALIAS_SYS (fgetc, int, (FILE *stream)); @@ -496,8 +499,8 @@ _GL_CXXALIASWARN (fgetc); # define fgets rpl_fgets # endif _GL_FUNCDECL_RPL (fgets, char *, - (char *restrict s, int n, FILE *restrict stream) - _GL_ARG_NONNULL ((1, 3))); + (char *restrict s, int n, FILE *restrict stream), + _GL_ARG_NONNULL ((1, 3)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (fgets, char *, (char *restrict s, int n, FILE *restrict stream)); # else @@ -533,17 +536,18 @@ _GL_CXXALIASWARN (fileno); # define fopen rpl_fopen # endif _GL_FUNCDECL_RPL (fopen, FILE *, - (const char *restrict filename, const char *restrict mode) + (const char *restrict filename, const char *restrict mode), _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) - _GL_ATTRIBUTE_MALLOC); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (fopen, FILE *, (const char *restrict filename, const char *restrict mode)); # else -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ _GL_FUNCDECL_SYS (fopen, FILE *, - (const char *restrict filename, const char *restrict mode) - _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); + (const char *restrict filename, const char *restrict mode), + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (fopen, FILE *, (const char *restrict filename, const char *restrict mode)); @@ -552,10 +556,10 @@ _GL_CXXALIAS_SYS (fopen, FILE *, _GL_CXXALIASWARN (fopen); # endif #else -# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fopen +# if @GNULIB_FCLOSE@ && (__GNUC__ >= 11 && !defined __clang__) && !defined fopen /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ _GL_FUNCDECL_SYS (fopen, FILE *, - (const char *restrict filename, const char *restrict mode) + (const char *restrict filename, const char *restrict mode), _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); # endif # if defined GNULIB_POSIXCHECK @@ -575,7 +579,7 @@ _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX complian directives nor widths, the only possible failure causes are ENOMEM and the possible failure causes from fwrite(). */ _GL_FUNCDECL_SYS (fzprintf, off64_t, - (FILE *restrict fp, const char *restrict format, ...) + (FILE *restrict fp, const char *restrict format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_SYS (fzprintf, off64_t, @@ -594,12 +598,12 @@ _GL_CXXALIAS_SYS (fzprintf, off64_t, # define GNULIB_overrides_fprintf 1 # if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ _GL_FUNCDECL_RPL (fprintf, int, - (FILE *restrict fp, const char *restrict format, ...) + (FILE *restrict fp, const char *restrict format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) _GL_ARG_NONNULL ((1, 2))); # else _GL_FUNCDECL_RPL (fprintf, int, - (FILE *restrict fp, const char *restrict format, ...) + (FILE *restrict fp, const char *restrict format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3) _GL_ARG_NONNULL ((1, 2))); # endif @@ -634,15 +638,17 @@ _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - " # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define fpurge rpl_fpurge # endif -_GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream)); # else # if !@HAVE_DECL_FPURGE@ -_GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (fpurge); +# endif #elif defined GNULIB_POSIXCHECK # undef fpurge # if HAVE_RAW_DECL_FPURGE @@ -657,7 +663,7 @@ _GL_WARN_ON_USE (fpurge, "fpurge is not always present - " # undef fputc # define fputc rpl_fputc # endif -_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); +_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream), _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream)); # else _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); @@ -674,7 +680,7 @@ _GL_CXXALIASWARN (fputc); # define fputs rpl_fputs # endif _GL_FUNCDECL_RPL (fputs, int, - (const char *restrict string, FILE *restrict stream) + (const char *restrict string, FILE *restrict stream), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (fputs, int, (const char *restrict string, FILE *restrict stream)); @@ -695,8 +701,8 @@ _GL_CXXALIASWARN (fputs); # endif _GL_FUNCDECL_RPL (fread, size_t, (void *restrict ptr, size_t s, size_t n, - FILE *restrict stream) - _GL_ARG_NONNULL ((4))); + FILE *restrict stream), + _GL_ARG_NONNULL ((4)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (fread, size_t, (void *restrict ptr, size_t s, size_t n, FILE *restrict stream)); @@ -718,8 +724,8 @@ _GL_CXXALIASWARN (fread); # endif _GL_FUNCDECL_RPL (freopen, FILE *, (const char *restrict filename, const char *restrict mode, - FILE *restrict stream) - _GL_ARG_NONNULL ((2, 3))); + FILE *restrict stream), + _GL_ARG_NONNULL ((2, 3)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (freopen, FILE *, (const char *restrict filename, const char *restrict mode, FILE *restrict stream)); @@ -746,9 +752,9 @@ _GL_WARN_ON_USE (freopen, # define fscanf rpl_fscanf # endif _GL_FUNCDECL_RPL (fscanf, int, - (FILE *restrict stream, const char *restrict format, ...) + (FILE *restrict stream, const char *restrict format, ...), _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3) - _GL_ARG_NONNULL ((1, 2))); + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (fscanf, int, (FILE *restrict stream, const char *restrict format, ...)); # else @@ -802,7 +808,7 @@ _GL_CXXALIASWARN (fscanf); # undef fseek # define fseek rpl_fseek # endif -_GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence) +_GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence)); # else @@ -825,12 +831,12 @@ _GL_CXXALIASWARN (fseek); # undef fseeko # define fseeko rpl_fseeko # endif -_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence) +_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); # else # if ! @HAVE_DECL_FSEEKO@ -_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence) +_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); @@ -868,7 +874,8 @@ _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB " # undef ftell # define ftell rpl_ftell # endif -_GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (ftell, long, (FILE *fp), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (ftell, long, (FILE *fp)); # else _GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); @@ -888,11 +895,13 @@ _GL_CXXALIASWARN (ftell); # undef ftello # define ftello rpl_ftello # endif -_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); # else # if ! @HAVE_DECL_FTELLO@ -_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); # endif @@ -925,7 +934,7 @@ _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB " # endif _GL_FUNCDECL_RPL (fwrite, size_t, (const void *restrict ptr, size_t s, size_t n, - FILE *restrict stream) + FILE *restrict stream), _GL_ARG_NONNULL ((1, 4))); _GL_CXXALIAS_RPL (fwrite, size_t, (const void *restrict ptr, size_t s, size_t n, @@ -940,9 +949,9 @@ _GL_CXXALIAS_SYS (fwrite, size_t, which sometimes causes an unwanted diagnostic for fwrite calls. This affects only function declaration attributes under certain versions of gcc and clang, and is not needed for C++. */ -# if (0 < __USE_FORTIFY_LEVEL \ +# if (0 < __USE_FORTIFY_LEVEL \ && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \ - && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \ + && (3 < __GNUC__ + (4 <= __GNUC_MINOR__) || defined __clang__) \ && !defined __cplusplus) # undef fwrite # undef fwrite_unlocked @@ -969,7 +978,7 @@ _GL_CXXALIASWARN (fwrite); # undef getc # define getc rpl_fgetc # endif -_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream)); # else _GL_CXXALIAS_SYS (getc, int, (FILE *stream)); @@ -1010,8 +1019,8 @@ _GL_CXXALIASWARN (getchar); _GL_FUNCDECL_RPL (getdelim, ssize_t, (char **restrict lineptr, size_t *restrict linesize, int delimiter, - FILE *restrict stream) - _GL_ARG_NONNULL ((1, 2, 4))); + FILE *restrict stream), + _GL_ARG_NONNULL ((1, 2, 4)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (getdelim, ssize_t, (char **restrict lineptr, size_t *restrict linesize, int delimiter, @@ -1021,8 +1030,8 @@ _GL_CXXALIAS_RPL (getdelim, ssize_t, _GL_FUNCDECL_SYS (getdelim, ssize_t, (char **restrict lineptr, size_t *restrict linesize, int delimiter, - FILE *restrict stream) - _GL_ARG_NONNULL ((1, 2, 4))); + FILE *restrict stream), + _GL_ARG_NONNULL ((1, 2, 4)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (getdelim, ssize_t, (char **restrict lineptr, size_t *restrict linesize, @@ -1054,8 +1063,8 @@ _GL_WARN_ON_USE (getdelim, "getdelim is unportable - " # endif _GL_FUNCDECL_RPL (getline, ssize_t, (char **restrict lineptr, size_t *restrict linesize, - FILE *restrict stream) - _GL_ARG_NONNULL ((1, 2, 3))); + FILE *restrict stream), + _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (getline, ssize_t, (char **restrict lineptr, size_t *restrict linesize, FILE *restrict stream)); @@ -1063,8 +1072,8 @@ _GL_CXXALIAS_RPL (getline, ssize_t, # if !@HAVE_DECL_GETLINE@ _GL_FUNCDECL_SYS (getline, ssize_t, (char **restrict lineptr, size_t *restrict linesize, - FILE *restrict stream) - _GL_ARG_NONNULL ((1, 2, 3))); + FILE *restrict stream), + _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (getline, ssize_t, (char **restrict lineptr, size_t *restrict linesize, @@ -1126,13 +1135,13 @@ struct obstack; directives nor widths, the only possible failure code is through obstack_alloc_failed_handler. */ _GL_FUNCDECL_SYS (obstack_zprintf, ptrdiff_t, - (struct obstack *obs, const char *format, ...) + (struct obstack *obs, const char *format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_SYS (obstack_zprintf, ptrdiff_t, (struct obstack *obs, const char *format, ...)); _GL_FUNCDECL_SYS (obstack_vzprintf, ptrdiff_t, - (struct obstack *obs, const char *format, va_list args) + (struct obstack *obs, const char *format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_SYS (obstack_vzprintf, ptrdiff_t, @@ -1151,7 +1160,7 @@ struct obstack; # define obstack_printf rpl_obstack_printf # endif _GL_FUNCDECL_RPL (obstack_printf, int, - (struct obstack *obs, const char *format, ...) + (struct obstack *obs, const char *format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (obstack_printf, int, @@ -1159,7 +1168,7 @@ _GL_CXXALIAS_RPL (obstack_printf, int, # else # if !@HAVE_DECL_OBSTACK_PRINTF@ _GL_FUNCDECL_SYS (obstack_printf, int, - (struct obstack *obs, const char *format, ...) + (struct obstack *obs, const char *format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) _GL_ARG_NONNULL ((1, 2))); # endif @@ -1172,7 +1181,7 @@ _GL_CXXALIASWARN (obstack_printf); # define obstack_vprintf rpl_obstack_vprintf # endif _GL_FUNCDECL_RPL (obstack_vprintf, int, - (struct obstack *obs, const char *format, va_list args) + (struct obstack *obs, const char *format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (obstack_vprintf, int, @@ -1180,7 +1189,7 @@ _GL_CXXALIAS_RPL (obstack_vprintf, int, # else # if !@HAVE_DECL_OBSTACK_PRINTF@ _GL_FUNCDECL_SYS (obstack_vprintf, int, - (struct obstack *obs, const char *format, va_list args) + (struct obstack *obs, const char *format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) _GL_ARG_NONNULL ((1, 2))); # endif @@ -1192,7 +1201,7 @@ _GL_CXXALIASWARN (obstack_vprintf); #if @GNULIB_PCLOSE@ # if !@HAVE_PCLOSE@ -_GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (pclose, int, (FILE *stream), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (pclose, int, (FILE *stream)); _GL_CXXALIASWARN (pclose); @@ -1234,25 +1243,26 @@ _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " # define popen rpl_popen # endif _GL_FUNCDECL_RPL (popen, FILE *, - (const char *cmd, const char *mode) + (const char *cmd, const char *mode), _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) - _GL_ATTRIBUTE_MALLOC); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); # else -# if !@HAVE_POPEN@ || __GNUC__ >= 11 +# if !@HAVE_POPEN@ || (__GNUC__ >= 11 && !defined __clang__) _GL_FUNCDECL_SYS (popen, FILE *, - (const char *cmd, const char *mode) + (const char *cmd, const char *mode), _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) - _GL_ATTRIBUTE_MALLOC); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); # endif _GL_CXXALIASWARN (popen); #else -# if @GNULIB_PCLOSE@ && __GNUC__ >= 11 && !defined popen +# if @GNULIB_PCLOSE@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined popen /* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */ _GL_FUNCDECL_SYS (popen, FILE *, - (const char *cmd, const char *mode) + (const char *cmd, const char *mode), _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) _GL_ATTRIBUTE_MALLOC); # endif @@ -1273,7 +1283,7 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " Therefore, if the format string is valid and does not use %ls/%lc directives nor widths, the only possible failure causes are ENOMEM and the possible failure causes from fwrite(). */ -_GL_FUNCDECL_SYS (zprintf, off64_t, (const char *restrict format, ...) +_GL_FUNCDECL_SYS (zprintf, off64_t, (const char *restrict format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_SYS (zprintf, off64_t, (const char *restrict format, ...)); @@ -1294,14 +1304,14 @@ _GL_CXXALIAS_SYS (zprintf, off64_t, (const char *restrict format, ...)); _GL_FUNCDECL_RPL_1 (__printf__, int, (const char *restrict format, ...) __asm__ (@ASM_SYMBOL_PREFIX@ - _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) + _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) _GL_ARG_NONNULL ((1))); # else _GL_FUNCDECL_RPL_1 (__printf__, int, (const char *restrict format, ...) __asm__ (@ASM_SYMBOL_PREFIX@ - _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) + _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)), _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2) _GL_ARG_NONNULL ((1))); # endif @@ -1311,7 +1321,7 @@ _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); # define printf rpl_printf # endif _GL_FUNCDECL_RPL (printf, int, - (const char *restrict format, ...) + (const char *restrict format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...)); @@ -1340,7 +1350,7 @@ _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - " # undef putc # define putc rpl_fputc # endif -_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); +_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream), _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream)); # else _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); @@ -1372,7 +1382,7 @@ _GL_CXXALIASWARN (putchar); # undef puts # define puts rpl_puts # endif -_GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (puts, int, (const char *string), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (puts, int, (const char *string)); # else _GL_CXXALIAS_SYS (puts, int, (const char *string)); @@ -1412,7 +1422,7 @@ _GL_CXXALIASWARN (putw); # undef remove # define remove rpl_remove # endif -_GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (remove, int, (const char *name), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (remove, int, (const char *name)); # else _GL_CXXALIAS_SYS (remove, int, (const char *name)); @@ -1434,7 +1444,7 @@ _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - " # define rename rpl_rename # endif _GL_FUNCDECL_RPL (rename, int, - (const char *old_filename, const char *new_filename) + (const char *old_filename, const char *new_filename), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (rename, int, (const char *old_filename, const char *new_filename)); @@ -1459,14 +1469,14 @@ _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - " # define renameat rpl_renameat # endif _GL_FUNCDECL_RPL (renameat, int, - (int fd1, char const *file1, int fd2, char const *file2) + (int fd1, char const *file1, int fd2, char const *file2), _GL_ARG_NONNULL ((2, 4))); _GL_CXXALIAS_RPL (renameat, int, (int fd1, char const *file1, int fd2, char const *file2)); # else # if !@HAVE_RENAMEAT@ _GL_FUNCDECL_SYS (renameat, int, - (int fd1, char const *file1, int fd2, char const *file2) + (int fd1, char const *file1, int fd2, char const *file2), _GL_ARG_NONNULL ((2, 4))); # endif _GL_CXXALIAS_SYS (renameat, int, @@ -1492,18 +1502,18 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - " _GL_FUNCDECL_RPL_1 (__scanf__, int, (const char *restrict format, ...) __asm__ (@ASM_SYMBOL_PREFIX@ - _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)) + _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)), _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) - _GL_ARG_NONNULL ((1))); + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...)); # else # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef scanf # define scanf rpl_scanf # endif -_GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...) +_GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...), _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) - _GL_ARG_NONNULL ((1))); + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...)); # endif # else @@ -1525,7 +1535,7 @@ _GL_CXXALIASWARN (scanf); directives nor widths, the only possible failure code is ENOMEM. */ _GL_FUNCDECL_SYS (snzprintf, ptrdiff_t, (char *restrict str, size_t size, - const char *restrict format, ...) + const char *restrict format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) _GL_ARG_NONNULL ((3))); _GL_CXXALIAS_SYS (snzprintf, ptrdiff_t, @@ -1546,7 +1556,7 @@ _GL_CXXALIAS_SYS (snzprintf, ptrdiff_t, # define GNULIB_overrides_snprintf 1 _GL_FUNCDECL_RPL (snprintf, int, (char *restrict str, size_t size, - const char *restrict format, ...) + const char *restrict format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) _GL_ARG_NONNULL ((3))); _GL_CXXALIAS_RPL (snprintf, int, @@ -1556,7 +1566,7 @@ _GL_CXXALIAS_RPL (snprintf, int, # if !@HAVE_DECL_SNPRINTF@ _GL_FUNCDECL_SYS (snprintf, int, (char *restrict str, size_t size, - const char *restrict format, ...) + const char *restrict format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) _GL_ARG_NONNULL ((3))); # endif @@ -1584,7 +1594,7 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - " directives nor widths, the only possible failure code is ENOMEM. */ _GL_FUNCDECL_SYS (szprintf, ptrdiff_t, (char *restrict str, - const char *restrict format, ...) + const char *restrict format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_SYS (szprintf, ptrdiff_t, @@ -1611,7 +1621,7 @@ _GL_CXXALIAS_SYS (szprintf, ptrdiff_t, # endif # define GNULIB_overrides_sprintf 1 _GL_FUNCDECL_RPL (sprintf, int, - (char *restrict str, const char *restrict format, ...) + (char *restrict str, const char *restrict format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (sprintf, int, @@ -1652,16 +1662,18 @@ _GL_CXXALIASWARN (tempnam); # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define tmpfile rpl_tmpfile # endif -_GL_FUNCDECL_RPL (tmpfile, FILE *, (void) +_GL_FUNCDECL_RPL (tmpfile, FILE *, (void), _GL_ATTRIBUTE_DEALLOC (fclose, 1) - _GL_ATTRIBUTE_MALLOC); + _GL_ATTRIBUTE_MALLOC + _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); # else -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ -_GL_FUNCDECL_SYS (tmpfile, FILE *, (void) +_GL_FUNCDECL_SYS (tmpfile, FILE *, (void), _GL_ATTRIBUTE_DEALLOC (fclose, 1) - _GL_ATTRIBUTE_MALLOC); + _GL_ATTRIBUTE_MALLOC + _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); # endif @@ -1669,9 +1681,10 @@ _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); _GL_CXXALIASWARN (tmpfile); # endif #else -# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile +# if @GNULIB_FCLOSE@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined tmpfile /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ -_GL_FUNCDECL_SYS (tmpfile, FILE *, (void) +_GL_FUNCDECL_SYS (tmpfile, FILE *, (void), _GL_ATTRIBUTE_DEALLOC (fclose, 1) _GL_ATTRIBUTE_MALLOC); # endif @@ -1694,15 +1707,17 @@ _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " Therefore, if the format string is valid and does not use %ls/%lc directives nor widths, the only possible failure code is ENOMEM. */ _GL_FUNCDECL_SYS (aszprintf, ptrdiff_t, - (char **result, const char *format, ...) + (char **result, const char *format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) - _GL_ARG_NONNULL ((1, 2))); + _GL_ARG_NONNULL ((1, 2)) + _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_SYS (aszprintf, ptrdiff_t, (char **result, const char *format, ...)); _GL_FUNCDECL_SYS (vaszprintf, ptrdiff_t, - (char **result, const char *format, va_list args) + (char **result, const char *format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) - _GL_ARG_NONNULL ((1, 2))); + _GL_ARG_NONNULL ((1, 2)) + _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_SYS (vaszprintf, ptrdiff_t, (char **result, const char *format, va_list args)); #endif @@ -1718,17 +1733,19 @@ _GL_CXXALIAS_SYS (vaszprintf, ptrdiff_t, # endif # define GNULIB_overrides_asprintf _GL_FUNCDECL_RPL (asprintf, int, - (char **result, const char *format, ...) + (char **result, const char *format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) - _GL_ARG_NONNULL ((1, 2))); + _GL_ARG_NONNULL ((1, 2)) + _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (asprintf, int, (char **result, const char *format, ...)); # else # if !@HAVE_VASPRINTF@ _GL_FUNCDECL_SYS (asprintf, int, - (char **result, const char *format, ...) + (char **result, const char *format, ...), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) - _GL_ARG_NONNULL ((1, 2))); + _GL_ARG_NONNULL ((1, 2)) + _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (asprintf, int, (char **result, const char *format, ...)); @@ -1740,17 +1757,19 @@ _GL_CXXALIASWARN (asprintf); # endif # define GNULIB_overrides_vasprintf 1 _GL_FUNCDECL_RPL (vasprintf, int, - (char **result, const char *format, va_list args) + (char **result, const char *format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) - _GL_ARG_NONNULL ((1, 2))); + _GL_ARG_NONNULL ((1, 2)) + _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (vasprintf, int, (char **result, const char *format, va_list args)); # else # if !@HAVE_VASPRINTF@ _GL_FUNCDECL_SYS (vasprintf, int, - (char **result, const char *format, va_list args) + (char **result, const char *format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) - _GL_ARG_NONNULL ((1, 2))); + _GL_ARG_NONNULL ((1, 2)) + _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (vasprintf, int, (char **result, const char *format, va_list args)); @@ -1767,7 +1786,7 @@ _GL_CXXALIASWARN (vasprintf); directives nor widths, the only possible failure codes are ENOMEM and the possible failure codes from write(), excluding EINTR. */ _GL_FUNCDECL_SYS (vdzprintf, off64_t, - (int fd, const char *restrict format, va_list args) + (int fd, const char *restrict format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_SYS (vdzprintf, off64_t, @@ -1783,7 +1802,7 @@ _GL_CXXALIAS_SYS (vdzprintf, off64_t, # define vdprintf rpl_vdprintf # endif _GL_FUNCDECL_RPL (vdprintf, int, - (int fd, const char *restrict format, va_list args) + (int fd, const char *restrict format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (vdprintf, int, @@ -1791,7 +1810,7 @@ _GL_CXXALIAS_RPL (vdprintf, int, # else # if !@HAVE_VDPRINTF@ _GL_FUNCDECL_SYS (vdprintf, int, - (int fd, const char *restrict format, va_list args) + (int fd, const char *restrict format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) _GL_ARG_NONNULL ((2))); # endif @@ -1821,7 +1840,7 @@ _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " and the possible failure causes from fwrite(). */ _GL_FUNCDECL_SYS (vfzprintf, off64_t, (FILE *restrict fp, - const char *restrict format, va_list args) + const char *restrict format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_SYS (vfzprintf, off64_t, @@ -1842,13 +1861,13 @@ _GL_CXXALIAS_SYS (vfzprintf, off64_t, # if @GNULIB_VFPRINTF_POSIX@ _GL_FUNCDECL_RPL (vfprintf, int, (FILE *restrict fp, - const char *restrict format, va_list args) + const char *restrict format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) _GL_ARG_NONNULL ((1, 2))); # else _GL_FUNCDECL_RPL (vfprintf, int, (FILE *restrict fp, - const char *restrict format, va_list args) + const char *restrict format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0) _GL_ARG_NONNULL ((1, 2))); # endif @@ -1885,9 +1904,9 @@ _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - " # endif _GL_FUNCDECL_RPL (vfscanf, int, (FILE *restrict stream, - const char *restrict format, va_list args) + const char *restrict format, va_list args), _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0) - _GL_ARG_NONNULL ((1, 2))); + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (vfscanf, int, (FILE *restrict stream, const char *restrict format, va_list args)); @@ -1909,9 +1928,10 @@ _GL_CXXALIASWARN (vfscanf); Therefore, if the format string is valid and does not use %ls/%lc directives nor widths, the only possible failure causes are ENOMEM and the possible failure causes from fwrite(). */ -_GL_FUNCDECL_SYS (vzprintf, off64_t, (const char *restrict format, va_list args) - _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0) - _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (vzprintf, off64_t, + (const char *restrict format, va_list args), + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0) + _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_SYS (vzprintf, off64_t, (const char *restrict format, va_list args)); #endif @@ -1927,11 +1947,11 @@ _GL_CXXALIAS_SYS (vzprintf, off64_t, # endif # define GNULIB_overrides_vprintf 1 # if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ -_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args) +_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0) _GL_ARG_NONNULL ((1))); # else -_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args) +_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0) _GL_ARG_NONNULL ((1))); # endif @@ -1963,9 +1983,9 @@ _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - " # undef vscanf # define vscanf rpl_vscanf # endif -_GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args) +_GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args), _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0) - _GL_ARG_NONNULL ((1))); + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args)); # else _GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args)); @@ -1986,7 +2006,7 @@ _GL_CXXALIASWARN (vscanf); directives nor widths, the only possible failure code is ENOMEM. */ _GL_FUNCDECL_SYS (vsnzprintf, ptrdiff_t, (char *restrict str, size_t size, - const char *restrict format, va_list args) + const char *restrict format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) _GL_ARG_NONNULL ((3))); _GL_CXXALIAS_SYS (vsnzprintf, ptrdiff_t, @@ -2007,7 +2027,7 @@ _GL_CXXALIAS_SYS (vsnzprintf, ptrdiff_t, # define GNULIB_overrides_vsnprintf 1 _GL_FUNCDECL_RPL (vsnprintf, int, (char *restrict str, size_t size, - const char *restrict format, va_list args) + const char *restrict format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) _GL_ARG_NONNULL ((3))); _GL_CXXALIAS_RPL (vsnprintf, int, @@ -2017,7 +2037,7 @@ _GL_CXXALIAS_RPL (vsnprintf, int, # if !@HAVE_DECL_VSNPRINTF@ _GL_FUNCDECL_SYS (vsnprintf, int, (char *restrict str, size_t size, - const char *restrict format, va_list args) + const char *restrict format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) _GL_ARG_NONNULL ((3))); # endif @@ -2045,7 +2065,7 @@ _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " directives nor widths, the only possible failure code is ENOMEM. */ _GL_FUNCDECL_SYS (vszprintf, ptrdiff_t, (char *restrict str, - const char *restrict format, va_list args) + const char *restrict format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_SYS (vszprintf, ptrdiff_t, @@ -2064,7 +2084,7 @@ _GL_CXXALIAS_SYS (vszprintf, ptrdiff_t, # define GNULIB_overrides_vsprintf 1 _GL_FUNCDECL_RPL (vsprintf, int, (char *restrict str, - const char *restrict format, va_list args) + const char *restrict format, va_list args), _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (vsprintf, int, diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index e42368eef27..1ec96c8b249 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -51,8 +51,8 @@ #define _@GUARD_PREFIX@_STDLIB_H /* This file uses _Noreturn, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, - _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, - HAVE_RAW_DECL_*. */ + _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, + GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ #if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif @@ -132,7 +132,7 @@ struct random_data that can be freed by passing them as the Ith argument to the function F. */ #ifndef _GL_ATTRIBUTE_DEALLOC -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) # else # define _GL_ATTRIBUTE_DEALLOC(f, i) @@ -161,7 +161,7 @@ struct random_data */ #ifndef _GL_ATTRIBUTE_NOTHROW # if defined __cplusplus -# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4 # if __cplusplus >= 201103L # define _GL_ATTRIBUTE_NOTHROW noexcept (true) # else @@ -241,6 +241,9 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - " #if @GNULIB_ABORT_DEBUG@ +/* Terminates the current process with signal SIGABRT. + Note: While the original abort() function is safe to call in signal handlers, + the overridden abort() function is not. */ # if @REPLACE_ABORT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef abort @@ -255,14 +258,6 @@ _GL_CXXALIAS_SYS (abort, void, (void)); _GL_CXXALIASWARN (abort); # endif #endif -#if @GNULIB_ABORT_DEBUG@ && @REPLACE_ABORT@ -_GL_EXTERN_C void _gl_pre_abort (void); -#else -# if !GNULIB_defined_gl_pre_abort -# define _gl_pre_abort() /* nothing */ -# define GNULIB_defined_gl_pre_abort 1 -# endif -#endif #if @GNULIB_FREE_POSIX@ @@ -272,7 +267,7 @@ _GL_EXTERN_C void _gl_pre_abort (void); # define free rpl_free # endif # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) -_GL_FUNCDECL_RPL (free, void, (void *ptr) _GL_ATTRIBUTE_NOTHROW); +_GL_FUNCDECL_RPL (free, void, (void *ptr)) _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_RPL (free, void, (void *ptr)); # endif @@ -299,22 +294,25 @@ _GL_WARN_ON_USE (free, "free is not future POSIX compliant everywhere - " # define aligned_alloc rpl_aligned_alloc # endif _GL_FUNCDECL_RPL (aligned_alloc, void *, - (size_t alignment, size_t size) - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + (size_t alignment, size_t size), + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size)); # else # if @HAVE_ALIGNED_ALLOC@ -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ /* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2 _GL_FUNCDECL_SYS (aligned_alloc, void *, - (size_t alignment, size_t size) - _GL_ATTRIBUTE_NOTHROW - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + (size_t alignment, size_t size), + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_NODISCARD) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (aligned_alloc, void *, - (size_t alignment, size_t size) - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + (size_t alignment, size_t size), + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_NODISCARD); # endif # endif _GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size)); @@ -324,16 +322,17 @@ _GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size)); _GL_CXXALIASWARN (aligned_alloc); # endif #else -# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined aligned_alloc +# if @GNULIB_FREE_POSIX@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined aligned_alloc /* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2 _GL_FUNCDECL_SYS (aligned_alloc, void *, - (size_t alignment, size_t size) - _GL_ATTRIBUTE_NOTHROW - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + (size_t alignment, size_t size), + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (aligned_alloc, void *, - (size_t alignment, size_t size) + (size_t alignment, size_t size), _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); # endif # endif @@ -350,9 +349,10 @@ _GL_WARN_ON_USE (aligned_alloc, "aligned_alloc is not portable - " /* Parse a signed decimal integer. Returns the value of the integer. Errors are not detected. */ # if !@HAVE_ATOLL@ -_GL_FUNCDECL_SYS (atoll, long long, (const char *string) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (atoll, long long, + (const char *string), + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (atoll, long long, (const char *string)); _GL_CXXALIASWARN (atoll); @@ -372,21 +372,24 @@ _GL_WARN_ON_USE (atoll, "atoll is unportable - " # define calloc rpl_calloc # endif _GL_FUNCDECL_RPL (calloc, void *, - (size_t nmemb, size_t size) - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + (size_t nmemb, size_t size), + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size)); # else -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ /* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (calloc, void *, - (size_t nmemb, size_t size) - _GL_ATTRIBUTE_NOTHROW - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + (size_t nmemb, size_t size), + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_NODISCARD) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (calloc, void *, - (size_t nmemb, size_t size) - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + (size_t nmemb, size_t size), + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_NODISCARD); # endif # endif _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); @@ -395,16 +398,17 @@ _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); _GL_CXXALIASWARN (calloc); # endif #else -# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined calloc +# if @GNULIB_FREE_POSIX@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined calloc /* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (calloc, void *, - (size_t nmemb, size_t size) - _GL_ATTRIBUTE_NOTHROW - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + (size_t nmemb, size_t size), + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (calloc, void *, - (size_t nmemb, size_t size) + (size_t nmemb, size_t size), _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); # endif # endif @@ -422,23 +426,26 @@ _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - " # define canonicalize_file_name rpl_canonicalize_file_name # endif _GL_FUNCDECL_RPL (canonicalize_file_name, char *, - (const char *name) + (const char *name), _GL_ARG_NONNULL ((1)) - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name)); # else -# if !@HAVE_CANONICALIZE_FILE_NAME@ || __GNUC__ >= 11 +# if !@HAVE_CANONICALIZE_FILE_NAME@ || (__GNUC__ >= 11 && !defined __clang__) # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (canonicalize_file_name, char *, - (const char *name) - _GL_ATTRIBUTE_NOTHROW + (const char *name), _GL_ARG_NONNULL ((1)) - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_NODISCARD) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (canonicalize_file_name, char *, - (const char *name) + (const char *name), _GL_ARG_NONNULL ((1)) - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_NODISCARD); # endif # endif _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name)); @@ -449,18 +456,19 @@ _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name)); # endif _GL_CXXALIASWARN (canonicalize_file_name); #else -# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined canonicalize_file_name +# if @GNULIB_FREE_POSIX@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined canonicalize_file_name /* For -Wmismatched-dealloc: Associate canonicalize_file_name with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (canonicalize_file_name, char *, - (const char *name) - _GL_ATTRIBUTE_NOTHROW + (const char *name), _GL_ARG_NONNULL ((1)) - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (canonicalize_file_name, char *, - (const char *name) + (const char *name), _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); # endif @@ -552,12 +560,12 @@ _GL_CXXALIASWARN (gcvt); # undef getloadavg # define getloadavg rpl_getloadavg # endif -_GL_FUNCDECL_RPL (getloadavg, int, (double loadavg[], int nelem) +_GL_FUNCDECL_RPL (getloadavg, int, (double loadavg[], int nelem), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (getloadavg, int, (double loadavg[], int nelem)); # else # if !@HAVE_DECL_GETLOADAVG@ -_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem) +_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem)); @@ -582,7 +590,7 @@ _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - " # define getprogname rpl_getprogname # endif # if @HAVE_DECL_PROGRAM_INVOCATION_NAME@ -_GL_FUNCDECL_RPL (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE); +_GL_FUNCDECL_RPL (getprogname, const char *, (void), _GL_ATTRIBUTE_PURE); # else _GL_FUNCDECL_RPL (getprogname, const char *, (void)); # endif @@ -590,7 +598,7 @@ _GL_CXXALIAS_RPL (getprogname, const char *, (void)); # else # if !@HAVE_GETPROGNAME@ # if @HAVE_DECL_PROGRAM_INVOCATION_NAME@ -_GL_FUNCDECL_SYS (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE); +_GL_FUNCDECL_SYS (getprogname, const char *, (void), _GL_ATTRIBUTE_PURE); # else _GL_FUNCDECL_SYS (getprogname, const char *, (void)); # endif @@ -626,15 +634,15 @@ _GL_WARN_ON_USE (getprogname, "getprogname is unportable - " # define getsubopt rpl_getsubopt # endif _GL_FUNCDECL_RPL (getsubopt, int, - (char **optionp, char *const *tokens, char **valuep) - _GL_ARG_NONNULL ((1, 2, 3))); + (char **optionp, char *const *tokens, char **valuep), + _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (getsubopt, int, (char **optionp, char *const *tokens, char **valuep)); # else # if !@HAVE_GETSUBOPT@ _GL_FUNCDECL_SYS (getsubopt, int, - (char **optionp, char *const *tokens, char **valuep) - _GL_ARG_NONNULL ((1, 2, 3))); + (char **optionp, char *const *tokens, char **valuep), + _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (getsubopt, int, (char **optionp, char *const *tokens, char **valuep)); @@ -679,21 +687,24 @@ _GL_WARN_ON_USE (grantpt, "grantpt is not portable - " # define malloc rpl_malloc # endif _GL_FUNCDECL_RPL (malloc, void *, - (size_t size) - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + (size_t size), + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (malloc, void *, (size_t size)); # else -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ /* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (malloc, void *, - (size_t size) - _GL_ATTRIBUTE_NOTHROW - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + (size_t size), + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_NODISCARD) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (malloc, void *, - (size_t size) - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + (size_t size), + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_NODISCARD); # endif # endif _GL_CXXALIAS_SYS (malloc, void *, (size_t size)); @@ -702,16 +713,17 @@ _GL_CXXALIAS_SYS (malloc, void *, (size_t size)); _GL_CXXALIASWARN (malloc); # endif #else -# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined malloc +# if @GNULIB_FREE_POSIX@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined malloc /* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (malloc, void *, - (size_t size) - _GL_ATTRIBUTE_NOTHROW - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + (size_t size), + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (malloc, void *, - (size_t size) + (size_t size), _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); # endif # endif @@ -747,7 +759,7 @@ int gl_MB_CUR_MAX (void) # endif _GL_FUNCDECL_RPL (mbstowcs, size_t, (wchar_t *restrict dest, const char *restrict src, - size_t len) + size_t len), _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (mbstowcs, size_t, (wchar_t *restrict dest, const char *restrict src, @@ -805,7 +817,9 @@ _GL_WARN_ON_USE (mbtowc, "mbtowc is not portable - " Returns TEMPLATE, or a null pointer if it cannot get a unique name. The directory is created mode 700. */ # if !@HAVE_MKDTEMP@ -_GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (mkdtemp, char *, + (char * /*template*/), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/)); _GL_CXXALIASWARN (mkdtemp); @@ -835,13 +849,13 @@ _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - " # undef mkostemp # define mkostemp rpl_mkostemp # endif -_GL_FUNCDECL_RPL (mkostemp, int, (char * /*template*/, int /*flags*/) - _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (mkostemp, int, (char * /*template*/, int /*flags*/), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (mkostemp, int, (char * /*template*/, int /*flags*/)); # else # if !@HAVE_MKOSTEMP@ -_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/) - _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)); # endif @@ -876,15 +890,15 @@ _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - " # define mkostemps rpl_mkostemps # endif _GL_FUNCDECL_RPL (mkostemps, int, - (char * /*template*/, int /*suffixlen*/, int /*flags*/) - _GL_ARG_NONNULL ((1))); + (char * /*template*/, int /*suffixlen*/, int /*flags*/), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (mkostemps, int, (char * /*template*/, int /*suffixlen*/, int /*flags*/)); # else # if !@HAVE_MKOSTEMPS@ _GL_FUNCDECL_SYS (mkostemps, int, - (char * /*template*/, int /*suffixlen*/, int /*flags*/) - _GL_ARG_NONNULL ((1))); + (char * /*template*/, int /*suffixlen*/, int /*flags*/), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (mkostemps, int, (char * /*template*/, int /*suffixlen*/, int /*flags*/)); @@ -914,11 +928,13 @@ _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - " # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define mkstemp rpl_mkstemp # endif -_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/)); # else # if ! @HAVE_MKSTEMP@ -_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/)); # endif @@ -943,8 +959,8 @@ _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - " Returns the open file descriptor if successful, otherwise -1 and errno set. */ # if !@HAVE_MKSTEMPS@ -_GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/) - _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)); _GL_CXXALIASWARN (mkstemps); @@ -980,8 +996,8 @@ _GL_CXXALIASWARN (mktemp); # define posix_memalign rpl_posix_memalign # endif _GL_FUNCDECL_RPL (posix_memalign, int, - (void **memptr, size_t alignment, size_t size) - _GL_ARG_NONNULL ((1))); + (void **memptr, size_t alignment, size_t size), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (posix_memalign, int, (void **memptr, size_t alignment, size_t size)); # else @@ -1009,11 +1025,11 @@ _GL_WARN_ON_USE (posix_memalign, "posix_memalign is not portable - " # undef posix_openpt # define posix_openpt rpl_posix_openpt # endif -_GL_FUNCDECL_RPL (posix_openpt, int, (int flags)); +_GL_FUNCDECL_RPL (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (posix_openpt, int, (int flags)); # else # if !@HAVE_POSIX_OPENPT@ -_GL_FUNCDECL_SYS (posix_openpt, int, (int flags)); +_GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (posix_openpt, int, (int flags)); # endif @@ -1036,11 +1052,11 @@ _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - " # undef ptsname # define ptsname rpl_ptsname # endif -_GL_FUNCDECL_RPL (ptsname, char *, (int fd)); +_GL_FUNCDECL_RPL (ptsname, char *, (int fd), _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (ptsname, char *, (int fd)); # else # if !@HAVE_PTSNAME@ -_GL_FUNCDECL_SYS (ptsname, char *, (int fd)); +_GL_FUNCDECL_SYS (ptsname, char *, (int fd), _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (ptsname, char *, (int fd)); # endif @@ -1088,7 +1104,7 @@ _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - " # undef putenv # define putenv rpl_putenv # endif -_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (putenv, int, (char *string), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (putenv, int, (char *string)); # elif defined _WIN32 && !defined __CYGWIN__ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -1147,7 +1163,8 @@ typedef int (*_gl_qsort_r_compar_fn) (void const *, void const *, void *); # endif _GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, _gl_qsort_r_compar_fn compare, - void *arg) _GL_ARG_NONNULL ((1, 4))); + void *arg), + _GL_ARG_NONNULL ((1, 4))); _GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, _gl_qsort_r_compar_fn compare, void *arg)); @@ -1155,7 +1172,8 @@ _GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, # if !@HAVE_QSORT_R@ _GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, _gl_qsort_r_compar_fn compare, - void *arg) _GL_ARG_NONNULL ((1, 4))); + void *arg), + _GL_ARG_NONNULL ((1, 4))); # endif _GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, _gl_qsort_r_compar_fn compare, @@ -1258,14 +1276,14 @@ _GL_WARN_ON_USE (srandom, "srandom is unportable - " # define initstate rpl_initstate # endif _GL_FUNCDECL_RPL (initstate, char *, - (unsigned int seed, char *buf, size_t buf_size) + (unsigned int seed, char *buf, size_t buf_size), _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (initstate, char *, (unsigned int seed, char *buf, size_t buf_size)); # else # if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@ _GL_FUNCDECL_SYS (initstate, char *, - (unsigned int seed, char *buf, size_t buf_size) + (unsigned int seed, char *buf, size_t buf_size), _GL_ARG_NONNULL ((2))); # endif /* Need to cast, because on FreeBSD, the first parameter is @@ -1290,11 +1308,11 @@ _GL_WARN_ON_USE (initstate, "initstate is unportable - " # undef setstate # define setstate rpl_setstate # endif -_GL_FUNCDECL_RPL (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (setstate, char *, (char *arg_state), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (setstate, char *, (char *arg_state)); # else # if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@ -_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state), _GL_ARG_NONNULL ((1))); # endif /* Need to cast, because on Mac OS X 10.13, HP-UX, Solaris the first parameter is const char *arg_state. */ @@ -1318,12 +1336,12 @@ _GL_WARN_ON_USE (setstate, "setstate is unportable - " # undef random_r # define random_r rpl_random_r # endif -_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result) +_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result)); # else # if !@HAVE_RANDOM_R@ -_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result) +_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result), _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); @@ -1344,14 +1362,14 @@ _GL_WARN_ON_USE (random_r, "random_r is unportable - " # define srandom_r rpl_srandom_r # endif _GL_FUNCDECL_RPL (srandom_r, int, - (unsigned int seed, struct random_data *rand_state) + (unsigned int seed, struct random_data *rand_state), _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (srandom_r, int, (unsigned int seed, struct random_data *rand_state)); # else # if !@HAVE_RANDOM_R@ _GL_FUNCDECL_SYS (srandom_r, int, - (unsigned int seed, struct random_data *rand_state) + (unsigned int seed, struct random_data *rand_state), _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (srandom_r, int, @@ -1374,7 +1392,7 @@ _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - " # endif _GL_FUNCDECL_RPL (initstate_r, int, (unsigned int seed, char *buf, size_t buf_size, - struct random_data *rand_state) + struct random_data *rand_state), _GL_ARG_NONNULL ((2, 4))); _GL_CXXALIAS_RPL (initstate_r, int, (unsigned int seed, char *buf, size_t buf_size, @@ -1383,7 +1401,7 @@ _GL_CXXALIAS_RPL (initstate_r, int, # if !@HAVE_RANDOM_R@ _GL_FUNCDECL_SYS (initstate_r, int, (unsigned int seed, char *buf, size_t buf_size, - struct random_data *rand_state) + struct random_data *rand_state), _GL_ARG_NONNULL ((2, 4))); # endif /* Need to cast, because on Haiku, the third parameter is @@ -1408,14 +1426,14 @@ _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - " # define setstate_r rpl_setstate_r # endif _GL_FUNCDECL_RPL (setstate_r, int, - (char *arg_state, struct random_data *rand_state) + (char *arg_state, struct random_data *rand_state), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (setstate_r, int, (char *arg_state, struct random_data *rand_state)); # else # if !@HAVE_RANDOM_R@ _GL_FUNCDECL_SYS (setstate_r, int, - (char *arg_state, struct random_data *rand_state) + (char *arg_state, struct random_data *rand_state), _GL_ARG_NONNULL ((1, 2))); # endif /* Need to cast, because on Haiku, the first parameter is @@ -1441,21 +1459,22 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " # undef realloc # define realloc rpl_realloc # endif -_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size) - _GL_ATTRIBUTE_DEALLOC_FREE); +_GL_FUNCDECL_RPL (realloc, void *, + (void *ptr, size_t size), + _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); # else -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ /* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (realloc, void *, - (void *ptr, size_t size) - _GL_ATTRIBUTE_NOTHROW - _GL_ATTRIBUTE_DEALLOC_FREE); + (void *ptr, size_t size), + _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (realloc, void *, - (void *ptr, size_t size) - _GL_ATTRIBUTE_DEALLOC_FREE); + (void *ptr, size_t size), + _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD); # endif # endif _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); @@ -1464,16 +1483,17 @@ _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); _GL_CXXALIASWARN (realloc); # endif #else -# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined realloc +# if @GNULIB_FREE_POSIX@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined realloc /* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (realloc, void *, - (void *ptr, size_t size) - _GL_ATTRIBUTE_NOTHROW - _GL_ATTRIBUTE_DEALLOC_FREE); + (void *ptr, size_t size), + _GL_ATTRIBUTE_DEALLOC_FREE) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (realloc, void *, - (void *ptr, size_t size) + (void *ptr, size_t size), _GL_ATTRIBUTE_DEALLOC_FREE); # endif # endif @@ -1493,13 +1513,15 @@ _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - " # define reallocarray rpl_reallocarray # endif _GL_FUNCDECL_RPL (reallocarray, void *, - (void *ptr, size_t nmemb, size_t size)); + (void *ptr, size_t nmemb, size_t size), + _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (reallocarray, void *, (void *ptr, size_t nmemb, size_t size)); # else # if ! @HAVE_REALLOCARRAY@ _GL_FUNCDECL_SYS (reallocarray, void *, - (void *ptr, size_t nmemb, size_t size)); + (void *ptr, size_t nmemb, size_t size), + _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (reallocarray, void *, (void *ptr, size_t nmemb, size_t size)); @@ -1521,15 +1543,15 @@ _GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - " # define realpath rpl_realpath # endif _GL_FUNCDECL_RPL (realpath, char *, - (const char *restrict name, char *restrict resolved) - _GL_ARG_NONNULL ((1))); + (const char *restrict name, char *restrict resolved), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (realpath, char *, (const char *restrict name, char *restrict resolved)); # else # if !@HAVE_REALPATH@ _GL_FUNCDECL_SYS (realpath, char *, - (const char *restrict name, char *restrict resolved) - _GL_ARG_NONNULL ((1))); + (const char *restrict name, char *restrict resolved), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (realpath, char *, (const char *restrict name, char *restrict resolved)); @@ -1547,7 +1569,8 @@ _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module " /* Test a user response to a question. Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */ # if !@HAVE_RPMATCH@ -_GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (rpmatch, int, (const char *response), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (rpmatch, int, (const char *response)); _GL_CXXALIASWARN (rpmatch); @@ -1563,7 +1586,8 @@ _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - " /* Look up NAME in the environment, returning 0 in insecure situations. */ # if !@HAVE_SECURE_GETENV@ _GL_FUNCDECL_SYS (secure_getenv, char *, - (char const *name) _GL_ARG_NONNULL ((1))); + (char const *name), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name)); _GL_CXXALIASWARN (secure_getenv); @@ -1584,14 +1608,14 @@ _GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - " # define setenv rpl_setenv # endif _GL_FUNCDECL_RPL (setenv, int, - (const char *name, const char *value, int replace) + (const char *name, const char *value, int replace), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (setenv, int, (const char *name, const char *value, int replace)); # else # if !@HAVE_DECL_SETENV@ _GL_FUNCDECL_SYS (setenv, int, - (const char *name, const char *value, int replace) + (const char *name, const char *value, int replace), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (setenv, int, @@ -1608,6 +1632,19 @@ _GL_WARN_ON_USE (setenv, "setenv is unportable - " # endif #endif +#if @GNULIB_STACK_TRACE@ +/* Prints a stack trace of the current thread to standard error, + if possible. */ +# if @CAN_PRINT_STACK_TRACE@ +_GL_EXTERN_C void print_stack_trace (void); +# else +# if !GNULIB_defined_print_stack_trace +# define print_stack_trace() /* nothing */ +# define GNULIB_defined_print_stack_trace 1 +# endif +# endif +#endif + #if @GNULIB_STRTOD@ /* Parse a double from STRING, updating ENDP if appropriate. */ # if @REPLACE_STRTOD@ @@ -1616,14 +1653,14 @@ _GL_WARN_ON_USE (setenv, "setenv is unportable - " # endif # define GNULIB_defined_strtod_function 1 _GL_FUNCDECL_RPL (strtod, double, - (const char *restrict str, char **restrict endp) + (const char *restrict str, char **restrict endp), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strtod, double, (const char *restrict str, char **restrict endp)); # else # if !@HAVE_STRTOD@ _GL_FUNCDECL_SYS (strtod, double, - (const char *restrict str, char **restrict endp) + (const char *restrict str, char **restrict endp), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strtod, double, @@ -1648,14 +1685,14 @@ _GL_WARN_ON_USE (strtod, "strtod is unportable - " # endif # define GNULIB_defined_strtof_function 1 _GL_FUNCDECL_RPL (strtof, float, - (const char *restrict str, char **restrict endp) + (const char *restrict str, char **restrict endp), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strtof, float, (const char *restrict str, char **restrict endp)); # else # if !@HAVE_STRTOF@ _GL_FUNCDECL_SYS (strtof, float, - (const char *restrict str, char **restrict endp) + (const char *restrict str, char **restrict endp), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strtof, float, @@ -1680,14 +1717,14 @@ _GL_WARN_ON_USE (strtof, "strtof is unportable - " # endif # define GNULIB_defined_strtold_function 1 _GL_FUNCDECL_RPL (strtold, long double, - (const char *restrict str, char **restrict endp) + (const char *restrict str, char **restrict endp), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strtold, long double, (const char *restrict str, char **restrict endp)); # else # if !@HAVE_STRTOLD@ _GL_FUNCDECL_SYS (strtold, long double, - (const char *restrict str, char **restrict endp) + (const char *restrict str, char **restrict endp), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strtold, long double, @@ -1718,7 +1755,7 @@ _GL_WARN_ON_USE (strtold, "strtold is unportable - " # define GNULIB_defined_strtol_function 1 _GL_FUNCDECL_RPL (strtol, long, (const char *restrict string, char **restrict endptr, - int base) + int base), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strtol, long, (const char *restrict string, char **restrict endptr, @@ -1727,7 +1764,7 @@ _GL_CXXALIAS_RPL (strtol, long, # if !@HAVE_STRTOL@ _GL_FUNCDECL_SYS (strtol, long, (const char *restrict string, char **restrict endptr, - int base) + int base), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strtol, long, @@ -1761,7 +1798,7 @@ _GL_WARN_ON_USE (strtol, "strtol is unportable - " # define GNULIB_defined_strtoll_function 1 _GL_FUNCDECL_RPL (strtoll, long long, (const char *restrict string, char **restrict endptr, - int base) + int base), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strtoll, long long, (const char *restrict string, char **restrict endptr, @@ -1770,7 +1807,7 @@ _GL_CXXALIAS_RPL (strtoll, long long, # if !@HAVE_STRTOLL@ _GL_FUNCDECL_SYS (strtoll, long long, (const char *restrict string, char **restrict endptr, - int base) + int base), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strtoll, long long, @@ -1801,7 +1838,7 @@ _GL_WARN_ON_USE (strtoll, "strtoll is unportable - " # define GNULIB_defined_strtoul_function 1 _GL_FUNCDECL_RPL (strtoul, unsigned long, (const char *restrict string, char **restrict endptr, - int base) + int base), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strtoul, unsigned long, (const char *restrict string, char **restrict endptr, @@ -1810,7 +1847,7 @@ _GL_CXXALIAS_RPL (strtoul, unsigned long, # if !@HAVE_STRTOUL@ _GL_FUNCDECL_SYS (strtoul, unsigned long, (const char *restrict string, char **restrict endptr, - int base) + int base), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strtoul, unsigned long, @@ -1844,7 +1881,7 @@ _GL_WARN_ON_USE (strtoul, "strtoul is unportable - " # define GNULIB_defined_strtoull_function 1 _GL_FUNCDECL_RPL (strtoull, unsigned long long, (const char *restrict string, char **restrict endptr, - int base) + int base), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strtoull, unsigned long long, (const char *restrict string, char **restrict endptr, @@ -1853,7 +1890,7 @@ _GL_CXXALIAS_RPL (strtoull, unsigned long long, # if !@HAVE_STRTOULL@ _GL_FUNCDECL_SYS (strtoull, unsigned long long, (const char *restrict string, char **restrict endptr, - int base) + int base), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strtoull, unsigned long long, @@ -1892,11 +1929,11 @@ _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - " # undef unsetenv # define unsetenv rpl_unsetenv # endif -_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (unsetenv, int, (const char *name), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (unsetenv, int, (const char *name)); # else # if !@HAVE_DECL_UNSETENV@ -_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (unsetenv, int, (const char *name), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (unsetenv, int, (const char *name)); # endif diff --git a/lib/strftime.c b/lib/strftime.c index 9b1b27a1fc8..4ddbec04269 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -321,7 +321,7 @@ enum pad_style maximum object size 9223372036854775807", caused by insufficient data flow analysis and value propagation of the 'width_add' expansion when GCC is not optimizing. Cf. . */ -#if __GNUC__ >= 7 && !__OPTIMIZE__ +#if _GL_GNUC_PREREQ (7, 0) && !__OPTIMIZE__ # pragma GCC diagnostic ignored "-Wstringop-overflow" #endif diff --git a/lib/strftime.h b/lib/strftime.h index 8ce62cdb6d7..3179874af97 100644 --- a/lib/strftime.h +++ b/lib/strftime.h @@ -21,11 +21,11 @@ extern "C" { #endif -/* Formats the broken-down time *__TP, with additional __NS nanoseconds, +/* Format the broken-down time *__TP, with additional __NS nanoseconds, into the buffer __S of size __MAXSIZE, according to the rules of the LC_TIME category of the current locale. - Uses the time zone __TZ. + Use the time zone __TZ. If *__TP represents local time, __TZ should be set to tzalloc (getenv ("TZ")). If *__TP represents universal time (a.k.a. GMT), __TZ should be set to @@ -60,15 +60,11 @@ extern "C" { time zone: %z %Z nanosecond %N - Stores the result, as a string with a trailing NUL character, at the - beginning of the array __S[0..__MAXSIZE-1], if it fits, and returns - the length of that string, not counting the trailing NUL. In this case, - errno is preserved if the return value is 0. - If it does not fit, this function sets errno to ERANGE and returns 0. - Upon other errors, this function sets errno and returns 0 as well. - - Note: The errno behavior is in draft POSIX 202x plus some requested - changes to POSIX. + Store the result, as a string with a trailing NUL character, at the + beginning of the array __S[0..__MAXSIZE-1] and return the length of + that string, not counting the trailing NUL, and without changing errno. + If unsuccessful, possibly change the array __S, set errno, and return 0; + errno == ERANGE means the string didn't fit. This function is like strftime, but with two more arguments: * __TZ instead of the local timezone information, diff --git a/lib/string.in.h b/lib/string.in.h index 44ec2e7ecdb..a588e7e2c26 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -79,7 +79,7 @@ that can be freed by passing them as the Ith argument to the function F. */ #ifndef _GL_ATTRIBUTE_DEALLOC -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) # else # define _GL_ATTRIBUTE_DEALLOC(f, i) @@ -115,7 +115,7 @@ */ #ifndef _GL_ATTRIBUTE_NOTHROW # if defined __cplusplus -# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4 # if __cplusplus >= 201103L # define _GL_ATTRIBUTE_NOTHROW noexcept (true) # else @@ -198,7 +198,7 @@ _GL_EXTERN_C void free (void *); #if @GNULIB_EXPLICIT_BZERO@ # if ! @HAVE_EXPLICIT_BZERO@ _GL_FUNCDECL_SYS (explicit_bzero, void, - (void *__dest, size_t __n) _GL_ARG_NONNULL ((1))); + (void *__dest, size_t __n), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n)); _GL_CXXALIASWARN (explicit_bzero); @@ -274,7 +274,7 @@ _GL_CXXALIASWARN (memccpy); # undef memchr # define memchr rpl_memchr # endif -_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) +_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); @@ -313,7 +313,7 @@ _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " # endif _GL_FUNCDECL_RPL (memmem, void *, (void const *__haystack, size_t __haystack_len, - void const *__needle, size_t __needle_len) + void const *__needle, size_t __needle_len), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 3))); _GL_CXXALIAS_RPL (memmem, void *, @@ -323,7 +323,7 @@ _GL_CXXALIAS_RPL (memmem, void *, # if ! @HAVE_DECL_MEMMEM@ _GL_FUNCDECL_SYS (memmem, void *, (void const *__haystack, size_t __haystack_len, - void const *__needle, size_t __needle_len) + void const *__needle, size_t __needle_len), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 3))); # endif @@ -351,7 +351,7 @@ _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - " # endif _GL_FUNCDECL_RPL (mempcpy, void *, (void *restrict __dest, void const *restrict __src, - size_t __n) + size_t __n), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (mempcpy, void *, (void *restrict __dest, void const *restrict __src, @@ -360,7 +360,7 @@ _GL_CXXALIAS_RPL (mempcpy, void *, # if !@HAVE_MEMPCPY@ _GL_FUNCDECL_SYS (mempcpy, void *, (void *restrict __dest, void const *restrict __src, - size_t __n) + size_t __n), _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (mempcpy, void *, @@ -381,7 +381,7 @@ _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " /* Search backwards through a block for a byte (specified as an int). */ #if @GNULIB_MEMRCHR@ # if ! @HAVE_DECL_MEMRCHR@ -_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) +_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif @@ -420,12 +420,12 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - " # define memset_explicit rpl_memset_explicit # endif _GL_FUNCDECL_RPL (memset_explicit, void *, - (void *__dest, int __c, size_t __n) _GL_ARG_NONNULL ((1))); + (void *__dest, int __c, size_t __n), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (memset_explicit, void *, (void *__dest, int __c, size_t __n)); # else # if !@HAVE_MEMSET_EXPLICIT@ _GL_FUNCDECL_SYS (memset_explicit, void *, - (void *__dest, int __c, size_t __n) _GL_ARG_NONNULL ((1))); + (void *__dest, int __c, size_t __n), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n)); # endif @@ -443,7 +443,7 @@ _GL_WARN_ON_USE (memset_explicit, "memset_explicit is unportable - " occur within N bytes. */ #if @GNULIB_RAWMEMCHR@ # if ! @HAVE_RAWMEMCHR@ -_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) +_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif @@ -481,14 +481,14 @@ _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " # define stpcpy rpl_stpcpy # endif _GL_FUNCDECL_RPL (stpcpy, char *, - (char *restrict __dst, char const *restrict __src) + (char *restrict __dst, char const *restrict __src), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (stpcpy, char *, (char *restrict __dst, char const *restrict __src)); # else # if !@HAVE_STPCPY@ _GL_FUNCDECL_SYS (stpcpy, char *, - (char *restrict __dst, char const *restrict __src) + (char *restrict __dst, char const *restrict __src), _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (stpcpy, char *, @@ -515,7 +515,7 @@ _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " # endif _GL_FUNCDECL_RPL (stpncpy, char *, (char *restrict __dst, char const *restrict __src, - size_t __n) + size_t __n), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (stpncpy, char *, (char *restrict __dst, char const *restrict __src, @@ -524,7 +524,7 @@ _GL_CXXALIAS_RPL (stpncpy, char *, # if ! @HAVE_STPNCPY@ _GL_FUNCDECL_SYS (stpncpy, char *, (char *restrict __dst, char const *restrict __src, - size_t __n) + size_t __n), _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (stpncpy, char *, @@ -560,14 +560,14 @@ _GL_WARN_ON_USE_CXX (strchr, # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define strchrnul rpl_strchrnul # endif -_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in) +_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strchrnul, char *, (const char *str, int ch)); # else # if ! @HAVE_STRCHRNUL@ -_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) +_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif @@ -606,7 +606,7 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " # define strdup rpl_strdup # endif _GL_FUNCDECL_RPL (strdup, char *, - (char const *__s) + (char const *__s), _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); _GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); @@ -621,16 +621,17 @@ _GL_CXXALIAS_MDA (strdup, char *, (char const *__s)); /* strdup exists as a function and as a macro. Get rid of the macro. */ # undef strdup # endif -# if (!@HAVE_DECL_STRDUP@ || __GNUC__ >= 11) && !defined strdup +# if (!@HAVE_DECL_STRDUP@ || (__GNUC__ >= 11 && !defined __clang__)) \ + && !defined strdup # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (strdup, char *, - (char const *__s) - _GL_ATTRIBUTE_NOTHROW + (char const *__s), _GL_ARG_NONNULL ((1)) - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (strdup, char *, - (char const *__s) + (char const *__s), _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); # endif @@ -639,17 +640,17 @@ _GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); # endif _GL_CXXALIASWARN (strdup); #else -# if __GNUC__ >= 11 && !defined strdup +# if (__GNUC__ >= 11 && !defined __clang__) && !defined strdup /* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (strdup, char *, - (char const *__s) - _GL_ATTRIBUTE_NOTHROW + (char const *__s), _GL_ARG_NONNULL ((1)) - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (strdup, char *, - (char const *__s) + (char const *__s), _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); # endif @@ -688,7 +689,7 @@ _GL_CXXALIASWARN (strdup); # define strncat rpl_strncat # endif _GL_FUNCDECL_RPL (strncat, char *, - (char *restrict dest, const char *restrict src, size_t n) + (char *restrict dest, const char *restrict src, size_t n), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (strncat, char *, (char *restrict dest, const char *restrict src, size_t n)); @@ -715,21 +716,22 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - " # define strndup rpl_strndup # endif _GL_FUNCDECL_RPL (strndup, char *, - (char const *__s, size_t __n) + (char const *__s, size_t __n), _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); _GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n)); # else -# if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup) +# if !@HAVE_DECL_STRNDUP@ \ + || ((__GNUC__ >= 11 && !defined __clang__) && !defined strndup) # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (strndup, char *, - (char const *__s, size_t __n) - _GL_ATTRIBUTE_NOTHROW + (char const *__s, size_t __n), _GL_ARG_NONNULL ((1)) - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (strndup, char *, - (char const *__s, size_t __n) + (char const *__s, size_t __n), _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); # endif @@ -738,17 +740,17 @@ _GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n)); # endif _GL_CXXALIASWARN (strndup); #else -# if __GNUC__ >= 11 && !defined strndup +# if (__GNUC__ >= 11 && !defined __clang__) && !defined strndup /* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (strndup, char *, - (char const *__s, size_t __n) - _GL_ATTRIBUTE_NOTHROW + (char const *__s, size_t __n), _GL_ARG_NONNULL ((1)) - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE) + _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (strndup, char *, - (char const *__s, size_t __n) + (char const *__s, size_t __n), _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); # endif @@ -771,13 +773,13 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - " # undef strnlen # define strnlen rpl_strnlen # endif -_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen) +_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)); # else # if ! @HAVE_DECL_STRNLEN@ -_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen) +_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif @@ -807,7 +809,7 @@ _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " /* Find the first occurrence in S of any character in ACCEPT. */ #if @GNULIB_STRPBRK@ # if ! @HAVE_STRPBRK@ -_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) +_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); # endif @@ -892,7 +894,7 @@ _GL_WARN_ON_USE_CXX (strrchr, #if @GNULIB_STRSEP@ # if ! @HAVE_STRSEP@ _GL_FUNCDECL_SYS (strsep, char *, - (char **restrict __stringp, char const *restrict __delim) + (char **restrict __stringp, char const *restrict __delim), _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (strsep, char *, @@ -917,7 +919,7 @@ _GL_WARN_ON_USE (strsep, "strsep is unportable - " # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define strstr rpl_strstr # endif -_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) +_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); @@ -963,7 +965,7 @@ _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " # define strcasestr rpl_strcasestr # endif _GL_FUNCDECL_RPL (strcasestr, char *, - (const char *haystack, const char *needle) + (const char *haystack, const char *needle), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (strcasestr, char *, @@ -971,7 +973,7 @@ _GL_CXXALIAS_RPL (strcasestr, char *, # else # if ! @HAVE_STRCASESTR@ _GL_FUNCDECL_SYS (strcasestr, char *, - (const char *haystack, const char *needle) + (const char *haystack, const char *needle), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); # endif @@ -1038,7 +1040,7 @@ _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character " # endif _GL_FUNCDECL_RPL (strtok_r, char *, (char *restrict s, char const *restrict delim, - char **restrict save_ptr) + char **restrict save_ptr), _GL_ARG_NONNULL ((2, 3))); _GL_CXXALIAS_RPL (strtok_r, char *, (char *restrict s, char const *restrict delim, @@ -1050,7 +1052,7 @@ _GL_CXXALIAS_RPL (strtok_r, char *, # if ! @HAVE_DECL_STRTOK_R@ _GL_FUNCDECL_SYS (strtok_r, char *, (char *restrict s, char const *restrict delim, - char **restrict save_ptr) + char **restrict save_ptr), _GL_ARG_NONNULL ((2, 3))); # endif _GL_CXXALIAS_SYS (strtok_r, char *, @@ -1085,12 +1087,12 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define mbslen rpl_mbslen # endif -_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) +_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); # else -_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) +_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); @@ -1117,12 +1119,12 @@ _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len) # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define mbschr rpl_mbschr /* avoid collision with HP-UX function */ # endif -_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) +_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); # else -_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) +_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); @@ -1139,12 +1141,12 @@ _GL_CXXALIASWARN (mbschr); # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define mbsrchr rpl_mbsrchr /* avoid collision with system function */ # endif -_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) +_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); # else -_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) +_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); @@ -1234,12 +1236,12 @@ _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept) # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ # endif -_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) +_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); # else -_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) +_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); @@ -1329,12 +1331,12 @@ _GL_WARN_ON_USE (strerror, "strerror is unportable - " # undef strerror_r # define strerror_r rpl_strerror_r # endif -_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen) +_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen), _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)); # else # if !@HAVE_DECL_STRERROR_R@ -_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen) +_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen), _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)); @@ -1433,13 +1435,13 @@ _GL_WARN_ON_USE (strsignal, "strsignal is unportable - " # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define strverscmp rpl_strverscmp # endif -_GL_FUNCDECL_RPL (strverscmp, int, (const char *, const char *) +_GL_FUNCDECL_RPL (strverscmp, int, (const char *, const char *), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (strverscmp, int, (const char *, const char *)); # else # if !@HAVE_STRVERSCMP@ -_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) +_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *), _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); # endif diff --git a/lib/sys_random.in.h b/lib/sys_random.in.h index 22f67b17635..279ce621309 100644 --- a/lib/sys_random.in.h +++ b/lib/sys_random.in.h @@ -45,7 +45,8 @@ #ifndef _@GUARD_PREFIX@_SYS_RANDOM_H #define _@GUARD_PREFIX@_SYS_RANDOM_H -/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +/* This file uses _GL_ATTRIBUTE_NODISCARD, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ #if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif @@ -76,15 +77,15 @@ # define getrandom rpl_getrandom # endif _GL_FUNCDECL_RPL (getrandom, ssize_t, - (void *buffer, size_t length, unsigned int flags) - _GL_ARG_NONNULL ((1))); + (void *buffer, size_t length, unsigned int flags), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (getrandom, ssize_t, (void *buffer, size_t length, unsigned int flags)); # else # if !@HAVE_GETRANDOM@ _GL_FUNCDECL_SYS (getrandom, ssize_t, - (void *buffer, size_t length, unsigned int flags) - _GL_ARG_NONNULL ((1))); + (void *buffer, size_t length, unsigned int flags), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (getrandom, ssize_t, (void *buffer, size_t length, unsigned int flags)); diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h index ddf25d1de4c..0d5ddd16783 100644 --- a/lib/sys_select.in.h +++ b/lib/sys_select.in.h @@ -332,8 +332,10 @@ _GL_CXXALIAS_SYS (select, int, _GL_CXXALIASWARN (select); # endif #elif @HAVE_WINSOCK2_H@ -# undef select -# define select select_used_without_requesting_gnulib_module_select +# if !GNULIB_SELECT +# undef select +# define select select_used_without_requesting_gnulib_module_select +# endif #elif defined GNULIB_POSIXCHECK # undef select # if HAVE_RAW_DECL_SELECT diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h index bf08f33536d..d2ecdb9da96 100644 --- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h @@ -55,7 +55,8 @@ #ifndef _@GUARD_PREFIX@_SYS_STAT_H #define _@GUARD_PREFIX@_SYS_STAT_H -/* This file uses _GL_ATTRIBUTE_NOTHROW, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +/* This file uses _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW, + GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ #if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif @@ -65,7 +66,7 @@ */ #ifndef _GL_ATTRIBUTE_NOTHROW # if defined __cplusplus -# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4 # if __cplusplus >= 201103L # define _GL_ATTRIBUTE_NOTHROW noexcept (true) # else @@ -122,9 +123,11 @@ # if @GNULIB_STAT@ # define stat rpl_stat # else - /* Provoke a clear link error if stat() is used as a function and - module 'stat' is not in use. */ -# define stat stat_used_without_requesting_gnulib_module_stat +# if !GNULIB_STAT + /* Provoke a clear link error if stat() is used as a function and + module 'stat' is not in use. */ +# define stat stat_used_without_requesting_gnulib_module_stat +# endif # endif # if !GNULIB_defined_struct_stat @@ -433,7 +436,7 @@ struct stat # undef chmod # define chmod rpl_chmod # endif -_GL_FUNCDECL_RPL (chmod, int, (const char *filename, mode_t mode) +_GL_FUNCDECL_RPL (chmod, int, (const char *filename, mode_t mode), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (chmod, int, (const char *filename, mode_t mode)); # elif defined _WIN32 && !defined __CYGWIN__ @@ -478,15 +481,15 @@ _GL_CXXALIASWARN (chmod); # define fchmodat rpl_fchmodat # endif _GL_FUNCDECL_RPL (fchmodat, int, - (int fd, char const *file, mode_t mode, int flag) - _GL_ARG_NONNULL ((2))); + (int fd, char const *file, mode_t mode, int flag), + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (fchmodat, int, (int fd, char const *file, mode_t mode, int flag)); # else # if !@HAVE_FCHMODAT@ _GL_FUNCDECL_SYS (fchmodat, int, - (int fd, char const *file, mode_t mode, int flag) - _GL_ARG_NONNULL ((2))); + (int fd, char const *file, mode_t mode, int flag), + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (fchmodat, int, (int fd, char const *file, mode_t mode, int flag)); @@ -507,7 +510,8 @@ _GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - " # undef fstat # define fstat rpl_fstat # endif -_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2))); +_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf), + _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf)); # else _GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf)); @@ -516,8 +520,10 @@ _GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf)); _GL_CXXALIASWARN (fstat); # endif #elif @GNULIB_OVERRIDES_STRUCT_STAT@ -# undef fstat -# define fstat fstat_used_without_requesting_gnulib_module_fstat +# if !GNULIB_FSTAT +# undef fstat +# define fstat fstat_used_without_requesting_gnulib_module_fstat +# endif #elif @WINDOWS_64_BIT_ST_SIZE@ /* Above, we define stat to _stati64. */ # define fstat _fstati64 @@ -538,7 +544,7 @@ _GL_WARN_ON_USE (fstat, "fstat has portability problems - " # endif _GL_FUNCDECL_RPL (fstatat, int, (int fd, char const *restrict name, struct stat *restrict st, - int flags) + int flags), _GL_ARG_NONNULL ((2, 3))); _GL_CXXALIAS_RPL (fstatat, int, (int fd, char const *restrict name, struct stat *restrict st, @@ -547,7 +553,7 @@ _GL_CXXALIAS_RPL (fstatat, int, # if !@HAVE_FSTATAT@ _GL_FUNCDECL_SYS (fstatat, int, (int fd, char const *restrict name, struct stat *restrict st, - int flags) + int flags), _GL_ARG_NONNULL ((2, 3))); # endif _GL_CXXALIAS_SYS (fstatat, int, @@ -556,8 +562,10 @@ _GL_CXXALIAS_SYS (fstatat, int, # endif _GL_CXXALIASWARN (fstatat); #elif @GNULIB_OVERRIDES_STRUCT_STAT@ -# undef fstatat -# define fstatat fstatat_used_without_requesting_gnulib_module_fstatat +# if !GNULIB_FSTATAT +# undef fstatat +# define fstatat fstatat_used_without_requesting_gnulib_module_fstatat +# endif #elif defined GNULIB_POSIXCHECK # undef fstatat # if HAVE_RAW_DECL_FSTATAT @@ -600,7 +608,7 @@ _GL_WARN_ON_USE (futimens, "futimens is not portable - " #if @GNULIB_GETUMASK@ # if !@HAVE_GETUMASK@ # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 -_GL_FUNCDECL_SYS (getumask, mode_t, (void) _GL_ATTRIBUTE_NOTHROW); +_GL_FUNCDECL_SYS (getumask, mode_t, (void)) _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (getumask, mode_t, (void)); # endif @@ -622,7 +630,7 @@ _GL_WARN_ON_USE (getumask, "getumask is not portable - " /* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME denotes a symbolic link. */ # if !@HAVE_LCHMOD@ || defined __hpux -_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode) +_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode)); @@ -642,7 +650,7 @@ _GL_WARN_ON_USE (lchmod, "lchmod is unportable - " # undef mkdir # define mkdir rpl_mkdir # endif -_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode) +_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); # elif defined _WIN32 && !defined __CYGWIN__ @@ -667,12 +675,6 @@ _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); _GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode)); # endif _GL_CXXALIASWARN (mkdir); -#elif defined GNULIB_POSIXCHECK -# undef mkdir -# if HAVE_RAW_DECL_MKDIR -_GL_WARN_ON_USE (mkdir, "mkdir does not always support two parameters - " - "use gnulib module mkdir for portability"); -# endif #elif @GNULIB_MDA_MKDIR@ /* On native Windows, map 'mkdir' to '_mkdir', so that -loldnames is not required. In C++ with GNULIB_NAMESPACE, avoid differences between @@ -695,12 +697,18 @@ _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); _GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode)); # endif _GL_CXXALIASWARN (mkdir); +#elif defined GNULIB_POSIXCHECK +# undef mkdir +# if HAVE_RAW_DECL_MKDIR +_GL_WARN_ON_USE (mkdir, "mkdir does not always support two parameters - " + "use gnulib module mkdir for portability"); +# endif #endif #if @GNULIB_MKDIRAT@ # if !@HAVE_MKDIRAT@ -_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode) +_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode), _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)); @@ -720,12 +728,12 @@ _GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - " # undef mkfifo # define mkfifo rpl_mkfifo # endif -_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode) +_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode)); # else # if !@HAVE_MKFIFO@ -_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode) +_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode)); @@ -746,12 +754,12 @@ _GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - " # undef mkfifoat # define mkfifoat rpl_mkfifoat # endif -_GL_FUNCDECL_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode) +_GL_FUNCDECL_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode), _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode)); # else # if !@HAVE_MKFIFOAT@ -_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode) +_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode), _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)); @@ -774,12 +782,12 @@ _GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - " # undef mknod # define mknod rpl_mknod # endif -_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev) +_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)); # else # if !@HAVE_MKNOD@ -_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev) +_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev), _GL_ARG_NONNULL ((1))); # endif /* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */ @@ -802,14 +810,14 @@ _GL_WARN_ON_USE (mknod, "mknod is not portable - " # define mknodat rpl_mknodat # endif _GL_FUNCDECL_RPL (mknodat, int, - (int fd, char const *file, mode_t mode, dev_t dev) + (int fd, char const *file, mode_t mode, dev_t dev), _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (mknodat, int, (int fd, char const *file, mode_t mode, dev_t dev)); # else # if !@HAVE_MKNODAT@ _GL_FUNCDECL_SYS (mknodat, int, - (int fd, char const *file, mode_t mode, dev_t dev) + (int fd, char const *file, mode_t mode, dev_t dev), _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (mknodat, int, @@ -916,7 +924,7 @@ _GL_CXXALIAS_RPL_1 (lstat, stat, int, # define lstat rpl_lstat # endif _GL_FUNCDECL_RPL (lstat, int, - (const char *restrict name, struct stat *restrict buf) + (const char *restrict name, struct stat *restrict buf), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (lstat, int, (const char *restrict name, struct stat *restrict buf)); @@ -928,8 +936,10 @@ _GL_CXXALIAS_SYS (lstat, int, _GL_CXXALIASWARN (lstat); # endif #elif @GNULIB_OVERRIDES_STRUCT_STAT@ -# undef lstat -# define lstat lstat_used_without_requesting_gnulib_module_lstat +# if !GNULIB_LSTAT +# undef lstat +# define lstat lstat_used_without_requesting_gnulib_module_lstat +# endif #elif defined GNULIB_POSIXCHECK # undef lstat # if HAVE_RAW_DECL_LSTAT @@ -968,14 +978,14 @@ _GL_CXXALIASWARN (umask); # define utimensat rpl_utimensat # endif _GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name, - struct timespec const times[2], int flag) + struct timespec const times[2], int flag), _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name, struct timespec const times[2], int flag)); # else # if !@HAVE_UTIMENSAT@ _GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name, - struct timespec const times[2], int flag) + struct timespec const times[2], int flag), _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name, diff --git a/lib/sys_time.in.h b/lib/sys_time.in.h index 4a301c48ba1..88e912e60e5 100644 --- a/lib/sys_time.in.h +++ b/lib/sys_time.in.h @@ -105,14 +105,14 @@ struct timeval # define gettimeofday rpl_gettimeofday # endif _GL_FUNCDECL_RPL (gettimeofday, int, - (struct timeval *restrict, void *restrict) + (struct timeval *restrict, void *restrict), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (gettimeofday, int, (struct timeval *restrict, void *restrict)); # else # if !@HAVE_GETTIMEOFDAY@ _GL_FUNCDECL_SYS (gettimeofday, int, - (struct timeval *restrict, void *restrict) + (struct timeval *restrict, void *restrict), _GL_ARG_NONNULL ((1))); # endif /* Need to cast, because on glibc systems, by default, the second argument is diff --git a/lib/time.in.h b/lib/time.in.h index b91018937ad..097c509d3cc 100644 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -147,12 +147,12 @@ extern # undef timespec_get # define timespec_get rpl_timespec_get # endif -_GL_FUNCDECL_RPL (timespec_get, int, (struct timespec *ts, int base) +_GL_FUNCDECL_RPL (timespec_get, int, (struct timespec *ts, int base), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (timespec_get, int, (struct timespec *ts, int base)); # else # if !@HAVE_TIMESPEC_GET@ -_GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base) +_GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base)); @@ -176,12 +176,12 @@ _GL_WARN_ON_USE (timespec_get, "timespec_get is unportable - " # undef timespec_getres # define timespec_getres rpl_timespec_getres # endif -_GL_FUNCDECL_RPL (timespec_getres, int, (struct timespec *ts, int base) +_GL_FUNCDECL_RPL (timespec_getres, int, (struct timespec *ts, int base), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (timespec_getres, int, (struct timespec *ts, int base)); # else # if !@HAVE_TIMESPEC_GETRES@ -_GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base) +_GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base)); @@ -226,14 +226,14 @@ _GL_WARN_ON_USE (time, "time has consistency problems - " # define nanosleep rpl_nanosleep # endif _GL_FUNCDECL_RPL (nanosleep, int, - (struct timespec const *__rqtp, struct timespec *__rmtp) + (struct timespec const *__rqtp, struct timespec *__rmtp), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (nanosleep, int, (struct timespec const *__rqtp, struct timespec *__rmtp)); # else # if ! @HAVE_NANOSLEEP@ _GL_FUNCDECL_SYS (nanosleep, int, - (struct timespec const *__rqtp, struct timespec *__rmtp) + (struct timespec const *__rqtp, struct timespec *__rmtp), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (nanosleep, int, @@ -295,7 +295,7 @@ _GL_WARN_ON_USE (tzset, "tzset has portability problems - " # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define mktime rpl_mktime # endif -_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp)); # else _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); @@ -321,14 +321,14 @@ _GL_WARN_ON_USE (mktime, "mktime has portability problems - " # define localtime_r rpl_localtime_r # endif _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, - struct tm *restrict __result) + struct tm *restrict __result), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result)); # else # if ! @HAVE_DECL_LOCALTIME_R@ _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, - struct tm *restrict __result) + struct tm *restrict __result), _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, @@ -343,14 +343,14 @@ _GL_CXXALIASWARN (localtime_r); # define gmtime_r rpl_gmtime_r # endif _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, - struct tm *restrict __result) + struct tm *restrict __result), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result)); # else # if ! @HAVE_DECL_LOCALTIME_R@ _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, - struct tm *restrict __result) + struct tm *restrict __result), _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, @@ -381,7 +381,7 @@ _GL_WARN_ON_USE (gmtime_r, "gmtime_r is unportable - " # undef localtime # define localtime rpl_localtime # endif -_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer) +_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer)); # else @@ -404,7 +404,7 @@ _GL_WARN_ON_USE (localtime, "localtime has portability problems - " # undef gmtime # define gmtime rpl_gmtime # endif -_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer) +_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer)); # else @@ -420,7 +420,7 @@ _GL_CXXALIASWARN (gmtime); # if ! @HAVE_STRPTIME@ _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, char const *restrict __format, - struct tm *restrict __tm) + struct tm *restrict __tm), _GL_ARG_NONNULL ((1, 2, 3))); # endif _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf, @@ -445,7 +445,7 @@ _GL_WARN_ON_USE (strptime, "strptime is unportable - " # ifndef __cplusplus _GL_ATTRIBUTE_DEPRECATED # endif -_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp) +_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp)); # else @@ -467,7 +467,7 @@ _GL_CXXALIASWARN (ctime); # endif _GL_FUNCDECL_RPL (strftime, size_t, (char *restrict __buf, size_t __bufsize, - const char *restrict __fmt, const struct tm *restrict __tp) + const char *restrict __fmt, const struct tm *restrict __tp), _GL_ARG_NONNULL ((1, 3, 4))); _GL_CXXALIAS_RPL (strftime, size_t, (char *restrict __buf, size_t __bufsize, @@ -488,14 +488,24 @@ _GL_WARN_ON_USE (strftime, "strftime has portability problems - " # endif # endif -# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@ +# if @GNULIB_TIME_RZ@ /* Functions that use a first-class time zone data type, instead of relying on an implicit global time zone. Inspired by NetBSD. */ /* Represents a time zone. (timezone_t) NULL stands for UTC. */ +# if !@HAVE_TZALLOC@ +# if !GNULIB_defined_timezone_t +# if !@HAVE_TIMEZONE_T@ typedef struct tm_zone *timezone_t; +# else +typedef struct tm_zone *rpl_timezone_t; +# define timezone_t rpl_timezone_t +# endif +# define GNULIB_defined_timezone_t 1 +# endif +# endif /* tzalloc (name) Returns a time zone object for the given time zone NAME. This object @@ -505,37 +515,72 @@ typedef struct tm_zone *timezone_t; would use it the TZ environment variable was unset. May return NULL if NAME is invalid (this is platform dependent) or upon memory allocation failure. */ +# if !@HAVE_TZALLOC@ _GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name)); _GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name)); +# endif /* tzfree (tz) Frees a time zone object. The argument must have been returned by tzalloc(). */ +# if !@HAVE_TZALLOC@ _GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz)); _GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz)); +# endif /* localtime_rz (tz, &t, &result) Converts an absolute time T to a broken-down time RESULT, assuming the time zone TZ. This function is like 'localtime_r', but relies on the argument TZ instead of an implicit global time zone. */ +# if @REPLACE_LOCALTIME_RZ@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef localtime_rz +# define localtime_rz rpl_localtime_rz +# endif +_GL_FUNCDECL_RPL (localtime_rz, struct tm *, + (timezone_t __tz, time_t const *restrict __timer, + struct tm *restrict __result), + _GL_ARG_NONNULL ((2, 3))); +_GL_CXXALIAS_RPL (localtime_rz, struct tm *, + (timezone_t __tz, time_t const *restrict __timer, + struct tm *restrict __result)); +# else +# if !@HAVE_TZALLOC@ _GL_FUNCDECL_SYS (localtime_rz, struct tm *, (timezone_t __tz, time_t const *restrict __timer, - struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3))); + struct tm *restrict __result), + _GL_ARG_NONNULL ((2, 3))); +# endif _GL_CXXALIAS_SYS (localtime_rz, struct tm *, (timezone_t __tz, time_t const *restrict __timer, struct tm *restrict __result)); +# endif /* mktime_z (tz, &tm) Normalizes the broken-down time TM and converts it to an absolute time, assuming the time zone TZ. Returns the absolute time. This function is like 'mktime', but relies on the argument TZ instead of an implicit global time zone. */ -_GL_FUNCDECL_SYS (mktime_z, time_t, - (timezone_t __tz, struct tm *restrict __tm) +# if @REPLACE_MKTIME_Z@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mktime_z +# define mktime_z rpl_mktime_z +# endif +_GL_FUNCDECL_RPL (mktime_z, time_t, + (timezone_t __tz, struct tm *restrict __tm), _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (mktime_z, time_t, + (timezone_t __tz, struct tm *restrict __tm)); +# else +# if !@HAVE_TZALLOC@ +_GL_FUNCDECL_SYS (mktime_z, time_t, + (timezone_t __tz, struct tm *restrict __tm), + _GL_ARG_NONNULL ((2))); +# endif _GL_CXXALIAS_SYS (mktime_z, time_t, (timezone_t __tz, struct tm *restrict __tm)); +# endif /* Time zone abbreviation strings (returned by 'localtime_rz' or 'mktime_z' in the 'tm_zone' member of 'struct tm') are valid as long as @@ -552,11 +597,11 @@ _GL_CXXALIAS_SYS (mktime_z, time_t, # undef timegm # define timegm rpl_timegm # endif -_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm)); # else # if ! @HAVE_TIMEGM@ -_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); # endif diff --git a/lib/time_rz.c b/lib/time_rz.c index a6523e1285b..14f43fd67a9 100644 --- a/lib/time_rz.c +++ b/lib/time_rz.c @@ -24,16 +24,41 @@ #include +/* Specification. */ #include -#include -#include -#include -#include +#if NEED_TIMEZONE_NULL_SUPPORT /* Android API level >= 35 */ -#include "flexmember.h" -#include "idx.h" -#include "time-internal.h" +struct tm * +localtime_rz (timezone_t tz, time_t const *t, struct tm *tm) +# undef localtime_rz +{ + if (!tz) + return gmtime_r (t, tm); + else + return localtime_rz (tz, t, tm); +} + +time_t +mktime_z (timezone_t tz, struct tm *tm) +# undef mktime_z +{ + if (!tz) + return timegm (tm); + else + return mktime_z (tz, tm); +} + +#else + +# include +# include +# include +# include + +# include "flexmember.h" +# include "idx.h" +# include "time-internal.h" /* The approximate size to use for small allocation requests. This is the largest "small" request for the GNU C library malloc. */ @@ -79,7 +104,7 @@ tzalloc (char const *name) static bool save_abbr (timezone_t tz, struct tm *tm) { -#if HAVE_STRUCT_TM_TM_ZONE +# if HAVE_STRUCT_TM_TM_ZONE char const *zone = tm->tm_zone; char *zone_copy = (char *) ""; @@ -120,7 +145,7 @@ save_abbr (timezone_t tz, struct tm *tm) /* Replace the zone name so that its lifetime matches that of TZ. */ tm->tm_zone = zone_copy; -#endif +# endif return true; } @@ -141,21 +166,21 @@ tzfree (timezone_t tz) /* Get and set the TZ environment variable. These functions can be overridden by programs like Emacs that manage their own environment. */ -#ifndef getenv_TZ +# ifndef getenv_TZ static char * getenv_TZ (void) { return getenv ("TZ"); } -#endif +# endif -#ifndef setenv_TZ +# ifndef setenv_TZ static int setenv_TZ (char const *tz) { return tz ? setenv ("TZ", tz, 1) : unsetenv ("TZ"); } -#endif +# endif /* Change the environment to match the specified timezone_t value. Return true if successful, false (setting errno) otherwise. */ @@ -220,7 +245,7 @@ revert_tz (timezone_t tz) struct tm * localtime_rz (timezone_t tz, time_t const *t, struct tm *tm) { -#ifdef HAVE_LOCALTIME_INFLOOP_BUG +# ifdef HAVE_LOCALTIME_INFLOOP_BUG /* The -67768038400665599 comes from: https://lists.gnu.org/r/bug-gnulib/2017-07/msg00142.html On affected platforms the greatest POSIX-compatible time_t value @@ -233,7 +258,7 @@ localtime_rz (timezone_t tz, time_t const *t, struct tm *tm) errno = EOVERFLOW; return NULL; } -#endif +# endif if (!tz) return gmtime_r (t, tm); @@ -282,3 +307,5 @@ mktime_z (timezone_t tz, struct tm *tm) return -1; } } + +#endif diff --git a/lib/unistd.in.h b/lib/unistd.in.h index e01629af259..3222f5a568f 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -69,8 +69,8 @@ #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H #define _@GUARD_PREFIX@_UNISTD_H -/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, GNULIB_POSIXCHECK, - HAVE_RAW_DECL_*. */ +/* This file uses _GL_ATTRIBUTE_NODISCARD, _GL_INLINE_HEADER_BEGIN, _GL_INLINE, + GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ #if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif @@ -287,7 +287,7 @@ _GL_INLINE_HEADER_BEGIN # undef access # define access rpl_access # endif -_GL_FUNCDECL_RPL (access, int, (const char *file, int mode) +_GL_FUNCDECL_RPL (access, int, (const char *file, int mode), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (access, int, (const char *file, int mode)); # elif defined _WIN32 && !defined __CYGWIN__ @@ -340,7 +340,7 @@ _GL_CXXALIASWARN (chdir); #elif defined GNULIB_POSIXCHECK # undef chdir # if HAVE_RAW_DECL_CHDIR -_GL_WARN_ON_USE (chown, "chdir is not always in - " +_GL_WARN_ON_USE (chdir, "chdir is not always in - " "use gnulib module chdir for portability"); # endif #elif @GNULIB_MDA_CHDIR@ @@ -371,13 +371,13 @@ _GL_CXXALIASWARN (chdir); # undef chown # define chown rpl_chown # endif -_GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid) - _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)); # else # if !@HAVE_CHOWN@ -_GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid) - _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)); # endif @@ -412,8 +412,10 @@ _GL_CXXALIAS_SYS (close, int, (int fd)); # endif _GL_CXXALIASWARN (close); #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ -# undef close -# define close close_used_without_requesting_gnulib_module_close +# if !GNULIB_CLOSE +# undef close +# define close close_used_without_requesting_gnulib_module_close +# endif #elif defined GNULIB_POSIXCHECK # undef close /* Assume close is always declared. */ @@ -474,7 +476,7 @@ _GL_WARN_ON_USE (copy_file_range, # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define dup rpl_dup # endif -_GL_FUNCDECL_RPL (dup, int, (int oldfd)); +_GL_FUNCDECL_RPL (dup, int, (int oldfd), _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (dup, int, (int oldfd)); # elif defined _WIN32 && !defined __CYGWIN__ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -637,7 +639,7 @@ rpl_environ (void) /* Like access(), except that it uses the effective user id and group id of the current process. */ # if !@HAVE_EUIDACCESS@ -_GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode) +_GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode)); @@ -662,7 +664,7 @@ _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - " # undef execl # define execl rpl_execl # endif -_GL_FUNCDECL_RPL (execl, int, (const char *program, const char *arg, ...) +_GL_FUNCDECL_RPL (execl, int, (const char *program, const char *arg, ...), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (execl, int, (const char *program, const char *arg, ...)); # else @@ -697,7 +699,7 @@ _GL_CXXALIASWARN (execl); # undef execle # define execle rpl_execle # endif -_GL_FUNCDECL_RPL (execle, int, (const char *program, const char *arg, ...) +_GL_FUNCDECL_RPL (execle, int, (const char *program, const char *arg, ...), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (execle, int, (const char *program, const char *arg, ...)); # else @@ -733,7 +735,7 @@ _GL_CXXALIASWARN (execle); # undef execlp # define execlp rpl_execlp # endif -_GL_FUNCDECL_RPL (execlp, int, (const char *program, const char *arg, ...) +_GL_FUNCDECL_RPL (execlp, int, (const char *program, const char *arg, ...), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (execlp, int, (const char *program, const char *arg, ...)); # else @@ -770,7 +772,7 @@ _GL_CXXALIASWARN (execlp); # undef execv # define execv rpl_execv # endif -_GL_FUNCDECL_RPL (execv, int, (const char *program, char * const *argv) +_GL_FUNCDECL_RPL (execv, int, (const char *program, char * const *argv), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (execv, int, (const char *program, char * const *argv)); # else @@ -807,7 +809,7 @@ _GL_CXXALIASWARN (execv); # define execve rpl_execve # endif _GL_FUNCDECL_RPL (execve, int, - (const char *program, char * const *argv, char * const *env) + (const char *program, char * const *argv, char * const *env), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (execve, int, (const char *program, char * const *argv, char * const *env)); @@ -847,7 +849,7 @@ _GL_CXXALIASWARN (execve); # undef execvp # define execvp rpl_execvp # endif -_GL_FUNCDECL_RPL (execvp, int, (const char *program, char * const *argv) +_GL_FUNCDECL_RPL (execvp, int, (const char *program, char * const *argv), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (execvp, int, (const char *program, char * const *argv)); # else @@ -884,14 +886,14 @@ _GL_CXXALIASWARN (execvp); # define execvpe rpl_execvpe # endif _GL_FUNCDECL_RPL (execvpe, int, - (const char *program, char * const *argv, char * const *env) + (const char *program, char * const *argv, char * const *env), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (execvpe, int, (const char *program, char * const *argv, char * const *env)); # else # if !@HAVE_DECL_EXECVPE@ _GL_FUNCDECL_SYS (execvpe, int, - (const char *program, char * const *argv, char * const *env) + (const char *program, char * const *argv, char * const *env), _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (execvpe, int, @@ -922,7 +924,7 @@ _GL_CXXALIAS_MDA_CAST (execvpe, intptr_t, # elif @HAVE_EXECVPE@ # if !@HAVE_DECL_EXECVPE@ _GL_FUNCDECL_SYS (execvpe, int, - (const char *program, char * const *argv, char * const *env) + (const char *program, char * const *argv, char * const *env), _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (execvpe, int, @@ -941,15 +943,15 @@ _GL_CXXALIASWARN (execvpe); # define faccessat rpl_faccessat # endif _GL_FUNCDECL_RPL (faccessat, int, - (int fd, char const *name, int mode, int flag) - _GL_ARG_NONNULL ((2))); + (int fd, char const *name, int mode, int flag), + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (faccessat, int, (int fd, char const *name, int mode, int flag)); # else # if !@HAVE_FACCESSAT@ _GL_FUNCDECL_SYS (faccessat, int, - (int fd, char const *file, int mode, int flag) - _GL_ARG_NONNULL ((2))); + (int fd, char const *file, int mode, int flag), + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (faccessat, int, (int fd, char const *file, int mode, int flag)); @@ -977,11 +979,11 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - " # undef fchdir # define fchdir rpl_fchdir # endif -_GL_FUNCDECL_RPL (fchdir, int, (int /*fd*/)); +_GL_FUNCDECL_RPL (fchdir, int, (int /*fd*/), _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (fchdir, int, (int /*fd*/)); # else # if !@HAVE_FCHDIR@ || !@HAVE_DECL_FCHDIR@ -_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); +_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/), _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/)); # endif @@ -1010,15 +1012,15 @@ _GL_WARN_ON_USE (fchdir, "fchdir is unportable - " # define fchownat rpl_fchownat # endif _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file, - uid_t owner, gid_t group, int flag) - _GL_ARG_NONNULL ((2))); + uid_t owner, gid_t group, int flag), + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file, uid_t owner, gid_t group, int flag)); # else # if !@HAVE_FCHOWNAT@ _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file, - uid_t owner, gid_t group, int flag) - _GL_ARG_NONNULL ((2))); + uid_t owner, gid_t group, int flag), + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file, uid_t owner, gid_t group, int flag)); @@ -1092,13 +1094,17 @@ _GL_WARN_ON_USE (fsync, "fsync is unportable - " # undef ftruncate # define ftruncate rpl_ftruncate # endif -_GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length)); -_GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length)); +_GL_FUNCDECL_RPL (ftruncate, int, + (int fd, off_t length), _GL_ATTRIBUTE_NODISCARD); +_GL_CXXALIAS_RPL (ftruncate, int, + (int fd, off_t length)); # else # if !@HAVE_FTRUNCATE@ -_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length)); +_GL_FUNCDECL_SYS (ftruncate, int, + (int fd, off_t length), _GL_ATTRIBUTE_NODISCARD); # endif -_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length)); +_GL_CXXALIAS_SYS (ftruncate, int, + (int fd, off_t length)); # endif # if __GLIBC__ >= 2 _GL_CXXALIASWARN (ftruncate); @@ -1127,7 +1133,8 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - " # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define getcwd rpl_getcwd # endif -_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size)); +_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size), + _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size)); # elif defined _WIN32 && !defined __CYGWIN__ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -1182,15 +1189,19 @@ _GL_CXXALIASWARN (getcwd); # undef getdomainname # define getdomainname rpl_getdomainname # endif -_GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len)); +_GL_FUNCDECL_RPL (getdomainname, int, + (char *name, size_t len), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); +_GL_CXXALIAS_RPL (getdomainname, int, + (char *name, size_t len)); # else # if !@HAVE_DECL_GETDOMAINNAME@ -_GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len) - _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (getdomainname, int, + (char *name, size_t len), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif -_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len)); +_GL_CXXALIAS_SYS (getdomainname, int, + (char *name, size_t len)); # endif # if __GLIBC__ >= 2 _GL_CXXALIASWARN (getdomainname); @@ -1239,13 +1250,17 @@ _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - " # undef getentropy # define getentropy rpl_getentropy # endif -_GL_FUNCDECL_RPL (getentropy, int, (void *buffer, size_t length)); -_GL_CXXALIAS_RPL (getentropy, int, (void *buffer, size_t length)); +_GL_FUNCDECL_RPL (getentropy, int, + (void *buffer, size_t length), _GL_ATTRIBUTE_NODISCARD); +_GL_CXXALIAS_RPL (getentropy, int, + (void *buffer, size_t length)); # else # if !@HAVE_GETENTROPY@ -_GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length)); +_GL_FUNCDECL_SYS (getentropy, int, + (void *buffer, size_t length), _GL_ATTRIBUTE_NODISCARD); # endif -_GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length)); +_GL_CXXALIAS_SYS (getentropy, int, + (void *buffer, size_t length)); # endif # if __GLIBC__ >= 2 _GL_CXXALIASWARN (getentropy); @@ -1270,13 +1285,17 @@ _GL_WARN_ON_USE (getentropy, "getentropy is unportable - " # undef getgroups # define getgroups rpl_getgroups # endif -_GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups)); -_GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups)); +_GL_FUNCDECL_RPL (getgroups, int, + (int n, gid_t *groups), _GL_ATTRIBUTE_NODISCARD); +_GL_CXXALIAS_RPL (getgroups, int, + (int n, gid_t *groups)); # else # if !@HAVE_GETGROUPS@ -_GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups)); +_GL_FUNCDECL_SYS (getgroups, int, + (int n, gid_t *groups), _GL_ATTRIBUTE_NODISCARD); # endif -_GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups)); +_GL_CXXALIAS_SYS (getgroups, int, + (int n, gid_t *groups)); # endif _GL_CXXALIASWARN (getgroups); #elif defined GNULIB_POSIXCHECK @@ -1301,12 +1320,12 @@ _GL_WARN_ON_USE (getgroups, "getgroups is unportable - " # undef gethostname # define gethostname rpl_gethostname # endif -_GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len) +_GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len)); # else # if !@HAVE_GETHOSTNAME@ -_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len) +_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len), _GL_ARG_NONNULL ((1))); # endif /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second @@ -1316,8 +1335,10 @@ _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len)); # endif _GL_CXXALIASWARN (gethostname); #elif @UNISTD_H_HAVE_WINSOCK2_H@ -# undef gethostname -# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname +# if !GNULIB_GETHOSTNAME +# undef gethostname +# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname +# endif #elif defined GNULIB_POSIXCHECK # undef gethostname # if HAVE_RAW_DECL_GETHOSTNAME @@ -1371,12 +1392,12 @@ _GL_WARN_ON_USE (getlogin, "getlogin is unportable - " # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define getlogin_r rpl_getlogin_r # endif -_GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size) +_GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size)); # else # if !@HAVE_DECL_GETLOGIN_R@ -_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size) +_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size), _GL_ARG_NONNULL ((1))); # endif /* Need to cast, because on Solaris 10 systems, the second argument is @@ -1493,12 +1514,12 @@ _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - " # undef getpass # define getpass rpl_getpass # endif -_GL_FUNCDECL_RPL (getpass, char *, (const char *prompt) +_GL_FUNCDECL_RPL (getpass, char *, (const char *prompt), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (getpass, char *, (const char *prompt)); # else # if !@HAVE_GETPASS@ -_GL_FUNCDECL_SYS (getpass, char *, (const char *prompt) +_GL_FUNCDECL_SYS (getpass, char *, (const char *prompt), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (getpass, char *, (const char *prompt)); @@ -1674,13 +1695,13 @@ _GL_CXXALIASWARN (isatty); # undef lchown # define lchown rpl_lchown # endif -_GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group) - _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)); # else # if !@HAVE_LCHOWN@ -_GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group) - _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)); # endif @@ -1703,13 +1724,13 @@ _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - " # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define link rpl_link # endif -_GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2) - _GL_ARG_NONNULL ((1, 2))); +_GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2), + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2)); # else # if !@HAVE_LINK@ -_GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2) - _GL_ARG_NONNULL ((1, 2))); +_GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2), + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2)); # endif @@ -1734,8 +1755,8 @@ _GL_WARN_ON_USE (link, "link is unportable - " # endif _GL_FUNCDECL_RPL (linkat, int, (int fd1, const char *path1, int fd2, const char *path2, - int flag) - _GL_ARG_NONNULL ((2, 4))); + int flag), + _GL_ARG_NONNULL ((2, 4)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (linkat, int, (int fd1, const char *path1, int fd2, const char *path2, int flag)); @@ -1743,8 +1764,8 @@ _GL_CXXALIAS_RPL (linkat, int, # if !@HAVE_LINKAT@ _GL_FUNCDECL_SYS (linkat, int, (int fd1, const char *path1, int fd2, const char *path2, - int flag) - _GL_ARG_NONNULL ((2, 4))); + int flag), + _GL_ARG_NONNULL ((2, 4)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (linkat, int, (int fd1, const char *path1, int fd2, const char *path2, @@ -1811,7 +1832,8 @@ _GL_CXXALIASWARN (lseek); Store the read-end as fd[0] and the write-end as fd[1]. Return 0 upon success, or -1 with errno set upon failure. */ # if !@HAVE_PIPE@ -_GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (pipe, int, (int fd[2]), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (pipe, int, (int fd[2])); _GL_CXXALIASWARN (pipe); @@ -1838,10 +1860,12 @@ _GL_WARN_ON_USE (pipe, "pipe is unportable - " # undef pipe2 # define pipe2 rpl_pipe2 # endif -_GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags)); # else -_GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags)); # endif # if __GLIBC__ >= 2 @@ -1868,15 +1892,15 @@ _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - " # define pread rpl_pread # endif _GL_FUNCDECL_RPL (pread, ssize_t, - (int fd, void *buf, size_t bufsize, off_t offset) - _GL_ARG_NONNULL ((2))); + (int fd, void *buf, size_t bufsize, off_t offset), + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (pread, ssize_t, (int fd, void *buf, size_t bufsize, off_t offset)); # else # if !@HAVE_PREAD@ _GL_FUNCDECL_SYS (pread, ssize_t, - (int fd, void *buf, size_t bufsize, off_t offset) - _GL_ARG_NONNULL ((2))); + (int fd, void *buf, size_t bufsize, off_t offset), + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (pread, ssize_t, (int fd, void *buf, size_t bufsize, off_t offset)); @@ -1905,15 +1929,15 @@ _GL_WARN_ON_USE (pread, "pread is unportable - " # define pwrite rpl_pwrite # endif _GL_FUNCDECL_RPL (pwrite, ssize_t, - (int fd, const void *buf, size_t bufsize, off_t offset) - _GL_ARG_NONNULL ((2))); + (int fd, const void *buf, size_t bufsize, off_t offset), + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (pwrite, ssize_t, (int fd, const void *buf, size_t bufsize, off_t offset)); # else # if !@HAVE_PWRITE@ _GL_FUNCDECL_SYS (pwrite, ssize_t, - (int fd, const void *buf, size_t bufsize, off_t offset) - _GL_ARG_NONNULL ((2))); + (int fd, const void *buf, size_t bufsize, off_t offset), + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (pwrite, ssize_t, (int fd, const void *buf, size_t bufsize, off_t offset)); @@ -1939,8 +1963,9 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - " # undef read # define read rpl_read # endif -_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count) - _GL_ARG_NONNULL ((2))); + +_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count), + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count)); # elif defined _WIN32 && !defined __CYGWIN__ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -1981,8 +2006,8 @@ _GL_CXXALIASWARN (read); # endif _GL_FUNCDECL_RPL (readlink, ssize_t, (const char *restrict file, - char *restrict buf, size_t bufsize) - _GL_ARG_NONNULL ((1, 2))); + char *restrict buf, size_t bufsize), + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (readlink, ssize_t, (const char *restrict file, char *restrict buf, size_t bufsize)); @@ -1990,8 +2015,8 @@ _GL_CXXALIAS_RPL (readlink, ssize_t, # if !@HAVE_READLINK@ _GL_FUNCDECL_SYS (readlink, ssize_t, (const char *restrict file, - char *restrict buf, size_t bufsize) - _GL_ARG_NONNULL ((1, 2))); + char *restrict buf, size_t bufsize), + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (readlink, ssize_t, (const char *restrict file, @@ -2014,8 +2039,8 @@ _GL_WARN_ON_USE (readlink, "readlink is unportable - " # endif _GL_FUNCDECL_RPL (readlinkat, ssize_t, (int fd, char const *restrict file, - char *restrict buf, size_t len) - _GL_ARG_NONNULL ((2, 3))); + char *restrict buf, size_t len), + _GL_ARG_NONNULL ((2, 3)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (readlinkat, ssize_t, (int fd, char const *restrict file, char *restrict buf, size_t len)); @@ -2023,8 +2048,8 @@ _GL_CXXALIAS_RPL (readlinkat, ssize_t, # if !@HAVE_READLINKAT@ _GL_FUNCDECL_SYS (readlinkat, ssize_t, (int fd, char const *restrict file, - char *restrict buf, size_t len) - _GL_ARG_NONNULL ((2, 3))); + char *restrict buf, size_t len), + _GL_ARG_NONNULL ((2, 3)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (readlinkat, ssize_t, (int fd, char const *restrict file, @@ -2048,7 +2073,7 @@ _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - " # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define rmdir rpl_rmdir # endif -_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (rmdir, int, (char const *name), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (rmdir, int, (char const *name)); # elif defined _WIN32 && !defined __CYGWIN__ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -2097,18 +2122,22 @@ _GL_CXXALIASWARN (rmdir); # undef sethostname # define sethostname rpl_sethostname # endif -_GL_FUNCDECL_RPL (sethostname, int, (const char *name, size_t len) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (sethostname, int, (const char *name, size_t len)); +_GL_FUNCDECL_RPL (sethostname, int, + (const char *name, size_t len), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); +_GL_CXXALIAS_RPL (sethostname, int, + (const char *name, size_t len)); # else # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@ -_GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len) - _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (sethostname, int, + (const char *name, size_t len), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5 and FreeBSD 6.4 the second parameter is int. On Solaris 11 2011-10, the first parameter is not const. */ -_GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len)); +_GL_CXXALIAS_SYS_CAST (sethostname, int, + (const char *name, size_t len)); # endif # if __GLIBC__ >= 2 _GL_CXXALIASWARN (sethostname); @@ -2181,15 +2210,19 @@ _GL_CXXALIASWARN (swab); # undef symlink # define symlink rpl_symlink # endif -_GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file)); +_GL_FUNCDECL_RPL (symlink, int, + (char const *contents, char const *file), + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD); +_GL_CXXALIAS_RPL (symlink, int, + (char const *contents, char const *file)); # else # if !@HAVE_SYMLINK@ -_GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file) - _GL_ARG_NONNULL ((1, 2))); +_GL_FUNCDECL_SYS (symlink, int, + (char const *contents, char const *file), + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD); # endif -_GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file)); +_GL_CXXALIAS_SYS (symlink, int, + (char const *contents, char const *file)); # endif _GL_CXXALIASWARN (symlink); #elif defined GNULIB_POSIXCHECK @@ -2208,15 +2241,15 @@ _GL_WARN_ON_USE (symlink, "symlink is not portable - " # define symlinkat rpl_symlinkat # endif _GL_FUNCDECL_RPL (symlinkat, int, - (char const *contents, int fd, char const *file) - _GL_ARG_NONNULL ((1, 3))); + (char const *contents, int fd, char const *file), + _GL_ARG_NONNULL ((1, 3)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (symlinkat, int, (char const *contents, int fd, char const *file)); # else # if !@HAVE_SYMLINKAT@ _GL_FUNCDECL_SYS (symlinkat, int, - (char const *contents, int fd, char const *file) - _GL_ARG_NONNULL ((1, 3))); + (char const *contents, int fd, char const *file), + _GL_ARG_NONNULL ((1, 3)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (symlinkat, int, (char const *contents, int fd, char const *file)); @@ -2243,13 +2276,13 @@ _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - " # undef truncate # define truncate rpl_truncate # endif -_GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length) - _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length)); # else # if !@HAVE_DECL_TRUNCATE@ -_GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length) - _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length), + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length)); # endif @@ -2274,13 +2307,15 @@ _GL_WARN_ON_USE (truncate, "truncate is unportable - " # define ttyname_r rpl_ttyname_r # endif _GL_FUNCDECL_RPL (ttyname_r, int, - (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); + (int fd, char *buf, size_t buflen), + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD); _GL_CXXALIAS_RPL (ttyname_r, int, (int fd, char *buf, size_t buflen)); # else # if !@HAVE_DECL_TTYNAME_R@ _GL_FUNCDECL_SYS (ttyname_r, int, - (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); + (int fd, char *buf, size_t buflen), + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD); # endif _GL_CXXALIAS_SYS (ttyname_r, int, (int fd, char *buf, size_t buflen)); @@ -2303,7 +2338,7 @@ _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - " # undef unlink # define unlink rpl_unlink # endif -_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (unlink, int, (char const *file), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (unlink, int, (char const *file)); # elif defined _WIN32 && !defined __CYGWIN__ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -2344,12 +2379,12 @@ _GL_CXXALIASWARN (unlink); # undef unlinkat # define unlinkat rpl_unlinkat # endif -_GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag) +_GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag), _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag)); # else # if !@HAVE_UNLINKAT@ -_GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag) +_GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag), _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag)); @@ -2403,17 +2438,21 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - " # undef write # define write rpl_write # endif -_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); +_GL_FUNCDECL_RPL (write, ssize_t, + (int fd, const void *buf, size_t count), + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD); +_GL_CXXALIAS_RPL (write, ssize_t, + (int fd, const void *buf, size_t count)); # elif defined _WIN32 && !defined __CYGWIN__ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef write # define write _write # endif -_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, size_t count)); +_GL_CXXALIAS_MDA (write, ssize_t, + (int fd, const void *buf, size_t count)); # else -_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count)); +_GL_CXXALIAS_SYS (write, ssize_t, + (int fd, const void *buf, size_t count)); # endif _GL_CXXALIASWARN (write); #elif @GNULIB_MDA_WRITE@ @@ -2425,9 +2464,11 @@ _GL_CXXALIASWARN (write); # undef write # define write _write # endif -_GL_CXXALIAS_MDA_CAST (write, ssize_t, (int fd, const void *buf, unsigned int count)); +_GL_CXXALIAS_MDA_CAST (write, ssize_t, + (int fd, const void *buf, unsigned int count)); # else -_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count)); +_GL_CXXALIAS_SYS (write, ssize_t, + (int fd, const void *buf, size_t count)); # endif _GL_CXXALIASWARN (write); #endif diff --git a/lib/verify.h b/lib/verify.h index 978926a4918..49a73c05088 100644 --- a/lib/verify.h +++ b/lib/verify.h @@ -34,11 +34,12 @@ #ifndef __cplusplus # if (201112 <= __STDC_VERSION__ \ || (!defined __STRICT_ANSI__ \ - && (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || 5 <= __clang_major__))) + && ((4 < __GNUC__ + (6 <= __GNUC_MINOR__) && !defined __clang__) \ + || 5 <= __clang_major__))) # define _GL_HAVE__STATIC_ASSERT 1 # endif # if (202311 <= __STDC_VERSION__ \ - || (!defined __STRICT_ANSI__ && 9 <= __GNUC__)) + || (!defined __STRICT_ANSI__ && 9 <= __GNUC__ && !defined __clang__)) # define _GL_HAVE__STATIC_ASSERT1 1 # endif #endif @@ -215,7 +216,7 @@ template # define _GL_VERIFY(R, DIAGNOSTIC, ...) \ extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] -# if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) +# if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) && !defined __clang__ # pragma GCC diagnostic ignored "-Wnested-externs" # endif #endif @@ -305,7 +306,7 @@ template #ifndef _GL_HAS_BUILTIN_UNREACHABLE # if defined __clang_major__ && __clang_major__ < 5 # define _GL_HAS_BUILTIN_UNREACHABLE 0 -# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) +# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) && !defined __clang__ # define _GL_HAS_BUILTIN_UNREACHABLE 1 # elif defined __has_builtin # define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) diff --git a/lib/warn-on-use.h b/lib/warn-on-use.h index 701013a07f4..73c439714ab 100644 --- a/lib/warn-on-use.h +++ b/lib/warn-on-use.h @@ -85,7 +85,7 @@ */ #ifndef _GL_WARN_ON_USE -# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) +# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__ /* A compiler attribute is available in gcc versions 4.3.0 and later. */ # define _GL_WARN_ON_USE(function, message) \ _GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message))) @@ -98,7 +98,7 @@ _GL_WARN_EXTERN_C __typeof__ (function) function \ __attribute__ ((__diagnose_if__ (1, message, "warning"))) # define _GL_WARN_ON_USE_ATTRIBUTE(message) \ __attribute__ ((__diagnose_if__ (1, message, "warning"))) -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING /* Verify the existence of the function. */ # define _GL_WARN_ON_USE(function, message) \ _GL_WARN_EXTERN_C __typeof__ (function) function @@ -121,7 +121,7 @@ _GL_WARN_EXTERN_C int _gl_warn_on_use # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ _GL_WARN_ON_USE (function, msg) # else -# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) +# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__ /* A compiler attribute is available in gcc versions 4.3.0 and later. */ # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ extern rettype_gcc function parameters_and_attributes \ @@ -131,7 +131,7 @@ extern rettype_gcc function parameters_and_attributes \ # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ extern rettype_clang function parameters_and_attributes \ __attribute__ ((__diagnose_if__ (1, msg, "warning"))) -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING /* Verify the existence of the function. */ # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ extern rettype_gcc function parameters_and_attributes diff --git a/lib/xalloc-oversized.h b/lib/xalloc-oversized.h index 7f30f83e769..cfa527d38ce 100644 --- a/lib/xalloc-oversized.h +++ b/lib/xalloc-oversized.h @@ -47,7 +47,8 @@ #if 7 <= __GNUC__ && !defined __clang__ && PTRDIFF_MAX < SIZE_MAX # define xalloc_oversized(n, s) \ __builtin_mul_overflow_p (n, s, (ptrdiff_t) 1) -#elif 5 <= __GNUC__ && !defined __ICC && PTRDIFF_MAX < SIZE_MAX +#elif 5 <= __GNUC__ && !defined __clang__ && !defined __ICC \ + && PTRDIFF_MAX < SIZE_MAX # define xalloc_oversized(n, s) \ (__builtin_constant_p (n) && __builtin_constant_p (s) \ ? __xalloc_oversized (n, s) \ diff --git a/m4/builtin-expect.m4 b/m4/builtin-expect.m4 index c7af926b34c..33f255e9f56 100644 --- a/m4/builtin-expect.m4 +++ b/m4/builtin-expect.m4 @@ -1,11 +1,11 @@ # builtin-expect.m4 -# serial 1 +# serial 2 dnl Copyright 2016-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -dnl Check for __builtin_expect. +dnl Provide a GCC-compatible __builtin_expect macro in . dnl Written by Paul Eggert. diff --git a/m4/errno_h.m4 b/m4/errno_h.m4 index b6050e5d8e0..920ea6cc653 100644 --- a/m4/errno_h.m4 +++ b/m4/errno_h.m4 @@ -1,5 +1,5 @@ # errno_h.m4 -# serial 14 +# serial 18 dnl Copyright (C) 2004, 2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,6 +10,11 @@ AC_PREREQ([2.61]) AC_DEFUN_ONCE([gl_HEADER_ERRNO_H], [ AC_REQUIRE([AC_PROG_CC]) + + dnl Through the dependency on module extensions-aix, _LINUX_SOURCE_COMPAT + dnl gets defined already before this macro gets invoked. This persuades + dnl AIX 7.3 errno.h to assign ENOTEMPTY a value different than EEXIST. + AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [ AC_EGREP_CPP([booboo],[ #include @@ -63,6 +68,9 @@ booboo #endif #if !defined EILSEQ booboo +#endif +#if !defined ESOCKTNOSUPPORT +booboo #endif ], [gl_cv_header_errno_h_complete=no], diff --git a/m4/extensions-aix.m4 b/m4/extensions-aix.m4 new file mode 100644 index 00000000000..990a7ac3ef0 --- /dev/null +++ b/m4/extensions-aix.m4 @@ -0,0 +1,25 @@ +# extensions-aix.m4 +# serial 1 +dnl Copyright (C) 2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# On AIX, most extensions are already enabled through the _ALL_SOURCE macro, +# defined by gl_USE_SYSTEM_EXTENSIONS. gl_USE_AIX_EXTENSIONS additionally +# activates more GNU and Linux-like behaviours, affecting +# - the time_t type, +# - errno values in : ENOTEMPTY +# - functions in : malloc calloc realloc valloc +# +# - functions in : strerror_r (returns 'char *', like glibc) +# - functions in : scandir, alphasort, readdir_r +# - functions in : gethostbyname_r gethostbyaddr_r +# - declarations in : sbrk +# and a couple of secondary header files. + +AC_DEFUN_ONCE([gl_USE_AIX_EXTENSIONS], +[ + AC_DEFINE([_LINUX_SOURCE_COMPAT], [1], + [Define so that AIX headers are more compatible with GNU/Linux.]) +]) diff --git a/m4/fchmodat.m4 b/m4/fchmodat.m4 index e71ee8e8ef6..99dcf58aa7a 100644 --- a/m4/fchmodat.m4 +++ b/m4/fchmodat.m4 @@ -1,5 +1,5 @@ # fchmodat.m4 -# serial 8 +# serial 9 dnl Copyright (C) 2004-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -70,12 +70,12 @@ AC_DEFUN([gl_FUNC_FCHMODAT], esac ], [case "$host_os" in - # Guess no on Linux with glibc and Cygwin. - linux-gnu* | cygwin*) gl_cv_func_fchmodat_works="guessing no" ;; - # Guess 'nearly' on AIX. - aix*) gl_cv_func_fchmodat_works="guessing nearly" ;; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_fchmodat_works="$gl_cross_guess_normal" ;; + # Guess no on Linux with glibc and Cygwin. + linux*-gnu* | cygwin*) gl_cv_func_fchmodat_works="guessing no" ;; + # Guess 'nearly' on AIX. + aix*) gl_cv_func_fchmodat_works="guessing nearly" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_fchmodat_works="$gl_cross_guess_normal" ;; esac ]) rm -f conftest.fchmodat]) diff --git a/m4/fpieee.m4 b/m4/fpieee.m4 index 665543d0ed8..086d51ddf5b 100644 --- a/m4/fpieee.m4 +++ b/m4/fpieee.m4 @@ -1,5 +1,5 @@ # fpieee.m4 -# serial 2 -*- coding: utf-8 -*- +# serial 2 dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 06dd6029759..d985522893f 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,5 +1,5 @@ # gnulib-common.m4 -# serial 95 +# serial 103 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -21,10 +21,22 @@ AC_DEFUN([gl_COMMON_BODY], [ #define _GL_CONFIG_H_INCLUDED 1 ]) AH_VERBATIM([_GL_GNUC_PREREQ], -[/* True if the compiler says it groks GNU C version MAJOR.MINOR. */ -#if defined __GNUC__ && defined __GNUC_MINOR__ +[/* True if the compiler says it groks GNU C version MAJOR.MINOR. + Except that + - clang groks GNU C 4.2, even on Windows, where it does not define + __GNUC__. + - The OpenMandriva-modified clang compiler pretends that it groks + GNU C version 13.1, but it doesn't: It does not support + __attribute__ ((__malloc__ (f, i))), nor does it support + __attribute__ ((__warning__ (message))) on a function redeclaration. + - Users can make clang lie as well, through the -fgnuc-version option. */ +#if defined __GNUC__ && defined __GNUC_MINOR__ && !defined __clang__ # define _GL_GNUC_PREREQ(major, minor) \ ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__)) +#elif defined __clang__ + /* clang really only groks GNU C 4.2. */ +# define _GL_GNUC_PREREQ(major, minor) \ + ((major) < 4 + ((minor) <= 2)) #else # define _GL_GNUC_PREREQ(major, minor) 0 #endif @@ -133,6 +145,23 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_HAVE___HAS_C_ATTRIBUTE 0 #endif +/* Attributes in bracket syntax [[...]] vs. attributes in __attribute__((...)) + syntax, in function declarations. There are two problems here. + (Last tested with gcc/g++ 14 and clang/clang++ 18.) + + 1) We want that the _GL_ATTRIBUTE_* can be cumulated on the same declaration + in any order. + =========================== foo.c = foo.cc =========================== + __attribute__ ((__deprecated__)) [[__nodiscard__]] int bar1 (int); + [[__nodiscard__]] __attribute__ ((__deprecated__)) int bar2 (int); + ====================================================================== + This gives a syntax error + - in C mode with gcc + , and + - in C++ mode with clang++ version < 16, and + - in C++ mode, inside extern "C" {}, still in newer clang++ versions + . + */ /* Define if, in a function declaration, the attributes in bracket syntax [[...]] must come before the attributes in __attribute__((...)) syntax. If this is defined, it is best to avoid the bracket syntax, so that the @@ -147,6 +176,176 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_BRACKET_BEFORE_ATTRIBUTE 1 # endif #endif +/* + 2) We want that the _GL_ATTRIBUTE_* can be placed in a declaration + - without 'extern', in C as well as in C++, + - with 'extern', in C, + - with 'extern "C"', in C++ + in the same position. That is, we don't want to be forced to use a + macro which arranges for the attribute to come before 'extern' in + one case and after 'extern' in the other case, because such a macro + would make the source code of .h files pretty ugly. + =========================== foo.c = foo.cc =========================== + #ifdef __cplusplus + # define CC "C" + #else + # define CC + #endif + + #define ND [[__nodiscard__]] + #define WUR __attribute__((__warn_unused_result__)) + + #ifdef __cplusplus + extern "C" { + #endif + // gcc clang g++ clang++ + + ND int foo (int); + int ND foo (int); // warn error warn error + int foo ND (int); + int foo (int) ND; // warn error warn error + + WUR int foo (int); + int WUR foo (int); + int fo1 WUR (int); // error error error error + int foo (int) WUR; + + #ifdef __cplusplus + } + #endif + + // gcc clang g++ clang++ + + ND extern CC int foo (int); // error error + extern CC ND int foo (int); // error error + extern CC int ND foo (int); // warn error warn error + extern CC int foo ND (int); + extern CC int foo (int) ND; // warn error warn error + + WUR extern CC int foo (int); // warn + extern CC WUR int foo (int); + extern CC int WUR foo (int); + extern CC int foo WUR (int); // error error error error + extern CC int foo (int) WUR; + + ND EXTERN_C_FUNC int foo (int); // error error + EXTERN_C_FUNC ND int foo (int); + EXTERN_C_FUNC int ND foo (int); // warn error warn error + EXTERN_C_FUNC int foo ND (int); + EXTERN_C_FUNC int foo (int) ND; // warn error warn error + + WUR EXTERN_C_FUNC int foo (int); // warn + EXTERN_C_FUNC WUR int foo (int); + EXTERN_C_FUNC int WUR foo (int); + EXTERN_C_FUNC int fo2 WUR (int); // error error error error + EXTERN_C_FUNC int foo (int) WUR; + ====================================================================== + So, if we insist on using the 'extern' keyword ('extern CC' idiom): + * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] + in both C and C++, there is one available position: + - between the function name and the parameter list. + * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax + in both C and C++, there are several available positions: + - before the return type, + - between return type and function name, + - at the end of the declaration. + * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] in C and to + __attribute__((...)) syntax in C++, there is no available position: + it would need to come before 'extern' in C but after 'extern "C"' + in C++. + * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax in C and + to bracket syntax [[...]] in C++, there is one available position: + - before the return type. + Whereas, if we use the 'EXTERN_C_FUNC' idiom, which conditionally + omits the 'extern' keyword: + * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] + in both C and C++, there are two available positions: + - before the return type, + - between the function name and the parameter list. + * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax + in both C and C++, there are several available positions: + - before the return type, + - between return type and function name, + - at the end of the declaration. + * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] in C and to + __attribute__((...)) syntax in C++, there is one available position: + - before the return type. + * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax in C and + to bracket syntax [[...]] in C++, there is one available position: + - before the return type. + The best choice is therefore to use the 'EXTERN_C_FUNC' idiom and + put the attributes before the return type. This works regardless + to what the _GL_ATTRIBUTE_* macros expand. + */ + +/* Attributes in bracket syntax [[...]] vs. attributes in __attribute__((...)) + syntax, in static/inline function definitions. + + There are similar constraints as for function declarations. However, here, + we cannot omit the storage-class specifier. Therefore, the following rule + applies: + * The macros + _GL_ATTRIBUTE_CONST + _GL_ATTRIBUTE_DEPRECATED + _GL_ATTRIBUTE_MAYBE_UNUSED + _GL_ATTRIBUTE_NODISCARD + _GL_ATTRIBUTE_PURE + _GL_ATTRIBUTE_REPRODUCIBLE + _GL_ATTRIBUTE_UNSEQUENCED + which may expand to bracket syntax [[...]], must come first, before the + storage-class specifier. + * Other _GL_ATTRIBUTE_* macros, that expand to __attribute__((...)) syntax, + are better placed between the storage-class specifier and the return + type. + */ + +/* Attributes in bracket syntax [[...]] vs. attributes in __attribute__((...)) + syntax, in variable declarations. + + At which position can they be placed? + (Last tested with gcc/g++ 14 and clang/clang++ 18.) + + =========================== foo.c = foo.cc =========================== + #ifdef __cplusplus + # define CC "C" + #else + # define CC + #endif + + #define BD [[__deprecated__]] + #define AD __attribute__ ((__deprecated__)) + + // gcc clang g++ clang++ + + BD extern CC int var; // error error + extern CC BD int var; // error error + extern CC int BD var; // warn error warn error + extern CC int var BD; + + AD extern CC int var; // warn + extern CC AD int var; + extern CC int AD var; + extern CC int var AD; + + BD extern CC int z[]; // error error + extern CC BD int z[]; // error error + extern CC int BD z[]; // warn error warn error + extern CC int z1 BD []; + extern CC int z[] BD; // warn error error + + AD extern CC int z[]; // warn + extern CC AD int z[]; + extern CC int AD z[]; + extern CC int z2 AD []; // error error error error + extern CC int z[] AD; + ====================================================================== + + * For non-array variables, the only good position is after the variable name, + that is, at the end of the declaration. + * For array variables, you will need to distinguish C and C++: + - In C, before the 'extern' keyword. + - In C++, between the 'extern "C"' and the variable's type. + */ ]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 @@ -488,7 +687,7 @@ AC_DEFUN([gl_COMMON_BODY], [ other attributes. */ #ifndef _GL_ATTRIBUTE_NOTHROW # if defined __cplusplus -# if _GL_GNUC_PREREQ (2, 8) || __clang_major >= 4 +# if _GL_GNUC_PREREQ (2, 8) || __clang_major__ >= 4 # if __cplusplus >= 201103L # define _GL_ATTRIBUTE_NOTHROW noexcept (true) # else @@ -1156,7 +1355,7 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS], dnl -Wno-unused-parameter >= 3 >= 3.9 dnl cat > conftest.c <<\EOF - #if __GNUC__ >= 3 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + #if (__GNUC__ >= 3 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) -Wno-cast-qual -Wno-conversion -Wno-float-equal @@ -1165,23 +1364,23 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS], -Wno-unused-function -Wno-unused-parameter #endif - #if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + #if (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) -Wno-float-conversion #endif - #if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + #if (__GNUC__ >= 7 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) -Wimplicit-fallthrough #endif - #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + #if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) -Wno-pedantic #endif #if 3 < __clang_major__ + (9 <= __clang_minor__) -Wno-tautological-constant-out-of-range-compare #endif - #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + #if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) -Wno-sign-conversion -Wno-type-limits #endif - #if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4 + #if (__GNUC__ + (__GNUC_MINOR__ >= 5) > 4 && !defined __clang__) -Wno-unsuffixed-float-constants #endif EOF @@ -1364,7 +1563,7 @@ dnl dnl This macro sets two variables: dnl - gl_cv_onwards_func_ to yes / no / "future OS version" dnl - ac_cv_func_ to yes / no / no -dnl The first variable allows distinguishing all three cases. +dnl The first variable allows to distinguish all three cases. dnl The second variable is set, so that an invocation dnl gl_CHECK_FUNCS_ANDROID([func], [[#include ]]) dnl can be used as a drop-in replacement for @@ -1417,7 +1616,7 @@ dnl dnl This macro sets two variables: dnl - gl_cv_onwards_func_ to yes / no / "future OS version" dnl - ac_cv_func_ to yes / no / no -dnl The first variable allows distinguishing all three cases. +dnl The first variable allows to distinguish all three cases. dnl The second variable is set, so that an invocation dnl gl_CHECK_FUNCS_MACOS([func], [[#include ]]) dnl can be used as a drop-in replacement for diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 79a0f27382a..31784600d44 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -83,6 +83,10 @@ AC_DEFUN([gl_EARLY], # Code from module euidaccess: # Code from module execinfo: # Code from module extensions: + # This is actually already done in the pre-early phase. + # AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + # Code from module extensions-aix: + AC_REQUIRE([gl_USE_AIX_EXTENSIONS]) # Code from module extern-inline: # Code from module faccessat: # Code from module fchmodat: @@ -129,6 +133,7 @@ AC_DEFUN([gl_EARLY], # Code from module lchmod: # Code from module libc-config: # Code from module libgmp: + # Code from module libgmp-mpz: # Code from module limits-h: # Code from module lstat: # Code from module malloc-gnu: @@ -339,6 +344,7 @@ AC_DEFUN([gl_INIT], gl_CONDITIONAL([GL_COND_OBJ_FSTATAT], [test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1]) gl_SYS_STAT_MODULE_INDICATOR([fstatat]) + gl_MODULE_INDICATOR([fstatat]) gl_FSUSAGE gl_CONDITIONAL([GL_COND_OBJ_FSUSAGE], [test $gl_cv_fs_space = yes]) AM_COND_IF([GL_COND_OBJ_FSUSAGE], [ @@ -417,6 +423,7 @@ AC_DEFUN([gl_INIT], gl_PREREQ_LSTAT ]) gl_SYS_STAT_MODULE_INDICATOR([lstat]) + gl_MODULE_INDICATOR([lstat]) gl_FUNC_MEMMEM_SIMPLE if test $HAVE_MEMMEM = 0 || test $REPLACE_MEMMEM = 1; then AC_LIBOBJ([memmem]) @@ -496,10 +503,12 @@ AC_DEFUN([gl_INIT], gl_PREREQ_REGEX ]) gl_FUNC_SIG2STR - gl_CONDITIONAL([GL_COND_OBJ_SIG2STR], [test $ac_cv_func_sig2str = no]) + gl_CONDITIONAL([GL_COND_OBJ_SIG2STR], + [test $HAVE_SIG2STR = 0 || test $HAVE_STR2SIG = 0]) AM_COND_IF([GL_COND_OBJ_SIG2STR], [ gl_PREREQ_SIG2STR ]) + gl_SIGNAL_MODULE_INDICATOR([sig2str]) gl_FUNC_SIGDESCR_NP gl_CONDITIONAL([GL_COND_OBJ_SIGDESCR_NP], [test $HAVE_SIGDESCR_NP = 0]) gl_STRING_MODULE_INDICATOR([sigdescr_np]) @@ -626,7 +635,8 @@ AC_DEFUN([gl_INIT], ]) gl_TIME_MODULE_INDICATOR([time_r]) gl_TIME_RZ - gl_CONDITIONAL([GL_COND_OBJ_TIME_RZ], [test $HAVE_TIMEZONE_T = 0]) + gl_CONDITIONAL([GL_COND_OBJ_TIME_RZ], + [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test $REPLACE_MKTIME_Z = 1]) gl_TIME_MODULE_INDICATOR([time_rz]) gl_FUNC_TIMEGM gl_CONDITIONAL([GL_COND_OBJ_TIMEGM], @@ -1521,6 +1531,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/errno_h.m4 m4/euidaccess.m4 m4/execinfo.m4 + m4/extensions-aix.m4 m4/extensions.m4 m4/extern-inline.m4 m4/faccessat.m4 @@ -1557,7 +1568,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/lchmod.m4 m4/libgmp.m4 m4/limits-h.m4 - m4/locale-fr.m4 + m4/locale-en.m4 m4/lstat.m4 m4/malloc.m4 m4/manywarnings-c++.m4 diff --git a/m4/locale-en.m4 b/m4/locale-en.m4 new file mode 100644 index 00000000000..39d08a23b0b --- /dev/null +++ b/m4/locale-en.m4 @@ -0,0 +1,137 @@ +# locale-en.m4 +# serial 1 +dnl Copyright (C) 2003-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl Determine the name of an English (or American English) locale with +dnl UTF-8 encoding. +AC_DEFUN_ONCE([gt_LOCALE_EN_UTF8], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AM_LANGINFO_CODESET]) + AC_CACHE_CHECK([for an english Unicode locale], [gt_cv_locale_en_utf8], [ + case "$host_os" in + *-musl* | midipix*) + dnl On musl libc, all kinds of ll_CC.UTF-8 locales exist, even without + dnl any locale file on disk. But they are effectively equivalent to the + dnl C.UTF-8 locale, except for locale categories (such as LC_MESSSAGES) + dnl for which localizations (.mo files) have been installed. + gt_cv_locale_en_utf8=en_US.UTF-8 + ;; + *) + AC_LANG_CONFTEST([AC_LANG_SOURCE([[ +#include +#include +#if HAVE_LANGINFO_CODESET +# include +#endif +#include +#include +struct tm t; +char buf[16]; +int main () { + /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl + imitates locale dependent behaviour by looking at the environment + variables, and all locales use the UTF-8 encoding. */ +#if !(defined __BEOS__ || defined __HAIKU__) + /* Check whether the given locale name is recognized by the system. */ +# if defined _WIN32 && !defined __CYGWIN__ + /* On native Windows, setlocale(category, "") looks at the system settings, + not at the environment variables. Also, when an encoding suffix such + as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE + category of the locale to "C". */ + if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL + || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) + return 1; +# else + if (setlocale (LC_ALL, "") == NULL) return 1; +# endif + /* Check whether nl_langinfo(CODESET) is "UTF-8" or equivalent. */ +# if HAVE_LANGINFO_CODESET + { + const char *cs = nl_langinfo (CODESET); + if (!(strcmp (cs, "UTF-8") == 0 || strcmp (cs, "UTF8") == 0 + || strcmp (cs, "utf-8") == 0 || strcmp (cs, "utf8") == 0)) + return 1; + } +# endif +# ifdef __CYGWIN__ + /* On Cygwin, avoid locale names without encoding suffix, because the + locale_charset() function relies on the encoding suffix. Note that + LC_ALL is set on the command line. */ + if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; +# endif + /* Check the third month name. */ + t.tm_year = 1975 - 1900; t.tm_mon = 3 - 1; t.tm_mday = 24; + if (strftime (buf, sizeof (buf), "%B", &t) < 5 || strcmp (buf, "March") != 0) + return 1; +#endif +#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ + /* Check whether the decimal separator is a dot. */ + if (localeconv () ->decimal_point[0] != '.') return 1; +#endif + return 0; +} + ]])]) + if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then + case "$host_os" in + # Handle native Windows specially, because there setlocale() interprets + # "ar" or "ara" as "Arabic" or "Arabic_Saudi Arabia.1256", + # "en" or "eng" as "English" or "English_United States.1252", + # "fr" or "fra" as "French" or "French_France.1252", + # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", + # "ja" or "jpn" as "Japanese" or "Japanese_Japan.932", + # and similar. + mingw* | windows*) + # Test for the hypothetical native Windows locale name. + if (LC_ALL='English_United States.65001' LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_en_utf8='English_United States.65001' + else + # None found. + gt_cv_locale_en_utf8=none + fi + ;; + *) + # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because + # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the + # configure script would override the LC_ALL setting. Likewise for + # LC_CTYPE, which is also set at the beginning of the configure script. + # Test for the locale name with explicit encoding suffix first + # (this is necessary on Haiku). + if (LC_ALL=en_US.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_en_utf8=en_US.UTF-8 + else + # Test for the locale name without encoding suffix. + if (LC_ALL=en_US LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_en_utf8=en_US + else + # Test for the Solaris 10 locale name. + if (LC_ALL=en.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_en_utf8=en.UTF-8 + else + # None found. + gt_cv_locale_en_utf8=none + fi + fi + fi + ;; + esac + fi + rm -fr conftest* + ;; + esac + ]) + LOCALE_EN_UTF8="$gt_cv_locale_en_utf8" + case "$LOCALE_EN_UTF8" in #( + '' | *[[\"\$\'*@<:@]]*) + dnl The empty value occurs when the conftest.c program above could not + dnl be compiled. The other values might cause trouble with sh or make. + AC_MSG_WARN([invalid locale "$LOCALE_EN_UTF8"; assuming "none"]) + LOCALE_EN_UTF8=none;; + esac + AC_SUBST([LOCALE_EN_UTF8]) +]) diff --git a/m4/malloc.m4 b/m4/malloc.m4 index 41a46937ead..ee6df5c3fb6 100644 --- a/m4/malloc.m4 +++ b/m4/malloc.m4 @@ -1,5 +1,5 @@ # malloc.m4 -# serial 31 +# serial 34 dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -45,6 +45,11 @@ AC_DEFUN([gl_FUNC_MALLOC_GNU], [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) + + dnl Through the dependency on module extensions-aix, _LINUX_SOURCE_COMPAT + dnl gets defined already before this macro gets invoked. This helps + dnl if !(__VEC__ || __AIXVEC), and doesn't hurt otherwise. + REPLACE_MALLOC_FOR_MALLOC_GNU="$REPLACE_MALLOC_FOR_MALLOC_POSIX" if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 0; then _AC_FUNC_MALLOC_IF([], [REPLACE_MALLOC_FOR_MALLOC_GNU=1]) diff --git a/m4/realloc.m4 b/m4/realloc.m4 index eb90d5885c7..cc91102836f 100644 --- a/m4/realloc.m4 +++ b/m4/realloc.m4 @@ -1,5 +1,5 @@ # realloc.m4 -# serial 29 +# serial 32 dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -45,6 +45,11 @@ AC_DEFUN([gl_FUNC_REALLOC_GNU], [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_REALLOC_POSIX]) + + dnl Through the dependency on module extensions-aix, _LINUX_SOURCE_COMPAT + dnl gets defined already before this macro gets invoked. This helps + dnl if !(__VEC__ || __AIXVEC), and doesn't hurt otherwise. + if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 0; then _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC_FOR_REALLOC_GNU=1]) fi diff --git a/m4/sig2str.m4 b/m4/sig2str.m4 index 096d0253fcb..acef58a6a40 100644 --- a/m4/sig2str.m4 +++ b/m4/sig2str.m4 @@ -1,5 +1,5 @@ # sig2str.m4 -# serial 7 +# serial 8 dnl Copyright (C) 2002, 2005-2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,7 +7,14 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_SIG2STR], [ - AC_CHECK_FUNCS([sig2str]) + AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) + AC_CHECK_FUNCS([sig2str str2sig]) + if test $ac_cv_func_sig2str = no; then + HAVE_SIG2STR=0 + fi + if test $ac_cv_func_str2sig = no; then + HAVE_STR2SIG=0 + fi ]) # Prerequisites of lib/sig2str.c. diff --git a/m4/signal_h.m4 b/m4/signal_h.m4 index 65afa2a1dee..7a7d2b3c526 100644 --- a/m4/signal_h.m4 +++ b/m4/signal_h.m4 @@ -1,5 +1,5 @@ # signal_h.m4 -# serial 22 +# serial 23 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -32,7 +32,8 @@ AC_DEFUN_ONCE([gl_SIGNAL_H], dnl Check for declarations of anything we want to poison if the dnl corresponding gnulib module is not in use. gl_WARN_ON_USE_PREPARE([[#include - ]], [pthread_sigmask sigaction + ]], [sig2str str2sig + pthread_sigmask sigaction sigaddset sigdelset sigemptyset sigfillset sigismember sigpending sigprocmask]) @@ -74,6 +75,7 @@ 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_SIG2STR]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGNAL_H_SIGPIPE]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGPROCMASK]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGACTION]) @@ -88,9 +90,11 @@ AC_DEFUN([gl_SIGNAL_H_DEFAULTS], HAVE_POSIX_SIGNALBLOCKING=1; AC_SUBST([HAVE_POSIX_SIGNALBLOCKING]) HAVE_PTHREAD_SIGMASK=1; AC_SUBST([HAVE_PTHREAD_SIGMASK]) HAVE_RAISE=1; AC_SUBST([HAVE_RAISE]) + HAVE_SIG2STR=1; AC_SUBST([HAVE_SIG2STR]) HAVE_SIGSET_T=1; AC_SUBST([HAVE_SIGSET_T]) HAVE_SIGINFO_T=1; AC_SUBST([HAVE_SIGINFO_T]) HAVE_SIGACTION=1; AC_SUBST([HAVE_SIGACTION]) + HAVE_STR2SIG=1; AC_SUBST([HAVE_STR2SIG]) HAVE_STRUCT_SIGACTION_SA_SIGACTION=1; AC_SUBST([HAVE_STRUCT_SIGACTION_SA_SIGACTION]) HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=1; diff --git a/m4/std-gnu11.m4 b/m4/std-gnu11.m4 index 37324c158e7..e8d5de7a1e1 100644 --- a/m4/std-gnu11.m4 +++ b/m4/std-gnu11.m4 @@ -1,8 +1,11 @@ # std-gnu11.m4 -# serial 1 +# serial 2 # Prefer GNU C11 and C++11 to earlier versions. -*- coding: utf-8 -*- +# The std-gnu23 module, which defines _AC_C_C23_OPTIONS, supersedes us. +m4_ifndef([_AC_C_C23_OPTIONS], [ + # This implementation is taken from GNU Autoconf lib/autoconf/c.m4 # commit 017d5ddd82854911f0119691d91ea8a1438824d6 # dated Sun Apr 3 13:57:17 2016 -0700 @@ -38,7 +41,7 @@ m4_version_prereq([2.70], [], [ # COMPILER ... is a space separated list of C compilers to search for. # This just gives the user an opportunity to specify an alternative # search list for the C compiler. -AC_DEFUN_ONCE([AC_PROG_CC], +AC_DEFUN([AC_PROG_CC], [AC_LANG_PUSH(C)dnl AC_ARG_VAR([CC], [C compiler command])dnl AC_ARG_VAR([CFLAGS], [C compiler flags])dnl @@ -830,3 +833,4 @@ dnl with extended modes being tried first. ])# m4_version_prereq +])# !_AC_C_C23_OPTIONS diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4 index bb5a6460414..5d9b3017c44 100644 --- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -1,5 +1,5 @@ # stdlib_h.m4 -# serial 78 +# serial 81 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -37,7 +37,7 @@ AC_DEFUN_ONCE([gl_STDLIB_H], dnl On Solaris 10, in UTF-8 locales, its value is 3 but needs to be 4. dnl Fortunately, we can do this because on this platform MB_LEN_MAX is 5. AC_REQUIRE([AC_CANONICAL_HOST]) - AC_REQUIRE([gt_LOCALE_FR_UTF8]) + AC_REQUIRE([gt_LOCALE_EN_UTF8]) AC_CACHE_CHECK([whether MB_CUR_MAX is correct], [gl_cv_macro_MB_CUR_MAX_good], [ @@ -45,13 +45,13 @@ AC_DEFUN_ONCE([gl_STDLIB_H], dnl is present. changequote(,)dnl case "$host_os" in - # Guess no on Solaris. - solaris*) gl_cv_macro_MB_CUR_MAX_good="guessing no" ;; - # Guess yes otherwise. - *) gl_cv_macro_MB_CUR_MAX_good="guessing yes" ;; + # Guess no on Solaris and Haiku. + solaris* | haiku*) gl_cv_macro_MB_CUR_MAX_good="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_macro_MB_CUR_MAX_good="guessing yes" ;; esac changequote([,])dnl - if test $LOCALE_FR_UTF8 != none; then + if test "$LOCALE_EN_UTF8" != none; then AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #include @@ -59,7 +59,7 @@ changequote([,])dnl int main () { int result = 0; - if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + if (setlocale (LC_ALL, "$LOCALE_EN_UTF8") != NULL) { if (MB_CUR_MAX < 4) result |= 1; @@ -146,6 +146,7 @@ AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS], 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_STACK_TRACE]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOD]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOF]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOL]) @@ -261,4 +262,5 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], REPLACE_STRTOULL=0; AC_SUBST([REPLACE_STRTOULL]) REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV]) REPLACE_WCTOMB=0; AC_SUBST([REPLACE_WCTOMB]) + CAN_PRINT_STACK_TRACE=0; AC_SUBST([CAN_PRINT_STACK_TRACE]) ]) diff --git a/m4/time_h.m4 b/m4/time_h.m4 index 4ca7305792c..88c76c03c02 100644 --- a/m4/time_h.m4 +++ b/m4/time_h.m4 @@ -1,5 +1,5 @@ # time_h.m4 -# serial 26 +# serial 27 dnl Copyright (C) 2000-2001, 2003-2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -163,13 +163,16 @@ AC_DEFUN([gl_TIME_H_DEFAULTS], HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) HAVE_TIMESPEC_GET=1; AC_SUBST([HAVE_TIMESPEC_GET]) HAVE_TIMESPEC_GETRES=1; AC_SUBST([HAVE_TIMESPEC_GETRES]) - dnl Even GNU libc does not have timezone_t yet. + dnl Even GNU libc does not have timezone_t and tzalloc() yet. HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T]) + HAVE_TZALLOC=0; AC_SUBST([HAVE_TZALLOC]) REPLACE_CTIME=0; AC_SUBST([REPLACE_CTIME]) REPLACE_GMTIME=0; AC_SUBST([REPLACE_GMTIME]) REPLACE_LOCALTIME=0; AC_SUBST([REPLACE_LOCALTIME]) REPLACE_LOCALTIME_R=0; AC_SUBST([REPLACE_LOCALTIME_R]) + REPLACE_LOCALTIME_RZ=0; AC_SUBST([REPLACE_LOCALTIME_RZ]) REPLACE_MKTIME=0; AC_SUBST([REPLACE_MKTIME]) + REPLACE_MKTIME_Z=0; AC_SUBST([REPLACE_MKTIME_Z]) REPLACE_NANOSLEEP=0; AC_SUBST([REPLACE_NANOSLEEP]) REPLACE_STRFTIME=0; AC_SUBST([REPLACE_STRFTIME]) REPLACE_TIME=0; AC_SUBST([REPLACE_TIME]) diff --git a/m4/time_rz.m4 b/m4/time_rz.m4 index 9613597aca0..1a3dd3befb1 100644 --- a/m4/time_rz.m4 +++ b/m4/time_rz.m4 @@ -1,5 +1,5 @@ # time_rz.m4 -# serial 2 +# serial 3 dnl Copyright (C) 2015-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,8 +11,9 @@ dnl Written by Paul Eggert. AC_DEFUN([gl_TIME_RZ], [ - AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) AC_REQUIRE([gl_TIME_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([AC_CANONICAL_HOST]) # On Mac OS X 10.6, localtime loops forever with some time_t values. # See Bug#27706, Bug#27736, and @@ -51,4 +52,29 @@ AC_DEFUN([gl_TIME_RZ], if test "$ac_cv_type_timezone_t" = yes; then HAVE_TIMEZONE_T=1 fi + + gl_CHECK_FUNCS_ANDROID([tzalloc], [[#include ]]) + if test $ac_cv_func_tzalloc = yes; then + HAVE_TZALLOC=1 + fi + dnl Assume that tzalloc, localtime_rz, mktime_z are all defined together. + case "$gl_cv_onwards_func_tzalloc" in + yes) + case "$host_os" in + *-android*) + dnl The Android libc functions localtime_rz, mktime_z don't support + dnl a NULL timezone_t argument. + AC_DEFINE([NEED_TIMEZONE_NULL_SUPPORT], [1], + [Define to 1 if localtime_rz, mktime_z exist and can be used with + non-NULL timezone_t values.]) + REPLACE_LOCALTIME_RZ=1 + REPLACE_MKTIME_Z=1 + ;; + esac + ;; + future*) + REPLACE_LOCALTIME_RZ=1 + REPLACE_MKTIME_Z=1 + ;; + esac ]) diff --git a/src/conf_post.h b/src/conf_post.h index 53e1cb56e74..f2353803074 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -475,15 +475,3 @@ extern int emacs_setenv_TZ (char const *); /* Emacs does not need glibc strftime behavior for AM and PM indicators. */ #define REQUIRE_GNUISH_STRFTIME_AM_PM false - -#if defined __ANDROID_API__ && __ANDROID_API__ < 35 -/* Persuade lib/time.h to include the system's time.h, then... */ -#define __need_time_t -#include -#undef __need_time_t - -/* ... redefine timezone_t to an Emacs-specific type, so that Gnulib's - replacement may not conflict with the OS type uselessly defined when - __ANDROID_API__ < 35. */ -#define timezone_t rpl_timezone_t -#endif /* __ANDROID_API__ && __ANDROID_API__ < 35 */