Update from Gnulib by running admin/merge-gnulib

This commit is contained in:
Paul Eggert 2023-02-25 17:01:22 -08:00
parent e91d29f004
commit 6a3a729705
15 changed files with 259 additions and 57 deletions

View file

@ -47,7 +47,7 @@
# define optind __GETOPT_ID (optind)
# define optopt __GETOPT_ID (optopt)
/* Work around a a problem on macOS, which declares getopt with a
/* Work around a problem on macOS, which declares getopt with a
trailing __DARWIN_ALIAS(getopt) that would expand to something like
__asm("_" "rpl_getopt" "$UNIX2003") were it not for the following
hack to suppress the macOS declaration <https://bugs.gnu.org/40205>. */

View file

@ -119,11 +119,14 @@
/* Macros specified by C23. */
#if (! defined BOOL_WIDTH \
&& (defined _GNU_SOURCE \
|| (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)))
# define BOOL_MAX 1
# define BOOL_WIDTH 1
#if (defined _GNU_SOURCE \
|| (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__))
# if ! defined BOOL_WIDTH
# define BOOL_WIDTH 1
# define BOOL_MAX 1
# elif ! defined BOOL_MAX
# define BOOL_MAX ((((1U << (BOOL_WIDTH - 1)) - 1) << 1) + 1)
# endif
#endif
#endif /* _@GUARD_PREFIX@_LIMITS_H */

View file

@ -126,7 +126,11 @@
# if (@REPLACE_FREE@ && !defined free \
&& !(defined __cplusplus && defined GNULIB_NAMESPACE))
/* We can't do '#define free rpl_free' here. */
# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
_GL_EXTERN_C void rpl_free (void *) throw ();
# else
_GL_EXTERN_C void rpl_free (void *);
# endif
# undef _GL_ATTRIBUTE_DEALLOC_FREE
# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
# else

View file

@ -40,6 +40,24 @@
# undef _GL_INCLUDING_UNISTD_H
#endif
/* Avoid lseek bugs in FreeBSD, macOS <https://bugs.gnu.org/61386>.
This bug is fixed after FreeBSD 13; see <https://bugs.freebsd.org/256205>.
Use macOS "9999" to stand for a future fixed macOS version. */
#if defined __FreeBSD__ && __FreeBSD__ < 14
# undef SEEK_DATA
# undef SEEK_HOLE
#elif defined __APPLE__ && defined __MACH__ && defined SEEK_DATA
# ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
# include <AvailabilityMacros.h>
# endif
# if (!defined MAC_OS_X_VERSION_MIN_REQUIRED \
|| MAC_OS_X_VERSION_MIN_REQUIRED < 99990000)
# include <sys/fcntl.h> /* It also defines the two macros. */
# undef SEEK_DATA
# undef SEEK_HOLE
# endif
#endif
/* Get all possible declarations of gethostname(). */
#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
&& !defined _GL_INCLUDING_WINSOCK2_H

View file

@ -265,6 +265,8 @@ template <int w>
# define _GL_SA3 static_assert
# define _GL_SA_PICK(x1,x2,x3,x4,...) x4
# define static_assert(...) _GL_EXPAND(_GL_SA_PICK(__VA_ARGS__,_GL_SA3,_GL_SA2,_GL_SA1)) (__VA_ARGS__)
/* Avoid "fatal error C1189: #error: The C++ Standard Library forbids macroizing keywords." */
# define _ALLOW_KEYWORD_MACROS 1
# else
# define static_assert _Static_assert /* C11 requires this #define. */
# endif

View file

@ -46,10 +46,13 @@ AC_DEFUN([gl_ASSERT_H],
gl_NEXT_HEADERS([assert.h])])
dnl The "zz" puts this toward config.h's end, to avoid potential
dnl collisions with other definitions. #undef assert so that
dnl programs are not tempted to use it without specifically
dnl including assert.h. Break the #undef apart with a comment
dnl so that 'configure' does not comment it out.
dnl collisions with other definitions.
dnl #undef assert so that programs are not tempted to use it without
dnl specifically including assert.h.
dnl #undef __ASSERT_H__ so that on IRIX, when programs later include
dnl <assert.h>, this include actually defines assert.
dnl Break the #undef_s apart with a comment so that 'configure' does
dnl not comment them out.
AH_VERBATIM([zzstatic_assert],
[#if (!defined HAVE_C_STATIC_ASSERT && !defined assert \
&& (!defined __cplusplus \
@ -57,6 +60,9 @@ AC_DEFUN([gl_ASSERT_H],
&& __GNUG__ < 6 && __clang_major__ < 6)))
#include <assert.h>
#undef/**/assert
#ifdef __sgi
#undef/**/__ASSERT_H__
#endif
/* Solaris 11.4 <assert.h> defines static_assert as a macro with 2 arguments.
We need it also to be invocable with a single argument. */
#if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus

View file

@ -1,4 +1,4 @@
# serial 14
# serial 15
# See if we need to provide fdopendir.
dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@ -49,12 +49,12 @@ DIR *fdopendir (int);
[gl_cv_func_fdopendir_works=yes],
[gl_cv_func_fdopendir_works=no],
[case "$host_os" in
# Guess yes on glibc systems.
*-gnu*) gl_cv_func_fdopendir_works="guessing yes" ;;
# Guess yes on musl systems.
*-musl*) gl_cv_func_fdopendir_works="guessing yes" ;;
# If we don't know, obey --enable-cross-guesses.
*) gl_cv_func_fdopendir_works="$gl_cross_guess_normal" ;;
# Guess yes on glibc systems.
*-gnu*) gl_cv_func_fdopendir_works="guessing yes" ;;
# Guess yes on musl systems.
*-musl* | midipix*) gl_cv_func_fdopendir_works="guessing yes" ;;
# If we don't know, obey --enable-cross-guesses.
*) gl_cv_func_fdopendir_works="$gl_cross_guess_normal" ;;
esac
])])
case "$gl_cv_func_fdopendir_works" in

View file

@ -1,4 +1,4 @@
# gnulib-common.m4 serial 80
# gnulib-common.m4 serial 82
dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@ -356,7 +356,7 @@ AC_DEFUN([gl_COMMON_BODY], [
[[__maybe_unused__]] nevertheless produces a warning. */
#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
# if defined __clang__ && defined __cplusplus
# if __clang_major__ >= 10
# if !defined __apple_build_version__ && __clang_major__ >= 10
# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
# endif
# elif defined __has_c_attribute
@ -1095,6 +1095,113 @@ AC_DEFUN([gl_CONDITIONAL_HEADER],
m4_popdef([gl_header_name])
])
dnl Preparations for gl_CHECK_FUNCS_MACOS.
AC_DEFUN([gl_PREPARE_CHECK_FUNCS_MACOS],
[
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([gl_COMPILER_CLANG])
AC_CACHE_CHECK([for compiler option needed when checking for future declarations],
[gl_cv_compiler_check_future_option],
[case "$host_os" in
dnl This is only needed on macOS.
darwin*)
if test $gl_cv_compiler_clang = yes; then
dnl Test whether the compiler supports the option
dnl '-Werror=unguarded-availability-new'.
save_ac_compile="$ac_compile"
ac_compile="$ac_compile -Werror=unguarded-availability-new"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
[gl_cv_compiler_check_future_option='-Werror=unguarded-availability-new'],
[gl_cv_compiler_check_future_option=none])
ac_compile="$save_ac_compile"
else
gl_cv_compiler_check_future_option=none
fi
;;
*) gl_cv_compiler_check_future_option=none ;;
esac
])
])
dnl Pieces of the expansion of
dnl gl_CHECK_FUNCS_ANDROID
dnl gl_CHECK_FUNCS_MACOS
dnl gl_CHECK_FUNCS_ANDROID_MACOS
AC_DEFUN([gl_CHECK_FUNCS_DEFAULT_CASE],
[
*)
AC_CHECK_FUNC([$1])
[gl_cv_onwards_func_][$1]=$[ac_cv_func_][$1]
;;
])
AC_DEFUN([gl_CHECK_FUNCS_CASE_FOR_ANDROID],
[
linux*-android*)
AC_CHECK_DECL([$1], , , [$2])
if test $[ac_cv_have_decl_][$1] = yes; then
AC_CHECK_FUNC([[$1]])
if test $[ac_cv_func_][$1] = yes; then
[gl_cv_onwards_func_][$1]=yes
else
dnl The function is declared but does not exist. This should not
dnl happen normally. But anyway, we know that a future version
dnl of Android will have the function.
[gl_cv_onwards_func_][$1]='future OS version'
fi
else
[gl_cv_onwards_func_][$1]='future OS version'
fi
;;
])
AC_DEFUN([gl_CHECK_FUNCS_CASE_FOR_MACOS],
[
darwin*)
if test "x$gl_cv_compiler_check_future_option" != "xnone"; then
dnl Use a compile test, not a link test.
save_ac_compile="$ac_compile"
ac_compile="$ac_compile $gl_cv_compiler_check_future_option"
save_ac_compile_for_check_decl="$ac_compile_for_check_decl"
ac_compile_for_check_decl="$ac_compile_for_check_decl $gl_cv_compiler_check_future_option"
unset [ac_cv_have_decl_][$1]
AC_CHECK_DECL([$1], , , [$2])
ac_compile="$save_ac_compile"
ac_compile_for_check_decl="$save_ac_compile_for_check_decl"
[ac_cv_func_][$1]="$[ac_cv_have_decl_][$1]"
if test $[ac_cv_func_][$1] = yes; then
[gl_cv_onwards_func_][$1]=yes
else
unset [ac_cv_have_decl_][$1]
AC_CHECK_DECL([$1], , , [$2])
if test $[ac_cv_have_decl_][$1] = yes; then
[gl_cv_onwards_func_][$1]='future OS version'
else
[gl_cv_onwards_func_][$1]=no
fi
fi
else
AC_CHECK_FUNC([$1])
[gl_cv_onwards_func_][$1]=$[ac_cv_func_][$1]
fi
;;
])
AC_DEFUN([gl_CHECK_FUNCS_SET_RESULTS],
[
case "$[gl_cv_onwards_func_][$1]" in
future*) [ac_cv_func_][$1]=no ;;
*) [ac_cv_func_][$1]=$[gl_cv_onwards_func_][$1] ;;
esac
if test $[ac_cv_func_][$1] = yes; then
AC_DEFINE([HAVE_]m4_translit([[$1]],
[abcdefghijklmnopqrstuvwxyz],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ]),
[1], [Define to 1 if you have the `$1' function.])
fi
])
dnl gl_CHECK_FUNCS_ANDROID([func], [[#include <foo.h>]])
dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem
dnl on Android.
@ -1137,39 +1244,87 @@ AC_DEFUN([gl_CHECK_FUNCS_ANDROID],
[[gl_cv_onwards_func_][$1]],
[gl_SILENT([
case "$host_os" in
linux*-android*)
AC_CHECK_DECL([$1], , , [$2])
if test $[ac_cv_have_decl_][$1] = yes; then
AC_CHECK_FUNC([[$1]])
if test $[ac_cv_func_][$1] = yes; then
[gl_cv_onwards_func_][$1]=yes
else
dnl The function is declared but does not exist. This should not
dnl happen normally. But anyway, we know that a future version
dnl of Android will have the function.
[gl_cv_onwards_func_][$1]='future OS version'
fi
else
[gl_cv_onwards_func_][$1]='future OS version'
fi
;;
*)
AC_CHECK_FUNC([$1])
[gl_cv_onwards_func_][$1]=$[ac_cv_func_][$1]
;;
gl_CHECK_FUNCS_CASE_FOR_ANDROID([$1], [$2])
gl_CHECK_FUNCS_DEFAULT_CASE([$1])
esac
])
])
case "$[gl_cv_onwards_func_][$1]" in
future*) [ac_cv_func_][$1]=no ;;
*) [ac_cv_func_][$1]=$[gl_cv_onwards_func_][$1] ;;
esac
if test $[ac_cv_func_][$1] = yes; then
AC_DEFINE([HAVE_]m4_translit([[$1]],
[abcdefghijklmnopqrstuvwxyz],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ]),
[1], [Define to 1 if you have the `$1' function.])
fi
gl_CHECK_FUNCS_SET_RESULTS([$1])
])
dnl gl_CHECK_FUNCS_MACOS([func], [[#include <foo.h>]])
dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem
dnl on macOS.
dnl
dnl When code is compiled on macOS, it is in the context of a certain minimum
dnl macOS version, that can be set through the option '-mmacosx-version-min='.
dnl In other words, you don't compile for a specific version of macOS. You
dnl compile for all versions of macOS, onwards from the given version.
dnl Thus, the question "does the OS have the function func" has three possible
dnl answers:
dnl - yes, in all versions starting from the given version,
dnl - no, in no version,
dnl - not in the given version, but in a later version of macOS.
dnl
dnl In detail, this works as follows:
dnl If func was added to, say, macOS version 13, then the libc has the
dnl symbol func always, whereas the header file <foo.h> declares func
dnl conditionally with a special availability attribute:
dnl ... func (...) __attribute__((availability(macos,introduced=13.0)));
dnl Thus, when compiling with "clang mmacosx-version-min=13", there is no
dnl warning about the use of func, and the resulting binary
dnl - runs fine on macOS 13,
dnl - aborts with a dyld "Symbol not found" message on macOS 12.
dnl Whereas, when compiling with "clang mmacosx-version-min=12", there is a
dnl warning: 'func' is only available on macOS 13.0 or newer
dnl [-Wunguarded-availability-new],
dnl and the resulting binary
dnl - runs fine on macOS 13,
dnl - crashes with a SIGSEGV (signal 11) on macOS 12.
dnl
dnl This macro sets two variables:
dnl - gl_cv_onwards_func_<func> to yes / no / "future OS version"
dnl - ac_cv_func_<func> to yes / no / no
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 <foo.h>]])
dnl can be used as a drop-in replacement for
dnl AC_CHECK_FUNCS([func]).
AC_DEFUN([gl_CHECK_FUNCS_MACOS],
[
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([gl_PREPARE_CHECK_FUNCS_MACOS])
AC_CACHE_CHECK([for [$1]],
[[gl_cv_onwards_func_][$1]],
[gl_SILENT([
case "$host_os" in
gl_CHECK_FUNCS_CASE_FOR_MACOS([$1], [$2])
gl_CHECK_FUNCS_DEFAULT_CASE([$1])
esac
])
])
gl_CHECK_FUNCS_SET_RESULTS([$1])
])
dnl gl_CHECK_FUNCS_ANDROID_MACOS([func], [[#include <foo.h>]])
dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem
dnl on Android and on macOS.
dnl It is the combination of gl_CHECK_FUNCS_ANDROID and gl_CHECK_FUNCS_MACOS.
AC_DEFUN([gl_CHECK_FUNCS_ANDROID_MACOS],
[
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([gl_PREPARE_CHECK_FUNCS_MACOS])
AC_CACHE_CHECK([for [$1]],
[[gl_cv_onwards_func_][$1]],
[gl_SILENT([
case "$host_os" in
gl_CHECK_FUNCS_CASE_FOR_ANDROID([$1], [$2])
gl_CHECK_FUNCS_CASE_FOR_MACOS([$1], [$2])
gl_CHECK_FUNCS_DEFAULT_CASE([$1])
esac
])
])
gl_CHECK_FUNCS_SET_RESULTS([$1])
])
dnl Expands to some code for use in .c programs that, on native Windows, defines

View file

@ -23,6 +23,7 @@ AC_DEFUN_ONCE([gl_LIMITS_H],
int wb = WORD_BIT;
int ullw = ULLONG_WIDTH;
int bw = BOOL_WIDTH;
int bm = BOOL_MAX;
]])],
[gl_cv_header_limits_width=yes],
[gl_cv_header_limits_width=no])])

View file

@ -1,4 +1,4 @@
# serial 33
# serial 34
# Copyright (C) 1997-2001, 2003-2023 Free Software Foundation, Inc.
#
@ -56,6 +56,9 @@ AC_DEFUN([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
linux-* | linux)
# Guess yes on Linux systems.
gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;
midipix*)
# Guess yes on systems that emulate the Linux system calls.
gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;
*-gnu* | gnu*)
# Guess yes on glibc systems.
gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;

View file

@ -1,4 +1,4 @@
# malloc.m4 serial 28
# malloc.m4 serial 29
dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@ -25,7 +25,7 @@ AC_DEFUN([_AC_FUNC_MALLOC_IF],
[case "$host_os" in
# Guess yes on platforms where we know the result.
*-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
| gnu* | *-musl* | midnightbsd* \
| gnu* | *-musl* | midipix* | midnightbsd* \
| hpux* | solaris* | cygwin* | mingw* | msys* )
ac_cv_func_malloc_0_nonnull="guessing yes" ;;
# If we don't know, obey --enable-cross-guesses.

View file

@ -1,4 +1,4 @@
# pselect.m4 serial 10
# pselect.m4 serial 11
dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@ -54,6 +54,8 @@ AC_DEFUN([gl_FUNC_PSELECT],
case "$host_os" in
# Guess yes on Linux systems.
linux-* | linux) gl_cv_func_pselect_detects_ebadf="guessing yes" ;;
# Guess yes on systems that emulate the Linux system calls.
midipix*) gl_cv_func_pselect_detects_ebadf="guessing yes" ;;
# Guess yes on glibc systems.
*-gnu* | gnu*) gl_cv_func_pselect_detects_ebadf="guessing yes" ;;
# If we don't know, obey --enable-cross-guesses.

View file

@ -1,4 +1,4 @@
# readlink.m4 serial 16
# readlink.m4 serial 17
dnl Copyright (C) 2003, 2007, 2009-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@ -38,6 +38,9 @@ AC_DEFUN([gl_FUNC_READLINK],
# Guess yes on Linux or glibc systems.
linux-* | linux | *-gnu* | gnu*)
gl_cv_func_readlink_trailing_slash="guessing yes" ;;
# Guess yes on systems that emulate the Linux system calls.
midipix*)
gl_cv_func_readlink_trailing_slash="guessing yes" ;;
# Guess no on AIX or HP-UX.
aix* | hpux*)
gl_cv_func_readlink_trailing_slash="guessing no" ;;
@ -75,6 +78,9 @@ AC_DEFUN([gl_FUNC_READLINK],
# Guess yes on Linux or glibc systems.
linux-* | linux | *-gnu* | gnu*)
gl_cv_func_readlink_truncate="guessing yes" ;;
# Guess yes on systems that emulate the Linux system calls.
midipix*)
gl_cv_func_readlink_truncate="guessing yes" ;;
# Guess no on AIX or HP-UX.
aix* | hpux*)
gl_cv_func_readlink_truncate="guessing no" ;;

View file

@ -1,4 +1,4 @@
# realloc.m4 serial 26
# realloc.m4 serial 27
dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@ -25,7 +25,7 @@ AC_DEFUN([_AC_FUNC_REALLOC_IF],
[case "$host_os" in
# Guess yes on platforms where we know the result.
*-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
| gnu* | *-musl* | midnightbsd* \
| gnu* | *-musl* | midipix* | midnightbsd* \
| hpux* | solaris* | cygwin* | mingw* | msys* )
ac_cv_func_realloc_0_nonnull="guessing yes" ;;
# If we don't know, obey --enable-cross-guesses.

View file

@ -1,4 +1,4 @@
# serial 9
# serial 10
# See if we need to provide symlink replacement.
dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@ -38,6 +38,8 @@ AC_DEFUN([gl_FUNC_SYMLINK],
[case "$host_os" in
# Guess yes on Linux systems.
linux-* | linux) gl_cv_func_symlink_works="guessing yes" ;;
# Guess yes on systems that emulate the Linux system calls.
midipix*) gl_cv_func_symlink_works="guessing yes" ;;
# Guess yes on glibc systems.
*-gnu* | gnu*) gl_cv_func_symlink_works="guessing yes" ;;
# If we don't know, obey --enable-cross-guesses.