summaryrefslogtreecommitdiffstats
path: root/gl/m4
diff options
context:
space:
mode:
authorLorenz <12514511+RincewindsHat@users.noreply.github.com>2023-03-27 12:34:19 +0200
committerGitHub <noreply@github.com>2023-03-27 12:34:19 +0200
commitbbc97d57f7f9e0a49fea78c02861c444fe95d46a (patch)
treec8956bbbe9b73e37d261735699a82cccaacea0db /gl/m4
parent917dba07fded8ef04967183a4c0443b5cce2db82 (diff)
parent482aa6c7fe86d7a899e4888d14149f1ccd5401fd (diff)
downloadmonitoring-plugins-bbc97d57f7f9e0a49fea78c02861c444fe95d46a.tar.gz
Merge branch 'master' into dev/check_ssh-patches
Diffstat (limited to 'gl/m4')
-rw-r--r--gl/m4/00gnulib.m491
-rw-r--r--gl/m4/__inline.m422
-rw-r--r--gl/m4/absolute-header.m4100
-rw-r--r--gl/m4/af_alg.m457
-rw-r--r--gl/m4/alloca.m453
-rw-r--r--gl/m4/arpa_inet_h.m435
-rw-r--r--gl/m4/assert_h.m467
-rw-r--r--gl/m4/base64.m42
-rw-r--r--gl/m4/btowc.m433
-rw-r--r--gl/m4/builtin-expect.m449
-rw-r--r--gl/m4/byteswap.m417
-rw-r--r--gl/m4/c-bool.m451
-rw-r--r--gl/m4/calloc.m483
-rw-r--r--gl/m4/close.m435
-rw-r--r--gl/m4/codeset.m43
-rw-r--r--gl/m4/configmake.m450
-rw-r--r--gl/m4/dirname.m419
-rw-r--r--gl/m4/double-slash-root.m42
-rw-r--r--gl/m4/dup2.m4105
-rw-r--r--gl/m4/eealloc.m42
-rw-r--r--gl/m4/environ.m423
-rw-r--r--gl/m4/errno_h.m420
-rw-r--r--gl/m4/error.m48
-rw-r--r--gl/m4/exponentd.m42
-rw-r--r--gl/m4/extensions.m4214
-rw-r--r--gl/m4/extern-inline.m496
-rw-r--r--gl/m4/fcntl-o.m422
-rw-r--r--gl/m4/fcntl.m4151
-rw-r--r--gl/m4/fcntl_h.m470
-rw-r--r--gl/m4/fflush.m4100
-rw-r--r--gl/m4/float_h.m454
-rw-r--r--gl/m4/floorf.m418
-rw-r--r--gl/m4/fopen.m4149
-rw-r--r--gl/m4/fpurge.m473
-rw-r--r--gl/m4/freading.m4 (renamed from gl/m4/sha1.m4)11
-rw-r--r--gl/m4/free.m452
-rw-r--r--gl/m4/fseek.m415
-rw-r--r--gl/m4/fseeko.m477
-rw-r--r--gl/m4/fstat.m440
-rw-r--r--gl/m4/fstypename.m42
-rw-r--r--gl/m4/fsusage.m4363
-rw-r--r--gl/m4/ftell.m415
-rw-r--r--gl/m4/ftello.m4151
-rw-r--r--gl/m4/getaddrinfo.m443
-rw-r--r--gl/m4/getdelim.m4111
-rw-r--r--gl/m4/getdtablesize.m463
-rw-r--r--gl/m4/gethostname.m48
-rw-r--r--gl/m4/getline.m4109
-rw-r--r--gl/m4/getloadavg.m417
-rw-r--r--gl/m4/getopt.m439
-rw-r--r--gl/m4/getprogname.m443
-rw-r--r--gl/m4/gettext.m4401
-rw-r--r--gl/m4/gl-openssl.m476
-rw-r--r--gl/m4/glibc2.m431
-rw-r--r--gl/m4/glibc21.m434
-rw-r--r--gl/m4/gnulib-cache.m444
-rw-r--r--gl/m4/gnulib-common.m41022
-rw-r--r--gl/m4/gnulib-comp.m4885
-rw-r--r--gl/m4/gnulib-tool.m410
-rw-r--r--gl/m4/hostent.m48
-rw-r--r--gl/m4/iconv.m4268
-rw-r--r--gl/m4/idpriv.m42
-rw-r--r--gl/m4/include_next.m490
-rw-r--r--gl/m4/inet_ntop.m416
-rw-r--r--gl/m4/intdiv0.m487
-rw-r--r--gl/m4/intl.m4271
-rw-r--r--gl/m4/intldir.m419
-rw-r--r--gl/m4/intlmacosx.m456
-rw-r--r--gl/m4/intmax.m436
-rw-r--r--gl/m4/intmax_t.m416
-rw-r--r--gl/m4/inttypes-pri.m442
-rw-r--r--gl/m4/inttypes.m4180
-rw-r--r--gl/m4/inttypes_h.m42
-rw-r--r--gl/m4/langinfo_h.m448
-rw-r--r--gl/m4/largefile.m4378
-rw-r--r--gl/m4/lcmessage.m435
-rw-r--r--gl/m4/lib-ld.m4119
-rw-r--r--gl/m4/lib-link.m4777
-rw-r--r--gl/m4/lib-prefix.m4224
-rw-r--r--gl/m4/limits-h.m441
-rw-r--r--gl/m4/localcharset.m410
-rw-r--r--gl/m4/locale-fr.m443
-rw-r--r--gl/m4/locale-ja.m445
-rw-r--r--gl/m4/locale-zh.m445
-rw-r--r--gl/m4/locale_h.m4134
-rw-r--r--gl/m4/localeconv.m42
-rw-r--r--gl/m4/lock.m411
-rw-r--r--gl/m4/longlong.m4113
-rw-r--r--gl/m4/ls-mntd-fs.m4357
-rw-r--r--gl/m4/lseek.m478
-rw-r--r--gl/m4/malloc.m4173
-rw-r--r--gl/m4/malloca.m45
-rw-r--r--gl/m4/math_h.m4560
-rw-r--r--gl/m4/mbrtowc.m4358
-rw-r--r--gl/m4/mbsinit.m415
-rw-r--r--gl/m4/mbstate_t.m413
-rw-r--r--gl/m4/mbtowc.m413
-rw-r--r--gl/m4/memchr.m474
-rw-r--r--gl/m4/minmax.m444
-rw-r--r--gl/m4/mktime.m4142
-rw-r--r--gl/m4/mmap-anon.m48
-rw-r--r--gl/m4/mode_t.m426
-rw-r--r--gl/m4/mountlist.m4331
-rw-r--r--gl/m4/msvc-inval.m42
-rw-r--r--gl/m4/msvc-nothrow.m42
-rw-r--r--gl/m4/multiarch.m469
-rw-r--r--gl/m4/netdb_h.m428
-rw-r--r--gl/m4/netinet_in_h.m410
-rw-r--r--gl/m4/nl_langinfo.m437
-rw-r--r--gl/m4/nls.m432
-rw-r--r--gl/m4/nocrash.m413
-rw-r--r--gl/m4/off_t.m42
-rw-r--r--gl/m4/onceonly.m4104
-rw-r--r--gl/m4/open-cloexec.m421
-rw-r--r--gl/m4/open-slash.m460
-rw-r--r--gl/m4/open.m456
-rw-r--r--gl/m4/pathmax.m442
-rw-r--r--gl/m4/pid_t.m438
-rw-r--r--gl/m4/po.m4453
-rw-r--r--gl/m4/printf-posix.m448
-rw-r--r--gl/m4/printf.m4490
-rw-r--r--gl/m4/progtest.m491
-rw-r--r--gl/m4/pthread_rwlock_rdlock.m4185
-rw-r--r--gl/m4/read.m426
-rw-r--r--gl/m4/realloc.m463
-rw-r--r--gl/m4/reallocarray.m423
-rw-r--r--gl/m4/regex.m4193
-rw-r--r--gl/m4/safe-read.m412
-rw-r--r--gl/m4/servent.m48
-rw-r--r--gl/m4/setenv.m476
-rw-r--r--gl/m4/setlocale_null.m498
-rw-r--r--gl/m4/sha256.m414
-rw-r--r--gl/m4/size_max.m416
-rw-r--r--gl/m4/snprintf.m412
-rw-r--r--gl/m4/socketlib.m438
-rw-r--r--gl/m4/sockets.m42
-rw-r--r--gl/m4/socklen.m417
-rw-r--r--gl/m4/sockpfaf.m423
-rw-r--r--gl/m4/ssize_t.m42
-rw-r--r--gl/m4/stat-time.m483
-rw-r--r--gl/m4/stat.m485
-rw-r--r--gl/m4/std-gnu11.m4829
-rw-r--r--gl/m4/stdalign.m4121
-rw-r--r--gl/m4/stdbool.m4100
-rw-r--r--gl/m4/stddef_h.m481
-rw-r--r--gl/m4/stdint.m4169
-rw-r--r--gl/m4/stdint_h.m42
-rw-r--r--gl/m4/stdio_h.m4229
-rw-r--r--gl/m4/stdlib_h.m4173
-rw-r--r--gl/m4/strcase.m48
-rw-r--r--gl/m4/strcasestr.m461
-rw-r--r--gl/m4/strerror.m430
-rw-r--r--gl/m4/string_h.m4150
-rw-r--r--gl/m4/strings_h.m440
-rw-r--r--gl/m4/strndup.m455
-rw-r--r--gl/m4/strnlen.m430
-rw-r--r--gl/m4/strsep.m46
-rw-r--r--gl/m4/strstr.m467
-rw-r--r--gl/m4/sys_socket_h.m488
-rw-r--r--gl/m4/sys_stat_h.m4129
-rw-r--r--gl/m4/sys_types_h.m450
-rw-r--r--gl/m4/sys_uio_h.m425
-rw-r--r--gl/m4/threadlib.m4667
-rw-r--r--gl/m4/time_h.m4114
-rw-r--r--gl/m4/time_r.m449
-rw-r--r--gl/m4/timegm.m410
-rw-r--r--gl/m4/uintmax_t.m430
-rw-r--r--gl/m4/ungetc.m473
-rw-r--r--gl/m4/unistd_h.m4348
-rw-r--r--gl/m4/unlocked-io.m436
-rw-r--r--gl/m4/vararrays.m472
-rw-r--r--gl/m4/vasnprintf.m417
-rw-r--r--gl/m4/vasprintf.m42
-rw-r--r--gl/m4/visibility.m479
-rw-r--r--gl/m4/vsnprintf.m412
-rw-r--r--gl/m4/warn-on-use.m461
-rw-r--r--gl/m4/wchar_h.m4222
-rw-r--r--gl/m4/wchar_t.m42
-rw-r--r--gl/m4/wcrtomb.m490
-rw-r--r--gl/m4/wctype_h.m499
-rw-r--r--gl/m4/wint_t.m449
-rw-r--r--gl/m4/xalloc.m42
-rw-r--r--gl/m4/xsize.m42
-rw-r--r--gl/m4/xstrndup.m415
-rw-r--r--gl/m4/zzgnulib.m423
185 files changed, 11045 insertions, 6899 deletions
diff --git a/gl/m4/00gnulib.m4 b/gl/m4/00gnulib.m4
index d4ad759f..7fe03e0b 100644
--- a/gl/m4/00gnulib.m4
+++ b/gl/m4/00gnulib.m4
@@ -1,27 +1,82 @@
1# 00gnulib.m4 serial 2 1# 00gnulib.m4 serial 8
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl This file must be named something that sorts before all other 7dnl This file must be named something that sorts before all other
8dnl gnulib-provided .m4 files. It is needed until such time as we can 8dnl gnulib-provided .m4 files. It is needed until the clang fix has
9dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE semantics. 9dnl been included in Autoconf.
10 10
11# AC_DEFUN_ONCE([NAME], VALUE) 11# The following definitions arrange to use a compiler option
12# ---------------------------- 12# -Werror=implicit-function-declaration in AC_CHECK_DECL, when the
13# Define NAME to expand to VALUE on the first use (whether by direct 13# compiler is clang. Without it, clang implicitly declares "known"
14# expansion, or by AC_REQUIRE), and to nothing on all subsequent uses. 14# library functions in C mode, but not in C++ mode, which would cause
15# Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier. This 15# Gnulib to omit a declaration and thus later produce an error in C++
16# definition is slower than the version in Autoconf 2.64, because it 16# mode. As of clang 9.0, these "known" functions are identified through
17# can only use interfaces that existed since 2.59; but it achieves the 17# LIBBUILTIN invocations in the LLVM source file
18# same effect. Quoting is necessary to avoid confusing Automake. 18# llvm/tools/clang/include/clang/Basic/Builtins.def.
19m4_version_prereq([2.63.263], [], 19# It's not possible to AC_REQUIRE the extra tests from AC_CHECK_DECL,
20[m4_define([AC][_DEFUN_ONCE], 20# because AC_CHECK_DECL, like other Autoconf built-ins, is not supposed
21 [AC][_DEFUN([$1], 21# to AC_REQUIRE anything: some configure.ac files have their first
22 [AC_REQUIRE([_gl_DEFUN_ONCE([$1])], 22# AC_CHECK_DECL executed conditionally. Therefore append the extra tests
23 [m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl 23# to AC_PROG_CC.
24[AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])]) 24AC_DEFUN([gl_COMPILER_CLANG],
25[
26dnl AC_REQUIRE([AC_PROG_CC])
27 AC_CACHE_CHECK([whether the compiler is clang],
28 [gl_cv_compiler_clang],
29 [dnl Use _AC_COMPILE_IFELSE instead of AC_EGREP_CPP, to avoid error
30 dnl "circular dependency of AC_LANG_COMPILER(C)" if AC_PROG_CC has
31 dnl not yet been invoked.
32 _AC_COMPILE_IFELSE(
33 [AC_LANG_PROGRAM([[
34 #ifdef __clang__
35 barfbarf
36 #endif
37 ]],[[]])
38 ],
39 [gl_cv_compiler_clang=no],
40 [gl_cv_compiler_clang=yes])
41 ])
42])
43AC_DEFUN([gl_COMPILER_PREPARE_CHECK_DECL],
44[
45dnl AC_REQUIRE([AC_PROG_CC])
46dnl AC_REQUIRE([gl_COMPILER_CLANG])
47 AC_CACHE_CHECK([for compiler option needed when checking for declarations],
48 [gl_cv_compiler_check_decl_option],
49 [if test $gl_cv_compiler_clang = yes; then
50 dnl Test whether the compiler supports the option
51 dnl '-Werror=implicit-function-declaration'.
52 save_ac_compile="$ac_compile"
53 ac_compile="$ac_compile -Werror=implicit-function-declaration"
54 dnl Use _AC_COMPILE_IFELSE instead of AC_COMPILE_IFELSE, to avoid a
55 dnl warning "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
56 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
57 [gl_cv_compiler_check_decl_option='-Werror=implicit-function-declaration'],
58 [gl_cv_compiler_check_decl_option=none])
59 ac_compile="$save_ac_compile"
60 else
61 gl_cv_compiler_check_decl_option=none
62 fi
63 ])
64 if test "x$gl_cv_compiler_check_decl_option" != xnone; then
65 ac_compile_for_check_decl="$ac_compile $gl_cv_compiler_check_decl_option"
66 else
67 ac_compile_for_check_decl="$ac_compile"
68 fi
69])
70dnl Redefine _AC_CHECK_DECL_BODY so that it references ac_compile_for_check_decl
71dnl instead of ac_compile. If, for whatever reason, the override of AC_PROG_CC
72dnl in zzgnulib.m4 is inactive, use the original ac_compile.
73m4_define([_AC_CHECK_DECL_BODY],
74[ ac_save_ac_compile="$ac_compile"
75 if test -n "$ac_compile_for_check_decl"; then
76 ac_compile="$ac_compile_for_check_decl"
77 fi]
78m4_defn([_AC_CHECK_DECL_BODY])[ ac_compile="$ac_save_ac_compile"
79])
25 80
26# gl_00GNULIB 81# gl_00GNULIB
27# ----------- 82# -----------
diff --git a/gl/m4/__inline.m4 b/gl/m4/__inline.m4
new file mode 100644
index 00000000..acf8668b
--- /dev/null
+++ b/gl/m4/__inline.m4
@@ -0,0 +1,22 @@
1# Test for __inline keyword
2dnl Copyright 2017-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl___INLINE],
8[
9 AC_CACHE_CHECK([whether the compiler supports the __inline keyword],
10 [gl_cv_c___inline],
11 [AC_COMPILE_IFELSE(
12 [AC_LANG_PROGRAM(
13 [[typedef int foo_t;
14 static __inline foo_t foo (void) { return 0; }]],
15 [[return foo ();]])],
16 [gl_cv_c___inline=yes],
17 [gl_cv_c___inline=no])])
18 if test $gl_cv_c___inline = yes; then
19 AC_DEFINE([HAVE___INLINE], [1],
20 [Define to 1 if the compiler supports the keyword '__inline'.])
21 fi
22])
diff --git a/gl/m4/absolute-header.m4 b/gl/m4/absolute-header.m4
new file mode 100644
index 00000000..e7947648
--- /dev/null
+++ b/gl/m4/absolute-header.m4
@@ -0,0 +1,100 @@
1# absolute-header.m4 serial 17
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Derek Price.
8
9# gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...)
10# ---------------------------------------
11# Find the absolute name of a header file, testing first if the header exists.
12# If the header were sys/inttypes.h, this macro would define
13# ABSOLUTE_SYS_INTTYPES_H to the '""' quoted absolute name of sys/inttypes.h
14# in config.h
15# (e.g. '#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"').
16# The three "///" are to pacify Sun C 5.8, which otherwise would say
17# "warning: #include of /usr/include/... may be non-portable".
18# Use '""', not '<>', so that the /// cannot be confused with a C99 comment.
19# Note: This macro assumes that the header file is not empty after
20# preprocessing, i.e. it does not only define preprocessor macros but also
21# provides some type/enum definitions or function/variable declarations.
22AC_DEFUN([gl_ABSOLUTE_HEADER],
23[AC_REQUIRE([AC_CANONICAL_HOST])
24AC_LANG_PREPROC_REQUIRE()dnl
25m4_foreach_w([gl_HEADER_NAME], [$1],
26 [AS_VAR_PUSHDEF([gl_absolute_header],
27 [gl_cv_absolute_]m4_defn([gl_HEADER_NAME]))dnl
28 AC_CACHE_CHECK([absolute name of <]m4_defn([gl_HEADER_NAME])[>],
29 [gl_absolute_header],
30 [AS_VAR_PUSHDEF([ac_header_exists],
31 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))dnl
32 AC_CHECK_HEADERS_ONCE(m4_defn([gl_HEADER_NAME]))dnl
33 if test AS_VAR_GET([ac_header_exists]) = yes; then
34 gl_ABSOLUTE_HEADER_ONE(m4_defn([gl_HEADER_NAME]))
35 fi
36 AS_VAR_POPDEF([ac_header_exists])dnl
37 ])dnl
38 AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_defn([gl_HEADER_NAME])),
39 ["AS_VAR_GET([gl_absolute_header])"],
40 [Define this to an absolute name of <]m4_defn([gl_HEADER_NAME])[>.])
41 AS_VAR_POPDEF([gl_absolute_header])dnl
42])dnl
43])# gl_ABSOLUTE_HEADER
44
45# gl_ABSOLUTE_HEADER_ONE(HEADER)
46# ------------------------------
47# Like gl_ABSOLUTE_HEADER, except that:
48# - it assumes that the header exists,
49# - it uses the current CPPFLAGS,
50# - it does not cache the result,
51# - it is silent.
52AC_DEFUN([gl_ABSOLUTE_HEADER_ONE],
53[
54 AC_REQUIRE([AC_CANONICAL_HOST])
55 AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote([$1])[[>]])])
56 dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
57 dnl that contain only a #include of other header files and no
58 dnl non-comment tokens of their own. This leads to a failure to
59 dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
60 dnl and others. The workaround is to force preservation of comments
61 dnl through option -C. This ensures all necessary #line directives
62 dnl are present. GCC supports option -C as well.
63 case "$host_os" in
64 aix*) gl_absname_cpp="$ac_cpp -C" ;;
65 *) gl_absname_cpp="$ac_cpp" ;;
66 esac
67changequote(,)
68 case "$host_os" in
69 mingw*)
70 dnl For the sake of native Windows compilers (excluding gcc),
71 dnl treat backslash as a directory separator, like /.
72 dnl Actually, these compilers use a double-backslash as
73 dnl directory separator, inside the
74 dnl # line "filename"
75 dnl directives.
76 gl_dirsep_regex='[/\\]'
77 ;;
78 *)
79 gl_dirsep_regex='\/'
80 ;;
81 esac
82 dnl A sed expression that turns a string into a basic regular
83 dnl expression, for use within "/.../".
84 gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
85 gl_header_literal_regex=`echo '$1' \
86 | sed -e "$gl_make_literal_regex_sed"`
87 gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
88 s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
89 s|^/[^/]|//&|
90 p
91 q
92 }'
93changequote([,])
94 dnl eval is necessary to expand gl_absname_cpp.
95 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
96 dnl so use subshell.
97 AS_VAR_SET([gl_cv_absolute_]AS_TR_SH([[$1]]),
98[`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
99 sed -n "$gl_absolute_header_sed"`])
100])
diff --git a/gl/m4/af_alg.m4 b/gl/m4/af_alg.m4
new file mode 100644
index 00000000..f4c0d624
--- /dev/null
+++ b/gl/m4/af_alg.m4
@@ -0,0 +1,57 @@
1# af_alg.m4 serial 6
2dnl Copyright 2018-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Matteo Croce.
8
9AC_DEFUN_ONCE([gl_AF_ALG],
10[
11 AC_REQUIRE([gl_SYS_SOCKET_H])
12 AC_REQUIRE([AC_C_INLINE])
13
14 dnl Check whether linux/if_alg.h has needed features.
15 AC_CACHE_CHECK([whether linux/if_alg.h has struct sockaddr_alg.],
16 [gl_cv_header_linux_if_alg_salg],
17 [AC_COMPILE_IFELSE(
18 [AC_LANG_PROGRAM([[#include <sys/socket.h>
19 #include <linux/if_alg.h>
20 struct sockaddr_alg salg = {
21 .salg_family = AF_ALG,
22 .salg_type = "hash",
23 .salg_name = "sha1",
24 };]])],
25 [gl_cv_header_linux_if_alg_salg=yes],
26 [gl_cv_header_linux_if_alg_salg=no])])
27 if test "$gl_cv_header_linux_if_alg_salg" = yes; then
28 AC_DEFINE([HAVE_LINUX_IF_ALG_H], [1],
29 [Define to 1 if you have 'struct sockaddr_alg' defined.])
30 fi
31
32 dnl The default is to not use AF_ALG if available,
33 dnl as it's system dependent as to whether the kernel
34 dnl routines are faster than libcrypto for example.
35 use_af_alg=no
36 AC_ARG_WITH([linux-crypto],
37 [AS_HELP_STRING([[--with-linux-crypto]],
38 [use Linux kernel cryptographic API (if available) for the hash functions
39 MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512 on files])],
40 [use_af_alg=$withval],
41 [use_af_alg=no])
42 dnl We cannot use it if it is not available.
43 if test "$gl_cv_header_linux_if_alg_salg" != yes; then
44 if test "$use_af_alg" != no; then
45 AC_MSG_WARN([Linux kernel cryptographic API not found])
46 fi
47 use_af_alg=no
48 fi
49
50 if test "$use_af_alg" != no; then
51 USE_AF_ALG=1
52 else
53 USE_AF_ALG=0
54 fi
55 AC_DEFINE_UNQUOTED([USE_LINUX_CRYPTO_API], [$USE_AF_ALG],
56 [Define to 1 if you want to use the Linux kernel cryptographic API.])
57])
diff --git a/gl/m4/alloca.m4 b/gl/m4/alloca.m4
index 270abd0c..c685fac9 100644
--- a/gl/m4/alloca.m4
+++ b/gl/m4/alloca.m4
@@ -1,5 +1,5 @@
1# alloca.m4 serial 14 1# alloca.m4 serial 21
2dnl Copyright (C) 2002-2004, 2006-2007, 2009-2013 Free Software Foundation, 2dnl Copyright (C) 2002-2004, 2006-2007, 2009-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -26,30 +26,35 @@ AC_DEFUN([gl_FUNC_ALLOCA],
26 AC_DEFINE([HAVE_ALLOCA], [1], 26 AC_DEFINE([HAVE_ALLOCA], [1],
27 [Define to 1 if you have 'alloca' after including <alloca.h>, 27 [Define to 1 if you have 'alloca' after including <alloca.h>,
28 a header that may be supplied by this distribution.]) 28 a header that may be supplied by this distribution.])
29 ALLOCA_H=alloca.h 29 GL_GENERATE_ALLOCA_H=true
30 else 30 else
31 dnl alloca exists as a library function, i.e. it is slow and probably 31 dnl alloca exists as a library function, i.e. it is slow and probably
32 dnl a memory leak. Don't define HAVE_ALLOCA in this case. 32 dnl a memory leak. Don't define HAVE_ALLOCA in this case.
33 ALLOCA_H= 33 GL_GENERATE_ALLOCA_H=false
34 fi 34 fi
35 else 35 else
36 ALLOCA_H=alloca.h 36 GL_GENERATE_ALLOCA_H=true
37 fi 37 fi
38 AC_SUBST([ALLOCA_H]) 38
39 AM_CONDITIONAL([GL_GENERATE_ALLOCA_H], [test -n "$ALLOCA_H"]) 39 if test $ac_cv_working_alloca_h = yes; then
40 HAVE_ALLOCA_H=1
41 else
42 HAVE_ALLOCA_H=0
43 fi
44 AC_SUBST([HAVE_ALLOCA_H])
40]) 45])
41 46
42# Prerequisites of lib/alloca.c. 47# Prerequisites of lib/alloca.c.
43# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA. 48# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA.
44AC_DEFUN([gl_PREREQ_ALLOCA], [:]) 49AC_DEFUN([gl_PREREQ_ALLOCA], [:])
45 50
46# This works around a bug in autoconf <= 2.68. 51m4_version_prereq([2.70], [], [
47# See <http://lists.gnu.org/archive/html/bug-gnulib/2011-06/msg00277.html>.
48 52
49m4_version_prereq([2.69], [] ,[ 53# This works around a bug in autoconf <= 2.68 and has simplifications
50 54# from 2.70. See:
51# This is taken from the following Autoconf patch: 55# https://lists.gnu.org/r/bug-gnulib/2011-06/msg00277.html
52# http://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=6cd9f12520b0d6f76d3230d7565feba1ecf29497 56# https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=6cd9f12520b0d6f76d3230d7565feba1ecf29497
57# https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=15edf7fd8094fd14a89d9891dd72a9624762597a
53 58
54# _AC_LIBOBJ_ALLOCA 59# _AC_LIBOBJ_ALLOCA
55# ----------------- 60# -----------------
@@ -65,26 +70,6 @@ AC_LIBSOURCES(alloca.c)
65AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl 70AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl
66AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using 'alloca.c'.]) 71AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using 'alloca.c'.])
67 72
68AC_CACHE_CHECK(whether 'alloca.c' needs Cray hooks, ac_cv_os_cray,
69[AC_EGREP_CPP(webecray,
70[#if defined CRAY && ! defined CRAY2
71webecray
72#else
73wenotbecray
74#endif
75], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
76if test $ac_cv_os_cray = yes; then
77 for ac_func in _getb67 GETB67 getb67; do
78 AC_CHECK_FUNC($ac_func,
79 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
80 [Define to one of '_getb67', 'GETB67',
81 'getb67' for Cray-2 and Cray-YMP
82 systems. This function is required for
83 'alloca.c' support on those systems.])
84 break])
85 done
86fi
87
88AC_CACHE_CHECK([stack direction for C alloca], 73AC_CACHE_CHECK([stack direction for C alloca],
89 [ac_cv_c_stack_direction], 74 [ac_cv_c_stack_direction],
90[AC_RUN_IFELSE([AC_LANG_SOURCE( 75[AC_RUN_IFELSE([AC_LANG_SOURCE(
@@ -115,7 +100,7 @@ AH_VERBATIM([STACK_DIRECTION],
115 STACK_DIRECTION > 0 => grows toward higher addresses 100 STACK_DIRECTION > 0 => grows toward higher addresses
116 STACK_DIRECTION < 0 => grows toward lower addresses 101 STACK_DIRECTION < 0 => grows toward lower addresses
117 STACK_DIRECTION = 0 => direction of growth unknown */ 102 STACK_DIRECTION = 0 => direction of growth unknown */
118@%:@undef STACK_DIRECTION])dnl 103#undef STACK_DIRECTION])dnl
119AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction) 104AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
120])# _AC_LIBOBJ_ALLOCA 105])# _AC_LIBOBJ_ALLOCA
121]) 106])
diff --git a/gl/m4/arpa_inet_h.m4 b/gl/m4/arpa_inet_h.m4
index ea69af57..fa5fe831 100644
--- a/gl/m4/arpa_inet_h.m4
+++ b/gl/m4/arpa_inet_h.m4
@@ -1,15 +1,15 @@
1# arpa_inet_h.m4 serial 13 1# arpa_inet_h.m4 serial 17
2dnl Copyright (C) 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl Written by Simon Josefsson and Bruno Haible 7dnl Written by Simon Josefsson and Bruno Haible
8 8
9AC_DEFUN([gl_HEADER_ARPA_INET], 9AC_DEFUN_ONCE([gl_ARPA_INET_H],
10[ 10[
11 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 11 dnl Ensure to expand the default settings once only, before all statements
12 dnl once only, before all statements that occur in other macros. 12 dnl that occur in other macros.
13 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) 13 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
14 14
15 AC_CHECK_HEADERS_ONCE([arpa/inet.h]) 15 AC_CHECK_HEADERS_ONCE([arpa/inet.h])
@@ -24,6 +24,8 @@ AC_DEFUN([gl_HEADER_ARPA_INET],
24 24
25 AC_REQUIRE([gl_FEATURES_H]) 25 AC_REQUIRE([gl_FEATURES_H])
26 26
27 gl_PREREQ_SYS_H_WS2TCPIP
28
27 dnl Check for declarations of anything we want to poison if the 29 dnl Check for declarations of anything we want to poison if the
28 dnl corresponding gnulib module is not in use. 30 dnl corresponding gnulib module is not in use.
29 gl_WARN_ON_USE_PREPARE([[ 31 gl_WARN_ON_USE_PREPARE([[
@@ -38,17 +40,32 @@ AC_DEFUN([gl_HEADER_ARPA_INET],
38 ]], [inet_ntop inet_pton]) 40 ]], [inet_ntop inet_pton])
39]) 41])
40 42
43# gl_ARPA_INET_MODULE_INDICATOR([modulename])
44# sets the shell variable that indicates the presence of the given module
45# to a C preprocessor expression that will evaluate to 1.
46# This macro invocation must not occur in macros that are AC_REQUIREd.
41AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR], 47AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR],
42[ 48[
43 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 49 dnl Ensure to expand the default settings once only.
44 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) 50 gl_ARPA_INET_H_REQUIRE_DEFAULTS
45 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 51 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
46]) 52])
47 53
54# Initializes the default values for AC_SUBSTed shell variables.
55# This macro must not be AC_REQUIREd. It must only be invoked, and only
56# outside of macros or in macros that are not AC_REQUIREd.
57AC_DEFUN([gl_ARPA_INET_H_REQUIRE_DEFAULTS],
58[
59 m4_defun(GL_MODULE_INDICATOR_PREFIX[_ARPA_INET_H_MODULE_INDICATOR_DEFAULTS], [
60 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_INET_NTOP])
61 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_INET_PTON])
62 ])
63 m4_require(GL_MODULE_INDICATOR_PREFIX[_ARPA_INET_H_MODULE_INDICATOR_DEFAULTS])
64 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
65])
66
48AC_DEFUN([gl_ARPA_INET_H_DEFAULTS], 67AC_DEFUN([gl_ARPA_INET_H_DEFAULTS],
49[ 68[
50 GNULIB_INET_NTOP=0; AC_SUBST([GNULIB_INET_NTOP])
51 GNULIB_INET_PTON=0; AC_SUBST([GNULIB_INET_PTON])
52 dnl Assume proper GNU behavior unless another module says otherwise. 69 dnl Assume proper GNU behavior unless another module says otherwise.
53 HAVE_DECL_INET_NTOP=1; AC_SUBST([HAVE_DECL_INET_NTOP]) 70 HAVE_DECL_INET_NTOP=1; AC_SUBST([HAVE_DECL_INET_NTOP])
54 HAVE_DECL_INET_PTON=1; AC_SUBST([HAVE_DECL_INET_PTON]) 71 HAVE_DECL_INET_PTON=1; AC_SUBST([HAVE_DECL_INET_PTON])
diff --git a/gl/m4/assert_h.m4 b/gl/m4/assert_h.m4
new file mode 100644
index 00000000..abba4fa3
--- /dev/null
+++ b/gl/m4/assert_h.m4
@@ -0,0 +1,67 @@
1# assert-h.m4
2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Paul Eggert.
8
9AC_DEFUN([gl_ASSERT_H],
10[
11 AC_CACHE_CHECK([for static_assert], [gl_cv_static_assert],
12 [gl_save_CFLAGS=$CFLAGS
13 for gl_working in "yes, a keyword" "yes, an <assert.h> macro"; do
14 AS_CASE([$gl_working],
15 [*assert.h*], [CFLAGS="$gl_save_CFLAGS -DINCLUDE_ASSERT_H"])
16
17 AC_COMPILE_IFELSE(
18 [AC_LANG_PROGRAM(
19 [[#if defined __clang__ && __STDC_VERSION__ < 202311
20 #pragma clang diagnostic error "-Wc2x-extensions"
21 #pragma clang diagnostic error "-Wc++17-extensions"
22 #endif
23 #ifdef INCLUDE_ASSERT_H
24 #include <assert.h>
25 #endif
26 static_assert (2 + 2 == 4, "arithmetic does not work");
27 static_assert (2 + 2 == 4);
28 ]],
29 [[
30 static_assert (sizeof (char) == 1, "sizeof does not work");
31 static_assert (sizeof (char) == 1);
32 ]])],
33 [gl_cv_static_assert=$gl_working],
34 [gl_cv_static_assert=no])
35 CFLAGS=$gl_save_CFLAGS
36 test "$gl_cv_static_assert" != no && break
37 done])
38
39 GL_GENERATE_ASSERT_H=false
40 AS_CASE([$gl_cv_static_assert],
41 [yes*keyword*],
42 [AC_DEFINE([HAVE_C_STATIC_ASSERT], [1],
43 [Define to 1 if the static_assert keyword works.])],
44 [no],
45 [GL_GENERATE_ASSERT_H=true
46 gl_NEXT_HEADERS([assert.h])])
47
48 dnl The "zz" puts this toward config.h's end, to avoid potential
49 dnl collisions with other definitions. #undef assert so that
50 dnl programs are not tempted to use it without specifically
51 dnl including assert.h. Break the #undef apart with a comment
52 dnl so that 'configure' does not comment it out.
53 AH_VERBATIM([zzstatic_assert],
54[#if (!defined HAVE_C_STATIC_ASSERT && !defined assert \
55 && (!defined __cplusplus \
56 || (__cpp_static_assert < 201411 \
57 && __GNUG__ < 6 && __clang_major__ < 6)))
58 #include <assert.h>
59 #undef/**/assert
60 /* Solaris 11.4 <assert.h> defines static_assert as a macro with 2 arguments.
61 We need it also to be invocable with a single argument. */
62 #if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus
63 #undef/**/static_assert
64 #define static_assert _Static_assert
65 #endif
66#endif])
67])
diff --git a/gl/m4/base64.m4 b/gl/m4/base64.m4
index fc19893e..987930ab 100644
--- a/gl/m4/base64.m4
+++ b/gl/m4/base64.m4
@@ -1,5 +1,5 @@
1# base64.m4 serial 4 1# base64.m4 serial 4
2dnl Copyright (C) 2004, 2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2004, 2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/btowc.m4 b/gl/m4/btowc.m4
index 978a06e9..77218a7d 100644
--- a/gl/m4/btowc.m4
+++ b/gl/m4/btowc.m4
@@ -1,5 +1,5 @@
1# btowc.m4 serial 10 1# btowc.m4 serial 12
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -10,7 +10,7 @@ AC_DEFUN([gl_FUNC_BTOWC],
10 10
11 dnl Check whether <wchar.h> is usable at all, first. Otherwise the test 11 dnl Check whether <wchar.h> is usable at all, first. Otherwise the test
12 dnl program below may lead to an endless loop. See 12 dnl program below may lead to an endless loop. See
13 dnl <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. 13 dnl <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>.
14 AC_REQUIRE([gl_WCHAR_H_INLINE_OK]) 14 AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
15 15
16 AC_CHECK_FUNCS_ONCE([btowc]) 16 AC_CHECK_FUNCS_ONCE([btowc])
@@ -28,14 +28,6 @@ AC_DEFUN([gl_FUNC_BTOWC],
28 [ 28 [
29 AC_RUN_IFELSE( 29 AC_RUN_IFELSE(
30 [AC_LANG_SOURCE([[ 30 [AC_LANG_SOURCE([[
31#include <string.h>
32/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
33 <wchar.h>.
34 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
35 included before <wchar.h>. */
36#include <stddef.h>
37#include <stdio.h>
38#include <time.h>
39#include <wchar.h> 31#include <wchar.h>
40int main () 32int main ()
41{ 33{
@@ -50,6 +42,8 @@ changequote(,)dnl
50 case "$host_os" in 42 case "$host_os" in
51 # Guess no on Cygwin. 43 # Guess no on Cygwin.
52 cygwin*) gl_cv_func_btowc_nul="guessing no" ;; 44 cygwin*) gl_cv_func_btowc_nul="guessing no" ;;
45 # Guess yes on native Windows.
46 mingw*) gl_cv_func_btowc_nul="guessing yes" ;;
53 # Guess yes otherwise. 47 # Guess yes otherwise.
54 *) gl_cv_func_btowc_nul="guessing yes" ;; 48 *) gl_cv_func_btowc_nul="guessing yes" ;;
55 esac 49 esac
@@ -65,24 +59,19 @@ changequote([,])dnl
65 dnl is present. 59 dnl is present.
66changequote(,)dnl 60changequote(,)dnl
67 case "$host_os" in 61 case "$host_os" in
68 # Guess no on IRIX. 62 # Guess no on IRIX.
69 irix*) gl_cv_func_btowc_eof="guessing no" ;; 63 irix*) gl_cv_func_btowc_eof="guessing no" ;;
70 # Guess yes otherwise. 64 # Guess yes on native Windows.
71 *) gl_cv_func_btowc_eof="guessing yes" ;; 65 mingw*) gl_cv_func_btowc_eof="guessing yes" ;;
66 # Guess yes otherwise.
67 *) gl_cv_func_btowc_eof="guessing yes" ;;
72 esac 68 esac
73changequote([,])dnl 69changequote([,])dnl
74 if test $LOCALE_FR != none; then 70 if test $LOCALE_FR != none; then
75 AC_RUN_IFELSE( 71 AC_RUN_IFELSE(
76 [AC_LANG_SOURCE([[ 72 [AC_LANG_SOURCE([[
77#include <locale.h> 73#include <locale.h>
78#include <string.h>
79/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
80 <wchar.h>.
81 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
82 included before <wchar.h>. */
83#include <stddef.h>
84#include <stdio.h> 74#include <stdio.h>
85#include <time.h>
86#include <wchar.h> 75#include <wchar.h>
87int main () 76int main ()
88{ 77{
diff --git a/gl/m4/builtin-expect.m4 b/gl/m4/builtin-expect.m4
new file mode 100644
index 00000000..531ed48a
--- /dev/null
+++ b/gl/m4/builtin-expect.m4
@@ -0,0 +1,49 @@
1dnl Check for __builtin_expect.
2
3dnl Copyright 2016-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl Written by Paul Eggert.
9
10AC_DEFUN([gl___BUILTIN_EXPECT],
11[
12 AC_CACHE_CHECK([for __builtin_expect],
13 [gl_cv___builtin_expect],
14 [AC_LINK_IFELSE(
15 [AC_LANG_SOURCE([[
16 int
17 main (int argc, char **argv)
18 {
19 argc = __builtin_expect (argc, 100);
20 return argv[argc != 100][0];
21 }]])],
22 [gl_cv___builtin_expect=yes],
23 [AC_LINK_IFELSE(
24 [AC_LANG_SOURCE([[
25 #include <builtins.h>
26 int
27 main (int argc, char **argv)
28 {
29 argc = __builtin_expect (argc, 100);
30 return argv[argc != 100][0];
31 }]])],
32 [gl_cv___builtin_expect="in <builtins.h>"],
33 [gl_cv___builtin_expect=no])])])
34 if test "$gl_cv___builtin_expect" = yes; then
35 AC_DEFINE([HAVE___BUILTIN_EXPECT], [1])
36 elif test "$gl_cv___builtin_expect" = "in <builtins.h>"; then
37 AC_DEFINE([HAVE___BUILTIN_EXPECT], [2])
38 fi
39 AH_VERBATIM([HAVE___BUILTIN_EXPECT],
40 [/* Define to 1 if the compiler supports __builtin_expect,
41 and to 2 if <builtins.h> does. */
42#undef HAVE___BUILTIN_EXPECT
43#ifndef HAVE___BUILTIN_EXPECT
44# define __builtin_expect(e, c) (e)
45#elif HAVE___BUILTIN_EXPECT == 2
46# include <builtins.h>
47#endif
48 ])
49])
diff --git a/gl/m4/byteswap.m4 b/gl/m4/byteswap.m4
new file mode 100644
index 00000000..8058d178
--- /dev/null
+++ b/gl/m4/byteswap.m4
@@ -0,0 +1,17 @@
1# byteswap.m4 serial 5
2dnl Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Written by Oskar Liljeblad.
8
9AC_DEFUN([gl_BYTESWAP],
10[
11 dnl Prerequisites of lib/byteswap.in.h.
12 AC_CHECK_HEADERS([byteswap.h], [
13 GL_GENERATE_BYTESWAP_H=false
14 ], [
15 GL_GENERATE_BYTESWAP_H=true
16 ])
17])
diff --git a/gl/m4/c-bool.m4 b/gl/m4/c-bool.m4
new file mode 100644
index 00000000..f614371b
--- /dev/null
+++ b/gl/m4/c-bool.m4
@@ -0,0 +1,51 @@
1# Check for bool that conforms to C2023.
2
3dnl Copyright 2022-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_C_BOOL],
9[
10 AC_CACHE_CHECK([for bool, true, false], [gl_cv_c_bool],
11 [AC_COMPILE_IFELSE(
12 [AC_LANG_SOURCE([[
13 #if true == false
14 #error "true == false"
15 #endif
16 extern bool b;
17 bool b = true == false;]])],
18 [gl_cv_c_bool=yes],
19 [gl_cv_c_bool=no])])
20 if test "$gl_cv_c_bool" = yes; then
21 AC_DEFINE([HAVE_C_BOOL], [1],
22 [Define to 1 if bool, true and false work as per C2023.])
23 fi
24
25 AC_CHECK_HEADERS_ONCE([stdbool.h])
26
27 dnl The "zz" puts this toward config.h's end, to avoid potential
28 dnl collisions with other definitions.
29 dnl If 'bool', 'true' and 'false' do not work, arrange for them to work.
30 dnl In C, this means including <stdbool.h> if it is not already included.
31 dnl However, if the preprocessor mistakenly treats 'true' as 0,
32 dnl define it to a bool expression equal to 1; this is needed in
33 dnl Sun C++ 5.11 (Oracle Solaris Studio 12.2, 2010) and older.
34 AH_VERBATIM([zzbool],
35[#ifndef HAVE_C_BOOL
36# if !defined __cplusplus && !defined __bool_true_false_are_defined
37# if HAVE_STDBOOL_H
38# include <stdbool.h>
39# else
40# if defined __SUNPRO_C
41# error "<stdbool.h> is not usable with this configuration. To make it usable, add -D_STDC_C99= to $CC."
42# else
43# error "<stdbool.h> does not exist on this platform. Use gnulib module 'stdbool-c99' instead of gnulib module 'stdbool'."
44# endif
45# endif
46# endif
47# if !true
48# define true (!false)
49# endif
50#endif])
51])
diff --git a/gl/m4/calloc.m4 b/gl/m4/calloc.m4
new file mode 100644
index 00000000..23c0dd9f
--- /dev/null
+++ b/gl/m4/calloc.m4
@@ -0,0 +1,83 @@
1# calloc.m4 serial 29
2
3# Copyright (C) 2004-2023 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved.
7
8# Written by Jim Meyering.
9
10# Determine whether calloc (N, S) returns non-NULL when N*S is zero,
11# and returns NULL when N*S overflows.
12# If so, define HAVE_CALLOC. Otherwise, define calloc to rpl_calloc
13# and arrange to use a calloc wrapper function that does work in that case.
14
15# _AC_FUNC_CALLOC_IF([IF-WORKS], [IF-NOT])
16# -------------------------------------
17# If calloc is compatible with GNU calloc, run IF-WORKS, otherwise, IF-NOT.
18AC_DEFUN([_AC_FUNC_CALLOC_IF],
19[
20 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
21 AC_CACHE_CHECK([whether calloc (0, n) and calloc (n, 0) return nonnull],
22 [ac_cv_func_calloc_0_nonnull],
23 [if test $cross_compiling != yes; then
24 ac_cv_func_calloc_0_nonnull=yes
25 AC_RUN_IFELSE(
26 [AC_LANG_PROGRAM(
27 [AC_INCLUDES_DEFAULT],
28 [[int result = 0;
29 char * volatile p = calloc (0, 0);
30 if (!p)
31 result |= 1;
32 free (p);
33 return result;
34 ]])],
35 [],
36 [ac_cv_func_calloc_0_nonnull=no])
37 else
38 case "$host_os" in
39 # Guess yes on glibc systems.
40 *-gnu* | gnu*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
41 # Guess yes on musl systems.
42 *-musl*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
43 # Guess yes on native Windows.
44 mingw*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
45 # If we don't know, obey --enable-cross-guesses.
46 *) ac_cv_func_calloc_0_nonnull="$gl_cross_guess_normal" ;;
47 esac
48 fi
49 ])
50 AS_CASE([$ac_cv_func_calloc_0_nonnull], [*yes], [$1], [$2])
51])
52
53
54# gl_FUNC_CALLOC_GNU
55# ------------------
56# Replace calloc if it is not compatible with GNU libc.
57AC_DEFUN([gl_FUNC_CALLOC_GNU],
58[
59 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
60 AC_REQUIRE([gl_FUNC_CALLOC_POSIX])
61 REPLACE_CALLOC_FOR_CALLOC_GNU="$REPLACE_CALLOC_FOR_CALLOC_POSIX"
62 if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 0; then
63 _AC_FUNC_CALLOC_IF([], [REPLACE_CALLOC_FOR_CALLOC_GNU=1])
64 fi
65])# gl_FUNC_CALLOC_GNU
66
67# gl_FUNC_CALLOC_POSIX
68# --------------------
69# Test whether 'calloc' is POSIX compliant (sets errno to ENOMEM when it
70# fails, and doesn't mess up with ptrdiff_t or size_t overflow),
71# and replace calloc if it is not.
72AC_DEFUN([gl_FUNC_CALLOC_POSIX],
73[
74 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
75 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
76 if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
77 REPLACE_CALLOC_FOR_CALLOC_POSIX=1
78 fi
79 dnl Although in theory we should also test for size_t overflow,
80 dnl in practice testing for ptrdiff_t overflow suffices
81 dnl since PTRDIFF_MAX <= SIZE_MAX on all known Gnulib porting targets.
82 dnl A separate size_t test would slow down 'configure'.
83])
diff --git a/gl/m4/close.m4 b/gl/m4/close.m4
new file mode 100644
index 00000000..9f95c670
--- /dev/null
+++ b/gl/m4/close.m4
@@ -0,0 +1,35 @@
1# close.m4 serial 9
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_CLOSE],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 m4_ifdef([gl_MSVC_INVAL], [
11 AC_REQUIRE([gl_MSVC_INVAL])
12 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
13 REPLACE_CLOSE=1
14 fi
15 ])
16 m4_ifdef([gl_PREREQ_SYS_H_WINSOCK2], [
17 gl_PREREQ_SYS_H_WINSOCK2
18 if test $UNISTD_H_HAVE_WINSOCK2_H = 1; then
19 dnl Even if the 'socket' module is not used here, another part of the
20 dnl application may use it and pass file descriptors that refer to
21 dnl sockets to the close() function. So enable the support for sockets.
22 REPLACE_CLOSE=1
23 fi
24 ])
25 dnl Replace close() for supporting the gnulib-defined fchdir() function,
26 dnl to keep fchdir's bookkeeping up-to-date.
27 m4_ifdef([gl_FUNC_FCHDIR], [
28 if test $REPLACE_CLOSE = 0; then
29 gl_TEST_FCHDIR
30 if test $HAVE_FCHDIR = 0; then
31 REPLACE_CLOSE=1
32 fi
33 fi
34 ])
35])
diff --git a/gl/m4/codeset.m4 b/gl/m4/codeset.m4
index c2761be2..5804f472 100644
--- a/gl/m4/codeset.m4
+++ b/gl/m4/codeset.m4
@@ -1,5 +1,6 @@
1# codeset.m4 serial 5 (gettext-0.18.2) 1# codeset.m4 serial 5 (gettext-0.18.2)
2dnl Copyright (C) 2000-2002, 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2006, 2008-2014, 2016, 2019-2023 Free Software
3dnl Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/configmake.m4 b/gl/m4/configmake.m4
deleted file mode 100644
index 823ffc0d..00000000
--- a/gl/m4/configmake.m4
+++ /dev/null
@@ -1,50 +0,0 @@
1# configmake.m4 serial 1
2dnl Copyright (C) 2010-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# gl_CONFIGMAKE_PREP
8# ------------------
9# Guarantee all of the standard directory variables, even when used with
10# autoconf 2.59 (datarootdir wasn't supported until 2.59c) or automake
11# 1.9.6 (pkglibexecdir wasn't supported until 1.10b.).
12AC_DEFUN([gl_CONFIGMAKE_PREP],
13[
14 dnl Technically, datadir should default to datarootdir. But if
15 dnl autoconf is too old to provide datarootdir, then reversing the
16 dnl definition is a reasonable compromise. Only AC_SUBST a variable
17 dnl if it was not already defined earlier by autoconf.
18 if test "x$datarootdir" = x; then
19 AC_SUBST([datarootdir], ['${datadir}'])
20 fi
21 dnl Copy the approach used in autoconf 2.60.
22 if test "x$docdir" = x; then
23 AC_SUBST([docdir], [m4_ifset([AC_PACKAGE_TARNAME],
24 ['${datarootdir}/doc/${PACKAGE_TARNAME}'],
25 ['${datarootdir}/doc/${PACKAGE}'])])
26 fi
27 dnl The remaining variables missing from autoconf 2.59 are easier.
28 if test "x$htmldir" = x; then
29 AC_SUBST([htmldir], ['${docdir}'])
30 fi
31 if test "x$dvidir" = x; then
32 AC_SUBST([dvidir], ['${docdir}'])
33 fi
34 if test "x$pdfdir" = x; then
35 AC_SUBST([pdfdir], ['${docdir}'])
36 fi
37 if test "x$psdir" = x; then
38 AC_SUBST([psdir], ['${docdir}'])
39 fi
40 if test "x$lispdir" = x; then
41 AC_SUBST([lispdir], ['${datarootdir}/emacs/site-lisp'])
42 fi
43 if test "x$localedir" = x; then
44 AC_SUBST([localedir], ['${datarootdir}/locale'])
45 fi
46
47 dnl Automake 1.9.6 only lacks pkglibexecdir; and since 1.11 merely
48 dnl provides it without AC_SUBST, this blind use of AC_SUBST is safe.
49 AC_SUBST([pkglibexecdir], ['${libexecdir}/${PACKAGE}'])
50])
diff --git a/gl/m4/dirname.m4 b/gl/m4/dirname.m4
deleted file mode 100644
index 5897a2a8..00000000
--- a/gl/m4/dirname.m4
+++ /dev/null
@@ -1,19 +0,0 @@
1#serial 10 -*- autoconf -*-
2dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_DIRNAME],
8[
9 AC_REQUIRE([gl_DIRNAME_LGPL])
10])
11
12AC_DEFUN([gl_DIRNAME_LGPL],
13[
14 dnl Prerequisites of lib/dirname.h.
15 AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
16
17 dnl No prerequisites of lib/basename-lgpl.c, lib/dirname-lgpl.c,
18 dnl lib/stripslash.c.
19])
diff --git a/gl/m4/double-slash-root.m4 b/gl/m4/double-slash-root.m4
index bd6f8671..1776e5eb 100644
--- a/gl/m4/double-slash-root.m4
+++ b/gl/m4/double-slash-root.m4
@@ -1,5 +1,5 @@
1# double-slash-root.m4 serial 4 -*- Autoconf -*- 1# double-slash-root.m4 serial 4 -*- Autoconf -*-
2dnl Copyright (C) 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/dup2.m4 b/gl/m4/dup2.m4
new file mode 100644
index 00000000..e1cc73e1
--- /dev/null
+++ b/gl/m4/dup2.m4
@@ -0,0 +1,105 @@
1#serial 27
2dnl Copyright (C) 2002, 2005, 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_DUP2],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works],
12 [AC_RUN_IFELSE([
13 AC_LANG_PROGRAM(
14 [[#include <errno.h>
15 #include <fcntl.h>
16 #include <limits.h>
17 #include <sys/resource.h>
18 #include <unistd.h>
19 ]GL_MDA_DEFINES[
20 #ifndef RLIM_SAVED_CUR
21 # define RLIM_SAVED_CUR RLIM_INFINITY
22 #endif
23 #ifndef RLIM_SAVED_MAX
24 # define RLIM_SAVED_MAX RLIM_INFINITY
25 #endif
26 ]],
27 [[int result = 0;
28 int bad_fd = INT_MAX;
29 struct rlimit rlim;
30 if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
31 && 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX
32 && rlim.rlim_cur != RLIM_INFINITY
33 && rlim.rlim_cur != RLIM_SAVED_MAX
34 && rlim.rlim_cur != RLIM_SAVED_CUR)
35 bad_fd = rlim.rlim_cur;
36 #ifdef FD_CLOEXEC
37 if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
38 result |= 1;
39 #endif
40 if (dup2 (1, 1) != 1)
41 result |= 2;
42 #ifdef FD_CLOEXEC
43 if (fcntl (1, F_GETFD) != FD_CLOEXEC)
44 result |= 4;
45 #endif
46 close (0);
47 if (dup2 (0, 0) != -1)
48 result |= 8;
49 /* Many gnulib modules require POSIX conformance of EBADF. */
50 if (dup2 (2, bad_fd) == -1 && errno != EBADF)
51 result |= 16;
52 /* Flush out some cygwin core dumps. */
53 if (dup2 (2, -1) != -1 || errno != EBADF)
54 result |= 32;
55 dup2 (2, 255);
56 dup2 (2, 256);
57 /* On OS/2 kLIBC, dup2() does not work on a directory fd. */
58 {
59 int fd = open (".", O_RDONLY);
60 if (fd == -1)
61 result |= 64;
62 else if (dup2 (fd, fd + 1) == -1)
63 result |= 128;
64 close (fd);
65 }
66 return result;]])
67 ],
68 [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
69 [case "$host_os" in
70 mingw*) # on this platform, dup2 always returns 0 for success
71 gl_cv_func_dup2_works="guessing no" ;;
72 cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
73 gl_cv_func_dup2_works="guessing no" ;;
74 aix* | freebsd*)
75 # on AIX 7.1 and FreeBSD 6.1, dup2 (1,toobig) gives EMFILE,
76 # not EBADF.
77 gl_cv_func_dup2_works="guessing no" ;;
78 haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC.
79 gl_cv_func_dup2_works="guessing no" ;;
80 *-android*) # implemented using dup3(), which fails if oldfd == newfd
81 gl_cv_func_dup2_works="guessing no" ;;
82 os2*) # on OS/2 kLIBC, dup2() does not work on a directory fd.
83 gl_cv_func_dup2_works="guessing no" ;;
84 *) gl_cv_func_dup2_works="guessing yes" ;;
85 esac])
86 ])
87 case "$gl_cv_func_dup2_works" in
88 *yes) ;;
89 *)
90 REPLACE_DUP2=1
91 AC_CHECK_FUNCS([setdtablesize])
92 ;;
93 esac
94 dnl Replace dup2() for supporting the gnulib-defined fchdir() function,
95 dnl to keep fchdir's bookkeeping up-to-date.
96 m4_ifdef([gl_FUNC_FCHDIR], [
97 gl_TEST_FCHDIR
98 if test $HAVE_FCHDIR = 0; then
99 REPLACE_DUP2=1
100 fi
101 ])
102])
103
104# Prerequisites of lib/dup2.c.
105AC_DEFUN([gl_PREREQ_DUP2], [])
diff --git a/gl/m4/eealloc.m4 b/gl/m4/eealloc.m4
index c640ec12..cb3e08fe 100644
--- a/gl/m4/eealloc.m4
+++ b/gl/m4/eealloc.m4
@@ -1,5 +1,5 @@
1# eealloc.m4 serial 3 1# eealloc.m4 serial 3
2dnl Copyright (C) 2003, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/environ.m4 b/gl/m4/environ.m4
index 593a33ed..741dfc56 100644
--- a/gl/m4/environ.m4
+++ b/gl/m4/environ.m4
@@ -1,5 +1,5 @@
1# environ.m4 serial 6 1# environ.m4 serial 8
2dnl Copyright (C) 2001-2004, 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2004, 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -29,16 +29,15 @@ AC_DEFUN_ONCE([gl_ENVIRON],
29AC_DEFUN([gt_CHECK_VAR_DECL], 29AC_DEFUN([gt_CHECK_VAR_DECL],
30[ 30[
31 define([gt_cv_var], [gt_cv_var_]$2[_declaration]) 31 define([gt_cv_var], [gt_cv_var_]$2[_declaration])
32 AC_MSG_CHECKING([if $2 is properly declared]) 32 AC_CACHE_CHECK([if $2 is properly declared], [gt_cv_var],
33 AC_CACHE_VAL([gt_cv_var], [ 33 [AC_COMPILE_IFELSE(
34 AC_COMPILE_IFELSE( 34 [AC_LANG_PROGRAM(
35 [AC_LANG_PROGRAM( 35 [[$1
36 [[$1 36 typedef struct { int foo; } foo_t;
37 extern struct { int foo; } $2;]], 37 extern foo_t $2;]],
38 [[$2.foo = 1;]])], 38 [[$2.foo = 1;]])],
39 [gt_cv_var=no], 39 [gt_cv_var=no],
40 [gt_cv_var=yes])]) 40 [gt_cv_var=yes])])
41 AC_MSG_RESULT([$gt_cv_var])
42 if test $gt_cv_var = yes; then 41 if test $gt_cv_var = yes; then
43 AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1, 42 AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1,
44 [Define if you have the declaration of $2.]) 43 [Define if you have the declaration of $2.])
diff --git a/gl/m4/errno_h.m4 b/gl/m4/errno_h.m4
index c813ea58..4c70d225 100644
--- a/gl/m4/errno_h.m4
+++ b/gl/m4/errno_h.m4
@@ -1,9 +1,11 @@
1# errno_h.m4 serial 12 1# errno_h.m4 serial 14
2dnl Copyright (C) 2004, 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2004, 2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_PREREQ([2.61])
8
7AC_DEFUN_ONCE([gl_HEADER_ERRNO_H], 9AC_DEFUN_ONCE([gl_HEADER_ERRNO_H],
8[ 10[
9 AC_REQUIRE([AC_PROG_CC]) 11 AC_REQUIRE([AC_PROG_CC])
@@ -66,13 +68,11 @@ booboo
66 [gl_cv_header_errno_h_complete=yes]) 68 [gl_cv_header_errno_h_complete=yes])
67 ]) 69 ])
68 if test $gl_cv_header_errno_h_complete = yes; then 70 if test $gl_cv_header_errno_h_complete = yes; then
69 ERRNO_H='' 71 GL_GENERATE_ERRNO_H=false
70 else 72 else
71 gl_NEXT_HEADERS([errno.h]) 73 gl_NEXT_HEADERS([errno.h])
72 ERRNO_H='errno.h' 74 GL_GENERATE_ERRNO_H=true
73 fi 75 fi
74 AC_SUBST([ERRNO_H])
75 AM_CONDITIONAL([GL_GENERATE_ERRNO_H], [test -n "$ERRNO_H"])
76 gl_REPLACE_ERRNO_VALUE([EMULTIHOP]) 76 gl_REPLACE_ERRNO_VALUE([EMULTIHOP])
77 gl_REPLACE_ERRNO_VALUE([ENOLINK]) 77 gl_REPLACE_ERRNO_VALUE([ENOLINK])
78 gl_REPLACE_ERRNO_VALUE([EOVERFLOW]) 78 gl_REPLACE_ERRNO_VALUE([EOVERFLOW])
@@ -86,7 +86,7 @@ booboo
86# Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE. 86# Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE.
87AC_DEFUN([gl_REPLACE_ERRNO_VALUE], 87AC_DEFUN([gl_REPLACE_ERRNO_VALUE],
88[ 88[
89 if test -n "$ERRNO_H"; then 89 if $GL_GENERATE_ERRNO_H; then
90 AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [ 90 AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [
91 AC_EGREP_CPP([yes],[ 91 AC_EGREP_CPP([yes],[
92#include <errno.h> 92#include <errno.h>
@@ -129,9 +129,3 @@ yes
129 AC_SUBST($1[_VALUE]) 129 AC_SUBST($1[_VALUE])
130 fi 130 fi
131]) 131])
132
133dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
134dnl Remove this when we can assume autoconf >= 2.61.
135m4_ifdef([AC_COMPUTE_INT], [], [
136 AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
137])
diff --git a/gl/m4/error.m4 b/gl/m4/error.m4
index 29e6fdc9..8cc75dff 100644
--- a/gl/m4/error.m4
+++ b/gl/m4/error.m4
@@ -1,6 +1,6 @@
1#serial 14 1#serial 15
2 2
3# Copyright (C) 1996-1998, 2001-2004, 2009-2013 Free Software Foundation, Inc. 3# Copyright (C) 1996-1998, 2001-2004, 2009-2023 Free Software Foundation, Inc.
4# 4#
5# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
@@ -22,6 +22,10 @@ AC_DEFUN([gl_ERROR],
22# Prerequisites of lib/error.c. 22# Prerequisites of lib/error.c.
23AC_DEFUN([gl_PREREQ_ERROR], 23AC_DEFUN([gl_PREREQ_ERROR],
24[ 24[
25 dnl Use system extensions on Android, so that AC_FUNC_STRERROR_R
26 dnl discovers the GNU API for strerror_r on Android API level 23 and later.
27 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
28
25 AC_REQUIRE([AC_FUNC_STRERROR_R]) 29 AC_REQUIRE([AC_FUNC_STRERROR_R])
26 : 30 :
27]) 31])
diff --git a/gl/m4/exponentd.m4 b/gl/m4/exponentd.m4
index 09df468c..2ef46437 100644
--- a/gl/m4/exponentd.m4
+++ b/gl/m4/exponentd.m4
@@ -1,5 +1,5 @@
1# exponentd.m4 serial 3 1# exponentd.m4 serial 3
2dnl Copyright (C) 2007-2008, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2008, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/extensions.m4 b/gl/m4/extensions.m4
index e30f1220..5336b8da 100644
--- a/gl/m4/extensions.m4
+++ b/gl/m4/extensions.m4
@@ -1,14 +1,19 @@
1# serial 13 -*- Autoconf -*- 1# serial 23 -*- Autoconf -*-
2# Enable extensions on systems that normally disable them. 2# Enable extensions on systems that normally disable them.
3 3
4# Copyright (C) 2003, 2006-2013 Free Software Foundation, Inc. 4# Copyright (C) 2003, 2006-2023 Free Software Foundation, Inc.
5# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved. 7# with or without modifications, as long as this notice is preserved.
8 8
9dnl Define to empty for the benefit of Autoconf 2.69 and earlier, so that
10dnl AC_USE_SYSTEM_EXTENSIONS (below) can be used unchanged from Autoconf 2.70+.
11m4_ifndef([AC_CHECK_INCLUDES_DEFAULT],
12 [AC_DEFUN([AC_CHECK_INCLUDES_DEFAULT], [])])
13
9# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git 14# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git
10# Autoconf. Perhaps we can remove this once we can assume Autoconf 15# Autoconf. Perhaps we can remove this once we can assume Autoconf
11# 2.70 or later everywhere, but since Autoconf mutates rapidly 16# is recent-enough everywhere, but since Autoconf mutates rapidly
12# enough in this area it's likely we'll need to redefine 17# enough in this area it's likely we'll need to redefine
13# AC_USE_SYSTEM_EXTENSIONS for quite some time. 18# AC_USE_SYSTEM_EXTENSIONS for quite some time.
14 19
@@ -26,67 +31,125 @@
26# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS 31# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS
27# invocation occurs in gl_EARLY, not in gl_INIT. 32# invocation occurs in gl_EARLY, not in gl_INIT.
28 33
34m4_version_prereq([2.72], [], [
35
29# AC_USE_SYSTEM_EXTENSIONS 36# AC_USE_SYSTEM_EXTENSIONS
30# ------------------------ 37# ------------------------
31# Enable extensions on systems that normally disable them, 38# Enable extensions on systems that normally disable them,
32# typically due to standards-conformance issues. 39# typically due to standards-conformance issues.
33# 40# We unconditionally define as many of the known feature-enabling
34# Remember that #undef in AH_VERBATIM gets replaced with #define by 41# as possible, reserving conditional behavior for macros that are
35# AC_DEFINE. The goal here is to define all known feature-enabling 42# known to cause problems on some platforms (such as __EXTENSIONS__).
36# macros, then, if reports of conflicts are made, disable macros that
37# cause problems on some platforms (such as __EXTENSIONS__).
38AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS], 43AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
39[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl 44[AC_BEFORE([$0], [AC_PREPROC_IFELSE])dnl
45AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
46AC_BEFORE([$0], [AC_LINK_IFELSE])dnl
40AC_BEFORE([$0], [AC_RUN_IFELSE])dnl 47AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
41 48AC_BEFORE([$0], [AC_CHECK_INCLUDES_DEFAULT])dnl
42 AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=]) 49dnl #undef in AH_VERBATIM gets replaced with #define by AC_DEFINE.
43 if test "$MINIX" = yes; then
44 AC_DEFINE([_POSIX_SOURCE], [1],
45 [Define to 1 if you need to in order for 'stat' and other
46 things to work.])
47 AC_DEFINE([_POSIX_1_SOURCE], [2],
48 [Define to 2 if the system does not provide POSIX.1 features
49 except with this defined.])
50 AC_DEFINE([_MINIX], [1],
51 [Define to 1 if on MINIX.])
52 AC_DEFINE([_NETBSD_SOURCE], [1],
53 [Define to 1 to make NetBSD features available. MINIX 3 needs this.])
54 fi
55
56dnl Use a different key than __EXTENSIONS__, as that name broke existing 50dnl Use a different key than __EXTENSIONS__, as that name broke existing
57dnl configure.ac when using autoheader 2.62. 51dnl configure.ac when using autoheader 2.62.
58 AH_VERBATIM([USE_SYSTEM_EXTENSIONS], 52dnl The macros below are in alphabetical order ignoring leading _ or __
53dnl prefixes.
54AH_VERBATIM([USE_SYSTEM_EXTENSIONS],
59[/* Enable extensions on AIX 3, Interix. */ 55[/* Enable extensions on AIX 3, Interix. */
60#ifndef _ALL_SOURCE 56#ifndef _ALL_SOURCE
61# undef _ALL_SOURCE 57# undef _ALL_SOURCE
62#endif 58#endif
63/* Enable general extensions on OS X. */ 59/* Enable general extensions on macOS. */
64#ifndef _DARWIN_C_SOURCE 60#ifndef _DARWIN_C_SOURCE
65# undef _DARWIN_C_SOURCE 61# undef _DARWIN_C_SOURCE
66#endif 62#endif
63/* Enable general extensions on Solaris. */
64#ifndef __EXTENSIONS__
65# undef __EXTENSIONS__
66#endif
67/* Enable GNU extensions on systems that have them. */ 67/* Enable GNU extensions on systems that have them. */
68#ifndef _GNU_SOURCE 68#ifndef _GNU_SOURCE
69# undef _GNU_SOURCE 69# undef _GNU_SOURCE
70#endif 70#endif
71/* Enable threading extensions on Solaris. */ 71/* Enable X/Open compliant socket functions that do not require linking
72 with -lxnet on HP-UX 11.11. */
73#ifndef _HPUX_ALT_XOPEN_SOCKET_API
74# undef _HPUX_ALT_XOPEN_SOCKET_API
75#endif
76/* Identify the host operating system as Minix.
77 This macro does not affect the system headers' behavior.
78 A future release of Autoconf may stop defining this macro. */
79#ifndef _MINIX
80# undef _MINIX
81#endif
82/* Enable general extensions on NetBSD.
83 Enable NetBSD compatibility extensions on Minix. */
84#ifndef _NETBSD_SOURCE
85# undef _NETBSD_SOURCE
86#endif
87/* Enable OpenBSD compatibility extensions on NetBSD.
88 Oddly enough, this does nothing on OpenBSD. */
89#ifndef _OPENBSD_SOURCE
90# undef _OPENBSD_SOURCE
91#endif
92/* Define to 1 if needed for POSIX-compatible behavior. */
93#ifndef _POSIX_SOURCE
94# undef _POSIX_SOURCE
95#endif
96/* Define to 2 if needed for POSIX-compatible behavior. */
97#ifndef _POSIX_1_SOURCE
98# undef _POSIX_1_SOURCE
99#endif
100/* Enable POSIX-compatible threading on Solaris. */
72#ifndef _POSIX_PTHREAD_SEMANTICS 101#ifndef _POSIX_PTHREAD_SEMANTICS
73# undef _POSIX_PTHREAD_SEMANTICS 102# undef _POSIX_PTHREAD_SEMANTICS
74#endif 103#endif
104/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
105#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
106# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
107#endif
108/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
109#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
110# undef __STDC_WANT_IEC_60559_BFP_EXT__
111#endif
112/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
113#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
114# undef __STDC_WANT_IEC_60559_DFP_EXT__
115#endif
116/* Enable extensions specified by C23 Annex F. */
117#ifndef __STDC_WANT_IEC_60559_EXT__
118# undef __STDC_WANT_IEC_60559_EXT__
119#endif
120/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
121#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
122# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
123#endif
124/* Enable extensions specified by C23 Annex H and ISO/IEC TS 18661-3:2015. */
125#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
126# undef __STDC_WANT_IEC_60559_TYPES_EXT__
127#endif
128/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
129#ifndef __STDC_WANT_LIB_EXT2__
130# undef __STDC_WANT_LIB_EXT2__
131#endif
132/* Enable extensions specified by ISO/IEC 24747:2009. */
133#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
134# undef __STDC_WANT_MATH_SPEC_FUNCS__
135#endif
75/* Enable extensions on HP NonStop. */ 136/* Enable extensions on HP NonStop. */
76#ifndef _TANDEM_SOURCE 137#ifndef _TANDEM_SOURCE
77# undef _TANDEM_SOURCE 138# undef _TANDEM_SOURCE
78#endif 139#endif
79/* Enable X/Open extensions if necessary. HP-UX 11.11 defines 140/* Enable X/Open extensions. Define to 500 only if necessary
80 mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of 141 to make mbstate_t available. */
81 whether compiling with -Ae or -D_HPUX_SOURCE=1. */
82#ifndef _XOPEN_SOURCE 142#ifndef _XOPEN_SOURCE
83# undef _XOPEN_SOURCE 143# undef _XOPEN_SOURCE
84#endif 144#endif
85/* Enable general extensions on Solaris. */ 145])dnl
86#ifndef __EXTENSIONS__ 146
87# undef __EXTENSIONS__ 147 AC_REQUIRE([AC_CHECK_INCLUDES_DEFAULT])dnl
88#endif 148 _AC_CHECK_HEADER_ONCE([wchar.h])
89]) 149 _AC_CHECK_HEADER_ONCE([minix/config.h])
150
151dnl Defining __EXTENSIONS__ may break the system headers on some systems.
152dnl (FIXME: Which ones?)
90 AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], 153 AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
91 [ac_cv_safe_to_define___extensions__], 154 [ac_cv_safe_to_define___extensions__],
92 [AC_COMPILE_IFELSE( 155 [AC_COMPILE_IFELSE(
@@ -95,30 +158,57 @@ dnl configure.ac when using autoheader 2.62.
95 ]AC_INCLUDES_DEFAULT])], 158 ]AC_INCLUDES_DEFAULT])],
96 [ac_cv_safe_to_define___extensions__=yes], 159 [ac_cv_safe_to_define___extensions__=yes],
97 [ac_cv_safe_to_define___extensions__=no])]) 160 [ac_cv_safe_to_define___extensions__=no])])
98 test $ac_cv_safe_to_define___extensions__ = yes && 161
99 AC_DEFINE([__EXTENSIONS__]) 162dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to
100 AC_DEFINE([_ALL_SOURCE]) 163dnl 500, regardless of whether compiling with -Ae or -D_HPUX_SOURCE=1.
101 AC_DEFINE([_DARWIN_C_SOURCE]) 164dnl But defining _XOPEN_SOURCE may turn *off* extensions on platforms
102 AC_DEFINE([_GNU_SOURCE]) 165dnl not covered by turn-on-extensions macros (notably Dragonfly, Free,
103 AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) 166dnl and OpenBSD, which don't have any equivalent of _NETBSD_SOURCE) so
104 AC_DEFINE([_TANDEM_SOURCE]) 167dnl it should only be defined when necessary.
105 AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined], 168 AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined],
106 [ac_cv_should_define__xopen_source], 169 [ac_cv_should_define__xopen_source],
107 [ac_cv_should_define__xopen_source=no 170 [ac_cv_should_define__xopen_source=no
108 AC_COMPILE_IFELSE( 171 AS_IF([test $ac_cv_header_wchar_h = yes],
109 [AC_LANG_PROGRAM([[ 172 [AC_COMPILE_IFELSE(
173 [AC_LANG_PROGRAM([[
110 #include <wchar.h> 174 #include <wchar.h>
111 mbstate_t x;]])], 175 mbstate_t x;]])],
112 [], 176 [],
113 [AC_COMPILE_IFELSE( 177 [AC_COMPILE_IFELSE(
114 [AC_LANG_PROGRAM([[ 178 [AC_LANG_PROGRAM([[
115 #define _XOPEN_SOURCE 500 179 #define _XOPEN_SOURCE 500
116 #include <wchar.h> 180 #include <wchar.h>
117 mbstate_t x;]])], 181 mbstate_t x;]])],
118 [ac_cv_should_define__xopen_source=yes])])]) 182 [ac_cv_should_define__xopen_source=yes])])])])
119 test $ac_cv_should_define__xopen_source = yes && 183
120 AC_DEFINE([_XOPEN_SOURCE], [500]) 184 AC_DEFINE([_ALL_SOURCE])
185 AC_DEFINE([_DARWIN_C_SOURCE])
186 AC_DEFINE([_GNU_SOURCE])
187 AC_DEFINE([_HPUX_ALT_XOPEN_SOCKET_API])
188 AC_DEFINE([_NETBSD_SOURCE])
189 AC_DEFINE([_OPENBSD_SOURCE])
190 AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
191 AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__])
192 AC_DEFINE([__STDC_WANT_IEC_60559_BFP_EXT__])
193 AC_DEFINE([__STDC_WANT_IEC_60559_DFP_EXT__])
194 AC_DEFINE([__STDC_WANT_IEC_60559_EXT__])
195 AC_DEFINE([__STDC_WANT_IEC_60559_FUNCS_EXT__])
196 AC_DEFINE([__STDC_WANT_IEC_60559_TYPES_EXT__])
197 AC_DEFINE([__STDC_WANT_LIB_EXT2__])
198 AC_DEFINE([__STDC_WANT_MATH_SPEC_FUNCS__])
199 AC_DEFINE([_TANDEM_SOURCE])
200 AS_IF([test $ac_cv_header_minix_config_h = yes],
201 [MINIX=yes
202 AC_DEFINE([_MINIX])
203 AC_DEFINE([_POSIX_SOURCE])
204 AC_DEFINE([_POSIX_1_SOURCE], [2])],
205 [MINIX=])
206 AS_IF([test $ac_cv_safe_to_define___extensions__ = yes],
207 [AC_DEFINE([__EXTENSIONS__])])
208 AS_IF([test $ac_cv_should_define__xopen_source = yes],
209 [AC_DEFINE([_XOPEN_SOURCE], [500])])
121])# AC_USE_SYSTEM_EXTENSIONS 210])# AC_USE_SYSTEM_EXTENSIONS
211])
122 212
123# gl_USE_SYSTEM_EXTENSIONS 213# gl_USE_SYSTEM_EXTENSIONS
124# ------------------------ 214# ------------------------
@@ -126,13 +216,17 @@ dnl configure.ac when using autoheader 2.62.
126# typically due to standards-conformance issues. 216# typically due to standards-conformance issues.
127AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS], 217AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
128[ 218[
129 dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS.
130 dnl gnulib does not need it. But if it gets required by third-party macros
131 dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a
132 dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
133 dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE,
134 dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck.
135 AC_REQUIRE([AC_GNU_SOURCE])
136
137 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 219 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
220
221 dnl On OpenBSD 6.8 with GCC, the include files contain a couple of
222 dnl definitions that are only activated with an explicit -D_ISOC11_SOURCE.
223 dnl That's because this version of GCC (4.2.1) supports the option
224 dnl '-std=gnu99' but not the option '-std=gnu11'.
225 AC_REQUIRE([AC_CANONICAL_HOST])
226 case "$host_os" in
227 openbsd*)
228 AC_DEFINE([_ISOC11_SOURCE], [1],
229 [Define to enable the declarations of ISO C 11 types and functions.])
230 ;;
231 esac
138]) 232])
diff --git a/gl/m4/extern-inline.m4 b/gl/m4/extern-inline.m4
index c4c5e7f2..c001b1cf 100644
--- a/gl/m4/extern-inline.m4
+++ b/gl/m4/extern-inline.m4
@@ -1,61 +1,121 @@
1dnl 'extern inline' a la ISO C99. 1dnl 'extern inline' a la ISO C99.
2 2
3dnl Copyright 2012-2013 Free Software Foundation, Inc. 3dnl Copyright 2012-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7 7
8AC_DEFUN([gl_EXTERN_INLINE], 8AC_DEFUN([gl_EXTERN_INLINE],
9[ 9[
10 AH_VERBATIM([extern_inline], 10 AC_CACHE_CHECK([whether ctype.h defines __header_inline],
11 [gl_cv_have___header_inline],
12 [AC_PREPROC_IFELSE(
13 [AC_LANG_SOURCE([[#include <ctype.h>
14 #ifndef __header_inline
15 #error "<ctype.h> does not define __header_inline"
16 #endif
17 ]])],
18 [gl_cv_have___header_inline=yes],
19 [gl_cv_have___header_inline=no])])
20 if test "$gl_cv_have___header_inline" = yes; then
21 AC_DEFINE([HAVE___HEADER_INLINE], [1],
22 [Define to 1 if ctype.h defines __header_inline.])
23 fi
24
25 AH_VERBATIM([HAVE___HEADER_INLINE_1],
11[/* Please see the Gnulib manual for how to use these macros. 26[/* Please see the Gnulib manual for how to use these macros.
12 27
13 Suppress extern inline with HP-UX cc, as it appears to be broken; see 28 Suppress extern inline with HP-UX cc, as it appears to be broken; see
14 <http://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>. 29 <https://lists.gnu.org/r/bug-texinfo/2013-02/msg00030.html>.
15 30
16 Suppress extern inline with Sun C in standards-conformance mode, as it 31 Suppress extern inline with Sun C in standards-conformance mode, as it
17 mishandles inline functions that call each other. E.g., for 'inline void f 32 mishandles inline functions that call each other. E.g., for 'inline void f
18 (void) { } inline void g (void) { f (); }', c99 incorrectly complains 33 (void) { } inline void g (void) { f (); }', c99 incorrectly complains
19 'reference to static identifier "f" in extern inline function'. 34 'reference to static identifier "f" in extern inline function'.
20 This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16. 35 This bug was observed with Oracle Developer Studio 12.6
36 (Sun C 5.15 SunOS_sparc 2017/05/30).
37
38 Suppress extern inline (with or without __attribute__ ((__gnu_inline__)))
39 on configurations that mistakenly use 'static inline' to implement
40 functions or macros in standard C headers like <ctype.h>. For example,
41 if isdigit is mistakenly implemented via a static inline function,
42 a program containing an extern inline function that calls isdigit
43 may not work since the C standard prohibits extern inline functions
44 from calling static functions (ISO C 99 section 6.7.4.(3).
45 This bug is known to occur on:
46
47 OS X 10.8 and earlier; see:
48 https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html
49
50 DragonFly; see
51 http://muscles.dragonflybsd.org/bulk/clang-master-potential/20141111_102002/logs/ah-tty-0.3.12.log
21 52
22 Suppress the use of extern inline on Apple's platforms, as Libc at least 53 FreeBSD; see:
23 through Libc-825.26 (2013-04-09) is incompatible with it; see, e.g., 54 https://lists.gnu.org/r/bug-gnulib/2014-07/msg00104.html
24 <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>. 55
25 Perhaps Apple will fix this some day. */ 56 OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
57 for clang but remains for g++; see <https://trac.macports.org/ticket/41033>.
58 Assume DragonFly and FreeBSD will be similar.
59
60 GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
61 inline semantics, unless -fgnu89-inline is used. It defines a macro
62 __GNUC_STDC_INLINE__ to indicate this situation or a macro
63 __GNUC_GNU_INLINE__ to indicate the opposite situation.
64 GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline
65 semantics but warns, unless -fgnu89-inline is used:
66 warning: C99 inline functions are not supported; using GNU89
67 warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute
68 It defines a macro __GNUC_GNU_INLINE__ to indicate this situation.
69 */
70#if (((defined __APPLE__ && defined __MACH__) \
71 || defined __DragonFly__ || defined __FreeBSD__) \
72 && (defined HAVE___HEADER_INLINE \
73 ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \
74 && ! defined __clang__) \
75 : ((! defined _DONT_USE_CTYPE_INLINE_ \
76 && (defined __GNUC__ || defined __cplusplus)) \
77 || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
78 && defined __GNUC__ && ! defined __cplusplus))))
79# define _GL_EXTERN_INLINE_STDHEADER_BUG
80#endif
26#if ((__GNUC__ \ 81#if ((__GNUC__ \
27 ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ 82 ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
28 : (199901L <= __STDC_VERSION__ \ 83 : (199901L <= __STDC_VERSION__ \
29 && !defined __HP_cc \ 84 && !defined __HP_cc \
85 && !defined __PGI \
30 && !(defined __SUNPRO_C && __STDC__))) \ 86 && !(defined __SUNPRO_C && __STDC__))) \
31 && !defined __APPLE__) 87 && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
32# define _GL_INLINE inline 88# define _GL_INLINE inline
33# define _GL_EXTERN_INLINE extern inline 89# define _GL_EXTERN_INLINE extern inline
90# define _GL_EXTERN_INLINE_IN_USE
34#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ 91#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
35 && !defined __APPLE__) 92 && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
36# if __GNUC_GNU_INLINE__ 93# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__
37 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ 94 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
38# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__)) 95# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
39# else 96# else
40# define _GL_INLINE extern inline 97# define _GL_INLINE extern inline
41# endif 98# endif
42# define _GL_EXTERN_INLINE extern 99# define _GL_EXTERN_INLINE extern
100# define _GL_EXTERN_INLINE_IN_USE
43#else 101#else
44# define _GL_INLINE static _GL_UNUSED 102# define _GL_INLINE _GL_UNUSED static
45# define _GL_EXTERN_INLINE static _GL_UNUSED 103# define _GL_EXTERN_INLINE _GL_UNUSED static
46#endif 104#endif
47 105
48#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) 106/* In GCC 4.6 (inclusive) to 5.1 (exclusive),
107 suppress bogus "no previous prototype for 'FOO'"
108 and "no previous declaration for 'FOO'" diagnostics,
109 when FOO is an inline function in the header; see
110 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113> and
111 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63877>. */
112#if __GNUC__ == 4 && 6 <= __GNUC_MINOR__
49# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ 113# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
50# define _GL_INLINE_HEADER_CONST_PRAGMA 114# define _GL_INLINE_HEADER_CONST_PRAGMA
51# else 115# else
52# define _GL_INLINE_HEADER_CONST_PRAGMA \ 116# define _GL_INLINE_HEADER_CONST_PRAGMA \
53 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") 117 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
54# endif 118# endif
55 /* Suppress GCC's bogus "no previous prototype for 'FOO'"
56 and "no previous declaration for 'FOO'" diagnostics,
57 when FOO is an inline function in the header; see
58 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>. */
59# define _GL_INLINE_HEADER_BEGIN \ 119# define _GL_INLINE_HEADER_BEGIN \
60 _Pragma ("GCC diagnostic push") \ 120 _Pragma ("GCC diagnostic push") \
61 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \ 121 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \
diff --git a/gl/m4/fcntl-o.m4 b/gl/m4/fcntl-o.m4
index 87cc4bd2..59d558bd 100644
--- a/gl/m4/fcntl-o.m4
+++ b/gl/m4/fcntl-o.m4
@@ -1,23 +1,22 @@
1# fcntl-o.m4 serial 4 1# fcntl-o.m4 serial 7
2dnl Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl Written by Paul Eggert. 7dnl Written by Paul Eggert.
8 8
9AC_PREREQ([2.60])
10
9# Test whether the flags O_NOATIME and O_NOFOLLOW actually work. 11# Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
10# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise. 12# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
11# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise. 13# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
12AC_DEFUN([gl_FCNTL_O_FLAGS], 14AC_DEFUN([gl_FCNTL_O_FLAGS],
13[ 15[
14 dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW. 16 dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
15 dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes 17 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
16 dnl AC_GNU_SOURCE.
17 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
18 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
19 [AC_REQUIRE([AC_GNU_SOURCE])])
20 18
19 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
21 AC_CHECK_HEADERS_ONCE([unistd.h]) 20 AC_CHECK_HEADERS_ONCE([unistd.h])
22 AC_CHECK_FUNCS_ONCE([symlink]) 21 AC_CHECK_FUNCS_ONCE([symlink])
23 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h], 22 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
@@ -33,6 +32,7 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
33 # defined sleep(n) _sleep ((n) * 1000) 32 # defined sleep(n) _sleep ((n) * 1000)
34 #endif 33 #endif
35 #include <fcntl.h> 34 #include <fcntl.h>
35 ]GL_MDA_DEFINES[
36 #ifndef O_NOATIME 36 #ifndef O_NOATIME
37 #define O_NOATIME 0 37 #define O_NOATIME 0
38 #endif 38 #endif
@@ -116,7 +116,13 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
116 68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( 116 68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
117 *) gl_cv_header_working_fcntl_h='no';; 117 *) gl_cv_header_working_fcntl_h='no';;
118 esac], 118 esac],
119 [gl_cv_header_working_fcntl_h=cross-compiling])]) 119 [case "$host_os" in
120 # Guess 'no' on native Windows.
121 mingw*) gl_cv_header_working_fcntl_h='no' ;;
122 *) gl_cv_header_working_fcntl_h=cross-compiling ;;
123 esac
124 ])
125 ])
120 126
121 case $gl_cv_header_working_fcntl_h in #( 127 case $gl_cv_header_working_fcntl_h in #(
122 *O_NOATIME* | no | cross-compiling) ac_val=0;; #( 128 *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
diff --git a/gl/m4/fcntl.m4 b/gl/m4/fcntl.m4
new file mode 100644
index 00000000..524a99af
--- /dev/null
+++ b/gl/m4/fcntl.m4
@@ -0,0 +1,151 @@
1# fcntl.m4 serial 11
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# For now, this module ensures that fcntl()
8# - supports F_DUPFD correctly
9# - supports or emulates F_DUPFD_CLOEXEC
10# - supports F_GETFD
11# Still to be ported to mingw:
12# - F_SETFD
13# - F_GETFL, F_SETFL
14# - F_GETOWN, F_SETOWN
15# - F_GETLK, F_SETLK, F_SETLKW
16AC_DEFUN([gl_FUNC_FCNTL],
17[
18 dnl Persuade glibc to expose F_DUPFD_CLOEXEC.
19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
20 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
21 AC_REQUIRE([AC_CANONICAL_HOST])
22 AC_CHECK_FUNCS_ONCE([fcntl])
23 if test $ac_cv_func_fcntl = no; then
24 gl_REPLACE_FCNTL
25 else
26 dnl cygwin 1.5.x F_DUPFD has wrong errno, and allows negative target
27 dnl haiku alpha 2 F_DUPFD has wrong errno
28 AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
29 [gl_cv_func_fcntl_f_dupfd_works],
30 [AC_RUN_IFELSE(
31 [AC_LANG_PROGRAM(
32 [[#include <errno.h>
33 #include <fcntl.h>
34 #include <limits.h>
35 #include <sys/resource.h>
36 #include <unistd.h>
37 ]GL_MDA_DEFINES[
38 #ifndef RLIM_SAVED_CUR
39 # define RLIM_SAVED_CUR RLIM_INFINITY
40 #endif
41 #ifndef RLIM_SAVED_MAX
42 # define RLIM_SAVED_MAX RLIM_INFINITY
43 #endif
44 ]],
45 [[int result = 0;
46 int bad_fd = INT_MAX;
47 struct rlimit rlim;
48 if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
49 && 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX
50 && rlim.rlim_cur != RLIM_INFINITY
51 && rlim.rlim_cur != RLIM_SAVED_MAX
52 && rlim.rlim_cur != RLIM_SAVED_CUR)
53 bad_fd = rlim.rlim_cur;
54 if (fcntl (0, F_DUPFD, -1) != -1) result |= 1;
55 if (errno != EINVAL) result |= 2;
56 if (fcntl (0, F_DUPFD, bad_fd) != -1) result |= 4;
57 if (errno != EINVAL) result |= 8;
58 /* On OS/2 kLIBC, F_DUPFD does not work on a directory fd */
59 {
60 int fd;
61 fd = open (".", O_RDONLY);
62 if (fd == -1)
63 result |= 16;
64 else if (fcntl (fd, F_DUPFD, STDERR_FILENO + 1) == -1)
65 result |= 32;
66
67 close (fd);
68 }
69 return result;]])],
70 [gl_cv_func_fcntl_f_dupfd_works=yes],
71 [gl_cv_func_fcntl_f_dupfd_works=no],
72 [case $host_os in
73 aix* | cygwin* | haiku*)
74 gl_cv_func_fcntl_f_dupfd_works="guessing no" ;;
75 *) gl_cv_func_fcntl_f_dupfd_works="guessing yes" ;;
76 esac])])
77 case $gl_cv_func_fcntl_f_dupfd_works in
78 *yes) ;;
79 *) gl_REPLACE_FCNTL
80 AC_DEFINE([FCNTL_DUPFD_BUGGY], [1], [Define this to 1 if F_DUPFD
81 behavior does not match POSIX]) ;;
82 esac
83
84 dnl Many systems lack F_DUPFD_CLOEXEC.
85 dnl NetBSD 9.0 declares F_DUPFD_CLOEXEC but it works only like F_DUPFD.
86 AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC],
87 [gl_cv_func_fcntl_f_dupfd_cloexec],
88 [AC_RUN_IFELSE(
89 [AC_LANG_SOURCE(
90 [[#include <fcntl.h>
91 #include <unistd.h>
92 int main (int argc, char *argv[])
93 {
94 if (argc == 1)
95 /* parent process */
96 {
97 if (fcntl (1, F_DUPFD_CLOEXEC, 10) < 0)
98 return 1;
99 return execl ("./conftest", "./conftest", "child", NULL);
100 }
101 else
102 /* child process */
103 return (fcntl (10, F_GETFL) < 0 ? 0 : 42);
104 }
105 ]])
106 ],
107 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
108#ifdef __linux__
109/* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace
110 it to support the semantics on older kernels that failed with EINVAL. */
111choke me
112#endif
113 ]])],
114 [gl_cv_func_fcntl_f_dupfd_cloexec=yes],
115 [gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"])
116 ],
117 [gl_cv_func_fcntl_f_dupfd_cloexec=no],
118 [case "$host_os" in
119 # Guess no on NetBSD.
120 netbsd*) gl_cv_func_fcntl_f_dupfd_cloexec="guessing no" ;;
121 *) gl_cv_func_fcntl_f_dupfd_cloexec="$gl_cross_guess_normal" ;;
122 esac
123 ])
124 ])
125 case "$gl_cv_func_fcntl_f_dupfd_cloexec" in
126 *yes) ;;
127 *) gl_REPLACE_FCNTL
128 dnl No witness macro needed for this bug.
129 ;;
130 esac
131 fi
132 dnl Replace fcntl() for supporting the gnulib-defined fchdir() function,
133 dnl to keep fchdir's bookkeeping up-to-date.
134 m4_ifdef([gl_FUNC_FCHDIR], [
135 gl_TEST_FCHDIR
136 if test $HAVE_FCHDIR = 0; then
137 gl_REPLACE_FCNTL
138 fi
139 ])
140])
141
142AC_DEFUN([gl_REPLACE_FCNTL],
143[
144 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
145 AC_CHECK_FUNCS_ONCE([fcntl])
146 if test $ac_cv_func_fcntl = no; then
147 HAVE_FCNTL=0
148 else
149 REPLACE_FCNTL=1
150 fi
151])
diff --git a/gl/m4/fcntl_h.m4 b/gl/m4/fcntl_h.m4
new file mode 100644
index 00000000..68f4e648
--- /dev/null
+++ b/gl/m4/fcntl_h.m4
@@ -0,0 +1,70 @@
1# serial 20
2# Configure fcntl.h.
3dnl Copyright (C) 2006-2007, 2009-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl Written by Paul Eggert.
9
10AC_DEFUN_ONCE([gl_FCNTL_H],
11[
12 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
13 AC_REQUIRE([gl_FCNTL_O_FLAGS])
14 gl_NEXT_HEADERS([fcntl.h])
15
16 dnl Ensure the type pid_t gets defined.
17 AC_REQUIRE([AC_TYPE_PID_T])
18
19 dnl Ensure the type mode_t gets defined.
20 AC_REQUIRE([AC_TYPE_MODE_T])
21
22 dnl Check for declarations of anything we want to poison if the
23 dnl corresponding gnulib module is not in use, if it is not common
24 dnl enough to be declared everywhere.
25 gl_WARN_ON_USE_PREPARE([[#include <fcntl.h>
26 ]], [fcntl openat])
27])
28
29# gl_FCNTL_MODULE_INDICATOR([modulename])
30# sets the shell variable that indicates the presence of the given module
31# to a C preprocessor expression that will evaluate to 1.
32# This macro invocation must not occur in macros that are AC_REQUIREd.
33AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],
34[
35 dnl Ensure to expand the default settings once only.
36 gl_FCNTL_H_REQUIRE_DEFAULTS
37 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
38 dnl Define it also as a C macro, for the benefit of the unit tests.
39 gl_MODULE_INDICATOR_FOR_TESTS([$1])
40])
41
42# Initializes the default values for AC_SUBSTed shell variables.
43# This macro must not be AC_REQUIREd. It must only be invoked, and only
44# outside of macros or in macros that are not AC_REQUIREd.
45AC_DEFUN([gl_FCNTL_H_REQUIRE_DEFAULTS],
46[
47 m4_defun(GL_MODULE_INDICATOR_PREFIX[_FCNTL_H_MODULE_INDICATOR_DEFAULTS], [
48 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CREAT])
49 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCNTL])
50 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NONBLOCKING])
51 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPEN])
52 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPENAT])
53 dnl Support Microsoft deprecated alias function names by default.
54 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CREAT], [1])
55 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_OPEN], [1])
56 ])
57 m4_require(GL_MODULE_INDICATOR_PREFIX[_FCNTL_H_MODULE_INDICATOR_DEFAULTS])
58 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
59])
60
61AC_DEFUN([gl_FCNTL_H_DEFAULTS],
62[
63 dnl Assume proper GNU behavior unless another module says otherwise.
64 HAVE_FCNTL=1; AC_SUBST([HAVE_FCNTL])
65 HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT])
66 REPLACE_CREAT=0; AC_SUBST([REPLACE_CREAT])
67 REPLACE_FCNTL=0; AC_SUBST([REPLACE_FCNTL])
68 REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
69 REPLACE_OPENAT=0; AC_SUBST([REPLACE_OPENAT])
70])
diff --git a/gl/m4/fflush.m4 b/gl/m4/fflush.m4
new file mode 100644
index 00000000..3e3c8903
--- /dev/null
+++ b/gl/m4/fflush.m4
@@ -0,0 +1,100 @@
1# fflush.m4 serial 18
2
3# Copyright (C) 2007-2023 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved.
7
8dnl From Eric Blake
9
10dnl Find out how to obey POSIX semantics of fflush(stdin) discarding
11dnl unread input on seekable streams, rather than C99 undefined semantics.
12
13AC_DEFUN([gl_FUNC_FFLUSH],
14[
15 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
16 gl_FUNC_FFLUSH_STDIN
17 case "$gl_cv_func_fflush_stdin" in
18 *yes) ;;
19 *) REPLACE_FFLUSH=1 ;;
20 esac
21])
22
23dnl Determine whether fflush works on input streams.
24dnl Sets gl_cv_func_fflush_stdin.
25
26AC_DEFUN([gl_FUNC_FFLUSH_STDIN],
27[
28 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
29 AC_CHECK_HEADERS_ONCE([unistd.h])
30 AC_CACHE_CHECK([whether fflush works on input streams],
31 [gl_cv_func_fflush_stdin],
32 [echo hello world > conftest.txt
33 AC_RUN_IFELSE([AC_LANG_PROGRAM(
34 [[
35#include <stdio.h>
36#if HAVE_UNISTD_H
37# include <unistd.h>
38#else /* on Windows with MSVC */
39# include <io.h>
40#endif
41 ]GL_MDA_DEFINES],
42 [[FILE *f = fopen ("conftest.txt", "r");
43 char buffer[10];
44 int fd;
45 int c;
46 if (f == NULL)
47 return 1;
48 fd = fileno (f);
49 if (fd < 0 || fread (buffer, 1, 5, f) != 5)
50 { fclose (f); return 2; }
51 /* For deterministic results, ensure f read a bigger buffer. */
52 if (lseek (fd, 0, SEEK_CUR) == 5)
53 { fclose (f); return 3; }
54 /* POSIX requires fflush-fseek to set file offset of fd. This fails
55 on BSD systems and on mingw. */
56 if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
57 { fclose (f); return 4; }
58 if (lseek (fd, 0, SEEK_CUR) != 5)
59 { fclose (f); return 5; }
60 /* Verify behaviour of fflush after ungetc. See
61 <https://www.opengroup.org/austin/aardvark/latest/xshbug3.txt> */
62 /* Verify behaviour of fflush after a backup ungetc. This fails on
63 mingw. */
64 c = fgetc (f);
65 ungetc (c, f);
66 fflush (f);
67 if (fgetc (f) != c)
68 { fclose (f); return 6; }
69 /* Verify behaviour of fflush after a non-backup ungetc. This fails
70 on glibc 2.8 and on BSD systems. */
71 c = fgetc (f);
72 ungetc ('@', f);
73 fflush (f);
74 if (fgetc (f) != c)
75 { fclose (f); return 7; }
76 fclose (f);
77 return 0;
78 ]])],
79 [gl_cv_func_fflush_stdin=yes],
80 [gl_cv_func_fflush_stdin=no],
81 [case "$host_os" in
82 # Guess no on native Windows.
83 mingw*) gl_cv_func_fflush_stdin="guessing no" ;;
84 *) gl_cv_func_fflush_stdin=cross ;;
85 esac
86 ])
87 rm conftest.txt
88 ])
89 case "$gl_cv_func_fflush_stdin" in
90 *yes) gl_func_fflush_stdin=1 ;;
91 *no) gl_func_fflush_stdin=0 ;;
92 *) gl_func_fflush_stdin='(-1)' ;;
93 esac
94 AC_DEFINE_UNQUOTED([FUNC_FFLUSH_STDIN], [$gl_func_fflush_stdin],
95 [Define to 1 if fflush is known to work on stdin as per POSIX.1-2008,
96 0 if fflush is known to not work, -1 if unknown.])
97])
98
99# Prerequisites of lib/fflush.c.
100AC_DEFUN([gl_PREREQ_FFLUSH], [:])
diff --git a/gl/m4/float_h.m4 b/gl/m4/float_h.m4
index 397f2d1f..2f0c9c4e 100644
--- a/gl/m4/float_h.m4
+++ b/gl/m4/float_h.m4
@@ -1,5 +1,5 @@
1# float_h.m4 serial 9 1# float_h.m4 serial 13
2dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,42 +8,46 @@ AC_DEFUN([gl_FLOAT_H],
8[ 8[
9 AC_REQUIRE([AC_PROG_CC]) 9 AC_REQUIRE([AC_PROG_CC])
10 AC_REQUIRE([AC_CANONICAL_HOST]) 10 AC_REQUIRE([AC_CANONICAL_HOST])
11 FLOAT_H= 11 GL_GENERATE_FLOAT_H=false
12 REPLACE_FLOAT_LDBL=0 12 REPLACE_FLOAT_LDBL=0
13 case "$host_os" in 13 case "$host_os" in
14 aix* | beos* | openbsd* | mirbsd* | irix*) 14 aix* | beos* | openbsd* | mirbsd* | irix*)
15 FLOAT_H=float.h 15 GL_GENERATE_FLOAT_H=true
16 ;; 16 ;;
17 freebsd*) 17 freebsd* | dragonfly*)
18 case "$host_cpu" in 18 case "$host_cpu" in
19changequote(,)dnl 19changequote(,)dnl
20 i[34567]86 ) 20 i[34567]86 )
21changequote([,])dnl 21changequote([,])dnl
22 FLOAT_H=float.h 22 GL_GENERATE_FLOAT_H=true
23 ;; 23 ;;
24 x86_64 ) 24 x86_64 )
25 # On x86_64 systems, the C compiler may still be generating 25 # On x86_64 systems, the C compiler may still be generating
26 # 32-bit code. 26 # 32-bit code.
27 AC_EGREP_CPP([yes], 27 AC_COMPILE_IFELSE(
28 [#if defined __LP64__ || defined __x86_64__ || defined __amd64__ 28 [AC_LANG_SOURCE(
29 yes 29 [[#if defined __LP64__ || defined __x86_64__ || defined __amd64__
30 #endif], 30 int ok;
31 #else
32 error fail
33 #endif
34 ]])],
31 [], 35 [],
32 [FLOAT_H=float.h]) 36 [GL_GENERATE_FLOAT_H=true])
33 ;; 37 ;;
34 esac 38 esac
35 ;; 39 ;;
36 linux*) 40 linux*)
37 case "$host_cpu" in 41 case "$host_cpu" in
38 powerpc*) 42 powerpc*)
39 FLOAT_H=float.h 43 GL_GENERATE_FLOAT_H=true
40 ;; 44 ;;
41 esac 45 esac
42 ;; 46 ;;
43 esac 47 esac
44 case "$host_os" in 48 case "$host_os" in
45 aix* | freebsd* | linux*) 49 aix* | freebsd* | dragonfly* | linux*)
46 if test -n "$FLOAT_H"; then 50 if $GL_GENERATE_FLOAT_H; then
47 REPLACE_FLOAT_LDBL=1 51 REPLACE_FLOAT_LDBL=1
48 fi 52 fi
49 ;; 53 ;;
@@ -69,14 +73,20 @@ int main ()
69 [gl_cv_func_itold_works=no], 73 [gl_cv_func_itold_works=no],
70 [case "$host" in 74 [case "$host" in
71 sparc*-*-linux*) 75 sparc*-*-linux*)
72 AC_EGREP_CPP([yes], 76 AC_COMPILE_IFELSE(
73 [#if defined __LP64__ || defined __arch64__ 77 [AC_LANG_SOURCE(
74 yes 78 [[#if defined __LP64__ || defined __arch64__
75 #endif], 79 int ok;
80 #else
81 error fail
82 #endif
83 ]])],
76 [gl_cv_func_itold_works="guessing no"], 84 [gl_cv_func_itold_works="guessing no"],
77 [gl_cv_func_itold_works="guessing yes"]) 85 [gl_cv_func_itold_works="guessing yes"])
78 ;; 86 ;;
79 *) gl_cv_func_itold_works="guessing yes" ;; 87 # Guess yes on native Windows.
88 mingw*) gl_cv_func_itold_works="guessing yes" ;;
89 *) gl_cv_func_itold_works="guessing yes" ;;
80 esac 90 esac
81 ]) 91 ])
82 ]) 92 ])
@@ -85,14 +95,12 @@ int main ()
85 REPLACE_ITOLD=1 95 REPLACE_ITOLD=1
86 dnl We add the workaround to <float.h> but also to <math.h>, 96 dnl We add the workaround to <float.h> but also to <math.h>,
87 dnl to increase the chances that the fix function gets pulled in. 97 dnl to increase the chances that the fix function gets pulled in.
88 FLOAT_H=float.h 98 GL_GENERATE_FLOAT_H=true
89 ;; 99 ;;
90 esac 100 esac
91 101
92 if test -n "$FLOAT_H"; then 102 if $GL_GENERATE_FLOAT_H; then
93 gl_NEXT_HEADERS([float.h]) 103 gl_NEXT_HEADERS([float.h])
94 fi 104 fi
95 AC_SUBST([FLOAT_H])
96 AM_CONDITIONAL([GL_GENERATE_FLOAT_H], [test -n "$FLOAT_H"])
97 AC_SUBST([REPLACE_ITOLD]) 105 AC_SUBST([REPLACE_ITOLD])
98]) 106])
diff --git a/gl/m4/floorf.m4 b/gl/m4/floorf.m4
index c892ff9c..c49ffa6b 100644
--- a/gl/m4/floorf.m4
+++ b/gl/m4/floorf.m4
@@ -1,5 +1,5 @@
1# floorf.m4 serial 13 1# floorf.m4 serial 18
2dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -39,7 +39,7 @@ AC_DEFUN([gl_FUNC_FLOORF],
39static float dummy (float f) { return 0; } 39static float dummy (float f) { return 0; }
40int main (int argc, char *argv[]) 40int main (int argc, char *argv[])
41{ 41{
42 float (*my_floorf) (float) = argc ? floorf : dummy; 42 float (* volatile my_floorf) (float) = argc ? floorf : dummy;
43 /* Test whether floorf (-0.0f) is -0.0f. */ 43 /* Test whether floorf (-0.0f) is -0.0f. */
44 if (signbitf (minus_zerof) && !signbitf (my_floorf (minus_zerof))) 44 if (signbitf (minus_zerof) && !signbitf (my_floorf (minus_zerof)))
45 return 1; 45 return 1;
@@ -49,10 +49,14 @@ int main (int argc, char *argv[])
49 [gl_cv_func_floorf_ieee=yes], 49 [gl_cv_func_floorf_ieee=yes],
50 [gl_cv_func_floorf_ieee=no], 50 [gl_cv_func_floorf_ieee=no],
51 [case "$host_os" in 51 [case "$host_os" in
52 # Guess yes on glibc systems. 52 # Guess yes on glibc systems.
53 *-gnu*) gl_cv_func_floorf_ieee="guessing yes" ;; 53 *-gnu* | gnu*) gl_cv_func_floorf_ieee="guessing yes" ;;
54 # If we don't know, assume the worst. 54 # Guess yes on musl systems.
55 *) gl_cv_func_floorf_ieee="guessing no" ;; 55 *-musl*) gl_cv_func_floorf_ieee="guessing yes" ;;
56 # Guess yes on native Windows.
57 mingw*) gl_cv_func_floorf_ieee="guessing yes" ;;
58 # If we don't know, obey --enable-cross-guesses.
59 *) gl_cv_func_floorf_ieee="$gl_cross_guess_normal" ;;
56 esac 60 esac
57 ]) 61 ])
58 LIBS="$save_LIBS" 62 LIBS="$save_LIBS"
diff --git a/gl/m4/fopen.m4 b/gl/m4/fopen.m4
new file mode 100644
index 00000000..9c39ff72
--- /dev/null
+++ b/gl/m4/fopen.m4
@@ -0,0 +1,149 @@
1# fopen.m4 serial 13
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FOPEN],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 case "$host_os" in
12 mingw* | pw*)
13 dnl Replace fopen, for handling of "/dev/null".
14 REPLACE_FOPEN=1
15 dnl fopen on mingw also has the trailing slash bug.
16 gl_cv_func_fopen_slash="guessing no"
17 ;;
18 *)
19 dnl fopen("foo/", "w") should not create a file when the file name has a
20 dnl trailing slash.
21 AC_CACHE_CHECK([whether fopen recognizes a trailing slash],
22 [gl_cv_func_fopen_slash],
23 [
24 AC_RUN_IFELSE(
25 [AC_LANG_SOURCE([[
26#include <stddef.h>
27#include <stdio.h>
28int main ()
29{
30 FILE *fp = fopen ("conftest.sl/", "w");
31 int result = (fp != NULL);
32 if (fp != NULL)
33 fclose (fp);
34 return result;
35}]])],
36 [gl_cv_func_fopen_slash=yes],
37 [gl_cv_func_fopen_slash=no],
38 [
39changequote(,)dnl
40 case "$host_os" in
41 aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*)
42 gl_cv_func_fopen_slash="guessing no" ;;
43 *)
44 gl_cv_func_fopen_slash="guessing yes" ;;
45 esac
46changequote([,])dnl
47 ])
48 rm -f conftest.sl
49 ])
50 ;;
51 esac
52 case "$gl_cv_func_fopen_slash" in
53 *no)
54 AC_DEFINE([FOPEN_TRAILING_SLASH_BUG], [1],
55 [Define to 1 if fopen() fails to recognize a trailing slash.])
56 REPLACE_FOPEN=1
57 ;;
58 esac
59])
60
61AC_DEFUN([gl_FUNC_FOPEN_GNU],
62[
63 AC_REQUIRE([gl_FUNC_FOPEN])
64 AC_CACHE_CHECK([whether fopen supports the mode character 'x'],
65 [gl_cv_func_fopen_mode_x],
66 [rm -f conftest.x
67 AC_RUN_IFELSE(
68 [AC_LANG_SOURCE([[
69#include <stdio.h>
70#include <errno.h>
71int main ()
72{
73 FILE *fp;
74 fp = fopen ("conftest.x", "w");
75 fclose (fp);
76 fp = fopen ("conftest.x", "wx");
77 if (fp != NULL)
78 /* 'x' ignored */
79 return 1;
80 else if (errno == EEXIST)
81 return 0;
82 else
83 /* 'x' rejected */
84 return 2;
85}]])],
86 [gl_cv_func_fopen_mode_x=yes],
87 [gl_cv_func_fopen_mode_x=no],
88 [case "$host_os" in
89 # Guess yes on glibc and musl systems.
90 linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl*)
91 gl_cv_func_fopen_mode_x="guessing yes" ;;
92 # If we don't know, obey --enable-cross-guesses.
93 *)
94 gl_cv_func_fopen_mode_x="$gl_cross_guess_normal" ;;
95 esac
96 ])
97 rm -f conftest.x
98 ])
99 AC_CACHE_CHECK([whether fopen supports the mode character 'e'],
100 [gl_cv_func_fopen_mode_e],
101 [echo foo > conftest.x
102 AC_RUN_IFELSE(
103 [AC_LANG_SOURCE([[
104#include <stdio.h>
105#include <errno.h>
106#include <fcntl.h>
107]GL_MDA_DEFINES[
108int main ()
109{
110 FILE *fp = fopen ("conftest.x", "re");
111 if (fp != NULL)
112 {
113 if (fcntl (fileno (fp), F_GETFD) & FD_CLOEXEC)
114 return 0;
115 else
116 /* 'e' ignored */
117 return 1;
118 }
119 else
120 /* 'e' rejected */
121 return 2;
122}]])],
123 [gl_cv_func_fopen_mode_e=yes],
124 [gl_cv_func_fopen_mode_e=no],
125 [case "$host_os" in
126 # Guess yes on glibc and musl systems.
127 linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl*)
128 gl_cv_func_fopen_mode_e="guessing yes" ;;
129 # Guess no on native Windows.
130 mingw*)
131 gl_cv_func_fopen_mode_e="guessing no" ;;
132 # If we don't know, obey --enable-cross-guesses.
133 *)
134 gl_cv_func_fopen_mode_e="$gl_cross_guess_normal" ;;
135 esac
136 ])
137 rm -f conftest.x
138 ])
139 REPLACE_FOPEN_FOR_FOPEN_GNU="$REPLACE_FOPEN"
140 case "$gl_cv_func_fopen_mode_x" in
141 *no) REPLACE_FOPEN_FOR_FOPEN_GNU=1 ;;
142 esac
143 case "$gl_cv_func_fopen_mode_e" in
144 *no) REPLACE_FOPEN_FOR_FOPEN_GNU=1 ;;
145 esac
146])
147
148# Prerequisites of lib/fopen.c.
149AC_DEFUN([gl_PREREQ_FOPEN], [:])
diff --git a/gl/m4/fpurge.m4 b/gl/m4/fpurge.m4
new file mode 100644
index 00000000..b365409d
--- /dev/null
+++ b/gl/m4/fpurge.m4
@@ -0,0 +1,73 @@
1# fpurge.m4 serial 12
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FPURGE],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
11 AC_CHECK_HEADERS_ONCE([stdio_ext.h])
12 AC_CHECK_FUNCS_ONCE([fpurge])
13 AC_CHECK_FUNCS_ONCE([__fpurge])
14 AC_CHECK_DECLS([fpurge], , , [[#include <stdio.h>]])
15 if test "x$ac_cv_func_fpurge" = xyes; then
16 HAVE_FPURGE=1
17 # Detect BSD bug. Only cygwin 1.7 and musl are known to be immune.
18 AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works],
19 [AC_RUN_IFELSE(
20 [AC_LANG_PROGRAM(
21 [[#include <stdio.h>
22]],
23 [[FILE *f = fopen ("conftest.txt", "w+");
24 if (!f)
25 return 1;
26 if (fputc ('a', f) != 'a')
27 { fclose (f); return 2; }
28 rewind (f);
29 if (fgetc (f) != 'a')
30 { fclose (f); return 3; }
31 if (fgetc (f) != EOF)
32 { fclose (f); return 4; }
33 if (fpurge (f) != 0)
34 { fclose (f); return 5; }
35 if (putc ('b', f) != 'b')
36 { fclose (f); return 6; }
37 if (fclose (f) != 0)
38 return 7;
39 if ((f = fopen ("conftest.txt", "r")) == NULL)
40 return 8;
41 if (fgetc (f) != 'a')
42 { fclose (f); return 9; }
43 if (fgetc (f) != 'b')
44 { fclose (f); return 10; }
45 if (fgetc (f) != EOF)
46 { fclose (f); return 11; }
47 if (fclose (f) != 0)
48 return 12;
49 if (remove ("conftest.txt") != 0)
50 return 13;
51 return 0;
52 ]])],
53 [gl_cv_func_fpurge_works=yes],
54 [gl_cv_func_fpurge_works=no],
55 [case "$host_os" in
56 # Guess yes on musl systems.
57 *-musl*) gl_cv_func_fpurge_works="guessing yes" ;;
58 # Otherwise obey --enable-cross-guesses.
59 *) gl_cv_func_fpurge_works="$gl_cross_guess_normal" ;;
60 esac
61 ])
62 ])
63 case "$gl_cv_func_fpurge_works" in
64 *yes) ;;
65 *) REPLACE_FPURGE=1 ;;
66 esac
67 else
68 HAVE_FPURGE=0
69 fi
70 if test "x$ac_cv_have_decl_fpurge" = xno; then
71 HAVE_DECL_FPURGE=0
72 fi
73])
diff --git a/gl/m4/sha1.m4 b/gl/m4/freading.m4
index 21c775e3..35333369 100644
--- a/gl/m4/sha1.m4
+++ b/gl/m4/freading.m4
@@ -1,12 +1,11 @@
1# sha1.m4 serial 11 1# freading.m4 serial 2
2dnl Copyright (C) 2002-2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_SHA1], 7AC_DEFUN([gl_FUNC_FREADING],
8[ 8[
9 dnl Prerequisites of lib/sha1.c. 9 AC_CHECK_HEADERS_ONCE([stdio_ext.h])
10 AC_REQUIRE([gl_BIGENDIAN]) 10 AC_CHECK_FUNCS_ONCE([__freading])
11 :
12]) 11])
diff --git a/gl/m4/free.m4 b/gl/m4/free.m4
new file mode 100644
index 00000000..0389dea3
--- /dev/null
+++ b/gl/m4/free.m4
@@ -0,0 +1,52 @@
1# free.m4 serial 6
2# Copyright (C) 2003-2005, 2009-2023 Free Software Foundation, Inc.
3# This file is free software; the Free Software Foundation
4# gives unlimited permission to copy and/or distribute it,
5# with or without modifications, as long as this notice is preserved.
6
7# Written by Paul Eggert and Bruno Haible.
8
9AC_DEFUN([gl_FUNC_FREE],
10[
11 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
12
13 dnl In the next release of POSIX, free must preserve errno.
14 dnl https://www.austingroupbugs.net/view.php?id=385
15 dnl https://sourceware.org/bugzilla/show_bug.cgi?id=17924
16 dnl So far, we know of three platforms that do this:
17 dnl * glibc >= 2.33, thanks to the fix for this bug:
18 dnl <https://sourceware.org/bugzilla/show_bug.cgi?id=17924>
19 dnl * OpenBSD >= 4.5, thanks to this commit:
20 dnl <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdlib/malloc.c.diff?r1=1.100&r2=1.101&f=h>
21 dnl * Solaris, because its malloc() implementation is based on brk(),
22 dnl not mmap(); hence its free() implementation makes no system calls.
23 dnl For other platforms, you can only be sure if they state it in their
24 dnl documentation, or by code inspection of the free() implementation in libc.
25 AC_CACHE_CHECK([whether free is known to preserve errno],
26 [gl_cv_func_free_preserves_errno],
27 [AC_COMPILE_IFELSE(
28 [AC_LANG_PROGRAM(
29 [[#include <stdlib.h>
30 ]],
31 [[#if 2 < __GLIBC__ + (33 <= __GLIBC_MINOR__)
32 #elif defined __OpenBSD__
33 #elif defined __sun
34 #else
35 #error "'free' is not known to preserve errno"
36 #endif
37 ]])],
38 [gl_cv_func_free_preserves_errno=yes],
39 [gl_cv_func_free_preserves_errno=no])
40 ])
41
42 case $gl_cv_func_free_preserves_errno in
43 *yes)
44 AC_DEFINE([HAVE_FREE_POSIX], [1],
45 [Define if the 'free' function is guaranteed to preserve errno.])
46 ;;
47 *) REPLACE_FREE=1 ;;
48 esac
49])
50
51# Prerequisites of lib/free.c.
52AC_DEFUN([gl_PREREQ_FREE], [:])
diff --git a/gl/m4/fseek.m4 b/gl/m4/fseek.m4
new file mode 100644
index 00000000..c5fe688c
--- /dev/null
+++ b/gl/m4/fseek.m4
@@ -0,0 +1,15 @@
1# fseek.m4 serial 4
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FSEEK],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_FSEEKO])
11 dnl When fseeko needs fixes, fseek needs them too.
12 if test $HAVE_FSEEKO = 0 || test $REPLACE_FSEEKO = 1; then
13 REPLACE_FSEEK=1
14 fi
15])
diff --git a/gl/m4/fseeko.m4 b/gl/m4/fseeko.m4
new file mode 100644
index 00000000..05ee06bc
--- /dev/null
+++ b/gl/m4/fseeko.m4
@@ -0,0 +1,77 @@
1# fseeko.m4 serial 20
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FSEEKO],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
11 AC_REQUIRE([gl_SYS_TYPES_H])
12 AC_REQUIRE([AC_PROG_CC])
13
14 dnl Persuade glibc <stdio.h> to declare fseeko().
15 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
16
17 AC_CACHE_CHECK([for fseeko], [gl_cv_func_fseeko],
18 [
19 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
20]], [[fseeko (stdin, 0, 0);]])],
21 [gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
22 ])
23
24 AC_CHECK_DECLS_ONCE([fseeko])
25 if test $ac_cv_have_decl_fseeko = no; then
26 HAVE_DECL_FSEEKO=0
27 fi
28
29 if test $gl_cv_func_fseeko = no; then
30 HAVE_FSEEKO=0
31 else
32 if test $WINDOWS_64_BIT_OFF_T = 1; then
33 REPLACE_FSEEKO=1
34 fi
35 if test $gl_cv_var_stdin_large_offset = no; then
36 REPLACE_FSEEKO=1
37 fi
38 m4_ifdef([gl_FUNC_FFLUSH_STDIN], [
39 gl_FUNC_FFLUSH_STDIN
40 case "$gl_cv_func_fflush_stdin" in
41 *yes) ;;
42 *) REPLACE_FSEEKO=1 ;;
43 esac
44 ])
45 fi
46])
47
48dnl Code shared by fseeko and ftello. Determine if large files are supported,
49dnl but stdin does not start as a large file by default.
50AC_DEFUN([gl_STDIN_LARGE_OFFSET],
51 [
52 AC_CACHE_CHECK([whether stdin defaults to large file offsets],
53 [gl_cv_var_stdin_large_offset],
54 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
55[[#if defined __SL64 && defined __SCLE /* cygwin */
56 /* Cygwin 1.5.24 and earlier fail to put stdin in 64-bit mode, making
57 fseeko/ftello needlessly fail. This bug was fixed in 1.5.25, and
58 it is easier to do a version check than building a runtime test. */
59# include <cygwin/version.h>
60# if CYGWIN_VERSION_DLL_COMBINED < CYGWIN_VERSION_DLL_MAKE_COMBINED (1005, 25)
61 choke me
62# endif
63#endif]])],
64 [gl_cv_var_stdin_large_offset=yes],
65 [gl_cv_var_stdin_large_offset=no])])
66])
67
68# Prerequisites of lib/fseeko.c.
69AC_DEFUN([gl_PREREQ_FSEEKO],
70[
71 dnl Native Windows has the function _fseeki64. mingw hides it in some
72 dnl circumstances, but mingw64 makes it usable again.
73 AC_CHECK_FUNCS([_fseeki64])
74 if test $ac_cv_func__fseeki64 = yes; then
75 AC_CHECK_DECLS([_fseeki64])
76 fi
77])
diff --git a/gl/m4/fstat.m4 b/gl/m4/fstat.m4
new file mode 100644
index 00000000..7cb2edb0
--- /dev/null
+++ b/gl/m4/fstat.m4
@@ -0,0 +1,40 @@
1# fstat.m4 serial 8
2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FSTAT],
8[
9 AC_REQUIRE([AC_CANONICAL_HOST])
10 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
11
12 case "$host_os" in
13 mingw* | solaris*)
14 dnl On MinGW, the original stat() returns st_atime, st_mtime,
15 dnl st_ctime values that are affected by the time zone.
16 dnl Solaris stat can return a negative tv_nsec.
17 REPLACE_FSTAT=1
18 ;;
19 esac
20
21 dnl Replace fstat() for supporting the gnulib-defined open() on directories.
22 m4_ifdef([gl_FUNC_FCHDIR], [
23 gl_TEST_FCHDIR
24 if test $HAVE_FCHDIR = 0; then
25 case "$gl_cv_func_open_directory_works" in
26 *yes) ;;
27 *)
28 REPLACE_FSTAT=1
29 ;;
30 esac
31 fi
32 ])
33])
34
35# Prerequisites of lib/fstat.c and lib/stat-w32.c.
36AC_DEFUN([gl_PREREQ_FSTAT], [
37 AC_REQUIRE([gl_SYS_STAT_H])
38 AC_REQUIRE([gl_PREREQ_STAT_W32])
39 :
40])
diff --git a/gl/m4/fstypename.m4 b/gl/m4/fstypename.m4
index c72ecb80..f65c459f 100644
--- a/gl/m4/fstypename.m4
+++ b/gl/m4/fstypename.m4
@@ -6,7 +6,7 @@ dnl See if struct statfs has the f_fstypename member.
6dnl If so, define HAVE_STRUCT_STATFS_F_FSTYPENAME. 6dnl If so, define HAVE_STRUCT_STATFS_F_FSTYPENAME.
7dnl 7dnl
8 8
9# Copyright (C) 1998-1999, 2001, 2004, 2006, 2009-2013 Free Software 9# Copyright (C) 1998-1999, 2001, 2004, 2006, 2009-2023 Free Software
10# Foundation, Inc. 10# Foundation, Inc.
11# This file is free software; the Free Software Foundation 11# This file is free software; the Free Software Foundation
12# gives unlimited permission to copy and/or distribute it, 12# gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/fsusage.m4 b/gl/m4/fsusage.m4
index 6277bfa5..88f3ca81 100644
--- a/gl/m4/fsusage.m4
+++ b/gl/m4/fsusage.m4
@@ -1,7 +1,7 @@
1# serial 30 1# serial 35
2# Obtaining file system usage information. 2# Obtaining file system usage information.
3 3
4# Copyright (C) 1997-1998, 2000-2001, 2003-2013 Free Software Foundation, Inc. 4# Copyright (C) 1997-1998, 2000-2001, 2003-2023 Free Software Foundation, Inc.
5# 5#
6# This file is free software; the Free Software Foundation 6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it, 7# gives unlimited permission to copy and/or distribute it,
@@ -29,27 +29,29 @@ AC_DEFUN([gl_FSUSAGE],
29 29
30AC_DEFUN([gl_FILE_SYSTEM_USAGE], 30AC_DEFUN([gl_FILE_SYSTEM_USAGE],
31[ 31[
32dnl Enable large-file support. This has the effect of changing the size 32 dnl Enable large-file support. This has the effect of changing the size
33dnl of field f_blocks in 'struct statvfs' from 32 bit to 64 bit on 33 dnl of field f_blocks in 'struct statvfs' from 32 bit to 64 bit on
34dnl glibc/Hurd, HP-UX 11, Solaris (32-bit mode). It also changes the size 34 dnl glibc/Hurd, HP-UX 11, Solaris (32-bit mode). It also changes the size
35dnl of field f_blocks in 'struct statfs' from 32 bit to 64 bit on 35 dnl of field f_blocks in 'struct statfs' from 32 bit to 64 bit on
36dnl Mac OS X >= 10.5 (32-bit mode). 36 dnl Mac OS X >= 10.5 (32-bit mode).
37AC_REQUIRE([AC_SYS_LARGEFILE]) 37 AC_REQUIRE([AC_SYS_LARGEFILE])
38 38
39AC_MSG_NOTICE([checking how to get file system space usage]) 39 ac_fsusage_space=no
40ac_fsusage_space=no
41 40
42# Perform only the link test since it seems there are no variants of the 41 # Perform only the link test since it seems there are no variants of the
43# statvfs function. This check is more than just AC_CHECK_FUNCS([statvfs]) 42 # statvfs function. This check is more than just AC_CHECK_FUNCS([statvfs])
44# because that got a false positive on SCO OSR5. Adding the declaration 43 # because that got a false positive on SCO OSR5. Adding the declaration
45# of a 'struct statvfs' causes this test to fail (as it should) on such 44 # of a 'struct statvfs' causes this test to fail (as it should) on such
46# systems. That system is reported to work fine with STAT_STATFS4 which 45 # systems. That system is reported to work fine with STAT_STATFS4 which
47# is what it gets when this test fails. 46 # is what it gets when this test fails.
48if test $ac_fsusage_space = no; then 47 if test $ac_fsusage_space = no; then
49 # glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0, 48 # glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0,
50 # OpenBSD >= 4.4, AIX, HP-UX, IRIX, Solaris, Cygwin, Interix, BeOS. 49 # OpenBSD >= 4.4, AIX, HP-UX, IRIX, Solaris, Cygwin, Interix, BeOS.
51 AC_CACHE_CHECK([for statvfs function (SVR4)], [fu_cv_sys_stat_statvfs], 50 AC_CACHE_CHECK([for statvfs function (SVR4)],
52 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 51 [fu_cv_sys_stat_statvfs],
52 [AC_LINK_IFELSE(
53 [AC_LANG_PROGRAM([[
54#include <sys/types.h>
53#ifdef __osf__ 55#ifdef __osf__
54"Do not use Tru64's statvfs implementation" 56"Do not use Tru64's statvfs implementation"
55#endif 57#endif
@@ -68,45 +70,47 @@ struct statvfs fsd;
68int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1]; 70int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1];
69#endif 71#endif
70]], 72]],
71 [[statvfs (0, &fsd);]])], 73 [[statvfs (0, &fsd);]])],
72 [fu_cv_sys_stat_statvfs=yes], 74 [fu_cv_sys_stat_statvfs=yes],
73 [fu_cv_sys_stat_statvfs=no])]) 75 [fu_cv_sys_stat_statvfs=no])
74 if test $fu_cv_sys_stat_statvfs = yes; then
75 ac_fsusage_space=yes
76 # AIX >= 5.2 has statvfs64 that has a wider f_blocks field than statvfs.
77 # glibc, HP-UX, IRIX, Solaris have statvfs64 as well, but on these systems
78 # statvfs with large-file support is already equivalent to statvfs64.
79 AC_CACHE_CHECK([whether to use statvfs64],
80 [fu_cv_sys_stat_statvfs64],
81 [AC_LINK_IFELSE(
82 [AC_LANG_PROGRAM(
83 [[#include <sys/types.h>
84 #include <sys/statvfs.h>
85 struct statvfs64 fsd;
86 int check_f_blocks_larger_in_statvfs64
87 [sizeof (((struct statvfs64 *) 0)->f_blocks)
88 > sizeof (((struct statvfs *) 0)->f_blocks)
89 ? 1 : -1];
90 ]],
91 [[statvfs64 (0, &fsd);]])],
92 [fu_cv_sys_stat_statvfs64=yes],
93 [fu_cv_sys_stat_statvfs64=no])
94 ]) 76 ])
95 if test $fu_cv_sys_stat_statvfs64 = yes; then 77 if test $fu_cv_sys_stat_statvfs = yes; then
96 AC_DEFINE([STAT_STATVFS64], [1], 78 ac_fsusage_space=yes
97 [ Define if statvfs64 should be preferred over statvfs.]) 79 # AIX >= 5.2 has statvfs64 that has a wider f_blocks field than statvfs.
98 else 80 # glibc, HP-UX, IRIX, Solaris have statvfs64 as well, but on these systems
99 AC_DEFINE([STAT_STATVFS], [1], 81 # statvfs with large-file support is already equivalent to statvfs64.
100 [ Define if there is a function named statvfs. (SVR4)]) 82 AC_CACHE_CHECK([whether to use statvfs64],
83 [fu_cv_sys_stat_statvfs64],
84 [AC_LINK_IFELSE(
85 [AC_LANG_PROGRAM(
86 [[#include <sys/types.h>
87 #include <sys/statvfs.h>
88 struct statvfs64 fsd;
89 int check_f_blocks_larger_in_statvfs64
90 [sizeof (((struct statvfs64 *) 0)->f_blocks)
91 > sizeof (((struct statvfs *) 0)->f_blocks)
92 ? 1 : -1];
93 ]],
94 [[statvfs64 (0, &fsd);]])],
95 [fu_cv_sys_stat_statvfs64=yes],
96 [fu_cv_sys_stat_statvfs64=no])
97 ])
98 if test $fu_cv_sys_stat_statvfs64 = yes; then
99 AC_DEFINE([STAT_STATVFS64], [1],
100 [Define if statvfs64 should be preferred over statvfs.])
101 else
102 AC_DEFINE([STAT_STATVFS], [1],
103 [Define if there is a function named statvfs. (SVR4)])
104 fi
101 fi 105 fi
102 fi 106 fi
103fi
104 107
105# Check for this unconditionally so we have a 108 # Check for this unconditionally so we have a
106# good fallback on glibc/Linux > 2.6 < 2.6.36 109 # good fallback on glibc/Linux > 2.6 < 2.6.36
107AC_MSG_CHECKING([for two-argument statfs with statfs.f_frsize member]) 110 AC_CACHE_CHECK([for two-argument statfs with statfs.f_frsize member],
108AC_CACHE_VAL([fu_cv_sys_stat_statfs2_frsize], 111 [fu_cv_sys_stat_statfs2_frsize],
109[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 112 [AC_RUN_IFELSE(
113 [AC_LANG_SOURCE([[
110#ifdef HAVE_SYS_PARAM_H 114#ifdef HAVE_SYS_PARAM_H
111#include <sys/param.h> 115#include <sys/param.h>
112#endif 116#endif
@@ -119,26 +123,26 @@ AC_CACHE_VAL([fu_cv_sys_stat_statfs2_frsize],
119 int 123 int
120 main () 124 main ()
121 { 125 {
122 struct statfs fsd; 126 struct statfs fsd;
123 fsd.f_frsize = 0; 127 fsd.f_frsize = 0;
124 return statfs (".", &fsd) != 0; 128 return statfs (".", &fsd) != 0;
125 }]])], 129 }]])],
126 [fu_cv_sys_stat_statfs2_frsize=yes], 130 [fu_cv_sys_stat_statfs2_frsize=yes],
127 [fu_cv_sys_stat_statfs2_frsize=no], 131 [fu_cv_sys_stat_statfs2_frsize=no],
128 [fu_cv_sys_stat_statfs2_frsize=no])]) 132 [fu_cv_sys_stat_statfs2_frsize=no])
129AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_frsize]) 133 ])
130if test $fu_cv_sys_stat_statfs2_frsize = yes; then 134 if test $fu_cv_sys_stat_statfs2_frsize = yes; then
131 ac_fsusage_space=yes 135 ac_fsusage_space=yes
132 AC_DEFINE([STAT_STATFS2_FRSIZE], [1], 136 AC_DEFINE([STAT_STATFS2_FRSIZE], [1],
133[ Define if statfs takes 2 args and struct statfs has a field named f_frsize. 137 [Define if statfs takes 2 args and struct statfs has a field named f_frsize.
134 (glibc/Linux > 2.6)]) 138 (glibc/Linux > 2.6)])
135fi 139 fi
136 140
137if test $ac_fsusage_space = no; then 141 if test $ac_fsusage_space = no; then
138 # DEC Alpha running OSF/1 142 # DEC Alpha running OSF/1
139 AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) 143 AC_CACHE_CHECK([for 3-argument statfs function (DEC OSF/1)],
140 AC_CACHE_VAL([fu_cv_sys_stat_statfs3_osf1], 144 [fu_cv_sys_stat_statfs3_osf1],
141 [AC_RUN_IFELSE([AC_LANG_SOURCE([[ 145 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
142#include <sys/param.h> 146#include <sys/param.h>
143#include <sys/types.h> 147#include <sys/types.h>
144#include <sys/mount.h> 148#include <sys/mount.h>
@@ -149,28 +153,27 @@ if test $ac_fsusage_space = no; then
149 fsd.f_fsize = 0; 153 fsd.f_fsize = 0;
150 return statfs (".", &fsd, sizeof (struct statfs)) != 0; 154 return statfs (".", &fsd, sizeof (struct statfs)) != 0;
151 }]])], 155 }]])],
152 [fu_cv_sys_stat_statfs3_osf1=yes], 156 [fu_cv_sys_stat_statfs3_osf1=yes],
153 [fu_cv_sys_stat_statfs3_osf1=no], 157 [fu_cv_sys_stat_statfs3_osf1=no],
154 [fu_cv_sys_stat_statfs3_osf1=no])]) 158 [fu_cv_sys_stat_statfs3_osf1=no])
155 AC_MSG_RESULT([$fu_cv_sys_stat_statfs3_osf1]) 159 ])
156 if test $fu_cv_sys_stat_statfs3_osf1 = yes; then 160 if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
157 ac_fsusage_space=yes 161 ac_fsusage_space=yes
158 AC_DEFINE([STAT_STATFS3_OSF1], [1], 162 AC_DEFINE([STAT_STATFS3_OSF1], [1],
159 [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)]) 163 [Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
164 fi
160 fi 165 fi
161fi
162 166
163if test $ac_fsusage_space = no; then 167 if test $ac_fsusage_space = no; then
164 # glibc/Linux, Mac OS X, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4. 168 # glibc/Linux, Mac OS X, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4.
165 # (glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0, 169 # (glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0,
166 # OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.) 170 # OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.)
167 # (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and 171 # (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and
168 # <sys/vfs.h>.) 172 # <sys/vfs.h>.)
169 # (On Solaris, statfs has 4 arguments.) 173 # (On Solaris, statfs has 4 arguments.)
170 AC_MSG_CHECKING([for two-argument statfs with statfs.f_bsize dnl 174 AC_CACHE_CHECK([for two-argument statfs with statfs.f_bsize member (AIX, 4.3BSD)],
171member (AIX, 4.3BSD)]) 175 [fu_cv_sys_stat_statfs2_bsize],
172 AC_CACHE_VAL([fu_cv_sys_stat_statfs2_bsize], 176 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
173 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
174#ifdef HAVE_SYS_PARAM_H 177#ifdef HAVE_SYS_PARAM_H
175#include <sys/param.h> 178#include <sys/param.h>
176#endif 179#endif
@@ -183,88 +186,56 @@ member (AIX, 4.3BSD)])
183 int 186 int
184 main () 187 main ()
185 { 188 {
186 struct statfs fsd; 189 struct statfs fsd;
187 fsd.f_bsize = 0; 190 fsd.f_bsize = 0;
188 return statfs (".", &fsd) != 0; 191 return statfs (".", &fsd) != 0;
189 }]])], 192 }]])],
190 [fu_cv_sys_stat_statfs2_bsize=yes], 193 [fu_cv_sys_stat_statfs2_bsize=yes],
191 [fu_cv_sys_stat_statfs2_bsize=no], 194 [fu_cv_sys_stat_statfs2_bsize=no],
192 [fu_cv_sys_stat_statfs2_bsize=no])]) 195 [fu_cv_sys_stat_statfs2_bsize=no])
193 AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_bsize]) 196 ])
194 if test $fu_cv_sys_stat_statfs2_bsize = yes; then 197 if test $fu_cv_sys_stat_statfs2_bsize = yes; then
195 ac_fsusage_space=yes 198 ac_fsusage_space=yes
196 AC_DEFINE([STAT_STATFS2_BSIZE], [1], 199 AC_DEFINE([STAT_STATFS2_BSIZE], [1],
197[ Define if statfs takes 2 args and struct statfs has a field named f_bsize. 200 [Define if statfs takes 2 args and struct statfs has a field named f_bsize.
198 (4.3BSD, SunOS 4, HP-UX, AIX PS/2)]) 201 (4.3BSD, SunOS 4, HP-UX)])
202 fi
199 fi 203 fi
200fi
201 204
202if test $ac_fsusage_space = no; then 205 if test $ac_fsusage_space = no; then
203 # SVR3 206 # SVR3
204 # (Solaris already handled above.) 207 # (Solaris already handled above.)
205 AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)]) 208 AC_CACHE_CHECK([for four-argument statfs (SVR3)],
206 AC_CACHE_VAL([fu_cv_sys_stat_statfs4], 209 [fu_cv_sys_stat_statfs4],
207 [AC_RUN_IFELSE([AC_LANG_SOURCE([[ 210 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
208#include <sys/types.h> 211#include <sys/types.h>
209#include <sys/statfs.h> 212#include <sys/statfs.h>
210 int 213 int
211 main () 214 main ()
212 { 215 {
213 struct statfs fsd; 216 struct statfs fsd;
214 return statfs (".", &fsd, sizeof fsd, 0) != 0; 217 return statfs (".", &fsd, sizeof fsd, 0) != 0;
215 }]])],
216 [fu_cv_sys_stat_statfs4=yes],
217 [fu_cv_sys_stat_statfs4=no],
218 [fu_cv_sys_stat_statfs4=no])])
219 AC_MSG_RESULT([$fu_cv_sys_stat_statfs4])
220 if test $fu_cv_sys_stat_statfs4 = yes; then
221 ac_fsusage_space=yes
222 AC_DEFINE([STAT_STATFS4], [1],
223 [ Define if statfs takes 4 args. (SVR3, Dynix, old Irix, old AIX, Dolphin)])
224 fi
225fi
226
227if test $ac_fsusage_space = no; then
228 # 4.4BSD and older NetBSD
229 # (OSF/1 already handled above.)
230 # (On AIX, you need to include <sys/statfs.h>, not only <sys/mount.h>.)
231 # (On Solaris, statfs has 4 arguments and 'struct statfs' is not declared in
232 # <sys/mount.h>.)
233 AC_MSG_CHECKING([for two-argument statfs with statfs.f_fsize dnl
234member (4.4BSD and NetBSD)])
235 AC_CACHE_VAL([fu_cv_sys_stat_statfs2_fsize],
236 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
237#include <sys/types.h>
238#ifdef HAVE_SYS_PARAM_H
239#include <sys/param.h>
240#endif
241#ifdef HAVE_SYS_MOUNT_H
242#include <sys/mount.h>
243#endif
244 int
245 main ()
246 {
247 struct statfs fsd;
248 fsd.f_fsize = 0;
249 return statfs (".", &fsd) != 0;
250 }]])], 218 }]])],
251 [fu_cv_sys_stat_statfs2_fsize=yes], 219 [fu_cv_sys_stat_statfs4=yes],
252 [fu_cv_sys_stat_statfs2_fsize=no], 220 [fu_cv_sys_stat_statfs4=no],
253 [fu_cv_sys_stat_statfs2_fsize=no])]) 221 [fu_cv_sys_stat_statfs4=no])
254 AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_fsize]) 222 ])
255 if test $fu_cv_sys_stat_statfs2_fsize = yes; then 223 if test $fu_cv_sys_stat_statfs4 = yes; then
256 ac_fsusage_space=yes 224 ac_fsusage_space=yes
257 AC_DEFINE([STAT_STATFS2_FSIZE], [1], 225 AC_DEFINE([STAT_STATFS4], [1],
258[ Define if statfs takes 2 args and struct statfs has a field named f_fsize. 226 [Define if statfs takes 4 args. (SVR3, old Irix)])
259 (4.4BSD, NetBSD)]) 227 fi
260 fi 228 fi
261fi
262 229
263if test $ac_fsusage_space = no; then 230 if test $ac_fsusage_space = no; then
264 # Ultrix 231 # 4.4BSD and older NetBSD
265 AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)]) 232 # (OSF/1 already handled above.)
266 AC_CACHE_VAL([fu_cv_sys_stat_fs_data], 233 # (On AIX, you need to include <sys/statfs.h>, not only <sys/mount.h>.)
267 [AC_RUN_IFELSE([AC_LANG_SOURCE([[ 234 # (On Solaris, statfs has 4 arguments and 'struct statfs' is not declared in
235 # <sys/mount.h>.)
236 AC_CACHE_CHECK([for two-argument statfs with statfs.f_fsize member (4.4BSD and NetBSD)],
237 [fu_cv_sys_stat_statfs2_fsize],
238 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
268#include <sys/types.h> 239#include <sys/types.h>
269#ifdef HAVE_SYS_PARAM_H 240#ifdef HAVE_SYS_PARAM_H
270#include <sys/param.h> 241#include <sys/param.h>
@@ -272,41 +243,26 @@ if test $ac_fsusage_space = no; then
272#ifdef HAVE_SYS_MOUNT_H 243#ifdef HAVE_SYS_MOUNT_H
273#include <sys/mount.h> 244#include <sys/mount.h>
274#endif 245#endif
275#ifdef HAVE_SYS_FS_TYPES_H
276#include <sys/fs_types.h>
277#endif
278 int 246 int
279 main () 247 main ()
280 { 248 {
281 struct fs_data fsd; 249 struct statfs fsd;
282 /* Ultrix's statfs returns 1 for success, 250 fsd.f_fsize = 0;
283 0 for not mounted, -1 for failure. */ 251 return statfs (".", &fsd) != 0;
284 return statfs (".", &fsd) != 1;
285 }]])], 252 }]])],
286 [fu_cv_sys_stat_fs_data=yes], 253 [fu_cv_sys_stat_statfs2_fsize=yes],
287 [fu_cv_sys_stat_fs_data=no], 254 [fu_cv_sys_stat_statfs2_fsize=no],
288 [fu_cv_sys_stat_fs_data=no])]) 255 [fu_cv_sys_stat_statfs2_fsize=no])
289 AC_MSG_RESULT([$fu_cv_sys_stat_fs_data]) 256 ])
290 if test $fu_cv_sys_stat_fs_data = yes; then 257 if test $fu_cv_sys_stat_statfs2_fsize = yes; then
291 ac_fsusage_space=yes 258 ac_fsusage_space=yes
292 AC_DEFINE([STAT_STATFS2_FS_DATA], [1], 259 AC_DEFINE([STAT_STATFS2_FSIZE], [1],
293[ Define if statfs takes 2 args and the second argument has 260 [Define if statfs takes 2 args and struct statfs has a field named f_fsize.
294 type struct fs_data. (Ultrix)]) 261 (4.4BSD, NetBSD)])
262 fi
295 fi 263 fi
296fi
297 264
298if test $ac_fsusage_space = no; then 265 AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
299 # SVR2
300 # (AIX, HP-UX, OSF/1 already handled above.)
301 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <sys/filsys.h>
302 ]])],
303 [AC_DEFINE([STAT_READ_FILSYS], [1],
304 [Define if there is no specific function for reading file systems usage
305 information and you have the <sys/filsys.h> header file. (SVR2)])
306 ac_fsusage_space=yes])
307fi
308
309AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
310 266
311]) 267])
312 268
@@ -316,18 +272,22 @@ AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
316# enable the work-around code in fsusage.c. 272# enable the work-around code in fsusage.c.
317AC_DEFUN([gl_STATFS_TRUNCATES], 273AC_DEFUN([gl_STATFS_TRUNCATES],
318[ 274[
319 AC_MSG_CHECKING([for statfs that truncates block counts]) 275 AC_CACHE_CHECK([for statfs that truncates block counts],
320 AC_CACHE_VAL([fu_cv_sys_truncating_statfs], 276 [fu_cv_sys_truncating_statfs],
321 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 277 [AC_COMPILE_IFELSE(
278 [AC_LANG_PROGRAM([[
322#if !defined(sun) && !defined(__sun) 279#if !defined(sun) && !defined(__sun)
323choke -- this is a workaround for a Sun-specific problem 280choke -- this is a workaround for a Sun-specific problem
324#endif 281#endif
325#include <sys/types.h> 282#include <sys/types.h>
326#include <sys/vfs.h>]], 283#include <sys/vfs.h>
327 [[struct statfs t; long c = *(t.f_spare); 284 ]],
328 if (c) return 0;]])], 285 [[struct statfs t; long c = *(t.f_spare);
329 [fu_cv_sys_truncating_statfs=yes], 286 if (c) return 0;
330 [fu_cv_sys_truncating_statfs=no])]) 287 ]])],
288 [fu_cv_sys_truncating_statfs=yes],
289 [fu_cv_sys_truncating_statfs=no])
290 ])
331 if test $fu_cv_sys_truncating_statfs = yes; then 291 if test $fu_cv_sys_truncating_statfs = yes; then
332 AC_DEFINE([STATFS_TRUNCATES_BLOCK_COUNTS], [1], 292 AC_DEFINE([STATFS_TRUNCATES_BLOCK_COUNTS], [1],
333 [Define if the block counts reported by statfs may be truncated to 2GB 293 [Define if the block counts reported by statfs may be truncated to 2GB
@@ -335,13 +295,12 @@ choke -- this is a workaround for a Sun-specific problem
335 (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem. 295 (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
336 SunOS 4.1.1 seems not to be affected.)]) 296 SunOS 4.1.1 seems not to be affected.)])
337 fi 297 fi
338 AC_MSG_RESULT([$fu_cv_sys_truncating_statfs])
339]) 298])
340 299
341 300
342# Prerequisites of lib/fsusage.c not done by gl_FILE_SYSTEM_USAGE. 301# Prerequisites of lib/fsusage.c not done by gl_FILE_SYSTEM_USAGE.
343AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA], 302AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA],
344[ 303[
345 AC_CHECK_HEADERS([dustat.h sys/fs/s5param.h sys/filsys.h sys/statfs.h]) 304 AC_CHECK_HEADERS([sys/fs/s5param.h sys/statfs.h])
346 gl_STATFS_TRUNCATES 305 gl_STATFS_TRUNCATES
347]) 306])
diff --git a/gl/m4/ftell.m4 b/gl/m4/ftell.m4
new file mode 100644
index 00000000..79f1aaf2
--- /dev/null
+++ b/gl/m4/ftell.m4
@@ -0,0 +1,15 @@
1# ftell.m4 serial 3
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FTELL],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_FTELLO])
11 dnl When ftello needs fixes, ftell needs them too.
12 if test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1; then
13 REPLACE_FTELL=1
14 fi
15])
diff --git a/gl/m4/ftello.m4 b/gl/m4/ftello.m4
new file mode 100644
index 00000000..4901b168
--- /dev/null
+++ b/gl/m4/ftello.m4
@@ -0,0 +1,151 @@
1# ftello.m4 serial 14
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FTELLO],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_PROG_CC])
11 AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
12 AC_REQUIRE([gl_SYS_TYPES_H])
13
14 dnl Persuade glibc <stdio.h> to declare ftello().
15 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
16
17 AC_CHECK_DECLS_ONCE([ftello])
18 if test $ac_cv_have_decl_ftello = no; then
19 HAVE_DECL_FTELLO=0
20 fi
21
22 AC_CACHE_CHECK([for ftello], [gl_cv_func_ftello],
23 [
24 AC_LINK_IFELSE(
25 [AC_LANG_PROGRAM(
26 [[#include <stdio.h>]],
27 [[ftello (stdin);]])],
28 [gl_cv_func_ftello=yes],
29 [gl_cv_func_ftello=no])
30 ])
31 if test $gl_cv_func_ftello = no; then
32 HAVE_FTELLO=0
33 else
34 if test $WINDOWS_64_BIT_OFF_T = 1; then
35 REPLACE_FTELLO=1
36 fi
37 if test $gl_cv_var_stdin_large_offset = no; then
38 REPLACE_FTELLO=1
39 fi
40 if test $REPLACE_FTELLO = 0; then
41 dnl Detect bug on Solaris.
42 dnl ftell and ftello produce incorrect results after putc that followed a
43 dnl getc call that reached EOF on Solaris. This is because the _IOREAD
44 dnl flag does not get cleared in this case, even though _IOWRT gets set,
45 dnl and ftell and ftello look whether the _IOREAD flag is set.
46 AC_REQUIRE([AC_CANONICAL_HOST])
47 AC_CACHE_CHECK([whether ftello works],
48 [gl_cv_func_ftello_works],
49 [
50 dnl Initial guess, used when cross-compiling or when /dev/tty cannot
51 dnl be opened.
52changequote(,)dnl
53 case "$host_os" in
54 # Guess no on Solaris.
55 solaris*) gl_cv_func_ftello_works="guessing no" ;;
56 # Guess yes on native Windows.
57 mingw*) gl_cv_func_ftello_works="guessing yes" ;;
58 # Guess yes otherwise.
59 *) gl_cv_func_ftello_works="guessing yes" ;;
60 esac
61changequote([,])dnl
62 AC_RUN_IFELSE(
63 [AC_LANG_SOURCE([[
64#include <stdio.h>
65#include <stdlib.h>
66#include <string.h>
67#define TESTFILE "conftest.tmp"
68int
69main (void)
70{
71 FILE *fp;
72
73 /* Create a file with some contents. */
74 fp = fopen (TESTFILE, "w");
75 if (fp == NULL)
76 return 70;
77 if (fwrite ("foogarsh", 1, 8, fp) < 8)
78 { fclose (fp); return 71; }
79 if (fclose (fp))
80 return 72;
81
82 /* The file's contents is now "foogarsh". */
83
84 /* Try writing after reading to EOF. */
85 fp = fopen (TESTFILE, "r+");
86 if (fp == NULL)
87 return 73;
88 if (fseek (fp, -1, SEEK_END))
89 { fclose (fp); return 74; }
90 if (!(getc (fp) == 'h'))
91 { fclose (fp); return 1; }
92 if (!(getc (fp) == EOF))
93 { fclose (fp); return 2; }
94 if (!(ftell (fp) == 8))
95 { fclose (fp); return 3; }
96 if (!(ftell (fp) == 8))
97 { fclose (fp); return 4; }
98 if (!(putc ('!', fp) == '!'))
99 { fclose (fp); return 5; }
100 if (!(ftell (fp) == 9))
101 { fclose (fp); return 6; }
102 if (!(fclose (fp) == 0))
103 return 7;
104 fp = fopen (TESTFILE, "r");
105 if (fp == NULL)
106 return 75;
107 {
108 char buf[10];
109 if (!(fread (buf, 1, 10, fp) == 9))
110 { fclose (fp); return 10; }
111 if (!(memcmp (buf, "foogarsh!", 9) == 0))
112 { fclose (fp); return 11; }
113 }
114 if (!(fclose (fp) == 0))
115 return 12;
116
117 /* The file's contents is now "foogarsh!". */
118
119 return 0;
120}]])],
121 [gl_cv_func_ftello_works=yes],
122 [gl_cv_func_ftello_works=no], [:])
123 ])
124 case "$gl_cv_func_ftello_works" in
125 *yes) ;;
126 *)
127 REPLACE_FTELLO=1
128 AC_DEFINE([FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE], [1],
129 [Define to 1 if the system's ftello function has the Solaris bug.])
130 ;;
131 esac
132 fi
133 if test $REPLACE_FTELLO = 0; then
134 dnl Detect bug on macOS >= 10.15.
135 gl_FUNC_UNGETC_WORKS
136 if test $gl_ftello_broken_after_ungetc = yes; then
137 REPLACE_FTELLO=1
138 AC_DEFINE([FTELLO_BROKEN_AFTER_UNGETC], [1],
139 [Define to 1 if the system's ftello function has the macOS bug.])
140 fi
141 fi
142 fi
143])
144
145# Prerequisites of lib/ftello.c.
146AC_DEFUN([gl_PREREQ_FTELLO],
147[
148 dnl Native Windows has the function _ftelli64. mingw hides it, but mingw64
149 dnl makes it usable again.
150 AC_CHECK_FUNCS([_ftelli64])
151])
diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4
index 1d631f8c..15f09ffb 100644
--- a/gl/m4/getaddrinfo.m4
+++ b/gl/m4/getaddrinfo.m4
@@ -1,14 +1,13 @@
1# getaddrinfo.m4 serial 30 1# getaddrinfo.m4 serial 34
2dnl Copyright (C) 2004-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2004-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_GETADDRINFO], 7AC_DEFUN([gl_GETADDRINFO],
8[ 8[
9 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 9 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
10 AC_REQUIRE([gl_HEADER_NETDB])dnl for HAVE_NETDB_H 10 AC_REQUIRE([gl_NETDB_H])dnl for HAVE_NETDB_H
11 AC_MSG_NOTICE([checking how to do getaddrinfo, freeaddrinfo and getnameinfo])
12 GETADDRINFO_LIB= 11 GETADDRINFO_LIB=
13 gai_saved_LIBS="$LIBS" 12 gai_saved_LIBS="$LIBS"
14 13
@@ -55,10 +54,40 @@ AC_DEFUN([gl_GETADDRINFO],
55 if test "$gl_cv_w32_getaddrinfo" = "yes"; then 54 if test "$gl_cv_w32_getaddrinfo" = "yes"; then
56 GETADDRINFO_LIB="-lws2_32" 55 GETADDRINFO_LIB="-lws2_32"
57 LIBS="$gai_saved_LIBS $GETADDRINFO_LIB" 56 LIBS="$gai_saved_LIBS $GETADDRINFO_LIB"
57 dnl Check for correct signature, in particular for a cdecl-compatible
58 dnl calling convention.
59 AC_CACHE_CHECK([for getaddrinfo with POSIX signature],
60 [gl_cv_func_getaddrinfo_posix_signature],
61 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
62#include <sys/types.h>
63#ifdef HAVE_SYS_SOCKET_H
64#include <sys/socket.h>
65#endif
66#ifdef HAVE_NETDB_H
67#include <netdb.h>
68#endif
69#ifdef HAVE_WS2TCPIP_H
70#include <ws2tcpip.h>
71#endif
72#include <stddef.h>
73extern
74#ifdef __cplusplus
75"C"
76#endif
77int getaddrinfo (const char *, const char *, const struct addrinfo *, struct addrinfo **);
78]])],
79 [gl_cv_func_getaddrinfo_posix_signature=yes],
80 [gl_cv_func_getaddrinfo_posix_signature=no])
81 ])
82 if test $gl_cv_func_getaddrinfo_posix_signature = no; then
83 REPLACE_GETADDRINFO=1
84 fi
58 else 85 else
59 HAVE_GETADDRINFO=0 86 HAVE_GETADDRINFO=0
60 fi 87 fi
61 fi 88 fi
89 AC_DEFINE_UNQUOTED([HAVE_GETADDRINFO], [$HAVE_GETADDRINFO],
90 [Define to 1 if getaddrinfo exists, or to 0 otherwise.])
62 91
63 # We can't use AC_REPLACE_FUNCS here because gai_strerror may be an 92 # We can't use AC_REPLACE_FUNCS here because gai_strerror may be an
64 # inline function declared in ws2tcpip.h, so we need to get that 93 # inline function declared in ws2tcpip.h, so we need to get that
@@ -127,13 +156,13 @@ const char *gai_strerror(int);]])],
127# Prerequisites of lib/netdb.in.h and lib/getaddrinfo.c. 156# Prerequisites of lib/netdb.in.h and lib/getaddrinfo.c.
128AC_DEFUN([gl_PREREQ_GETADDRINFO], [ 157AC_DEFUN([gl_PREREQ_GETADDRINFO], [
129 AC_REQUIRE([gl_NETDB_H_DEFAULTS]) 158 AC_REQUIRE([gl_NETDB_H_DEFAULTS])
130 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 159 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
131 AC_REQUIRE([gl_HOSTENT]) dnl for HOSTENT_LIB 160 AC_REQUIRE([gl_HOSTENT]) dnl for HOSTENT_LIB
132 AC_REQUIRE([gl_SERVENT]) dnl for SERVENT_LIB 161 AC_REQUIRE([gl_SERVENT]) dnl for SERVENT_LIB
133 AC_REQUIRE([gl_FUNC_INET_NTOP]) dnl for INET_NTOP_LIB 162 AC_REQUIRE([gl_FUNC_INET_NTOP]) dnl for INET_NTOP_LIB
134 AC_REQUIRE([AC_C_RESTRICT]) 163 AC_REQUIRE([AC_C_RESTRICT])
135 AC_REQUIRE([gl_SOCKET_FAMILIES]) 164 AC_REQUIRE([gl_SOCKET_FAMILIES])
136 AC_REQUIRE([gl_HEADER_SYS_SOCKET]) 165 AC_REQUIRE([gl_SYS_SOCKET_H])
137 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 166 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
138 167
139 dnl Including sys/socket.h is wrong for Windows, but Windows does not 168 dnl Including sys/socket.h is wrong for Windows, but Windows does not
diff --git a/gl/m4/getdelim.m4 b/gl/m4/getdelim.m4
new file mode 100644
index 00000000..9aaed202
--- /dev/null
+++ b/gl/m4/getdelim.m4
@@ -0,0 +1,111 @@
1# getdelim.m4 serial 16
2
3dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
4dnl
5dnl This file is free software; the Free Software Foundation
6dnl gives unlimited permission to copy and/or distribute it,
7dnl with or without modifications, as long as this notice is preserved.
8
9AC_PREREQ([2.59])
10
11AC_DEFUN([gl_FUNC_GETDELIM],
12[
13 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
14 AC_REQUIRE([AC_CANONICAL_HOST])
15
16 dnl Persuade glibc <stdio.h> to declare getdelim().
17 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
18
19 AC_CHECK_DECLS_ONCE([getdelim])
20
21 AC_CHECK_FUNCS_ONCE([getdelim])
22 if test $ac_cv_func_getdelim = yes; then
23 HAVE_GETDELIM=1
24 dnl Found it in some library. Verify that it works.
25 AC_CACHE_CHECK([for working getdelim function],
26 [gl_cv_func_working_getdelim],
27 [case "$host_os" in
28 darwin*)
29 dnl On macOS 10.13, valgrind detected an out-of-bounds read during
30 dnl the GNU sed test suite:
31 dnl Invalid read of size 16
32 dnl at 0x100EE6A05: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib)
33 dnl by 0x100B7B0BD: getdelim (in /usr/lib/system/libsystem_c.dylib)
34 dnl by 0x10000B0BE: ck_getdelim (utils.c:254)
35 gl_cv_func_working_getdelim=no ;;
36 *)
37 echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
38 AC_RUN_IFELSE([AC_LANG_SOURCE([[
39# include <stdio.h>
40# include <stdlib.h>
41# include <string.h>
42 int main ()
43 {
44 FILE *in = fopen ("./conftest.data", "r");
45 if (!in)
46 return 1;
47 {
48 /* Test result for a NULL buffer and a zero size.
49 Based on a test program from Karl Heuer. */
50 char *line = NULL;
51 size_t siz = 0;
52 int len = getdelim (&line, &siz, '\n', in);
53 if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
54 { free (line); fclose (in); return 2; }
55 free (line);
56 }
57 {
58 /* Test result for a NULL buffer and a non-zero size.
59 This crashes on FreeBSD 8.0. */
60 char *line = NULL;
61 size_t siz = (size_t)(~0) / 4;
62 if (getdelim (&line, &siz, '\n', in) == -1)
63 { fclose (in); return 3; }
64 free (line);
65 }
66 fclose (in);
67 return 0;
68 }
69 ]])],
70 [gl_cv_func_working_getdelim=yes],
71 [gl_cv_func_working_getdelim=no],
72 [dnl We're cross compiling.
73 dnl Guess it works on glibc2 systems and musl systems.
74 AC_EGREP_CPP([Lucky GNU user],
75 [
76#include <features.h>
77#ifdef __GNU_LIBRARY__
78 #if (__GLIBC__ >= 2) && !defined __UCLIBC__
79 Lucky GNU user
80 #endif
81#endif
82 ],
83 [gl_cv_func_working_getdelim="guessing yes"],
84 [case "$host_os" in
85 *-musl*) gl_cv_func_working_getdelim="guessing yes" ;;
86 *) gl_cv_func_working_getdelim="$gl_cross_guess_normal" ;;
87 esac
88 ])
89 ])
90 ;;
91 esac
92 ])
93 case "$gl_cv_func_working_getdelim" in
94 *yes) ;;
95 *) REPLACE_GETDELIM=1 ;;
96 esac
97 else
98 HAVE_GETDELIM=0
99 fi
100
101 if test $ac_cv_have_decl_getdelim = no; then
102 HAVE_DECL_GETDELIM=0
103 fi
104])
105
106# Prerequisites of lib/getdelim.c.
107AC_DEFUN([gl_PREREQ_GETDELIM],
108[
109 AC_CHECK_FUNCS([flockfile funlockfile])
110 AC_CHECK_DECLS([getc_unlocked])
111])
diff --git a/gl/m4/getdtablesize.m4 b/gl/m4/getdtablesize.m4
new file mode 100644
index 00000000..8bcda905
--- /dev/null
+++ b/gl/m4/getdtablesize.m4
@@ -0,0 +1,63 @@
1# getdtablesize.m4 serial 8
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_GETDTABLESIZE],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 AC_CHECK_FUNCS_ONCE([getdtablesize])
12 AC_CHECK_DECLS_ONCE([getdtablesize])
13 if test $ac_cv_func_getdtablesize = yes &&
14 test $ac_cv_have_decl_getdtablesize = yes; then
15 AC_CACHE_CHECK([whether getdtablesize works],
16 [gl_cv_func_getdtablesize_works],
17 [dnl There are two concepts: the "maximum possible file descriptor value + 1"
18 dnl and the "maximum number of open file descriptors in a process".
19 dnl Per SUSv2 and POSIX, getdtablesize() should return the first one.
20 dnl On most platforms, the first and the second concept are the same.
21 dnl On OpenVMS, however, they are different and getdtablesize() returns
22 dnl the second one; thus the test below fails. But we don't care
23 dnl because there's no good way to write a replacement getdtablesize().
24 case "$host_os" in
25 vms*) gl_cv_func_getdtablesize_works="no (limitation)" ;;
26 *)
27 dnl Cygwin 1.7.25 automatically increases the RLIMIT_NOFILE soft
28 dnl limit up to an unchangeable hard limit; all other platforms
29 dnl correctly require setrlimit before getdtablesize() can report
30 dnl a larger value.
31 AC_RUN_IFELSE([
32 AC_LANG_PROGRAM(
33 [[#include <unistd.h>]
34 GL_MDA_DEFINES
35 ],
36 [[int size = getdtablesize();
37 if (dup2 (0, getdtablesize()) != -1)
38 return 1;
39 if (size != getdtablesize())
40 return 2;
41 ]])],
42 [gl_cv_func_getdtablesize_works=yes],
43 [gl_cv_func_getdtablesize_works=no],
44 [case "$host_os" in
45 cygwin*) # on cygwin 1.5.25, getdtablesize() automatically grows
46 gl_cv_func_getdtablesize_works="guessing no" ;;
47 *) gl_cv_func_getdtablesize_works="guessing yes" ;;
48 esac
49 ])
50 ;;
51 esac
52 ])
53 case "$gl_cv_func_getdtablesize_works" in
54 *yes | "no (limitation)") ;;
55 *) REPLACE_GETDTABLESIZE=1 ;;
56 esac
57 else
58 HAVE_GETDTABLESIZE=0
59 fi
60])
61
62# Prerequisites of lib/getdtablesize.c.
63AC_DEFUN([gl_PREREQ_GETDTABLESIZE], [:])
diff --git a/gl/m4/gethostname.m4 b/gl/m4/gethostname.m4
index 7413f9e3..63f5f636 100644
--- a/gl/m4/gethostname.m4
+++ b/gl/m4/gethostname.m4
@@ -1,5 +1,5 @@
1# gethostname.m4 serial 13 1# gethostname.m4 serial 15
2dnl Copyright (C) 2002, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -48,7 +48,7 @@ AC_DEFUN([gl_PREREQ_HOST_NAME_MAX], [
48 dnl - On most Unix systems, use MAXHOSTNAMELEN from <sys/param.h> instead. 48 dnl - On most Unix systems, use MAXHOSTNAMELEN from <sys/param.h> instead.
49 dnl - On Solaris, Cygwin, BeOS, use MAXHOSTNAMELEN from <netdb.h> instead. 49 dnl - On Solaris, Cygwin, BeOS, use MAXHOSTNAMELEN from <netdb.h> instead.
50 dnl - On mingw, use 256, because 50 dnl - On mingw, use 256, because
51 dnl <http://msdn.microsoft.com/en-us/library/ms738527.aspx> says: 51 dnl <https://docs.microsoft.com/en-us/windows/desktop/api/winsock/nf-winsock-gethostname> says:
52 dnl "if a buffer of 256 bytes is passed in the name parameter and 52 dnl "if a buffer of 256 bytes is passed in the name parameter and
53 dnl the namelen parameter is set to 256, the buffer size will always 53 dnl the namelen parameter is set to 256, the buffer size will always
54 dnl be adequate." 54 dnl be adequate."
@@ -74,7 +74,7 @@ lucky
74 dnl mingw. 74 dnl mingw.
75 gl_cv_decl_HOST_NAME_MAX=256 75 gl_cv_decl_HOST_NAME_MAX=256
76 else 76 else
77 _AC_COMPUTE_INT([MAXHOSTNAMELEN], [gl_cv_decl_HOST_NAME_MAX], [ 77 AC_COMPUTE_INT([gl_cv_decl_HOST_NAME_MAX], [MAXHOSTNAMELEN], [
78#include <sys/types.h> 78#include <sys/types.h>
79#if HAVE_SYS_PARAM_H 79#if HAVE_SYS_PARAM_H
80# include <sys/param.h> 80# include <sys/param.h>
diff --git a/gl/m4/getline.m4 b/gl/m4/getline.m4
new file mode 100644
index 00000000..03569f06
--- /dev/null
+++ b/gl/m4/getline.m4
@@ -0,0 +1,109 @@
1# getline.m4 serial 30
2
3dnl Copyright (C) 1998-2003, 2005-2007, 2009-2023 Free Software Foundation,
4dnl Inc.
5dnl
6dnl This file is free software; the Free Software Foundation
7dnl gives unlimited permission to copy and/or distribute it,
8dnl with or without modifications, as long as this notice is preserved.
9
10AC_PREREQ([2.59])
11
12dnl See if there's a working, system-supplied version of the getline function.
13dnl We can't just do AC_REPLACE_FUNCS([getline]) because some systems
14dnl have a function by that name in -linet that doesn't have anything
15dnl to do with the function we need.
16AC_DEFUN([gl_FUNC_GETLINE],
17[
18 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
19 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
20
21 dnl Persuade glibc <stdio.h> to declare getline().
22 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
23
24 AC_CHECK_DECLS_ONCE([getline])
25
26 gl_getline_needs_run_time_check=no
27 AC_CHECK_FUNC([getline],
28 [dnl Found it in some library. Verify that it works.
29 gl_getline_needs_run_time_check=yes],
30 [am_cv_func_working_getline=no])
31 if test $gl_getline_needs_run_time_check = yes; then
32 AC_CACHE_CHECK([for working getline function],
33 [am_cv_func_working_getline],
34 [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
35 AC_RUN_IFELSE([AC_LANG_SOURCE([[
36# include <stdio.h>
37# include <stdlib.h>
38# include <string.h>
39 int main ()
40 {
41 FILE *in = fopen ("./conftest.data", "r");
42 if (!in)
43 return 1;
44 {
45 /* Test result for a NULL buffer and a zero size.
46 Based on a test program from Karl Heuer. */
47 char *line = NULL;
48 size_t siz = 0;
49 int len = getline (&line, &siz, in);
50 if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
51 { free (line); fclose (in); return 2; }
52 free (line);
53 }
54 {
55 /* Test result for a NULL buffer and a non-zero size.
56 This crashes on FreeBSD 8.0. */
57 char *line = NULL;
58 size_t siz = (size_t)(~0) / 4;
59 if (getline (&line, &siz, in) == -1)
60 { fclose (in); return 3; }
61 free (line);
62 }
63 fclose (in);
64 return 0;
65 }
66 ]])],
67 [am_cv_func_working_getline=yes],
68 [am_cv_func_working_getline=no],
69 [dnl We're cross compiling.
70 dnl Guess it works on glibc2 systems and musl systems.
71 AC_EGREP_CPP([Lucky GNU user],
72 [
73#include <features.h>
74#ifdef __GNU_LIBRARY__
75 #if (__GLIBC__ >= 2) && !defined __UCLIBC__
76 Lucky GNU user
77 #endif
78#endif
79 ],
80 [am_cv_func_working_getline="guessing yes"],
81 [case "$host_os" in
82 *-musl*) am_cv_func_working_getline="guessing yes" ;;
83 *) am_cv_func_working_getline="$gl_cross_guess_normal" ;;
84 esac
85 ])
86 ])
87 ])
88 fi
89
90 if test $ac_cv_have_decl_getline = no; then
91 HAVE_DECL_GETLINE=0
92 fi
93
94 case "$am_cv_func_working_getline" in
95 *yes) ;;
96 *)
97 dnl Set REPLACE_GETLINE always: Even if we have not found the broken
98 dnl getline function among $LIBS, it may exist in libinet and the
99 dnl executable may be linked with -linet.
100 REPLACE_GETLINE=1
101 ;;
102 esac
103])
104
105# Prerequisites of lib/getline.c.
106AC_DEFUN([gl_PREREQ_GETLINE],
107[
108 :
109])
diff --git a/gl/m4/getloadavg.m4 b/gl/m4/getloadavg.m4
index 611372aa..79e420ba 100644
--- a/gl/m4/getloadavg.m4
+++ b/gl/m4/getloadavg.m4
@@ -1,13 +1,13 @@
1# Check for getloadavg. 1# Check for getloadavg.
2 2
3# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2013 Free Software 3# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2023 Free Software
4# Foundation, Inc. 4# Foundation, Inc.
5 5
6# This file is free software; the Free Software Foundation 6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it, 7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved. 8# with or without modifications, as long as this notice is preserved.
9 9
10#serial 6 10#serial 10
11 11
12# Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent. 12# Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent.
13# New applications should use gl_GETLOADAVG instead. 13# New applications should use gl_GETLOADAVG instead.
@@ -22,7 +22,7 @@ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
22 22
23gl_save_LIBS=$LIBS 23gl_save_LIBS=$LIBS
24 24
25# getloadvg is present in libc on glibc >= 2.2, Mac OS X, FreeBSD >= 2.0, 25# getloadavg is present in libc on glibc >= 2.2, Mac OS X, FreeBSD >= 2.0,
26# NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7. 26# NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7.
27HAVE_GETLOADAVG=1 27HAVE_GETLOADAVG=1
28AC_CHECK_FUNC([getloadavg], [], 28AC_CHECK_FUNC([getloadavg], [],
@@ -45,7 +45,9 @@ AC_CHECK_FUNC([getloadavg], [],
45 # There is a commonly available library for RS/6000 AIX. 45 # There is a commonly available library for RS/6000 AIX.
46 # Since it is not a standard part of AIX, it might be installed locally. 46 # Since it is not a standard part of AIX, it might be installed locally.
47 gl_getloadavg_LIBS=$LIBS 47 gl_getloadavg_LIBS=$LIBS
48 LIBS="-L/usr/local/lib $LIBS" 48 if test $cross_compiling != yes; then
49 LIBS="-L/usr/local/lib $LIBS"
50 fi
49 AC_CHECK_LIB([getloadavg], [getloadavg], 51 AC_CHECK_LIB([getloadavg], [getloadavg],
50 [LIBS="-lgetloadavg $LIBS" gl_func_getloadavg_done=yes], 52 [LIBS="-lgetloadavg $LIBS" gl_func_getloadavg_done=yes],
51 [LIBS=$gl_getloadavg_LIBS]) 53 [LIBS=$gl_getloadavg_LIBS])
@@ -92,6 +94,9 @@ else
92fi 94fi
93AC_CHECK_DECL([getloadavg], [], [HAVE_DECL_GETLOADAVG=0], 95AC_CHECK_DECL([getloadavg], [], [HAVE_DECL_GETLOADAVG=0],
94 [[#if HAVE_SYS_LOADAVG_H 96 [[#if HAVE_SYS_LOADAVG_H
97 /* OpenIndiana has a bug: <sys/time.h> must be included before
98 <sys/loadavg.h>. */
99 # include <sys/time.h>
95 # include <sys/loadavg.h> 100 # include <sys/loadavg.h>
96 #endif 101 #endif
97 #include <stdlib.h>]]) 102 #include <stdlib.h>]])
@@ -105,7 +110,7 @@ AC_DEFUN([gl_PREREQ_GETLOADAVG],
105[ 110[
106# Figure out what our getloadavg.c needs. 111# Figure out what our getloadavg.c needs.
107 112
108AC_CHECK_HEADERS_ONCE([sys/param.h]) 113AC_CHECK_HEADERS_ONCE([sys/param.h unistd.h])
109 114
110# On HPUX9, an unprivileged user can get load averages this way. 115# On HPUX9, an unprivileged user can get load averages this way.
111if test $gl_func_getloadavg_done = no; then 116if test $gl_func_getloadavg_done = no; then
@@ -142,7 +147,7 @@ fi
142AC_CHECK_HEADERS([nlist.h], 147AC_CHECK_HEADERS([nlist.h],
143[AC_CHECK_MEMBERS([struct nlist.n_un.n_name], 148[AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
144 [], [], 149 [], [],
145 [@%:@include <nlist.h>]) 150 [#include <nlist.h>])
146 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]], 151 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]],
147 [[struct nlist x; 152 [[struct nlist x;
148 #ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME 153 #ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
diff --git a/gl/m4/getopt.m4 b/gl/m4/getopt.m4
index 50f45091..7981a095 100644
--- a/gl/m4/getopt.m4
+++ b/gl/m4/getopt.m4
@@ -1,5 +1,5 @@
1# getopt.m4 serial 44 1# getopt.m4 serial 48
2dnl Copyright (C) 2002-2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -21,6 +21,8 @@ AC_DEFUN([gl_FUNC_GETOPT_POSIX],
21 REPLACE_GETOPT=1 21 REPLACE_GETOPT=1
22 fi 22 fi
23 ]) 23 ])
24 GL_GENERATE_GETOPT_H=false
25 GL_GENERATE_GETOPT_CDEFS_H=false
24 if test $REPLACE_GETOPT = 1; then 26 if test $REPLACE_GETOPT = 1; then
25 dnl Arrange for getopt.h to be created. 27 dnl Arrange for getopt.h to be created.
26 gl_GETOPT_SUBSTITUTE_HEADER 28 gl_GETOPT_SUBSTITUTE_HEADER
@@ -32,9 +34,16 @@ AC_DEFUN([gl_FUNC_GETOPT_POSIX],
32# getopt_long_only. 34# getopt_long_only.
33AC_DEFUN([gl_FUNC_GETOPT_GNU], 35AC_DEFUN([gl_FUNC_GETOPT_GNU],
34[ 36[
37 dnl Set the variable gl_getopt_required, so that all invocations of
38 dnl gl_GETOPT_CHECK_HEADERS in the scope of the current configure file
39 dnl will check for getopt with GNU extensions.
40 dnl This means that if one gnulib-tool invocation requests getopt-posix
41 dnl and another gnulib-tool invocation requests getopt-gnu, it is as if
42 dnl both had requested getopt-gnu.
35 m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU]) 43 m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU])
36 44
37 AC_REQUIRE([gl_FUNC_GETOPT_POSIX]) 45 dnl No need to invoke gl_FUNC_GETOPT_POSIX here; this is automatically
46 dnl done through the module dependency getopt-gnu -> getopt-posix.
38]) 47])
39 48
40# Determine whether to replace the entire getopt facility. 49# Determine whether to replace the entire getopt facility.
@@ -295,8 +304,10 @@ dnl is ambiguous with environment values that contain newlines.
295 ]])], 304 ]])],
296 [gl_cv_func_getopt_gnu=yes], 305 [gl_cv_func_getopt_gnu=yes],
297 [gl_cv_func_getopt_gnu=no], 306 [gl_cv_func_getopt_gnu=no],
298 [dnl Cross compiling. Assume the worst, even on glibc platforms. 307 [dnl Cross compiling.
299 gl_cv_func_getopt_gnu="guessing no" 308 dnl Assume the worst, even on glibc platforms.
309 dnl But obey --enable-cross-guesses.
310 gl_cv_func_getopt_gnu="$gl_cross_guess_normal"
300 ]) 311 ])
301 case $gl_had_POSIXLY_CORRECT in 312 case $gl_had_POSIXLY_CORRECT in
302 exported) ;; 313 exported) ;;
@@ -354,15 +365,17 @@ dnl is ambiguous with environment values that contain newlines.
354 365
355AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER], 366AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
356[ 367[
357 GETOPT_H=getopt.h 368 AC_CHECK_HEADERS_ONCE([sys/cdefs.h])
369 if test $ac_cv_header_sys_cdefs_h = yes; then
370 HAVE_SYS_CDEFS_H=1
371 else
372 HAVE_SYS_CDEFS_H=0
373 fi
374 AC_SUBST([HAVE_SYS_CDEFS_H])
375
358 AC_DEFINE([__GETOPT_PREFIX], [[rpl_]], 376 AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
359 [Define to rpl_ if the getopt replacement functions and variables 377 [Define to rpl_ if the getopt replacement functions and variables
360 should be used.]) 378 should be used.])
361 AC_SUBST([GETOPT_H]) 379 GL_GENERATE_GETOPT_H=true
362]) 380 GL_GENERATE_GETOPT_CDEFS_H=true
363
364# Prerequisites of lib/getopt*.
365AC_DEFUN([gl_PREREQ_GETOPT],
366[
367 AC_CHECK_DECLS_ONCE([getenv])
368]) 381])
diff --git a/gl/m4/getprogname.m4 b/gl/m4/getprogname.m4
new file mode 100644
index 00000000..b67c527c
--- /dev/null
+++ b/gl/m4/getprogname.m4
@@ -0,0 +1,43 @@
1# getprogname.m4 - check for getprogname or replacements for it
2
3# Copyright (C) 2016-2023 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved.
7
8# serial 4
9
10AC_DEFUN([gl_FUNC_GETPROGNAME],
11[
12 AC_CHECK_FUNCS_ONCE([getprogname getexecname])
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14 ac_found=0
15 AC_CHECK_DECLS([program_invocation_name], [ac_found=1], [],
16 [#include <errno.h>])
17 AC_CHECK_DECLS([program_invocation_short_name], [ac_found=1], [],
18 [#include <errno.h>])
19 AC_CHECK_DECLS([__argv], [ac_found=1], [], [#include <stdlib.h>])
20
21 # Incur the cost of this test only if none of the above worked.
22 if test $ac_found = 0; then
23 # On OpenBSD 5.1, using the global __progname variable appears to be
24 # the only way to implement getprogname.
25 AC_CACHE_CHECK([whether __progname is defined in default libraries],
26 [gl_cv_var___progname],
27 [
28 gl_cv_var___progname=
29 AC_LINK_IFELSE(
30 [AC_LANG_PROGRAM(
31 [[extern char *__progname;]],
32 [[return *__progname;]]
33 )],
34 [gl_cv_var___progname=yes]
35 )
36 ]
37 )
38 if test "$gl_cv_var___progname" = yes; then
39 AC_DEFINE([HAVE_VAR___PROGNAME], 1,
40 [Define if you have a global __progname variable])
41 fi
42 fi
43])
diff --git a/gl/m4/gettext.m4 b/gl/m4/gettext.m4
deleted file mode 100644
index 8d1f0665..00000000
--- a/gl/m4/gettext.m4
+++ /dev/null
@@ -1,401 +0,0 @@
1# gettext.m4 serial 66 (gettext-0.18.2)
2dnl Copyright (C) 1995-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006, 2008-2010.
19
20dnl Macro to add for using GNU gettext.
21
22dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
23dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
24dnl default (if it is not specified or empty) is 'no-libtool'.
25dnl INTLSYMBOL should be 'external' for packages with no intl directory,
26dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory.
27dnl If INTLSYMBOL is 'use-libtool', then a libtool library
28dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static,
29dnl depending on --{enable,disable}-{shared,static} and on the presence of
30dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
31dnl $(top_builddir)/intl/libintl.a will be created.
32dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
33dnl implementations (in libc or libintl) without the ngettext() function
34dnl will be ignored. If NEEDSYMBOL is specified and is
35dnl 'need-formatstring-macros', then GNU gettext implementations that don't
36dnl support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
37dnl INTLDIR is used to find the intl libraries. If empty,
38dnl the value '$(top_builddir)/intl/' is used.
39dnl
40dnl The result of the configuration is one of three cases:
41dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
42dnl and used.
43dnl Catalog format: GNU --> install in $(datadir)
44dnl Catalog extension: .mo after installation, .gmo in source tree
45dnl 2) GNU gettext has been found in the system's C library.
46dnl Catalog format: GNU --> install in $(datadir)
47dnl Catalog extension: .mo after installation, .gmo in source tree
48dnl 3) No internationalization, always use English msgid.
49dnl Catalog format: none
50dnl Catalog extension: none
51dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
52dnl The use of .gmo is historical (it was needed to avoid overwriting the
53dnl GNU format catalogs when building on a platform with an X/Open gettext),
54dnl but we keep it in order not to force irrelevant filename changes on the
55dnl maintainers.
56dnl
57AC_DEFUN([AM_GNU_GETTEXT],
58[
59 dnl Argument checking.
60 ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
61 [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
62])])])])])
63 ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old],
64 [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])])
65 ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
66 [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
67])])])])
68 define([gt_included_intl],
69 ifelse([$1], [external],
70 ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]),
71 [yes]))
72 define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], []))
73 gt_NEEDS_INIT
74 AM_GNU_GETTEXT_NEED([$2])
75
76 AC_REQUIRE([AM_PO_SUBDIRS])dnl
77 ifelse(gt_included_intl, yes, [
78 AC_REQUIRE([AM_INTL_SUBDIR])dnl
79 ])
80
81 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
82 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
83 AC_REQUIRE([AC_LIB_RPATH])
84
85 dnl Sometimes libintl requires libiconv, so first search for libiconv.
86 dnl Ideally we would do this search only after the
87 dnl if test "$USE_NLS" = "yes"; then
88 dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
89 dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
90 dnl the configure script would need to contain the same shell code
91 dnl again, outside any 'if'. There are two solutions:
92 dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
93 dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
94 dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
95 dnl documented, we avoid it.
96 ifelse(gt_included_intl, yes, , [
97 AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
98 ])
99
100 dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation.
101 gt_INTL_MACOSX
102
103 dnl Set USE_NLS.
104 AC_REQUIRE([AM_NLS])
105
106 ifelse(gt_included_intl, yes, [
107 BUILD_INCLUDED_LIBINTL=no
108 USE_INCLUDED_LIBINTL=no
109 ])
110 LIBINTL=
111 LTLIBINTL=
112 POSUB=
113
114 dnl Add a version number to the cache macros.
115 case " $gt_needs " in
116 *" need-formatstring-macros "*) gt_api_version=3 ;;
117 *" need-ngettext "*) gt_api_version=2 ;;
118 *) gt_api_version=1 ;;
119 esac
120 gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc"
121 gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl"
122
123 dnl If we use NLS figure out what method
124 if test "$USE_NLS" = "yes"; then
125 gt_use_preinstalled_gnugettext=no
126 ifelse(gt_included_intl, yes, [
127 AC_MSG_CHECKING([whether included gettext is requested])
128 AC_ARG_WITH([included-gettext],
129 [ --with-included-gettext use the GNU gettext library included here],
130 nls_cv_force_use_gnu_gettext=$withval,
131 nls_cv_force_use_gnu_gettext=no)
132 AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext])
133
134 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
135 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
136 ])
137 dnl User does not insist on using GNU NLS library. Figure out what
138 dnl to use. If GNU gettext is available we use this. Else we have
139 dnl to fall back to GNU NLS library.
140
141 if test $gt_api_version -ge 3; then
142 gt_revision_test_code='
143#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
144#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
145#endif
146changequote(,)dnl
147typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
148changequote([,])dnl
149'
150 else
151 gt_revision_test_code=
152 fi
153 if test $gt_api_version -ge 2; then
154 gt_expression_test_code=' + * ngettext ("", "", 0)'
155 else
156 gt_expression_test_code=
157 fi
158
159 AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
160 [AC_LINK_IFELSE(
161 [AC_LANG_PROGRAM(
162 [[
163#include <libintl.h>
164$gt_revision_test_code
165extern int _nl_msg_cat_cntr;
166extern int *_nl_domain_bindings;
167 ]],
168 [[
169bindtextdomain ("", "");
170return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings
171 ]])],
172 [eval "$gt_func_gnugettext_libc=yes"],
173 [eval "$gt_func_gnugettext_libc=no"])])
174
175 if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
176 dnl Sometimes libintl requires libiconv, so first search for libiconv.
177 ifelse(gt_included_intl, yes, , [
178 AM_ICONV_LINK
179 ])
180 dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
181 dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
182 dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
183 dnl even if libiconv doesn't exist.
184 AC_LIB_LINKFLAGS_BODY([intl])
185 AC_CACHE_CHECK([for GNU gettext in libintl],
186 [$gt_func_gnugettext_libintl],
187 [gt_save_CPPFLAGS="$CPPFLAGS"
188 CPPFLAGS="$CPPFLAGS $INCINTL"
189 gt_save_LIBS="$LIBS"
190 LIBS="$LIBS $LIBINTL"
191 dnl Now see whether libintl exists and does not depend on libiconv.
192 AC_LINK_IFELSE(
193 [AC_LANG_PROGRAM(
194 [[
195#include <libintl.h>
196$gt_revision_test_code
197extern int _nl_msg_cat_cntr;
198extern
199#ifdef __cplusplus
200"C"
201#endif
202const char *_nl_expand_alias (const char *);
203 ]],
204 [[
205bindtextdomain ("", "");
206return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")
207 ]])],
208 [eval "$gt_func_gnugettext_libintl=yes"],
209 [eval "$gt_func_gnugettext_libintl=no"])
210 dnl Now see whether libintl exists and depends on libiconv.
211 if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then
212 LIBS="$LIBS $LIBICONV"
213 AC_LINK_IFELSE(
214 [AC_LANG_PROGRAM(
215 [[
216#include <libintl.h>
217$gt_revision_test_code
218extern int _nl_msg_cat_cntr;
219extern
220#ifdef __cplusplus
221"C"
222#endif
223const char *_nl_expand_alias (const char *);
224 ]],
225 [[
226bindtextdomain ("", "");
227return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")
228 ]])],
229 [LIBINTL="$LIBINTL $LIBICONV"
230 LTLIBINTL="$LTLIBINTL $LTLIBICONV"
231 eval "$gt_func_gnugettext_libintl=yes"
232 ])
233 fi
234 CPPFLAGS="$gt_save_CPPFLAGS"
235 LIBS="$gt_save_LIBS"])
236 fi
237
238 dnl If an already present or preinstalled GNU gettext() is found,
239 dnl use it. But if this macro is used in GNU gettext, and GNU
240 dnl gettext is already preinstalled in libintl, we update this
241 dnl libintl. (Cf. the install rule in intl/Makefile.in.)
242 if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \
243 || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \
244 && test "$PACKAGE" != gettext-runtime \
245 && test "$PACKAGE" != gettext-tools; }; then
246 gt_use_preinstalled_gnugettext=yes
247 else
248 dnl Reset the values set by searching for libintl.
249 LIBINTL=
250 LTLIBINTL=
251 INCINTL=
252 fi
253
254 ifelse(gt_included_intl, yes, [
255 if test "$gt_use_preinstalled_gnugettext" != "yes"; then
256 dnl GNU gettext is not found in the C library.
257 dnl Fall back on included GNU gettext library.
258 nls_cv_use_gnu_gettext=yes
259 fi
260 fi
261
262 if test "$nls_cv_use_gnu_gettext" = "yes"; then
263 dnl Mark actions used to generate GNU NLS library.
264 BUILD_INCLUDED_LIBINTL=yes
265 USE_INCLUDED_LIBINTL=yes
266 LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD"
267 LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD"
268 LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
269 fi
270
271 CATOBJEXT=
272 if test "$gt_use_preinstalled_gnugettext" = "yes" \
273 || test "$nls_cv_use_gnu_gettext" = "yes"; then
274 dnl Mark actions to use GNU gettext tools.
275 CATOBJEXT=.gmo
276 fi
277 ])
278
279 if test -n "$INTL_MACOSX_LIBS"; then
280 if test "$gt_use_preinstalled_gnugettext" = "yes" \
281 || test "$nls_cv_use_gnu_gettext" = "yes"; then
282 dnl Some extra flags are needed during linking.
283 LIBINTL="$LIBINTL $INTL_MACOSX_LIBS"
284 LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS"
285 fi
286 fi
287
288 if test "$gt_use_preinstalled_gnugettext" = "yes" \
289 || test "$nls_cv_use_gnu_gettext" = "yes"; then
290 AC_DEFINE([ENABLE_NLS], [1],
291 [Define to 1 if translation of program messages to the user's native language
292 is requested.])
293 else
294 USE_NLS=no
295 fi
296 fi
297
298 AC_MSG_CHECKING([whether to use NLS])
299 AC_MSG_RESULT([$USE_NLS])
300 if test "$USE_NLS" = "yes"; then
301 AC_MSG_CHECKING([where the gettext function comes from])
302 if test "$gt_use_preinstalled_gnugettext" = "yes"; then
303 if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
304 gt_source="external libintl"
305 else
306 gt_source="libc"
307 fi
308 else
309 gt_source="included intl directory"
310 fi
311 AC_MSG_RESULT([$gt_source])
312 fi
313
314 if test "$USE_NLS" = "yes"; then
315
316 if test "$gt_use_preinstalled_gnugettext" = "yes"; then
317 if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
318 AC_MSG_CHECKING([how to link with libintl])
319 AC_MSG_RESULT([$LIBINTL])
320 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
321 fi
322
323 dnl For backward compatibility. Some packages may be using this.
324 AC_DEFINE([HAVE_GETTEXT], [1],
325 [Define if the GNU gettext() function is already present or preinstalled.])
326 AC_DEFINE([HAVE_DCGETTEXT], [1],
327 [Define if the GNU dcgettext() function is already present or preinstalled.])
328 fi
329
330 dnl We need to process the po/ directory.
331 POSUB=po
332 fi
333
334 ifelse(gt_included_intl, yes, [
335 dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
336 dnl to 'yes' because some of the testsuite requires it.
337 if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then
338 BUILD_INCLUDED_LIBINTL=yes
339 fi
340
341 dnl Make all variables we use known to autoconf.
342 AC_SUBST([BUILD_INCLUDED_LIBINTL])
343 AC_SUBST([USE_INCLUDED_LIBINTL])
344 AC_SUBST([CATOBJEXT])
345
346 dnl For backward compatibility. Some configure.ins may be using this.
347 nls_cv_header_intl=
348 nls_cv_header_libgt=
349
350 dnl For backward compatibility. Some Makefiles may be using this.
351 DATADIRNAME=share
352 AC_SUBST([DATADIRNAME])
353
354 dnl For backward compatibility. Some Makefiles may be using this.
355 INSTOBJEXT=.mo
356 AC_SUBST([INSTOBJEXT])
357
358 dnl For backward compatibility. Some Makefiles may be using this.
359 GENCAT=gencat
360 AC_SUBST([GENCAT])
361
362 dnl For backward compatibility. Some Makefiles may be using this.
363 INTLOBJS=
364 if test "$USE_INCLUDED_LIBINTL" = yes; then
365 INTLOBJS="\$(GETTOBJS)"
366 fi
367 AC_SUBST([INTLOBJS])
368
369 dnl Enable libtool support if the surrounding package wishes it.
370 INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
371 AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX])
372 ])
373
374 dnl For backward compatibility. Some Makefiles may be using this.
375 INTLLIBS="$LIBINTL"
376 AC_SUBST([INTLLIBS])
377
378 dnl Make all documented variables known to autoconf.
379 AC_SUBST([LIBINTL])
380 AC_SUBST([LTLIBINTL])
381 AC_SUBST([POSUB])
382])
383
384
385dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized.
386m4_define([gt_NEEDS_INIT],
387[
388 m4_divert_text([DEFAULTS], [gt_needs=])
389 m4_define([gt_NEEDS_INIT], [])
390])
391
392
393dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL])
394AC_DEFUN([AM_GNU_GETTEXT_NEED],
395[
396 m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"])
397])
398
399
400dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
401AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
diff --git a/gl/m4/gl-openssl.m4 b/gl/m4/gl-openssl.m4
new file mode 100644
index 00000000..7eab4e10
--- /dev/null
+++ b/gl/m4/gl-openssl.m4
@@ -0,0 +1,76 @@
1# gl-openssl.m4 serial 6
2dnl Copyright (C) 2013-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_SET_CRYPTO_CHECK_DEFAULT],
8[
9 m4_define([gl_CRYPTO_CHECK_DEFAULT], [$1])
10])
11gl_SET_CRYPTO_CHECK_DEFAULT([no])
12
13AC_DEFUN([gl_CRYPTO_CHECK],
14[
15 dnl gnulib users set this before gl_INIT with gl_SET_CRYPTO_CHECK_DEFAULT()
16 m4_divert_once([DEFAULTS], [with_openssl_default='gl_CRYPTO_CHECK_DEFAULT'])
17
18 dnl Only clear once, so crypto routines can be checked for individually
19 m4_divert_once([DEFAULTS], [LIB_CRYPTO=])
20
21 AC_ARG_WITH([openssl],
22 [[ --with-openssl[=ARG] use libcrypto hash routines for the hash functions
23 MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512.
24 Valid ARGs are:
25 'yes',
26 'no',
27 'auto' => use if any version available,
28 'auto-gpl-compat' => use if GPL compatible version
29 available,
30 'optional' => use if available
31 and warn if not available;
32 Default is ']gl_CRYPTO_CHECK_DEFAULT['.]m4_ifdef([gl_AF_ALG], [
33 Note also --with-linux-crypto, which will enable the
34 use of Linux kernel crypto routines (if available),
35 which has precedence for files.])],
36 [],
37 [with_openssl=$with_openssl_default])
38
39 AC_SUBST([LIB_CRYPTO])
40 if test "x$with_openssl" != xno; then
41 if test "x$with_openssl" = xauto-gpl-compat; then
42 AC_CACHE_CHECK([whether openssl is GPL compatible],
43 [gl_cv_openssl_gpl_compat],
44 [AC_COMPILE_IFELSE(
45 [AC_LANG_PROGRAM([[
46 #include <openssl/opensslv.h>
47 #if OPENSSL_VERSION_MAJOR < 3
48 #error "openssl >= version 3 not found"
49 #endif
50 ]])],
51 [gl_cv_openssl_gpl_compat=yes],
52 [gl_cv_openssl_gpl_compat=no])])
53 fi
54 if test "x$with_openssl" != xauto-gpl-compat ||
55 test "x$gl_cv_openssl_gpl_compat" = xyes; then
56 AC_CHECK_LIB([crypto], [$1],
57 [AC_CHECK_HEADERS(
58 m4_if([$1], [MD5], [openssl/md5.h], [openssl/sha.h]),
59 [LIB_CRYPTO=-lcrypto
60 AC_DEFINE([HAVE_OPENSSL_$1], [1],
61 [Define to 1 if libcrypto is used for $1.])])])
62 fi
63 if test "x$LIB_CRYPTO" = x; then
64 message='openssl development library not found for $1.
65 If you want to install it, first find the pre-built package name:
66 - On Debian and Debian-based systems: libssl-dev,
67 - On Red Hat distributions: openssl-devel.
68 - Other: https://repology.org/project/openssl/versions'
69 if test "x$with_openssl" = xyes; then
70 AC_MSG_ERROR([$message])
71 elif test "x$with_openssl" = xoptional; then
72 AC_MSG_WARN([$message])
73 fi
74 fi
75 fi
76])
diff --git a/gl/m4/glibc2.m4 b/gl/m4/glibc2.m4
deleted file mode 100644
index 0e506826..00000000
--- a/gl/m4/glibc2.m4
+++ /dev/null
@@ -1,31 +0,0 @@
1# glibc2.m4 serial 3
2dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8# Test for the GNU C Library, version 2.0 or newer.
9# From Bruno Haible.
10
11AC_DEFUN([gt_GLIBC2],
12 [
13 AC_CACHE_CHECK([whether we are using the GNU C Library 2 or newer],
14 [ac_cv_gnu_library_2],
15 [AC_EGREP_CPP([Lucky GNU user],
16 [
17#include <features.h>
18#ifdef __GNU_LIBRARY__
19 #if (__GLIBC__ >= 2) && !defined __UCLIBC__
20 Lucky GNU user
21 #endif
22#endif
23 ],
24 [ac_cv_gnu_library_2=yes],
25 [ac_cv_gnu_library_2=no])
26 ]
27 )
28 AC_SUBST([GLIBC2])
29 GLIBC2="$ac_cv_gnu_library_2"
30 ]
31)
diff --git a/gl/m4/glibc21.m4 b/gl/m4/glibc21.m4
deleted file mode 100644
index 613fb2a4..00000000
--- a/gl/m4/glibc21.m4
+++ /dev/null
@@ -1,34 +0,0 @@
1# glibc21.m4 serial 5
2dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8# Test for the GNU C Library, version 2.1 or newer, or uClibc.
9# From Bruno Haible.
10
11AC_DEFUN([gl_GLIBC21],
12 [
13 AC_CACHE_CHECK([whether we are using the GNU C Library >= 2.1 or uClibc],
14 [ac_cv_gnu_library_2_1],
15 [AC_EGREP_CPP([Lucky],
16 [
17#include <features.h>
18#ifdef __GNU_LIBRARY__
19 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
20 Lucky GNU user
21 #endif
22#endif
23#ifdef __UCLIBC__
24 Lucky user
25#endif
26 ],
27 [ac_cv_gnu_library_2_1=yes],
28 [ac_cv_gnu_library_2_1=no])
29 ]
30 )
31 AC_SUBST([GLIBC21])
32 GLIBC21="$ac_cv_gnu_library_2_1"
33 ]
34)
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4
index 90ad4aaa..267f0692 100644
--- a/gl/m4/gnulib-cache.m4
+++ b/gl/m4/gnulib-cache.m4
@@ -1,8 +1,8 @@
1# Copyright (C) 2002-2013 Free Software Foundation, Inc. 1# Copyright (C) 2002-2023 Free Software Foundation, Inc.
2# 2#
3# This file is free software; you can redistribute it and/or modify 3# This file is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by 4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or 5# the Free Software Foundation, either version 3 of the License, or
6# (at your option) any later version. 6# (at your option) any later version.
7# 7#
8# This file is distributed in the hope that it will be useful, 8# This file is distributed in the hope that it will be useful,
@@ -11,7 +11,7 @@
11# GNU General Public License for more details. 11# GNU General Public License for more details.
12# 12#
13# You should have received a copy of the GNU General Public License 13# You should have received a copy of the GNU General Public License
14# along with this file. If not, see <http://www.gnu.org/licenses/>. 14# along with this file. If not, see <https://www.gnu.org/licenses/>.
15# 15#
16# As a special exception to the GNU General Public License, 16# As a special exception to the GNU General Public License,
17# this file may be distributed as part of a program that 17# this file may be distributed as part of a program that
@@ -27,13 +27,45 @@
27 27
28 28
29# Specification in the form of a command-line invocation: 29# Specification in the form of a command-line invocation:
30# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strcasestr strsep timegm unsetenv vasprintf vsnprintf 30# gnulib-tool --import \
31# --lib=libgnu \
32# --source-base=gl \
33# --m4-base=gl/m4 \
34# --doc-base=doc \
35# --tests-base=tests \
36# --aux-dir=build-aux \
37# --no-conditional-dependencies \
38# --no-libtool \
39# --macro-prefix=gl \
40# --no-vc-files \
41# base64 \
42# crypto/sha256 \
43# dirname \
44# environ \
45# floorf \
46# fsusage \
47# getaddrinfo \
48# gethostname \
49# getloadavg \
50# getopt-gnu \
51# gettext-h \
52# idpriv-droptemp \
53# mountlist \
54# regex \
55# setenv \
56# strcase \
57# strcasestr \
58# strsep \
59# timegm \
60# unsetenv \
61# vasprintf \
62# vsnprintf
31 63
32# Specification in the form of a few gnulib-tool.m4 macro invocations: 64# Specification in the form of a few gnulib-tool.m4 macro invocations:
33gl_LOCAL_DIR([]) 65gl_LOCAL_DIR([])
34gl_MODULES([ 66gl_MODULES([
35 base64 67 base64
36 crypto/sha1 68 crypto/sha256
37 dirname 69 dirname
38 environ 70 environ
39 floorf 71 floorf
@@ -42,7 +74,7 @@ gl_MODULES([
42 gethostname 74 gethostname
43 getloadavg 75 getloadavg
44 getopt-gnu 76 getopt-gnu
45 gettext 77 gettext-h
46 idpriv-droptemp 78 idpriv-droptemp
47 mountlist 79 mountlist
48 regex 80 regex
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4
index 0ae5a9ec..facc3404 100644
--- a/gl/m4/gnulib-common.m4
+++ b/gl/m4/gnulib-common.m4
@@ -1,25 +1,59 @@
1# gnulib-common.m4 serial 33 1# gnulib-common.m4 serial 75a
2dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_PREREQ([2.62])
8
7# gl_COMMON 9# gl_COMMON
8# is expanded unconditionally through gnulib-tool magic. 10# is expanded unconditionally through gnulib-tool magic.
9AC_DEFUN([gl_COMMON], [ 11AC_DEFUN([gl_COMMON], [
10 dnl Use AC_REQUIRE here, so that the code is expanded once only. 12 dnl Use AC_REQUIRE here, so that the code is expanded once only.
11 AC_REQUIRE([gl_00GNULIB]) 13 AC_REQUIRE([gl_00GNULIB])
12 AC_REQUIRE([gl_COMMON_BODY]) 14 AC_REQUIRE([gl_COMMON_BODY])
15 AC_REQUIRE([gl_ZZGNULIB])
13]) 16])
14AC_DEFUN([gl_COMMON_BODY], [ 17AC_DEFUN([gl_COMMON_BODY], [
18 AH_VERBATIM([_GL_GNUC_PREREQ],
19[/* True if the compiler says it groks GNU C version MAJOR.MINOR. */
20#if defined __GNUC__ && defined __GNUC_MINOR__
21# define _GL_GNUC_PREREQ(major, minor) \
22 ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__))
23#else
24# define _GL_GNUC_PREREQ(major, minor) 0
25#endif
26])
15 AH_VERBATIM([_Noreturn], 27 AH_VERBATIM([_Noreturn],
16[/* The _Noreturn keyword of C11. */ 28[/* The _Noreturn keyword of C11. */
17#if ! (defined _Noreturn \ 29#ifndef _Noreturn
18 || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)) 30# if (defined __cplusplus \
19# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \ 31 && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
20 || 0x5110 <= __SUNPRO_C) 32 || (defined _MSC_VER && 1900 <= _MSC_VER)) \
33 && 0)
34 /* [[noreturn]] is not practically usable, because with it the syntax
35 extern _Noreturn void func (...);
36 would not be valid; such a declaration would only be valid with 'extern'
37 and '_Noreturn' swapped, or without the 'extern' keyword. However, some
38 AIX system header files and several gnulib header files use precisely
39 this syntax with 'extern'. */
40# define _Noreturn [[noreturn]]
41# elif (defined __clang__ && __clang_major__ < 16 \
42 && defined _GL_WORK_AROUND_LLVM_BUG_59792)
43 /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around
44 that rare LLVM bug, though you may get many false-alarm warnings. */
45# define _Noreturn
46# elif ((!defined __cplusplus || defined __clang__) \
47 && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
48 || (!defined __STRICT_ANSI__ \
49 && (_GL_GNUC_PREREQ (4, 7) \
50 || (defined __apple_build_version__ \
51 ? 6000000 <= __apple_build_version__ \
52 : 3 < __clang_major__ + (5 <= __clang_minor__))))))
53 /* _Noreturn works as-is. */
54# elif _GL_GNUC_PREREQ (2, 8) || defined __clang__ || 0x5110 <= __SUNPRO_C
21# define _Noreturn __attribute__ ((__noreturn__)) 55# define _Noreturn __attribute__ ((__noreturn__))
22# elif defined _MSC_VER && 1200 <= _MSC_VER 56# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
23# define _Noreturn __declspec (noreturn) 57# define _Noreturn __declspec (noreturn)
24# else 58# else
25# define _Noreturn 59# define _Noreturn
@@ -36,33 +70,519 @@ AC_DEFUN([gl_COMMON_BODY], [
36#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ 70#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
37# define __GNUC_STDC_INLINE__ 1 71# define __GNUC_STDC_INLINE__ 1
38#endif]) 72#endif])
39 AH_VERBATIM([unused_parameter], 73 AH_VERBATIM([attribute],
40[/* Define as a marker that can be attached to declarations that might not 74[/* Attributes. */
41 be used. This helps to reduce warnings, such as from 75#if (defined __has_attribute \
42 GCC -Wunused-parameter. */ 76 && (!defined __clang_minor__ \
43#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) 77 || (defined __apple_build_version__ \
44# define _GL_UNUSED __attribute__ ((__unused__)) 78 ? 6000000 <= __apple_build_version__ \
79 : 3 < __clang_major__ + (5 <= __clang_minor__))))
80# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
45#else 81#else
46# define _GL_UNUSED 82# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr
83# define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3)
84# define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2)
85# define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3)
86# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3)
87# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95)
88# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1)
89# define _GL_ATTR_diagnose_if 0
90# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3)
91# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1)
92# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0)
93# define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7)
94# define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6)
95# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0)
96# ifdef _ICC
97# define _GL_ATTR_may_alias 0
98# else
99# define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3)
100# endif
101# define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1)
102# define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3)
103# define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0)
104# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3)
105# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7)
106# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96)
107# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9)
108# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0)
109# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7)
110# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
47#endif 111#endif
48/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
49 is a misnomer outside of parameter lists. */
50#define _UNUSED_PARAMETER_ _GL_UNUSED
51 112
52/* The __pure__ attribute was added in gcc 2.96. */ 113/* Disable GCC -Wpedantic if using __has_c_attribute and this is not C23+. */
53#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 114#if (defined __has_c_attribute && _GL_GNUC_PREREQ (4, 6) \
54# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 115 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710)
55#else 116# pragma GCC diagnostic ignored "-Wpedantic"
56# define _GL_ATTRIBUTE_PURE /* empty */
57#endif 117#endif
58 118
59/* The __const__ attribute was added in gcc 2.95. */ 119]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's alignas instead.
60#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) 120[
61# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) 121/* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function
62#else 122 is the size of the returned memory block.
63# define _GL_ATTRIBUTE_CONST /* empty */ 123 _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied
124 by the Nth argument of the function is the size of the returned memory block.
125 */
126/* Applies to: function, pointer to function, function types. */
127#ifndef _GL_ATTRIBUTE_ALLOC_SIZE
128# if _GL_HAS_ATTRIBUTE (alloc_size)
129# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
130# else
131# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
132# endif
133#endif
134
135/* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the
136 function and report an error if it cannot do so. */
137/* Applies to: function. */
138#ifndef _GL_ATTRIBUTE_ALWAYS_INLINE
139# if _GL_HAS_ATTRIBUTE (always_inline)
140# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__))
141# else
142# define _GL_ATTRIBUTE_ALWAYS_INLINE
143# endif
144#endif
145
146/* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show
147 in stack traces when debugging. The compiler should omit the function from
148 stack traces. */
149/* Applies to: function. */
150#ifndef _GL_ATTRIBUTE_ARTIFICIAL
151# if _GL_HAS_ATTRIBUTE (artificial)
152# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__))
153# else
154# define _GL_ATTRIBUTE_ARTIFICIAL
155# endif
156#endif
157
158/* _GL_ATTRIBUTE_COLD declares that the function is rarely executed. */
159/* Applies to: functions. */
160/* Avoid __attribute__ ((cold)) on MinGW; see thread starting at
161 <https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>.
162 Also, Oracle Studio 12.6 requires 'cold' not '__cold__'. */
163#ifndef _GL_ATTRIBUTE_COLD
164# if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__
165# ifndef __SUNPRO_C
166# define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__))
167# else
168# define _GL_ATTRIBUTE_COLD __attribute__ ((cold))
169# endif
170# else
171# define _GL_ATTRIBUTE_COLD
172# endif
173#endif
174
175/* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate
176 calls to the function with the same arguments.
177 This attribute is safe for a function that neither depends on nor affects
178 observable state, and always returns exactly once - e.g., does not loop
179 forever, and does not call longjmp.
180 (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */
181/* Applies to: functions. */
182#ifndef _GL_ATTRIBUTE_CONST
183# if _GL_HAS_ATTRIBUTE (const)
184# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
185# else
186# define _GL_ATTRIBUTE_CONST
187# endif
188#endif
189
190/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
191 that can be freed by passing them as the Ith argument to the
192 function F.
193 _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
194 can be freed via 'free'; it can be used only after declaring 'free'. */
195/* Applies to: functions. Cannot be used on inline functions. */
196#ifndef _GL_ATTRIBUTE_DEALLOC
197# if _GL_GNUC_PREREQ (11, 0)
198# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
199# else
200# define _GL_ATTRIBUTE_DEALLOC(f, i)
201# endif
202#endif
203/* If gnulib's <string.h> or <wchar.h> has already defined this macro, continue
204 to use this earlier definition, since <stdlib.h> may not have been included
205 yet. */
206#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
207# if defined __cplusplus && defined __GNUC__ && !defined __clang__
208/* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
209# define _GL_ATTRIBUTE_DEALLOC_FREE \
210 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
211# else
212# define _GL_ATTRIBUTE_DEALLOC_FREE \
213 _GL_ATTRIBUTE_DEALLOC (free, 1)
214# endif
215#endif
216
217/* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated.
218 The compiler may warn if the entity is used. */
219/* Applies to:
220 - function, variable,
221 - struct, union, struct/union member,
222 - enumeration, enumeration item,
223 - typedef,
224 in C++ also: namespace, class, template specialization. */
225#ifndef _GL_ATTRIBUTE_DEPRECATED
226# ifdef __has_c_attribute
227# if __has_c_attribute (__deprecated__)
228# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
229# endif
230# endif
231# if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated)
232# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
233# endif
234# ifndef _GL_ATTRIBUTE_DEPRECATED
235# define _GL_ATTRIBUTE_DEPRECATED
236# endif
237#endif
238
239/* _GL_ATTRIBUTE_ERROR(msg) requests an error if a function is called and
240 the function call is not optimized away.
241 _GL_ATTRIBUTE_WARNING(msg) requests a warning if a function is called and
242 the function call is not optimized away. */
243/* Applies to: functions. */
244#if !(defined _GL_ATTRIBUTE_ERROR && defined _GL_ATTRIBUTE_WARNING)
245# if _GL_HAS_ATTRIBUTE (error)
246# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg)))
247# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg)))
248# elif _GL_HAS_ATTRIBUTE (diagnose_if)
249# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__diagnose_if__ (1, msg, "error")))
250# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__diagnose_if__ (1, msg, "warning")))
251# else
252# define _GL_ATTRIBUTE_ERROR(msg)
253# define _GL_ATTRIBUTE_WARNING(msg)
254# endif
255#endif
256
257/* _GL_ATTRIBUTE_EXTERNALLY_VISIBLE declares that the entity should remain
258 visible to debuggers etc., even with '-fwhole-program'. */
259/* Applies to: functions, variables. */
260#ifndef _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
261# if _GL_HAS_ATTRIBUTE (externally_visible)
262# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible))
263# else
264# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
265# endif
266#endif
267
268/* _GL_ATTRIBUTE_FALLTHROUGH declares that it is not a programming mistake if
269 the control flow falls through to the immediately following 'case' or
270 'default' label. The compiler should not warn in this case. */
271/* Applies to: Empty statement (;), inside a 'switch' statement. */
272/* Always expands to something. */
273#ifndef _GL_ATTRIBUTE_FALLTHROUGH
274# ifdef __has_c_attribute
275# if __has_c_attribute (__fallthrough__)
276# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]]
277# endif
278# endif
279# if !defined _GL_ATTRIBUTE_FALLTHROUGH && _GL_HAS_ATTRIBUTE (fallthrough)
280# define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
281# endif
282# ifndef _GL_ATTRIBUTE_FALLTHROUGH
283# define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0)
284# endif
285#endif
286
287/* _GL_ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK))
288 declares that the STRING-INDEXth function argument is a format string of
289 style ARCHETYPE, which is one of:
290 printf, gnu_printf
291 scanf, gnu_scanf,
292 strftime, gnu_strftime,
293 strfmon,
294 or the same thing prefixed and suffixed with '__'.
295 If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK
296 are suitable for the format string. */
297/* Applies to: functions. */
298#ifndef _GL_ATTRIBUTE_FORMAT
299# if _GL_HAS_ATTRIBUTE (format)
300# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
301# else
302# define _GL_ATTRIBUTE_FORMAT(spec)
303# endif
304#endif
305
306/* _GL_ATTRIBUTE_LEAF declares that if the function is called from some other
307 compilation unit, it executes code from that unit only by return or by
308 exception handling. This declaration lets the compiler optimize that unit
309 more aggressively. */
310/* Applies to: functions. */
311#ifndef _GL_ATTRIBUTE_LEAF
312# if _GL_HAS_ATTRIBUTE (leaf)
313# define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__))
314# else
315# define _GL_ATTRIBUTE_LEAF
316# endif
317#endif
318
319/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
320 allocated memory. */
321/* Applies to: functions. */
322#ifndef _GL_ATTRIBUTE_MALLOC
323# if _GL_HAS_ATTRIBUTE (malloc)
324# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
325# else
326# define _GL_ATTRIBUTE_MALLOC
327# endif
328#endif
329
330/* _GL_ATTRIBUTE_MAY_ALIAS declares that pointers to the type may point to the
331 same storage as pointers to other types. Thus this declaration disables
332 strict aliasing optimization. */
333/* Applies to: types. */
334/* Oracle Studio 12.6 mishandles may_alias despite __has_attribute OK. */
335#ifndef _GL_ATTRIBUTE_MAY_ALIAS
336# if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C
337# define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__))
338# else
339# define _GL_ATTRIBUTE_MAY_ALIAS
340# endif
341#endif
342
343/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if
344 the entity is not used. The compiler should not warn if the entity is not
345 used. */
346/* Applies to:
347 - function, variable,
348 - struct, union, struct/union member,
349 - enumeration, enumeration item,
350 - typedef,
351 in C++ also: class. */
352/* In C++ and C23, this is spelled [[__maybe_unused__]].
353 GCC's syntax is __attribute__ ((__unused__)).
354 clang supports both syntaxes. */
355#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
356# ifdef __has_c_attribute
357# if __has_c_attribute (__maybe_unused__)
358# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
359# endif
360# endif
361# ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
362# define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED
363# endif
364#endif
365/* Alternative spelling of this macro, for convenience and for
366 compatibility with glibc/include/libc-symbols.h. */
367#define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
368/* Earlier spellings of this macro. */
369#define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED
370
371/* _GL_ATTRIBUTE_NODISCARD declares that the caller of the function should not
372 discard the return value. The compiler may warn if the caller does not use
373 the return value, unless the caller uses something like ignore_value. */
374/* Applies to: function, enumeration, class. */
375#ifndef _GL_ATTRIBUTE_NODISCARD
376# ifdef __has_c_attribute
377# if __has_c_attribute (__nodiscard__)
378# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
379# endif
380# endif
381# if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_result)
382# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__))
383# endif
384# ifndef _GL_ATTRIBUTE_NODISCARD
385# define _GL_ATTRIBUTE_NODISCARD
386# endif
387#endif
388
389/* _GL_ATTRIBUTE_NOINLINE tells that the compiler should not inline the
390 function. */
391/* Applies to: functions. */
392#ifndef _GL_ATTRIBUTE_NOINLINE
393# if _GL_HAS_ATTRIBUTE (noinline)
394# define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__))
395# else
396# define _GL_ATTRIBUTE_NOINLINE
397# endif
398#endif
399
400/* _GL_ATTRIBUTE_NONNULL ((N1, N2,...)) declares that the arguments N1, N2,...
401 must not be NULL.
402 _GL_ATTRIBUTE_NONNULL () declares that all pointer arguments must not be
403 null. */
404/* Applies to: functions. */
405#ifndef _GL_ATTRIBUTE_NONNULL
406# if _GL_HAS_ATTRIBUTE (nonnull)
407# define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args))
408# else
409# define _GL_ATTRIBUTE_NONNULL(args)
410# endif
411#endif
412
413/* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is
414 not meant to be NUL-terminated. */
415/* Applies to: struct/union members and variables that are arrays of element
416 type '[[un]signed] char'. */
417#ifndef _GL_ATTRIBUTE_NONSTRING
418# if _GL_HAS_ATTRIBUTE (nonstring)
419# define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__))
420# else
421# define _GL_ATTRIBUTE_NONSTRING
422# endif
423#endif
424
425/* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */
426
427/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
428 */
429/* Applies to: functions. */
430#ifndef _GL_ATTRIBUTE_NOTHROW
431# if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus
432# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
433# else
434# define _GL_ATTRIBUTE_NOTHROW
435# endif
436#endif
437
438/* _GL_ATTRIBUTE_PACKED declares:
439 For struct members: The member has the smallest possible alignment.
440 For struct, union, class: All members have the smallest possible alignment,
441 minimizing the memory required. */
442/* Applies to: struct members, struct, union,
443 in C++ also: class. */
444#ifndef _GL_ATTRIBUTE_PACKED
445# if _GL_HAS_ATTRIBUTE (packed)
446# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__))
447# else
448# define _GL_ATTRIBUTE_PACKED
449# endif
450#endif
451
452/* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate
453 calls to the function with the same arguments if observable state is not
454 changed between calls.
455 This attribute is safe for a function that does not affect
456 observable state, and always returns exactly once.
457 (This attribute is looser than _GL_ATTRIBUTE_CONST.) */
458/* Applies to: functions. */
459#ifndef _GL_ATTRIBUTE_PURE
460# if _GL_HAS_ATTRIBUTE (pure)
461# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
462# else
463# define _GL_ATTRIBUTE_PURE
464# endif
465#endif
466
467/* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value is
468 a non-NULL pointer. */
469/* Applies to: functions. */
470#ifndef _GL_ATTRIBUTE_RETURNS_NONNULL
471# if _GL_HAS_ATTRIBUTE (returns_nonnull)
472# define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__))
473# else
474# define _GL_ATTRIBUTE_RETURNS_NONNULL
475# endif
476#endif
477
478/* _GL_ATTRIBUTE_SENTINEL(pos) declares that the variadic function expects a
479 trailing NULL argument.
480 _GL_ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99).
481 _GL_ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */
482/* Applies to: functions. */
483#ifndef _GL_ATTRIBUTE_SENTINEL
484# if _GL_HAS_ATTRIBUTE (sentinel)
485# define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos))
486# else
487# define _GL_ATTRIBUTE_SENTINEL(pos)
488# endif
489#endif
490
491/* A helper macro. Don't use it directly. */
492#ifndef _GL_ATTRIBUTE_UNUSED
493# if _GL_HAS_ATTRIBUTE (unused)
494# define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
495# else
496# define _GL_ATTRIBUTE_UNUSED
497# endif
498#endif
499
500]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead.
501[
502/* _GL_UNUSED_LABEL; declares that it is not a programming mistake if the
503 immediately preceding label is not used. The compiler should not warn
504 if the label is not used. */
505/* Applies to: label (both in C and C++). */
506/* Note that g++ < 4.5 does not support the '__attribute__ ((__unused__)) ;'
507 syntax. But clang does. */
508#ifndef _GL_UNUSED_LABEL
509# if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang__
510# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED
511# else
512# define _GL_UNUSED_LABEL
513# endif
64#endif 514#endif
65]) 515])
516 AH_VERBATIM([async_safe],
517[/* The _GL_ASYNC_SAFE marker should be attached to functions that are
518 signal handlers (for signals other than SIGABRT, SIGPIPE) or can be
519 invoked from such signal handlers. Such functions have some restrictions:
520 * All functions that it calls should be marked _GL_ASYNC_SAFE as well,
521 or should be listed as async-signal-safe in POSIX
522 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04>
523 section 2.4.3. Note that malloc(), sprintf(), and fwrite(), in
524 particular, are NOT async-signal-safe.
525 * All memory locations (variables and struct fields) that these functions
526 access must be marked 'volatile'. This holds for both read and write
527 accesses. Otherwise the compiler might optimize away stores to and
528 reads from such locations that occur in the program, depending on its
529 data flow analysis. For example, when the program contains a loop
530 that is intended to inspect a variable set from within a signal handler
531 while (!signal_occurred)
532 ;
533 the compiler is allowed to transform this into an endless loop if the
534 variable 'signal_occurred' is not declared 'volatile'.
535 Additionally, recall that:
536 * A signal handler should not modify errno (except if it is a handler
537 for a fatal signal and ends by raising the same signal again, thus
538 provoking the termination of the process). If it invokes a function
539 that may clobber errno, it needs to save and restore the value of
540 errno. */
541#define _GL_ASYNC_SAFE
542])
543 AH_VERBATIM([micro_optimizations],
544[/* _GL_CMP (n1, n2) performs a three-valued comparison on n1 vs. n2, where
545 n1 and n2 are expressions without side effects, that evaluate to real
546 numbers (excluding NaN).
547 It returns
548 1 if n1 > n2
549 0 if n1 == n2
550 -1 if n1 < n2
551 The naïve code (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) produces a conditional
552 jump with nearly all GCC versions up to GCC 10.
553 This variant (n1 < n2 ? -1 : n1 > n2) produces a conditional with many
554 GCC versions up to GCC 9.
555 The better code (n1 > n2) - (n1 < n2) from Hacker's Delight § 2-9
556 avoids conditional jumps in all GCC versions >= 3.4. */
557#define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2)))
558])
559 dnl Hint which direction to take regarding cross-compilation guesses:
560 dnl When a user installs a program on a platform they are not intimately
561 dnl familiar with, --enable-cross-guesses=conservative is the appropriate
562 dnl choice. It implements the "If we don't know, assume the worst" principle.
563 dnl However, when an operating system developer (on a platform which is not
564 dnl yet known to gnulib) builds packages for their platform, they want to
565 dnl expose, not hide, possible platform bugs; in this case,
566 dnl --enable-cross-guesses=risky is the appropriate choice.
567 dnl Sets the variables
568 dnl gl_cross_guess_normal (to be used when 'yes' is good and 'no' is bad),
569 dnl gl_cross_guess_inverted (to be used when 'no' is good and 'yes' is bad).
570 AC_ARG_ENABLE([cross-guesses],
571 [AS_HELP_STRING([--enable-cross-guesses={conservative|risky}],
572 [specify policy for cross-compilation guesses])],
573 [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then
574 AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses])
575 enableval=conservative
576 fi
577 gl_cross_guesses="$enableval"],
578 [gl_cross_guesses=conservative])
579 if test $gl_cross_guesses = risky; then
580 gl_cross_guess_normal="guessing yes"
581 gl_cross_guess_inverted="guessing no"
582 else
583 gl_cross_guess_normal="guessing no"
584 gl_cross_guess_inverted="guessing yes"
585 fi
66 dnl Preparation for running test programs: 586 dnl Preparation for running test programs:
67 dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not 587 dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
68 dnl to /dev/tty, so they can be redirected to log files. Such diagnostics 588 dnl to /dev/tty, so they can be redirected to log files. Such diagnostics
@@ -71,6 +591,16 @@ AC_DEFUN([gl_COMMON_BODY], [
71 export LIBC_FATAL_STDERR_ 591 export LIBC_FATAL_STDERR_
72]) 592])
73 593
594# gl_MODULE_INDICATOR_INIT_VARIABLE([variablename])
595# gl_MODULE_INDICATOR_INIT_VARIABLE([variablename], [initialvalue])
596# initializes the shell variable that indicates the presence of the given module
597# as a C preprocessor expression.
598AC_DEFUN([gl_MODULE_INDICATOR_INIT_VARIABLE],
599[
600 GL_MODULE_INDICATOR_PREFIX[]_[$1]=m4_if([$2], , [0], [$2])
601 AC_SUBST(GL_MODULE_INDICATOR_PREFIX[]_[$1])
602])
603
74# gl_MODULE_INDICATOR_CONDITION 604# gl_MODULE_INDICATOR_CONDITION
75# expands to a C preprocessor expression that evaluates to 1 or 0, depending 605# expands to a C preprocessor expression that evaluates to 1 or 0, depending
76# whether a gnulib module that has been requested shall be considered present 606# whether a gnulib module that has been requested shall be considered present
@@ -83,9 +613,9 @@ m4_define([gl_MODULE_INDICATOR_CONDITION], [1])
83AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE], 613AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE],
84[ 614[
85 gl_MODULE_INDICATOR_SET_VARIABLE_AUX( 615 gl_MODULE_INDICATOR_SET_VARIABLE_AUX(
86 [GNULIB_[]m4_translit([[$1]], 616 [GL_MODULE_INDICATOR_PREFIX[]_GNULIB_[]m4_translit([[$1]],
87 [abcdefghijklmnopqrstuvwxyz./-], 617 [abcdefghijklmnopqrstuvwxyz./-],
88 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])], 618 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])],
89 [gl_MODULE_INDICATOR_CONDITION]) 619 [gl_MODULE_INDICATOR_CONDITION])
90]) 620])
91 621
@@ -197,42 +727,20 @@ AC_DEFUN([gl_FEATURES_H],
197 AC_SUBST([HAVE_FEATURES_H]) 727 AC_SUBST([HAVE_FEATURES_H])
198]) 728])
199 729
200# m4_foreach_w
201# is a backport of autoconf-2.59c's m4_foreach_w.
202# Remove this macro when we can assume autoconf >= 2.60.
203m4_ifndef([m4_foreach_w],
204 [m4_define([m4_foreach_w],
205 [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
206
207# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH])
208# ----------------------------------------------------
209# Backport of autoconf-2.63b's macro.
210# Remove this macro when we can assume autoconf >= 2.64.
211m4_ifndef([AS_VAR_IF],
212[m4_define([AS_VAR_IF],
213[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
214
215# gl_PROG_CC_C99 730# gl_PROG_CC_C99
216# Modifies the value of the shell variable CC in an attempt to make $CC 731# Modifies the value of the shell variable CC in an attempt to make $CC
217# understand ISO C99 source code. 732# understand ISO C99 source code.
218# This is like AC_PROG_CC_C99, except that
219# - AC_PROG_CC_C99 did not exist in Autoconf versions < 2.60,
220# - AC_PROG_CC_C99 does not mix well with AC_PROG_CC_STDC
221# <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00367.html>,
222# but many more packages use AC_PROG_CC_STDC than AC_PROG_CC_C99
223# <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00441.html>.
224# Remaining problems:
225# - When AC_PROG_CC_STDC is invoked twice, it adds the C99 enabling options
226# to CC twice
227# <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00431.html>.
228# - AC_PROG_CC_STDC is likely to change now that C11 is an ISO standard.
229AC_DEFUN([gl_PROG_CC_C99], 733AC_DEFUN([gl_PROG_CC_C99],
230[ 734[
231 dnl Change that version number to the minimum Autoconf version that supports 735 dnl Just use AC_PROG_CC_C99.
232 dnl mixing AC_PROG_CC_C99 calls with AC_PROG_CC_STDC calls. 736 dnl When AC_PROG_CC_C99 and AC_PROG_CC_STDC are used together, the substituted
233 m4_version_prereq([9.0], 737 dnl value of CC will contain the C99 enabling options twice. But this is only
234 [AC_REQUIRE([AC_PROG_CC_C99])], 738 dnl a cosmetic problem.
235 [AC_REQUIRE([AC_PROG_CC_STDC])]) 739 dnl With Autoconf >= 2.70, use AC_PROG_CC since it implies AC_PROG_CC_C99;
740 dnl this avoids a "warning: The macro `AC_PROG_CC_C99' is obsolete."
741 m4_version_prereq([2.70],
742 [AC_REQUIRE([AC_PROG_CC])],
743 [AC_REQUIRE([AC_PROG_CC_C99])])
236]) 744])
237 745
238# gl_PROG_AR_RANLIB 746# gl_PROG_AR_RANLIB
@@ -243,9 +751,11 @@ AC_DEFUN([gl_PROG_AR_RANLIB],
243[ 751[
244 dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler 752 dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler
245 dnl as "cc", and GCC as "gcc". They have different object file formats and 753 dnl as "cc", and GCC as "gcc". They have different object file formats and
246 dnl library formats. In particular, the GNU binutils programs ar, ranlib 754 dnl library formats. In particular, the GNU binutils programs ar and ranlib
247 dnl produce libraries that work only with gcc, not with cc. 755 dnl produce libraries that work only with gcc, not with cc.
248 AC_REQUIRE([AC_PROG_CC]) 756 AC_REQUIRE([AC_PROG_CC])
757 dnl The '][' hides this use from 'aclocal'.
758 AC_BEFORE([$0], [A][M_PROG_AR])
249 AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler], 759 AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler],
250 [ 760 [
251 AC_EGREP_CPP([Amsterdam], 761 AC_EGREP_CPP([Amsterdam],
@@ -257,25 +767,39 @@ Amsterdam
257 [gl_cv_c_amsterdam_compiler=yes], 767 [gl_cv_c_amsterdam_compiler=yes],
258 [gl_cv_c_amsterdam_compiler=no]) 768 [gl_cv_c_amsterdam_compiler=no])
259 ]) 769 ])
260 if test -z "$AR"; then 770
261 if test $gl_cv_c_amsterdam_compiler = yes; then 771 dnl Don't compete with AM_PROG_AR's decision about AR/ARFLAGS if we are not
772 dnl building with __ACK__.
773 if test $gl_cv_c_amsterdam_compiler = yes; then
774 if test -z "$AR"; then
262 AR='cc -c.a' 775 AR='cc -c.a'
263 if test -z "$ARFLAGS"; then
264 ARFLAGS='-o'
265 fi
266 else
267 dnl Use the Automake-documented default values for AR and ARFLAGS,
268 dnl but prefer ${host}-ar over ar (useful for cross-compiling).
269 AC_CHECK_TOOL([AR], [ar], [ar])
270 if test -z "$ARFLAGS"; then
271 ARFLAGS='cru'
272 fi
273 fi 776 fi
274 else
275 if test -z "$ARFLAGS"; then 777 if test -z "$ARFLAGS"; then
276 ARFLAGS='cru' 778 ARFLAGS='-o'
277 fi 779 fi
780 else
781 dnl AM_PROG_AR was added in automake v1.11.2. AM_PROG_AR does not AC_SUBST
782 dnl ARFLAGS variable (it is filed into Makefile.in directly by automake
783 dnl script on-demand, if not specified by ./configure of course).
784 dnl Don't AC_REQUIRE the AM_PROG_AR otherwise the code for __ACK__ above
785 dnl will be ignored. Also, pay attention to call AM_PROG_AR in else block
786 dnl because AM_PROG_AR is written so it could re-set AR variable even for
787 dnl __ACK__. It may seem like its easier to avoid calling the macro here,
788 dnl but we need to AC_SUBST both AR/ARFLAGS (thus those must have some good
789 dnl default value and automake should usually know them).
790 dnl
791 dnl The '][' hides this use from 'aclocal'.
792 m4_ifdef([A][M_PROG_AR], [A][M_PROG_AR], [:])
278 fi 793 fi
794
795 dnl In case the code above has not helped with setting AR/ARFLAGS, use
796 dnl Automake-documented default values for AR and ARFLAGS, but prefer
797 dnl ${host}-ar over ar (useful for cross-compiling).
798 AC_CHECK_TOOL([AR], [ar], [ar])
799 if test -z "$ARFLAGS"; then
800 ARFLAGS='cr'
801 fi
802
279 AC_SUBST([AR]) 803 AC_SUBST([AR])
280 AC_SUBST([ARFLAGS]) 804 AC_SUBST([ARFLAGS])
281 if test -z "$RANLIB"; then 805 if test -z "$RANLIB"; then
@@ -289,46 +813,29 @@ Amsterdam
289 AC_SUBST([RANLIB]) 813 AC_SUBST([RANLIB])
290]) 814])
291 815
292# AC_PROG_MKDIR_P
293# is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix
294# for interoperability with automake-1.9.6 from autoconf-2.62.
295# Remove this macro when we can assume autoconf >= 2.62 or
296# autoconf >= 2.60 && automake >= 1.10.
297# AC_AUTOCONF_VERSION was introduced in 2.62, so use that as the witness.
298m4_ifndef([AC_AUTOCONF_VERSION],[
299m4_ifdef([AC_PROG_MKDIR_P], [
300 dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed.
301 m4_define([AC_PROG_MKDIR_P],
302 m4_defn([AC_PROG_MKDIR_P])[
303 AC_SUBST([MKDIR_P])])], [
304 dnl For autoconf < 2.60: Backport of AC_PROG_MKDIR_P.
305 AC_DEFUN_ONCE([AC_PROG_MKDIR_P],
306 [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
307 MKDIR_P='$(mkdir_p)'
308 AC_SUBST([MKDIR_P])])])
309])
310
311# AC_C_RESTRICT 816# AC_C_RESTRICT
312# This definition overrides the AC_C_RESTRICT macro from autoconf 2.60..2.61, 817# This definition is copied from post-2.70 Autoconf and overrides the
313# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++ 818# AC_C_RESTRICT macro from autoconf 2.60..2.70.
314# works. 819m4_version_prereq([2.70.1], [], [
315# This definition can be removed once autoconf >= 2.62 can be assumed.
316# AC_AUTOCONF_VERSION was introduced in 2.62, so use that as the witness.
317m4_ifndef([AC_AUTOCONF_VERSION],[
318AC_DEFUN([AC_C_RESTRICT], 820AC_DEFUN([AC_C_RESTRICT],
319[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], 821[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
320 [ac_cv_c_restrict=no 822 [ac_cv_c_restrict=no
321 # The order here caters to the fact that C++ does not require restrict. 823 # Put '__restrict__' first, to avoid problems with glibc and non-GCC; see:
322 for ac_kw in __restrict __restrict__ _Restrict restrict; do 824 # https://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html
323 AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 825 # Put 'restrict' last, because C++ lacks it.
324 [[typedef int * int_ptr; 826 for ac_kw in __restrict__ __restrict _Restrict restrict; do
325 int foo (int_ptr $ac_kw ip) { 827 AC_COMPILE_IFELSE(
326 return ip[0]; 828 [AC_LANG_PROGRAM(
327 }]], 829 [[typedef int *int_ptr;
328 [[int s[1]; 830 int foo (int_ptr $ac_kw ip) { return ip[0]; }
329 int * $ac_kw t = s; 831 int bar (int [$ac_kw]); /* Catch GCC bug 14050. */
330 t[0] = 0; 832 int bar (int ip[$ac_kw]) { return ip[0]; }
331 return foo(t)]])], 833 ]],
834 [[int s[1];
835 int *$ac_kw t = s;
836 t[0] = 0;
837 return foo (t) + bar (t);
838 ]])],
332 [ac_cv_c_restrict=$ac_kw]) 839 [ac_cv_c_restrict=$ac_kw])
333 test "$ac_cv_c_restrict" != no && break 840 test "$ac_cv_c_restrict" != no && break
334 done 841 done
@@ -336,22 +843,24 @@ AC_DEFUN([AC_C_RESTRICT],
336 AH_VERBATIM([restrict], 843 AH_VERBATIM([restrict],
337[/* Define to the equivalent of the C99 'restrict' keyword, or to 844[/* Define to the equivalent of the C99 'restrict' keyword, or to
338 nothing if this is not supported. Do not define if restrict is 845 nothing if this is not supported. Do not define if restrict is
339 supported directly. */ 846 supported only directly. */
340#undef restrict 847#undef restrict
341/* Work around a bug in Sun C++: it does not support _Restrict, even 848/* Work around a bug in older versions of Sun C++, which did not
342 though the corresponding Sun C compiler does, which causes 849 #define __restrict__ or support _Restrict or __restrict__
343 "#define restrict _Restrict" in the previous line. Perhaps some future 850 even though the corresponding Sun C compiler ended up with
344 version of Sun C++ will work with _Restrict; if so, it'll probably 851 "#define restrict _Restrict" or "#define restrict __restrict__"
345 define __RESTRICT, just as Sun C does. */ 852 in the previous line. This workaround can be removed once
346#if defined __SUNPRO_CC && !defined __RESTRICT 853 we assume Oracle Developer Studio 12.5 (2016) or later. */
854#if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__
347# define _Restrict 855# define _Restrict
856# define __restrict__
348#endif]) 857#endif])
349 case $ac_cv_c_restrict in 858 case $ac_cv_c_restrict in
350 restrict) ;; 859 restrict) ;;
351 no) AC_DEFINE([restrict], []) ;; 860 no) AC_DEFINE([restrict], []) ;;
352 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; 861 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
353 esac 862 esac
354]) 863])# AC_C_RESTRICT
355]) 864])
356 865
357# gl_BIGENDIAN 866# gl_BIGENDIAN
@@ -363,6 +872,22 @@ AC_DEFUN([gl_BIGENDIAN],
363 AC_C_BIGENDIAN 872 AC_C_BIGENDIAN
364]) 873])
365 874
875# A temporary file descriptor.
876# Must be less than 10, because dash 0.5.8 does not support redirections
877# with multi-digit file descriptors.
878m4_define([GL_TMP_FD], 9)
879
880# gl_SILENT(command)
881# executes command, but without the normal configure output.
882# This is useful when you want to invoke AC_CACHE_CHECK (or AC_CHECK_FUNC etc.)
883# inside another AC_CACHE_CHECK.
884AC_DEFUN([gl_SILENT],
885[
886 exec GL_TMP_FD>&AS_MESSAGE_FD AS_MESSAGE_FD>/dev/null
887 $1
888 exec AS_MESSAGE_FD>&GL_TMP_FD GL_TMP_FD>&-
889])
890
366# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it) 891# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it)
367# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not 892# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not
368# output a spurious "(cached)" mark in the midst of other configure output. 893# output a spurious "(cached)" mark in the midst of other configure output.
@@ -370,8 +895,257 @@ AC_DEFUN([gl_BIGENDIAN],
370# by an AC_MSG_CHECKING/AC_MSG_RESULT pair. 895# by an AC_MSG_CHECKING/AC_MSG_RESULT pair.
371AC_DEFUN([gl_CACHE_VAL_SILENT], 896AC_DEFUN([gl_CACHE_VAL_SILENT],
372[ 897[
373 saved_as_echo_n="$as_echo_n" 898 gl_SILENT([
374 as_echo_n=':' 899 AC_CACHE_VAL([$1], [$2])
375 AC_CACHE_VAL([$1], [$2]) 900 ])
376 as_echo_n="$saved_as_echo_n" 901])
902
903# gl_CONDITIONAL(conditional, condition)
904# is like AM_CONDITIONAL(conditional, condition), except that it does not
905# produce an error
906# configure: error: conditional "..." was never defined.
907# Usually this means the macro was only invoked conditionally.
908# when only invoked conditionally. Instead, in that case, both the _TRUE
909# and the _FALSE case are disabled.
910AC_DEFUN([gl_CONDITIONAL],
911[
912 pushdef([AC_CONFIG_COMMANDS_PRE], [:])dnl
913 AM_CONDITIONAL([$1], [$2])
914 popdef([AC_CONFIG_COMMANDS_PRE])dnl
915 if test -z "${[$1]_TRUE}" && test -z "${[$1]_FALSE}"; then
916 [$1]_TRUE='#'
917 [$1]_FALSE='#'
918 fi
919])
920
921# gl_CC_ALLOW_WARNINGS
922# sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) option
923# that reverts a preceding '-Werror' option, if available.
924# This is expected to be '-Wno-error' on gcc, clang (except clang/MSVC), xlclang
925# and empty otherwise.
926AC_DEFUN([gl_CC_ALLOW_WARNINGS],
927[
928 AC_REQUIRE([AC_PROG_CC])
929 AC_CACHE_CHECK([for C compiler option to allow warnings],
930 [gl_cv_cc_wallow],
931 [rm -f conftest*
932 echo 'int dummy;' > conftest.c
933 AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null
934 AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2>conftest2.err]) >/dev/null
935 dnl Test the number of error output lines, because AIX xlc accepts the
936 dnl option '-Wno-error', just to produce a warning
937 dnl "Option -Wno-error was incorrectly specified. The option will be ignored."
938 dnl afterwards.
939 if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then
940 gl_cv_cc_wallow='-Wno-error'
941 else
942 gl_cv_cc_wallow=none
943 fi
944 rm -f conftest*
945 ])
946 case "$gl_cv_cc_wallow" in
947 none) GL_CFLAG_ALLOW_WARNINGS='' ;;
948 *) GL_CFLAG_ALLOW_WARNINGS="$gl_cv_cc_wallow" ;;
949 esac
950 AC_SUBST([GL_CFLAG_ALLOW_WARNINGS])
951])
952
953# gl_CXX_ALLOW_WARNINGS
954# sets and substitutes a variable GL_CXXFLAG_ALLOW_WARNINGS, to a $(CC) option
955# that reverts a preceding '-Werror' option, if available.
956AC_DEFUN([gl_CXX_ALLOW_WARNINGS],
957[
958 dnl Requires AC_PROG_CXX or gl_PROG_ANSI_CXX.
959 if test -n "$CXX" && test "$CXX" != no; then
960 AC_CACHE_CHECK([for C++ compiler option to allow warnings],
961 [gl_cv_cxx_wallow],
962 [rm -f conftest*
963 echo 'int dummy;' > conftest.cc
964 AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null
965 AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c conftest.cc 2>conftest2.err]) >/dev/null
966 dnl Test the number of error output lines, because AIX xlC accepts the
967 dnl option '-Wno-error', just to produce a warning
968 dnl "Option -Wno-error was incorrectly specified. The option will be ignored."
969 dnl afterwards.
970 if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then
971 gl_cv_cxx_wallow='-Wno-error'
972 else
973 gl_cv_cxx_wallow=none
974 fi
975 rm -f conftest*
976 ])
977 case "$gl_cv_cxx_wallow" in
978 none) GL_CXXFLAG_ALLOW_WARNINGS='' ;;
979 *) GL_CXXFLAG_ALLOW_WARNINGS="$gl_cv_cxx_wallow" ;;
980 esac
981 else
982 GL_CXXFLAG_ALLOW_WARNINGS=''
983 fi
984 AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS])
985])
986
987# gl_CC_GNULIB_WARNINGS
988# sets and substitutes a variable GL_CFLAG_GNULIB_WARNINGS, to a $(CC) option
989# set that enables or disables warnings as suitable for the Gnulib coding style.
990AC_DEFUN([gl_CC_GNULIB_WARNINGS],
991[
992 AC_REQUIRE([gl_CC_ALLOW_WARNINGS])
993 dnl Assume that the compiler supports -Wno-* options only if it also supports
994 dnl -Wno-error.
995 GL_CFLAG_GNULIB_WARNINGS=''
996 if test -n "$GL_CFLAG_ALLOW_WARNINGS"; then
997 dnl Enable these warning options:
998 dnl
999 dnl GCC clang
1000 dnl -Wno-cast-qual >= 3 >= 3.9
1001 dnl -Wno-conversion >= 3 >= 3.9
1002 dnl -Wno-float-conversion >= 4.9 >= 3.9
1003 dnl -Wno-float-equal >= 3 >= 3.9
1004 dnl -Wimplicit-fallthrough >= 7 >= 3.9
1005 dnl -Wno-pedantic >= 4.8 >= 3.9
1006 dnl -Wno-sign-compare >= 3 >= 3.9
1007 dnl -Wno-sign-conversion >= 4.3 >= 3.9
1008 dnl -Wno-type-limits >= 4.3 >= 3.9
1009 dnl -Wno-undef >= 3 >= 3.9
1010 dnl -Wno-unsuffixed-float-constants >= 4.5
1011 dnl -Wno-unused-function >= 3 >= 3.9
1012 dnl -Wno-unused-parameter >= 3 >= 3.9
1013 dnl
1014 cat > conftest.c <<\EOF
1015 #if __GNUC__ >= 3 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1016 -Wno-cast-qual
1017 -Wno-conversion
1018 -Wno-float-equal
1019 -Wno-sign-compare
1020 -Wno-undef
1021 -Wno-unused-function
1022 -Wno-unused-parameter
1023 #endif
1024 #if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1025 -Wno-float-conversion
1026 #endif
1027 #if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1028 -Wimplicit-fallthrough
1029 #endif
1030 #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1031 -Wno-pedantic
1032 #endif
1033 #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1034 -Wno-sign-conversion
1035 -Wno-type-limits
1036 #endif
1037 #if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4
1038 -Wno-unsuffixed-float-constants
1039 #endif
1040EOF
1041 gl_command="$CC $CFLAGS $CPPFLAGS -E conftest.c > conftest.out"
1042 if AC_TRY_EVAL([gl_command]); then
1043 gl_options=`grep -v '#' conftest.out`
1044 for word in $gl_options; do
1045 GL_CFLAG_GNULIB_WARNINGS="$GL_CFLAG_GNULIB_WARNINGS $word"
1046 done
1047 fi
1048 rm -f conftest.c conftest.out
1049 fi
1050 AC_SUBST([GL_CFLAG_GNULIB_WARNINGS])
1051])
1052
1053dnl gl_CONDITIONAL_HEADER([foo.h])
1054dnl takes a shell variable GL_GENERATE_FOO_H (with value true or false) as input
1055dnl and produces
1056dnl - an AC_SUBSTed variable FOO_H that is either a file name or empty, based
1057dnl on whether GL_GENERATE_FOO_H is true or false,
1058dnl - an Automake conditional GL_GENERATE_FOO_H that evaluates to the value of
1059dnl the shell variable GL_GENERATE_FOO_H.
1060AC_DEFUN([gl_CONDITIONAL_HEADER],
1061[
1062 m4_pushdef([gl_header_name], AS_TR_SH(m4_toupper($1)))
1063 m4_pushdef([gl_generate_var], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
1064 m4_pushdef([gl_generate_cond], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
1065 case "$gl_generate_var" in
1066 false) gl_header_name='' ;;
1067 true)
1068 dnl It is OK to use a .h file in lib/ from within tests/, but not vice
1069 dnl versa.
1070 if test -z "$gl_header_name"; then
1071 gl_header_name="${gl_source_base_prefix}$1"
1072 fi
1073 ;;
1074 *) echo "*** gl_generate_var is not set correctly" 1>&2; exit 1 ;;
1075 esac
1076 AC_SUBST(gl_header_name)
1077 gl_CONDITIONAL(gl_generate_cond, [$gl_generate_var])
1078 m4_popdef([gl_generate_cond])
1079 m4_popdef([gl_generate_var])
1080 m4_popdef([gl_header_name])
1081])
1082
1083dnl Expands to some code for use in .c programs that, on native Windows, defines
1084dnl the Microsoft deprecated alias function names to the underscore-prefixed
1085dnl actual function names. With this macro, these function names are available
1086dnl without linking with '-loldnames' and without generating warnings.
1087dnl Usage: Use it after all system header files are included.
1088dnl #include <...>
1089dnl #include <...>
1090dnl ]GL_MDA_DEFINES[
1091dnl ...
1092AC_DEFUN([GL_MDA_DEFINES],[
1093AC_REQUIRE([_GL_MDA_DEFINES])
1094[$gl_mda_defines]
1095])
1096AC_DEFUN([_GL_MDA_DEFINES],
1097[gl_mda_defines='
1098#if defined _WIN32 && !defined __CYGWIN__
1099#define access _access
1100#define chdir _chdir
1101#define chmod _chmod
1102#define close _close
1103#define creat _creat
1104#define dup _dup
1105#define dup2 _dup2
1106#define ecvt _ecvt
1107#define execl _execl
1108#define execle _execle
1109#define execlp _execlp
1110#define execv _execv
1111#define execve _execve
1112#define execvp _execvp
1113#define execvpe _execvpe
1114#define fcloseall _fcloseall
1115#define fcvt _fcvt
1116#define fdopen _fdopen
1117#define fileno _fileno
1118#define gcvt _gcvt
1119#define getcwd _getcwd
1120#define getpid _getpid
1121#define getw _getw
1122#define isatty _isatty
1123#define j0 _j0
1124#define j1 _j1
1125#define jn _jn
1126#define lfind _lfind
1127#define lsearch _lsearch
1128#define lseek _lseek
1129#define memccpy _memccpy
1130#define mkdir _mkdir
1131#define mktemp _mktemp
1132#define open _open
1133#define putenv _putenv
1134#define putw _putw
1135#define read _read
1136#define rmdir _rmdir
1137#define strdup _strdup
1138#define swab _swab
1139#define tempnam _tempnam
1140#define tzset _tzset
1141#define umask _umask
1142#define unlink _unlink
1143#define utime _utime
1144#define wcsdup _wcsdup
1145#define write _write
1146#define y0 _y0
1147#define y1 _y1
1148#define yn _yn
1149#endif
1150'
377]) 1151])
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 9a4f5027..4764622e 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -1,9 +1,9 @@
1# DO NOT EDIT! GENERATED AUTOMATICALLY! 1# DO NOT EDIT! GENERATED AUTOMATICALLY!
2# Copyright (C) 2002-2013 Free Software Foundation, Inc. 2# Copyright (C) 2002-2023 Free Software Foundation, Inc.
3# 3#
4# This file is free software; you can redistribute it and/or modify 4# This file is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by 5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3 of the License, or 6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version. 7# (at your option) any later version.
8# 8#
9# This file is distributed in the hope that it will be useful, 9# This file is distributed in the hope that it will be useful,
@@ -12,7 +12,7 @@
12# GNU General Public License for more details. 12# GNU General Public License for more details.
13# 13#
14# You should have received a copy of the GNU General Public License 14# You should have received a copy of the GNU General Public License
15# along with this file. If not, see <http://www.gnu.org/licenses/>. 15# along with this file. If not, see <https://www.gnu.org/licenses/>.
16# 16#
17# As a special exception to the GNU General Public License, 17# As a special exception to the GNU General Public License,
18# this file may be distributed as part of a program that 18# this file may be distributed as part of a program that
@@ -37,50 +37,91 @@ AC_DEFUN([gl_EARLY],
37 m4_pattern_allow([^gl_ES$])dnl a valid locale name 37 m4_pattern_allow([^gl_ES$])dnl a valid locale name
38 m4_pattern_allow([^gl_LIBOBJS$])dnl a variable 38 m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
39 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable 39 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
40
41 # Pre-early section.
42 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
40 AC_REQUIRE([gl_PROG_AR_RANLIB]) 43 AC_REQUIRE([gl_PROG_AR_RANLIB])
41 AC_REQUIRE([AM_PROG_CC_C_O]) 44
45 # Code from module absolute-header:
42 # Code from module alloca-opt: 46 # Code from module alloca-opt:
43 # Code from module arpa_inet: 47 # Code from module arpa_inet:
48 # Code from module assert-h:
49 # Code from module attribute:
44 # Code from module base64: 50 # Code from module base64:
51 # Code from module basename-lgpl:
45 # Code from module btowc: 52 # Code from module btowc:
46 # Code from module configmake: 53 # Code from module builtin-expect:
47 # Code from module crypto/sha1: 54 # Code from module byteswap:
55 # Code from module c99:
56 # Code from module calloc-gnu:
57 # Code from module calloc-posix:
58 # Code from module cloexec:
59 # Code from module close:
60 # Code from module crypto/af_alg:
61 # Code from module crypto/sha256:
62 # Code from module crypto/sha256-buffer:
48 # Code from module dirname: 63 # Code from module dirname:
49 # Code from module dirname-lgpl: 64 # Code from module dirname-lgpl:
50 # Code from module dosname:
51 # Code from module double-slash-root: 65 # Code from module double-slash-root:
66 # Code from module dup2:
52 # Code from module environ: 67 # Code from module environ:
53 # Code from module errno: 68 # Code from module errno:
54 # Code from module error: 69 # Code from module error:
55 # Code from module exitfail: 70 # Code from module exitfail:
56 # Code from module extensions: 71 # Code from module extensions:
57 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
58 # Code from module extern-inline: 72 # Code from module extern-inline:
73 # Code from module fcntl:
74 # Code from module fcntl-h:
59 # Code from module fd-hook: 75 # Code from module fd-hook:
76 # Code from module fflush:
77 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
78 # Code from module filename:
60 # Code from module float: 79 # Code from module float:
61 # Code from module floorf: 80 # Code from module floorf:
81 # Code from module fopen:
82 # Code from module fopen-gnu:
83 # Code from module fpurge:
84 # Code from module freading:
85 # Code from module free-posix:
86 # Code from module fseek:
87 # Code from module fseeko:
88 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
89 # Code from module fstat:
62 # Code from module fsusage: 90 # Code from module fsusage:
63 # Code from module full-read: 91 # Code from module ftell:
92 # Code from module ftello:
93 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
94 # Code from module gen-header:
64 # Code from module getaddrinfo: 95 # Code from module getaddrinfo:
96 # Code from module getdelim:
97 # Code from module getdtablesize:
65 # Code from module gethostname: 98 # Code from module gethostname:
99 # Code from module getline:
66 # Code from module getloadavg: 100 # Code from module getloadavg:
67 # Code from module getopt-gnu: 101 # Code from module getopt-gnu:
68 # Code from module getopt-posix: 102 # Code from module getopt-posix:
69 # Code from module gettext: 103 # Code from module getprogname:
70 # Code from module gettext-h: 104 # Code from module gettext-h:
71 # Code from module havelib: 105 # Code from module glibc-internal/dynarray:
106 # Code from module hard-locale:
72 # Code from module hostent: 107 # Code from module hostent:
108 # Code from module ialloc:
73 # Code from module idpriv-droptemp: 109 # Code from module idpriv-droptemp:
110 # Code from module idx:
74 # Code from module include_next: 111 # Code from module include_next:
75 # Code from module inet_ntop: 112 # Code from module inet_ntop:
76 # Code from module intprops: 113 # Code from module intprops:
114 # Code from module inttypes-incomplete:
77 # Code from module langinfo: 115 # Code from module langinfo:
78 # Code from module largefile: 116 # Code from module largefile:
79 AC_REQUIRE([AC_SYS_LARGEFILE]) 117 AC_REQUIRE([AC_SYS_LARGEFILE])
118 # Code from module libc-config:
119 # Code from module limits-h:
80 # Code from module localcharset: 120 # Code from module localcharset:
81 # Code from module locale: 121 # Code from module locale:
82 # Code from module localeconv: 122 # Code from module localeconv:
83 # Code from module lock: 123 # Code from module lock:
124 # Code from module lseek:
84 # Code from module malloc-gnu: 125 # Code from module malloc-gnu:
85 # Code from module malloc-posix: 126 # Code from module malloc-posix:
86 # Code from module malloca: 127 # Code from module malloca:
@@ -89,6 +130,7 @@ AC_DEFUN([gl_EARLY],
89 # Code from module mbsinit: 130 # Code from module mbsinit:
90 # Code from module mbtowc: 131 # Code from module mbtowc:
91 # Code from module memchr: 132 # Code from module memchr:
133 # Code from module minmax:
92 # Code from module mktime: 134 # Code from module mktime:
93 # Code from module mktime-internal: 135 # Code from module mktime-internal:
94 # Code from module mountlist: 136 # Code from module mountlist:
@@ -99,11 +141,15 @@ AC_DEFUN([gl_EARLY],
99 # Code from module netinet_in: 141 # Code from module netinet_in:
100 # Code from module nl_langinfo: 142 # Code from module nl_langinfo:
101 # Code from module nocrash: 143 # Code from module nocrash:
102 # Code from module read: 144 # Code from module open:
145 # Code from module pathmax:
146 # Code from module realloc-gnu:
147 # Code from module realloc-posix:
148 # Code from module reallocarray:
103 # Code from module regex: 149 # Code from module regex:
104 # Code from module safe-read:
105 # Code from module servent: 150 # Code from module servent:
106 # Code from module setenv: 151 # Code from module setenv:
152 # Code from module setlocale-null:
107 # Code from module size_max: 153 # Code from module size_max:
108 # Code from module snippet/_Noreturn: 154 # Code from module snippet/_Noreturn:
109 # Code from module snippet/arg-nonnull: 155 # Code from module snippet/arg-nonnull:
@@ -114,8 +160,12 @@ AC_DEFUN([gl_EARLY],
114 # Code from module sockets: 160 # Code from module sockets:
115 # Code from module socklen: 161 # Code from module socklen:
116 # Code from module ssize_t: 162 # Code from module ssize_t:
163 # Code from module stat:
164 # Code from module stat-time:
165 # Code from module std-gnu11:
117 # Code from module stdalign: 166 # Code from module stdalign:
118 # Code from module stdbool: 167 # Code from module stdbool:
168 # Code from module stdckdint:
119 # Code from module stddef: 169 # Code from module stddef:
120 # Code from module stdint: 170 # Code from module stdint:
121 # Code from module stdio: 171 # Code from module stdio:
@@ -128,11 +178,10 @@ AC_DEFUN([gl_EARLY],
128 # Code from module strerror-override: 178 # Code from module strerror-override:
129 # Code from module string: 179 # Code from module string:
130 # Code from module strings: 180 # Code from module strings:
131 # Code from module strndup:
132 # Code from module strnlen:
133 # Code from module strsep: 181 # Code from module strsep:
134 # Code from module strstr-simple: 182 # Code from module strstr-simple:
135 # Code from module sys_socket: 183 # Code from module sys_socket:
184 # Code from module sys_stat:
136 # Code from module sys_types: 185 # Code from module sys_types:
137 # Code from module sys_uio: 186 # Code from module sys_uio:
138 # Code from module threadlib: 187 # Code from module threadlib:
@@ -141,7 +190,9 @@ AC_DEFUN([gl_EARLY],
141 # Code from module time_r: 190 # Code from module time_r:
142 # Code from module timegm: 191 # Code from module timegm:
143 # Code from module unistd: 192 # Code from module unistd:
193 # Code from module unlocked-io-internal:
144 # Code from module unsetenv: 194 # Code from module unsetenv:
195 # Code from module vararrays:
145 # Code from module vasnprintf: 196 # Code from module vasnprintf:
146 # Code from module vasprintf: 197 # Code from module vasprintf:
147 # Code from module verify: 198 # Code from module verify:
@@ -149,11 +200,14 @@ AC_DEFUN([gl_EARLY],
149 # Code from module wchar: 200 # Code from module wchar:
150 # Code from module wcrtomb: 201 # Code from module wcrtomb:
151 # Code from module wctype-h: 202 # Code from module wctype-h:
203 # Code from module windows-mutex:
204 # Code from module windows-once:
205 # Code from module windows-recmutex:
206 # Code from module windows-rwlock:
152 # Code from module xalloc: 207 # Code from module xalloc:
153 # Code from module xalloc-die: 208 # Code from module xalloc-die:
154 # Code from module xalloc-oversized: 209 # Code from module xalloc-oversized:
155 # Code from module xsize: 210 # Code from module xsize:
156 # Code from module xstrndup:
157]) 211])
158 212
159# This macro should be invoked from ./configure.ac, in the section 213# This macro should be invoked from ./configure.ac, in the section
@@ -170,154 +224,300 @@ AC_DEFUN([gl_INIT],
170 m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES])) 224 m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES]))
171 m4_pushdef([gl_LIBSOURCES_LIST], []) 225 m4_pushdef([gl_LIBSOURCES_LIST], [])
172 m4_pushdef([gl_LIBSOURCES_DIR], []) 226 m4_pushdef([gl_LIBSOURCES_DIR], [])
227 m4_pushdef([GL_MACRO_PREFIX], [gl])
228 m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL])
173 gl_COMMON 229 gl_COMMON
174 gl_source_base='gl' 230 gl_source_base='gl'
231 gl_source_base_prefix=
175 gl_FUNC_ALLOCA 232 gl_FUNC_ALLOCA
176 gl_HEADER_ARPA_INET 233 gl_CONDITIONAL_HEADER([alloca.h])
234 AC_PROG_MKDIR_P
235 gl_ARPA_INET_H
236 gl_ARPA_INET_H_REQUIRE_DEFAULTS
237 AC_PROG_MKDIR_P
238 gl_ASSERT_H
239 gl_CONDITIONAL_HEADER([assert.h])
177 AC_PROG_MKDIR_P 240 AC_PROG_MKDIR_P
178 gl_FUNC_BASE64 241 gl_FUNC_BASE64
179 gl_FUNC_BTOWC 242 gl_FUNC_BTOWC
180 if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then 243 gl_CONDITIONAL([GL_COND_OBJ_BTOWC],
181 AC_LIBOBJ([btowc]) 244 [test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1])
245 AM_COND_IF([GL_COND_OBJ_BTOWC], [
182 gl_PREREQ_BTOWC 246 gl_PREREQ_BTOWC
183 fi 247 ])
184 gl_WCHAR_MODULE_INDICATOR([btowc]) 248 gl_WCHAR_MODULE_INDICATOR([btowc])
185 gl_CONFIGMAKE_PREP 249 gl___BUILTIN_EXPECT
186 gl_SHA1 250 gl_BYTESWAP
187 gl_DIRNAME 251 gl_CONDITIONAL_HEADER([byteswap.h])
252 AC_PROG_MKDIR_P
253 gl_FUNC_CALLOC_GNU
254 if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 1; then
255 AC_LIBOBJ([calloc])
256 fi
257 gl_STDLIB_MODULE_INDICATOR([calloc-gnu])
258 gl_FUNC_CALLOC_POSIX
259 if test $REPLACE_CALLOC_FOR_CALLOC_POSIX = 1; then
260 AC_LIBOBJ([calloc])
261 fi
262 gl_STDLIB_MODULE_INDICATOR([calloc-posix])
263 gl_MODULE_INDICATOR_FOR_TESTS([cloexec])
264 gl_FUNC_CLOSE
265 gl_CONDITIONAL([GL_COND_OBJ_CLOSE], [test $REPLACE_CLOSE = 1])
266 gl_UNISTD_MODULE_INDICATOR([close])
267 gl_AF_ALG
268 AC_REQUIRE([AC_C_RESTRICT])
269 gl_SHA256
188 gl_MODULE_INDICATOR([dirname]) 270 gl_MODULE_INDICATOR([dirname])
189 gl_DIRNAME_LGPL
190 gl_DOUBLE_SLASH_ROOT 271 gl_DOUBLE_SLASH_ROOT
272 gl_FUNC_DUP2
273 gl_CONDITIONAL([GL_COND_OBJ_DUP2], [test $REPLACE_DUP2 = 1])
274 AM_COND_IF([GL_COND_OBJ_DUP2], [
275 gl_PREREQ_DUP2
276 ])
277 gl_UNISTD_MODULE_INDICATOR([dup2])
191 gl_ENVIRON 278 gl_ENVIRON
192 gl_UNISTD_MODULE_INDICATOR([environ]) 279 gl_UNISTD_MODULE_INDICATOR([environ])
193 gl_HEADER_ERRNO_H 280 gl_HEADER_ERRNO_H
281 gl_CONDITIONAL_HEADER([errno.h])
282 AC_PROG_MKDIR_P
194 gl_ERROR 283 gl_ERROR
195 if test $ac_cv_lib_error_at_line = no; then 284 gl_CONDITIONAL([GL_COND_OBJ_ERROR], [test "$ac_cv_lib_error_at_line" = no])
196 AC_LIBOBJ([error]) 285 AM_COND_IF([GL_COND_OBJ_ERROR], [
197 gl_PREREQ_ERROR 286 gl_PREREQ_ERROR
198 fi 287 ])
199 m4_ifdef([AM_XGETTEXT_OPTION], 288 m4_ifdef([AM_XGETTEXT_OPTION],
200 [AM_][XGETTEXT_OPTION([--flag=error:3:c-format]) 289 [AM_][XGETTEXT_OPTION([--flag=error:3:c-format])
201 AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])]) 290 AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])])
202 AC_REQUIRE([gl_EXTERN_INLINE]) 291 AC_REQUIRE([gl_EXTERN_INLINE])
292 gl_FUNC_FCNTL
293 gl_CONDITIONAL([GL_COND_OBJ_FCNTL],
294 [test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1])
295 gl_FCNTL_MODULE_INDICATOR([fcntl])
296 gl_FCNTL_H
297 gl_FCNTL_H_REQUIRE_DEFAULTS
298 AC_PROG_MKDIR_P
299 gl_FUNC_FFLUSH
300 gl_CONDITIONAL([GL_COND_OBJ_FFLUSH], [test $REPLACE_FFLUSH = 1])
301 AM_COND_IF([GL_COND_OBJ_FFLUSH], [
302 gl_PREREQ_FFLUSH
303 ])
304 gl_MODULE_INDICATOR([fflush])
305 gl_STDIO_MODULE_INDICATOR([fflush])
203 gl_FLOAT_H 306 gl_FLOAT_H
204 if test $REPLACE_FLOAT_LDBL = 1; then 307 gl_CONDITIONAL_HEADER([float.h])
205 AC_LIBOBJ([float]) 308 AC_PROG_MKDIR_P
206 fi 309 gl_CONDITIONAL([GL_COND_OBJ_FLOAT], [test $REPLACE_FLOAT_LDBL = 1])
207 if test $REPLACE_ITOLD = 1; then 310 gl_CONDITIONAL([GL_COND_OBJ_ITOLD], [test $REPLACE_ITOLD = 1])
208 AC_LIBOBJ([itold])
209 fi
210 gl_FUNC_FLOORF 311 gl_FUNC_FLOORF
211 if test $HAVE_DECL_FLOORF = 0 || test $REPLACE_FLOORF = 1; then 312 gl_CONDITIONAL([GL_COND_OBJ_FLOORF],
212 AC_LIBOBJ([floorf]) 313 [test $HAVE_DECL_FLOORF = 0 || test $REPLACE_FLOORF = 1])
213 fi
214 gl_MATH_MODULE_INDICATOR([floorf]) 314 gl_MATH_MODULE_INDICATOR([floorf])
315 gl_FUNC_FOPEN
316 if test $REPLACE_FOPEN = 1; then
317 AC_LIBOBJ([fopen])
318 gl_PREREQ_FOPEN
319 fi
320 gl_STDIO_MODULE_INDICATOR([fopen])
321 gl_FUNC_FOPEN_GNU
322 if test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1; then
323 AC_LIBOBJ([fopen])
324 gl_PREREQ_FOPEN
325 fi
326 gl_MODULE_INDICATOR([fopen-gnu])
327 gl_STDIO_MODULE_INDICATOR([fopen-gnu])
328 gl_FUNC_FPURGE
329 gl_CONDITIONAL([GL_COND_OBJ_FPURGE],
330 [test $HAVE_FPURGE = 0 || test $REPLACE_FPURGE = 1])
331 gl_STDIO_MODULE_INDICATOR([fpurge])
332 gl_FUNC_FREADING
333 gl_FUNC_FREE
334 gl_CONDITIONAL([GL_COND_OBJ_FREE], [test $REPLACE_FREE = 1])
335 AM_COND_IF([GL_COND_OBJ_FREE], [
336 gl_PREREQ_FREE
337 ])
338 gl_STDLIB_MODULE_INDICATOR([free-posix])
339 gl_FUNC_FSEEK
340 gl_CONDITIONAL([GL_COND_OBJ_FSEEK], [test $REPLACE_FSEEK = 1])
341 gl_STDIO_MODULE_INDICATOR([fseek])
342 gl_FUNC_FSEEKO
343 gl_CONDITIONAL([GL_COND_OBJ_FSEEKO],
344 [test $HAVE_FSEEKO = 0 || test $REPLACE_FSEEKO = 1])
345 AM_COND_IF([GL_COND_OBJ_FSEEKO], [
346 gl_PREREQ_FSEEKO
347 ])
348 gl_STDIO_MODULE_INDICATOR([fseeko])
349 gl_FUNC_FSTAT
350 gl_CONDITIONAL([GL_COND_OBJ_FSTAT], [test $REPLACE_FSTAT = 1])
351 AM_COND_IF([GL_COND_OBJ_FSTAT], [
352 case "$host_os" in
353 mingw*)
354 AC_LIBOBJ([stat-w32])
355 ;;
356 esac
357 gl_PREREQ_FSTAT
358 ])
359 gl_SYS_STAT_MODULE_INDICATOR([fstat])
215 gl_FSUSAGE 360 gl_FSUSAGE
216 if test $gl_cv_fs_space = yes; then 361 gl_CONDITIONAL([GL_COND_OBJ_FSUSAGE], [test $gl_cv_fs_space = yes])
217 AC_LIBOBJ([fsusage]) 362 AM_COND_IF([GL_COND_OBJ_FSUSAGE], [
218 gl_PREREQ_FSUSAGE_EXTRA 363 gl_PREREQ_FSUSAGE_EXTRA
219 fi 364 ])
365 gl_FUNC_FTELL
366 gl_CONDITIONAL([GL_COND_OBJ_FTELL], [test $REPLACE_FTELL = 1])
367 gl_STDIO_MODULE_INDICATOR([ftell])
368 gl_FUNC_FTELLO
369 gl_CONDITIONAL([GL_COND_OBJ_FTELLO],
370 [test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1])
371 AM_COND_IF([GL_COND_OBJ_FTELLO], [
372 gl_PREREQ_FTELLO
373 ])
374 gl_STDIO_MODULE_INDICATOR([ftello])
220 gl_GETADDRINFO 375 gl_GETADDRINFO
221 if test $HAVE_GETADDRINFO = 0; then 376 gl_CONDITIONAL([GL_COND_OBJ_GETADDRINFO],
222 AC_LIBOBJ([getaddrinfo]) 377 [test $HAVE_GETADDRINFO = 0 || test $REPLACE_GETADDRINFO = 1])
223 fi 378 gl_CONDITIONAL([GL_COND_OBJ_GAI_STRERROR],
224 if test $HAVE_DECL_GAI_STRERROR = 0 || test $REPLACE_GAI_STRERROR = 1; then 379 [test $HAVE_DECL_GAI_STRERROR = 0 || test $REPLACE_GAI_STRERROR = 1])
225 AC_LIBOBJ([gai_strerror])
226 fi
227 gl_NETDB_MODULE_INDICATOR([getaddrinfo]) 380 gl_NETDB_MODULE_INDICATOR([getaddrinfo])
381 gl_FUNC_GETDELIM
382 gl_CONDITIONAL([GL_COND_OBJ_GETDELIM],
383 [test $HAVE_GETDELIM = 0 || test $REPLACE_GETDELIM = 1])
384 AM_COND_IF([GL_COND_OBJ_GETDELIM], [
385 gl_PREREQ_GETDELIM
386 ])
387 gl_STDIO_MODULE_INDICATOR([getdelim])
388 gl_FUNC_GETDTABLESIZE
389 gl_CONDITIONAL([GL_COND_OBJ_GETDTABLESIZE],
390 [test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1])
391 AM_COND_IF([GL_COND_OBJ_GETDTABLESIZE], [
392 gl_PREREQ_GETDTABLESIZE
393 ])
394 gl_UNISTD_MODULE_INDICATOR([getdtablesize])
228 gl_FUNC_GETHOSTNAME 395 gl_FUNC_GETHOSTNAME
229 if test $HAVE_GETHOSTNAME = 0; then 396 gl_CONDITIONAL([GL_COND_OBJ_GETHOSTNAME], [test $HAVE_GETHOSTNAME = 0])
230 AC_LIBOBJ([gethostname]) 397 AM_COND_IF([GL_COND_OBJ_GETHOSTNAME], [
231 gl_PREREQ_GETHOSTNAME 398 gl_PREREQ_GETHOSTNAME
232 fi 399 ])
233 gl_UNISTD_MODULE_INDICATOR([gethostname]) 400 gl_UNISTD_MODULE_INDICATOR([gethostname])
401 gl_FUNC_GETLINE
402 gl_CONDITIONAL([GL_COND_OBJ_GETLINE], [test $REPLACE_GETLINE = 1])
403 AM_COND_IF([GL_COND_OBJ_GETLINE], [
404 gl_PREREQ_GETLINE
405 ])
406 gl_STDIO_MODULE_INDICATOR([getline])
407 AC_REQUIRE([AC_CANONICAL_HOST])
234 gl_GETLOADAVG 408 gl_GETLOADAVG
235 if test $HAVE_GETLOADAVG = 0; then 409 gl_CONDITIONAL([GL_COND_OBJ_GETLOADAVG], [test $HAVE_GETLOADAVG = 0])
236 AC_LIBOBJ([getloadavg]) 410 AM_COND_IF([GL_COND_OBJ_GETLOADAVG], [
237 gl_PREREQ_GETLOADAVG 411 gl_PREREQ_GETLOADAVG
238 fi 412 ])
239 gl_STDLIB_MODULE_INDICATOR([getloadavg]) 413 gl_STDLIB_MODULE_INDICATOR([getloadavg])
240 gl_FUNC_GETOPT_GNU 414 gl_FUNC_GETOPT_GNU
241 if test $REPLACE_GETOPT = 1; then 415 dnl Because of the way gl_FUNC_GETOPT_GNU is implemented (the gl_getopt_required
242 AC_LIBOBJ([getopt]) 416 dnl mechanism), there is no need to do any AC_LIBOBJ or AC_SUBST here; they are
243 AC_LIBOBJ([getopt1]) 417 dnl done in the getopt-posix module.
244 gl_PREREQ_GETOPT
245 dnl Arrange for unistd.h to include getopt.h.
246 GNULIB_GL_UNISTD_H_GETOPT=1
247 fi
248 AC_SUBST([GNULIB_GL_UNISTD_H_GETOPT])
249 gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu])
250 gl_FUNC_GETOPT_POSIX 418 gl_FUNC_GETOPT_POSIX
251 if test $REPLACE_GETOPT = 1; then 419 gl_CONDITIONAL_HEADER([getopt.h])
252 AC_LIBOBJ([getopt]) 420 gl_CONDITIONAL_HEADER([getopt-cdefs.h])
253 AC_LIBOBJ([getopt1]) 421 AC_PROG_MKDIR_P
254 gl_PREREQ_GETOPT 422 gl_CONDITIONAL([GL_COND_OBJ_GETOPT], [test $REPLACE_GETOPT = 1])
255 dnl Arrange for unistd.h to include getopt.h. 423 AM_COND_IF([GL_COND_OBJ_GETOPT], [
256 GNULIB_GL_UNISTD_H_GETOPT=1 424 dnl Define the substituted variable GNULIB_UNISTD_H_GETOPT to 1.
257 fi 425 gl_UNISTD_H_REQUIRE_DEFAULTS
258 AC_SUBST([GNULIB_GL_UNISTD_H_GETOPT]) 426 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT], [1])
259 dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac. 427 ])
260 AM_GNU_GETTEXT_VERSION([0.18.1]) 428 gl_UNISTD_MODULE_INDICATOR([getopt-posix])
429 gl_FUNC_GETPROGNAME
261 AC_SUBST([LIBINTL]) 430 AC_SUBST([LIBINTL])
262 AC_SUBST([LTLIBINTL]) 431 AC_SUBST([LTLIBINTL])
432 AC_PROG_MKDIR_P
433 AC_REQUIRE([gl_FUNC_SETLOCALE_NULL])
434 LIB_HARD_LOCALE="$LIB_SETLOCALE_NULL"
435 AC_SUBST([LIB_HARD_LOCALE])
263 gl_HOSTENT 436 gl_HOSTENT
264 gl_IDPRIV 437 gl_IDPRIV
265 gl_FUNC_INET_NTOP 438 gl_FUNC_INET_NTOP
266 if test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1; then 439 gl_CONDITIONAL([GL_COND_OBJ_INET_NTOP],
267 AC_LIBOBJ([inet_ntop]) 440 [test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1])
441 AM_COND_IF([GL_COND_OBJ_INET_NTOP], [
268 gl_PREREQ_INET_NTOP 442 gl_PREREQ_INET_NTOP
269 fi 443 ])
270 gl_ARPA_INET_MODULE_INDICATOR([inet_ntop]) 444 gl_ARPA_INET_MODULE_INDICATOR([inet_ntop])
445 gl_INTTYPES_INCOMPLETE
446 gl_INTTYPES_H_REQUIRE_DEFAULTS
447 AC_PROG_MKDIR_P
271 gl_LANGINFO_H 448 gl_LANGINFO_H
449 gl_LANGINFO_H_REQUIRE_DEFAULTS
450 AC_PROG_MKDIR_P
272 AC_REQUIRE([gl_LARGEFILE]) 451 AC_REQUIRE([gl_LARGEFILE])
452 gl___INLINE
453 gl_LIMITS_H
454 gl_CONDITIONAL_HEADER([limits.h])
455 AC_PROG_MKDIR_P
273 gl_LOCALCHARSET 456 gl_LOCALCHARSET
274 LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(abs_top_builddir)/$gl_source_base\"" 457 dnl For backward compatibility. Some packages still use this.
458 LOCALCHARSET_TESTS_ENVIRONMENT=
275 AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT]) 459 AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT])
276 gl_LOCALE_H 460 gl_LOCALE_H
461 gl_LOCALE_H_REQUIRE_DEFAULTS
462 AC_PROG_MKDIR_P
277 gl_FUNC_LOCALECONV 463 gl_FUNC_LOCALECONV
278 if test $REPLACE_LOCALECONV = 1; then 464 gl_CONDITIONAL([GL_COND_OBJ_LOCALECONV], [test $REPLACE_LOCALECONV = 1])
279 AC_LIBOBJ([localeconv]) 465 AM_COND_IF([GL_COND_OBJ_LOCALECONV], [
280 gl_PREREQ_LOCALECONV 466 gl_PREREQ_LOCALECONV
281 fi 467 ])
282 gl_LOCALE_MODULE_INDICATOR([localeconv]) 468 gl_LOCALE_MODULE_INDICATOR([localeconv])
283 gl_LOCK 469 gl_LOCK
284 gl_MODULE_INDICATOR([lock]) 470 gl_MODULE_INDICATOR([lock])
471 gl_FUNC_LSEEK
472 gl_CONDITIONAL([GL_COND_OBJ_LSEEK], [test $REPLACE_LSEEK = 1])
473 gl_UNISTD_MODULE_INDICATOR([lseek])
285 gl_FUNC_MALLOC_GNU 474 gl_FUNC_MALLOC_GNU
286 if test $REPLACE_MALLOC = 1; then 475 if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1; then
287 AC_LIBOBJ([malloc]) 476 AC_LIBOBJ([malloc])
288 fi 477 fi
289 gl_MODULE_INDICATOR([malloc-gnu]) 478 gl_STDLIB_MODULE_INDICATOR([malloc-gnu])
290 gl_FUNC_MALLOC_POSIX 479 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
291 if test $REPLACE_MALLOC = 1; then 480 if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
292 AC_LIBOBJ([malloc]) 481 AC_LIBOBJ([malloc])
293 fi 482 fi
294 gl_STDLIB_MODULE_INDICATOR([malloc-posix]) 483 gl_STDLIB_MODULE_INDICATOR([malloc-posix])
295 gl_MALLOCA 484 gl_MALLOCA
296 gl_MATH_H 485 gl_MATH_H
486 gl_MATH_H_REQUIRE_DEFAULTS
487 AC_PROG_MKDIR_P
297 gl_FUNC_MBRTOWC 488 gl_FUNC_MBRTOWC
298 if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then 489 gl_CONDITIONAL([GL_COND_OBJ_MBRTOWC],
299 AC_LIBOBJ([mbrtowc]) 490 [test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1])
491 AM_COND_IF([GL_COND_OBJ_MBRTOWC], [
492 if test $REPLACE_MBSTATE_T = 1; then
493 AC_LIBOBJ([lc-charset-dispatch])
494 AC_LIBOBJ([mbtowc-lock])
495 gl_PREREQ_MBTOWC_LOCK
496 fi
300 gl_PREREQ_MBRTOWC 497 gl_PREREQ_MBRTOWC
301 fi 498 ])
302 gl_WCHAR_MODULE_INDICATOR([mbrtowc]) 499 gl_WCHAR_MODULE_INDICATOR([mbrtowc])
303 gl_FUNC_MBSINIT 500 gl_FUNC_MBSINIT
304 if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then 501 gl_CONDITIONAL([GL_COND_OBJ_MBSINIT],
305 AC_LIBOBJ([mbsinit]) 502 [test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1])
503 AM_COND_IF([GL_COND_OBJ_MBSINIT], [
306 gl_PREREQ_MBSINIT 504 gl_PREREQ_MBSINIT
307 fi 505 ])
308 gl_WCHAR_MODULE_INDICATOR([mbsinit]) 506 gl_WCHAR_MODULE_INDICATOR([mbsinit])
309 gl_FUNC_MBTOWC 507 gl_FUNC_MBTOWC
310 if test $REPLACE_MBTOWC = 1; then 508 gl_CONDITIONAL([GL_COND_OBJ_MBTOWC],
311 AC_LIBOBJ([mbtowc]) 509 [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1])
510 AM_COND_IF([GL_COND_OBJ_MBTOWC], [
312 gl_PREREQ_MBTOWC 511 gl_PREREQ_MBTOWC
313 fi 512 ])
314 gl_STDLIB_MODULE_INDICATOR([mbtowc]) 513 gl_STDLIB_MODULE_INDICATOR([mbtowc])
315 gl_FUNC_MEMCHR 514 gl_FUNC_MEMCHR
316 if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then 515 gl_CONDITIONAL([GL_COND_OBJ_MEMCHR], [test $REPLACE_MEMCHR = 1])
317 AC_LIBOBJ([memchr]) 516 AM_COND_IF([GL_COND_OBJ_MEMCHR], [
318 gl_PREREQ_MEMCHR 517 gl_PREREQ_MEMCHR
319 fi 518 ])
320 gl_STRING_MODULE_INDICATOR([memchr]) 519 gl_STRING_MODULE_INDICATOR([memchr])
520 gl_MINMAX
321 gl_FUNC_MKTIME 521 gl_FUNC_MKTIME
322 if test $REPLACE_MKTIME = 1; then 522 if test $REPLACE_MKTIME = 1; then
323 AC_LIBOBJ([mktime]) 523 AC_LIBOBJ([mktime])
@@ -325,73 +525,162 @@ AC_DEFUN([gl_INIT],
325 fi 525 fi
326 gl_TIME_MODULE_INDICATOR([mktime]) 526 gl_TIME_MODULE_INDICATOR([mktime])
327 gl_FUNC_MKTIME_INTERNAL 527 gl_FUNC_MKTIME_INTERNAL
328 if test $REPLACE_MKTIME = 1; then 528 if test $WANT_MKTIME_INTERNAL = 1; then
329 AC_LIBOBJ([mktime]) 529 AC_LIBOBJ([mktime])
330 gl_PREREQ_MKTIME 530 gl_PREREQ_MKTIME
331 fi 531 fi
332 gl_MOUNTLIST 532 gl_MOUNTLIST
333 if test $gl_cv_list_mounted_fs = yes; then 533 gl_CONDITIONAL([GL_COND_OBJ_MOUNTLIST], [test $gl_cv_list_mounted_fs = yes])
334 AC_LIBOBJ([mountlist]) 534 AM_COND_IF([GL_COND_OBJ_MOUNTLIST], [
335 gl_PREREQ_MOUNTLIST_EXTRA 535 gl_PREREQ_MOUNTLIST_EXTRA
336 fi 536 ])
337 gl_MSVC_INVAL 537 AC_REQUIRE([gl_MSVC_INVAL])
338 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then 538 gl_CONDITIONAL([GL_COND_OBJ_MSVC_INVAL],
339 AC_LIBOBJ([msvc-inval]) 539 [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1])
340 fi 540 AC_REQUIRE([gl_MSVC_NOTHROW])
341 gl_MSVC_NOTHROW 541 gl_CONDITIONAL([GL_COND_OBJ_MSVC_NOTHROW],
342 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then 542 [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1])
343 AC_LIBOBJ([msvc-nothrow]) 543 gl_MODULE_INDICATOR([msvc-nothrow])
344 fi
345 gl_MULTIARCH 544 gl_MULTIARCH
346 gl_HEADER_NETDB 545 gl_NETDB_H
546 gl_NETDB_H_REQUIRE_DEFAULTS
547 AC_PROG_MKDIR_P
347 gl_HEADER_NETINET_IN 548 gl_HEADER_NETINET_IN
549 gl_CONDITIONAL_HEADER([netinet/in.h])
348 AC_PROG_MKDIR_P 550 AC_PROG_MKDIR_P
349 gl_FUNC_NL_LANGINFO 551 gl_FUNC_NL_LANGINFO
350 if test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1; then 552 gl_CONDITIONAL([GL_COND_OBJ_NL_LANGINFO],
351 AC_LIBOBJ([nl_langinfo]) 553 [test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1])
554 gl_CONDITIONAL([GL_COND_OBJ_NL_LANGINFO_LOCK],
555 [test $REPLACE_NL_LANGINFO = 1 && test $NL_LANGINFO_MTSAFE = 0])
556 if test $REPLACE_NL_LANGINFO = 1 && test $NL_LANGINFO_MTSAFE = 0; then
557 gl_PREREQ_NL_LANGINFO_LOCK
352 fi 558 fi
353 gl_LANGINFO_MODULE_INDICATOR([nl_langinfo]) 559 gl_LANGINFO_MODULE_INDICATOR([nl_langinfo])
354 gl_FUNC_READ 560 gl_FUNC_OPEN
355 if test $REPLACE_READ = 1; then 561 gl_CONDITIONAL([GL_COND_OBJ_OPEN], [test $REPLACE_OPEN = 1])
356 AC_LIBOBJ([read]) 562 AM_COND_IF([GL_COND_OBJ_OPEN], [
357 gl_PREREQ_READ 563 gl_PREREQ_OPEN
564 ])
565 gl_FCNTL_MODULE_INDICATOR([open])
566 gl_PATHMAX
567 gl_FUNC_REALLOC_GNU
568 if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then
569 AC_LIBOBJ([realloc])
570 fi
571 gl_STDLIB_MODULE_INDICATOR([realloc-gnu])
572 gl_FUNC_REALLOC_POSIX
573 if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then
574 AC_LIBOBJ([realloc])
358 fi 575 fi
359 gl_UNISTD_MODULE_INDICATOR([read]) 576 gl_STDLIB_MODULE_INDICATOR([realloc-posix])
577 gl_FUNC_REALLOCARRAY
578 gl_CONDITIONAL([GL_COND_OBJ_REALLOCARRAY],
579 [test $HAVE_REALLOCARRAY = 0 || test $REPLACE_REALLOCARRAY = 1])
580 AM_COND_IF([GL_COND_OBJ_REALLOCARRAY], [
581 gl_PREREQ_REALLOCARRAY
582 ])
583 gl_MODULE_INDICATOR([reallocarray])
584 gl_STDLIB_MODULE_INDICATOR([reallocarray])
360 gl_REGEX 585 gl_REGEX
361 if test $ac_use_included_regex = yes; then 586 gl_CONDITIONAL([GL_COND_OBJ_REGEX], [test $ac_use_included_regex = yes])
362 AC_LIBOBJ([regex]) 587 AM_COND_IF([GL_COND_OBJ_REGEX], [
363 gl_PREREQ_REGEX 588 gl_PREREQ_REGEX
364 fi 589 ])
365 gl_PREREQ_SAFE_READ
366 gl_SERVENT 590 gl_SERVENT
367 gl_FUNC_SETENV 591 gl_FUNC_SETENV
368 if test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1; then 592 gl_CONDITIONAL([GL_COND_OBJ_SETENV],
369 AC_LIBOBJ([setenv]) 593 [test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1])
370 fi
371 gl_STDLIB_MODULE_INDICATOR([setenv]) 594 gl_STDLIB_MODULE_INDICATOR([setenv])
595 gl_FUNC_SETLOCALE_NULL
596 gl_CONDITIONAL([GL_COND_OBJ_SETLOCALE_LOCK],
597 [test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0])
598 AM_COND_IF([GL_COND_OBJ_SETLOCALE_LOCK], [
599 gl_PREREQ_SETLOCALE_LOCK
600 ])
601 gl_LOCALE_MODULE_INDICATOR([setlocale_null])
372 gl_SIZE_MAX 602 gl_SIZE_MAX
373 gl_FUNC_SNPRINTF 603 gl_FUNC_SNPRINTF
374 gl_STDIO_MODULE_INDICATOR([snprintf]) 604 gl_STDIO_MODULE_INDICATOR([snprintf])
375 gl_MODULE_INDICATOR([snprintf]) 605 gl_MODULE_INDICATOR([snprintf])
376 gl_SOCKETLIB 606 AC_REQUIRE([gl_SOCKETLIB])
377 gl_SOCKETS 607 AC_REQUIRE([gl_SOCKETS])
378 gl_TYPE_SOCKLEN_T 608 gl_TYPE_SOCKLEN_T
379 gt_TYPE_SSIZE_T 609 gt_TYPE_SSIZE_T
610 gl_FUNC_STAT
611 gl_CONDITIONAL([GL_COND_OBJ_STAT], [test $REPLACE_STAT = 1])
612 AM_COND_IF([GL_COND_OBJ_STAT], [
613 case "$host_os" in
614 mingw*)
615 AC_LIBOBJ([stat-w32])
616 ;;
617 esac
618 gl_PREREQ_STAT
619 ])
620 gl_SYS_STAT_MODULE_INDICATOR([stat])
621 gl_STAT_TIME
622 gl_STAT_BIRTHTIME
380 gl_STDALIGN_H 623 gl_STDALIGN_H
381 AM_STDBOOL_H 624 gl_CONDITIONAL_HEADER([stdalign.h])
625 AC_PROG_MKDIR_P
626 gl_C_BOOL
627 AC_CHECK_HEADERS_ONCE([stdckdint.h])
628 if test $ac_cv_header_stdckdint_h = yes; then
629 GL_GENERATE_STDCKDINT_H=false
630 else
631 GL_GENERATE_STDCKDINT_H=true
632 fi
633 gl_CONDITIONAL_HEADER([stdckdint.h])
634 AC_PROG_MKDIR_P
382 gl_STDDEF_H 635 gl_STDDEF_H
636 gl_STDDEF_H_REQUIRE_DEFAULTS
637 gl_CONDITIONAL_HEADER([stddef.h])
638 AC_PROG_MKDIR_P
383 gl_STDINT_H 639 gl_STDINT_H
640 gl_CONDITIONAL_HEADER([stdint.h])
641 dnl Because of gl_REPLACE_LIMITS_H:
642 gl_CONDITIONAL_HEADER([limits.h])
643 AC_PROG_MKDIR_P
384 gl_STDIO_H 644 gl_STDIO_H
645 gl_STDIO_H_REQUIRE_DEFAULTS
646 AC_PROG_MKDIR_P
647 gl_CONDITIONAL([GL_COND_OBJ_STDIO_READ], [test $REPLACE_STDIO_READ_FUNCS = 1])
648 gl_CONDITIONAL([GL_COND_OBJ_STDIO_WRITE], [test $REPLACE_STDIO_WRITE_FUNCS = 1])
649 dnl No need to create extra modules for these functions. Everyone who uses
650 dnl <stdio.h> likely needs them.
651 gl_STDIO_MODULE_INDICATOR([fscanf])
652 gl_MODULE_INDICATOR([fscanf])
653 gl_STDIO_MODULE_INDICATOR([scanf])
654 gl_MODULE_INDICATOR([scanf])
655 gl_STDIO_MODULE_INDICATOR([fgetc])
656 gl_STDIO_MODULE_INDICATOR([getc])
657 gl_STDIO_MODULE_INDICATOR([getchar])
658 gl_STDIO_MODULE_INDICATOR([fgets])
659 gl_STDIO_MODULE_INDICATOR([fread])
660 dnl No need to create extra modules for these functions. Everyone who uses
661 dnl <stdio.h> likely needs them.
662 gl_STDIO_MODULE_INDICATOR([fprintf])
663 gl_STDIO_MODULE_INDICATOR([printf])
664 gl_STDIO_MODULE_INDICATOR([vfprintf])
665 gl_STDIO_MODULE_INDICATOR([vprintf])
666 gl_STDIO_MODULE_INDICATOR([fputc])
667 gl_STDIO_MODULE_INDICATOR([putc])
668 gl_STDIO_MODULE_INDICATOR([putchar])
669 gl_STDIO_MODULE_INDICATOR([fputs])
670 gl_STDIO_MODULE_INDICATOR([puts])
671 gl_STDIO_MODULE_INDICATOR([fwrite])
385 gl_STDLIB_H 672 gl_STDLIB_H
673 gl_STDLIB_H_REQUIRE_DEFAULTS
674 AC_PROG_MKDIR_P
386 gl_STRCASE 675 gl_STRCASE
387 if test $HAVE_STRCASECMP = 0; then 676 gl_CONDITIONAL([GL_COND_OBJ_STRCASECMP], [test $HAVE_STRCASECMP = 0])
388 AC_LIBOBJ([strcasecmp]) 677 AM_COND_IF([GL_COND_OBJ_STRCASECMP], [
389 gl_PREREQ_STRCASECMP 678 gl_PREREQ_STRCASECMP
390 fi 679 ])
391 if test $HAVE_STRNCASECMP = 0; then 680 gl_CONDITIONAL([GL_COND_OBJ_STRNCASECMP], [test $HAVE_STRNCASECMP = 0])
392 AC_LIBOBJ([strncasecmp]) 681 AM_COND_IF([GL_COND_OBJ_STRNCASECMP], [
393 gl_PREREQ_STRNCASECMP 682 gl_PREREQ_STRNCASECMP
394 fi 683 ])
395 gl_FUNC_STRCASESTR 684 gl_FUNC_STRCASESTR
396 if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then 685 if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then
397 AC_LIBOBJ([strcasestr]) 686 AC_LIBOBJ([strcasestr])
@@ -404,68 +693,76 @@ AC_DEFUN([gl_INIT],
404 fi 693 fi
405 gl_STRING_MODULE_INDICATOR([strcasestr]) 694 gl_STRING_MODULE_INDICATOR([strcasestr])
406 gl_FUNC_STRERROR 695 gl_FUNC_STRERROR
407 if test $REPLACE_STRERROR = 1; then 696 gl_CONDITIONAL([GL_COND_OBJ_STRERROR], [test $REPLACE_STRERROR = 1])
408 AC_LIBOBJ([strerror])
409 fi
410 gl_MODULE_INDICATOR([strerror]) 697 gl_MODULE_INDICATOR([strerror])
411 gl_STRING_MODULE_INDICATOR([strerror]) 698 gl_STRING_MODULE_INDICATOR([strerror])
412 AC_REQUIRE([gl_HEADER_ERRNO_H]) 699 AC_REQUIRE([gl_HEADER_ERRNO_H])
413 AC_REQUIRE([gl_FUNC_STRERROR_0]) 700 AC_REQUIRE([gl_FUNC_STRERROR_0])
414 if test -n "$ERRNO_H" || test $REPLACE_STRERROR_0 = 1; then 701 gl_CONDITIONAL([GL_COND_OBJ_STRERROR_OVERRIDE],
415 AC_LIBOBJ([strerror-override]) 702 [test -n "$ERRNO_H" || test $REPLACE_STRERROR_0 = 1])
703 AM_COND_IF([GL_COND_OBJ_STRERROR_OVERRIDE], [
416 gl_PREREQ_SYS_H_WINSOCK2 704 gl_PREREQ_SYS_H_WINSOCK2
417 fi 705 ])
418 gl_HEADER_STRING_H 706 gl_STRING_H
419 gl_HEADER_STRINGS_H 707 gl_STRING_H_REQUIRE_DEFAULTS
420 gl_FUNC_STRNDUP 708 AC_PROG_MKDIR_P
421 if test $HAVE_STRNDUP = 0 || test $REPLACE_STRNDUP = 1; then 709 gl_STRINGS_H
422 AC_LIBOBJ([strndup]) 710 gl_STRINGS_H_REQUIRE_DEFAULTS
423 fi 711 AC_PROG_MKDIR_P
424 gl_STRING_MODULE_INDICATOR([strndup])
425 gl_FUNC_STRNLEN
426 if test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1; then
427 AC_LIBOBJ([strnlen])
428 gl_PREREQ_STRNLEN
429 fi
430 gl_STRING_MODULE_INDICATOR([strnlen])
431 gl_FUNC_STRSEP 712 gl_FUNC_STRSEP
432 if test $HAVE_STRSEP = 0; then 713 gl_CONDITIONAL([GL_COND_OBJ_STRSEP], [test $HAVE_STRSEP = 0])
433 AC_LIBOBJ([strsep]) 714 AM_COND_IF([GL_COND_OBJ_STRSEP], [
434 gl_PREREQ_STRSEP 715 gl_PREREQ_STRSEP
435 fi 716 ])
436 gl_STRING_MODULE_INDICATOR([strsep]) 717 gl_STRING_MODULE_INDICATOR([strsep])
437 gl_FUNC_STRSTR_SIMPLE 718 gl_FUNC_STRSTR_SIMPLE
438 if test $REPLACE_STRSTR = 1; then 719 if test $REPLACE_STRSTR = 1; then
439 AC_LIBOBJ([strstr]) 720 AC_LIBOBJ([strstr])
440 fi 721 fi
441 gl_STRING_MODULE_INDICATOR([strstr]) 722 gl_STRING_MODULE_INDICATOR([strstr])
442 gl_HEADER_SYS_SOCKET 723 gl_SYS_SOCKET_H
724 gl_SYS_SOCKET_H_REQUIRE_DEFAULTS
725 AC_PROG_MKDIR_P
726 gl_SYS_STAT_H
727 gl_SYS_STAT_H_REQUIRE_DEFAULTS
443 AC_PROG_MKDIR_P 728 AC_PROG_MKDIR_P
444 gl_SYS_TYPES_H 729 gl_SYS_TYPES_H
730 gl_SYS_TYPES_H_REQUIRE_DEFAULTS
731 AC_PROG_MKDIR_P
732 gl_SYS_UIO_H
733 gl_SYS_UIO_H_REQUIRE_DEFAULTS
445 AC_PROG_MKDIR_P 734 AC_PROG_MKDIR_P
446 gl_HEADER_SYS_UIO 735 AC_REQUIRE([gl_THREADLIB])
736 gl_TIME_H
737 gl_TIME_H_REQUIRE_DEFAULTS
447 AC_PROG_MKDIR_P 738 AC_PROG_MKDIR_P
448 gl_THREADLIB
449 gl_HEADER_TIME_H
450 gl_TIME_R 739 gl_TIME_R
451 if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then 740 gl_CONDITIONAL([GL_COND_OBJ_TIME_R],
452 AC_LIBOBJ([time_r]) 741 [test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1])
742 AM_COND_IF([GL_COND_OBJ_TIME_R], [
453 gl_PREREQ_TIME_R 743 gl_PREREQ_TIME_R
454 fi 744 ])
455 gl_TIME_MODULE_INDICATOR([time_r]) 745 gl_TIME_MODULE_INDICATOR([time_r])
456 gl_FUNC_TIMEGM 746 gl_FUNC_TIMEGM
457 if test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1; then 747 gl_CONDITIONAL([GL_COND_OBJ_TIMEGM],
458 AC_LIBOBJ([timegm]) 748 [test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1])
749 AM_COND_IF([GL_COND_OBJ_TIMEGM], [
459 gl_PREREQ_TIMEGM 750 gl_PREREQ_TIMEGM
460 fi 751 ])
461 gl_TIME_MODULE_INDICATOR([timegm]) 752 gl_TIME_MODULE_INDICATOR([timegm])
462 gl_UNISTD_H 753 gl_UNISTD_H
754 gl_UNISTD_H_REQUIRE_DEFAULTS
755 AC_PROG_MKDIR_P
756 gl_FUNC_GLIBC_UNLOCKED_IO
463 gl_FUNC_UNSETENV 757 gl_FUNC_UNSETENV
464 if test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1; then 758 gl_CONDITIONAL([GL_COND_OBJ_UNSETENV],
465 AC_LIBOBJ([unsetenv]) 759 [test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1])
760 AM_COND_IF([GL_COND_OBJ_UNSETENV], [
466 gl_PREREQ_UNSETENV 761 gl_PREREQ_UNSETENV
467 fi 762 ])
468 gl_STDLIB_MODULE_INDICATOR([unsetenv]) 763 gl_STDLIB_MODULE_INDICATOR([unsetenv])
764 AC_C_VARARRAYS
765 AC_REQUIRE([AC_C_RESTRICT])
469 gl_FUNC_VASNPRINTF 766 gl_FUNC_VASNPRINTF
470 gl_FUNC_VASPRINTF 767 gl_FUNC_VASPRINTF
471 gl_STDIO_MODULE_INDICATOR([vasprintf]) 768 gl_STDIO_MODULE_INDICATOR([vasprintf])
@@ -475,16 +772,34 @@ AC_DEFUN([gl_INIT],
475 gl_FUNC_VSNPRINTF 772 gl_FUNC_VSNPRINTF
476 gl_STDIO_MODULE_INDICATOR([vsnprintf]) 773 gl_STDIO_MODULE_INDICATOR([vsnprintf])
477 gl_WCHAR_H 774 gl_WCHAR_H
775 gl_WCHAR_H_REQUIRE_DEFAULTS
776 AC_PROG_MKDIR_P
478 gl_FUNC_WCRTOMB 777 gl_FUNC_WCRTOMB
479 if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then 778 gl_CONDITIONAL([GL_COND_OBJ_WCRTOMB],
480 AC_LIBOBJ([wcrtomb]) 779 [test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1])
780 AM_COND_IF([GL_COND_OBJ_WCRTOMB], [
481 gl_PREREQ_WCRTOMB 781 gl_PREREQ_WCRTOMB
482 fi 782 ])
483 gl_WCHAR_MODULE_INDICATOR([wcrtomb]) 783 gl_WCHAR_MODULE_INDICATOR([wcrtomb])
484 gl_WCTYPE_H 784 gl_WCTYPE_H
785 gl_WCTYPE_H_REQUIRE_DEFAULTS
786 AC_PROG_MKDIR_P
787 AC_REQUIRE([AC_CANONICAL_HOST])
788 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_MUTEX],
789 [case "$host_os" in mingw*) true;; *) false;; esac])
790 AC_REQUIRE([AC_CANONICAL_HOST])
791 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_ONCE],
792 [case "$host_os" in mingw*) true;; *) false;; esac])
793 AC_REQUIRE([AC_CANONICAL_HOST])
794 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RECMUTEX],
795 [case "$host_os" in mingw*) true;; *) false;; esac])
796 AC_REQUIRE([AC_CANONICAL_HOST])
797 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RWLOCK],
798 [case "$host_os" in mingw*) true;; *) false;; esac])
485 gl_XALLOC 799 gl_XALLOC
800 gl_MODULE_INDICATOR([xalloc])
801 gl_MODULE_INDICATOR([xalloc-die])
486 gl_XSIZE 802 gl_XSIZE
487 gl_XSTRNDUP
488 # End of code from modules 803 # End of code from modules
489 m4_ifval(gl_LIBSOURCES_LIST, [ 804 m4_ifval(gl_LIBSOURCES_LIST, [
490 m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ || 805 m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ ||
@@ -497,6 +812,8 @@ AC_DEFUN([gl_INIT],
497 m4_if(m4_sysval, [0], [], 812 m4_if(m4_sysval, [0], [],
498 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) 813 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
499 ]) 814 ])
815 m4_popdef([GL_MODULE_INDICATOR_PREFIX])
816 m4_popdef([GL_MACRO_PREFIX])
500 m4_popdef([gl_LIBSOURCES_DIR]) 817 m4_popdef([gl_LIBSOURCES_DIR])
501 m4_popdef([gl_LIBSOURCES_LIST]) 818 m4_popdef([gl_LIBSOURCES_LIST])
502 m4_popdef([AC_LIBSOURCES]) 819 m4_popdef([AC_LIBSOURCES])
@@ -505,16 +822,28 @@ AC_DEFUN([gl_INIT],
505 AC_CONFIG_COMMANDS_PRE([ 822 AC_CONFIG_COMMANDS_PRE([
506 gl_libobjs= 823 gl_libobjs=
507 gl_ltlibobjs= 824 gl_ltlibobjs=
825 gl_libobjdeps=
508 if test -n "$gl_LIBOBJS"; then 826 if test -n "$gl_LIBOBJS"; then
509 # Remove the extension. 827 # Remove the extension.
828changequote(,)dnl
510 sed_drop_objext='s/\.o$//;s/\.obj$//' 829 sed_drop_objext='s/\.o$//;s/\.obj$//'
830 sed_dirname1='s,//*,/,g'
831 sed_dirname2='s,\(.\)/$,\1,'
832 sed_dirname3='s,^[^/]*$,.,'
833 sed_dirname4='s,\(.\)/[^/]*$,\1,'
834 sed_basename1='s,.*/,,'
835changequote([, ])dnl
511 for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do 836 for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
512 gl_libobjs="$gl_libobjs $i.$ac_objext" 837 gl_libobjs="$gl_libobjs $i.$ac_objext"
513 gl_ltlibobjs="$gl_ltlibobjs $i.lo" 838 gl_ltlibobjs="$gl_ltlibobjs $i.lo"
839 i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"`
840 i_base=`echo "$i" | sed -e "$sed_basename1"`
841 gl_libobjdeps="$gl_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po"
514 done 842 done
515 fi 843 fi
516 AC_SUBST([gl_LIBOBJS], [$gl_libobjs]) 844 AC_SUBST([gl_LIBOBJS], [$gl_libobjs])
517 AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs]) 845 AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs])
846 AC_SUBST([gl_LIBOBJDEPS], [$gl_libobjdeps])
518 ]) 847 ])
519 gltests_libdeps= 848 gltests_libdeps=
520 gltests_ltlibdeps= 849 gltests_ltlibdeps=
@@ -523,8 +852,11 @@ AC_DEFUN([gl_INIT],
523 m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES])) 852 m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES]))
524 m4_pushdef([gltests_LIBSOURCES_LIST], []) 853 m4_pushdef([gltests_LIBSOURCES_LIST], [])
525 m4_pushdef([gltests_LIBSOURCES_DIR], []) 854 m4_pushdef([gltests_LIBSOURCES_DIR], [])
855 m4_pushdef([GL_MACRO_PREFIX], [gltests])
856 m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL])
526 gl_COMMON 857 gl_COMMON
527 gl_source_base='tests' 858 gl_source_base='tests'
859 gl_source_base_prefix=
528changequote(,)dnl 860changequote(,)dnl
529 gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS 861 gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS
530changequote([, ])dnl 862changequote([, ])dnl
@@ -543,6 +875,8 @@ changequote([, ])dnl
543 m4_if(m4_sysval, [0], [], 875 m4_if(m4_sysval, [0], [],
544 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) 876 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
545 ]) 877 ])
878 m4_popdef([GL_MODULE_INDICATOR_PREFIX])
879 m4_popdef([GL_MACRO_PREFIX])
546 m4_popdef([gltests_LIBSOURCES_DIR]) 880 m4_popdef([gltests_LIBSOURCES_DIR])
547 m4_popdef([gltests_LIBSOURCES_LIST]) 881 m4_popdef([gltests_LIBSOURCES_LIST])
548 m4_popdef([AC_LIBSOURCES]) 882 m4_popdef([AC_LIBSOURCES])
@@ -551,17 +885,30 @@ changequote([, ])dnl
551 AC_CONFIG_COMMANDS_PRE([ 885 AC_CONFIG_COMMANDS_PRE([
552 gltests_libobjs= 886 gltests_libobjs=
553 gltests_ltlibobjs= 887 gltests_ltlibobjs=
888 gltests_libobjdeps=
554 if test -n "$gltests_LIBOBJS"; then 889 if test -n "$gltests_LIBOBJS"; then
555 # Remove the extension. 890 # Remove the extension.
891changequote(,)dnl
556 sed_drop_objext='s/\.o$//;s/\.obj$//' 892 sed_drop_objext='s/\.o$//;s/\.obj$//'
893 sed_dirname1='s,//*,/,g'
894 sed_dirname2='s,\(.\)/$,\1,'
895 sed_dirname3='s,^[^/]*$,.,'
896 sed_dirname4='s,\(.\)/[^/]*$,\1,'
897 sed_basename1='s,.*/,,'
898changequote([, ])dnl
557 for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do 899 for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
558 gltests_libobjs="$gltests_libobjs $i.$ac_objext" 900 gltests_libobjs="$gltests_libobjs $i.$ac_objext"
559 gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" 901 gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
902 i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"`
903 i_base=`echo "$i" | sed -e "$sed_basename1"`
904 gltests_libobjdeps="$gltests_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po"
560 done 905 done
561 fi 906 fi
562 AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs]) 907 AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs])
563 AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs]) 908 AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs])
909 AC_SUBST([gltests_LIBOBJDEPS], [$gltests_libobjdeps])
564 ]) 910 ])
911 AC_REQUIRE([gl_CC_GNULIB_WARNINGS])
565 LIBGNU_LIBDEPS="$gl_libdeps" 912 LIBGNU_LIBDEPS="$gl_libdeps"
566 AC_SUBST([LIBGNU_LIBDEPS]) 913 AC_SUBST([LIBGNU_LIBDEPS])
567 LIBGNU_LTLIBDEPS="$gl_ltlibdeps" 914 LIBGNU_LTLIBDEPS="$gl_ltlibdeps"
@@ -625,76 +972,130 @@ AC_DEFUN([gltests_LIBSOURCES], [
625# This macro records the list of files which have been installed by 972# This macro records the list of files which have been installed by
626# gnulib-tool and may be removed by future gnulib-tool invocations. 973# gnulib-tool and may be removed by future gnulib-tool invocations.
627AC_DEFUN([gl_FILE_LIST], [ 974AC_DEFUN([gl_FILE_LIST], [
628 build-aux/config.rpath 975 lib/_Noreturn.h
629 build-aux/snippet/_Noreturn.h 976 lib/af_alg.c
630 build-aux/snippet/arg-nonnull.h 977 lib/af_alg.h
631 build-aux/snippet/c++defs.h
632 build-aux/snippet/warn-on-use.h
633 lib/alloca.in.h 978 lib/alloca.in.h
979 lib/arg-nonnull.h
634 lib/arpa_inet.in.h 980 lib/arpa_inet.in.h
635 lib/asnprintf.c 981 lib/asnprintf.c
636 lib/asprintf.c 982 lib/asprintf.c
983 lib/assert.in.h
984 lib/attribute.h
637 lib/base64.c 985 lib/base64.c
638 lib/base64.h 986 lib/base64.h
639 lib/basename-lgpl.c 987 lib/basename-lgpl.c
988 lib/basename-lgpl.h
640 lib/basename.c 989 lib/basename.c
641 lib/btowc.c 990 lib/btowc.c
642 lib/config.charset 991 lib/byteswap.in.h
992 lib/c++defs.h
993 lib/calloc.c
994 lib/cdefs.h
995 lib/cloexec.c
996 lib/cloexec.h
997 lib/close.c
643 lib/dirname-lgpl.c 998 lib/dirname-lgpl.c
644 lib/dirname.c 999 lib/dirname.c
645 lib/dirname.h 1000 lib/dirname.h
646 lib/dosname.h 1001 lib/dup2.c
1002 lib/dynarray.h
647 lib/errno.in.h 1003 lib/errno.in.h
648 lib/error.c 1004 lib/error.c
649 lib/error.h 1005 lib/error.h
650 lib/exitfail.c 1006 lib/exitfail.c
651 lib/exitfail.h 1007 lib/exitfail.h
1008 lib/fcntl.c
1009 lib/fcntl.in.h
652 lib/fd-hook.c 1010 lib/fd-hook.c
653 lib/fd-hook.h 1011 lib/fd-hook.h
1012 lib/fflush.c
1013 lib/filename.h
654 lib/float+.h 1014 lib/float+.h
655 lib/float.c 1015 lib/float.c
656 lib/float.in.h 1016 lib/float.in.h
657 lib/floor.c 1017 lib/floor.c
658 lib/floorf.c 1018 lib/floorf.c
1019 lib/fopen.c
1020 lib/fpurge.c
1021 lib/freading.c
1022 lib/freading.h
1023 lib/free.c
1024 lib/fseek.c
1025 lib/fseeko.c
1026 lib/fstat.c
659 lib/fsusage.c 1027 lib/fsusage.c
660 lib/fsusage.h 1028 lib/fsusage.h
661 lib/full-read.c 1029 lib/ftell.c
662 lib/full-read.h 1030 lib/ftello.c
663 lib/full-write.c
664 lib/gai_strerror.c 1031 lib/gai_strerror.c
665 lib/getaddrinfo.c 1032 lib/getaddrinfo.c
1033 lib/getdelim.c
1034 lib/getdtablesize.c
666 lib/gethostname.c 1035 lib/gethostname.c
1036 lib/getline.c
667 lib/getloadavg.c 1037 lib/getloadavg.c
1038 lib/getopt-cdefs.in.h
1039 lib/getopt-core.h
1040 lib/getopt-ext.h
1041 lib/getopt-pfx-core.h
1042 lib/getopt-pfx-ext.h
668 lib/getopt.c 1043 lib/getopt.c
669 lib/getopt.in.h 1044 lib/getopt.in.h
670 lib/getopt1.c 1045 lib/getopt1.c
671 lib/getopt_int.h 1046 lib/getopt_int.h
1047 lib/getprogname.c
1048 lib/getprogname.h
672 lib/gettext.h 1049 lib/gettext.h
1050 lib/gl_openssl.h
673 lib/glthread/lock.c 1051 lib/glthread/lock.c
674 lib/glthread/lock.h 1052 lib/glthread/lock.h
675 lib/glthread/threadlib.c 1053 lib/glthread/threadlib.c
1054 lib/hard-locale.c
1055 lib/hard-locale.h
1056 lib/ialloc.c
1057 lib/ialloc.h
676 lib/idpriv-droptemp.c 1058 lib/idpriv-droptemp.c
677 lib/idpriv.h 1059 lib/idpriv.h
1060 lib/idx.h
678 lib/inet_ntop.c 1061 lib/inet_ntop.c
1062 lib/intprops-internal.h
679 lib/intprops.h 1063 lib/intprops.h
1064 lib/inttypes.in.h
680 lib/itold.c 1065 lib/itold.c
681 lib/langinfo.in.h 1066 lib/langinfo.in.h
1067 lib/lc-charset-dispatch.c
1068 lib/lc-charset-dispatch.h
1069 lib/libc-config.h
1070 lib/limits.in.h
682 lib/localcharset.c 1071 lib/localcharset.c
683 lib/localcharset.h 1072 lib/localcharset.h
684 lib/locale.in.h 1073 lib/locale.in.h
685 lib/localeconv.c 1074 lib/localeconv.c
1075 lib/lseek.c
686 lib/malloc.c 1076 lib/malloc.c
1077 lib/malloc/dynarray-skeleton.c
1078 lib/malloc/dynarray.h
1079 lib/malloc/dynarray_at_failure.c
1080 lib/malloc/dynarray_emplace_enlarge.c
1081 lib/malloc/dynarray_finalize.c
1082 lib/malloc/dynarray_resize.c
1083 lib/malloc/dynarray_resize_clear.c
687 lib/malloca.c 1084 lib/malloca.c
688 lib/malloca.h 1085 lib/malloca.h
689 lib/malloca.valgrind
690 lib/math.c 1086 lib/math.c
691 lib/math.in.h 1087 lib/math.in.h
1088 lib/mbrtowc-impl-utf8.h
1089 lib/mbrtowc-impl.h
692 lib/mbrtowc.c 1090 lib/mbrtowc.c
693 lib/mbsinit.c 1091 lib/mbsinit.c
694 lib/mbtowc-impl.h 1092 lib/mbtowc-impl.h
1093 lib/mbtowc-lock.c
1094 lib/mbtowc-lock.h
695 lib/mbtowc.c 1095 lib/mbtowc.c
696 lib/memchr.c 1096 lib/memchr.c
697 lib/memchr.valgrind 1097 lib/memchr.valgrind
1098 lib/minmax.h
698 lib/mktime-internal.h 1099 lib/mktime-internal.h
699 lib/mktime.c 1100 lib/mktime.c
700 lib/mountlist.c 1101 lib/mountlist.c
@@ -705,33 +1106,45 @@ AC_DEFUN([gl_FILE_LIST], [
705 lib/msvc-nothrow.h 1106 lib/msvc-nothrow.h
706 lib/netdb.in.h 1107 lib/netdb.in.h
707 lib/netinet_in.in.h 1108 lib/netinet_in.in.h
1109 lib/nl_langinfo-lock.c
708 lib/nl_langinfo.c 1110 lib/nl_langinfo.c
1111 lib/open.c
1112 lib/pathmax.h
709 lib/printf-args.c 1113 lib/printf-args.c
710 lib/printf-args.h 1114 lib/printf-args.h
711 lib/printf-parse.c 1115 lib/printf-parse.c
712 lib/printf-parse.h 1116 lib/printf-parse.h
713 lib/read.c 1117 lib/realloc.c
714 lib/ref-add.sin 1118 lib/reallocarray.c
715 lib/ref-del.sin
716 lib/regcomp.c 1119 lib/regcomp.c
717 lib/regex.c 1120 lib/regex.c
718 lib/regex.h 1121 lib/regex.h
719 lib/regex_internal.c 1122 lib/regex_internal.c
720 lib/regex_internal.h 1123 lib/regex_internal.h
721 lib/regexec.c 1124 lib/regexec.c
722 lib/safe-read.c
723 lib/safe-read.h
724 lib/setenv.c 1125 lib/setenv.c
725 lib/sha1.c 1126 lib/setlocale-lock.c
726 lib/sha1.h 1127 lib/setlocale_null.c
1128 lib/setlocale_null.h
1129 lib/sha256-stream.c
1130 lib/sha256.c
1131 lib/sha256.h
727 lib/size_max.h 1132 lib/size_max.h
728 lib/snprintf.c 1133 lib/snprintf.c
729 lib/sockets.c 1134 lib/sockets.c
730 lib/sockets.h 1135 lib/sockets.h
1136 lib/stat-time.c
1137 lib/stat-time.h
1138 lib/stat-w32.c
1139 lib/stat-w32.h
1140 lib/stat.c
731 lib/stdalign.in.h 1141 lib/stdalign.in.h
732 lib/stdbool.in.h 1142 lib/stdckdint.in.h
733 lib/stddef.in.h 1143 lib/stddef.in.h
734 lib/stdint.in.h 1144 lib/stdint.in.h
1145 lib/stdio-impl.h
1146 lib/stdio-read.c
1147 lib/stdio-write.c
735 lib/stdio.in.h 1148 lib/stdio.in.h
736 lib/stdlib.in.h 1149 lib/stdlib.in.h
737 lib/str-two-way.h 1150 lib/str-two-way.h
@@ -745,12 +1158,12 @@ AC_DEFUN([gl_FILE_LIST], [
745 lib/strings.in.h 1158 lib/strings.in.h
746 lib/stripslash.c 1159 lib/stripslash.c
747 lib/strncasecmp.c 1160 lib/strncasecmp.c
748 lib/strndup.c
749 lib/strnlen.c
750 lib/strsep.c 1161 lib/strsep.c
751 lib/strstr.c 1162 lib/strstr.c
1163 lib/sys-limits.h
752 lib/sys_socket.c 1164 lib/sys_socket.c
753 lib/sys_socket.in.h 1165 lib/sys_socket.in.h
1166 lib/sys_stat.in.h
754 lib/sys_types.in.h 1167 lib/sys_types.in.h
755 lib/sys_uio.in.h 1168 lib/sys_uio.in.h
756 lib/time.in.h 1169 lib/time.in.h
@@ -758,6 +1171,7 @@ AC_DEFUN([gl_FILE_LIST], [
758 lib/timegm.c 1171 lib/timegm.c
759 lib/unistd.c 1172 lib/unistd.c
760 lib/unistd.in.h 1173 lib/unistd.in.h
1174 lib/unlocked-io.h
761 lib/unsetenv.c 1175 lib/unsetenv.c
762 lib/vasnprintf.c 1176 lib/vasnprintf.c
763 lib/vasnprintf.h 1177 lib/vasnprintf.h
@@ -765,27 +1179,43 @@ AC_DEFUN([gl_FILE_LIST], [
765 lib/verify.h 1179 lib/verify.h
766 lib/vsnprintf.c 1180 lib/vsnprintf.c
767 lib/w32sock.h 1181 lib/w32sock.h
1182 lib/warn-on-use.h
768 lib/wchar.in.h 1183 lib/wchar.in.h
769 lib/wcrtomb.c 1184 lib/wcrtomb.c
770 lib/wctype-h.c 1185 lib/wctype-h.c
771 lib/wctype.in.h 1186 lib/wctype.in.h
1187 lib/windows-initguard.h
1188 lib/windows-mutex.c
1189 lib/windows-mutex.h
1190 lib/windows-once.c
1191 lib/windows-once.h
1192 lib/windows-recmutex.c
1193 lib/windows-recmutex.h
1194 lib/windows-rwlock.c
1195 lib/windows-rwlock.h
772 lib/xalloc-die.c 1196 lib/xalloc-die.c
773 lib/xalloc-oversized.h 1197 lib/xalloc-oversized.h
774 lib/xalloc.h 1198 lib/xalloc.h
775 lib/xmalloc.c 1199 lib/xmalloc.c
776 lib/xsize.c 1200 lib/xsize.c
777 lib/xsize.h 1201 lib/xsize.h
778 lib/xstrndup.c
779 lib/xstrndup.h
780 m4/00gnulib.m4 1202 m4/00gnulib.m4
1203 m4/__inline.m4
1204 m4/absolute-header.m4
1205 m4/af_alg.m4
781 m4/alloca.m4 1206 m4/alloca.m4
782 m4/arpa_inet_h.m4 1207 m4/arpa_inet_h.m4
1208 m4/assert_h.m4
783 m4/base64.m4 1209 m4/base64.m4
784 m4/btowc.m4 1210 m4/btowc.m4
1211 m4/builtin-expect.m4
1212 m4/byteswap.m4
1213 m4/c-bool.m4
1214 m4/calloc.m4
1215 m4/close.m4
785 m4/codeset.m4 1216 m4/codeset.m4
786 m4/configmake.m4
787 m4/dirname.m4
788 m4/double-slash-root.m4 1217 m4/double-slash-root.m4
1218 m4/dup2.m4
789 m4/eealloc.m4 1219 m4/eealloc.m4
790 m4/environ.m4 1220 m4/environ.m4
791 m4/errno_h.m4 1221 m4/errno_h.m4
@@ -794,37 +1224,42 @@ AC_DEFUN([gl_FILE_LIST], [
794 m4/extensions.m4 1224 m4/extensions.m4
795 m4/extern-inline.m4 1225 m4/extern-inline.m4
796 m4/fcntl-o.m4 1226 m4/fcntl-o.m4
1227 m4/fcntl.m4
1228 m4/fcntl_h.m4
1229 m4/fflush.m4
797 m4/float_h.m4 1230 m4/float_h.m4
798 m4/floorf.m4 1231 m4/floorf.m4
1232 m4/fopen.m4
1233 m4/fpurge.m4
1234 m4/freading.m4
1235 m4/free.m4
1236 m4/fseek.m4
1237 m4/fseeko.m4
1238 m4/fstat.m4
799 m4/fstypename.m4 1239 m4/fstypename.m4
800 m4/fsusage.m4 1240 m4/fsusage.m4
1241 m4/ftell.m4
1242 m4/ftello.m4
801 m4/getaddrinfo.m4 1243 m4/getaddrinfo.m4
1244 m4/getdelim.m4
1245 m4/getdtablesize.m4
802 m4/gethostname.m4 1246 m4/gethostname.m4
1247 m4/getline.m4
803 m4/getloadavg.m4 1248 m4/getloadavg.m4
804 m4/getopt.m4 1249 m4/getopt.m4
805 m4/gettext.m4 1250 m4/getprogname.m4
806 m4/glibc2.m4 1251 m4/gl-openssl.m4
807 m4/glibc21.m4
808 m4/gnulib-common.m4 1252 m4/gnulib-common.m4
809 m4/hostent.m4 1253 m4/hostent.m4
810 m4/iconv.m4
811 m4/idpriv.m4 1254 m4/idpriv.m4
812 m4/include_next.m4 1255 m4/include_next.m4
813 m4/inet_ntop.m4 1256 m4/inet_ntop.m4
814 m4/intdiv0.m4
815 m4/intl.m4
816 m4/intldir.m4
817 m4/intlmacosx.m4
818 m4/intmax.m4
819 m4/intmax_t.m4 1257 m4/intmax_t.m4
820 m4/inttypes-pri.m4 1258 m4/inttypes.m4
821 m4/inttypes_h.m4 1259 m4/inttypes_h.m4
822 m4/langinfo_h.m4 1260 m4/langinfo_h.m4
823 m4/largefile.m4 1261 m4/largefile.m4
824 m4/lcmessage.m4 1262 m4/limits-h.m4
825 m4/lib-ld.m4
826 m4/lib-link.m4
827 m4/lib-prefix.m4
828 m4/localcharset.m4 1263 m4/localcharset.m4
829 m4/locale-fr.m4 1264 m4/locale-fr.m4
830 m4/locale-ja.m4 1265 m4/locale-ja.m4
@@ -832,8 +1267,7 @@ AC_DEFUN([gl_FILE_LIST], [
832 m4/locale_h.m4 1267 m4/locale_h.m4
833 m4/localeconv.m4 1268 m4/localeconv.m4
834 m4/lock.m4 1269 m4/lock.m4
835 m4/longlong.m4 1270 m4/lseek.m4
836 m4/ls-mntd-fs.m4
837 m4/malloc.m4 1271 m4/malloc.m4
838 m4/malloca.m4 1272 m4/malloca.m4
839 m4/math_h.m4 1273 m4/math_h.m4
@@ -842,8 +1276,10 @@ AC_DEFUN([gl_FILE_LIST], [
842 m4/mbstate_t.m4 1276 m4/mbstate_t.m4
843 m4/mbtowc.m4 1277 m4/mbtowc.m4
844 m4/memchr.m4 1278 m4/memchr.m4
1279 m4/minmax.m4
845 m4/mktime.m4 1280 m4/mktime.m4
846 m4/mmap-anon.m4 1281 m4/mmap-anon.m4
1282 m4/mode_t.m4
847 m4/mountlist.m4 1283 m4/mountlist.m4
848 m4/msvc-inval.m4 1284 m4/msvc-inval.m4
849 m4/msvc-nothrow.m4 1285 m4/msvc-nothrow.m4
@@ -851,20 +1287,22 @@ AC_DEFUN([gl_FILE_LIST], [
851 m4/netdb_h.m4 1287 m4/netdb_h.m4
852 m4/netinet_in_h.m4 1288 m4/netinet_in_h.m4
853 m4/nl_langinfo.m4 1289 m4/nl_langinfo.m4
854 m4/nls.m4
855 m4/nocrash.m4 1290 m4/nocrash.m4
856 m4/off_t.m4 1291 m4/off_t.m4
857 m4/onceonly.m4 1292 m4/open-cloexec.m4
858 m4/po.m4 1293 m4/open-slash.m4
859 m4/printf-posix.m4 1294 m4/open.m4
1295 m4/pathmax.m4
1296 m4/pid_t.m4
860 m4/printf.m4 1297 m4/printf.m4
861 m4/progtest.m4 1298 m4/pthread_rwlock_rdlock.m4
862 m4/read.m4 1299 m4/realloc.m4
1300 m4/reallocarray.m4
863 m4/regex.m4 1301 m4/regex.m4
864 m4/safe-read.m4
865 m4/servent.m4 1302 m4/servent.m4
866 m4/setenv.m4 1303 m4/setenv.m4
867 m4/sha1.m4 1304 m4/setlocale_null.m4
1305 m4/sha256.m4
868 m4/size_max.m4 1306 m4/size_max.m4
869 m4/snprintf.m4 1307 m4/snprintf.m4
870 m4/socketlib.m4 1308 m4/socketlib.m4
@@ -872,8 +1310,10 @@ AC_DEFUN([gl_FILE_LIST], [
872 m4/socklen.m4 1310 m4/socklen.m4
873 m4/sockpfaf.m4 1311 m4/sockpfaf.m4
874 m4/ssize_t.m4 1312 m4/ssize_t.m4
1313 m4/stat-time.m4
1314 m4/stat.m4
1315 m4/std-gnu11.m4
875 m4/stdalign.m4 1316 m4/stdalign.m4
876 m4/stdbool.m4
877 m4/stddef_h.m4 1317 m4/stddef_h.m4
878 m4/stdint.m4 1318 m4/stdint.m4
879 m4/stdint_h.m4 1319 m4/stdint_h.m4
@@ -884,19 +1324,20 @@ AC_DEFUN([gl_FILE_LIST], [
884 m4/strerror.m4 1324 m4/strerror.m4
885 m4/string_h.m4 1325 m4/string_h.m4
886 m4/strings_h.m4 1326 m4/strings_h.m4
887 m4/strndup.m4
888 m4/strnlen.m4
889 m4/strsep.m4 1327 m4/strsep.m4
890 m4/strstr.m4 1328 m4/strstr.m4
891 m4/sys_socket_h.m4 1329 m4/sys_socket_h.m4
1330 m4/sys_stat_h.m4
892 m4/sys_types_h.m4 1331 m4/sys_types_h.m4
893 m4/sys_uio_h.m4 1332 m4/sys_uio_h.m4
894 m4/threadlib.m4 1333 m4/threadlib.m4
895 m4/time_h.m4 1334 m4/time_h.m4
896 m4/time_r.m4 1335 m4/time_r.m4
897 m4/timegm.m4 1336 m4/timegm.m4
898 m4/uintmax_t.m4 1337 m4/ungetc.m4
899 m4/unistd_h.m4 1338 m4/unistd_h.m4
1339 m4/unlocked-io.m4
1340 m4/vararrays.m4
900 m4/vasnprintf.m4 1341 m4/vasnprintf.m4
901 m4/vasprintf.m4 1342 m4/vasprintf.m4
902 m4/visibility.m4 1343 m4/visibility.m4
@@ -909,5 +1350,5 @@ AC_DEFUN([gl_FILE_LIST], [
909 m4/wint_t.m4 1350 m4/wint_t.m4
910 m4/xalloc.m4 1351 m4/xalloc.m4
911 m4/xsize.m4 1352 m4/xsize.m4
912 m4/xstrndup.m4 1353 m4/zzgnulib.m4
913]) 1354])
diff --git a/gl/m4/gnulib-tool.m4 b/gl/m4/gnulib-tool.m4
index f3dea1a9..a9dd569b 100644
--- a/gl/m4/gnulib-tool.m4
+++ b/gl/m4/gnulib-tool.m4
@@ -1,5 +1,5 @@
1# gnulib-tool.m4 serial 2 1# gnulib-tool.m4 serial 4
2dnl Copyright (C) 2004-2005, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2004-2005, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,12 @@ AC_DEFUN([gl_LGPL], [])
44dnl Usage: gl_MAKEFILE_NAME([FILENAME]) 44dnl Usage: gl_MAKEFILE_NAME([FILENAME])
45AC_DEFUN([gl_MAKEFILE_NAME], []) 45AC_DEFUN([gl_MAKEFILE_NAME], [])
46 46
47dnl Usage: gl_TESTS_MAKEFILE_NAME([FILENAME])
48AC_DEFUN([gl_TESTS_MAKEFILE_NAME], [])
49
50dnl Usage: gl_AUTOMAKE_SUBDIR
51AC_DEFUN([gl_AUTOMAKE_SUBDIR], [])
52
47dnl Usage: gl_LIBTOOL 53dnl Usage: gl_LIBTOOL
48AC_DEFUN([gl_LIBTOOL], []) 54AC_DEFUN([gl_LIBTOOL], [])
49 55
diff --git a/gl/m4/hostent.m4 b/gl/m4/hostent.m4
index 72be876b..3b2cc2b2 100644
--- a/gl/m4/hostent.m4
+++ b/gl/m4/hostent.m4
@@ -1,5 +1,5 @@
1# hostent.m4 serial 2 1# hostent.m4 serial 4
2dnl Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,12 +8,12 @@ AC_DEFUN([gl_HOSTENT],
8[ 8[
9 dnl Where are gethostent(), sethostent(), endhostent(), gethostbyname(), 9 dnl Where are gethostent(), sethostent(), endhostent(), gethostbyname(),
10 dnl gethostbyaddr() defined? 10 dnl gethostbyaddr() defined?
11 dnl - On Solaris, they are in libnsl. Ignore libxnet. 11 dnl - On Solaris < 11.4, they are in libnsl. Ignore libxnet.
12 dnl - On Haiku, they are in libnetwork. 12 dnl - On Haiku, they are in libnetwork.
13 dnl - On BeOS, they are in libnet. 13 dnl - On BeOS, they are in libnet.
14 dnl - On native Windows, they are in ws2_32.dll. 14 dnl - On native Windows, they are in ws2_32.dll.
15 dnl - Otherwise they are in libc. 15 dnl - Otherwise they are in libc.
16 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 16 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
17 HOSTENT_LIB= 17 HOSTENT_LIB=
18 gl_saved_libs="$LIBS" 18 gl_saved_libs="$LIBS"
19 AC_SEARCH_LIBS([gethostbyname], [nsl network net], 19 AC_SEARCH_LIBS([gethostbyname], [nsl network net],
diff --git a/gl/m4/iconv.m4 b/gl/m4/iconv.m4
deleted file mode 100644
index a5036465..00000000
--- a/gl/m4/iconv.m4
+++ /dev/null
@@ -1,268 +0,0 @@
1# iconv.m4 serial 18 (gettext-0.18.2)
2dnl Copyright (C) 2000-2002, 2007-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
10[
11 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
12 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
13 AC_REQUIRE([AC_LIB_RPATH])
14
15 dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
16 dnl accordingly.
17 AC_LIB_LINKFLAGS_BODY([iconv])
18])
19
20AC_DEFUN([AM_ICONV_LINK],
21[
22 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
23 dnl those with the standalone portable GNU libiconv installed).
24 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
25
26 dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
27 dnl accordingly.
28 AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
29
30 dnl Add $INCICONV to CPPFLAGS before performing the following checks,
31 dnl because if the user has installed libiconv and not disabled its use
32 dnl via --without-libiconv-prefix, he wants to use it. The first
33 dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
34 am_save_CPPFLAGS="$CPPFLAGS"
35 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
36
37 AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
38 am_cv_func_iconv="no, consider installing GNU libiconv"
39 am_cv_lib_iconv=no
40 AC_LINK_IFELSE(
41 [AC_LANG_PROGRAM(
42 [[
43#include <stdlib.h>
44#include <iconv.h>
45 ]],
46 [[iconv_t cd = iconv_open("","");
47 iconv(cd,NULL,NULL,NULL,NULL);
48 iconv_close(cd);]])],
49 [am_cv_func_iconv=yes])
50 if test "$am_cv_func_iconv" != yes; then
51 am_save_LIBS="$LIBS"
52 LIBS="$LIBS $LIBICONV"
53 AC_LINK_IFELSE(
54 [AC_LANG_PROGRAM(
55 [[
56#include <stdlib.h>
57#include <iconv.h>
58 ]],
59 [[iconv_t cd = iconv_open("","");
60 iconv(cd,NULL,NULL,NULL,NULL);
61 iconv_close(cd);]])],
62 [am_cv_lib_iconv=yes]
63 [am_cv_func_iconv=yes])
64 LIBS="$am_save_LIBS"
65 fi
66 ])
67 if test "$am_cv_func_iconv" = yes; then
68 AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
69 dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
70 dnl Solaris 10.
71 am_save_LIBS="$LIBS"
72 if test $am_cv_lib_iconv = yes; then
73 LIBS="$LIBS $LIBICONV"
74 fi
75 AC_RUN_IFELSE(
76 [AC_LANG_SOURCE([[
77#include <iconv.h>
78#include <string.h>
79int main ()
80{
81 int result = 0;
82 /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
83 returns. */
84 {
85 iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
86 if (cd_utf8_to_88591 != (iconv_t)(-1))
87 {
88 static const char input[] = "\342\202\254"; /* EURO SIGN */
89 char buf[10];
90 const char *inptr = input;
91 size_t inbytesleft = strlen (input);
92 char *outptr = buf;
93 size_t outbytesleft = sizeof (buf);
94 size_t res = iconv (cd_utf8_to_88591,
95 (char **) &inptr, &inbytesleft,
96 &outptr, &outbytesleft);
97 if (res == 0)
98 result |= 1;
99 iconv_close (cd_utf8_to_88591);
100 }
101 }
102 /* Test against Solaris 10 bug: Failures are not distinguishable from
103 successful returns. */
104 {
105 iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
106 if (cd_ascii_to_88591 != (iconv_t)(-1))
107 {
108 static const char input[] = "\263";
109 char buf[10];
110 const char *inptr = input;
111 size_t inbytesleft = strlen (input);
112 char *outptr = buf;
113 size_t outbytesleft = sizeof (buf);
114 size_t res = iconv (cd_ascii_to_88591,
115 (char **) &inptr, &inbytesleft,
116 &outptr, &outbytesleft);
117 if (res == 0)
118 result |= 2;
119 iconv_close (cd_ascii_to_88591);
120 }
121 }
122 /* Test against AIX 6.1..7.1 bug: Buffer overrun. */
123 {
124 iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
125 if (cd_88591_to_utf8 != (iconv_t)(-1))
126 {
127 static const char input[] = "\304";
128 static char buf[2] = { (char)0xDE, (char)0xAD };
129 const char *inptr = input;
130 size_t inbytesleft = 1;
131 char *outptr = buf;
132 size_t outbytesleft = 1;
133 size_t res = iconv (cd_88591_to_utf8,
134 (char **) &inptr, &inbytesleft,
135 &outptr, &outbytesleft);
136 if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
137 result |= 4;
138 iconv_close (cd_88591_to_utf8);
139 }
140 }
141#if 0 /* This bug could be worked around by the caller. */
142 /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */
143 {
144 iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
145 if (cd_88591_to_utf8 != (iconv_t)(-1))
146 {
147 static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
148 char buf[50];
149 const char *inptr = input;
150 size_t inbytesleft = strlen (input);
151 char *outptr = buf;
152 size_t outbytesleft = sizeof (buf);
153 size_t res = iconv (cd_88591_to_utf8,
154 (char **) &inptr, &inbytesleft,
155 &outptr, &outbytesleft);
156 if ((int)res > 0)
157 result |= 8;
158 iconv_close (cd_88591_to_utf8);
159 }
160 }
161#endif
162 /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
163 provided. */
164 if (/* Try standardized names. */
165 iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
166 /* Try IRIX, OSF/1 names. */
167 && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
168 /* Try AIX names. */
169 && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
170 /* Try HP-UX names. */
171 && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
172 result |= 16;
173 return result;
174}]])],
175 [am_cv_func_iconv_works=yes],
176 [am_cv_func_iconv_works=no],
177 [
178changequote(,)dnl
179 case "$host_os" in
180 aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
181 *) am_cv_func_iconv_works="guessing yes" ;;
182 esac
183changequote([,])dnl
184 ])
185 LIBS="$am_save_LIBS"
186 ])
187 case "$am_cv_func_iconv_works" in
188 *no) am_func_iconv=no am_cv_lib_iconv=no ;;
189 *) am_func_iconv=yes ;;
190 esac
191 else
192 am_func_iconv=no am_cv_lib_iconv=no
193 fi
194 if test "$am_func_iconv" = yes; then
195 AC_DEFINE([HAVE_ICONV], [1],
196 [Define if you have the iconv() function and it works.])
197 fi
198 if test "$am_cv_lib_iconv" = yes; then
199 AC_MSG_CHECKING([how to link with libiconv])
200 AC_MSG_RESULT([$LIBICONV])
201 else
202 dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
203 dnl either.
204 CPPFLAGS="$am_save_CPPFLAGS"
205 LIBICONV=
206 LTLIBICONV=
207 fi
208 AC_SUBST([LIBICONV])
209 AC_SUBST([LTLIBICONV])
210])
211
212dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
213dnl avoid warnings like
214dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
215dnl This is tricky because of the way 'aclocal' is implemented:
216dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
217dnl Otherwise aclocal's initial scan pass would miss the macro definition.
218dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
219dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
220dnl warnings.
221m4_define([gl_iconv_AC_DEFUN],
222 m4_version_prereq([2.64],
223 [[AC_DEFUN_ONCE(
224 [$1], [$2])]],
225 [m4_ifdef([gl_00GNULIB],
226 [[AC_DEFUN_ONCE(
227 [$1], [$2])]],
228 [[AC_DEFUN(
229 [$1], [$2])]])]))
230gl_iconv_AC_DEFUN([AM_ICONV],
231[
232 AM_ICONV_LINK
233 if test "$am_cv_func_iconv" = yes; then
234 AC_MSG_CHECKING([for iconv declaration])
235 AC_CACHE_VAL([am_cv_proto_iconv], [
236 AC_COMPILE_IFELSE(
237 [AC_LANG_PROGRAM(
238 [[
239#include <stdlib.h>
240#include <iconv.h>
241extern
242#ifdef __cplusplus
243"C"
244#endif
245#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
246size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
247#else
248size_t iconv();
249#endif
250 ]],
251 [[]])],
252 [am_cv_proto_iconv_arg1=""],
253 [am_cv_proto_iconv_arg1="const"])
254 am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
255 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
256 AC_MSG_RESULT([
257 $am_cv_proto_iconv])
258 AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
259 [Define as const if the declaration of iconv() needs const.])
260 dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
261 m4_ifdef([gl_ICONV_H_DEFAULTS],
262 [AC_REQUIRE([gl_ICONV_H_DEFAULTS])
263 if test -n "$am_cv_proto_iconv_arg1"; then
264 ICONV_CONST="const"
265 fi
266 ])
267 fi
268])
diff --git a/gl/m4/idpriv.m4 b/gl/m4/idpriv.m4
index 167f5238..fc3dd17d 100644
--- a/gl/m4/idpriv.m4
+++ b/gl/m4/idpriv.m4
@@ -1,5 +1,5 @@
1# idpriv.m4 serial 1 1# idpriv.m4 serial 1
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/include_next.m4 b/gl/m4/include_next.m4
index 108d9456..9f19215e 100644
--- a/gl/m4/include_next.m4
+++ b/gl/m4/include_next.m4
@@ -1,12 +1,13 @@
1# include_next.m4 serial 23 1# include_next.m4 serial 26
2dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Paul Eggert and Derek Price. 7dnl From Paul Eggert and Derek Price.
8 8
9dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER. 9dnl Sets INCLUDE_NEXT, INCLUDE_NEXT_AS_FIRST_DIRECTIVE, PRAGMA_SYSTEM_HEADER,
10dnl and PRAGMA_COLUMNS.
10dnl 11dnl
11dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to 12dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
12dnl 'include' otherwise. 13dnl 'include' otherwise.
@@ -105,19 +106,21 @@ dnl We intentionally avoid using AC_LANG_SOURCE here.
105 AC_SUBST([INCLUDE_NEXT]) 106 AC_SUBST([INCLUDE_NEXT])
106 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE]) 107 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
107 AC_SUBST([PRAGMA_SYSTEM_HEADER]) 108 AC_SUBST([PRAGMA_SYSTEM_HEADER])
108 AC_CACHE_CHECK([whether system header files limit the line length], 109
109 [gl_cv_pragma_columns], 110 dnl HP NonStop systems, which define __TANDEM, limit the line length
110 [dnl HP NonStop systems, which define __TANDEM, have this misfeature. 111 dnl after including some system header files.
111 AC_EGREP_CPP([choke me], 112 AC_CACHE_CHECK([whether source code line length is unlimited],
113 [gl_cv_source_line_length_unlimited],
114 [AC_EGREP_CPP([choke me],
112 [ 115 [
113#ifdef __TANDEM 116#ifdef __TANDEM
114choke me 117choke me
115#endif 118#endif
116 ], 119 ],
117 [gl_cv_pragma_columns=yes], 120 [gl_cv_source_line_length_unlimited=no],
118 [gl_cv_pragma_columns=no]) 121 [gl_cv_source_line_length_unlimited=yes])
119 ]) 122 ])
120 if test $gl_cv_pragma_columns = yes; then 123 if test $gl_cv_source_line_length_unlimited = no; then
121 PRAGMA_COLUMNS="#pragma COLUMNS 10000" 124 PRAGMA_COLUMNS="#pragma COLUMNS 10000"
122 else 125 else
123 PRAGMA_COLUMNS= 126 PRAGMA_COLUMNS=
@@ -175,89 +178,40 @@ AC_DEFUN([gl_NEXT_HEADERS_INTERNAL],
175 [AC_CHECK_HEADERS_ONCE([$1]) 178 [AC_CHECK_HEADERS_ONCE([$1])
176 ]) 179 ])
177 180
178dnl FIXME: gl_next_header and gl_header_exists must be used unquoted
179dnl until we can assume autoconf 2.64 or newer.
180 m4_foreach_w([gl_HEADER_NAME], [$1], 181 m4_foreach_w([gl_HEADER_NAME], [$1],
181 [AS_VAR_PUSHDEF([gl_next_header], 182 [AS_VAR_PUSHDEF([gl_next_header],
182 [gl_cv_next_]m4_defn([gl_HEADER_NAME])) 183 [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
183 if test $gl_cv_have_include_next = yes; then 184 if test $gl_cv_have_include_next = yes; then
184 AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>']) 185 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
185 else 186 else
186 AC_CACHE_CHECK( 187 AC_CACHE_CHECK(
187 [absolute name of <]m4_defn([gl_HEADER_NAME])[>], 188 [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
188 m4_defn([gl_next_header]), 189 [gl_next_header],
189 [m4_if([$2], [check], 190 [m4_if([$2], [check],
190 [AS_VAR_PUSHDEF([gl_header_exists], 191 [AS_VAR_PUSHDEF([gl_header_exists],
191 [ac_cv_header_]m4_defn([gl_HEADER_NAME])) 192 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
192 if test AS_VAR_GET(gl_header_exists) = yes; then 193 if test AS_VAR_GET([gl_header_exists]) = yes; then
193 AS_VAR_POPDEF([gl_header_exists]) 194 AS_VAR_POPDEF([gl_header_exists])
194 ]) 195 ])
195 AC_LANG_CONFTEST( 196 gl_ABSOLUTE_HEADER_ONE(gl_HEADER_NAME)
196 [AC_LANG_SOURCE( 197 AS_VAR_COPY([gl_header], [gl_cv_absolute_]AS_TR_SH(gl_HEADER_NAME))
197 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] 198 AS_VAR_SET([gl_next_header], ['"'$gl_header'"'])
198 )])
199 dnl AIX "xlc -E" and "cc -E" omit #line directives for header
200 dnl files that contain only a #include of other header files and
201 dnl no non-comment tokens of their own. This leads to a failure
202 dnl to detect the absolute name of <dirent.h>, <signal.h>,
203 dnl <poll.h> and others. The workaround is to force preservation
204 dnl of comments through option -C. This ensures all necessary
205 dnl #line directives are present. GCC supports option -C as well.
206 case "$host_os" in
207 aix*) gl_absname_cpp="$ac_cpp -C" ;;
208 *) gl_absname_cpp="$ac_cpp" ;;
209 esac
210changequote(,)
211 case "$host_os" in
212 mingw*)
213 dnl For the sake of native Windows compilers (excluding gcc),
214 dnl treat backslash as a directory separator, like /.
215 dnl Actually, these compilers use a double-backslash as
216 dnl directory separator, inside the
217 dnl # line "filename"
218 dnl directives.
219 gl_dirsep_regex='[/\\]'
220 ;;
221 *)
222 gl_dirsep_regex='\/'
223 ;;
224 esac
225 dnl A sed expression that turns a string into a basic regular
226 dnl expression, for use within "/.../".
227 gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
228changequote([,])
229 gl_header_literal_regex=`echo ']m4_defn([gl_HEADER_NAME])[' \
230 | sed -e "$gl_make_literal_regex_sed"`
231 gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
232 s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
233changequote(,)dnl
234 s|^/[^/]|//&|
235changequote([,])dnl
236 p
237 q
238 }'
239 dnl eval is necessary to expand gl_absname_cpp.
240 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
241 dnl so use subshell.
242 AS_VAR_SET(gl_next_header,
243 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
244 sed -n "$gl_absolute_header_sed"`'"'])
245 m4_if([$2], [check], 199 m4_if([$2], [check],
246 [else 200 [else
247 AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>']) 201 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
248 fi 202 fi
249 ]) 203 ])
250 ]) 204 ])
251 fi 205 fi
252 AC_SUBST( 206 AC_SUBST(
253 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])), 207 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
254 [AS_VAR_GET(gl_next_header)]) 208 [AS_VAR_GET([gl_next_header])])
255 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then 209 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
256 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' 210 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
257 gl_next_as_first_directive='<'gl_HEADER_NAME'>' 211 gl_next_as_first_directive='<'gl_HEADER_NAME'>'
258 else 212 else
259 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' 213 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
260 gl_next_as_first_directive=AS_VAR_GET(gl_next_header) 214 gl_next_as_first_directive=AS_VAR_GET([gl_next_header])
261 fi 215 fi
262 AC_SUBST( 216 AC_SUBST(
263 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])), 217 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),
diff --git a/gl/m4/inet_ntop.m4 b/gl/m4/inet_ntop.m4
index 476f063f..48822d69 100644
--- a/gl/m4/inet_ntop.m4
+++ b/gl/m4/inet_ntop.m4
@@ -1,5 +1,5 @@
1# inet_ntop.m4 serial 19 1# inet_ntop.m4 serial 21
2dnl Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -16,6 +16,7 @@ AC_DEFUN([gl_FUNC_INET_NTOP],
16 dnl Most platforms that provide inet_ntop define it in libc. 16 dnl Most platforms that provide inet_ntop define it in libc.
17 dnl Solaris 8..10 provide inet_ntop in libnsl instead. 17 dnl Solaris 8..10 provide inet_ntop in libnsl instead.
18 dnl Solaris 2.6..7 provide inet_ntop in libresolv instead. 18 dnl Solaris 2.6..7 provide inet_ntop in libresolv instead.
19 dnl Haiku provides it in -lnetwork.
19 dnl Native Windows provides it in -lws2_32 instead, with a declaration in 20 dnl Native Windows provides it in -lws2_32 instead, with a declaration in
20 dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl 21 dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
21 dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it). 22 dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
@@ -23,19 +24,20 @@ AC_DEFUN([gl_FUNC_INET_NTOP],
23 INET_NTOP_LIB= 24 INET_NTOP_LIB=
24 gl_PREREQ_SYS_H_WINSOCK2 25 gl_PREREQ_SYS_H_WINSOCK2
25 if test $HAVE_WINSOCK2_H = 1; then 26 if test $HAVE_WINSOCK2_H = 1; then
27 dnl It needs to be overridden, because the stdcall calling convention
28 dnl is not compliant with POSIX. Set REPLACE_INET_NTOP in order to avoid
29 dnl a name conflict at the linker level, even though the header file
30 dnl <ws2tcpip.h> declares inet_ntop only if _WIN32_WINNT >= 0x0600.
31 REPLACE_INET_NTOP=1
26 AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]]) 32 AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]])
27 if test $ac_cv_have_decl_inet_ntop = yes; then 33 if test $ac_cv_have_decl_inet_ntop = yes; then
28 dnl It needs to be overridden, because the stdcall calling convention
29 dnl is not compliant with POSIX.
30 REPLACE_INET_NTOP=1
31 INET_NTOP_LIB="-lws2_32" 34 INET_NTOP_LIB="-lws2_32"
32 else 35 else
33 HAVE_DECL_INET_NTOP=0 36 HAVE_DECL_INET_NTOP=0
34 HAVE_INET_NTOP=0
35 fi 37 fi
36 else 38 else
37 gl_save_LIBS=$LIBS 39 gl_save_LIBS=$LIBS
38 AC_SEARCH_LIBS([inet_ntop], [nsl resolv], [], 40 AC_SEARCH_LIBS([inet_ntop], [nsl resolv network], [],
39 [AC_CHECK_FUNCS([inet_ntop]) 41 [AC_CHECK_FUNCS([inet_ntop])
40 if test $ac_cv_func_inet_ntop = no; then 42 if test $ac_cv_func_inet_ntop = no; then
41 HAVE_INET_NTOP=0 43 HAVE_INET_NTOP=0
diff --git a/gl/m4/intdiv0.m4 b/gl/m4/intdiv0.m4
deleted file mode 100644
index 74d0e80d..00000000
--- a/gl/m4/intdiv0.m4
+++ /dev/null
@@ -1,87 +0,0 @@
1# intdiv0.m4 serial 6 (gettext-0.18.2)
2dnl Copyright (C) 2002, 2007-2008, 2010-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9AC_DEFUN([gt_INTDIV0],
10[
11 AC_REQUIRE([AC_PROG_CC])dnl
12 AC_REQUIRE([AC_CANONICAL_HOST])dnl
13
14 AC_CACHE_CHECK([whether integer division by zero raises SIGFPE],
15 gt_cv_int_divbyzero_sigfpe,
16 [
17 gt_cv_int_divbyzero_sigfpe=
18changequote(,)dnl
19 case "$host_os" in
20 macos* | darwin[6-9]* | darwin[1-9][0-9]*)
21 # On Mac OS X 10.2 or newer, just assume the same as when cross-
22 # compiling. If we were to perform the real test, 1 Crash Report
23 # dialog window would pop up.
24 case "$host_cpu" in
25 i[34567]86 | x86_64)
26 gt_cv_int_divbyzero_sigfpe="guessing yes" ;;
27 esac
28 ;;
29 esac
30changequote([,])dnl
31 if test -z "$gt_cv_int_divbyzero_sigfpe"; then
32 AC_RUN_IFELSE(
33 [AC_LANG_SOURCE([[
34#include <stdlib.h>
35#include <signal.h>
36
37static void
38sigfpe_handler (int sig)
39{
40 /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */
41 exit (sig != SIGFPE);
42}
43
44int x = 1;
45int y = 0;
46int z;
47int nan;
48
49int main ()
50{
51 signal (SIGFPE, sigfpe_handler);
52/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */
53#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
54 signal (SIGTRAP, sigfpe_handler);
55#endif
56/* Linux/SPARC yields signal SIGILL. */
57#if defined (__sparc__) && defined (__linux__)
58 signal (SIGILL, sigfpe_handler);
59#endif
60
61 z = x / y;
62 nan = y / y;
63 exit (2);
64}
65]])],
66 [gt_cv_int_divbyzero_sigfpe=yes],
67 [gt_cv_int_divbyzero_sigfpe=no],
68 [
69 # Guess based on the CPU.
70changequote(,)dnl
71 case "$host_cpu" in
72 alpha* | i[34567]86 | x86_64 | m68k | s390*)
73 gt_cv_int_divbyzero_sigfpe="guessing yes";;
74 *)
75 gt_cv_int_divbyzero_sigfpe="guessing no";;
76 esac
77changequote([,])dnl
78 ])
79 fi
80 ])
81 case "$gt_cv_int_divbyzero_sigfpe" in
82 *yes) value=1;;
83 *) value=0;;
84 esac
85 AC_DEFINE_UNQUOTED([INTDIV0_RAISES_SIGFPE], [$value],
86 [Define if integer division by zero raises signal SIGFPE.])
87])
diff --git a/gl/m4/intl.m4 b/gl/m4/intl.m4
deleted file mode 100644
index 959bd042..00000000
--- a/gl/m4/intl.m4
+++ /dev/null
@@ -1,271 +0,0 @@
1# intl.m4 serial 23 (gettext-0.18.3)
2dnl Copyright (C) 1995-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2009.
19
20AC_PREREQ([2.60])
21
22dnl Checks for all prerequisites of the intl subdirectory,
23dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
24dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
25AC_DEFUN([AM_INTL_SUBDIR],
26[
27 AC_REQUIRE([AC_PROG_INSTALL])dnl
28 AC_REQUIRE([AC_PROG_MKDIR_P])dnl
29 AC_REQUIRE([AC_PROG_CC])dnl
30 AC_REQUIRE([AC_CANONICAL_HOST])dnl
31 AC_REQUIRE([gt_GLIBC2])dnl
32 AC_REQUIRE([AC_PROG_RANLIB])dnl
33 AC_REQUIRE([gl_VISIBILITY])dnl
34 AC_REQUIRE([gt_INTL_SUBDIR_CORE])dnl
35 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])dnl
36 AC_REQUIRE([gt_TYPE_WCHAR_T])dnl
37 AC_REQUIRE([gt_TYPE_WINT_T])dnl
38 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
39 AC_REQUIRE([gt_TYPE_INTMAX_T])
40 AC_REQUIRE([gt_PRINTF_POSIX])
41 AC_REQUIRE([gl_GLIBC21])dnl
42 AC_REQUIRE([gl_XSIZE])dnl
43 AC_REQUIRE([gl_FCNTL_O_FLAGS])dnl
44 AC_REQUIRE([gt_INTL_MACOSX])dnl
45
46 dnl Support for automake's --enable-silent-rules.
47 case "$enable_silent_rules" in
48 yes) INTL_DEFAULT_VERBOSITY=0;;
49 no) INTL_DEFAULT_VERBOSITY=1;;
50 *) INTL_DEFAULT_VERBOSITY=1;;
51 esac
52 AC_SUBST([INTL_DEFAULT_VERBOSITY])
53
54 AC_CHECK_TYPE([ptrdiff_t], ,
55 [AC_DEFINE([ptrdiff_t], [long],
56 [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
57 ])
58 AC_CHECK_HEADERS([features.h stddef.h stdlib.h string.h])
59 AC_CHECK_FUNCS([asprintf fwprintf newlocale putenv setenv setlocale \
60 snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
61
62 dnl Use the _snprintf function only if it is declared (because on NetBSD it
63 dnl is defined as a weak alias of snprintf; we prefer to use the latter).
64 AC_CHECK_DECLS([_snprintf _snwprintf], , , [#include <stdio.h>])
65
66 dnl Use the *_unlocked functions only if they are declared.
67 dnl (because some of them were defined without being declared in Solaris
68 dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
69 dnl on Solaris 2.5.1 to run on Solaris 2.6).
70 AC_CHECK_DECLS([getc_unlocked], , , [#include <stdio.h>])
71
72 case $gt_cv_func_printf_posix in
73 *yes) HAVE_POSIX_PRINTF=1 ;;
74 *) HAVE_POSIX_PRINTF=0 ;;
75 esac
76 AC_SUBST([HAVE_POSIX_PRINTF])
77 if test "$ac_cv_func_asprintf" = yes; then
78 HAVE_ASPRINTF=1
79 else
80 HAVE_ASPRINTF=0
81 fi
82 AC_SUBST([HAVE_ASPRINTF])
83 if test "$ac_cv_func_snprintf" = yes; then
84 HAVE_SNPRINTF=1
85 else
86 HAVE_SNPRINTF=0
87 fi
88 AC_SUBST([HAVE_SNPRINTF])
89 if test "$ac_cv_func_newlocale" = yes; then
90 HAVE_NEWLOCALE=1
91 else
92 HAVE_NEWLOCALE=0
93 fi
94 AC_SUBST([HAVE_NEWLOCALE])
95 if test "$ac_cv_func_wprintf" = yes; then
96 HAVE_WPRINTF=1
97 else
98 HAVE_WPRINTF=0
99 fi
100 AC_SUBST([HAVE_WPRINTF])
101
102 AM_LANGINFO_CODESET
103 gt_LC_MESSAGES
104
105 dnl Compilation on mingw and Cygwin needs special Makefile rules, because
106 dnl 1. when we install a shared library, we must arrange to export
107 dnl auxiliary pointer variables for every exported variable,
108 dnl 2. when we install a shared library and a static library simultaneously,
109 dnl the include file specifies __declspec(dllimport) and therefore we
110 dnl must arrange to define the auxiliary pointer variables for the
111 dnl exported variables _also_ in the static library.
112 if test "$enable_shared" = yes; then
113 case "$host_os" in
114 mingw* | cygwin*) is_woe32dll=yes ;;
115 *) is_woe32dll=no ;;
116 esac
117 else
118 is_woe32dll=no
119 fi
120 WOE32DLL=$is_woe32dll
121 AC_SUBST([WOE32DLL])
122
123 dnl On mingw and Cygwin, we can activate special Makefile rules which add
124 dnl version information to the shared libraries and executables.
125 case "$host_os" in
126 mingw* | cygwin*) is_woe32=yes ;;
127 *) is_woe32=no ;;
128 esac
129 WOE32=$is_woe32
130 AC_SUBST([WOE32])
131 if test $WOE32 = yes; then
132 dnl Check for a program that compiles Windows resource files.
133 AC_CHECK_TOOL([WINDRES], [windres])
134 fi
135
136 dnl Determine whether when creating a library, "-lc" should be passed to
137 dnl libtool or not. On many platforms, it is required for the libtool option
138 dnl -no-undefined to work. On HP-UX, however, the -lc - stored by libtool
139 dnl in the *.la files - makes it impossible to create multithreaded programs,
140 dnl because libtool also reorders the -lc to come before the -pthread, and
141 dnl this disables pthread_create() <http://docs.hp.com/en/1896/pthreads.html>.
142 case "$host_os" in
143 hpux*) LTLIBC="" ;;
144 *) LTLIBC="-lc" ;;
145 esac
146 AC_SUBST([LTLIBC])
147
148 dnl Rename some macros and functions used for locking.
149 AH_BOTTOM([
150#define __libc_lock_t gl_lock_t
151#define __libc_lock_define gl_lock_define
152#define __libc_lock_define_initialized gl_lock_define_initialized
153#define __libc_lock_init gl_lock_init
154#define __libc_lock_lock gl_lock_lock
155#define __libc_lock_unlock gl_lock_unlock
156#define __libc_lock_recursive_t gl_recursive_lock_t
157#define __libc_lock_define_recursive gl_recursive_lock_define
158#define __libc_lock_define_initialized_recursive gl_recursive_lock_define_initialized
159#define __libc_lock_init_recursive gl_recursive_lock_init
160#define __libc_lock_lock_recursive gl_recursive_lock_lock
161#define __libc_lock_unlock_recursive gl_recursive_lock_unlock
162#define glthread_in_use libintl_thread_in_use
163#define glthread_lock_init_func libintl_lock_init_func
164#define glthread_lock_lock_func libintl_lock_lock_func
165#define glthread_lock_unlock_func libintl_lock_unlock_func
166#define glthread_lock_destroy_func libintl_lock_destroy_func
167#define glthread_rwlock_init_multithreaded libintl_rwlock_init_multithreaded
168#define glthread_rwlock_init_func libintl_rwlock_init_func
169#define glthread_rwlock_rdlock_multithreaded libintl_rwlock_rdlock_multithreaded
170#define glthread_rwlock_rdlock_func libintl_rwlock_rdlock_func
171#define glthread_rwlock_wrlock_multithreaded libintl_rwlock_wrlock_multithreaded
172#define glthread_rwlock_wrlock_func libintl_rwlock_wrlock_func
173#define glthread_rwlock_unlock_multithreaded libintl_rwlock_unlock_multithreaded
174#define glthread_rwlock_unlock_func libintl_rwlock_unlock_func
175#define glthread_rwlock_destroy_multithreaded libintl_rwlock_destroy_multithreaded
176#define glthread_rwlock_destroy_func libintl_rwlock_destroy_func
177#define glthread_recursive_lock_init_multithreaded libintl_recursive_lock_init_multithreaded
178#define glthread_recursive_lock_init_func libintl_recursive_lock_init_func
179#define glthread_recursive_lock_lock_multithreaded libintl_recursive_lock_lock_multithreaded
180#define glthread_recursive_lock_lock_func libintl_recursive_lock_lock_func
181#define glthread_recursive_lock_unlock_multithreaded libintl_recursive_lock_unlock_multithreaded
182#define glthread_recursive_lock_unlock_func libintl_recursive_lock_unlock_func
183#define glthread_recursive_lock_destroy_multithreaded libintl_recursive_lock_destroy_multithreaded
184#define glthread_recursive_lock_destroy_func libintl_recursive_lock_destroy_func
185#define glthread_once_func libintl_once_func
186#define glthread_once_singlethreaded libintl_once_singlethreaded
187#define glthread_once_multithreaded libintl_once_multithreaded
188])
189])
190
191
192dnl Checks for the core files of the intl subdirectory:
193dnl dcigettext.c
194dnl eval-plural.h
195dnl explodename.c
196dnl finddomain.c
197dnl gettextP.h
198dnl gmo.h
199dnl hash-string.h hash-string.c
200dnl l10nflist.c
201dnl libgnuintl.h.in (except the *printf stuff)
202dnl loadinfo.h
203dnl loadmsgcat.c
204dnl localealias.c
205dnl log.c
206dnl plural-exp.h plural-exp.c
207dnl plural.y
208dnl Used by libglocale.
209AC_DEFUN([gt_INTL_SUBDIR_CORE],
210[
211 AC_REQUIRE([AC_C_INLINE])dnl
212 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
213 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
214 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
215 AC_REQUIRE([AC_FUNC_MMAP])dnl
216 AC_REQUIRE([gt_INTDIV0])dnl
217 AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])dnl
218 AC_REQUIRE([gt_INTTYPES_PRI])dnl
219 AC_REQUIRE([gl_LOCK])dnl
220
221 AC_LINK_IFELSE(
222 [AC_LANG_PROGRAM(
223 [[int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }]],
224 [[]])],
225 [AC_DEFINE([HAVE_BUILTIN_EXPECT], [1],
226 [Define to 1 if the compiler understands __builtin_expect.])])
227
228 AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h])
229 AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \
230 stpcpy strcasecmp strdup strtoul tsearch uselocale argz_count \
231 argz_stringify argz_next __fsetlocking])
232
233 dnl Use the *_unlocked functions only if they are declared.
234 dnl (because some of them were defined without being declared in Solaris
235 dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
236 dnl on Solaris 2.5.1 to run on Solaris 2.6).
237 AC_CHECK_DECLS([feof_unlocked fgets_unlocked], , , [#include <stdio.h>])
238
239 AM_ICONV
240
241 dnl intl/plural.c is generated from intl/plural.y. It requires bison,
242 dnl because plural.y uses bison specific features. It requires at least
243 dnl bison-1.26 because earlier versions generate a plural.c that doesn't
244 dnl compile.
245 dnl bison is only needed for the maintainer (who touches plural.y). But in
246 dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
247 dnl the rule in general Makefile. Now, some people carelessly touch the
248 dnl files or have a broken "make" program, hence the plural.c rule will
249 dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
250 dnl present or too old.
251 AC_CHECK_PROGS([INTLBISON], [bison])
252 if test -z "$INTLBISON"; then
253 ac_verc_fail=yes
254 else
255 dnl Found it, now check the version.
256 AC_MSG_CHECKING([version of bison])
257changequote(<<,>>)dnl
258 ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
259 case $ac_prog_version in
260 '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
261 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
262changequote([,])dnl
263 ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
264 *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
265 esac
266 AC_MSG_RESULT([$ac_prog_version])
267 fi
268 if test $ac_verc_fail = yes; then
269 INTLBISON=:
270 fi
271])
diff --git a/gl/m4/intldir.m4 b/gl/m4/intldir.m4
deleted file mode 100644
index 388ecd6f..00000000
--- a/gl/m4/intldir.m4
+++ /dev/null
@@ -1,19 +0,0 @@
1# intldir.m4 serial 2 (gettext-0.18)
2dnl Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16AC_PREREQ([2.52])
17
18dnl Tells the AM_GNU_GETTEXT macro to consider an intl/ directory.
19AC_DEFUN([AM_GNU_GETTEXT_INTL_SUBDIR], [])
diff --git a/gl/m4/intlmacosx.m4 b/gl/m4/intlmacosx.m4
deleted file mode 100644
index ab97d39f..00000000
--- a/gl/m4/intlmacosx.m4
+++ /dev/null
@@ -1,56 +0,0 @@
1# intlmacosx.m4 serial 5 (gettext-0.18.2)
2dnl Copyright (C) 2004-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16dnl Checks for special options needed on Mac OS X.
17dnl Defines INTL_MACOSX_LIBS.
18AC_DEFUN([gt_INTL_MACOSX],
19[
20 dnl Check for API introduced in Mac OS X 10.2.
21 AC_CACHE_CHECK([for CFPreferencesCopyAppValue],
22 [gt_cv_func_CFPreferencesCopyAppValue],
23 [gt_save_LIBS="$LIBS"
24 LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
25 AC_LINK_IFELSE(
26 [AC_LANG_PROGRAM(
27 [[#include <CoreFoundation/CFPreferences.h>]],
28 [[CFPreferencesCopyAppValue(NULL, NULL)]])],
29 [gt_cv_func_CFPreferencesCopyAppValue=yes],
30 [gt_cv_func_CFPreferencesCopyAppValue=no])
31 LIBS="$gt_save_LIBS"])
32 if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
33 AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1],
34 [Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
35 fi
36 dnl Check for API introduced in Mac OS X 10.3.
37 AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent],
38 [gt_save_LIBS="$LIBS"
39 LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
40 AC_LINK_IFELSE(
41 [AC_LANG_PROGRAM(
42 [[#include <CoreFoundation/CFLocale.h>]],
43 [[CFLocaleCopyCurrent();]])],
44 [gt_cv_func_CFLocaleCopyCurrent=yes],
45 [gt_cv_func_CFLocaleCopyCurrent=no])
46 LIBS="$gt_save_LIBS"])
47 if test $gt_cv_func_CFLocaleCopyCurrent = yes; then
48 AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1],
49 [Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework.])
50 fi
51 INTL_MACOSX_LIBS=
52 if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then
53 INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
54 fi
55 AC_SUBST([INTL_MACOSX_LIBS])
56])
diff --git a/gl/m4/intmax.m4 b/gl/m4/intmax.m4
deleted file mode 100644
index 18733a52..00000000
--- a/gl/m4/intmax.m4
+++ /dev/null
@@ -1,36 +0,0 @@
1# intmax.m4 serial 6 (gettext-0.18.2)
2dnl Copyright (C) 2002-2005, 2008-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8dnl Test whether the system has the 'intmax_t' type, but don't attempt to
9dnl find a replacement if it is lacking.
10
11AC_DEFUN([gt_TYPE_INTMAX_T],
12[
13 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
14 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
15 AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t],
16 [AC_COMPILE_IFELSE(
17 [AC_LANG_PROGRAM(
18 [[
19#include <stddef.h>
20#include <stdlib.h>
21#if HAVE_STDINT_H_WITH_UINTMAX
22#include <stdint.h>
23#endif
24#if HAVE_INTTYPES_H_WITH_UINTMAX
25#include <inttypes.h>
26#endif
27 ]],
28 [[intmax_t x = -1;
29 return !x;]])],
30 [gt_cv_c_intmax_t=yes],
31 [gt_cv_c_intmax_t=no])])
32 if test $gt_cv_c_intmax_t = yes; then
33 AC_DEFINE([HAVE_INTMAX_T], [1],
34 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
35 fi
36])
diff --git a/gl/m4/intmax_t.m4 b/gl/m4/intmax_t.m4
index 6ea70531..ef32e1b9 100644
--- a/gl/m4/intmax_t.m4
+++ b/gl/m4/intmax_t.m4
@@ -1,5 +1,5 @@
1# intmax_t.m4 serial 8 1# intmax_t.m4 serial 9
2dnl Copyright (C) 1997-2004, 2006-2007, 2009-2013 Free Software Foundation, 2dnl Copyright (C) 1997-2004, 2006-2007, 2009-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -19,11 +19,7 @@ AC_DEFUN([gl_AC_TYPE_INTMAX_T],
19 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) 19 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
20 AC_REQUIRE([gl_AC_HEADER_STDINT_H]) 20 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
21 if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then 21 if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then
22 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 22 AC_DEFINE_UNQUOTED([intmax_t], [long long],
23 test $ac_cv_type_long_long_int = yes \
24 && ac_type='long long' \
25 || ac_type='long'
26 AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
27 [Define to long or long long if <inttypes.h> and <stdint.h> don't define.]) 23 [Define to long or long long if <inttypes.h> and <stdint.h> don't define.])
28 else 24 else
29 AC_DEFINE([HAVE_INTMAX_T], [1], 25 AC_DEFINE([HAVE_INTMAX_T], [1],
@@ -57,11 +53,7 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T],
57 AC_DEFINE([HAVE_INTMAX_T], [1], 53 AC_DEFINE([HAVE_INTMAX_T], [1],
58 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.]) 54 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
59 else 55 else
60 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 56 AC_DEFINE_UNQUOTED([intmax_t], [long long],
61 test $ac_cv_type_long_long_int = yes \
62 && ac_type='long long' \
63 || ac_type='long'
64 AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
65 [Define to long or long long if <stdint.h> and <inttypes.h> don't define.]) 57 [Define to long or long long if <stdint.h> and <inttypes.h> don't define.])
66 fi 58 fi
67]) 59])
diff --git a/gl/m4/inttypes-pri.m4 b/gl/m4/inttypes-pri.m4
deleted file mode 100644
index e5a1e057..00000000
--- a/gl/m4/inttypes-pri.m4
+++ /dev/null
@@ -1,42 +0,0 @@
1# inttypes-pri.m4 serial 7 (gettext-0.18.2)
2dnl Copyright (C) 1997-2002, 2006, 2008-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9AC_PREREQ([2.53])
10
11# Define PRI_MACROS_BROKEN if <inttypes.h> exists and defines the PRI*
12# macros to non-string values. This is the case on AIX 4.3.3.
13
14AC_DEFUN([gt_INTTYPES_PRI],
15[
16 AC_CHECK_HEADERS([inttypes.h])
17 if test $ac_cv_header_inttypes_h = yes; then
18 AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken],
19 [gt_cv_inttypes_pri_broken],
20 [
21 AC_COMPILE_IFELSE(
22 [AC_LANG_PROGRAM(
23 [[
24#include <inttypes.h>
25#ifdef PRId32
26char *p = PRId32;
27#endif
28 ]],
29 [[]])],
30 [gt_cv_inttypes_pri_broken=no],
31 [gt_cv_inttypes_pri_broken=yes])
32 ])
33 fi
34 if test "$gt_cv_inttypes_pri_broken" = yes; then
35 AC_DEFINE_UNQUOTED([PRI_MACROS_BROKEN], [1],
36 [Define if <inttypes.h> exists and defines unusable PRI* macros.])
37 PRI_MACROS_BROKEN=1
38 else
39 PRI_MACROS_BROKEN=0
40 fi
41 AC_SUBST([PRI_MACROS_BROKEN])
42])
diff --git a/gl/m4/inttypes.m4 b/gl/m4/inttypes.m4
new file mode 100644
index 00000000..bf2eab2b
--- /dev/null
+++ b/gl/m4/inttypes.m4
@@ -0,0 +1,180 @@
1# inttypes.m4 serial 36
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Derek Price, Bruno Haible.
8dnl Test whether <inttypes.h> is supported or must be substituted.
9
10AC_DEFUN_ONCE([gl_INTTYPES_H],
11[
12 AC_REQUIRE([gl_INTTYPES_INCOMPLETE])
13 gl_INTTYPES_PRI_SCN
14])
15
16AC_DEFUN_ONCE([gl_INTTYPES_INCOMPLETE],
17[
18 AC_REQUIRE([gl_STDINT_H])
19 AC_CHECK_HEADERS_ONCE([inttypes.h])
20
21 dnl Override <inttypes.h> always, so that the portability warnings work.
22 AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
23 gl_CHECK_NEXT_HEADERS([inttypes.h])
24
25 AC_REQUIRE([gl_MULTIARCH])
26
27 dnl Check for declarations of anything we want to poison if the
28 dnl corresponding gnulib module is not in use.
29 gl_WARN_ON_USE_PREPARE([[#include <inttypes.h>
30 ]], [imaxabs imaxdiv strtoimax strtoumax])
31
32 AC_REQUIRE([AC_C_RESTRICT])
33])
34
35# Ensure that the PRI* and SCN* macros are defined appropriately.
36AC_DEFUN([gl_INTTYPES_PRI_SCN],
37[
38 PRIPTR_PREFIX=
39 if $GL_GENERATE_STDINT_H; then
40 dnl Using the gnulib <stdint.h>. It defines intptr_t to 'long' or
41 dnl 'long long', depending on _WIN64.
42 AC_COMPILE_IFELSE(
43 [AC_LANG_PROGRAM([[
44 #ifdef _WIN64
45 LLP64
46 #endif
47 ]])
48 ],
49 [PRIPTR_PREFIX='"l"'],
50 [PRIPTR_PREFIX='"ll"'])
51 else
52 dnl Using the system's <stdint.h>.
53 for glpfx in '' l ll I64; do
54 case $glpfx in
55 '') gltype1='int';;
56 l) gltype1='long int';;
57 ll) gltype1='long long int';;
58 I64) gltype1='__int64';;
59 esac
60 AC_COMPILE_IFELSE(
61 [AC_LANG_PROGRAM([[#include <stdint.h>
62 extern intptr_t foo;
63 extern $gltype1 foo;]])],
64 [PRIPTR_PREFIX='"'$glpfx'"'])
65 test -n "$PRIPTR_PREFIX" && break
66 done
67 fi
68 AC_SUBST([PRIPTR_PREFIX])
69
70 gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
71 [INT32_MAX_LT_INTMAX_MAX],
72 [defined INT32_MAX && defined INTMAX_MAX],
73 [INT32_MAX < INTMAX_MAX],
74 [sizeof (int) < sizeof (long long int)])
75 if test $APPLE_UNIVERSAL_BUILD = 0; then
76 gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
77 [INT64_MAX_EQ_LONG_MAX],
78 [defined INT64_MAX],
79 [INT64_MAX == LONG_MAX],
80 [sizeof (long long int) == sizeof (long int)])
81 else
82 INT64_MAX_EQ_LONG_MAX=-1
83 fi
84 gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
85 [UINT32_MAX_LT_UINTMAX_MAX],
86 [defined UINT32_MAX && defined UINTMAX_MAX],
87 [UINT32_MAX < UINTMAX_MAX],
88 [sizeof (unsigned int) < sizeof (unsigned long long int)])
89 if test $APPLE_UNIVERSAL_BUILD = 0; then
90 gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
91 [UINT64_MAX_EQ_ULONG_MAX],
92 [defined UINT64_MAX],
93 [UINT64_MAX == ULONG_MAX],
94 [sizeof (unsigned long long int) == sizeof (unsigned long int)])
95 else
96 UINT64_MAX_EQ_ULONG_MAX=-1
97 fi
98])
99
100# Define the symbol $1 to be 1 if the condition is true, 0 otherwise.
101# If $2 is true, the condition is $3; otherwise if long long int is supported
102# approximate the condition with $4; otherwise, assume the condition is false.
103# The condition should work on all C99 platforms; the approximations should be
104# good enough to work on all practical pre-C99 platforms.
105# $2 is evaluated by the C preprocessor, $3 and $4 as compile-time constants.
106AC_DEFUN([gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION],
107[
108 AC_CACHE_CHECK([whether $3],
109 [gl_cv_test_$1],
110 [AC_COMPILE_IFELSE(
111 [AC_LANG_PROGRAM(
112 [[/* Work also in C++ mode. */
113 #define __STDC_LIMIT_MACROS 1
114
115 /* Work if build is not clean. */
116 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H
117
118 #include <limits.h>
119 #if HAVE_STDINT_H
120 #include <stdint.h>
121 #endif
122
123 #if $2
124 #define CONDITION ($3)
125 #else
126 #define CONDITION ($4)
127 #endif
128 int test[CONDITION ? 1 : -1];]])],
129 [gl_cv_test_$1=yes],
130 [gl_cv_test_$1=no])])
131 if test $gl_cv_test_$1 = yes; then
132 $1=1;
133 else
134 $1=0;
135 fi
136 AC_SUBST([$1])
137])
138
139# gl_INTTYPES_MODULE_INDICATOR([modulename])
140# sets the shell variable that indicates the presence of the given module
141# to a C preprocessor expression that will evaluate to 1.
142# This macro invocation must not occur in macros that are AC_REQUIREd.
143AC_DEFUN([gl_INTTYPES_MODULE_INDICATOR],
144[
145 dnl Ensure to expand the default settings once only.
146 gl_INTTYPES_H_REQUIRE_DEFAULTS
147 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
148])
149
150# Initializes the default values for AC_SUBSTed shell variables.
151# This macro must not be AC_REQUIREd. It must only be invoked, and only
152# outside of macros or in macros that are not AC_REQUIREd.
153AC_DEFUN([gl_INTTYPES_H_REQUIRE_DEFAULTS],
154[
155 m4_defun(GL_MODULE_INDICATOR_PREFIX[_INTTYPES_H_MODULE_INDICATOR_DEFAULTS], [
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_IMAXABS])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_IMAXDIV])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOIMAX])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOUMAX])
160 ])
161 m4_require(GL_MODULE_INDICATOR_PREFIX[_INTTYPES_H_MODULE_INDICATOR_DEFAULTS])
162 AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
163])
164
165AC_DEFUN([gl_INTTYPES_H_DEFAULTS],
166[
167 dnl Assume proper GNU behavior unless another module says otherwise.
168 HAVE_DECL_IMAXABS=1; AC_SUBST([HAVE_DECL_IMAXABS])
169 HAVE_DECL_IMAXDIV=1; AC_SUBST([HAVE_DECL_IMAXDIV])
170 HAVE_DECL_STRTOIMAX=1; AC_SUBST([HAVE_DECL_STRTOIMAX])
171 HAVE_DECL_STRTOUMAX=1; AC_SUBST([HAVE_DECL_STRTOUMAX])
172 HAVE_IMAXDIV_T=1; AC_SUBST([HAVE_IMAXDIV_T])
173 REPLACE_STRTOIMAX=0; AC_SUBST([REPLACE_STRTOIMAX])
174 REPLACE_STRTOUMAX=0; AC_SUBST([REPLACE_STRTOUMAX])
175 INT32_MAX_LT_INTMAX_MAX=1; AC_SUBST([INT32_MAX_LT_INTMAX_MAX])
176 INT64_MAX_EQ_LONG_MAX='defined _LP64'; AC_SUBST([INT64_MAX_EQ_LONG_MAX])
177 PRIPTR_PREFIX=__PRIPTR_PREFIX; AC_SUBST([PRIPTR_PREFIX])
178 UINT32_MAX_LT_UINTMAX_MAX=1; AC_SUBST([UINT32_MAX_LT_UINTMAX_MAX])
179 UINT64_MAX_EQ_ULONG_MAX='defined _LP64'; AC_SUBST([UINT64_MAX_EQ_ULONG_MAX])
180])
diff --git a/gl/m4/inttypes_h.m4 b/gl/m4/inttypes_h.m4
index 5f05ac58..68c60e9d 100644
--- a/gl/m4/inttypes_h.m4
+++ b/gl/m4/inttypes_h.m4
@@ -1,5 +1,5 @@
1# inttypes_h.m4 serial 10 1# inttypes_h.m4 serial 10
2dnl Copyright (C) 1997-2004, 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 1997-2004, 2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/langinfo_h.m4 b/gl/m4/langinfo_h.m4
index 73bef8bc..b17a526a 100644
--- a/gl/m4/langinfo_h.m4
+++ b/gl/m4/langinfo_h.m4
@@ -1,10 +1,10 @@
1# langinfo_h.m4 serial 7 1# langinfo_h.m4 serial 12
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_LANGINFO_H], 7AC_DEFUN_ONCE([gl_LANGINFO_H],
8[ 8[
9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) 9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
10 10
@@ -17,13 +17,17 @@ AC_DEFUN([gl_LANGINFO_H],
17 dnl Determine whether <langinfo.h> exists. It is missing on mingw and BeOS. 17 dnl Determine whether <langinfo.h> exists. It is missing on mingw and BeOS.
18 HAVE_LANGINFO_CODESET=0 18 HAVE_LANGINFO_CODESET=0
19 HAVE_LANGINFO_T_FMT_AMPM=0 19 HAVE_LANGINFO_T_FMT_AMPM=0
20 HAVE_LANGINFO_ALTMON=0
20 HAVE_LANGINFO_ERA=0 21 HAVE_LANGINFO_ERA=0
21 HAVE_LANGINFO_YESEXPR=0 22 HAVE_LANGINFO_YESEXPR=0
22 AC_CHECK_HEADERS_ONCE([langinfo.h]) 23 AC_CHECK_HEADERS_ONCE([langinfo.h])
23 if test $ac_cv_header_langinfo_h = yes; then 24 if test $ac_cv_header_langinfo_h = yes; then
24 HAVE_LANGINFO_H=1 25 HAVE_LANGINFO_H=1
25 dnl Determine what <langinfo.h> defines. CODESET and ERA etc. are missing 26 dnl Determine what <langinfo.h> defines.
26 dnl on OpenBSD 3.8. T_FMT_AMPM and YESEXPR, NOEXPR are missing on IRIX 5.3. 27 dnl CODESET is missing on OpenBSD 3.8.
28 dnl ERA etc. are missing on OpenBSD 6.7.
29 dnl T_FMT_AMPM and YESEXPR, NOEXPR are missing on IRIX 5.3.
30 dnl ALTMON_* are missing on glibc 2.26 and many other systems.
27 AC_CACHE_CHECK([whether langinfo.h defines CODESET], 31 AC_CACHE_CHECK([whether langinfo.h defines CODESET],
28 [gl_cv_header_langinfo_codeset], 32 [gl_cv_header_langinfo_codeset],
29 [AC_COMPILE_IFELSE( 33 [AC_COMPILE_IFELSE(
@@ -48,6 +52,18 @@ int a = T_FMT_AMPM;
48 if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then 52 if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then
49 HAVE_LANGINFO_T_FMT_AMPM=1 53 HAVE_LANGINFO_T_FMT_AMPM=1
50 fi 54 fi
55 AC_CACHE_CHECK([whether langinfo.h defines ALTMON_1],
56 [gl_cv_header_langinfo_altmon],
57 [AC_COMPILE_IFELSE(
58 [AC_LANG_PROGRAM([[#include <langinfo.h>
59int a = ALTMON_1;
60]])],
61 [gl_cv_header_langinfo_altmon=yes],
62 [gl_cv_header_langinfo_altmon=no])
63 ])
64 if test $gl_cv_header_langinfo_altmon = yes; then
65 HAVE_LANGINFO_ALTMON=1
66 fi
51 AC_CACHE_CHECK([whether langinfo.h defines ERA], 67 AC_CACHE_CHECK([whether langinfo.h defines ERA],
52 [gl_cv_header_langinfo_era], 68 [gl_cv_header_langinfo_era],
53 [AC_COMPILE_IFELSE( 69 [AC_COMPILE_IFELSE(
@@ -78,6 +94,7 @@ int a = YESEXPR;
78 AC_SUBST([HAVE_LANGINFO_H]) 94 AC_SUBST([HAVE_LANGINFO_H])
79 AC_SUBST([HAVE_LANGINFO_CODESET]) 95 AC_SUBST([HAVE_LANGINFO_CODESET])
80 AC_SUBST([HAVE_LANGINFO_T_FMT_AMPM]) 96 AC_SUBST([HAVE_LANGINFO_T_FMT_AMPM])
97 AC_SUBST([HAVE_LANGINFO_ALTMON])
81 AC_SUBST([HAVE_LANGINFO_ERA]) 98 AC_SUBST([HAVE_LANGINFO_ERA])
82 AC_SUBST([HAVE_LANGINFO_YESEXPR]) 99 AC_SUBST([HAVE_LANGINFO_YESEXPR])
83 100
@@ -87,18 +104,33 @@ int a = YESEXPR;
87 ]], [nl_langinfo]) 104 ]], [nl_langinfo])
88]) 105])
89 106
107# gl_LANGINFO_MODULE_INDICATOR([modulename])
108# sets the shell variable that indicates the presence of the given module
109# to a C preprocessor expression that will evaluate to 1.
110# This macro invocation must not occur in macros that are AC_REQUIREd.
90AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR], 111AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR],
91[ 112[
92 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 113 dnl Ensure to expand the default settings once only.
93 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) 114 gl_LANGINFO_H_REQUIRE_DEFAULTS
94 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 115 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
95 dnl Define it also as a C macro, for the benefit of the unit tests. 116 dnl Define it also as a C macro, for the benefit of the unit tests.
96 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 117 gl_MODULE_INDICATOR_FOR_TESTS([$1])
97]) 118])
98 119
120# Initializes the default values for AC_SUBSTed shell variables.
121# This macro must not be AC_REQUIREd. It must only be invoked, and only
122# outside of macros or in macros that are not AC_REQUIREd.
123AC_DEFUN([gl_LANGINFO_H_REQUIRE_DEFAULTS],
124[
125 m4_defun(GL_MODULE_INDICATOR_PREFIX[_LANGINFO_H_MODULE_INDICATOR_DEFAULTS], [
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NL_LANGINFO])
127 ])
128 m4_require(GL_MODULE_INDICATOR_PREFIX[_LANGINFO_H_MODULE_INDICATOR_DEFAULTS])
129 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
130])
131
99AC_DEFUN([gl_LANGINFO_H_DEFAULTS], 132AC_DEFUN([gl_LANGINFO_H_DEFAULTS],
100[ 133[
101 GNULIB_NL_LANGINFO=0; AC_SUBST([GNULIB_NL_LANGINFO])
102 dnl Assume proper GNU behavior unless another module says otherwise. 134 dnl Assume proper GNU behavior unless another module says otherwise.
103 HAVE_NL_LANGINFO=1; AC_SUBST([HAVE_NL_LANGINFO]) 135 HAVE_NL_LANGINFO=1; AC_SUBST([HAVE_NL_LANGINFO])
104 REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO]) 136 REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO])
diff --git a/gl/m4/largefile.m4 b/gl/m4/largefile.m4
index 1e605e3d..7fb81b86 100644
--- a/gl/m4/largefile.m4
+++ b/gl/m4/largefile.m4
@@ -1,104 +1,319 @@
1# Enable large files on systems where this is not the default. 1# Enable large files on systems where this is not the default.
2# Enable support for files on Linux file systems with 64-bit inode numbers.
2 3
3# Copyright 1992-1996, 1998-2013 Free Software Foundation, Inc. 4# Copyright 1992-1996, 1998-2023 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved. 7# with or without modifications, as long as this notice is preserved.
7 8
8# The following implementation works around a problem in autoconf <= 2.69; 9# The following macro works around a problem in Autoconf's AC_FUNC_FSEEKO:
10# It does not set _LARGEFILE_SOURCE=1 on HP-UX/ia64 32-bit, although this
11# setting of _LARGEFILE_SOURCE is needed so that <stdio.h> declares fseeko
12# and ftello in C++ mode as well.
13# Fixed in Autoconf 2.72, which has AC_SYS_YEAR2038.
14AC_DEFUN([gl_SET_LARGEFILE_SOURCE],
15 m4_ifndef([AC_SYS_YEAR2038], [[
16 AC_REQUIRE([AC_CANONICAL_HOST])
17 AC_FUNC_FSEEKO
18 case "$host_os" in
19 hpux*)
20 AC_DEFINE([_LARGEFILE_SOURCE], [1],
21 [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).])
22 ;;
23 esac
24 ]])
25)
26
27# Work around a problem in autoconf <= 2.69:
9# AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5, 28# AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5,
10# or configures them incorrectly in some cases. 29# or configures them incorrectly in some cases.
11m4_version_prereq([2.70], [] ,[ 30m4_version_prereq([2.70], [], [
12 31
13# _AC_SYS_LARGEFILE_TEST_INCLUDES 32# _AC_SYS_LARGEFILE_TEST_INCLUDES
14# ------------------------------- 33# -------------------------------
15m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], 34m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES],
16[@%:@include <sys/types.h> 35[#include <sys/types.h>
17 /* Check that off_t can represent 2**63 - 1 correctly. 36 /* Check that off_t can represent 2**63 - 1 correctly.
18 We can't simply define LARGE_OFF_T to be 9223372036854775807, 37 We can't simply define LARGE_OFF_T to be 9223372036854775807,
19 since some C++ compilers masquerading as C compilers 38 since some C++ compilers masquerading as C compilers
20 incorrectly reject 9223372036854775807. */ 39 incorrectly reject 9223372036854775807. */
21@%:@define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) 40#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31))
22 int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721 41 int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
23 && LARGE_OFF_T % 2147483647 == 1) 42 && LARGE_OFF_T % 2147483647 == 1)
24 ? 1 : -1]];[]dnl 43 ? 1 : -1]];[]dnl
25]) 44])
45])# m4_version_prereq 2.70
46
47# Support AC_SYS_YEAR2038, even if Autoconf 2.71 or earlier.
48# This code is taken from Autoconf master.
49m4_ifndef([AC_SYS_YEAR2038], [
50
51# _AC_SYS_YEAR2038_TEST_CODE
52# --------------------------
53# C code used to probe for time_t that can represent time points more
54# than 2**31 - 1 seconds after the epoch. With the usual Unix epoch,
55# these correspond to dates after 2038-01-18 22:14:07 +0000 (Gregorian),
56# hence the name.
57AC_DEFUN([_AC_SYS_YEAR2038_TEST_CODE],
58[[
59 #include <time.h>
60 /* Check that time_t can represent 2**32 - 1 correctly. */
61 #define LARGE_TIME_T \\
62 ((time_t) (((time_t) 1 << 30) - 1 + 3 * ((time_t) 1 << 30)))
63 int verify_time_t_range[(LARGE_TIME_T / 65537 == 65535
64 && LARGE_TIME_T % 65537 == 0)
65 ? 1 : -1];
66]])
67
68# _AC_SYS_YEAR2038_OPTIONS
69# ------------------------
70# List of known ways to enable support for large time_t. If you change
71# this list you probably also need to change the AS_CASE at the end of
72# _AC_SYS_YEAR2038_PROBE.
73m4_define([_AC_SYS_YEAR2038_OPTIONS], m4_normalize(
74 ["none needed"] dnl 64-bit and newer 32-bit Unix
75 ["-D_TIME_BITS=64"] dnl glibc 2.34 with some 32-bit ABIs
76 ["-D__MINGW_USE_VC2005_COMPAT"] dnl 32-bit MinGW
77 ["-U_USE_32_BIT_TIME_T -D__MINGW_USE_VC2005_COMPAT"]
78 dnl 32-bit MinGW (misconfiguration)
79))
80
81# _AC_SYS_YEAR2038_PROBE([IF-NOT-DETECTED])
82# -----------------------------------------
83# Subroutine of AC_SYS_YEAR2038. Probe for time_t that can represent
84# time points more than 2**31 - 1 seconds after the epoch (dates after
85# 2038-01-18, see above) and set the cache variable ac_cv_sys_year2038_opts
86# to one of the values in the _AC_SYS_YEAR2038_OPTIONS list, or to
87# "support not detected" if none of them worked. Then, set compilation
88# options and #defines as necessary to enable large time_t support.
89#
90# Note that we do not test whether mktime, localtime, etc. handle
91# large values of time_t correctly, as that would require use of
92# AC_TRY_RUN. Note also that some systems only support large time_t
93# together with large off_t.
94#
95# If support is not detected, the behavior depends on which of the
96# top-level AC_SYS_YEAR2038 macros was used (see below).
97#
98# If you change this macro you may also need to change
99# _AC_SYS_YEAR2038_OPTIONS.
100AC_DEFUN([_AC_SYS_YEAR2038_PROBE],
101[AC_CACHE_CHECK([for $CC option to enable timestamps after Jan 2038],
102 [ac_cv_sys_year2038_opts],
103 [ac_save_CPPFLAGS="$CPPFLAGS"
104 ac_opt_found=no
105 for ac_opt in _AC_SYS_YEAR2038_OPTIONS; do
106 AS_IF([test x"$ac_opt" != x"none needed"],
107 [CPPFLAGS="$ac_save_CPPFLAGS $ac_opt"])
108 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_YEAR2038_TEST_CODE])],
109 [ac_cv_sys_year2038_opts="$ac_opt"
110 ac_opt_found=yes])
111 test $ac_opt_found = no || break
112 done
113 CPPFLAGS="$ac_save_CPPFLAGS"
114 test $ac_opt_found = yes || ac_cv_sys_year2038_opts="support not detected"])
115
116ac_have_year2038=yes
117AS_CASE([$ac_cv_sys_year2038_opts],
118 ["none needed"], [],
119 ["support not detected"],
120 [ac_have_year2038=no
121 AS_CASE([$enable_year2038],
122 [yes],
123 [# If we're not cross compiling and 'touch' works with a large
124 # timestamp, then we can presume the system supports wider time_t
125 # *somehow* and we just weren't able to detect it. One common
126 # case that we deliberately *don't* probe for is a system that
127 # supports both 32- and 64-bit ABIs but only the 64-bit ABI offers
128 # wide time_t. (It would be inappropriate for us to override an
129 # intentional use of -m32.) Error out, demanding use of
130 # --disable-year2038 if this is intentional.
131 AS_IF([test $cross_compiling = no],
132 [AS_IF([TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null],
133 [AS_CASE([`TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null`],
134 [*'Feb 7 2106'* | *'Feb 7 17:10'*],
135 [AC_MSG_FAILURE(m4_text_wrap(
136 [this system appears to support timestamps after January 2038,
137 but no mechanism for enabling wide 'time_t' was detected.
138 Did you mean to build a 64-bit binary? (e.g. 'CC="${CC} -m64"'.)
139 To proceed with 32-bit time_t, configure with '--disable-year2038'.],
140 [], [], [55]))])])])])],
141
142 ["-D_TIME_BITS=64"],
143 [AC_DEFINE([_TIME_BITS], [64],
144 [Number of bits in time_t, on hosts where this is settable.])],
145
146 ["-D__MINGW_USE_VC2005_COMPAT=1"],
147 [AC_DEFINE([__MINGW_USE_VC2005_COMPAT], [1],
148 [Define to 1 on platforms where this makes time_t a 64-bit type.])],
149
150 ["-U_USE_32_BIT_TIME_T"*],
151 [AC_MSG_FAILURE(m4_text_wrap(
152 [the 'time_t' type is currently forced to be 32-bit.
153 It will stop working after January 2038.
154 Remove _USE_32BIT_TIME_T from the compiler flags.],
155 [], [], [55]))],
156
157 [AC_MSG_ERROR(
158 [internal error: bad value for \$ac_cv_sys_year2038_opts])])
159])
160
161# _AC_SYS_YEAR2038_ENABLE
162# -----------------------
163# Subroutine of AC_SYS_YEAR2038 and _AC_SYS_YEAR2038_OPT_IN.
164# Depending on which of the YEAR2038 macros was used, add either an
165# --enable-year2038, or a --disable-year2038, or no option at all to
166# the configure script. Note that this is expanded very late and
167# therefore there cannot be any code in the AC_ARG_ENABLE. The
168# default value for enable_year2038 is emitted unconditionally
169# because the generated code always looks at this variable.
170m4_define([_AC_SYS_YEAR2038_ENABLE],
171[m4_divert_text([DEFAULTS],
172 m4_provide_if([AC_SYS_YEAR2038],
173 [enable_year2038=yes],
174 [enable_year2038=no]))]dnl
175[AC_ARG_ENABLE([year2038],
176 m4_provide_if([AC_SYS_YEAR2038],
177 [AS_HELP_STRING([--disable-year2038],
178 [do not support timestamps after 2038])],
179 [AS_HELP_STRING([--enable-year2038],
180 [support timestamps after 2038])]))])
181
182# _AC_SYS_YEAR2038_OPT_IN
183# -----------------------
184# If the --enable-year2038 option is given to configure, attempt to
185# detect and activate support for large time_t on 32-bit systems.
186# This macro is automatically invoked by AC_SYS_LARGEFILE when large
187# *file* support is detected. It does not AC_REQUIRE AC_SYS_LARGEFILE
188# to avoid a dependency loop, and is therefore unsafe to expose as a
189# documented macro.
190AC_DEFUN([_AC_SYS_YEAR2038_OPT_IN],
191[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl
192 AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE])
193 AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])
194])])
195
196# AC_SYS_YEAR2038
197# ---------------
198# Attempt to detect and activate support for large time_t.
199# On systems where time_t is not always 64 bits, this probe can be
200# skipped by passing the --disable-year2038 option to configure.
201AC_DEFUN([AC_SYS_YEAR2038],
202[AC_REQUIRE([AC_SYS_LARGEFILE])]dnl
203[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl
204 AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE])
205 AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])
206])])
207
208# _AC_SYS_LARGEFILE_TEST_CODE
209# ---------------------------
210# C code used to probe for large file support.
211m4_define([_AC_SYS_LARGEFILE_TEST_CODE],
212[@%:@include <sys/types.h>
213 /* Check that off_t can represent 2**63 - 1 correctly.
214 We can't simply define LARGE_OFF_T to be 9223372036854775807,
215 since some C++ compilers masquerading as C compilers
216 incorrectly reject 9223372036854775807. */
217@%:@define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31))
218 int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
219 && LARGE_OFF_T % 2147483647 == 1)
220 ? 1 : -1]];[]dnl
221])
222
223# _AC_SYS_LARGEFILE_OPTIONS
224# -------------------------
225# List of known ways to enable support for large files. If you change
226# this list you probably also need to change the AS_CASE at the end of
227# _AC_SYS_LARGEFILE_PROBE.
228m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize(
229 ["none needed"] dnl Most current systems
230 ["-D_FILE_OFFSET_BITS=64"] dnl X/Open LFS spec
231 ["-D_LARGE_FILES=1"] dnl AIX (which versions?)
232 ["-n32"] dnl Irix 6.2 w/ SGI compiler
233))
234
235# _AC_SYS_LARGEFILE_PROBE
236# -----------------------
237# Subroutine of AC_SYS_LARGEFILE. Probe for large file support and set
238# the cache variable ac_cv_sys_largefile_opts to one of the values in
239# the _AC_SYS_LARGEFILE_OPTIONS list, or to "support not detected" if
240# none of the options in that list worked. Then, set compilation
241# options and #defines as necessary to enable large file support.
242#
243# If large file support is not detected, the behavior depends on which of
244# the top-level AC_SYS_LARGEFILE macros was used (see below).
245#
246# If you change this macro you may also need to change
247# _AC_SYS_LARGEFILE_OPTIONS.
248AC_DEFUN([_AC_SYS_LARGEFILE_PROBE],
249[AC_CACHE_CHECK([for $CC option to enable large file support],
250 [ac_cv_sys_largefile_opts],
251 [ac_save_CC="$CC"
252 ac_opt_found=no
253 for ac_opt in _AC_SYS_LARGEFILE_OPTIONS; do
254 AS_IF([test x"$ac_opt" != x"none needed"],
255 [CC="$ac_save_CC $ac_opt"])
256 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_CODE])],
257 [ac_cv_sys_largefile_opts="$ac_opt"
258 ac_opt_found=yes])
259 test $ac_opt_found = no || break
260 done
261 CC="$ac_save_CC"
262 test $ac_opt_found = yes || ac_cv_sys_largefile_opts="support not detected"])
263
264ac_have_largefile=yes
265AS_CASE([$ac_cv_sys_largefile_opts],
266 ["none needed"], [],
267 ["support not detected"],
268 [ac_have_largefile=no],
269
270 ["-D_FILE_OFFSET_BITS=64"],
271 [AC_DEFINE([_FILE_OFFSET_BITS], [64],
272 [Number of bits in a file offset, on hosts where this is settable.])],
273
274 ["-D_LARGE_FILES=1"],
275 [AC_DEFINE([_LARGE_FILES], [1],
276 [Define to 1 on platforms where this makes off_t a 64-bit type.])],
26 277
278 ["-n32"],
279 [CC="$CC -n32"],
27 280
28# _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, 281 [AC_MSG_ERROR(
29# CACHE-VAR, 282 [internal error: bad value for \$ac_cv_sys_largefile_opts])])
30# DESCRIPTION,
31# PROLOGUE, [FUNCTION-BODY])
32# --------------------------------------------------------
33m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE],
34[AC_CACHE_CHECK([for $1 value needed for large files], [$3],
35[while :; do
36 m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
37 [AC_LANG_PROGRAM([$5], [$6])],
38 [$3=no; break])
39 m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
40 [AC_LANG_PROGRAM([@%:@define $1 $2
41$5], [$6])],
42 [$3=$2; break])
43 $3=unknown
44 break
45done])
46case $$3 in #(
47 no | unknown) ;;
48 *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);;
49esac
50rm -rf conftest*[]dnl
51])# _AC_SYS_LARGEFILE_MACRO_VALUE
52 283
284_AC_SYS_YEAR2038_OPT_IN
285])
286
287# _AC_SYS_LARGEFILE_ENABLE
288# ------------------------
289# Subroutine of AC_SYS_LARGEFILE. Note that this
290# is expanded very late and therefore there cannot be any code in the
291# AC_ARG_ENABLE. The default value for enable_largefile is emitted
292# unconditionally because the generated shell code always looks at
293# this variable.
294m4_define([_AC_SYS_LARGEFILE_ENABLE],
295[m4_divert_text([DEFAULTS],
296 enable_largefile=yes)]dnl
297[AC_ARG_ENABLE([largefile],
298 [AS_HELP_STRING([--disable-largefile], [omit support for large files])])])
53 299
54# AC_SYS_LARGEFILE 300# AC_SYS_LARGEFILE
55# ---------------- 301# ----------------
56# By default, many hosts won't let programs access large files; 302# By default, many hosts won't let programs access large files;
57# one must use special compiler options to get large-file access to work. 303# one must use special compiler options to get large-file access to work.
58# For more details about this brain damage please see: 304# For more details about this brain damage please see:
59# http://www.unix-systems.org/version2/whatsnew/lfs20mar.html 305# http://www.unix.org/version2/whatsnew/lfs20mar.html
306# Additionally, on Linux file systems with 64-bit inodes a file that happens
307# to have a 64-bit inode number cannot be accessed by 32-bit applications on
308# Linux x86/x86_64. This can occur with file systems such as XFS and NFS.
309# This macro allows configuration to continue if the system doesn't support
310# large files.
60AC_DEFUN([AC_SYS_LARGEFILE], 311AC_DEFUN([AC_SYS_LARGEFILE],
61[AC_ARG_ENABLE(largefile, 312[m4_provide_if([_AC_SYS_LARGEFILE_PROBE], [], [dnl
62 [ --disable-largefile omit support for large files]) 313 AS_IF([test "$enable_largefile" != no], [_AC_SYS_LARGEFILE_PROBE])
63if test "$enable_largefile" != no; then 314 AC_CONFIG_COMMANDS_PRE([_AC_SYS_LARGEFILE_ENABLE])
64 315])])
65 AC_CACHE_CHECK([for special C compiler options needed for large files], 316])# m4_ifndef AC_SYS_YEAR2038
66 ac_cv_sys_largefile_CC,
67 [ac_cv_sys_largefile_CC=no
68 if test "$GCC" != yes; then
69 ac_save_CC=$CC
70 while :; do
71 # IRIX 6.2 and later do not support large files by default,
72 # so use the C compiler's -n32 option if that helps.
73 AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])])
74 AC_COMPILE_IFELSE([], [break])
75 CC="$CC -n32"
76 AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break])
77 break
78 done
79 CC=$ac_save_CC
80 rm -f conftest.$ac_ext
81 fi])
82 if test "$ac_cv_sys_largefile_CC" != no; then
83 CC=$CC$ac_cv_sys_largefile_CC
84 fi
85
86 _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
87 ac_cv_sys_file_offset_bits,
88 [Number of bits in a file offset, on hosts where this is settable.],
89 [_AC_SYS_LARGEFILE_TEST_INCLUDES])
90 if test $ac_cv_sys_file_offset_bits = unknown; then
91 _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
92 ac_cv_sys_large_files,
93 [Define for large files, on AIX-style hosts.],
94 [_AC_SYS_LARGEFILE_TEST_INCLUDES])
95 fi
96
97 AC_DEFINE([_DARWIN_USE_64_BIT_INODE], [1],
98 [Enable large inode numbers on Mac OS X 10.5.])
99fi
100])# AC_SYS_LARGEFILE
101])# m4_version_prereq 2.70
102 317
103# Enable large files on systems where this is implemented by Gnulib, not by the 318# Enable large files on systems where this is implemented by Gnulib, not by the
104# system headers. 319# system headers.
@@ -126,9 +341,24 @@ AC_DEFUN([gl_LARGEFILE],
126 else 341 else
127 WINDOWS_64_BIT_OFF_T=0 342 WINDOWS_64_BIT_OFF_T=0
128 fi 343 fi
129 dnl But all native Windows platforms (including mingw64) have a 32-bit 344 dnl Some mingw versions define, if _FILE_OFFSET_BITS=64, 'struct stat'
130 dnl st_size member in 'struct stat'. 345 dnl to 'struct _stat32i64' or 'struct _stat64' (depending on
131 WINDOWS_64_BIT_ST_SIZE=1 346 dnl _USE_32BIT_TIME_T), which has a 32-bit st_size member.
347 AC_CACHE_CHECK([for 64-bit st_size], [gl_cv_member_st_size_64],
348 [AC_COMPILE_IFELSE(
349 [AC_LANG_PROGRAM(
350 [[#include <sys/types.h>
351 struct stat buf;
352 int verify_st_size_size[sizeof (buf.st_size) >= 8 ? 1 : -1];
353 ]],
354 [[]])],
355 [gl_cv_member_st_size_64=yes], [gl_cv_member_st_size_64=no])
356 ])
357 if test $gl_cv_member_st_size_64 = no; then
358 WINDOWS_64_BIT_ST_SIZE=1
359 else
360 WINDOWS_64_BIT_ST_SIZE=0
361 fi
132 ;; 362 ;;
133 *) 363 *)
134 dnl Nothing to do on gnulib's side. 364 dnl Nothing to do on gnulib's side.
diff --git a/gl/m4/lcmessage.m4 b/gl/m4/lcmessage.m4
deleted file mode 100644
index d62a175f..00000000
--- a/gl/m4/lcmessage.m4
+++ /dev/null
@@ -1,35 +0,0 @@
1# lcmessage.m4 serial 7 (gettext-0.18.2)
2dnl Copyright (C) 1995-2002, 2004-2005, 2008-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl
8dnl This file can can be used in projects which are not available under
9dnl the GNU General Public License or the GNU Library General Public
10dnl License but which still want to provide support for the GNU gettext
11dnl functionality.
12dnl Please note that the actual code of the GNU gettext library is covered
13dnl by the GNU Library General Public License, and the rest of the GNU
14dnl gettext package package is covered by the GNU General Public License.
15dnl They are *not* in the public domain.
16
17dnl Authors:
18dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
19
20# Check whether LC_MESSAGES is available in <locale.h>.
21
22AC_DEFUN([gt_LC_MESSAGES],
23[
24 AC_CACHE_CHECK([for LC_MESSAGES], [gt_cv_val_LC_MESSAGES],
25 [AC_LINK_IFELSE(
26 [AC_LANG_PROGRAM(
27 [[#include <locale.h>]],
28 [[return LC_MESSAGES]])],
29 [gt_cv_val_LC_MESSAGES=yes],
30 [gt_cv_val_LC_MESSAGES=no])])
31 if test $gt_cv_val_LC_MESSAGES = yes; then
32 AC_DEFINE([HAVE_LC_MESSAGES], [1],
33 [Define if your <locale.h> file defines LC_MESSAGES.])
34 fi
35])
diff --git a/gl/m4/lib-ld.m4 b/gl/m4/lib-ld.m4
deleted file mode 100644
index c145e478..00000000
--- a/gl/m4/lib-ld.m4
+++ /dev/null
@@ -1,119 +0,0 @@
1# lib-ld.m4 serial 6
2dnl Copyright (C) 1996-2003, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Subroutines of libtool.m4,
8dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
9dnl collision with libtool.m4.
10
11dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
12AC_DEFUN([AC_LIB_PROG_LD_GNU],
13[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
14[# I'd rather use --version here, but apparently some GNU lds only accept -v.
15case `$LD -v 2>&1 </dev/null` in
16*GNU* | *'with BFD'*)
17 acl_cv_prog_gnu_ld=yes
18 ;;
19*)
20 acl_cv_prog_gnu_ld=no
21 ;;
22esac])
23with_gnu_ld=$acl_cv_prog_gnu_ld
24])
25
26dnl From libtool-2.4. Sets the variable LD.
27AC_DEFUN([AC_LIB_PROG_LD],
28[AC_REQUIRE([AC_PROG_CC])dnl
29AC_REQUIRE([AC_CANONICAL_HOST])dnl
30
31AC_ARG_WITH([gnu-ld],
32 [AS_HELP_STRING([--with-gnu-ld],
33 [assume the C compiler uses GNU ld [default=no]])],
34 [test "$withval" = no || with_gnu_ld=yes],
35 [with_gnu_ld=no])dnl
36
37# Prepare PATH_SEPARATOR.
38# The user is always right.
39if test "${PATH_SEPARATOR+set}" != set; then
40 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
41 # contains only /bin. Note that ksh looks also at the FPATH variable,
42 # so we have to set that as well for the test.
43 PATH_SEPARATOR=:
44 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
45 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
46 || PATH_SEPARATOR=';'
47 }
48fi
49
50ac_prog=ld
51if test "$GCC" = yes; then
52 # Check if gcc -print-prog-name=ld gives a path.
53 AC_MSG_CHECKING([for ld used by $CC])
54 case $host in
55 *-*-mingw*)
56 # gcc leaves a trailing carriage return which upsets mingw
57 ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
58 *)
59 ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
60 esac
61 case $ac_prog in
62 # Accept absolute paths.
63 [[\\/]]* | ?:[[\\/]]*)
64 re_direlt='/[[^/]][[^/]]*/\.\./'
65 # Canonicalize the pathname of ld
66 ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'`
67 while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do
68 ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
69 done
70 test -z "$LD" && LD="$ac_prog"
71 ;;
72 "")
73 # If it fails, then pretend we aren't using GCC.
74 ac_prog=ld
75 ;;
76 *)
77 # If it is relative, then search for the first ld in PATH.
78 with_gnu_ld=unknown
79 ;;
80 esac
81elif test "$with_gnu_ld" = yes; then
82 AC_MSG_CHECKING([for GNU ld])
83else
84 AC_MSG_CHECKING([for non-GNU ld])
85fi
86AC_CACHE_VAL([acl_cv_path_LD],
87[if test -z "$LD"; then
88 acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
89 for ac_dir in $PATH; do
90 IFS="$acl_save_ifs"
91 test -z "$ac_dir" && ac_dir=.
92 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
93 acl_cv_path_LD="$ac_dir/$ac_prog"
94 # Check to see if the program is GNU ld. I'd rather use --version,
95 # but apparently some variants of GNU ld only accept -v.
96 # Break only if it was the GNU/non-GNU ld that we prefer.
97 case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
98 *GNU* | *'with BFD'*)
99 test "$with_gnu_ld" != no && break
100 ;;
101 *)
102 test "$with_gnu_ld" != yes && break
103 ;;
104 esac
105 fi
106 done
107 IFS="$acl_save_ifs"
108else
109 acl_cv_path_LD="$LD" # Let the user override the test with a path.
110fi])
111LD="$acl_cv_path_LD"
112if test -n "$LD"; then
113 AC_MSG_RESULT([$LD])
114else
115 AC_MSG_RESULT([no])
116fi
117test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
118AC_LIB_PROG_LD_GNU
119])
diff --git a/gl/m4/lib-link.m4 b/gl/m4/lib-link.m4
deleted file mode 100644
index 073f0405..00000000
--- a/gl/m4/lib-link.m4
+++ /dev/null
@@ -1,777 +0,0 @@
1# lib-link.m4 serial 26 (gettext-0.18.2)
2dnl Copyright (C) 2001-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9AC_PREREQ([2.54])
10
11dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
12dnl the libraries corresponding to explicit and implicit dependencies.
13dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
14dnl augments the CPPFLAGS variable.
15dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
16dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
17AC_DEFUN([AC_LIB_LINKFLAGS],
18[
19 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
20 AC_REQUIRE([AC_LIB_RPATH])
21 pushdef([Name],[m4_translit([$1],[./+-], [____])])
22 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
23 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
24 AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
25 AC_LIB_LINKFLAGS_BODY([$1], [$2])
26 ac_cv_lib[]Name[]_libs="$LIB[]NAME"
27 ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
28 ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
29 ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
30 ])
31 LIB[]NAME="$ac_cv_lib[]Name[]_libs"
32 LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
33 INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
34 LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
35 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
36 AC_SUBST([LIB]NAME)
37 AC_SUBST([LTLIB]NAME)
38 AC_SUBST([LIB]NAME[_PREFIX])
39 dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
40 dnl results of this search when this library appears as a dependency.
41 HAVE_LIB[]NAME=yes
42 popdef([NAME])
43 popdef([Name])
44])
45
46dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message])
47dnl searches for libname and the libraries corresponding to explicit and
48dnl implicit dependencies, together with the specified include files and
49dnl the ability to compile and link the specified testcode. The missing-message
50dnl defaults to 'no' and may contain additional hints for the user.
51dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME}
52dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and
53dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
54dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
55dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
56dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
57AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
58[
59 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
60 AC_REQUIRE([AC_LIB_RPATH])
61 pushdef([Name],[m4_translit([$1],[./+-], [____])])
62 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
63 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
64
65 dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
66 dnl accordingly.
67 AC_LIB_LINKFLAGS_BODY([$1], [$2])
68
69 dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
70 dnl because if the user has installed lib[]Name and not disabled its use
71 dnl via --without-lib[]Name-prefix, he wants to use it.
72 ac_save_CPPFLAGS="$CPPFLAGS"
73 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
74
75 AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
76 ac_save_LIBS="$LIBS"
77 dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
78 dnl because these -l options might require -L options that are present in
79 dnl LIBS. -l options benefit only from the -L options listed before it.
80 dnl Otherwise, add it to the front of LIBS, because it may be a static
81 dnl library that depends on another static library that is present in LIBS.
82 dnl Static libraries benefit only from the static libraries listed after
83 dnl it.
84 case " $LIB[]NAME" in
85 *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
86 *) LIBS="$LIB[]NAME $LIBS" ;;
87 esac
88 AC_LINK_IFELSE(
89 [AC_LANG_PROGRAM([[$3]], [[$4]])],
90 [ac_cv_lib[]Name=yes],
91 [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
92 LIBS="$ac_save_LIBS"
93 ])
94 if test "$ac_cv_lib[]Name" = yes; then
95 HAVE_LIB[]NAME=yes
96 AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
97 AC_MSG_CHECKING([how to link with lib[]$1])
98 AC_MSG_RESULT([$LIB[]NAME])
99 else
100 HAVE_LIB[]NAME=no
101 dnl If $LIB[]NAME didn't lead to a usable library, we don't need
102 dnl $INC[]NAME either.
103 CPPFLAGS="$ac_save_CPPFLAGS"
104 LIB[]NAME=
105 LTLIB[]NAME=
106 LIB[]NAME[]_PREFIX=
107 fi
108 AC_SUBST([HAVE_LIB]NAME)
109 AC_SUBST([LIB]NAME)
110 AC_SUBST([LTLIB]NAME)
111 AC_SUBST([LIB]NAME[_PREFIX])
112 popdef([NAME])
113 popdef([Name])
114])
115
116dnl Determine the platform dependent parameters needed to use rpath:
117dnl acl_libext,
118dnl acl_shlibext,
119dnl acl_libname_spec,
120dnl acl_library_names_spec,
121dnl acl_hardcode_libdir_flag_spec,
122dnl acl_hardcode_libdir_separator,
123dnl acl_hardcode_direct,
124dnl acl_hardcode_minus_L.
125AC_DEFUN([AC_LIB_RPATH],
126[
127 dnl Tell automake >= 1.10 to complain if config.rpath is missing.
128 m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
129 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
130 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
131 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
132 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
133 AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
134 CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
135 ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
136 . ./conftest.sh
137 rm -f ./conftest.sh
138 acl_cv_rpath=done
139 ])
140 wl="$acl_cv_wl"
141 acl_libext="$acl_cv_libext"
142 acl_shlibext="$acl_cv_shlibext"
143 acl_libname_spec="$acl_cv_libname_spec"
144 acl_library_names_spec="$acl_cv_library_names_spec"
145 acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
146 acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
147 acl_hardcode_direct="$acl_cv_hardcode_direct"
148 acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
149 dnl Determine whether the user wants rpath handling at all.
150 AC_ARG_ENABLE([rpath],
151 [ --disable-rpath do not hardcode runtime library paths],
152 :, enable_rpath=yes)
153])
154
155dnl AC_LIB_FROMPACKAGE(name, package)
156dnl declares that libname comes from the given package. The configure file
157dnl will then not have a --with-libname-prefix option but a
158dnl --with-package-prefix option. Several libraries can come from the same
159dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
160dnl macro call that searches for libname.
161AC_DEFUN([AC_LIB_FROMPACKAGE],
162[
163 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
164 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
165 define([acl_frompackage_]NAME, [$2])
166 popdef([NAME])
167 pushdef([PACK],[$2])
168 pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
169 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
170 define([acl_libsinpackage_]PACKUP,
171 m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1])
172 popdef([PACKUP])
173 popdef([PACK])
174])
175
176dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
177dnl the libraries corresponding to explicit and implicit dependencies.
178dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
179dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
180dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
181AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
182[
183 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
184 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
185 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
186 pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
187 pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
188 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
189 pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
190 dnl Autoconf >= 2.61 supports dots in --with options.
191 pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)])
192 dnl By default, look in $includedir and $libdir.
193 use_additional=yes
194 AC_LIB_WITH_FINAL_PREFIX([
195 eval additional_includedir=\"$includedir\"
196 eval additional_libdir=\"$libdir\"
197 ])
198 AC_ARG_WITH(P_A_C_K[-prefix],
199[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
200 --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
201[
202 if test "X$withval" = "Xno"; then
203 use_additional=no
204 else
205 if test "X$withval" = "X"; then
206 AC_LIB_WITH_FINAL_PREFIX([
207 eval additional_includedir=\"$includedir\"
208 eval additional_libdir=\"$libdir\"
209 ])
210 else
211 additional_includedir="$withval/include"
212 additional_libdir="$withval/$acl_libdirstem"
213 if test "$acl_libdirstem2" != "$acl_libdirstem" \
214 && ! test -d "$withval/$acl_libdirstem"; then
215 additional_libdir="$withval/$acl_libdirstem2"
216 fi
217 fi
218 fi
219])
220 dnl Search the library and its dependencies in $additional_libdir and
221 dnl $LDFLAGS. Using breadth-first-seach.
222 LIB[]NAME=
223 LTLIB[]NAME=
224 INC[]NAME=
225 LIB[]NAME[]_PREFIX=
226 dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
227 dnl computed. So it has to be reset here.
228 HAVE_LIB[]NAME=
229 rpathdirs=
230 ltrpathdirs=
231 names_already_handled=
232 names_next_round='$1 $2'
233 while test -n "$names_next_round"; do
234 names_this_round="$names_next_round"
235 names_next_round=
236 for name in $names_this_round; do
237 already_handled=
238 for n in $names_already_handled; do
239 if test "$n" = "$name"; then
240 already_handled=yes
241 break
242 fi
243 done
244 if test -z "$already_handled"; then
245 names_already_handled="$names_already_handled $name"
246 dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
247 dnl or AC_LIB_HAVE_LINKFLAGS call.
248 uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
249 eval value=\"\$HAVE_LIB$uppername\"
250 if test -n "$value"; then
251 if test "$value" = yes; then
252 eval value=\"\$LIB$uppername\"
253 test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
254 eval value=\"\$LTLIB$uppername\"
255 test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
256 else
257 dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
258 dnl that this library doesn't exist. So just drop it.
259 :
260 fi
261 else
262 dnl Search the library lib$name in $additional_libdir and $LDFLAGS
263 dnl and the already constructed $LIBNAME/$LTLIBNAME.
264 found_dir=
265 found_la=
266 found_so=
267 found_a=
268 eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
269 if test -n "$acl_shlibext"; then
270 shrext=".$acl_shlibext" # typically: shrext=.so
271 else
272 shrext=
273 fi
274 if test $use_additional = yes; then
275 dir="$additional_libdir"
276 dnl The same code as in the loop below:
277 dnl First look for a shared library.
278 if test -n "$acl_shlibext"; then
279 if test -f "$dir/$libname$shrext"; then
280 found_dir="$dir"
281 found_so="$dir/$libname$shrext"
282 else
283 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
284 ver=`(cd "$dir" && \
285 for f in "$libname$shrext".*; do echo "$f"; done \
286 | sed -e "s,^$libname$shrext\\\\.,," \
287 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
288 | sed 1q ) 2>/dev/null`
289 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
290 found_dir="$dir"
291 found_so="$dir/$libname$shrext.$ver"
292 fi
293 else
294 eval library_names=\"$acl_library_names_spec\"
295 for f in $library_names; do
296 if test -f "$dir/$f"; then
297 found_dir="$dir"
298 found_so="$dir/$f"
299 break
300 fi
301 done
302 fi
303 fi
304 fi
305 dnl Then look for a static library.
306 if test "X$found_dir" = "X"; then
307 if test -f "$dir/$libname.$acl_libext"; then
308 found_dir="$dir"
309 found_a="$dir/$libname.$acl_libext"
310 fi
311 fi
312 if test "X$found_dir" != "X"; then
313 if test -f "$dir/$libname.la"; then
314 found_la="$dir/$libname.la"
315 fi
316 fi
317 fi
318 if test "X$found_dir" = "X"; then
319 for x in $LDFLAGS $LTLIB[]NAME; do
320 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
321 case "$x" in
322 -L*)
323 dir=`echo "X$x" | sed -e 's/^X-L//'`
324 dnl First look for a shared library.
325 if test -n "$acl_shlibext"; then
326 if test -f "$dir/$libname$shrext"; then
327 found_dir="$dir"
328 found_so="$dir/$libname$shrext"
329 else
330 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
331 ver=`(cd "$dir" && \
332 for f in "$libname$shrext".*; do echo "$f"; done \
333 | sed -e "s,^$libname$shrext\\\\.,," \
334 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
335 | sed 1q ) 2>/dev/null`
336 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
337 found_dir="$dir"
338 found_so="$dir/$libname$shrext.$ver"
339 fi
340 else
341 eval library_names=\"$acl_library_names_spec\"
342 for f in $library_names; do
343 if test -f "$dir/$f"; then
344 found_dir="$dir"
345 found_so="$dir/$f"
346 break
347 fi
348 done
349 fi
350 fi
351 fi
352 dnl Then look for a static library.
353 if test "X$found_dir" = "X"; then
354 if test -f "$dir/$libname.$acl_libext"; then
355 found_dir="$dir"
356 found_a="$dir/$libname.$acl_libext"
357 fi
358 fi
359 if test "X$found_dir" != "X"; then
360 if test -f "$dir/$libname.la"; then
361 found_la="$dir/$libname.la"
362 fi
363 fi
364 ;;
365 esac
366 if test "X$found_dir" != "X"; then
367 break
368 fi
369 done
370 fi
371 if test "X$found_dir" != "X"; then
372 dnl Found the library.
373 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
374 if test "X$found_so" != "X"; then
375 dnl Linking with a shared library. We attempt to hardcode its
376 dnl directory into the executable's runpath, unless it's the
377 dnl standard /usr/lib.
378 if test "$enable_rpath" = no \
379 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
380 || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
381 dnl No hardcoding is needed.
382 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
383 else
384 dnl Use an explicit option to hardcode DIR into the resulting
385 dnl binary.
386 dnl Potentially add DIR to ltrpathdirs.
387 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
388 haveit=
389 for x in $ltrpathdirs; do
390 if test "X$x" = "X$found_dir"; then
391 haveit=yes
392 break
393 fi
394 done
395 if test -z "$haveit"; then
396 ltrpathdirs="$ltrpathdirs $found_dir"
397 fi
398 dnl The hardcoding into $LIBNAME is system dependent.
399 if test "$acl_hardcode_direct" = yes; then
400 dnl Using DIR/libNAME.so during linking hardcodes DIR into the
401 dnl resulting binary.
402 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
403 else
404 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
405 dnl Use an explicit option to hardcode DIR into the resulting
406 dnl binary.
407 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
408 dnl Potentially add DIR to rpathdirs.
409 dnl The rpathdirs will be appended to $LIBNAME at the end.
410 haveit=
411 for x in $rpathdirs; do
412 if test "X$x" = "X$found_dir"; then
413 haveit=yes
414 break
415 fi
416 done
417 if test -z "$haveit"; then
418 rpathdirs="$rpathdirs $found_dir"
419 fi
420 else
421 dnl Rely on "-L$found_dir".
422 dnl But don't add it if it's already contained in the LDFLAGS
423 dnl or the already constructed $LIBNAME
424 haveit=
425 for x in $LDFLAGS $LIB[]NAME; do
426 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
427 if test "X$x" = "X-L$found_dir"; then
428 haveit=yes
429 break
430 fi
431 done
432 if test -z "$haveit"; then
433 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
434 fi
435 if test "$acl_hardcode_minus_L" != no; then
436 dnl FIXME: Not sure whether we should use
437 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
438 dnl here.
439 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
440 else
441 dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
442 dnl here, because this doesn't fit in flags passed to the
443 dnl compiler. So give up. No hardcoding. This affects only
444 dnl very old systems.
445 dnl FIXME: Not sure whether we should use
446 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
447 dnl here.
448 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
449 fi
450 fi
451 fi
452 fi
453 else
454 if test "X$found_a" != "X"; then
455 dnl Linking with a static library.
456 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
457 else
458 dnl We shouldn't come here, but anyway it's good to have a
459 dnl fallback.
460 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
461 fi
462 fi
463 dnl Assume the include files are nearby.
464 additional_includedir=
465 case "$found_dir" in
466 */$acl_libdirstem | */$acl_libdirstem/)
467 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
468 if test "$name" = '$1'; then
469 LIB[]NAME[]_PREFIX="$basedir"
470 fi
471 additional_includedir="$basedir/include"
472 ;;
473 */$acl_libdirstem2 | */$acl_libdirstem2/)
474 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
475 if test "$name" = '$1'; then
476 LIB[]NAME[]_PREFIX="$basedir"
477 fi
478 additional_includedir="$basedir/include"
479 ;;
480 esac
481 if test "X$additional_includedir" != "X"; then
482 dnl Potentially add $additional_includedir to $INCNAME.
483 dnl But don't add it
484 dnl 1. if it's the standard /usr/include,
485 dnl 2. if it's /usr/local/include and we are using GCC on Linux,
486 dnl 3. if it's already present in $CPPFLAGS or the already
487 dnl constructed $INCNAME,
488 dnl 4. if it doesn't exist as a directory.
489 if test "X$additional_includedir" != "X/usr/include"; then
490 haveit=
491 if test "X$additional_includedir" = "X/usr/local/include"; then
492 if test -n "$GCC"; then
493 case $host_os in
494 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
495 esac
496 fi
497 fi
498 if test -z "$haveit"; then
499 for x in $CPPFLAGS $INC[]NAME; do
500 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
501 if test "X$x" = "X-I$additional_includedir"; then
502 haveit=yes
503 break
504 fi
505 done
506 if test -z "$haveit"; then
507 if test -d "$additional_includedir"; then
508 dnl Really add $additional_includedir to $INCNAME.
509 INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
510 fi
511 fi
512 fi
513 fi
514 fi
515 dnl Look for dependencies.
516 if test -n "$found_la"; then
517 dnl Read the .la file. It defines the variables
518 dnl dlname, library_names, old_library, dependency_libs, current,
519 dnl age, revision, installed, dlopen, dlpreopen, libdir.
520 save_libdir="$libdir"
521 case "$found_la" in
522 */* | *\\*) . "$found_la" ;;
523 *) . "./$found_la" ;;
524 esac
525 libdir="$save_libdir"
526 dnl We use only dependency_libs.
527 for dep in $dependency_libs; do
528 case "$dep" in
529 -L*)
530 additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
531 dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
532 dnl But don't add it
533 dnl 1. if it's the standard /usr/lib,
534 dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
535 dnl 3. if it's already present in $LDFLAGS or the already
536 dnl constructed $LIBNAME,
537 dnl 4. if it doesn't exist as a directory.
538 if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
539 && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
540 haveit=
541 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
542 || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
543 if test -n "$GCC"; then
544 case $host_os in
545 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
546 esac
547 fi
548 fi
549 if test -z "$haveit"; then
550 haveit=
551 for x in $LDFLAGS $LIB[]NAME; do
552 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
553 if test "X$x" = "X-L$additional_libdir"; then
554 haveit=yes
555 break
556 fi
557 done
558 if test -z "$haveit"; then
559 if test -d "$additional_libdir"; then
560 dnl Really add $additional_libdir to $LIBNAME.
561 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
562 fi
563 fi
564 haveit=
565 for x in $LDFLAGS $LTLIB[]NAME; do
566 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
567 if test "X$x" = "X-L$additional_libdir"; then
568 haveit=yes
569 break
570 fi
571 done
572 if test -z "$haveit"; then
573 if test -d "$additional_libdir"; then
574 dnl Really add $additional_libdir to $LTLIBNAME.
575 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
576 fi
577 fi
578 fi
579 fi
580 ;;
581 -R*)
582 dir=`echo "X$dep" | sed -e 's/^X-R//'`
583 if test "$enable_rpath" != no; then
584 dnl Potentially add DIR to rpathdirs.
585 dnl The rpathdirs will be appended to $LIBNAME at the end.
586 haveit=
587 for x in $rpathdirs; do
588 if test "X$x" = "X$dir"; then
589 haveit=yes
590 break
591 fi
592 done
593 if test -z "$haveit"; then
594 rpathdirs="$rpathdirs $dir"
595 fi
596 dnl Potentially add DIR to ltrpathdirs.
597 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
598 haveit=
599 for x in $ltrpathdirs; do
600 if test "X$x" = "X$dir"; then
601 haveit=yes
602 break
603 fi
604 done
605 if test -z "$haveit"; then
606 ltrpathdirs="$ltrpathdirs $dir"
607 fi
608 fi
609 ;;
610 -l*)
611 dnl Handle this in the next round.
612 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
613 ;;
614 *.la)
615 dnl Handle this in the next round. Throw away the .la's
616 dnl directory; it is already contained in a preceding -L
617 dnl option.
618 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
619 ;;
620 *)
621 dnl Most likely an immediate library name.
622 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
623 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
624 ;;
625 esac
626 done
627 fi
628 else
629 dnl Didn't find the library; assume it is in the system directories
630 dnl known to the linker and runtime loader. (All the system
631 dnl directories known to the linker should also be known to the
632 dnl runtime loader, otherwise the system is severely misconfigured.)
633 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
634 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
635 fi
636 fi
637 fi
638 done
639 done
640 if test "X$rpathdirs" != "X"; then
641 if test -n "$acl_hardcode_libdir_separator"; then
642 dnl Weird platform: only the last -rpath option counts, the user must
643 dnl pass all path elements in one option. We can arrange that for a
644 dnl single library, but not when more than one $LIBNAMEs are used.
645 alldirs=
646 for found_dir in $rpathdirs; do
647 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
648 done
649 dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
650 acl_save_libdir="$libdir"
651 libdir="$alldirs"
652 eval flag=\"$acl_hardcode_libdir_flag_spec\"
653 libdir="$acl_save_libdir"
654 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
655 else
656 dnl The -rpath options are cumulative.
657 for found_dir in $rpathdirs; do
658 acl_save_libdir="$libdir"
659 libdir="$found_dir"
660 eval flag=\"$acl_hardcode_libdir_flag_spec\"
661 libdir="$acl_save_libdir"
662 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
663 done
664 fi
665 fi
666 if test "X$ltrpathdirs" != "X"; then
667 dnl When using libtool, the option that works for both libraries and
668 dnl executables is -R. The -R options are cumulative.
669 for found_dir in $ltrpathdirs; do
670 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
671 done
672 fi
673 popdef([P_A_C_K])
674 popdef([PACKLIBS])
675 popdef([PACKUP])
676 popdef([PACK])
677 popdef([NAME])
678])
679
680dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
681dnl unless already present in VAR.
682dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
683dnl contains two or three consecutive elements that belong together.
684AC_DEFUN([AC_LIB_APPENDTOVAR],
685[
686 for element in [$2]; do
687 haveit=
688 for x in $[$1]; do
689 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
690 if test "X$x" = "X$element"; then
691 haveit=yes
692 break
693 fi
694 done
695 if test -z "$haveit"; then
696 [$1]="${[$1]}${[$1]:+ }$element"
697 fi
698 done
699])
700
701dnl For those cases where a variable contains several -L and -l options
702dnl referring to unknown libraries and directories, this macro determines the
703dnl necessary additional linker options for the runtime path.
704dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
705dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
706dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
707dnl otherwise linking without libtool is assumed.
708AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
709[
710 AC_REQUIRE([AC_LIB_RPATH])
711 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
712 $1=
713 if test "$enable_rpath" != no; then
714 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
715 dnl Use an explicit option to hardcode directories into the resulting
716 dnl binary.
717 rpathdirs=
718 next=
719 for opt in $2; do
720 if test -n "$next"; then
721 dir="$next"
722 dnl No need to hardcode the standard /usr/lib.
723 if test "X$dir" != "X/usr/$acl_libdirstem" \
724 && test "X$dir" != "X/usr/$acl_libdirstem2"; then
725 rpathdirs="$rpathdirs $dir"
726 fi
727 next=
728 else
729 case $opt in
730 -L) next=yes ;;
731 -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
732 dnl No need to hardcode the standard /usr/lib.
733 if test "X$dir" != "X/usr/$acl_libdirstem" \
734 && test "X$dir" != "X/usr/$acl_libdirstem2"; then
735 rpathdirs="$rpathdirs $dir"
736 fi
737 next= ;;
738 *) next= ;;
739 esac
740 fi
741 done
742 if test "X$rpathdirs" != "X"; then
743 if test -n ""$3""; then
744 dnl libtool is used for linking. Use -R options.
745 for dir in $rpathdirs; do
746 $1="${$1}${$1:+ }-R$dir"
747 done
748 else
749 dnl The linker is used for linking directly.
750 if test -n "$acl_hardcode_libdir_separator"; then
751 dnl Weird platform: only the last -rpath option counts, the user
752 dnl must pass all path elements in one option.
753 alldirs=
754 for dir in $rpathdirs; do
755 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
756 done
757 acl_save_libdir="$libdir"
758 libdir="$alldirs"
759 eval flag=\"$acl_hardcode_libdir_flag_spec\"
760 libdir="$acl_save_libdir"
761 $1="$flag"
762 else
763 dnl The -rpath options are cumulative.
764 for dir in $rpathdirs; do
765 acl_save_libdir="$libdir"
766 libdir="$dir"
767 eval flag=\"$acl_hardcode_libdir_flag_spec\"
768 libdir="$acl_save_libdir"
769 $1="${$1}${$1:+ }$flag"
770 done
771 fi
772 fi
773 fi
774 fi
775 fi
776 AC_SUBST([$1])
777])
diff --git a/gl/m4/lib-prefix.m4 b/gl/m4/lib-prefix.m4
deleted file mode 100644
index 60908e8f..00000000
--- a/gl/m4/lib-prefix.m4
+++ /dev/null
@@ -1,224 +0,0 @@
1# lib-prefix.m4 serial 7 (gettext-0.18)
2dnl Copyright (C) 2001-2005, 2008-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
10dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
11dnl require excessive bracketing.
12ifdef([AC_HELP_STRING],
13[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
14[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
15
16dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
17dnl to access previously installed libraries. The basic assumption is that
18dnl a user will want packages to use other packages he previously installed
19dnl with the same --prefix option.
20dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
21dnl libraries, but is otherwise very convenient.
22AC_DEFUN([AC_LIB_PREFIX],
23[
24 AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
25 AC_REQUIRE([AC_PROG_CC])
26 AC_REQUIRE([AC_CANONICAL_HOST])
27 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
28 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
29 dnl By default, look in $includedir and $libdir.
30 use_additional=yes
31 AC_LIB_WITH_FINAL_PREFIX([
32 eval additional_includedir=\"$includedir\"
33 eval additional_libdir=\"$libdir\"
34 ])
35 AC_LIB_ARG_WITH([lib-prefix],
36[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
37 --without-lib-prefix don't search for libraries in includedir and libdir],
38[
39 if test "X$withval" = "Xno"; then
40 use_additional=no
41 else
42 if test "X$withval" = "X"; then
43 AC_LIB_WITH_FINAL_PREFIX([
44 eval additional_includedir=\"$includedir\"
45 eval additional_libdir=\"$libdir\"
46 ])
47 else
48 additional_includedir="$withval/include"
49 additional_libdir="$withval/$acl_libdirstem"
50 fi
51 fi
52])
53 if test $use_additional = yes; then
54 dnl Potentially add $additional_includedir to $CPPFLAGS.
55 dnl But don't add it
56 dnl 1. if it's the standard /usr/include,
57 dnl 2. if it's already present in $CPPFLAGS,
58 dnl 3. if it's /usr/local/include and we are using GCC on Linux,
59 dnl 4. if it doesn't exist as a directory.
60 if test "X$additional_includedir" != "X/usr/include"; then
61 haveit=
62 for x in $CPPFLAGS; do
63 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
64 if test "X$x" = "X-I$additional_includedir"; then
65 haveit=yes
66 break
67 fi
68 done
69 if test -z "$haveit"; then
70 if test "X$additional_includedir" = "X/usr/local/include"; then
71 if test -n "$GCC"; then
72 case $host_os in
73 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
74 esac
75 fi
76 fi
77 if test -z "$haveit"; then
78 if test -d "$additional_includedir"; then
79 dnl Really add $additional_includedir to $CPPFLAGS.
80 CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
81 fi
82 fi
83 fi
84 fi
85 dnl Potentially add $additional_libdir to $LDFLAGS.
86 dnl But don't add it
87 dnl 1. if it's the standard /usr/lib,
88 dnl 2. if it's already present in $LDFLAGS,
89 dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
90 dnl 4. if it doesn't exist as a directory.
91 if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
92 haveit=
93 for x in $LDFLAGS; do
94 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
95 if test "X$x" = "X-L$additional_libdir"; then
96 haveit=yes
97 break
98 fi
99 done
100 if test -z "$haveit"; then
101 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
102 if test -n "$GCC"; then
103 case $host_os in
104 linux*) haveit=yes;;
105 esac
106 fi
107 fi
108 if test -z "$haveit"; then
109 if test -d "$additional_libdir"; then
110 dnl Really add $additional_libdir to $LDFLAGS.
111 LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
112 fi
113 fi
114 fi
115 fi
116 fi
117])
118
119dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
120dnl acl_final_exec_prefix, containing the values to which $prefix and
121dnl $exec_prefix will expand at the end of the configure script.
122AC_DEFUN([AC_LIB_PREPARE_PREFIX],
123[
124 dnl Unfortunately, prefix and exec_prefix get only finally determined
125 dnl at the end of configure.
126 if test "X$prefix" = "XNONE"; then
127 acl_final_prefix="$ac_default_prefix"
128 else
129 acl_final_prefix="$prefix"
130 fi
131 if test "X$exec_prefix" = "XNONE"; then
132 acl_final_exec_prefix='${prefix}'
133 else
134 acl_final_exec_prefix="$exec_prefix"
135 fi
136 acl_save_prefix="$prefix"
137 prefix="$acl_final_prefix"
138 eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
139 prefix="$acl_save_prefix"
140])
141
142dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
143dnl variables prefix and exec_prefix bound to the values they will have
144dnl at the end of the configure script.
145AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
146[
147 acl_save_prefix="$prefix"
148 prefix="$acl_final_prefix"
149 acl_save_exec_prefix="$exec_prefix"
150 exec_prefix="$acl_final_exec_prefix"
151 $1
152 exec_prefix="$acl_save_exec_prefix"
153 prefix="$acl_save_prefix"
154])
155
156dnl AC_LIB_PREPARE_MULTILIB creates
157dnl - a variable acl_libdirstem, containing the basename of the libdir, either
158dnl "lib" or "lib64" or "lib/64",
159dnl - a variable acl_libdirstem2, as a secondary possible value for
160dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or
161dnl "lib/amd64".
162AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
163[
164 dnl There is no formal standard regarding lib and lib64.
165 dnl On glibc systems, the current practice is that on a system supporting
166 dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
167 dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine
168 dnl the compiler's default mode by looking at the compiler's library search
169 dnl path. If at least one of its elements ends in /lib64 or points to a
170 dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI.
171 dnl Otherwise we use the default, namely "lib".
172 dnl On Solaris systems, the current practice is that on a system supporting
173 dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
174 dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
175 dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
176 AC_REQUIRE([AC_CANONICAL_HOST])
177 acl_libdirstem=lib
178 acl_libdirstem2=
179 case "$host_os" in
180 solaris*)
181 dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
182 dnl <http://docs.sun.com/app/docs/doc/816-5138/dev-env?l=en&a=view>.
183 dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
184 dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
185 dnl symlink is missing, so we set acl_libdirstem2 too.
186 AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit],
187 [AC_EGREP_CPP([sixtyfour bits], [
188#ifdef _LP64
189sixtyfour bits
190#endif
191 ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no])
192 ])
193 if test $gl_cv_solaris_64bit = yes; then
194 acl_libdirstem=lib/64
195 case "$host_cpu" in
196 sparc*) acl_libdirstem2=lib/sparcv9 ;;
197 i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
198 esac
199 fi
200 ;;
201 *)
202 searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
203 if test -n "$searchpath"; then
204 acl_save_IFS="${IFS= }"; IFS=":"
205 for searchdir in $searchpath; do
206 if test -d "$searchdir"; then
207 case "$searchdir" in
208 */lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
209 */../ | */.. )
210 # Better ignore directories of this form. They are misleading.
211 ;;
212 *) searchdir=`cd "$searchdir" && pwd`
213 case "$searchdir" in
214 */lib64 ) acl_libdirstem=lib64 ;;
215 esac ;;
216 esac
217 fi
218 done
219 IFS="$acl_save_IFS"
220 fi
221 ;;
222 esac
223 test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
224])
diff --git a/gl/m4/limits-h.m4 b/gl/m4/limits-h.m4
new file mode 100644
index 00000000..5088fa16
--- /dev/null
+++ b/gl/m4/limits-h.m4
@@ -0,0 +1,41 @@
1dnl Check whether limits.h has needed features.
2
3dnl Copyright 2016-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl From Paul Eggert.
9
10AC_DEFUN_ONCE([gl_LIMITS_H],
11[
12 gl_CHECK_NEXT_HEADERS([limits.h])
13
14 AC_CACHE_CHECK([whether limits.h has WORD_BIT, BOOL_WIDTH etc.],
15 [gl_cv_header_limits_width],
16 [AC_COMPILE_IFELSE(
17 [AC_LANG_PROGRAM(
18 [[#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
19 #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
20 #endif
21 #include <limits.h>
22 long long llm = LLONG_MAX;
23 int wb = WORD_BIT;
24 int ullw = ULLONG_WIDTH;
25 int bw = BOOL_WIDTH;
26 ]])],
27 [gl_cv_header_limits_width=yes],
28 [gl_cv_header_limits_width=no])])
29 if test "$gl_cv_header_limits_width" = yes; then
30 GL_GENERATE_LIMITS_H=false
31 else
32 GL_GENERATE_LIMITS_H=true
33 fi
34])
35
36dnl Unconditionally enables the replacement of <limits.h>.
37AC_DEFUN([gl_REPLACE_LIMITS_H],
38[
39 AC_REQUIRE([gl_LIMITS_H])
40 GL_GENERATE_LIMITS_H=true
41])
diff --git a/gl/m4/localcharset.m4 b/gl/m4/localcharset.m4
index 2e93e581..15b6b2a5 100644
--- a/gl/m4/localcharset.m4
+++ b/gl/m4/localcharset.m4
@@ -1,5 +1,5 @@
1# localcharset.m4 serial 7 1# localcharset.m4 serial 8
2dnl Copyright (C) 2002, 2004, 2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2004, 2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,10 +8,4 @@ AC_DEFUN([gl_LOCALCHARSET],
8[ 8[
9 dnl Prerequisites of lib/localcharset.c. 9 dnl Prerequisites of lib/localcharset.c.
10 AC_REQUIRE([AM_LANGINFO_CODESET]) 10 AC_REQUIRE([AM_LANGINFO_CODESET])
11 AC_REQUIRE([gl_FCNTL_O_FLAGS])
12 AC_CHECK_DECLS_ONCE([getc_unlocked])
13
14 dnl Prerequisites of the lib/Makefile.am snippet.
15 AC_REQUIRE([AC_CANONICAL_HOST])
16 AC_REQUIRE([gl_GLIBC21])
17]) 11])
diff --git a/gl/m4/locale-fr.m4 b/gl/m4/locale-fr.m4
index ef199e39..8c41fadf 100644
--- a/gl/m4/locale-fr.m4
+++ b/gl/m4/locale-fr.m4
@@ -1,5 +1,5 @@
1# locale-fr.m4 serial 17 1# locale-fr.m4 serial 20
2dnl Copyright (C) 2003, 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,8 +12,7 @@ AC_DEFUN([gt_LOCALE_FR],
12 AC_REQUIRE([AC_CANONICAL_HOST]) 12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET]) 13 AC_REQUIRE([AM_LANGINFO_CODESET])
14 AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [ 14 AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [
15 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 15 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
16changequote(,)dnl
17#include <locale.h> 16#include <locale.h>
18#include <time.h> 17#include <time.h>
19#if HAVE_LANGINFO_CODESET 18#if HAVE_LANGINFO_CODESET
@@ -24,8 +23,14 @@ changequote(,)dnl
24struct tm t; 23struct tm t;
25char buf[16]; 24char buf[16];
26int main () { 25int main () {
26 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
27 imitates locale dependent behaviour by looking at the environment
28 variables, and all locales use the UTF-8 encoding. */
29#if defined __BEOS__ || defined __HAIKU__
30 return 1;
31#else
27 /* Check whether the given locale name is recognized by the system. */ 32 /* Check whether the given locale name is recognized by the system. */
28#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ 33# if defined _WIN32 && !defined __CYGWIN__
29 /* On native Windows, setlocale(category, "") looks at the system settings, 34 /* On native Windows, setlocale(category, "") looks at the system settings,
30 not at the environment variables. Also, when an encoding suffix such 35 not at the environment variables. Also, when an encoding suffix such
31 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE 36 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
@@ -33,9 +38,9 @@ int main () {
33 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL 38 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
34 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) 39 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
35 return 1; 40 return 1;
36#else 41# else
37 if (setlocale (LC_ALL, "") == NULL) return 1; 42 if (setlocale (LC_ALL, "") == NULL) return 1;
38#endif 43# endif
39 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". 44 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
40 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) 45 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
41 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. 46 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
@@ -44,35 +49,35 @@ int main () {
44 some unit tests fail. 49 some unit tests fail.
45 On MirBSD 10, when an unsupported locale is specified, setlocale() 50 On MirBSD 10, when an unsupported locale is specified, setlocale()
46 succeeds but then nl_langinfo(CODESET) is "UTF-8". */ 51 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
47#if HAVE_LANGINFO_CODESET 52# if HAVE_LANGINFO_CODESET
48 { 53 {
49 const char *cs = nl_langinfo (CODESET); 54 const char *cs = nl_langinfo (CODESET);
50 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 55 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
51 || strcmp (cs, "UTF-8") == 0) 56 || strcmp (cs, "UTF-8") == 0)
52 return 1; 57 return 1;
53 } 58 }
54#endif 59# endif
55#ifdef __CYGWIN__ 60# ifdef __CYGWIN__
56 /* On Cygwin, avoid locale names without encoding suffix, because the 61 /* On Cygwin, avoid locale names without encoding suffix, because the
57 locale_charset() function relies on the encoding suffix. Note that 62 locale_charset() function relies on the encoding suffix. Note that
58 LC_ALL is set on the command line. */ 63 LC_ALL is set on the command line. */
59 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; 64 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
60#endif 65# endif
61 /* Check whether in the abbreviation of the second month, the second 66 /* Check whether in the abbreviation of the second month, the second
62 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only 67 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
63 one byte long. This excludes the UTF-8 encoding. */ 68 one byte long. This excludes the UTF-8 encoding. */
64 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; 69 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
65 if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1; 70 if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
66#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ 71# if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */
67 /* Check whether the decimal separator is a comma. 72 /* Check whether the decimal separator is a comma.
68 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point 73 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
69 are nl_langinfo(RADIXCHAR) are both ".". */ 74 are nl_langinfo(RADIXCHAR) are both ".". */
70 if (localeconv () ->decimal_point[0] != ',') return 1; 75 if (localeconv () ->decimal_point[0] != ',') return 1;
71#endif 76# endif
72 return 0; 77 return 0;
78#endif
73} 79}
74changequote([,])dnl 80 ]])])
75 ])])
76 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 81 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
77 case "$host_os" in 82 case "$host_os" in
78 # Handle native Windows specially, because there setlocale() interprets 83 # Handle native Windows specially, because there setlocale() interprets
@@ -136,8 +141,7 @@ AC_DEFUN([gt_LOCALE_FR_UTF8],
136[ 141[
137 AC_REQUIRE([AM_LANGINFO_CODESET]) 142 AC_REQUIRE([AM_LANGINFO_CODESET])
138 AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [ 143 AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [
139 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 144 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
140changequote(,)dnl
141#include <locale.h> 145#include <locale.h>
142#include <time.h> 146#include <time.h>
143#if HAVE_LANGINFO_CODESET 147#if HAVE_LANGINFO_CODESET
@@ -153,7 +157,7 @@ int main () {
153 variables, and all locales use the UTF-8 encoding. */ 157 variables, and all locales use the UTF-8 encoding. */
154#if !(defined __BEOS__ || defined __HAIKU__) 158#if !(defined __BEOS__ || defined __HAIKU__)
155 /* Check whether the given locale name is recognized by the system. */ 159 /* Check whether the given locale name is recognized by the system. */
156# if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ 160# if defined _WIN32 && !defined __CYGWIN__
157 /* On native Windows, setlocale(category, "") looks at the system settings, 161 /* On native Windows, setlocale(category, "") looks at the system settings,
158 not at the environment variables. Also, when an encoding suffix such 162 not at the environment variables. Also, when an encoding suffix such
159 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE 163 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
@@ -199,8 +203,7 @@ int main () {
199#endif 203#endif
200 return 0; 204 return 0;
201} 205}
202changequote([,])dnl 206 ]])])
203 ])])
204 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 207 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
205 case "$host_os" in 208 case "$host_os" in
206 # Handle native Windows specially, because there setlocale() interprets 209 # Handle native Windows specially, because there setlocale() interprets
diff --git a/gl/m4/locale-ja.m4 b/gl/m4/locale-ja.m4
index 132a3e77..25901730 100644
--- a/gl/m4/locale-ja.m4
+++ b/gl/m4/locale-ja.m4
@@ -1,5 +1,5 @@
1# locale-ja.m4 serial 12 1# locale-ja.m4 serial 15
2dnl Copyright (C) 2003, 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,8 +12,7 @@ AC_DEFUN([gt_LOCALE_JA],
12 AC_REQUIRE([AC_CANONICAL_HOST]) 12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET]) 13 AC_REQUIRE([AM_LANGINFO_CODESET])
14 AC_CACHE_CHECK([for a traditional japanese locale], [gt_cv_locale_ja], [ 14 AC_CACHE_CHECK([for a traditional japanese locale], [gt_cv_locale_ja], [
15 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 15 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
16changequote(,)dnl
17#include <locale.h> 16#include <locale.h>
18#include <time.h> 17#include <time.h>
19#if HAVE_LANGINFO_CODESET 18#if HAVE_LANGINFO_CODESET
@@ -25,9 +24,14 @@ struct tm t;
25char buf[16]; 24char buf[16];
26int main () 25int main ()
27{ 26{
28 const char *p; 27 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
28 imitates locale dependent behaviour by looking at the environment
29 variables, and all locales use the UTF-8 encoding. */
30#if defined __BEOS__ || defined __HAIKU__
31 return 1;
32#else
29 /* Check whether the given locale name is recognized by the system. */ 33 /* Check whether the given locale name is recognized by the system. */
30#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ 34# if defined _WIN32 && !defined __CYGWIN__
31 /* On native Windows, setlocale(category, "") looks at the system settings, 35 /* On native Windows, setlocale(category, "") looks at the system settings,
32 not at the environment variables. Also, when an encoding suffix such 36 not at the environment variables. Also, when an encoding suffix such
33 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE 37 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
@@ -35,9 +39,9 @@ int main ()
35 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL 39 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
36 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) 40 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
37 return 1; 41 return 1;
38#else 42# else
39 if (setlocale (LC_ALL, "") == NULL) return 1; 43 if (setlocale (LC_ALL, "") == NULL) return 1;
40#endif 44# endif
41 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". 45 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
42 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) 46 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
43 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. 47 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
@@ -46,35 +50,38 @@ int main ()
46 some unit tests fail. 50 some unit tests fail.
47 On MirBSD 10, when an unsupported locale is specified, setlocale() 51 On MirBSD 10, when an unsupported locale is specified, setlocale()
48 succeeds but then nl_langinfo(CODESET) is "UTF-8". */ 52 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
49#if HAVE_LANGINFO_CODESET 53# if HAVE_LANGINFO_CODESET
50 { 54 {
51 const char *cs = nl_langinfo (CODESET); 55 const char *cs = nl_langinfo (CODESET);
52 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 56 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
53 || strcmp (cs, "UTF-8") == 0) 57 || strcmp (cs, "UTF-8") == 0)
54 return 1; 58 return 1;
55 } 59 }
56#endif 60# endif
57#ifdef __CYGWIN__ 61# ifdef __CYGWIN__
58 /* On Cygwin, avoid locale names without encoding suffix, because the 62 /* On Cygwin, avoid locale names without encoding suffix, because the
59 locale_charset() function relies on the encoding suffix. Note that 63 locale_charset() function relies on the encoding suffix. Note that
60 LC_ALL is set on the command line. */ 64 LC_ALL is set on the command line. */
61 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; 65 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
62#endif 66# endif
63 /* Check whether MB_CUR_MAX is > 1. This excludes the dysfunctional locales 67 /* Check whether MB_CUR_MAX is > 1. This excludes the dysfunctional locales
64 on Cygwin 1.5.x. */ 68 on Cygwin 1.5.x. */
65 if (MB_CUR_MAX == 1) 69 if (MB_CUR_MAX == 1)
66 return 1; 70 return 1;
67 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs. 71 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
68 This excludes the UTF-8 encoding (except on MirBSD). */ 72 This excludes the UTF-8 encoding (except on MirBSD). */
69 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; 73 {
70 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1; 74 const char *p;
71 for (p = buf; *p != '\0'; p++) 75 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
72 if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0) 76 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
73 return 1; 77 for (p = buf; *p != '\0'; p++)
78 if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
79 return 1;
80 }
74 return 0; 81 return 0;
82#endif
75} 83}
76changequote([,])dnl 84 ]])])
77 ])])
78 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 85 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
79 case "$host_os" in 86 case "$host_os" in
80 # Handle native Windows specially, because there setlocale() interprets 87 # Handle native Windows specially, because there setlocale() interprets
diff --git a/gl/m4/locale-zh.m4 b/gl/m4/locale-zh.m4
index 4eed73f4..b9f9eef7 100644
--- a/gl/m4/locale-zh.m4
+++ b/gl/m4/locale-zh.m4
@@ -1,5 +1,5 @@
1# locale-zh.m4 serial 12 1# locale-zh.m4 serial 15
2dnl Copyright (C) 2003, 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,8 +12,7 @@ AC_DEFUN([gt_LOCALE_ZH_CN],
12 AC_REQUIRE([AC_CANONICAL_HOST]) 12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET]) 13 AC_REQUIRE([AM_LANGINFO_CODESET])
14 AC_CACHE_CHECK([for a transitional chinese locale], [gt_cv_locale_zh_CN], [ 14 AC_CACHE_CHECK([for a transitional chinese locale], [gt_cv_locale_zh_CN], [
15 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 15 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
16changequote(,)dnl
17#include <locale.h> 16#include <locale.h>
18#include <stdlib.h> 17#include <stdlib.h>
19#include <time.h> 18#include <time.h>
@@ -26,9 +25,14 @@ struct tm t;
26char buf[16]; 25char buf[16];
27int main () 26int main ()
28{ 27{
29 const char *p; 28 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
29 imitates locale dependent behaviour by looking at the environment
30 variables, and all locales use the UTF-8 encoding. */
31#if defined __BEOS__ || defined __HAIKU__
32 return 1;
33#else
30 /* Check whether the given locale name is recognized by the system. */ 34 /* Check whether the given locale name is recognized by the system. */
31#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ 35# if defined _WIN32 && !defined __CYGWIN__
32 /* On native Windows, setlocale(category, "") looks at the system settings, 36 /* On native Windows, setlocale(category, "") looks at the system settings,
33 not at the environment variables. Also, when an encoding suffix such 37 not at the environment variables. Also, when an encoding suffix such
34 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE 38 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
@@ -36,9 +40,9 @@ int main ()
36 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL 40 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
37 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) 41 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
38 return 1; 42 return 1;
39#else 43# else
40 if (setlocale (LC_ALL, "") == NULL) return 1; 44 if (setlocale (LC_ALL, "") == NULL) return 1;
41#endif 45# endif
42 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". 46 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
43 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) 47 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
44 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. 48 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
@@ -47,35 +51,38 @@ int main ()
47 some unit tests fail. 51 some unit tests fail.
48 On MirBSD 10, when an unsupported locale is specified, setlocale() 52 On MirBSD 10, when an unsupported locale is specified, setlocale()
49 succeeds but then nl_langinfo(CODESET) is "UTF-8". */ 53 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
50#if HAVE_LANGINFO_CODESET 54# if HAVE_LANGINFO_CODESET
51 { 55 {
52 const char *cs = nl_langinfo (CODESET); 56 const char *cs = nl_langinfo (CODESET);
53 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 57 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
54 || strcmp (cs, "UTF-8") == 0) 58 || strcmp (cs, "UTF-8") == 0)
55 return 1; 59 return 1;
56 } 60 }
57#endif 61# endif
58#ifdef __CYGWIN__ 62# ifdef __CYGWIN__
59 /* On Cygwin, avoid locale names without encoding suffix, because the 63 /* On Cygwin, avoid locale names without encoding suffix, because the
60 locale_charset() function relies on the encoding suffix. Note that 64 locale_charset() function relies on the encoding suffix. Note that
61 LC_ALL is set on the command line. */ 65 LC_ALL is set on the command line. */
62 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; 66 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
63#endif 67# endif
64 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs. 68 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
65 This excludes the UTF-8 encoding (except on MirBSD). */ 69 This excludes the UTF-8 encoding (except on MirBSD). */
66 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; 70 {
67 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1; 71 const char *p;
68 for (p = buf; *p != '\0'; p++) 72 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
69 if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0) 73 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
70 return 1; 74 for (p = buf; *p != '\0'; p++)
75 if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
76 return 1;
77 }
71 /* Check whether a typical GB18030 multibyte sequence is recognized as a 78 /* Check whether a typical GB18030 multibyte sequence is recognized as a
72 single wide character. This excludes the GB2312 and GBK encodings. */ 79 single wide character. This excludes the GB2312 and GBK encodings. */
73 if (mblen ("\203\062\332\066", 5) != 4) 80 if (mblen ("\203\062\332\066", 5) != 4)
74 return 1; 81 return 1;
75 return 0; 82 return 0;
83#endif
76} 84}
77changequote([,])dnl 85 ]])])
78 ])])
79 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 86 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
80 case "$host_os" in 87 case "$host_os" in
81 # Handle native Windows specially, because there setlocale() interprets 88 # Handle native Windows specially, because there setlocale() interprets
diff --git a/gl/m4/locale_h.m4 b/gl/m4/locale_h.m4
index 8bd12e80..a33a0a46 100644
--- a/gl/m4/locale_h.m4
+++ b/gl/m4/locale_h.m4
@@ -1,13 +1,13 @@
1# locale_h.m4 serial 19 1# locale_h.m4 serial 28
2dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_LOCALE_H], 7AC_DEFUN_ONCE([gl_LOCALE_H],
8[ 8[
9 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 9 dnl Ensure to expand the default settings once only, before all statements
10 dnl once only, before all statements that occur in other macros. 10 dnl that occur in other macros.
11 AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) 11 AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
12 12
13 dnl Persuade glibc <locale.h> to define locale_t and the int_p_*, int_n_* 13 dnl Persuade glibc <locale.h> to define locale_t and the int_p_*, int_n_*
@@ -17,7 +17,9 @@ AC_DEFUN([gl_LOCALE_H],
17 dnl If <stddef.h> is replaced, then <locale.h> must also be replaced. 17 dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
18 AC_REQUIRE([gl_STDDEF_H]) 18 AC_REQUIRE([gl_STDDEF_H])
19 19
20 dnl Solaris 11 2011-11 defines the int_p_*, int_n_* members of 'struct lconv' 20 AC_REQUIRE([gl_LOCALE_T])
21
22 dnl Solaris 11.0 defines the int_p_*, int_n_* members of 'struct lconv'
21 dnl only if _LCONV_C99 is defined. 23 dnl only if _LCONV_C99 is defined.
22 AC_REQUIRE([AC_CANONICAL_HOST]) 24 AC_REQUIRE([AC_CANONICAL_HOST])
23 case "$host_os" in 25 case "$host_os" in
@@ -37,34 +39,6 @@ AC_DEFUN([gl_LOCALE_H],
37 [gl_cv_header_locale_h_posix2001=yes], 39 [gl_cv_header_locale_h_posix2001=yes],
38 [gl_cv_header_locale_h_posix2001=no])]) 40 [gl_cv_header_locale_h_posix2001=no])])
39 41
40 dnl Check for <xlocale.h>.
41 AC_CHECK_HEADERS_ONCE([xlocale.h])
42 if test $ac_cv_header_xlocale_h = yes; then
43 HAVE_XLOCALE_H=1
44 dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
45 dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
46 dnl itself, we assume that <xlocale.h> will do so.
47 AC_CACHE_CHECK([whether locale.h defines locale_t],
48 [gl_cv_header_locale_has_locale_t],
49 [AC_COMPILE_IFELSE(
50 [AC_LANG_PROGRAM(
51 [[#include <locale.h>
52 locale_t x;]],
53 [[]])],
54 [gl_cv_header_locale_has_locale_t=yes],
55 [gl_cv_header_locale_has_locale_t=no])
56 ])
57 if test $gl_cv_header_locale_has_locale_t = yes; then
58 gl_cv_header_locale_h_needs_xlocale_h=no
59 else
60 gl_cv_header_locale_h_needs_xlocale_h=yes
61 fi
62 else
63 HAVE_XLOCALE_H=0
64 gl_cv_header_locale_h_needs_xlocale_h=no
65 fi
66 AC_SUBST([HAVE_XLOCALE_H])
67
68 dnl Check whether 'struct lconv' is complete. 42 dnl Check whether 'struct lconv' is complete.
69 dnl Bionic libc's 'struct lconv' is just a dummy. 43 dnl Bionic libc's 'struct lconv' is just a dummy.
70 dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x, 44 dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x,
@@ -82,7 +56,20 @@ AC_DEFUN([gl_LOCALE_H],
82 [gl_cv_sys_struct_lconv_ok=no]) 56 [gl_cv_sys_struct_lconv_ok=no])
83 ]) 57 ])
84 if test $gl_cv_sys_struct_lconv_ok = no; then 58 if test $gl_cv_sys_struct_lconv_ok = no; then
85 REPLACE_STRUCT_LCONV=1 59 dnl On native Windows with MSVC, merely define these member names as macros.
60 dnl This avoids trouble in C++ mode.
61 case "$host_os" in
62 mingw*)
63 AC_EGREP_CPP([Special], [
64#ifdef _MSC_VER
65 Special
66#endif
67 ],
68 [],
69 [REPLACE_STRUCT_LCONV=1])
70 ;;
71 *) REPLACE_STRUCT_LCONV=1 ;;
72 esac
86 fi 73 fi
87 74
88 dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK. 75 dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK.
@@ -96,27 +83,92 @@ AC_DEFUN([gl_LOCALE_H],
96# include <xlocale.h> 83# include <xlocale.h>
97#endif 84#endif
98 ]], 85 ]],
99 [setlocale duplocale]) 86 [setlocale newlocale duplocale freelocale])
87])
88
89dnl Checks to determine whether the system has the locale_t type,
90dnl and how to obtain it.
91AC_DEFUN([gl_LOCALE_T],
92[
93 dnl Persuade glibc and Solaris <locale.h> to define locale_t.
94 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
95
96 dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
97 dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
98 dnl itself, we assume that <xlocale.h> will do so.
99 AC_CACHE_CHECK([whether locale.h defines locale_t],
100 [gl_cv_header_locale_has_locale_t],
101 [AC_COMPILE_IFELSE(
102 [AC_LANG_PROGRAM(
103 [[#include <locale.h>
104 locale_t x;]],
105 [[]])],
106 [gl_cv_header_locale_has_locale_t=yes],
107 [gl_cv_header_locale_has_locale_t=no])
108 ])
109
110 dnl Check for <xlocale.h>.
111 AC_CHECK_HEADERS_ONCE([xlocale.h])
112 if test $ac_cv_header_xlocale_h = yes; then
113 HAVE_XLOCALE_H=1
114 if test $gl_cv_header_locale_has_locale_t = yes; then
115 gl_cv_header_locale_h_needs_xlocale_h=no
116 else
117 gl_cv_header_locale_h_needs_xlocale_h=yes
118 fi
119 HAVE_LOCALE_T=1
120 else
121 HAVE_XLOCALE_H=0
122 gl_cv_header_locale_h_needs_xlocale_h=no
123 if test $gl_cv_header_locale_has_locale_t = yes; then
124 HAVE_LOCALE_T=1
125 else
126 HAVE_LOCALE_T=0
127 fi
128 fi
129 AC_SUBST([HAVE_XLOCALE_H])
100]) 130])
101 131
132# gl_LOCALE_MODULE_INDICATOR([modulename])
133# sets the shell variable that indicates the presence of the given module
134# to a C preprocessor expression that will evaluate to 1.
135# This macro invocation must not occur in macros that are AC_REQUIREd.
102AC_DEFUN([gl_LOCALE_MODULE_INDICATOR], 136AC_DEFUN([gl_LOCALE_MODULE_INDICATOR],
103[ 137[
104 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 138 dnl Ensure to expand the default settings once only.
105 AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) 139 gl_LOCALE_H_REQUIRE_DEFAULTS
106 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 140 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
107 dnl Define it also as a C macro, for the benefit of the unit tests. 141 dnl Define it also as a C macro, for the benefit of the unit tests.
108 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 142 gl_MODULE_INDICATOR_FOR_TESTS([$1])
109]) 143])
110 144
145# Initializes the default values for AC_SUBSTed shell variables.
146# This macro must not be AC_REQUIREd. It must only be invoked, and only
147# outside of macros or in macros that are not AC_REQUIREd.
148AC_DEFUN([gl_LOCALE_H_REQUIRE_DEFAULTS],
149[
150 m4_defun(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS], [
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALECONV])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE_NULL])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUPLOCALE])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALENAME])
156 ])
157 m4_require(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS])
158 AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
159])
160
111AC_DEFUN([gl_LOCALE_H_DEFAULTS], 161AC_DEFUN([gl_LOCALE_H_DEFAULTS],
112[ 162[
113 GNULIB_LOCALECONV=0; AC_SUBST([GNULIB_LOCALECONV])
114 GNULIB_SETLOCALE=0; AC_SUBST([GNULIB_SETLOCALE])
115 GNULIB_DUPLOCALE=0; AC_SUBST([GNULIB_DUPLOCALE])
116 dnl Assume proper GNU behavior unless another module says otherwise. 163 dnl Assume proper GNU behavior unless another module says otherwise.
164 HAVE_NEWLOCALE=1; AC_SUBST([HAVE_NEWLOCALE])
117 HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE]) 165 HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE])
166 HAVE_FREELOCALE=1; AC_SUBST([HAVE_FREELOCALE])
118 REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV]) 167 REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV])
119 REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE]) 168 REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE])
169 REPLACE_NEWLOCALE=0; AC_SUBST([REPLACE_NEWLOCALE])
120 REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE]) 170 REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE])
171 REPLACE_FREELOCALE=0; AC_SUBST([REPLACE_FREELOCALE])
121 REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV]) 172 REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV])
173 LOCALENAME_ENHANCE_LOCALE_FUNCS=0; AC_SUBST([LOCALENAME_ENHANCE_LOCALE_FUNCS])
122]) 174])
diff --git a/gl/m4/localeconv.m4 b/gl/m4/localeconv.m4
index b8bb5964..ae225fed 100644
--- a/gl/m4/localeconv.m4
+++ b/gl/m4/localeconv.m4
@@ -1,5 +1,5 @@
1# localeconv.m4 serial 1 1# localeconv.m4 serial 1
2dnl Copyright (C) 2012-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2012-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/lock.m4 b/gl/m4/lock.m4
index aae1701a..88cf5575 100644
--- a/gl/m4/lock.m4
+++ b/gl/m4/lock.m4
@@ -1,5 +1,5 @@
1# lock.m4 serial 13 (gettext-0.18.2) 1# lock.m4 serial 14
2dnl Copyright (C) 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,11 +12,16 @@ AC_DEFUN([gl_LOCK],
12 if test "$gl_threads_api" = posix; then 12 if test "$gl_threads_api" = posix; then
13 # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the 13 # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the
14 # pthread_rwlock_* functions. 14 # pthread_rwlock_* functions.
15 has_rwlock=false
15 AC_CHECK_TYPE([pthread_rwlock_t], 16 AC_CHECK_TYPE([pthread_rwlock_t],
16 [AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1], 17 [has_rwlock=true
18 AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1],
17 [Define if the POSIX multithreading library has read/write locks.])], 19 [Define if the POSIX multithreading library has read/write locks.])],
18 [], 20 [],
19 [#include <pthread.h>]) 21 [#include <pthread.h>])
22 if $has_rwlock; then
23 gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
24 fi
20 # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. 25 # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro.
21 AC_COMPILE_IFELSE([ 26 AC_COMPILE_IFELSE([
22 AC_LANG_PROGRAM( 27 AC_LANG_PROGRAM(
diff --git a/gl/m4/longlong.m4 b/gl/m4/longlong.m4
deleted file mode 100644
index 3af6ab5a..00000000
--- a/gl/m4/longlong.m4
+++ /dev/null
@@ -1,113 +0,0 @@
1# longlong.m4 serial 17
2dnl Copyright (C) 1999-2007, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Paul Eggert.
8
9# Define HAVE_LONG_LONG_INT if 'long long int' works.
10# This fixes a bug in Autoconf 2.61, and can be faster
11# than what's in Autoconf 2.62 through 2.68.
12
13# Note: If the type 'long long int' exists but is only 32 bits large
14# (as on some very old compilers), HAVE_LONG_LONG_INT will not be
15# defined. In this case you can treat 'long long int' like 'long int'.
16
17AC_DEFUN([AC_TYPE_LONG_LONG_INT],
18[
19 AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
20 AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
21 [ac_cv_type_long_long_int=yes
22 if test "x${ac_cv_prog_cc_c99-no}" = xno; then
23 ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int
24 if test $ac_cv_type_long_long_int = yes; then
25 dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
26 dnl If cross compiling, assume the bug is not important, since
27 dnl nobody cross compiles for this platform as far as we know.
28 AC_RUN_IFELSE(
29 [AC_LANG_PROGRAM(
30 [[@%:@include <limits.h>
31 @%:@ifndef LLONG_MAX
32 @%:@ define HALF \
33 (1LL << (sizeof (long long int) * CHAR_BIT - 2))
34 @%:@ define LLONG_MAX (HALF - 1 + HALF)
35 @%:@endif]],
36 [[long long int n = 1;
37 int i;
38 for (i = 0; ; i++)
39 {
40 long long int m = n << i;
41 if (m >> i != n)
42 return 1;
43 if (LLONG_MAX / 2 < m)
44 break;
45 }
46 return 0;]])],
47 [],
48 [ac_cv_type_long_long_int=no],
49 [:])
50 fi
51 fi])
52 if test $ac_cv_type_long_long_int = yes; then
53 AC_DEFINE([HAVE_LONG_LONG_INT], [1],
54 [Define to 1 if the system has the type 'long long int'.])
55 fi
56])
57
58# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works.
59# This fixes a bug in Autoconf 2.61, and can be faster
60# than what's in Autoconf 2.62 through 2.68.
61
62# Note: If the type 'unsigned long long int' exists but is only 32 bits
63# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT
64# will not be defined. In this case you can treat 'unsigned long long int'
65# like 'unsigned long int'.
66
67AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
68[
69 AC_CACHE_CHECK([for unsigned long long int],
70 [ac_cv_type_unsigned_long_long_int],
71 [ac_cv_type_unsigned_long_long_int=yes
72 if test "x${ac_cv_prog_cc_c99-no}" = xno; then
73 AC_LINK_IFELSE(
74 [_AC_TYPE_LONG_LONG_SNIPPET],
75 [],
76 [ac_cv_type_unsigned_long_long_int=no])
77 fi])
78 if test $ac_cv_type_unsigned_long_long_int = yes; then
79 AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
80 [Define to 1 if the system has the type 'unsigned long long int'.])
81 fi
82])
83
84# Expands to a C program that can be used to test for simultaneous support
85# of 'long long' and 'unsigned long long'. We don't want to say that
86# 'long long' is available if 'unsigned long long' is not, or vice versa,
87# because too many programs rely on the symmetry between signed and unsigned
88# integer types (excluding 'bool').
89AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
90[
91 AC_LANG_PROGRAM(
92 [[/* For now, do not test the preprocessor; as of 2007 there are too many
93 implementations with broken preprocessors. Perhaps this can
94 be revisited in 2012. In the meantime, code should not expect
95 #if to work with literals wider than 32 bits. */
96 /* Test literals. */
97 long long int ll = 9223372036854775807ll;
98 long long int nll = -9223372036854775807LL;
99 unsigned long long int ull = 18446744073709551615ULL;
100 /* Test constant expressions. */
101 typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
102 ? 1 : -1)];
103 typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
104 ? 1 : -1)];
105 int i = 63;]],
106 [[/* Test availability of runtime routines for shift and division. */
107 long long int llmax = 9223372036854775807ll;
108 unsigned long long int ullmax = 18446744073709551615ull;
109 return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
110 | (llmax / ll) | (llmax % ll)
111 | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
112 | (ullmax / ull) | (ullmax % ull));]])
113])
diff --git a/gl/m4/ls-mntd-fs.m4 b/gl/m4/ls-mntd-fs.m4
deleted file mode 100644
index fb116c8b..00000000
--- a/gl/m4/ls-mntd-fs.m4
+++ /dev/null
@@ -1,357 +0,0 @@
1# serial 30
2# How to list mounted file systems.
3
4# Copyright (C) 1998-2004, 2006, 2009-2013 Free Software Foundation, Inc.
5#
6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved.
9
10dnl From Jim Meyering.
11dnl
12dnl This is not pretty. I've just taken the autoconf code and wrapped
13dnl it in an AC_DEFUN and made some other fixes.
14dnl
15
16# Replace Autoconf's AC_FUNC_GETMNTENT to work around a bug in Autoconf
17# through Autoconf 2.59. We can remove this once we assume Autoconf 2.60
18# or later.
19AC_DEFUN([AC_FUNC_GETMNTENT],
20[# getmntent is in the standard C library on UNICOS, in -lsun on Irix 4,
21# -lseq on Dynix/PTX, -lgen on Unixware.
22AC_SEARCH_LIBS([getmntent], [sun seq gen])
23AC_CHECK_FUNCS([getmntent])
24])
25
26# gl_LIST_MOUNTED_FILE_SYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
27AC_DEFUN([gl_LIST_MOUNTED_FILE_SYSTEMS],
28 [
29AC_CHECK_FUNCS([listmntent getmntinfo])
30AC_CHECK_HEADERS_ONCE([sys/param.h sys/statvfs.h])
31
32# We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses
33# NGROUPS (as the array dimension for a struct member) without a definition.
34AC_CHECK_HEADERS([sys/ucred.h], [], [], [#include <grp.h>])
35
36AC_CHECK_HEADERS([sys/mount.h], [], [],
37 [AC_INCLUDES_DEFAULT
38 [#if HAVE_SYS_PARAM_H
39 #include <sys/param.h>
40 #endif]])
41
42AC_CHECK_HEADERS([mntent.h sys/fs_types.h])
43 getfsstat_includes="\
44$ac_includes_default
45#if HAVE_SYS_PARAM_H
46# include <sys/param.h> /* needed by powerpc-apple-darwin1.3.7 */
47#endif
48#if HAVE_SYS_UCRED_H
49# include <grp.h> /* needed for definition of NGROUPS */
50# include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
51#endif
52#if HAVE_SYS_MOUNT_H
53# include <sys/mount.h>
54#endif
55#if HAVE_SYS_FS_TYPES_H
56# include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */
57#endif
58"
59AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes])
60
61# Determine how to get the list of mounted file systems.
62ac_list_mounted_fs=
63
64# If the getmntent function is available but not in the standard library,
65# make sure LIBS contains the appropriate -l option.
66AC_FUNC_GETMNTENT
67
68# This test must precede the ones for getmntent because Unicos-9 is
69# reported to have the getmntent function, but its support is incompatible
70# with other getmntent implementations.
71
72# NOTE: Normally, I wouldn't use a check for system type as I've done for
73# 'CRAY' below since that goes against the whole autoconf philosophy. But
74# I think there is too great a chance that some non-Cray system has a
75# function named listmntent to risk the false positive.
76
77if test -z "$ac_list_mounted_fs"; then
78 # Cray UNICOS 9
79 AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
80 AC_CACHE_VAL([fu_cv_sys_mounted_cray_listmntent],
81 [fu_cv_sys_mounted_cray_listmntent=no
82 AC_EGREP_CPP([yes],
83 [#ifdef _CRAY
84yes
85#endif
86 ], [test $ac_cv_func_listmntent = yes \
87 && fu_cv_sys_mounted_cray_listmntent=yes]
88 )
89 ]
90 )
91 AC_MSG_RESULT([$fu_cv_sys_mounted_cray_listmntent])
92 if test $fu_cv_sys_mounted_cray_listmntent = yes; then
93 ac_list_mounted_fs=found
94 AC_DEFINE([MOUNTED_LISTMNTENT], [1],
95 [Define if there is a function named listmntent that can be used to
96 list all mounted file systems. (UNICOS)])
97 fi
98fi
99
100if test -z "$ac_list_mounted_fs"; then
101 # AIX.
102 AC_MSG_CHECKING([for mntctl function and struct vmount])
103 AC_CACHE_VAL([fu_cv_sys_mounted_vmount],
104 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <fshelp.h>]])],
105 [fu_cv_sys_mounted_vmount=yes],
106 [fu_cv_sys_mounted_vmount=no])])
107 AC_MSG_RESULT([$fu_cv_sys_mounted_vmount])
108 if test $fu_cv_sys_mounted_vmount = yes; then
109 ac_list_mounted_fs=found
110 AC_DEFINE([MOUNTED_VMOUNT], [1],
111 [Define if there is a function named mntctl that can be used to read
112 the list of mounted file systems, and there is a system header file
113 that declares 'struct vmount'. (AIX)])
114 fi
115fi
116
117if test $ac_cv_func_getmntent = yes; then
118
119 # This system has the getmntent function.
120 # Determine whether it's the one-argument variant or the two-argument one.
121
122 if test -z "$ac_list_mounted_fs"; then
123 # 4.3BSD, SunOS, HP-UX, Dynix, Irix
124 AC_MSG_CHECKING([for one-argument getmntent function])
125 AC_CACHE_VAL([fu_cv_sys_mounted_getmntent1],
126 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
127/* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */
128#include <stdio.h>
129
130#include <mntent.h>
131#if !defined MOUNTED
132# if defined _PATH_MOUNTED /* GNU libc */
133# define MOUNTED _PATH_MOUNTED
134# endif
135# if defined MNT_MNTTAB /* HP-UX. */
136# define MOUNTED MNT_MNTTAB
137# endif
138# if defined MNTTABNAME /* Dynix. */
139# define MOUNTED MNTTABNAME
140# endif
141#endif
142]],
143 [[ struct mntent *mnt = 0; char *table = MOUNTED;
144 if (sizeof mnt && sizeof table) return 0;]])],
145 [fu_cv_sys_mounted_getmntent1=yes],
146 [fu_cv_sys_mounted_getmntent1=no])])
147 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent1])
148 if test $fu_cv_sys_mounted_getmntent1 = yes; then
149 ac_list_mounted_fs=found
150 AC_DEFINE([MOUNTED_GETMNTENT1], [1],
151 [Define if there is a function named getmntent for reading the list
152 of mounted file systems, and that function takes a single argument.
153 (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
154 fi
155 fi
156
157 if test -z "$ac_list_mounted_fs"; then
158 # SVR4
159 AC_MSG_CHECKING([for two-argument getmntent function])
160 AC_CACHE_VAL([fu_cv_sys_mounted_getmntent2],
161 [AC_EGREP_HEADER([getmntent], [sys/mnttab.h],
162 fu_cv_sys_mounted_getmntent2=yes,
163 fu_cv_sys_mounted_getmntent2=no)])
164 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent2])
165 if test $fu_cv_sys_mounted_getmntent2 = yes; then
166 ac_list_mounted_fs=found
167 AC_DEFINE([MOUNTED_GETMNTENT2], [1],
168 [Define if there is a function named getmntent for reading the list of
169 mounted file systems, and that function takes two arguments. (SVR4)])
170 AC_CHECK_FUNCS([hasmntopt])
171 fi
172 fi
173
174fi
175
176if test -z "$ac_list_mounted_fs"; then
177 # DEC Alpha running OSF/1, and Apple Darwin 1.3.
178 # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h
179
180 AC_MSG_CHECKING([for getfsstat function])
181 AC_CACHE_VAL([fu_cv_sys_mounted_getfsstat],
182 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
183#include <sys/types.h>
184#if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
185# define FS_TYPE(Ent) ((Ent).f_fstypename)
186#else
187# define FS_TYPE(Ent) mnt_names[(Ent).f_type]
188#endif
189$getfsstat_includes]]
190,
191 [[struct statfs *stats;
192 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
193 char *t = FS_TYPE (*stats); ]])],
194 [fu_cv_sys_mounted_getfsstat=yes],
195 [fu_cv_sys_mounted_getfsstat=no])])
196 AC_MSG_RESULT([$fu_cv_sys_mounted_getfsstat])
197 if test $fu_cv_sys_mounted_getfsstat = yes; then
198 ac_list_mounted_fs=found
199 AC_DEFINE([MOUNTED_GETFSSTAT], [1],
200 [Define if there is a function named getfsstat for reading the
201 list of mounted file systems. (DEC Alpha running OSF/1)])
202 fi
203fi
204
205if test -z "$ac_list_mounted_fs"; then
206 # SVR3
207 AC_MSG_CHECKING([for FIXME existence of three headers])
208 AC_CACHE_VAL([fu_cv_sys_mounted_fread_fstyp],
209 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
210#include <sys/statfs.h>
211#include <sys/fstyp.h>
212#include <mnttab.h>]])],
213 [fu_cv_sys_mounted_fread_fstyp=yes],
214 [fu_cv_sys_mounted_fread_fstyp=no])])
215 AC_MSG_RESULT([$fu_cv_sys_mounted_fread_fstyp])
216 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
217 ac_list_mounted_fs=found
218 AC_DEFINE([MOUNTED_FREAD_FSTYP], [1],
219 [Define if (like SVR2) there is no specific function for reading the
220 list of mounted file systems, and your system has these header files:
221 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
222 fi
223fi
224
225if test -z "$ac_list_mounted_fs"; then
226 # 4.4BSD and DEC OSF/1.
227 AC_MSG_CHECKING([for getmntinfo function])
228 AC_CACHE_VAL([fu_cv_sys_mounted_getmntinfo],
229 [
230 test "$ac_cv_func_getmntinfo" = yes \
231 && fu_cv_sys_mounted_getmntinfo=yes \
232 || fu_cv_sys_mounted_getmntinfo=no
233 ])
234 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo])
235 if test $fu_cv_sys_mounted_getmntinfo = yes; then
236 AC_MSG_CHECKING([whether getmntinfo returns statvfs structures])
237 AC_CACHE_VAL([fu_cv_sys_mounted_getmntinfo2],
238 [
239 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
240#if HAVE_SYS_PARAM_H
241# include <sys/param.h>
242#endif
243#include <sys/types.h>
244#if HAVE_SYS_MOUNT_H
245# include <sys/mount.h>
246#endif
247#if HAVE_SYS_STATVFS_H
248# include <sys/statvfs.h>
249#endif
250extern
251#ifdef __cplusplus
252"C"
253#endif
254int getmntinfo (struct statfs **, int);
255 ]], [])],
256 [fu_cv_sys_mounted_getmntinfo2=no],
257 [fu_cv_sys_mounted_getmntinfo2=yes])
258 ])
259 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo2])
260 if test $fu_cv_sys_mounted_getmntinfo2 = no; then
261 ac_list_mounted_fs=found
262 AC_DEFINE([MOUNTED_GETMNTINFO], [1],
263 [Define if there is a function named getmntinfo for reading the
264 list of mounted file systems and it returns an array of
265 'struct statfs'. (4.4BSD, Darwin)])
266 else
267 ac_list_mounted_fs=found
268 AC_DEFINE([MOUNTED_GETMNTINFO2], [1],
269 [Define if there is a function named getmntinfo for reading the
270 list of mounted file systems and it returns an array of
271 'struct statvfs'. (NetBSD 3.0)])
272 fi
273 fi
274fi
275
276if test -z "$ac_list_mounted_fs"; then
277 # Ultrix
278 AC_MSG_CHECKING([for getmnt function])
279 AC_CACHE_VAL([fu_cv_sys_mounted_getmnt],
280 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
281#include <sys/fs_types.h>
282#include <sys/mount.h>]])],
283 [fu_cv_sys_mounted_getmnt=yes],
284 [fu_cv_sys_mounted_getmnt=no])])
285 AC_MSG_RESULT([$fu_cv_sys_mounted_getmnt])
286 if test $fu_cv_sys_mounted_getmnt = yes; then
287 ac_list_mounted_fs=found
288 AC_DEFINE([MOUNTED_GETMNT], [1],
289 [Define if there is a function named getmnt for reading the list of
290 mounted file systems. (Ultrix)])
291 fi
292fi
293
294if test -z "$ac_list_mounted_fs"; then
295 # BeOS
296 AC_CHECK_FUNCS([next_dev fs_stat_dev])
297 AC_CHECK_HEADERS([fs_info.h])
298 AC_MSG_CHECKING([for BEOS mounted file system support functions])
299 if test $ac_cv_header_fs_info_h = yes \
300 && test $ac_cv_func_next_dev = yes \
301 && test $ac_cv_func_fs_stat_dev = yes; then
302 fu_result=yes
303 else
304 fu_result=no
305 fi
306 AC_MSG_RESULT([$fu_result])
307 if test $fu_result = yes; then
308 ac_list_mounted_fs=found
309 AC_DEFINE([MOUNTED_FS_STAT_DEV], [1],
310 [Define if there are functions named next_dev and fs_stat_dev for
311 reading the list of mounted file systems. (BeOS)])
312 fi
313fi
314
315if test -z "$ac_list_mounted_fs"; then
316 # SVR2
317 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
318 AC_CACHE_VAL([fu_cv_sys_mounted_fread],
319 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <mnttab.h>]])],
320 [fu_cv_sys_mounted_fread=yes],
321 [fu_cv_sys_mounted_fread=no])])
322 AC_MSG_RESULT([$fu_cv_sys_mounted_fread])
323 if test $fu_cv_sys_mounted_fread = yes; then
324 ac_list_mounted_fs=found
325 AC_DEFINE([MOUNTED_FREAD], [1],
326 [Define if there is no specific function for reading the list of
327 mounted file systems. fread will be used to read /etc/mnttab.
328 (SVR2) ])
329 fi
330fi
331
332if test -z "$ac_list_mounted_fs"; then
333 # Interix / BSD alike statvfs
334 # the code is really interix specific, so make sure, we're on it.
335 case "$host" in
336 *-interix*)
337 AC_CHECK_FUNCS([statvfs])
338 if test $ac_cv_func_statvfs = yes; then
339 ac_list_mounted_fs=found
340 AC_DEFINE([MOUNTED_INTERIX_STATVFS], [1],
341 [Define if we are on interix, and ought to use statvfs plus
342 some special knowledge on where mounted file systems can be
343 found. (Interix)])
344 fi
345 ;;
346 esac
347fi
348
349if test -z "$ac_list_mounted_fs"; then
350 AC_MSG_ERROR([could not determine how to read list of mounted file systems])
351 # FIXME -- no need to abort building the whole package
352 # Can't build mountlist.c or anything that needs its functions
353fi
354
355AS_IF([test $ac_list_mounted_fs = found], [$1], [$2])
356
357 ])
diff --git a/gl/m4/lseek.m4 b/gl/m4/lseek.m4
new file mode 100644
index 00000000..fd4f1f27
--- /dev/null
+++ b/gl/m4/lseek.m4
@@ -0,0 +1,78 @@
1# lseek.m4 serial 12
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_LSEEK],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10
11 AC_REQUIRE([AC_CANONICAL_HOST])
12 AC_REQUIRE([AC_PROG_CC])
13 AC_CHECK_HEADERS_ONCE([unistd.h])
14 AC_CACHE_CHECK([whether lseek detects pipes], [gl_cv_func_lseek_pipe],
15 [case "$host_os" in
16 mingw*)
17 dnl Native Windows.
18 dnl The result of lseek (fd, (off_t)0, SEEK_CUR) or
19 dnl SetFilePointer(handle, 0, NULL, FILE_CURRENT)
20 dnl for a pipe depends on the environment: In a Cygwin 1.5
21 dnl environment it succeeds (wrong); in a Cygwin 1.7 environment
22 dnl it fails with a wrong errno value.
23 gl_cv_func_lseek_pipe=no
24 ;;
25 *)
26 if test $cross_compiling = no; then
27 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
28#include <sys/types.h> /* for off_t */
29#include <stdio.h> /* for SEEK_CUR */
30#if HAVE_UNISTD_H
31# include <unistd.h>
32#else /* on Windows with MSVC */
33# include <io.h>
34#endif
35]GL_MDA_DEFINES],
36[[
37 /* Exit with success only if stdin is seekable. */
38 return lseek (0, (off_t)0, SEEK_CUR) < 0;
39]])],
40 [if test -s conftest$ac_exeext \
41 && ./conftest$ac_exeext < conftest.$ac_ext \
42 && test 1 = "`echo hi \
43 | { ./conftest$ac_exeext; echo $?; cat >/dev/null; }`"; then
44 gl_cv_func_lseek_pipe=yes
45 else
46 gl_cv_func_lseek_pipe=no
47 fi
48 ],
49 [gl_cv_func_lseek_pipe=no])
50 else
51 AC_COMPILE_IFELSE(
52 [AC_LANG_SOURCE([[
53#if defined __BEOS__
54/* BeOS mistakenly return 0 when trying to seek on pipes. */
55 Choke me.
56#endif]])],
57 [gl_cv_func_lseek_pipe=yes], [gl_cv_func_lseek_pipe=no])
58 fi
59 ;;
60 esac
61 ])
62 if test "$gl_cv_func_lseek_pipe" = no; then
63 REPLACE_LSEEK=1
64 AC_DEFINE([LSEEK_PIPE_BROKEN], [1],
65 [Define to 1 if lseek does not detect pipes.])
66 fi
67
68 AC_REQUIRE([gl_SYS_TYPES_H])
69 if test $WINDOWS_64_BIT_OFF_T = 1; then
70 REPLACE_LSEEK=1
71 fi
72
73 dnl macOS SEEK_DATA is incompatible with other platforms.
74 case $host_os in
75 darwin*)
76 REPLACE_LSEEK=1;;
77 esac
78])
diff --git a/gl/m4/malloc.m4 b/gl/m4/malloc.m4
index 4b24a0b1..55402924 100644
--- a/gl/m4/malloc.m4
+++ b/gl/m4/malloc.m4
@@ -1,98 +1,175 @@
1# malloc.m4 serial 14 1# malloc.m4 serial 28
2dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7m4_version_prereq([2.70], [] ,[ 7# This is adapted with modifications from upstream Autoconf here:
8 8# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n949
9# This is taken from the following Autoconf patch:
10# http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9
11AC_DEFUN([_AC_FUNC_MALLOC_IF], 9AC_DEFUN([_AC_FUNC_MALLOC_IF],
12[ 10[
13 AC_REQUIRE([AC_HEADER_STDC])dnl
14 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles 11 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
15 AC_CHECK_HEADERS([stdlib.h]) 12 AC_CACHE_CHECK([whether malloc (0) returns nonnull],
16 AC_CACHE_CHECK([for GNU libc compatible malloc],
17 [ac_cv_func_malloc_0_nonnull], 13 [ac_cv_func_malloc_0_nonnull],
18 [AC_RUN_IFELSE( 14 [AC_RUN_IFELSE(
19 [AC_LANG_PROGRAM( 15 [AC_LANG_PROGRAM(
20 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H 16 [[#include <stdlib.h>
21 # include <stdlib.h>
22 #else
23 char *malloc ();
24 #endif
25 ]], 17 ]],
26 [[return ! malloc (0);]]) 18 [[void *p = malloc (0);
19 int result = !p;
20 free (p);
21 return result;]])
27 ], 22 ],
28 [ac_cv_func_malloc_0_nonnull=yes], 23 [ac_cv_func_malloc_0_nonnull=yes],
29 [ac_cv_func_malloc_0_nonnull=no], 24 [ac_cv_func_malloc_0_nonnull=no],
30 [case "$host_os" in 25 [case "$host_os" in
31 # Guess yes on platforms where we know the result. 26 # Guess yes on platforms where we know the result.
32 *-gnu* | freebsd* | netbsd* | openbsd* \ 27 *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
33 | hpux* | solaris* | cygwin* | mingw*) 28 | gnu* | *-musl* | midnightbsd* \
34 ac_cv_func_malloc_0_nonnull=yes ;; 29 | hpux* | solaris* | cygwin* | mingw* | msys* )
35 # If we don't know, assume the worst. 30 ac_cv_func_malloc_0_nonnull="guessing yes" ;;
36 *) ac_cv_func_malloc_0_nonnull=no ;; 31 # If we don't know, obey --enable-cross-guesses.
32 *) ac_cv_func_malloc_0_nonnull="$gl_cross_guess_normal" ;;
37 esac 33 esac
38 ]) 34 ])
39 ]) 35 ])
40 AS_IF([test $ac_cv_func_malloc_0_nonnull = yes], [$1], [$2]) 36 AS_CASE([$ac_cv_func_malloc_0_nonnull], [*yes], [$1], [$2])
41])# _AC_FUNC_MALLOC_IF 37])# _AC_FUNC_MALLOC_IF
42 38
43])
44
45# gl_FUNC_MALLOC_GNU 39# gl_FUNC_MALLOC_GNU
46# ------------------ 40# ------------------
47# Test whether 'malloc (0)' is handled like in GNU libc, and replace malloc if 41# Replace malloc if it is not compatible with GNU libc.
48# it is not.
49AC_DEFUN([gl_FUNC_MALLOC_GNU], 42AC_DEFUN([gl_FUNC_MALLOC_GNU],
50[ 43[
51 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 44 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
52 dnl _AC_FUNC_MALLOC_IF is defined in Autoconf. 45 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
53 _AC_FUNC_MALLOC_IF( 46 REPLACE_MALLOC_FOR_MALLOC_GNU="$REPLACE_MALLOC_FOR_MALLOC_POSIX"
54 [AC_DEFINE([HAVE_MALLOC_GNU], [1], 47 if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 0; then
55 [Define to 1 if your system has a GNU libc compatible 'malloc' 48 _AC_FUNC_MALLOC_IF([], [REPLACE_MALLOC_FOR_MALLOC_GNU=1])
56 function, and to 0 otherwise.])], 49 fi
57 [AC_DEFINE([HAVE_MALLOC_GNU], [0]) 50])
58 REPLACE_MALLOC=1 51
52# gl_FUNC_MALLOC_PTRDIFF
53# ----------------------
54# Test whether malloc (N) reliably fails when N exceeds PTRDIFF_MAX,
55# and replace malloc otherwise.
56AC_DEFUN([gl_FUNC_MALLOC_PTRDIFF],
57[
58 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
59 AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF])
60 test "$gl_cv_malloc_ptrdiff" = yes || REPLACE_MALLOC_FOR_MALLOC_POSIX=1
61])
62
63# Test whether malloc, realloc, calloc refuse to create objects
64# larger than what can be expressed in ptrdiff_t.
65# Set gl_cv_func_malloc_gnu to yes or no accordingly.
66AC_DEFUN([gl_CHECK_MALLOC_PTRDIFF],
67[
68 AC_CACHE_CHECK([whether malloc is ptrdiff_t safe],
69 [gl_cv_malloc_ptrdiff],
70 [AC_COMPILE_IFELSE(
71 [AC_LANG_PROGRAM(
72 [[#include <stdint.h>
73 ]],
74 [[/* 64-bit ptrdiff_t is so wide that no practical platform
75 can exceed it. */
76 #define WIDE_PTRDIFF (PTRDIFF_MAX >> 31 >> 31 != 0)
77
78 /* On rare machines where size_t fits in ptrdiff_t there
79 is no problem. */
80 #define NARROW_SIZE (SIZE_MAX <= PTRDIFF_MAX)
81
82 /* glibc 2.30 and later malloc refuses to exceed ptrdiff_t
83 bounds even on 32-bit platforms. We don't know which
84 non-glibc systems are safe. */
85 #define KNOWN_SAFE (2 < __GLIBC__ + (30 <= __GLIBC_MINOR__))
86
87 #if WIDE_PTRDIFF || NARROW_SIZE || KNOWN_SAFE
88 return 0;
89 #else
90 #error "malloc might not be ptrdiff_t safe"
91 syntax error
92 #endif
93 ]])],
94 [gl_cv_malloc_ptrdiff=yes],
95 [gl_cv_malloc_ptrdiff=no])
59 ]) 96 ])
60]) 97])
61 98
62# gl_FUNC_MALLOC_POSIX 99# gl_FUNC_MALLOC_POSIX
63# -------------------- 100# --------------------
64# Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it 101# Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it
65# fails), and replace malloc if it is not. 102# fails, and doesn't mess up with ptrdiff_t overflow), and replace
103# malloc if it is not.
66AC_DEFUN([gl_FUNC_MALLOC_POSIX], 104AC_DEFUN([gl_FUNC_MALLOC_POSIX],
67[ 105[
68 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 106 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
107 AC_REQUIRE([gl_FUNC_MALLOC_PTRDIFF])
69 AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) 108 AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
70 if test $gl_cv_func_malloc_posix = yes; then 109 if test "$gl_cv_func_malloc_posix" = yes; then
71 AC_DEFINE([HAVE_MALLOC_POSIX], [1], 110 AC_DEFINE([HAVE_MALLOC_POSIX], [1],
72 [Define if the 'malloc' function is POSIX compliant.]) 111 [Define if malloc, realloc, and calloc set errno on allocation failure.])
73 else 112 else
74 REPLACE_MALLOC=1 113 REPLACE_MALLOC_FOR_MALLOC_POSIX=1
75 fi 114 fi
76]) 115])
77 116
78# Test whether malloc, realloc, calloc are POSIX compliant, 117# Test whether malloc, realloc, calloc set errno to ENOMEM on failure.
79# Set gl_cv_func_malloc_posix to yes or no accordingly. 118# Set gl_cv_func_malloc_posix to yes or no accordingly.
80AC_DEFUN([gl_CHECK_MALLOC_POSIX], 119AC_DEFUN([gl_CHECK_MALLOC_POSIX],
81[ 120[
82 AC_CACHE_CHECK([whether malloc, realloc, calloc are POSIX compliant], 121 AC_REQUIRE([AC_CANONICAL_HOST])
122 AC_CACHE_CHECK([whether malloc, realloc, calloc set errno on failure],
83 [gl_cv_func_malloc_posix], 123 [gl_cv_func_malloc_posix],
84 [ 124 [
85 dnl It is too dangerous to try to allocate a large amount of memory: 125 dnl It is too dangerous to try to allocate a large amount of memory:
86 dnl some systems go to their knees when you do that. So assume that 126 dnl some systems go to their knees when you do that. So assume that
87 dnl all Unix implementations of the function are POSIX compliant. 127 dnl all Unix implementations of the function set errno on failure,
88 AC_COMPILE_IFELSE( 128 dnl except on those platforms where we have seen 'test-malloc-gnu',
89 [AC_LANG_PROGRAM( 129 dnl 'test-realloc-gnu', 'test-calloc-gnu' fail.
90 [[]], 130 case "$host_os" in
91 [[#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 131 mingw*)
92 choke me 132 gl_cv_func_malloc_posix=no ;;
93 #endif 133 irix* | solaris*)
94 ]])], 134 dnl On IRIX 6.5, the three functions return NULL with errno unset
95 [gl_cv_func_malloc_posix=yes], 135 dnl when the argument is larger than PTRDIFF_MAX.
96 [gl_cv_func_malloc_posix=no]) 136 dnl On Solaris 11.3, the three functions return NULL with errno set
137 dnl to EAGAIN, not ENOMEM, when the argument is larger than
138 dnl PTRDIFF_MAX.
139 dnl Here is a test program:
140m4_divert_push([KILL])
141#include <errno.h>
142#include <stdio.h>
143#include <stdlib.h>
144#define ptrdiff_t long
145#ifndef PTRDIFF_MAX
146# define PTRDIFF_MAX ((ptrdiff_t) ((1UL << (8 * sizeof (ptrdiff_t) - 1)) - 1))
147#endif
148
149int main ()
150{
151 void *p;
152
153 fprintf (stderr, "PTRDIFF_MAX = %lu\n", (unsigned long) PTRDIFF_MAX);
154
155 errno = 0;
156 p = malloc ((unsigned long) PTRDIFF_MAX + 1);
157 fprintf (stderr, "p=%p errno=%d\n", p, errno);
158
159 errno = 0;
160 p = calloc (PTRDIFF_MAX / 2 + 1, 2);
161 fprintf (stderr, "p=%p errno=%d\n", p, errno);
162
163 errno = 0;
164 p = realloc (NULL, (unsigned long) PTRDIFF_MAX + 1);
165 fprintf (stderr, "p=%p errno=%d\n", p, errno);
166
167 return 0;
168}
169m4_divert_pop([KILL])
170 gl_cv_func_malloc_posix=no ;;
171 *)
172 gl_cv_func_malloc_posix=yes ;;
173 esac
97 ]) 174 ])
98]) 175])
diff --git a/gl/m4/malloca.m4 b/gl/m4/malloca.m4
index 791ce10d..1d777ebe 100644
--- a/gl/m4/malloca.m4
+++ b/gl/m4/malloca.m4
@@ -1,5 +1,5 @@
1# malloca.m4 serial 1 1# malloca.m4 serial 2
2dnl Copyright (C) 2003-2004, 2006-2007, 2009-2013 Free Software Foundation, 2dnl Copyright (C) 2003-2004, 2006-2007, 2009-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -11,5 +11,4 @@ AC_DEFUN([gl_MALLOCA],
11 dnl @ALLOCA@ and @LTALLOCA@. 11 dnl @ALLOCA@ and @LTALLOCA@.
12 dnl gl_FUNC_ALLOCA dnl Already brought in by the module dependencies. 12 dnl gl_FUNC_ALLOCA dnl Already brought in by the module dependencies.
13 AC_REQUIRE([gl_EEMALLOC]) 13 AC_REQUIRE([gl_EEMALLOC])
14 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
15]) 14])
diff --git a/gl/m4/math_h.m4 b/gl/m4/math_h.m4
index bf0845fd..d2e90ff1 100644
--- a/gl/m4/math_h.m4
+++ b/gl/m4/math_h.m4
@@ -1,16 +1,16 @@
1# math_h.m4 serial 114 1# math_h.m4 serial 125
2dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_MATH_H], 7AC_DEFUN_ONCE([gl_MATH_H],
8[ 8[
9 AC_REQUIRE([gl_MATH_H_DEFAULTS]) 9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
10 gl_CHECK_NEXT_HEADERS([math.h]) 10 gl_CHECK_NEXT_HEADERS([math.h])
11 11
12 AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works], 12 AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works],
13 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]], 13 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]],
14 [[/* Solaris 10 has a broken definition of NAN. Other platforms 14 [[/* Solaris 10 has a broken definition of NAN. Other platforms
15 fail to provide NAN, or provide it only in C99 mode; this 15 fail to provide NAN, or provide it only in C99 mode; this
16 test only needs to fail when NAN is provided but wrong. */ 16 test only needs to fail when NAN is provided but wrong. */
@@ -25,7 +25,7 @@ AC_DEFUN([gl_MATH_H],
25 REPLACE_NAN=1 25 REPLACE_NAN=1
26 fi 26 fi
27 AC_CACHE_CHECK([whether HUGE_VAL works], [gl_cv_header_math_huge_val_works], 27 AC_CACHE_CHECK([whether HUGE_VAL works], [gl_cv_header_math_huge_val_works],
28 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]], 28 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]],
29 [[/* Solaris 10 has a broken definition of HUGE_VAL. */ 29 [[/* Solaris 10 has a broken definition of HUGE_VAL. */
30 double d = HUGE_VAL; 30 double d = HUGE_VAL;
31 return d == 0;]])], 31 return d == 0;]])],
@@ -53,272 +53,310 @@ AC_DEFUN([gl_MATH_H],
53 tanf tanl tanhf trunc truncf truncl]) 53 tanf tanl tanhf trunc truncf truncl])
54]) 54])
55 55
56# gl_MATH_MODULE_INDICATOR([modulename])
57# sets the shell variable that indicates the presence of the given module
58# to a C preprocessor expression that will evaluate to 1.
59# This macro invocation must not occur in macros that are AC_REQUIREd.
56AC_DEFUN([gl_MATH_MODULE_INDICATOR], 60AC_DEFUN([gl_MATH_MODULE_INDICATOR],
57[ 61[
58 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 62 dnl Ensure to expand the default settings once only.
59 AC_REQUIRE([gl_MATH_H_DEFAULTS]) 63 gl_MATH_H_REQUIRE_DEFAULTS
60 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 64 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
61 dnl Define it also as a C macro, for the benefit of the unit tests. 65 dnl Define it also as a C macro, for the benefit of the unit tests.
62 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 66 gl_MODULE_INDICATOR_FOR_TESTS([$1])
63]) 67])
64 68
69# Initializes the default values for AC_SUBSTed shell variables.
70# This macro must not be AC_REQUIREd. It must only be invoked, and only
71# outside of macros or in macros that are not AC_REQUIREd.
72AC_DEFUN([gl_MATH_H_REQUIRE_DEFAULTS],
73[
74 m4_defun(GL_MODULE_INDICATOR_PREFIX[_MATH_H_MODULE_INDICATOR_DEFAULTS], [
75 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACOSF])
76 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACOSL])
77 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ASINF])
78 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ASINL])
79 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATANF])
80 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATANL])
81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATAN2F])
82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CBRT])
83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CBRTF])
84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CBRTL])
85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CEIL])
86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CEILF])
87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CEILL])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPYSIGN])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPYSIGNF])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPYSIGNL])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COSF])
92 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COSL])
93 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COSHF])
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPF])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPL])
96 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXP2])
97 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXP2F])
98 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXP2L])
99 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPM1])
100 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPM1F])
101 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPM1L])
102 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FABSF])
103 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FABSL])
104 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FLOOR])
105 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FLOORF])
106 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FLOORL])
107 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMA])
108 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMAF])
109 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMAL])
110 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMOD])
111 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMODF])
112 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMODL])
113 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXPF])
114 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXP])
115 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXPL])
116 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOT])
117 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOTF])
118 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOTL])
119 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGB])
120 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGBF])
121 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGBL])
122 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISFINITE])
123 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISINF])
124 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNAN])
125 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNANF])
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNAND])
127 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNANL])
128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXPF])
129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXPL])
130 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG])
131 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGF])
132 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGL])
133 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG10])
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG10F])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG10L])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG1P])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG1PF])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG1PL])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG2])
140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG2F])
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG2L])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGB])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGBF])
144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGBL])
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODF])
146 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFF])
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFL])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POWF])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMAINDER])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMAINDERF])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMAINDERL])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RINT])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RINTF])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RINTL])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUND])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUNDF])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUNDL])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGNBIT])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINF])
160 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINL])
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINHF])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SQRTF])
163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SQRTL])
164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANF])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANL])
166 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANHF])
167 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNC])
168 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCF])
169 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCL])
170 dnl Support Microsoft deprecated alias function names by default.
171 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_J0], [1])
172 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_J1], [1])
173 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_JN], [1])
174 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_Y0], [1])
175 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_Y1], [1])
176 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_YN], [1])
177 ])
178 m4_require(GL_MODULE_INDICATOR_PREFIX[_MATH_H_MODULE_INDICATOR_DEFAULTS])
179 AC_REQUIRE([gl_MATH_H_DEFAULTS])
180])
181
65AC_DEFUN([gl_MATH_H_DEFAULTS], 182AC_DEFUN([gl_MATH_H_DEFAULTS],
66[ 183[
67 GNULIB_ACOSF=0; AC_SUBST([GNULIB_ACOSF])
68 GNULIB_ACOSL=0; AC_SUBST([GNULIB_ACOSL])
69 GNULIB_ASINF=0; AC_SUBST([GNULIB_ASINF])
70 GNULIB_ASINL=0; AC_SUBST([GNULIB_ASINL])
71 GNULIB_ATANF=0; AC_SUBST([GNULIB_ATANF])
72 GNULIB_ATANL=0; AC_SUBST([GNULIB_ATANL])
73 GNULIB_ATAN2F=0; AC_SUBST([GNULIB_ATAN2F])
74 GNULIB_CBRT=0; AC_SUBST([GNULIB_CBRT])
75 GNULIB_CBRTF=0; AC_SUBST([GNULIB_CBRTF])
76 GNULIB_CBRTL=0; AC_SUBST([GNULIB_CBRTL])
77 GNULIB_CEIL=0; AC_SUBST([GNULIB_CEIL])
78 GNULIB_CEILF=0; AC_SUBST([GNULIB_CEILF])
79 GNULIB_CEILL=0; AC_SUBST([GNULIB_CEILL])
80 GNULIB_COPYSIGN=0; AC_SUBST([GNULIB_COPYSIGN])
81 GNULIB_COPYSIGNF=0; AC_SUBST([GNULIB_COPYSIGNF])
82 GNULIB_COPYSIGNL=0; AC_SUBST([GNULIB_COPYSIGNL])
83 GNULIB_COSF=0; AC_SUBST([GNULIB_COSF])
84 GNULIB_COSL=0; AC_SUBST([GNULIB_COSL])
85 GNULIB_COSHF=0; AC_SUBST([GNULIB_COSHF])
86 GNULIB_EXPF=0; AC_SUBST([GNULIB_EXPF])
87 GNULIB_EXPL=0; AC_SUBST([GNULIB_EXPL])
88 GNULIB_EXP2=0; AC_SUBST([GNULIB_EXP2])
89 GNULIB_EXP2F=0; AC_SUBST([GNULIB_EXP2F])
90 GNULIB_EXP2L=0; AC_SUBST([GNULIB_EXP2L])
91 GNULIB_EXPM1=0; AC_SUBST([GNULIB_EXPM1])
92 GNULIB_EXPM1F=0; AC_SUBST([GNULIB_EXPM1F])
93 GNULIB_EXPM1L=0; AC_SUBST([GNULIB_EXPM1L])
94 GNULIB_FABSF=0; AC_SUBST([GNULIB_FABSF])
95 GNULIB_FABSL=0; AC_SUBST([GNULIB_FABSL])
96 GNULIB_FLOOR=0; AC_SUBST([GNULIB_FLOOR])
97 GNULIB_FLOORF=0; AC_SUBST([GNULIB_FLOORF])
98 GNULIB_FLOORL=0; AC_SUBST([GNULIB_FLOORL])
99 GNULIB_FMA=0; AC_SUBST([GNULIB_FMA])
100 GNULIB_FMAF=0; AC_SUBST([GNULIB_FMAF])
101 GNULIB_FMAL=0; AC_SUBST([GNULIB_FMAL])
102 GNULIB_FMOD=0; AC_SUBST([GNULIB_FMOD])
103 GNULIB_FMODF=0; AC_SUBST([GNULIB_FMODF])
104 GNULIB_FMODL=0; AC_SUBST([GNULIB_FMODL])
105 GNULIB_FREXPF=0; AC_SUBST([GNULIB_FREXPF])
106 GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP])
107 GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL])
108 GNULIB_HYPOT=0; AC_SUBST([GNULIB_HYPOT])
109 GNULIB_HYPOTF=0; AC_SUBST([GNULIB_HYPOTF])
110 GNULIB_HYPOTL=0; AC_SUBST([GNULIB_HYPOTL])
111 GNULIB_ILOGB=0; AC_SUBST([GNULIB_ILOGB])
112 GNULIB_ILOGBF=0; AC_SUBST([GNULIB_ILOGBF])
113 GNULIB_ILOGBL=0; AC_SUBST([GNULIB_ILOGBL])
114 GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE])
115 GNULIB_ISINF=0; AC_SUBST([GNULIB_ISINF])
116 GNULIB_ISNAN=0; AC_SUBST([GNULIB_ISNAN])
117 GNULIB_ISNANF=0; AC_SUBST([GNULIB_ISNANF])
118 GNULIB_ISNAND=0; AC_SUBST([GNULIB_ISNAND])
119 GNULIB_ISNANL=0; AC_SUBST([GNULIB_ISNANL])
120 GNULIB_LDEXPF=0; AC_SUBST([GNULIB_LDEXPF])
121 GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL])
122 GNULIB_LOG=0; AC_SUBST([GNULIB_LOG])
123 GNULIB_LOGF=0; AC_SUBST([GNULIB_LOGF])
124 GNULIB_LOGL=0; AC_SUBST([GNULIB_LOGL])
125 GNULIB_LOG10=0; AC_SUBST([GNULIB_LOG10])
126 GNULIB_LOG10F=0; AC_SUBST([GNULIB_LOG10F])
127 GNULIB_LOG10L=0; AC_SUBST([GNULIB_LOG10L])
128 GNULIB_LOG1P=0; AC_SUBST([GNULIB_LOG1P])
129 GNULIB_LOG1PF=0; AC_SUBST([GNULIB_LOG1PF])
130 GNULIB_LOG1PL=0; AC_SUBST([GNULIB_LOG1PL])
131 GNULIB_LOG2=0; AC_SUBST([GNULIB_LOG2])
132 GNULIB_LOG2F=0; AC_SUBST([GNULIB_LOG2F])
133 GNULIB_LOG2L=0; AC_SUBST([GNULIB_LOG2L])
134 GNULIB_LOGB=0; AC_SUBST([GNULIB_LOGB])
135 GNULIB_LOGBF=0; AC_SUBST([GNULIB_LOGBF])
136 GNULIB_LOGBL=0; AC_SUBST([GNULIB_LOGBL])
137 GNULIB_MODF=0; AC_SUBST([GNULIB_MODF])
138 GNULIB_MODFF=0; AC_SUBST([GNULIB_MODFF])
139 GNULIB_MODFL=0; AC_SUBST([GNULIB_MODFL])
140 GNULIB_POWF=0; AC_SUBST([GNULIB_POWF])
141 GNULIB_REMAINDER=0; AC_SUBST([GNULIB_REMAINDER])
142 GNULIB_REMAINDERF=0; AC_SUBST([GNULIB_REMAINDERF])
143 GNULIB_REMAINDERL=0; AC_SUBST([GNULIB_REMAINDERL])
144 GNULIB_RINT=0; AC_SUBST([GNULIB_RINT])
145 GNULIB_RINTF=0; AC_SUBST([GNULIB_RINTF])
146 GNULIB_RINTL=0; AC_SUBST([GNULIB_RINTL])
147 GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND])
148 GNULIB_ROUNDF=0; AC_SUBST([GNULIB_ROUNDF])
149 GNULIB_ROUNDL=0; AC_SUBST([GNULIB_ROUNDL])
150 GNULIB_SIGNBIT=0; AC_SUBST([GNULIB_SIGNBIT])
151 GNULIB_SINF=0; AC_SUBST([GNULIB_SINF])
152 GNULIB_SINL=0; AC_SUBST([GNULIB_SINL])
153 GNULIB_SINHF=0; AC_SUBST([GNULIB_SINHF])
154 GNULIB_SQRTF=0; AC_SUBST([GNULIB_SQRTF])
155 GNULIB_SQRTL=0; AC_SUBST([GNULIB_SQRTL])
156 GNULIB_TANF=0; AC_SUBST([GNULIB_TANF])
157 GNULIB_TANL=0; AC_SUBST([GNULIB_TANL])
158 GNULIB_TANHF=0; AC_SUBST([GNULIB_TANHF])
159 GNULIB_TRUNC=0; AC_SUBST([GNULIB_TRUNC])
160 GNULIB_TRUNCF=0; AC_SUBST([GNULIB_TRUNCF])
161 GNULIB_TRUNCL=0; AC_SUBST([GNULIB_TRUNCL])
162 dnl Assume proper GNU behavior unless another module says otherwise. 184 dnl Assume proper GNU behavior unless another module says otherwise.
163 HAVE_ACOSF=1; AC_SUBST([HAVE_ACOSF]) 185 HAVE_ACOSF=1; AC_SUBST([HAVE_ACOSF])
164 HAVE_ACOSL=1; AC_SUBST([HAVE_ACOSL]) 186 HAVE_ACOSL=1; AC_SUBST([HAVE_ACOSL])
165 HAVE_ASINF=1; AC_SUBST([HAVE_ASINF]) 187 HAVE_ASINF=1; AC_SUBST([HAVE_ASINF])
166 HAVE_ASINL=1; AC_SUBST([HAVE_ASINL]) 188 HAVE_ASINL=1; AC_SUBST([HAVE_ASINL])
167 HAVE_ATANF=1; AC_SUBST([HAVE_ATANF]) 189 HAVE_ATANF=1; AC_SUBST([HAVE_ATANF])
168 HAVE_ATANL=1; AC_SUBST([HAVE_ATANL]) 190 HAVE_ATANL=1; AC_SUBST([HAVE_ATANL])
169 HAVE_ATAN2F=1; AC_SUBST([HAVE_ATAN2F]) 191 HAVE_ATAN2F=1; AC_SUBST([HAVE_ATAN2F])
170 HAVE_CBRT=1; AC_SUBST([HAVE_CBRT]) 192 HAVE_CBRT=1; AC_SUBST([HAVE_CBRT])
171 HAVE_CBRTF=1; AC_SUBST([HAVE_CBRTF]) 193 HAVE_CBRTF=1; AC_SUBST([HAVE_CBRTF])
172 HAVE_CBRTL=1; AC_SUBST([HAVE_CBRTL]) 194 HAVE_CBRTL=1; AC_SUBST([HAVE_CBRTL])
173 HAVE_COPYSIGN=1; AC_SUBST([HAVE_COPYSIGN]) 195 HAVE_COPYSIGN=1; AC_SUBST([HAVE_COPYSIGN])
174 HAVE_COPYSIGNL=1; AC_SUBST([HAVE_COPYSIGNL]) 196 HAVE_COPYSIGNL=1; AC_SUBST([HAVE_COPYSIGNL])
175 HAVE_COSF=1; AC_SUBST([HAVE_COSF]) 197 HAVE_COSF=1; AC_SUBST([HAVE_COSF])
176 HAVE_COSL=1; AC_SUBST([HAVE_COSL]) 198 HAVE_COSL=1; AC_SUBST([HAVE_COSL])
177 HAVE_COSHF=1; AC_SUBST([HAVE_COSHF]) 199 HAVE_COSHF=1; AC_SUBST([HAVE_COSHF])
178 HAVE_EXPF=1; AC_SUBST([HAVE_EXPF]) 200 HAVE_EXPF=1; AC_SUBST([HAVE_EXPF])
179 HAVE_EXPL=1; AC_SUBST([HAVE_EXPL]) 201 HAVE_EXPL=1; AC_SUBST([HAVE_EXPL])
180 HAVE_EXPM1=1; AC_SUBST([HAVE_EXPM1]) 202 HAVE_EXPM1=1; AC_SUBST([HAVE_EXPM1])
181 HAVE_EXPM1F=1; AC_SUBST([HAVE_EXPM1F]) 203 HAVE_EXPM1F=1; AC_SUBST([HAVE_EXPM1F])
182 HAVE_FABSF=1; AC_SUBST([HAVE_FABSF]) 204 HAVE_FABSF=1; AC_SUBST([HAVE_FABSF])
183 HAVE_FABSL=1; AC_SUBST([HAVE_FABSL]) 205 HAVE_FABSL=1; AC_SUBST([HAVE_FABSL])
184 HAVE_FMA=1; AC_SUBST([HAVE_FMA]) 206 HAVE_FMA=1; AC_SUBST([HAVE_FMA])
185 HAVE_FMAF=1; AC_SUBST([HAVE_FMAF]) 207 HAVE_FMAF=1; AC_SUBST([HAVE_FMAF])
186 HAVE_FMAL=1; AC_SUBST([HAVE_FMAL]) 208 HAVE_FMAL=1; AC_SUBST([HAVE_FMAL])
187 HAVE_FMODF=1; AC_SUBST([HAVE_FMODF]) 209 HAVE_FMODF=1; AC_SUBST([HAVE_FMODF])
188 HAVE_FMODL=1; AC_SUBST([HAVE_FMODL]) 210 HAVE_FMODL=1; AC_SUBST([HAVE_FMODL])
189 HAVE_FREXPF=1; AC_SUBST([HAVE_FREXPF]) 211 HAVE_FREXPF=1; AC_SUBST([HAVE_FREXPF])
190 HAVE_HYPOTF=1; AC_SUBST([HAVE_HYPOTF]) 212 HAVE_HYPOTF=1; AC_SUBST([HAVE_HYPOTF])
191 HAVE_HYPOTL=1; AC_SUBST([HAVE_HYPOTL]) 213 HAVE_HYPOTL=1; AC_SUBST([HAVE_HYPOTL])
192 HAVE_ILOGB=1; AC_SUBST([HAVE_ILOGB]) 214 HAVE_ILOGB=1; AC_SUBST([HAVE_ILOGB])
193 HAVE_ILOGBF=1; AC_SUBST([HAVE_ILOGBF]) 215 HAVE_ILOGBF=1; AC_SUBST([HAVE_ILOGBF])
194 HAVE_ILOGBL=1; AC_SUBST([HAVE_ILOGBL]) 216 HAVE_ILOGBL=1; AC_SUBST([HAVE_ILOGBL])
195 HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF]) 217 HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF])
196 HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND]) 218 HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND])
197 HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL]) 219 HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL])
198 HAVE_LDEXPF=1; AC_SUBST([HAVE_LDEXPF]) 220 HAVE_LDEXPF=1; AC_SUBST([HAVE_LDEXPF])
199 HAVE_LOGF=1; AC_SUBST([HAVE_LOGF]) 221 HAVE_LOGF=1; AC_SUBST([HAVE_LOGF])
200 HAVE_LOGL=1; AC_SUBST([HAVE_LOGL]) 222 HAVE_LOGL=1; AC_SUBST([HAVE_LOGL])
201 HAVE_LOG10F=1; AC_SUBST([HAVE_LOG10F]) 223 HAVE_LOG10F=1; AC_SUBST([HAVE_LOG10F])
202 HAVE_LOG10L=1; AC_SUBST([HAVE_LOG10L]) 224 HAVE_LOG10L=1; AC_SUBST([HAVE_LOG10L])
203 HAVE_LOG1P=1; AC_SUBST([HAVE_LOG1P]) 225 HAVE_LOG1P=1; AC_SUBST([HAVE_LOG1P])
204 HAVE_LOG1PF=1; AC_SUBST([HAVE_LOG1PF]) 226 HAVE_LOG1PF=1; AC_SUBST([HAVE_LOG1PF])
205 HAVE_LOG1PL=1; AC_SUBST([HAVE_LOG1PL]) 227 HAVE_LOG1PL=1; AC_SUBST([HAVE_LOG1PL])
206 HAVE_LOGBF=1; AC_SUBST([HAVE_LOGBF]) 228 HAVE_LOGBF=1; AC_SUBST([HAVE_LOGBF])
207 HAVE_LOGBL=1; AC_SUBST([HAVE_LOGBL]) 229 HAVE_LOGBL=1; AC_SUBST([HAVE_LOGBL])
208 HAVE_MODFF=1; AC_SUBST([HAVE_MODFF]) 230 HAVE_MODFF=1; AC_SUBST([HAVE_MODFF])
209 HAVE_MODFL=1; AC_SUBST([HAVE_MODFL]) 231 HAVE_MODFL=1; AC_SUBST([HAVE_MODFL])
210 HAVE_POWF=1; AC_SUBST([HAVE_POWF]) 232 HAVE_POWF=1; AC_SUBST([HAVE_POWF])
211 HAVE_REMAINDER=1; AC_SUBST([HAVE_REMAINDER]) 233 HAVE_REMAINDER=1; AC_SUBST([HAVE_REMAINDER])
212 HAVE_REMAINDERF=1; AC_SUBST([HAVE_REMAINDERF]) 234 HAVE_REMAINDERF=1; AC_SUBST([HAVE_REMAINDERF])
213 HAVE_RINT=1; AC_SUBST([HAVE_RINT]) 235 HAVE_RINT=1; AC_SUBST([HAVE_RINT])
214 HAVE_RINTL=1; AC_SUBST([HAVE_RINTL]) 236 HAVE_RINTL=1; AC_SUBST([HAVE_RINTL])
215 HAVE_SINF=1; AC_SUBST([HAVE_SINF]) 237 HAVE_SINF=1; AC_SUBST([HAVE_SINF])
216 HAVE_SINL=1; AC_SUBST([HAVE_SINL]) 238 HAVE_SINL=1; AC_SUBST([HAVE_SINL])
217 HAVE_SINHF=1; AC_SUBST([HAVE_SINHF]) 239 HAVE_SINHF=1; AC_SUBST([HAVE_SINHF])
218 HAVE_SQRTF=1; AC_SUBST([HAVE_SQRTF]) 240 HAVE_SQRTF=1; AC_SUBST([HAVE_SQRTF])
219 HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL]) 241 HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL])
220 HAVE_TANF=1; AC_SUBST([HAVE_TANF]) 242 HAVE_TANF=1; AC_SUBST([HAVE_TANF])
221 HAVE_TANL=1; AC_SUBST([HAVE_TANL]) 243 HAVE_TANL=1; AC_SUBST([HAVE_TANL])
222 HAVE_TANHF=1; AC_SUBST([HAVE_TANHF]) 244 HAVE_TANHF=1; AC_SUBST([HAVE_TANHF])
223 HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL]) 245 HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL])
224 HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL]) 246 HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL])
225 HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL]) 247 HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL])
226 HAVE_DECL_CBRTF=1; AC_SUBST([HAVE_DECL_CBRTF]) 248 HAVE_DECL_CBRTF=1; AC_SUBST([HAVE_DECL_CBRTF])
227 HAVE_DECL_CBRTL=1; AC_SUBST([HAVE_DECL_CBRTL]) 249 HAVE_DECL_CBRTL=1; AC_SUBST([HAVE_DECL_CBRTL])
228 HAVE_DECL_CEILF=1; AC_SUBST([HAVE_DECL_CEILF]) 250 HAVE_DECL_CEILF=1; AC_SUBST([HAVE_DECL_CEILF])
229 HAVE_DECL_CEILL=1; AC_SUBST([HAVE_DECL_CEILL]) 251 HAVE_DECL_CEILL=1; AC_SUBST([HAVE_DECL_CEILL])
230 HAVE_DECL_COPYSIGNF=1; AC_SUBST([HAVE_DECL_COPYSIGNF]) 252 HAVE_DECL_COPYSIGNF=1; AC_SUBST([HAVE_DECL_COPYSIGNF])
231 HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL]) 253 HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL])
232 HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL]) 254 HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL])
233 HAVE_DECL_EXP2=1; AC_SUBST([HAVE_DECL_EXP2]) 255 HAVE_DECL_EXP2=1; AC_SUBST([HAVE_DECL_EXP2])
234 HAVE_DECL_EXP2F=1; AC_SUBST([HAVE_DECL_EXP2F]) 256 HAVE_DECL_EXP2F=1; AC_SUBST([HAVE_DECL_EXP2F])
235 HAVE_DECL_EXP2L=1; AC_SUBST([HAVE_DECL_EXP2L]) 257 HAVE_DECL_EXP2L=1; AC_SUBST([HAVE_DECL_EXP2L])
236 HAVE_DECL_EXPM1L=1; AC_SUBST([HAVE_DECL_EXPM1L]) 258 HAVE_DECL_EXPM1L=1; AC_SUBST([HAVE_DECL_EXPM1L])
237 HAVE_DECL_FLOORF=1; AC_SUBST([HAVE_DECL_FLOORF]) 259 HAVE_DECL_FLOORF=1; AC_SUBST([HAVE_DECL_FLOORF])
238 HAVE_DECL_FLOORL=1; AC_SUBST([HAVE_DECL_FLOORL]) 260 HAVE_DECL_FLOORL=1; AC_SUBST([HAVE_DECL_FLOORL])
239 HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL]) 261 HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL])
240 HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL]) 262 HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL])
241 HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL]) 263 HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL])
242 HAVE_DECL_LOG10L=1; AC_SUBST([HAVE_DECL_LOG10L]) 264 HAVE_DECL_LOG10L=1; AC_SUBST([HAVE_DECL_LOG10L])
243 HAVE_DECL_LOG2=1; AC_SUBST([HAVE_DECL_LOG2]) 265 HAVE_DECL_LOG2=1; AC_SUBST([HAVE_DECL_LOG2])
244 HAVE_DECL_LOG2F=1; AC_SUBST([HAVE_DECL_LOG2F]) 266 HAVE_DECL_LOG2F=1; AC_SUBST([HAVE_DECL_LOG2F])
245 HAVE_DECL_LOG2L=1; AC_SUBST([HAVE_DECL_LOG2L]) 267 HAVE_DECL_LOG2L=1; AC_SUBST([HAVE_DECL_LOG2L])
246 HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB]) 268 HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB])
247 HAVE_DECL_REMAINDER=1; AC_SUBST([HAVE_DECL_REMAINDER]) 269 HAVE_DECL_REMAINDER=1; AC_SUBST([HAVE_DECL_REMAINDER])
248 HAVE_DECL_REMAINDERL=1; AC_SUBST([HAVE_DECL_REMAINDERL]) 270 HAVE_DECL_REMAINDERL=1; AC_SUBST([HAVE_DECL_REMAINDERL])
249 HAVE_DECL_RINTF=1; AC_SUBST([HAVE_DECL_RINTF]) 271 HAVE_DECL_RINTF=1; AC_SUBST([HAVE_DECL_RINTF])
250 HAVE_DECL_ROUND=1; AC_SUBST([HAVE_DECL_ROUND]) 272 HAVE_DECL_ROUND=1; AC_SUBST([HAVE_DECL_ROUND])
251 HAVE_DECL_ROUNDF=1; AC_SUBST([HAVE_DECL_ROUNDF]) 273 HAVE_DECL_ROUNDF=1; AC_SUBST([HAVE_DECL_ROUNDF])
252 HAVE_DECL_ROUNDL=1; AC_SUBST([HAVE_DECL_ROUNDL]) 274 HAVE_DECL_ROUNDL=1; AC_SUBST([HAVE_DECL_ROUNDL])
253 HAVE_DECL_SINL=1; AC_SUBST([HAVE_DECL_SINL]) 275 HAVE_DECL_SINL=1; AC_SUBST([HAVE_DECL_SINL])
254 HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL]) 276 HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL])
255 HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL]) 277 HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL])
256 HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC]) 278 HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC])
257 HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF]) 279 HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF])
258 HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL]) 280 HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL])
259 REPLACE_CBRTF=0; AC_SUBST([REPLACE_CBRTF]) 281 REPLACE_ACOSF=0; AC_SUBST([REPLACE_ACOSF])
260 REPLACE_CBRTL=0; AC_SUBST([REPLACE_CBRTL]) 282 REPLACE_ASINF=0; AC_SUBST([REPLACE_ASINF])
261 REPLACE_CEIL=0; AC_SUBST([REPLACE_CEIL]) 283 REPLACE_ATANF=0; AC_SUBST([REPLACE_ATANF])
262 REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF]) 284 REPLACE_ATAN2F=0; AC_SUBST([REPLACE_ATAN2F])
263 REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL]) 285 REPLACE_CBRTF=0; AC_SUBST([REPLACE_CBRTF])
264 REPLACE_EXPM1=0; AC_SUBST([REPLACE_EXPM1]) 286 REPLACE_CBRTL=0; AC_SUBST([REPLACE_CBRTL])
265 REPLACE_EXPM1F=0; AC_SUBST([REPLACE_EXPM1F]) 287 REPLACE_CEIL=0; AC_SUBST([REPLACE_CEIL])
266 REPLACE_EXP2=0; AC_SUBST([REPLACE_EXP2]) 288 REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF])
267 REPLACE_EXP2L=0; AC_SUBST([REPLACE_EXP2L]) 289 REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL])
268 REPLACE_FABSL=0; AC_SUBST([REPLACE_FABSL]) 290 REPLACE_COSF=0; AC_SUBST([REPLACE_COSF])
269 REPLACE_FLOOR=0; AC_SUBST([REPLACE_FLOOR]) 291 REPLACE_COSHF=0; AC_SUBST([REPLACE_COSHF])
270 REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF]) 292 REPLACE_EXPF=0; AC_SUBST([REPLACE_EXPF])
271 REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL]) 293 REPLACE_EXPL=0; AC_SUBST([REPLACE_EXPL])
272 REPLACE_FMA=0; AC_SUBST([REPLACE_FMA]) 294 REPLACE_EXPM1=0; AC_SUBST([REPLACE_EXPM1])
273 REPLACE_FMAF=0; AC_SUBST([REPLACE_FMAF]) 295 REPLACE_EXPM1F=0; AC_SUBST([REPLACE_EXPM1F])
274 REPLACE_FMAL=0; AC_SUBST([REPLACE_FMAL]) 296 REPLACE_EXPM1L=0; AC_SUBST([REPLACE_EXPM1L])
275 REPLACE_FMOD=0; AC_SUBST([REPLACE_FMOD]) 297 REPLACE_EXP2=0; AC_SUBST([REPLACE_EXP2])
276 REPLACE_FMODF=0; AC_SUBST([REPLACE_FMODF]) 298 REPLACE_EXP2L=0; AC_SUBST([REPLACE_EXP2L])
277 REPLACE_FMODL=0; AC_SUBST([REPLACE_FMODL]) 299 REPLACE_FABSL=0; AC_SUBST([REPLACE_FABSL])
278 REPLACE_FREXPF=0; AC_SUBST([REPLACE_FREXPF]) 300 REPLACE_FLOOR=0; AC_SUBST([REPLACE_FLOOR])
279 REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP]) 301 REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF])
280 REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL]) 302 REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL])
281 REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL]) 303 REPLACE_FMA=0; AC_SUBST([REPLACE_FMA])
282 REPLACE_HYPOT=0; AC_SUBST([REPLACE_HYPOT]) 304 REPLACE_FMAF=0; AC_SUBST([REPLACE_FMAF])
283 REPLACE_HYPOTF=0; AC_SUBST([REPLACE_HYPOTF]) 305 REPLACE_FMAL=0; AC_SUBST([REPLACE_FMAL])
284 REPLACE_HYPOTL=0; AC_SUBST([REPLACE_HYPOTL]) 306 REPLACE_FMOD=0; AC_SUBST([REPLACE_FMOD])
285 REPLACE_ILOGB=0; AC_SUBST([REPLACE_ILOGB]) 307 REPLACE_FMODF=0; AC_SUBST([REPLACE_FMODF])
286 REPLACE_ILOGBF=0; AC_SUBST([REPLACE_ILOGBF]) 308 REPLACE_FMODL=0; AC_SUBST([REPLACE_FMODL])
287 REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE]) 309 REPLACE_FREXPF=0; AC_SUBST([REPLACE_FREXPF])
288 REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF]) 310 REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP])
289 REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN]) 311 REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL])
290 REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL]) 312 REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL])
291 REPLACE_LOG=0; AC_SUBST([REPLACE_LOG]) 313 REPLACE_HYPOT=0; AC_SUBST([REPLACE_HYPOT])
292 REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF]) 314 REPLACE_HYPOTF=0; AC_SUBST([REPLACE_HYPOTF])
293 REPLACE_LOGL=0; AC_SUBST([REPLACE_LOGL]) 315 REPLACE_HYPOTL=0; AC_SUBST([REPLACE_HYPOTL])
294 REPLACE_LOG10=0; AC_SUBST([REPLACE_LOG10]) 316 REPLACE_ILOGB=0; AC_SUBST([REPLACE_ILOGB])
295 REPLACE_LOG10F=0; AC_SUBST([REPLACE_LOG10F]) 317 REPLACE_ILOGBF=0; AC_SUBST([REPLACE_ILOGBF])
296 REPLACE_LOG10L=0; AC_SUBST([REPLACE_LOG10L]) 318 REPLACE_ILOGBL=0; AC_SUBST([REPLACE_ILOGBL])
297 REPLACE_LOG1P=0; AC_SUBST([REPLACE_LOG1P]) 319 REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE])
298 REPLACE_LOG1PF=0; AC_SUBST([REPLACE_LOG1PF]) 320 REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF])
299 REPLACE_LOG1PL=0; AC_SUBST([REPLACE_LOG1PL]) 321 REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN])
300 REPLACE_LOG2=0; AC_SUBST([REPLACE_LOG2]) 322 REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL])
301 REPLACE_LOG2F=0; AC_SUBST([REPLACE_LOG2F]) 323 REPLACE_LOG=0; AC_SUBST([REPLACE_LOG])
302 REPLACE_LOG2L=0; AC_SUBST([REPLACE_LOG2L]) 324 REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF])
303 REPLACE_LOGB=0; AC_SUBST([REPLACE_LOGB]) 325 REPLACE_LOGL=0; AC_SUBST([REPLACE_LOGL])
304 REPLACE_LOGBF=0; AC_SUBST([REPLACE_LOGBF]) 326 REPLACE_LOG10=0; AC_SUBST([REPLACE_LOG10])
305 REPLACE_LOGBL=0; AC_SUBST([REPLACE_LOGBL]) 327 REPLACE_LOG10F=0; AC_SUBST([REPLACE_LOG10F])
306 REPLACE_MODF=0; AC_SUBST([REPLACE_MODF]) 328 REPLACE_LOG10L=0; AC_SUBST([REPLACE_LOG10L])
307 REPLACE_MODFF=0; AC_SUBST([REPLACE_MODFF]) 329 REPLACE_LOG1P=0; AC_SUBST([REPLACE_LOG1P])
308 REPLACE_MODFL=0; AC_SUBST([REPLACE_MODFL]) 330 REPLACE_LOG1PF=0; AC_SUBST([REPLACE_LOG1PF])
309 REPLACE_NAN=0; AC_SUBST([REPLACE_NAN]) 331 REPLACE_LOG1PL=0; AC_SUBST([REPLACE_LOG1PL])
310 REPLACE_REMAINDER=0; AC_SUBST([REPLACE_REMAINDER]) 332 REPLACE_LOG2=0; AC_SUBST([REPLACE_LOG2])
311 REPLACE_REMAINDERF=0; AC_SUBST([REPLACE_REMAINDERF]) 333 REPLACE_LOG2F=0; AC_SUBST([REPLACE_LOG2F])
312 REPLACE_REMAINDERL=0; AC_SUBST([REPLACE_REMAINDERL]) 334 REPLACE_LOG2L=0; AC_SUBST([REPLACE_LOG2L])
313 REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND]) 335 REPLACE_LOGB=0; AC_SUBST([REPLACE_LOGB])
314 REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF]) 336 REPLACE_LOGBF=0; AC_SUBST([REPLACE_LOGBF])
315 REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL]) 337 REPLACE_LOGBL=0; AC_SUBST([REPLACE_LOGBL])
316 REPLACE_SIGNBIT=0; AC_SUBST([REPLACE_SIGNBIT]) 338 REPLACE_MODF=0; AC_SUBST([REPLACE_MODF])
317 REPLACE_SIGNBIT_USING_GCC=0; AC_SUBST([REPLACE_SIGNBIT_USING_GCC]) 339 REPLACE_MODFF=0; AC_SUBST([REPLACE_MODFF])
318 REPLACE_SQRTL=0; AC_SUBST([REPLACE_SQRTL]) 340 REPLACE_MODFL=0; AC_SUBST([REPLACE_MODFL])
319 REPLACE_TRUNC=0; AC_SUBST([REPLACE_TRUNC]) 341 REPLACE_NAN=0; AC_SUBST([REPLACE_NAN])
320 REPLACE_TRUNCF=0; AC_SUBST([REPLACE_TRUNCF]) 342 REPLACE_REMAINDER=0; AC_SUBST([REPLACE_REMAINDER])
321 REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL]) 343 REPLACE_REMAINDERF=0; AC_SUBST([REPLACE_REMAINDERF])
344 REPLACE_REMAINDERL=0; AC_SUBST([REPLACE_REMAINDERL])
345 REPLACE_RINTL=0; AC_SUBST([REPLACE_RINTL])
346 REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND])
347 REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF])
348 REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL])
349 REPLACE_SIGNBIT=0; AC_SUBST([REPLACE_SIGNBIT])
350 REPLACE_SIGNBIT_USING_BUILTINS=0; AC_SUBST([REPLACE_SIGNBIT_USING_BUILTINS])
351 REPLACE_SINF=0; AC_SUBST([REPLACE_SINF])
352 REPLACE_SINHF=0; AC_SUBST([REPLACE_SINHF])
353 REPLACE_SQRTF=0; AC_SUBST([REPLACE_SQRTF])
354 REPLACE_SQRTL=0; AC_SUBST([REPLACE_SQRTL])
355 REPLACE_TANF=0; AC_SUBST([REPLACE_TANF])
356 REPLACE_TANHF=0; AC_SUBST([REPLACE_TANHF])
357 REPLACE_TRUNC=0; AC_SUBST([REPLACE_TRUNC])
358 REPLACE_TRUNCF=0; AC_SUBST([REPLACE_TRUNCF])
359 REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL])
322]) 360])
323 361
324# gl_LONG_DOUBLE_VS_DOUBLE 362# gl_LONG_DOUBLE_VS_DOUBLE
diff --git a/gl/m4/mbrtowc.m4 b/gl/m4/mbrtowc.m4
index 4c9f3886..bb393041 100644
--- a/gl/m4/mbrtowc.m4
+++ b/gl/m4/mbrtowc.m4
@@ -1,5 +1,5 @@
1# mbrtowc.m4 serial 25 1# mbrtowc.m4 serial 38 -*- coding: utf-8 -*-
2dnl Copyright (C) 2001-2002, 2004-2005, 2008-2013 Free Software Foundation, 2dnl Copyright (C) 2001-2002, 2004-2005, 2008-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,8 @@ dnl with or without modifications, as long as this notice is preserved.
8AC_DEFUN([gl_FUNC_MBRTOWC], 8AC_DEFUN([gl_FUNC_MBRTOWC],
9[ 9[
10 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 10 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
11 AC_REQUIRE([gl_PTHREADLIB])
12 AC_CHECK_HEADERS_ONCE([threads.h])
11 13
12 AC_REQUIRE([AC_TYPE_MBSTATE_T]) 14 AC_REQUIRE([AC_TYPE_MBSTATE_T])
13 gl_MBSTATE_T_BROKEN 15 gl_MBSTATE_T_BROKEN
@@ -16,15 +18,8 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
16 if test $ac_cv_func_mbrtowc = no; then 18 if test $ac_cv_func_mbrtowc = no; then
17 HAVE_MBRTOWC=0 19 HAVE_MBRTOWC=0
18 AC_CHECK_DECLS([mbrtowc],,, [[ 20 AC_CHECK_DECLS([mbrtowc],,, [[
19/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 21 #include <wchar.h>
20 <wchar.h>. 22 ]])
21 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
22 included before <wchar.h>. */
23#include <stddef.h>
24#include <stdio.h>
25#include <time.h>
26#include <wchar.h>
27]])
28 if test $ac_cv_have_decl_mbrtowc = yes; then 23 if test $ac_cv_have_decl_mbrtowc = yes; then
29 dnl On Minix 3.1.8, the system's <wchar.h> declares mbrtowc() although 24 dnl On Minix 3.1.8, the system's <wchar.h> declares mbrtowc() although
30 dnl it does not have the function. Avoid a collision with gnulib's 25 dnl it does not have the function. Avoid a collision with gnulib's
@@ -39,6 +34,9 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
39 gl_MBRTOWC_NULL_ARG2 34 gl_MBRTOWC_NULL_ARG2
40 gl_MBRTOWC_RETVAL 35 gl_MBRTOWC_RETVAL
41 gl_MBRTOWC_NUL_RETVAL 36 gl_MBRTOWC_NUL_RETVAL
37 gl_MBRTOWC_STORES_INCOMPLETE
38 gl_MBRTOWC_EMPTY_INPUT
39 gl_MBRTOWC_C_LOCALE
42 case "$gl_cv_func_mbrtowc_null_arg1" in 40 case "$gl_cv_func_mbrtowc_null_arg1" in
43 *yes) ;; 41 *yes) ;;
44 *) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1], 42 *) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1],
@@ -67,8 +65,47 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
67 REPLACE_MBRTOWC=1 65 REPLACE_MBRTOWC=1
68 ;; 66 ;;
69 esac 67 esac
68 case "$gl_cv_func_mbrtowc_stores_incomplete" in
69 *no) ;;
70 *) AC_DEFINE([MBRTOWC_STORES_INCOMPLETE_BUG], [1],
71 [Define if the mbrtowc function stores a wide character when reporting incomplete input.])
72 REPLACE_MBRTOWC=1
73 ;;
74 esac
75 case "$gl_cv_func_mbrtowc_empty_input" in
76 *yes) ;;
77 *) AC_DEFINE([MBRTOWC_EMPTY_INPUT_BUG], [1],
78 [Define if the mbrtowc function does not return (size_t) -2
79 for empty input.])
80 REPLACE_MBRTOWC=1
81 ;;
82 esac
83 case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in
84 *yes) ;;
85 *) AC_DEFINE([MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ], [1],
86 [Define if the mbrtowc function may signal encoding errors in the C locale.])
87 REPLACE_MBRTOWC=1
88 ;;
89 esac
70 fi 90 fi
71 fi 91 fi
92 if test $REPLACE_MBSTATE_T = 1; then
93 case "$host_os" in
94 mingw*) LIB_MBRTOWC= ;;
95 *)
96 gl_WEAK_SYMBOLS
97 case "$gl_cv_have_weak" in
98 *yes) LIB_MBRTOWC= ;;
99 *) LIB_MBRTOWC="$LIBPTHREAD" ;;
100 esac
101 ;;
102 esac
103 else
104 LIB_MBRTOWC=
105 fi
106 dnl LIB_MBRTOWC is expected to be '-pthread' or '-lpthread' on AIX
107 dnl with gcc or xlc, and empty otherwise.
108 AC_SUBST([LIB_MBRTOWC])
72]) 109])
73 110
74dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that 111dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that
@@ -80,11 +117,19 @@ dnl avoid inconsistencies.
80AC_DEFUN([gl_MBSTATE_T_BROKEN], 117AC_DEFUN([gl_MBSTATE_T_BROKEN],
81[ 118[
82 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 119 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
120 AC_REQUIRE([AC_CANONICAL_HOST])
83 121
84 AC_REQUIRE([AC_TYPE_MBSTATE_T]) 122 AC_REQUIRE([AC_TYPE_MBSTATE_T])
85 AC_CHECK_FUNCS_ONCE([mbsinit]) 123 AC_CHECK_FUNCS_ONCE([mbsinit])
86 AC_CHECK_FUNCS_ONCE([mbrtowc]) 124 AC_CHECK_FUNCS_ONCE([mbrtowc])
87 if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then 125 dnl On native Windows, we know exactly how mbsinit() behaves and don't need
126 dnl to override it, even if - like on MSVC - mbsinit() is only defined as
127 dnl an inline function, not as a global function.
128 if case "$host_os" in
129 mingw*) true ;;
130 *) test $ac_cv_func_mbsinit = yes ;;
131 esac \
132 && test $ac_cv_func_mbrtowc = yes; then
88 gl_MBRTOWC_INCOMPLETE_STATE 133 gl_MBRTOWC_INCOMPLETE_STATE
89 gl_MBRTOWC_SANITYCHECK 134 gl_MBRTOWC_SANITYCHECK
90 REPLACE_MBSTATE_T=0 135 REPLACE_MBSTATE_T=0
@@ -109,6 +154,7 @@ AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE],
109[ 154[
110 AC_REQUIRE([AC_PROG_CC]) 155 AC_REQUIRE([AC_PROG_CC])
111 AC_REQUIRE([gt_LOCALE_JA]) 156 AC_REQUIRE([gt_LOCALE_JA])
157 AC_REQUIRE([gt_LOCALE_FR_UTF8])
112 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 158 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
113 AC_CACHE_CHECK([whether mbrtowc handles incomplete characters], 159 AC_CACHE_CHECK([whether mbrtowc handles incomplete characters],
114 [gl_cv_func_mbrtowc_incomplete_state], 160 [gl_cv_func_mbrtowc_incomplete_state],
@@ -128,13 +174,6 @@ changequote([,])dnl
128 [AC_LANG_SOURCE([[ 174 [AC_LANG_SOURCE([[
129#include <locale.h> 175#include <locale.h>
130#include <string.h> 176#include <string.h>
131/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
132 <wchar.h>.
133 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
134 included before <wchar.h>. */
135#include <stddef.h>
136#include <stdio.h>
137#include <time.h>
138#include <wchar.h> 177#include <wchar.h>
139int main () 178int main ()
140{ 179{
@@ -147,13 +186,39 @@ int main ()
147 memset (&state, '\0', sizeof (mbstate_t)); 186 memset (&state, '\0', sizeof (mbstate_t));
148 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) 187 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
149 if (mbsinit (&state)) 188 if (mbsinit (&state))
150 return 1; 189 return 2;
190 }
191 return 0;
192}]])],
193 [gl_cv_func_mbrtowc_incomplete_state=yes],
194 [gl_cv_func_mbrtowc_incomplete_state=no],
195 [:])
196 else
197 if test $LOCALE_FR_UTF8 != none; then
198 AC_RUN_IFELSE(
199 [AC_LANG_SOURCE([[
200#include <locale.h>
201#include <string.h>
202#include <wchar.h>
203int main ()
204{
205 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
206 {
207 const char input[] = "B\303\274\303\237er"; /* "Büßer" */
208 mbstate_t state;
209 wchar_t wc;
210
211 memset (&state, '\0', sizeof (mbstate_t));
212 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
213 if (mbsinit (&state))
214 return 2;
151 } 215 }
152 return 0; 216 return 0;
153}]])], 217}]])],
154 [gl_cv_func_mbrtowc_incomplete_state=yes], 218 [gl_cv_func_mbrtowc_incomplete_state=yes],
155 [gl_cv_func_mbrtowc_incomplete_state=no], 219 [gl_cv_func_mbrtowc_incomplete_state=no],
156 [:]) 220 [:])
221 fi
157 fi 222 fi
158 ]) 223 ])
159]) 224])
@@ -185,13 +250,6 @@ changequote([,])dnl
185#include <locale.h> 250#include <locale.h>
186#include <stdlib.h> 251#include <stdlib.h>
187#include <string.h> 252#include <string.h>
188/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
189 <wchar.h>.
190 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
191 included before <wchar.h>. */
192#include <stddef.h>
193#include <stdio.h>
194#include <time.h>
195#include <wchar.h> 253#include <wchar.h>
196int main () 254int main ()
197{ 255{
@@ -207,7 +265,7 @@ int main ()
207 memset (&state, '\0', sizeof (mbstate_t)); 265 memset (&state, '\0', sizeof (mbstate_t));
208 if (mbrtowc (&wc, input + 3, 6, &state) != 4 266 if (mbrtowc (&wc, input + 3, 6, &state) != 4
209 && mbtowc (&wc, input + 3, 6) == 4) 267 && mbtowc (&wc, input + 3, 6) == 4)
210 return 1; 268 return 2;
211 } 269 }
212 return 0; 270 return 0;
213}]])], 271}]])],
@@ -245,13 +303,6 @@ changequote([,])dnl
245#include <locale.h> 303#include <locale.h>
246#include <stdlib.h> 304#include <stdlib.h>
247#include <string.h> 305#include <string.h>
248/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
249 <wchar.h>.
250 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
251 included before <wchar.h>. */
252#include <stddef.h>
253#include <stdio.h>
254#include <time.h>
255#include <wchar.h> 306#include <wchar.h>
256int main () 307int main ()
257{ 308{
@@ -314,13 +365,6 @@ changequote([,])dnl
314 [AC_LANG_SOURCE([[ 365 [AC_LANG_SOURCE([[
315#include <locale.h> 366#include <locale.h>
316#include <string.h> 367#include <string.h>
317/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
318 <wchar.h>.
319 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
320 included before <wchar.h>. */
321#include <stddef.h>
322#include <stdio.h>
323#include <time.h>
324#include <wchar.h> 368#include <wchar.h>
325int main () 369int main ()
326{ 370{
@@ -335,7 +379,7 @@ int main ()
335 mbrtowc (&wc, NULL, 5, &state); 379 mbrtowc (&wc, NULL, 5, &state);
336 /* Check that wc was not modified. */ 380 /* Check that wc was not modified. */
337 if (wc != (wchar_t) 0xBADFACE) 381 if (wc != (wchar_t) 0xBADFACE)
338 return 1; 382 return 2;
339 } 383 }
340 return 0; 384 return 0;
341}]])], 385}]])],
@@ -376,13 +420,6 @@ changequote([,])dnl
376 [AC_LANG_SOURCE([[ 420 [AC_LANG_SOURCE([[
377#include <locale.h> 421#include <locale.h>
378#include <string.h> 422#include <string.h>
379/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
380 <wchar.h>.
381 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
382 included before <wchar.h>. */
383#include <stddef.h>
384#include <stdio.h>
385#include <time.h>
386#include <wchar.h> 423#include <wchar.h>
387int main () 424int main ()
388{ 425{
@@ -504,13 +541,6 @@ changequote([,])dnl
504 [AC_LANG_SOURCE([[ 541 [AC_LANG_SOURCE([[
505#include <locale.h> 542#include <locale.h>
506#include <string.h> 543#include <string.h>
507/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
508 <wchar.h>.
509 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
510 included before <wchar.h>. */
511#include <stddef.h>
512#include <stdio.h>
513#include <time.h>
514#include <wchar.h> 544#include <wchar.h>
515int main () 545int main ()
516{ 546{
@@ -522,7 +552,7 @@ int main ()
522 552
523 memset (&state, '\0', sizeof (mbstate_t)); 553 memset (&state, '\0', sizeof (mbstate_t));
524 if (mbrtowc (&wc, "", 1, &state) != 0) 554 if (mbrtowc (&wc, "", 1, &state) != 0)
525 return 1; 555 return 2;
526 } 556 }
527 return 0; 557 return 0;
528}]])], 558}]])],
@@ -533,11 +563,206 @@ int main ()
533 ]) 563 ])
534]) 564])
535 565
536# Prerequisites of lib/mbrtowc.c. 566dnl Test whether mbrtowc stores a wide character when reporting incomplete
567dnl input.
568
569AC_DEFUN([gl_MBRTOWC_STORES_INCOMPLETE],
570[
571 AC_REQUIRE([AC_PROG_CC])
572 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
573 AC_CACHE_CHECK([whether mbrtowc stores incomplete characters],
574 [gl_cv_func_mbrtowc_stores_incomplete],
575 [
576 dnl Initial guess, used when cross-compiling or when no suitable locale
577 dnl is present.
578changequote(,)dnl
579 case "$host_os" in
580 # Guess yes on native Windows.
581 mingw*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;;
582 *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;;
583 esac
584changequote([,])dnl
585 case "$host_os" in
586 mingw*)
587 AC_RUN_IFELSE(
588 [AC_LANG_SOURCE([[
589#include <locale.h>
590#include <string.h>
591#include <wchar.h>
592int main ()
593{
594 int result = 0;
595 if (setlocale (LC_ALL, "French_France.65001") != NULL)
596 {
597 wchar_t wc = (wchar_t) 0xBADFACE;
598 mbstate_t state;
599
600 memset (&state, '\0', sizeof (mbstate_t));
601 if (mbrtowc (&wc, "\303", 1, &state) == (size_t)(-2)
602 && wc != (wchar_t) 0xBADFACE)
603 result |= 1;
604 }
605 if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL)
606 {
607 wchar_t wc = (wchar_t) 0xBADFACE;
608 mbstate_t state;
609
610 memset (&state, '\0', sizeof (mbstate_t));
611 if (mbrtowc (&wc, "\226", 1, &state) == (size_t)(-2)
612 && wc != (wchar_t) 0xBADFACE)
613 result |= 2;
614 }
615 if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL)
616 {
617 wchar_t wc = (wchar_t) 0xBADFACE;
618 mbstate_t state;
619
620 memset (&state, '\0', sizeof (mbstate_t));
621 if (mbrtowc (&wc, "\245", 1, &state) == (size_t)(-2)
622 && wc != (wchar_t) 0xBADFACE)
623 result |= 4;
624 }
625 if (setlocale (LC_ALL, "Chinese_China.936") != NULL)
626 {
627 wchar_t wc = (wchar_t) 0xBADFACE;
628 mbstate_t state;
629
630 memset (&state, '\0', sizeof (mbstate_t));
631 if (mbrtowc (&wc, "\261", 1, &state) == (size_t)(-2)
632 && wc != (wchar_t) 0xBADFACE)
633 result |= 8;
634 }
635 return result;
636}]])],
637 [gl_cv_func_mbrtowc_stores_incomplete=no],
638 [gl_cv_func_mbrtowc_stores_incomplete=yes],
639 [:])
640 ;;
641 *)
642 AC_REQUIRE([gt_LOCALE_FR_UTF8])
643 if test $LOCALE_FR_UTF8 != none; then
644 AC_RUN_IFELSE(
645 [AC_LANG_SOURCE([[
646#include <locale.h>
647#include <string.h>
648#include <wchar.h>
649int main ()
650{
651 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
652 {
653 wchar_t wc = (wchar_t) 0xBADFACE;
654 mbstate_t state;
655
656 memset (&state, '\0', sizeof (mbstate_t));
657 if (mbrtowc (&wc, "\303", 1, &state) == (size_t)(-2)
658 && wc != (wchar_t) 0xBADFACE)
659 return 1;
660 }
661 return 0;
662}]])],
663 [gl_cv_func_mbrtowc_stores_incomplete=no],
664 [gl_cv_func_mbrtowc_stores_incomplete=yes],
665 [:])
666 fi
667 ;;
668 esac
669 ])
670])
671
672dnl Test whether mbrtowc returns the correct value on empty input.
673
674AC_DEFUN([gl_MBRTOWC_EMPTY_INPUT],
675[
676 AC_REQUIRE([AC_PROG_CC])
677 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
678 AC_CACHE_CHECK([whether mbrtowc works on empty input],
679 [gl_cv_func_mbrtowc_empty_input],
680 [
681 dnl Initial guess, used when cross-compiling or when no suitable locale
682 dnl is present.
683changequote(,)dnl
684 case "$host_os" in
685 # Guess no on AIX and glibc systems.
686 aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;;
687 # Guess yes on native Windows.
688 mingw*) gl_cv_func_mbrtowc_empty_input="guessing yes" ;;
689 *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;;
690 esac
691changequote([,])dnl
692 AC_RUN_IFELSE(
693 [AC_LANG_SOURCE([[
694 #include <wchar.h>
695 static wchar_t wc;
696 static mbstate_t mbs;
697 int
698 main (void)
699 {
700 return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2;
701 }]])],
702 [gl_cv_func_mbrtowc_empty_input=yes],
703 [gl_cv_func_mbrtowc_empty_input=no],
704 [:])
705 ])
706])
707
708dnl Test whether mbrtowc reports encoding errors in the C locale.
709dnl Although POSIX was never intended to allow this, the GNU C Library
710dnl and other implementations do it. See:
711dnl https://sourceware.org/bugzilla/show_bug.cgi?id=19932
712
713AC_DEFUN([gl_MBRTOWC_C_LOCALE],
714[
715 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
716 AC_CACHE_CHECK([whether the C locale is free of encoding errors],
717 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ],
718 [
719 dnl Initial guess, used when cross-compiling or when no suitable locale
720 dnl is present.
721 gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal"
722
723 AC_RUN_IFELSE(
724 [AC_LANG_PROGRAM(
725 [[#include <limits.h>
726 #include <locale.h>
727 #include <wchar.h>
728 ]], [[
729 int i;
730 char *locale = setlocale (LC_ALL, "C");
731 if (! locale)
732 return 2;
733 for (i = CHAR_MIN; i <= CHAR_MAX; i++)
734 {
735 char c = i;
736 wchar_t wc;
737 mbstate_t mbs = { 0, };
738 size_t ss = mbrtowc (&wc, &c, 1, &mbs);
739 if (1 < ss)
740 return 3;
741 }
742 return 0;
743 ]])],
744 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes],
745 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no],
746 [case "$host_os" in
747 # Guess yes on native Windows.
748 mingw*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;;
749 esac
750 ])
751 ])
752])
753
754# Prerequisites of lib/mbrtowc.c and lib/lc-charset-dispatch.c.
537AC_DEFUN([gl_PREREQ_MBRTOWC], [ 755AC_DEFUN([gl_PREREQ_MBRTOWC], [
756 AC_REQUIRE([AC_C_INLINE])
538 : 757 :
539]) 758])
540 759
760# Prerequisites of lib/mbtowc-lock.c.
761AC_DEFUN([gl_PREREQ_MBTOWC_LOCK],
762[
763 gl_VISIBILITY
764])
765
541 766
542dnl From Paul Eggert 767dnl From Paul Eggert
543 768
@@ -547,24 +772,17 @@ AC_DEFUN([AC_FUNC_MBRTOWC],
547[ 772[
548 dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60. 773 dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60.
549 AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared], 774 AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
550 gl_cv_func_mbrtowc, 775 [gl_cv_func_mbrtowc],
551 [AC_LINK_IFELSE( 776 [AC_LINK_IFELSE(
552 [AC_LANG_PROGRAM( 777 [AC_LANG_PROGRAM(
553 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be 778 [[#include <wchar.h>]],
554 included before <wchar.h>.
555 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
556 must be included before <wchar.h>. */
557 #include <stddef.h>
558 #include <stdio.h>
559 #include <time.h>
560 #include <wchar.h>]],
561 [[wchar_t wc; 779 [[wchar_t wc;
562 char const s[] = ""; 780 char const s[] = "";
563 size_t n = 1; 781 size_t n = 1;
564 mbstate_t state; 782 mbstate_t state;
565 return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])], 783 return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
566 gl_cv_func_mbrtowc=yes, 784 [gl_cv_func_mbrtowc=yes],
567 gl_cv_func_mbrtowc=no)]) 785 [gl_cv_func_mbrtowc=no])])
568 if test $gl_cv_func_mbrtowc = yes; then 786 if test $gl_cv_func_mbrtowc = yes; then
569 AC_DEFINE([HAVE_MBRTOWC], [1], 787 AC_DEFINE([HAVE_MBRTOWC], [1],
570 [Define to 1 if mbrtowc and mbstate_t are properly declared.]) 788 [Define to 1 if mbrtowc and mbstate_t are properly declared.])
diff --git a/gl/m4/mbsinit.m4 b/gl/m4/mbsinit.m4
index 2e6d0921..c388a8b9 100644
--- a/gl/m4/mbsinit.m4
+++ b/gl/m4/mbsinit.m4
@@ -1,5 +1,5 @@
1# mbsinit.m4 serial 8 1# mbsinit.m4 serial 9
2dnl Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -16,15 +16,8 @@ AC_DEFUN([gl_FUNC_MBSINIT],
16 if test $ac_cv_func_mbsinit = no; then 16 if test $ac_cv_func_mbsinit = no; then
17 HAVE_MBSINIT=0 17 HAVE_MBSINIT=0
18 AC_CHECK_DECLS([mbsinit],,, [[ 18 AC_CHECK_DECLS([mbsinit],,, [[
19/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 19 #include <wchar.h>
20 <wchar.h>. 20 ]])
21 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
22 included before <wchar.h>. */
23#include <stddef.h>
24#include <stdio.h>
25#include <time.h>
26#include <wchar.h>
27]])
28 if test $ac_cv_have_decl_mbsinit = yes; then 21 if test $ac_cv_have_decl_mbsinit = yes; then
29 dnl On Minix 3.1.8, the system's <wchar.h> declares mbsinit() although 22 dnl On Minix 3.1.8, the system's <wchar.h> declares mbsinit() although
30 dnl it does not have the function. Avoid a collision with gnulib's 23 dnl it does not have the function. Avoid a collision with gnulib's
diff --git a/gl/m4/mbstate_t.m4 b/gl/m4/mbstate_t.m4
index ed001179..dcd66b96 100644
--- a/gl/m4/mbstate_t.m4
+++ b/gl/m4/mbstate_t.m4
@@ -1,5 +1,5 @@
1# mbstate_t.m4 serial 13 1# mbstate_t.m4 serial 14
2dnl Copyright (C) 2000-2002, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -20,14 +20,7 @@ AC_DEFUN([AC_TYPE_MBSTATE_T],
20 [AC_COMPILE_IFELSE( 20 [AC_COMPILE_IFELSE(
21 [AC_LANG_PROGRAM( 21 [AC_LANG_PROGRAM(
22 [AC_INCLUDES_DEFAULT[ 22 [AC_INCLUDES_DEFAULT[
23/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 23 #include <wchar.h>]],
24 <wchar.h>.
25 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
26 included before <wchar.h>. */
27#include <stddef.h>
28#include <stdio.h>
29#include <time.h>
30#include <wchar.h>]],
31 [[mbstate_t x; return sizeof x;]])], 24 [[mbstate_t x; return sizeof x;]])],
32 [ac_cv_type_mbstate_t=yes], 25 [ac_cv_type_mbstate_t=yes],
33 [ac_cv_type_mbstate_t=no])]) 26 [ac_cv_type_mbstate_t=no])])
diff --git a/gl/m4/mbtowc.m4 b/gl/m4/mbtowc.m4
index e4794619..7823be0e 100644
--- a/gl/m4/mbtowc.m4
+++ b/gl/m4/mbtowc.m4
@@ -1,5 +1,5 @@
1# mbtowc.m4 serial 2 1# mbtowc.m4 serial 3
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,8 +8,13 @@ AC_DEFUN([gl_FUNC_MBTOWC],
8[ 8[
9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
10 10
11 if false; then 11 AC_CHECK_FUNCS([mbtowc])
12 REPLACE_MBTOWC=1 12 if test $ac_cv_func_mbtowc = no; then
13 HAVE_MBTOWC=0
14 else
15 if false; then
16 REPLACE_MBTOWC=1
17 fi
13 fi 18 fi
14]) 19])
15 20
diff --git a/gl/m4/memchr.m4 b/gl/m4/memchr.m4
index 2d8abe75..4f1aed01 100644
--- a/gl/m4/memchr.m4
+++ b/gl/m4/memchr.m4
@@ -1,35 +1,30 @@
1# memchr.m4 serial 12 1# memchr.m4 serial 18
2dnl Copyright (C) 2002-2004, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN_ONCE([gl_FUNC_MEMCHR], 7AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
8[ 8[
9 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
10
9 dnl Check for prerequisites for memory fence checks. 11 dnl Check for prerequisites for memory fence checks.
10 gl_FUNC_MMAP_ANON 12 gl_FUNC_MMAP_ANON
11 AC_CHECK_HEADERS_ONCE([sys/mman.h]) 13 AC_CHECK_HEADERS_ONCE([sys/mman.h])
12 AC_CHECK_FUNCS_ONCE([mprotect]) 14 AC_CHECK_FUNCS_ONCE([mprotect])
13 15
14 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 16 AC_REQUIRE([gl_STRING_H_DEFAULTS])
15 m4_ifdef([gl_FUNC_MEMCHR_OBSOLETE], [ 17 # Detect platform-specific bugs in some versions of glibc:
16 dnl These days, we assume memchr is present. But if support for old 18 # memchr should not dereference anything with length 0
17 dnl platforms is desired: 19 # https://bugzilla.redhat.com/show_bug.cgi?id=499689
18 AC_CHECK_FUNCS_ONCE([memchr]) 20 # memchr should not dereference overestimated length after a match
19 if test $ac_cv_func_memchr = no; then 21 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
20 HAVE_MEMCHR=0 22 # https://sourceware.org/bugzilla/show_bug.cgi?id=10162
21 fi 23 # memchr should cast the second argument to 'unsigned char'.
22 ]) 24 # This bug exists in Android 4.3.
23 if test $HAVE_MEMCHR = 1; then 25 # Assume that memchr works on platforms that lack mprotect.
24 # Detect platform-specific bugs in some versions of glibc: 26 AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works],
25 # memchr should not dereference anything with length 0 27 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
26 # http://bugzilla.redhat.com/499689
27 # memchr should not dereference overestimated length after a match
28 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
29 # http://sourceware.org/bugzilla/show_bug.cgi?id=10162
30 # Assume that memchr works on platforms that lack mprotect.
31 AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works],
32 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
33#include <string.h> 28#include <string.h>
34#if HAVE_SYS_MMAN_H 29#if HAVE_SYS_MMAN_H
35# include <fcntl.h> 30# include <fcntl.h>
@@ -64,6 +59,7 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
64#endif 59#endif
65 if (fence) 60 if (fence)
66 { 61 {
62 /* Test against bugs on glibc systems. */
67 if (memchr (fence, 0, 0)) 63 if (memchr (fence, 0, 0))
68 result |= 1; 64 result |= 1;
69 strcpy (fence - 9, "12345678"); 65 strcpy (fence - 9, "12345678");
@@ -71,15 +67,37 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
71 result |= 2; 67 result |= 2;
72 if (memchr (fence - 1, 0, 3) != fence - 1) 68 if (memchr (fence - 1, 0, 3) != fence - 1)
73 result |= 4; 69 result |= 4;
70 /* Test against bug on AIX 7.2. */
71 if (memchr (fence - 4, '6', 16) != fence - 4)
72 result |= 8;
74 } 73 }
74 /* Test against bug on Android 4.3. */
75 {
76 char input[3];
77 input[0] = 'a';
78 input[1] = 'b';
79 input[2] = 'c';
80 if (memchr (input, 0x789abc00 | 'b', 3) != input + 1)
81 result |= 16;
82 }
75 return result; 83 return result;
76]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no], 84]])],
77 [dnl Be pessimistic for now. 85 [gl_cv_func_memchr_works=yes],
78 gl_cv_func_memchr_works="guessing no"])]) 86 [gl_cv_func_memchr_works=no],
79 if test "$gl_cv_func_memchr_works" != yes; then 87 [case "$host_os" in
80 REPLACE_MEMCHR=1 88 # Guess no on Android.
81 fi 89 linux*-android*) gl_cv_func_memchr_works="guessing no" ;;
82 fi 90 # Guess yes on native Windows.
91 mingw*) gl_cv_func_memchr_works="guessing yes" ;;
92 # If we don't know, obey --enable-cross-guesses.
93 *) gl_cv_func_memchr_works="$gl_cross_guess_normal" ;;
94 esac
95 ])
96 ])
97 case "$gl_cv_func_memchr_works" in
98 *yes) ;;
99 *) REPLACE_MEMCHR=1 ;;
100 esac
83]) 101])
84 102
85# Prerequisites of lib/memchr.c. 103# Prerequisites of lib/memchr.c.
diff --git a/gl/m4/minmax.m4 b/gl/m4/minmax.m4
new file mode 100644
index 00000000..fd09846f
--- /dev/null
+++ b/gl/m4/minmax.m4
@@ -0,0 +1,44 @@
1# minmax.m4 serial 4
2dnl Copyright (C) 2005, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_PREREQ([2.53])
8
9AC_DEFUN([gl_MINMAX],
10[
11 AC_REQUIRE([gl_PREREQ_MINMAX])
12])
13
14# Prerequisites of lib/minmax.h.
15AC_DEFUN([gl_PREREQ_MINMAX],
16[
17 gl_MINMAX_IN_HEADER([limits.h])
18 gl_MINMAX_IN_HEADER([sys/param.h])
19])
20
21dnl gl_MINMAX_IN_HEADER(HEADER)
22dnl The parameter has to be a literal header name; it cannot be macro,
23dnl nor a shell variable. (Because autoheader collects only AC_DEFINE
24dnl invocations with a literal macro name.)
25AC_DEFUN([gl_MINMAX_IN_HEADER],
26[
27 m4_pushdef([header], AS_TR_SH([$1]))
28 m4_pushdef([HEADER], AS_TR_CPP([$1]))
29 AC_CACHE_CHECK([whether <$1> defines MIN and MAX],
30 [gl_cv_minmax_in_]header,
31 [AC_COMPILE_IFELSE(
32 [AC_LANG_PROGRAM(
33 [[#include <$1>
34 int x = MIN (42, 17);]],
35 [[]])],
36 [gl_cv_minmax_in_]header[=yes],
37 [gl_cv_minmax_in_]header[=no])])
38 if test $gl_cv_minmax_in_[]header = yes; then
39 AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1,
40 [Define to 1 if <$1> defines the MIN and MAX macros.])
41 fi
42 m4_popdef([HEADER])
43 m4_popdef([header])
44])
diff --git a/gl/m4/mktime.m4 b/gl/m4/mktime.m4
index faefb770..e9d31f35 100644
--- a/gl/m4/mktime.m4
+++ b/gl/m4/mktime.m4
@@ -1,5 +1,5 @@
1# serial 25 1# serial 37
2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation, 2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -7,24 +7,40 @@ dnl with or without modifications, as long as this notice is preserved.
7 7
8dnl From Jim Meyering. 8dnl From Jim Meyering.
9 9
10AC_DEFUN([gl_FUNC_MKTIME], 10AC_DEFUN([gl_TIME_T_IS_SIGNED],
11[
12 AC_CACHE_CHECK([whether time_t is signed],
13 [gl_cv_time_t_is_signed],
14 [AC_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM([[#include <time.h>
16 char time_t_signed[(time_t) -1 < 0 ? 1 : -1];]])],
17 [gl_cv_time_t_is_signed=yes],
18 [gl_cv_time_t_is_signed=no])])
19 if test $gl_cv_time_t_is_signed = yes; then
20 AC_DEFINE([TIME_T_IS_SIGNED], [1], [Define to 1 if time_t is signed.])
21 fi
22])
23
24dnl Test whether mktime works. Set gl_cv_func_working_mktime.
25AC_DEFUN([gl_FUNC_MKTIME_WORKS],
11[ 26[
12 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 27 AC_REQUIRE([gl_TIME_T_IS_SIGNED])
28 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13 29
14 dnl We don't use AC_FUNC_MKTIME any more, because it is no longer maintained 30 dnl We don't use AC_FUNC_MKTIME any more, because it is no longer maintained
15 dnl in Autoconf and because it invokes AC_LIBOBJ. 31 dnl in Autoconf and because it invokes AC_LIBOBJ.
16 AC_CHECK_HEADERS_ONCE([unistd.h]) 32 AC_CHECK_HEADERS_ONCE([unistd.h])
17 AC_CHECK_DECLS_ONCE([alarm]) 33 AC_CHECK_DECLS_ONCE([alarm])
18 AC_REQUIRE([gl_MULTIARCH]) 34 AC_REQUIRE([gl_MULTIARCH])
19 if test $APPLE_UNIVERSAL_BUILD = 1; then
20 # A universal build on Apple Mac OS X platforms.
21 # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode.
22 # But we need a configuration result that is valid in both modes.
23 gl_cv_func_working_mktime=no
24 fi
25 AC_CACHE_CHECK([for working mktime], [gl_cv_func_working_mktime], 35 AC_CACHE_CHECK([for working mktime], [gl_cv_func_working_mktime],
26 [AC_RUN_IFELSE( 36 [if test $APPLE_UNIVERSAL_BUILD = 1; then
27 [AC_LANG_SOURCE( 37 # A universal build on Apple Mac OS X platforms.
38 # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode.
39 # But we need a configuration result that is valid in both modes.
40 gl_cv_func_working_mktime="guessing no"
41 else
42 AC_RUN_IFELSE(
43 [AC_LANG_SOURCE(
28[[/* Test program from Paul Eggert and Tony Leneis. */ 44[[/* Test program from Paul Eggert and Tony Leneis. */
29#include <limits.h> 45#include <limits.h>
30#include <stdlib.h> 46#include <stdlib.h>
@@ -38,8 +54,11 @@ AC_DEFUN([gl_FUNC_MKTIME],
38# include <signal.h> 54# include <signal.h>
39#endif 55#endif
40 56
41/* Work around redefinition to rpl_putenv by other config tests. */ 57]GL_MDA_DEFINES[
42#undef putenv 58
59#ifndef TIME_T_IS_SIGNED
60# define TIME_T_IS_SIGNED 0
61#endif
43 62
44static time_t time_t_max; 63static time_t time_t_max;
45static time_t time_t_min; 64static time_t time_t_min;
@@ -63,7 +82,8 @@ spring_forward_gap ()
63 instead of "TZ=America/Vancouver" in order to detect the bug even 82 instead of "TZ=America/Vancouver" in order to detect the bug even
64 on systems that don't support the Olson extension, or don't have the 83 on systems that don't support the Olson extension, or don't have the
65 full zoneinfo tables installed. */ 84 full zoneinfo tables installed. */
66 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0"); 85 if (putenv ("TZ=PST8PDT,M4.1.0,M10.5.0") != 0)
86 return -1;
67 87
68 tm.tm_year = 98; 88 tm.tm_year = 98;
69 tm.tm_mon = 3; 89 tm.tm_mon = 3;
@@ -151,7 +171,8 @@ year_2050_test ()
151 instead of "TZ=America/Vancouver" in order to detect the bug even 171 instead of "TZ=America/Vancouver" in order to detect the bug even
152 on systems that don't support the Olson extension, or don't have the 172 on systems that don't support the Olson extension, or don't have the
153 full zoneinfo tables installed. */ 173 full zoneinfo tables installed. */
154 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0"); 174 if (putenv ("TZ=PST8PDT,M4.1.0,M10.5.0") != 0)
175 return -1;
155 176
156 t = mktime (&tm); 177 t = mktime (&tm);
157 178
@@ -162,6 +183,25 @@ year_2050_test ()
162 || (0 < t && answer - 120 <= t && t <= answer + 120)); 183 || (0 < t && answer - 120 <= t && t <= answer + 120));
163} 184}
164 185
186static int
187indiana_test ()
188{
189 if (putenv ("TZ=America/Indiana/Indianapolis") != 0)
190 return -1;
191 struct tm tm;
192 tm.tm_year = 1986 - 1900; tm.tm_mon = 4 - 1; tm.tm_mday = 28;
193 tm.tm_hour = 16; tm.tm_min = 24; tm.tm_sec = 50; tm.tm_isdst = 0;
194 time_t std = mktime (&tm);
195 if (! (std == 515107490 || std == 515107503))
196 return 1;
197
198 /* This platform supports TZDB, either without or with leap seconds.
199 Return true if GNU Bug#48085 is absent. */
200 tm.tm_isdst = 1;
201 time_t dst = mktime (&tm);
202 return std - dst == 60 * 60;
203}
204
165int 205int
166main () 206main ()
167{ 207{
@@ -169,7 +209,6 @@ main ()
169 time_t t, delta; 209 time_t t, delta;
170 int i, j; 210 int i, j;
171 int time_t_signed_magnitude = (time_t) ~ (time_t) 0 < (time_t) -1; 211 int time_t_signed_magnitude = (time_t) ~ (time_t) 0 < (time_t) -1;
172 int time_t_signed = ! ((time_t) 0 < (time_t) -1);
173 212
174#if HAVE_DECL_ALARM 213#if HAVE_DECL_ALARM
175 /* This test makes some buggy mktime implementations loop. 214 /* This test makes some buggy mktime implementations loop.
@@ -179,11 +218,11 @@ main ()
179 alarm (60); 218 alarm (60);
180#endif 219#endif
181 220
182 time_t_max = (! time_t_signed 221 time_t_max = (! TIME_T_IS_SIGNED
183 ? (time_t) -1 222 ? (time_t) -1
184 : ((((time_t) 1 << (sizeof (time_t) * CHAR_BIT - 2)) - 1) 223 : ((((time_t) 1 << (sizeof (time_t) * CHAR_BIT - 2)) - 1)
185 * 2 + 1)); 224 * 2 + 1));
186 time_t_min = (! time_t_signed 225 time_t_min = (! TIME_T_IS_SIGNED
187 ? (time_t) 0 226 ? (time_t) 0
188 : time_t_signed_magnitude 227 : time_t_signed_magnitude
189 ? ~ (time_t) 0 228 ? ~ (time_t) 0
@@ -218,35 +257,62 @@ main ()
218 result |= 16; 257 result |= 16;
219 if (! spring_forward_gap ()) 258 if (! spring_forward_gap ())
220 result |= 32; 259 result |= 32;
221 if (! year_2050_test ()) 260 if (! year_2050_test () || ! indiana_test ())
222 result |= 64; 261 result |= 64;
223 return result; 262 return result;
224}]])], 263}]])],
225 [gl_cv_func_working_mktime=yes], 264 [gl_cv_func_working_mktime=yes],
226 [gl_cv_func_working_mktime=no], 265 [gl_cv_func_working_mktime=no],
227 [gl_cv_func_working_mktime=no]) 266 [case "$host_os" in
267 # Guess no on native Windows.
268 mingw*) gl_cv_func_working_mktime="guessing no" ;;
269 *) gl_cv_func_working_mktime="$gl_cross_guess_normal" ;;
270 esac
271 ])
272 fi
228 ]) 273 ])
274])
275
276dnl Main macro of module 'mktime'.
277AC_DEFUN([gl_FUNC_MKTIME],
278[
279 AC_REQUIRE([gl_TIME_H_DEFAULTS])
280 AC_REQUIRE([AC_CANONICAL_HOST])
281 AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
229 282
230 if test $gl_cv_func_working_mktime = no; then 283 REPLACE_MKTIME=0
284 if test "$gl_cv_func_working_mktime" != yes; then
231 REPLACE_MKTIME=1 285 REPLACE_MKTIME=1
232 else 286 AC_DEFINE([NEED_MKTIME_WORKING], [1],
233 REPLACE_MKTIME=0 287 [Define if the compilation of mktime.c should define 'mktime'
288 with the algorithmic workarounds.])
234 fi 289 fi
290 case "$host_os" in
291 mingw*)
292 REPLACE_MKTIME=1
293 AC_DEFINE([NEED_MKTIME_WINDOWS], [1],
294 [Define if the compilation of mktime.c should define 'mktime'
295 with the native Windows TZ workaround.])
296 ;;
297 esac
235]) 298])
236 299
300dnl Main macro of module 'mktime-internal'.
237AC_DEFUN([gl_FUNC_MKTIME_INTERNAL], [ 301AC_DEFUN([gl_FUNC_MKTIME_INTERNAL], [
238 AC_REQUIRE([gl_FUNC_MKTIME]) 302 AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
239 if test $REPLACE_MKTIME = 0; then 303
240 dnl BeOS has __mktime_internal in libc, but other platforms don't. 304 WANT_MKTIME_INTERNAL=0
241 AC_CHECK_FUNC([__mktime_internal], 305 dnl BeOS has __mktime_internal in libc, but other platforms don't.
242 [AC_DEFINE([mktime_internal], [__mktime_internal], 306 AC_CHECK_FUNC([__mktime_internal],
243 [Define to the real name of the mktime_internal function.]) 307 [AC_DEFINE([mktime_internal], [__mktime_internal],
244 ], 308 [Define to the real name of the mktime_internal function.])
245 [dnl mktime works but it doesn't export __mktime_internal, 309 ],
246 dnl so we need to substitute our own mktime implementation. 310 [dnl mktime works but it doesn't export __mktime_internal,
247 REPLACE_MKTIME=1 311 dnl so we need to substitute our own mktime implementation.
248 ]) 312 WANT_MKTIME_INTERNAL=1
249 fi 313 AC_DEFINE([NEED_MKTIME_INTERNAL], [1],
314 [Define if the compilation of mktime.c should define 'mktime_internal'.])
315 ])
250]) 316])
251 317
252# Prerequisites of lib/mktime.c. 318# Prerequisites of lib/mktime.c.
diff --git a/gl/m4/mmap-anon.m4 b/gl/m4/mmap-anon.m4
index 9b60ddfa..d07d26e4 100644
--- a/gl/m4/mmap-anon.m4
+++ b/gl/m4/mmap-anon.m4
@@ -1,5 +1,5 @@
1# mmap-anon.m4 serial 10 1# mmap-anon.m4 serial 12
2dnl Copyright (C) 2005, 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -9,11 +9,11 @@ dnl with or without modifications, as long as this notice is preserved.
9# - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS 9# - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS
10# and MAP_ANON exist and have the same value. 10# and MAP_ANON exist and have the same value.
11# - On HP-UX, only MAP_ANONYMOUS exists. 11# - On HP-UX, only MAP_ANONYMOUS exists.
12# - On Mac OS X, FreeBSD, NetBSD, OpenBSD, only MAP_ANON exists. 12# - On Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, only MAP_ANON exists.
13# - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be 13# - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be
14# used. 14# used.
15 15
16AC_DEFUN([gl_FUNC_MMAP_ANON], 16AC_DEFUN_ONCE([gl_FUNC_MMAP_ANON],
17[ 17[
18 dnl Persuade glibc <sys/mman.h> to define MAP_ANONYMOUS. 18 dnl Persuade glibc <sys/mman.h> to define MAP_ANONYMOUS.
19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
diff --git a/gl/m4/mode_t.m4 b/gl/m4/mode_t.m4
new file mode 100644
index 00000000..82197c02
--- /dev/null
+++ b/gl/m4/mode_t.m4
@@ -0,0 +1,26 @@
1# mode_t.m4 serial 2
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# For using mode_t, it's sufficient to use AC_TYPE_MODE_T and
8# include <sys/types.h>.
9
10# Define PROMOTED_MODE_T to the type that is the result of "default argument
11# promotion" (ISO C 6.5.2.2.(6)) of the type mode_t.
12AC_DEFUN([gl_PROMOTED_TYPE_MODE_T],
13[
14 AC_REQUIRE([AC_TYPE_MODE_T])
15 AC_CACHE_CHECK([for promoted mode_t type], [gl_cv_promoted_mode_t], [
16 dnl Assume mode_t promotes to 'int' if and only if it is smaller than 'int',
17 dnl and to itself otherwise. This assumption is not guaranteed by the ISO C
18 dnl standard, but we don't know of any real-world counterexamples.
19 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>]],
20 [[typedef int array[2 * (sizeof (mode_t) < sizeof (int)) - 1];]])],
21 [gl_cv_promoted_mode_t='int'],
22 [gl_cv_promoted_mode_t='mode_t'])
23 ])
24 AC_DEFINE_UNQUOTED([PROMOTED_MODE_T], [$gl_cv_promoted_mode_t],
25 [Define to the type that is the result of default argument promotions of type mode_t.])
26])
diff --git a/gl/m4/mountlist.m4 b/gl/m4/mountlist.m4
index cd137c91..a9b4edb9 100644
--- a/gl/m4/mountlist.m4
+++ b/gl/m4/mountlist.m4
@@ -1,19 +1,338 @@
1# serial 11 1# serial 15
2dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Jim Meyering.
8
9AC_PREREQ([2.60])
10
7AC_DEFUN([gl_MOUNTLIST], 11AC_DEFUN([gl_MOUNTLIST],
8[ 12[
9 gl_LIST_MOUNTED_FILE_SYSTEMS([gl_cv_list_mounted_fs=yes], 13 AC_REQUIRE([AC_CANONICAL_HOST])
10 [gl_cv_list_mounted_fs=no]) 14 AC_CHECK_FUNCS([listmntent])
15 AC_CHECK_HEADERS_ONCE([sys/param.h sys/statvfs.h])
16
17 # We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses
18 # NGROUPS (as the array dimension for a struct member) without a definition.
19 AC_CHECK_HEADERS([sys/ucred.h], [], [], [#include <grp.h>])
20
21 AC_CHECK_HEADERS([sys/mount.h], [], [],
22 [AC_INCLUDES_DEFAULT
23 [#if HAVE_SYS_PARAM_H
24 #include <sys/param.h>
25 #endif
26 ]])
27
28 AC_CHECK_HEADERS([mntent.h sys/fs_types.h])
29 getfsstat_includes="\
30$ac_includes_default
31#if HAVE_SYS_PARAM_H
32# include <sys/param.h> /* needed by powerpc-apple-darwin1.3.7 */
33#endif
34#if HAVE_SYS_UCRED_H
35# include <grp.h> /* needed for definition of NGROUPS */
36# include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
37#endif
38#if HAVE_SYS_MOUNT_H
39# include <sys/mount.h>
40#endif
41#if HAVE_SYS_FS_TYPES_H
42# include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */
43#endif
44"
45 AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes])
46
47 # Determine how to get the list of mounted file systems.
48 ac_list_mounted_fs=
49
50 # If the getmntent function is available but not in the standard library,
51 # make sure LIBS contains the appropriate -l option.
52 AC_FUNC_GETMNTENT
53
54 if test -z "$ac_list_mounted_fs"; then
55 # AIX.
56 AC_CACHE_CHECK([for mntctl function and struct vmount],
57 [fu_cv_sys_mounted_vmount],
58 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <fshelp.h>]])],
59 [fu_cv_sys_mounted_vmount=yes],
60 [fu_cv_sys_mounted_vmount=no])])
61 if test $fu_cv_sys_mounted_vmount = yes; then
62 ac_list_mounted_fs=found
63 AC_DEFINE([MOUNTED_VMOUNT], [1],
64 [Define if there is a function named mntctl that can be used to read
65 the list of mounted file systems, and there is a system header file
66 that declares 'struct vmount'. (AIX)])
67 fi
68 fi
69
70 if test $ac_cv_func_getmntent = yes; then
71
72 # This system has the getmntent function.
73 # Determine whether it's the one-argument variant or the two-argument one.
74
75 if test -z "$ac_list_mounted_fs"; then
76 # glibc, HP-UX, IRIX, Cygwin, Android, also (obsolete) 4.3BSD, SunOS.
77 AC_CACHE_CHECK([for one-argument getmntent function],
78 [fu_cv_sys_mounted_getmntent1],
79 [AC_COMPILE_IFELSE(
80 [AC_LANG_PROGRAM([[
81/* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */
82#include <stdio.h>
83
84#include <mntent.h>
85#if defined __ANDROID__ /* Android */
86# undef MOUNTED
87# define MOUNTED "/proc/mounts"
88#elif !defined MOUNTED
89# if defined _PATH_MOUNTED /* GNU libc */
90# define MOUNTED _PATH_MOUNTED
91# endif
92# if defined MNT_MNTTAB /* HP-UX. */
93# define MOUNTED MNT_MNTTAB
94# endif
95#endif
96]],
97 [[struct mntent *mnt = 0; char *table = MOUNTED;
98 if (sizeof mnt && sizeof table) return 0;
99 ]])],
100 [fu_cv_sys_mounted_getmntent1=yes],
101 [fu_cv_sys_mounted_getmntent1=no])
102 ])
103 if test $fu_cv_sys_mounted_getmntent1 = yes; then
104 ac_list_mounted_fs=found
105 AC_DEFINE([MOUNTED_GETMNTENT1], [1],
106 [Define if there is a function named getmntent for reading the list
107 of mounted file systems, and that function takes a single argument.
108 (4.3BSD, SunOS, HP-UX, Irix)])
109 AC_CHECK_FUNCS([setmntent endmntent hasmntopt])
110 fi
111 fi
112
113 if test -z "$ac_list_mounted_fs"; then
114 # Solaris >= 8.
115 AC_CACHE_CHECK([for getextmntent function],
116 [fu_cv_sys_mounted_getextmntent],
117 [AC_EGREP_HEADER([getextmntent], [sys/mnttab.h],
118 [fu_cv_sys_mounted_getextmntent=yes],
119 [fu_cv_sys_mounted_getextmntent=no])])
120 if test $fu_cv_sys_mounted_getextmntent = yes; then
121 ac_list_mounted_fs=found
122 AC_DEFINE([MOUNTED_GETEXTMNTENT], [1],
123 [Define if there is a function named getextmntent for reading the list
124 of mounted file systems. (Solaris)])
125 fi
126 fi
127
128 if test -z "$ac_list_mounted_fs"; then
129 # Solaris < 8, also (obsolete) SVR4.
130 # Solaris >= 8 has the two-argument getmntent but is already handled above.
131 AC_CACHE_CHECK([for two-argument getmntent function],
132 [fu_cv_sys_mounted_getmntent2],
133 [AC_EGREP_HEADER([getmntent], [sys/mnttab.h],
134 [fu_cv_sys_mounted_getmntent2=yes],
135 [fu_cv_sys_mounted_getmntent2=no])
136 ])
137 if test $fu_cv_sys_mounted_getmntent2 = yes; then
138 ac_list_mounted_fs=found
139 AC_DEFINE([MOUNTED_GETMNTENT2], [1],
140 [Define if there is a function named getmntent for reading the list of
141 mounted file systems, and that function takes two arguments. (SVR4)])
142 AC_CHECK_FUNCS([hasmntopt])
143 fi
144 fi
145
146 fi
147
148 if test -z "$ac_list_mounted_fs"; then
149 # OSF/1, also (obsolete) Apple Darwin 1.3.
150 # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h
151
152 AC_CACHE_CHECK([for getfsstat function],
153 [fu_cv_sys_mounted_getfsstat],
154 [AC_LINK_IFELSE(
155 [AC_LANG_PROGRAM([[
156#include <sys/types.h>
157#if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
158# define FS_TYPE(Ent) ((Ent).f_fstypename)
159#else
160# define FS_TYPE(Ent) mnt_names[(Ent).f_type]
161#endif
162$getfsstat_includes
163 ]],
164 [[struct statfs *stats;
165 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
166 char *t = FS_TYPE (*stats);
167 ]])],
168 [fu_cv_sys_mounted_getfsstat=yes],
169 [fu_cv_sys_mounted_getfsstat=no])
170 ])
171 if test $fu_cv_sys_mounted_getfsstat = yes; then
172 ac_list_mounted_fs=found
173 AC_DEFINE([MOUNTED_GETFSSTAT], [1],
174 [Define if there is a function named getfsstat for reading the
175 list of mounted file systems. (DEC Alpha running OSF/1)])
176 fi
177 fi
178
179 if test -z "$ac_list_mounted_fs"; then
180 # (obsolete) SVR3
181 AC_CACHE_CHECK([for FIXME existence of three headers],
182 [fu_cv_sys_mounted_fread_fstyp],
183 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
184#include <sys/statfs.h>
185#include <sys/fstyp.h>
186#include <mnttab.h>
187]])],
188 [fu_cv_sys_mounted_fread_fstyp=yes],
189 [fu_cv_sys_mounted_fread_fstyp=no])
190 ])
191 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
192 ac_list_mounted_fs=found
193 AC_DEFINE([MOUNTED_FREAD_FSTYP], [1],
194 [Define if (like SVR2) there is no specific function for reading the
195 list of mounted file systems, and your system has these header files:
196 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
197 fi
198 fi
199
200 if test -z "$ac_list_mounted_fs"; then
201 # Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, also (obsolete) 4.4BSD.
202 # OSF/1 also has getmntinfo but is already handled above.
203 # We cannot use AC_CHECK_FUNCS([getmntinfo]) here, because at the linker
204 # level the function is sometimes called getmntinfo64 or getmntinfo$INODE64
205 # on Mac OS X, __getmntinfo13 on NetBSD and Minix, _F64_getmntinfo on OSF/1.
206 AC_CACHE_CHECK([for getmntinfo function],
207 [fu_cv_sys_mounted_getmntinfo],
208 [AC_LINK_IFELSE(
209 [AC_LANG_PROGRAM([[
210#if HAVE_SYS_PARAM_H
211# include <sys/param.h>
212#endif
213#include <sys/types.h>
214#if HAVE_SYS_MOUNT_H
215# include <sys/mount.h>
216#endif
217#if HAVE_SYS_STATVFS_H
218# include <sys/statvfs.h>
219#endif
220#include <stdlib.h>
221 ]],
222 [[int count = getmntinfo (NULL, MNT_WAIT);
223 ]])],
224 [fu_cv_sys_mounted_getmntinfo=yes],
225 [fu_cv_sys_mounted_getmntinfo=no])
226 ])
227 if test $fu_cv_sys_mounted_getmntinfo = yes; then
228 AC_CACHE_CHECK([whether getmntinfo returns statvfs structures],
229 [fu_cv_sys_mounted_getmntinfo2],
230 [AC_COMPILE_IFELSE(
231 [AC_LANG_PROGRAM([[
232#if HAVE_SYS_PARAM_H
233# include <sys/param.h>
234#endif
235#include <sys/types.h>
236#if HAVE_SYS_MOUNT_H
237# include <sys/mount.h>
238#endif
239#if HAVE_SYS_STATVFS_H
240# include <sys/statvfs.h>
241#endif
242extern
243#ifdef __cplusplus
244"C"
245#endif
246int getmntinfo (struct statfs **, int);
247 ]], [[]])],
248 [fu_cv_sys_mounted_getmntinfo2=no],
249 [fu_cv_sys_mounted_getmntinfo2=yes])
250 ])
251 if test $fu_cv_sys_mounted_getmntinfo2 = no; then
252 # Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD.
253 ac_list_mounted_fs=found
254 AC_DEFINE([MOUNTED_GETMNTINFO], [1],
255 [Define if there is a function named getmntinfo for reading the
256 list of mounted file systems and it returns an array of
257 'struct statfs'. (4.4BSD, Darwin)])
258 else
259 # NetBSD, Minix.
260 ac_list_mounted_fs=found
261 AC_DEFINE([MOUNTED_GETMNTINFO2], [1],
262 [Define if there is a function named getmntinfo for reading the
263 list of mounted file systems and it returns an array of
264 'struct statvfs'. (NetBSD 3.0)])
265 fi
266 fi
267 fi
268
269 if test -z "$ac_list_mounted_fs"; then
270 # Haiku, also (obsolete) BeOS.
271 AC_CHECK_FUNCS([next_dev fs_stat_dev])
272 AC_CHECK_HEADERS([fs_info.h])
273 AC_CACHE_CHECK([for BEOS mounted file system support functions],
274 [fu_cv_sys_mounted_fs_stat_dev],
275 [if test $ac_cv_header_fs_info_h = yes \
276 && test $ac_cv_func_next_dev = yes \
277 && test $ac_cv_func_fs_stat_dev = yes; then
278 fu_cv_sys_mounted_fs_stat_dev=yes
279 else
280 fu_cv_sys_mounted_fs_stat_dev=no
281 fi
282 ])
283 if test $fu_cv_sys_mounted_fs_stat_dev = yes; then
284 ac_list_mounted_fs=found
285 AC_DEFINE([MOUNTED_FS_STAT_DEV], [1],
286 [Define if there are functions named next_dev and fs_stat_dev for
287 reading the list of mounted file systems. (BeOS)])
288 fi
289 fi
290
291 if test -z "$ac_list_mounted_fs"; then
292 # Interix / BSD alike statvfs
293 # the code is really interix specific, so make sure, we're on it.
294 case "$host" in
295 *-interix*)
296 AC_CHECK_FUNCS([statvfs])
297 if test $ac_cv_func_statvfs = yes; then
298 ac_list_mounted_fs=found
299 AC_DEFINE([MOUNTED_INTERIX_STATVFS], [1],
300 [Define if we are on interix, and ought to use statvfs plus
301 some special knowledge on where mounted file systems can be
302 found. (Interix)])
303 fi
304 ;;
305 esac
306 fi
307
308 if test -z "$ac_list_mounted_fs"; then
309 AC_MSG_ERROR([could not determine how to read list of mounted file systems])
310 # FIXME -- no need to abort building the whole package
311 # Can't build mountlist.c or anything that needs its functions
312 fi
313
314 if test $ac_list_mounted_fs = found; then
315 gl_cv_list_mounted_fs=yes
316 else
317 gl_cv_list_mounted_fs=no
318 fi
11]) 319])
12 320
13# Prerequisites of lib/mountlist.c not done by gl_LIST_MOUNTED_FILE_SYSTEMS. 321# Prerequisites of lib/mountlist.c not done by gl_MOUNTLIST.
14AC_DEFUN([gl_PREREQ_MOUNTLIST_EXTRA], 322AC_DEFUN([gl_PREREQ_MOUNTLIST_EXTRA],
15[ 323[
16 dnl Note gl_LIST_MOUNTED_FILE_SYSTEMS checks for mntent.h, not sys/mntent.h. 324 dnl Note gl_MOUNTLIST checks for mntent.h, not sys/mntent.h.
17 AC_CHECK_HEADERS([sys/mntent.h]) 325 AC_CHECK_HEADERS([sys/mntent.h])
326 AC_HEADER_MAJOR()dnl for use of makedev ()
18 gl_FSTYPENAME 327 gl_FSTYPENAME
19]) 328])
329
330# Replace Autoconf's AC_FUNC_GETMNTENT to omit checks that are unnecessary
331# nowadays.
332AC_DEFUN([AC_FUNC_GETMNTENT],
333[
334 # getmntent is in the standard C library on most systems, but in -lgen on
335 # Unixware.
336 AC_SEARCH_LIBS([getmntent], [gen])
337 AC_CHECK_FUNCS([getmntent])
338])
diff --git a/gl/m4/msvc-inval.m4 b/gl/m4/msvc-inval.m4
index 9a6a47a7..8d9d21b5 100644
--- a/gl/m4/msvc-inval.m4
+++ b/gl/m4/msvc-inval.m4
@@ -1,5 +1,5 @@
1# msvc-inval.m4 serial 1 1# msvc-inval.m4 serial 1
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/msvc-nothrow.m4 b/gl/m4/msvc-nothrow.m4
index a39618a4..0263e490 100644
--- a/gl/m4/msvc-nothrow.m4
+++ b/gl/m4/msvc-nothrow.m4
@@ -1,5 +1,5 @@
1# msvc-nothrow.m4 serial 1 1# msvc-nothrow.m4 serial 1
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/multiarch.m4 b/gl/m4/multiarch.m4
index 552ec7e7..3ba5b0f7 100644
--- a/gl/m4/multiarch.m4
+++ b/gl/m4/multiarch.m4
@@ -1,5 +1,5 @@
1# multiarch.m4 serial 7 1# multiarch.m4 serial 9
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -21,37 +21,40 @@ dnl with or without modifications, as long as this notice is preserved.
21AC_DEFUN_ONCE([gl_MULTIARCH], 21AC_DEFUN_ONCE([gl_MULTIARCH],
22[ 22[
23 dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN. 23 dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN.
24 gl_cv_c_multiarch=no 24 AC_CACHE_CHECK([whether the compiler produces multi-arch binaries],
25 AC_COMPILE_IFELSE( 25 [gl_cv_c_multiarch],
26 [AC_LANG_SOURCE( 26 [gl_cv_c_multiarch=no
27 [[#ifndef __APPLE_CC__ 27 AC_COMPILE_IFELSE(
28 not a universal capable compiler 28 [AC_LANG_SOURCE(
29 #endif 29 [[#ifndef __APPLE_CC__
30 typedef int dummy; 30 not a universal capable compiler
31 ]])], 31 #endif
32 [ 32 typedef int dummy;
33 dnl Check for potential -arch flags. It is not universal unless 33 ]])],
34 dnl there are at least two -arch flags with different values. 34 [
35 arch= 35 dnl Check for potential -arch flags. It is not universal unless
36 prev= 36 dnl there are at least two -arch flags with different values.
37 for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do 37 arch=
38 if test -n "$prev"; then 38 prev=
39 case $word in 39 for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
40 i?86 | x86_64 | ppc | ppc64) 40 if test -n "$prev"; then
41 if test -z "$arch" || test "$arch" = "$word"; then 41 case $word in
42 arch="$word" 42 i?86 | x86_64 | ppc | ppc64 | arm | arm64)
43 else 43 if test -z "$arch" || test "$arch" = "$word"; then
44 gl_cv_c_multiarch=yes 44 arch="$word"
45 fi 45 else
46 ;; 46 gl_cv_c_multiarch=yes
47 esac 47 fi
48 prev= 48 ;;
49 else 49 esac
50 if test "x$word" = "x-arch"; then 50 prev=
51 prev=arch 51 else
52 fi 52 if test "x$word" = "x-arch"; then
53 fi 53 prev=arch
54 done 54 fi
55 fi
56 done
57 ])
55 ]) 58 ])
56 if test $gl_cv_c_multiarch = yes; then 59 if test $gl_cv_c_multiarch = yes; then
57 APPLE_UNIVERSAL_BUILD=1 60 APPLE_UNIVERSAL_BUILD=1
diff --git a/gl/m4/netdb_h.m4 b/gl/m4/netdb_h.m4
index 2c69f999..e6aa8925 100644
--- a/gl/m4/netdb_h.m4
+++ b/gl/m4/netdb_h.m4
@@ -1,10 +1,10 @@
1# netdb_h.m4 serial 11 1# netdb_h.m4 serial 15
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_HEADER_NETDB], 7AC_DEFUN_ONCE([gl_NETDB_H],
8[ 8[
9 AC_REQUIRE([gl_NETDB_H_DEFAULTS]) 9 AC_REQUIRE([gl_NETDB_H_DEFAULTS])
10 gl_CHECK_NEXT_HEADERS([netdb.h]) 10 gl_CHECK_NEXT_HEADERS([netdb.h])
@@ -21,18 +21,33 @@ AC_DEFUN([gl_HEADER_NETDB],
21 [getaddrinfo freeaddrinfo gai_strerror getnameinfo]) 21 [getaddrinfo freeaddrinfo gai_strerror getnameinfo])
22]) 22])
23 23
24# gl_NETDB_MODULE_INDICATOR([modulename])
25# sets the shell variable that indicates the presence of the given module
26# to a C preprocessor expression that will evaluate to 1.
27# This macro invocation must not occur in macros that are AC_REQUIREd.
24AC_DEFUN([gl_NETDB_MODULE_INDICATOR], 28AC_DEFUN([gl_NETDB_MODULE_INDICATOR],
25[ 29[
26 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 30 dnl Ensure to expand the default settings once only.
27 AC_REQUIRE([gl_NETDB_H_DEFAULTS]) 31 gl_NETDB_H_REQUIRE_DEFAULTS
28 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 32 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
29 dnl Define it also as a C macro, for the benefit of the unit tests. 33 dnl Define it also as a C macro, for the benefit of the unit tests.
30 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 34 gl_MODULE_INDICATOR_FOR_TESTS([$1])
31]) 35])
32 36
37# Initializes the default values for AC_SUBSTed shell variables.
38# This macro must not be AC_REQUIREd. It must only be invoked, and only
39# outside of macros or in macros that are not AC_REQUIREd.
40AC_DEFUN([gl_NETDB_H_REQUIRE_DEFAULTS],
41[
42 m4_defun(GL_MODULE_INDICATOR_PREFIX[_NETDB_H_MODULE_INDICATOR_DEFAULTS], [
43 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETADDRINFO])
44 ])
45 m4_require(GL_MODULE_INDICATOR_PREFIX[_NETDB_H_MODULE_INDICATOR_DEFAULTS])
46 AC_REQUIRE([gl_NETDB_H_DEFAULTS])
47])
48
33AC_DEFUN([gl_NETDB_H_DEFAULTS], 49AC_DEFUN([gl_NETDB_H_DEFAULTS],
34[ 50[
35 GNULIB_GETADDRINFO=0; AC_SUBST([GNULIB_GETADDRINFO])
36 dnl Assume proper GNU behavior unless another module says otherwise. 51 dnl Assume proper GNU behavior unless another module says otherwise.
37 HAVE_STRUCT_ADDRINFO=1; AC_SUBST([HAVE_STRUCT_ADDRINFO]) 52 HAVE_STRUCT_ADDRINFO=1; AC_SUBST([HAVE_STRUCT_ADDRINFO])
38 HAVE_DECL_FREEADDRINFO=1; AC_SUBST([HAVE_DECL_FREEADDRINFO]) 53 HAVE_DECL_FREEADDRINFO=1; AC_SUBST([HAVE_DECL_FREEADDRINFO])
@@ -40,4 +55,5 @@ AC_DEFUN([gl_NETDB_H_DEFAULTS],
40 HAVE_DECL_GETADDRINFO=1; AC_SUBST([HAVE_DECL_GETADDRINFO]) 55 HAVE_DECL_GETADDRINFO=1; AC_SUBST([HAVE_DECL_GETADDRINFO])
41 HAVE_DECL_GETNAMEINFO=1; AC_SUBST([HAVE_DECL_GETNAMEINFO]) 56 HAVE_DECL_GETNAMEINFO=1; AC_SUBST([HAVE_DECL_GETNAMEINFO])
42 REPLACE_GAI_STRERROR=0; AC_SUBST([REPLACE_GAI_STRERROR]) 57 REPLACE_GAI_STRERROR=0; AC_SUBST([REPLACE_GAI_STRERROR])
58 REPLACE_GETADDRINFO=0; AC_SUBST([REPLACE_GETADDRINFO])
43]) 59])
diff --git a/gl/m4/netinet_in_h.m4 b/gl/m4/netinet_in_h.m4
index 21971b29..71154191 100644
--- a/gl/m4/netinet_in_h.m4
+++ b/gl/m4/netinet_in_h.m4
@@ -1,5 +1,5 @@
1# netinet_in_h.m4 serial 5 1# netinet_in_h.m4 serial 6
2dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -14,9 +14,9 @@ AC_DEFUN([gl_HEADER_NETINET_IN],
14 [gl_cv_header_netinet_in_h_selfcontained=no]) 14 [gl_cv_header_netinet_in_h_selfcontained=no])
15 ]) 15 ])
16 if test $gl_cv_header_netinet_in_h_selfcontained = yes; then 16 if test $gl_cv_header_netinet_in_h_selfcontained = yes; then
17 NETINET_IN_H='' 17 GL_GENERATE_NETINET_IN_H=false
18 else 18 else
19 NETINET_IN_H='netinet/in.h' 19 GL_GENERATE_NETINET_IN_H=true
20 AC_CHECK_HEADERS([netinet/in.h]) 20 AC_CHECK_HEADERS([netinet/in.h])
21 gl_CHECK_NEXT_HEADERS([netinet/in.h]) 21 gl_CHECK_NEXT_HEADERS([netinet/in.h])
22 if test $ac_cv_header_netinet_in_h = yes; then 22 if test $ac_cv_header_netinet_in_h = yes; then
@@ -26,6 +26,4 @@ AC_DEFUN([gl_HEADER_NETINET_IN],
26 fi 26 fi
27 AC_SUBST([HAVE_NETINET_IN_H]) 27 AC_SUBST([HAVE_NETINET_IN_H])
28 fi 28 fi
29 AC_SUBST([NETINET_IN_H])
30 AM_CONDITIONAL([GL_GENERATE_NETINET_IN_H], [test -n "$NETINET_IN_H"])
31]) 29])
diff --git a/gl/m4/nl_langinfo.m4 b/gl/m4/nl_langinfo.m4
index 25e21015..51e783ce 100644
--- a/gl/m4/nl_langinfo.m4
+++ b/gl/m4/nl_langinfo.m4
@@ -1,5 +1,5 @@
1# nl_langinfo.m4 serial 5 1# nl_langinfo.m4 serial 8
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -9,7 +9,10 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO],
9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) 9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
10 AC_REQUIRE([gl_LANGINFO_H]) 10 AC_REQUIRE([gl_LANGINFO_H])
11 AC_CHECK_FUNCS_ONCE([nl_langinfo]) 11 AC_CHECK_FUNCS_ONCE([nl_langinfo])
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([gl_FUNC_SETLOCALE_NULL])
14 AC_REQUIRE([gl_PTHREADLIB])
15 AC_CHECK_HEADERS_ONCE([threads.h])
13 if test $ac_cv_func_nl_langinfo = yes; then 16 if test $ac_cv_func_nl_langinfo = yes; then
14 # On Irix 6.5, YESEXPR is defined, but nl_langinfo(YESEXPR) is broken. 17 # On Irix 6.5, YESEXPR is defined, but nl_langinfo(YESEXPR) is broken.
15 AC_CACHE_CHECK([whether YESEXPR works], 18 AC_CACHE_CHECK([whether YESEXPR works],
@@ -36,8 +39,19 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO],
36 AC_DEFINE_UNQUOTED([FUNC_NL_LANGINFO_YESEXPR_WORKS], 39 AC_DEFINE_UNQUOTED([FUNC_NL_LANGINFO_YESEXPR_WORKS],
37 [$FUNC_NL_LANGINFO_YESEXPR_WORKS], 40 [$FUNC_NL_LANGINFO_YESEXPR_WORKS],
38 [Define to 1 if nl_langinfo (YESEXPR) returns a non-empty string.]) 41 [Define to 1 if nl_langinfo (YESEXPR) returns a non-empty string.])
39 if test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1 \ 42 # On Solaris 10 and Solaris 11.3, nl_langinfo is not multithread-safe.
40 && test $FUNC_NL_LANGINFO_YESEXPR_WORKS = 1; then 43 case "$host_os" in
44 solaris*) NL_LANGINFO_MTSAFE=0 ;;
45 *) NL_LANGINFO_MTSAFE=1 ;;
46 esac
47 AC_DEFINE_UNQUOTED([NL_LANGINFO_MTSAFE], [$NL_LANGINFO_MTSAFE],
48 [Define to 1 if nl_langinfo is multithread-safe.])
49 if test $HAVE_LANGINFO_CODESET = 1 \
50 && test $HAVE_LANGINFO_T_FMT_AMPM = 1 \
51 && test $HAVE_LANGINFO_ALTMON = 1 \
52 && test $HAVE_LANGINFO_ERA = 1 \
53 && test $FUNC_NL_LANGINFO_YESEXPR_WORKS = 1 \
54 && test $NL_LANGINFO_MTSAFE = 1; then
41 : 55 :
42 else 56 else
43 REPLACE_NL_LANGINFO=1 57 REPLACE_NL_LANGINFO=1
@@ -47,4 +61,17 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO],
47 else 61 else
48 HAVE_NL_LANGINFO=0 62 HAVE_NL_LANGINFO=0
49 fi 63 fi
64 if test $HAVE_NL_LANGINFO = 0 || test $HAVE_LANGINFO_CODESET = 0; then
65 LIB_NL_LANGINFO="$LIB_SETLOCALE_NULL"
66 else
67 LIB_NL_LANGINFO=
68 fi
69 dnl LIB_NL_LANGINFO is expected to be empty everywhere.
70 AC_SUBST([LIB_NL_LANGINFO])
71])
72
73# Prerequisites of lib/nl_langinfo-lock.c.
74AC_DEFUN([gl_PREREQ_NL_LANGINFO_LOCK],
75[
76 gl_VISIBILITY
50]) 77])
diff --git a/gl/m4/nls.m4 b/gl/m4/nls.m4
deleted file mode 100644
index 8f8a147b..00000000
--- a/gl/m4/nls.m4
+++ /dev/null
@@ -1,32 +0,0 @@
1# nls.m4 serial 5 (gettext-0.18)
2dnl Copyright (C) 1995-2003, 2005-2006, 2008-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl
8dnl This file can can be used in projects which are not available under
9dnl the GNU General Public License or the GNU Library General Public
10dnl License but which still want to provide support for the GNU gettext
11dnl functionality.
12dnl Please note that the actual code of the GNU gettext library is covered
13dnl by the GNU Library General Public License, and the rest of the GNU
14dnl gettext package package is covered by the GNU General Public License.
15dnl They are *not* in the public domain.
16
17dnl Authors:
18dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
19dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003.
20
21AC_PREREQ([2.50])
22
23AC_DEFUN([AM_NLS],
24[
25 AC_MSG_CHECKING([whether NLS is requested])
26 dnl Default is enabled NLS
27 AC_ARG_ENABLE([nls],
28 [ --disable-nls do not use Native Language Support],
29 USE_NLS=$enableval, USE_NLS=yes)
30 AC_MSG_RESULT([$USE_NLS])
31 AC_SUBST([USE_NLS])
32])
diff --git a/gl/m4/nocrash.m4 b/gl/m4/nocrash.m4
index 105b884f..6a766387 100644
--- a/gl/m4/nocrash.m4
+++ b/gl/m4/nocrash.m4
@@ -1,5 +1,5 @@
1# nocrash.m4 serial 4 1# nocrash.m4 serial 5
2dnl Copyright (C) 2005, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -53,7 +53,7 @@ nocrash_init (void)
53 /* Allocate a port on which the thread shall listen for exceptions. */ 53 /* Allocate a port on which the thread shall listen for exceptions. */
54 if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) 54 if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port)
55 == KERN_SUCCESS) { 55 == KERN_SUCCESS) {
56 /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ 56 /* See https://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */
57 if (mach_port_insert_right (self, our_exception_port, our_exception_port, 57 if (mach_port_insert_right (self, our_exception_port, our_exception_port,
58 MACH_MSG_TYPE_MAKE_SEND) 58 MACH_MSG_TYPE_MAKE_SEND)
59 == KERN_SUCCESS) { 59 == KERN_SUCCESS) {
@@ -72,14 +72,14 @@ nocrash_init (void)
72 for a particular thread. This has the effect that when our exception 72 for a particular thread. This has the effect that when our exception
73 port gets the message, the thread specific exception port has already 73 port gets the message, the thread specific exception port has already
74 been asked, and we don't need to bother about it. 74 been asked, and we don't need to bother about it.
75 See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ 75 See https://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */
76 task_set_exception_ports (self, mask, our_exception_port, 76 task_set_exception_ports (self, mask, our_exception_port,
77 EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); 77 EXCEPTION_DEFAULT, MACHINE_THREAD_STATE);
78 } 78 }
79 } 79 }
80 } 80 }
81} 81}
82#elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 82#elif defined _WIN32 && ! defined __CYGWIN__
83/* Avoid a crash on native Windows. */ 83/* Avoid a crash on native Windows. */
84#define WIN32_LEAN_AND_MEAN 84#define WIN32_LEAN_AND_MEAN
85#include <windows.h> 85#include <windows.h>
@@ -110,11 +110,12 @@ nocrash_init (void)
110#else 110#else
111/* Avoid a crash on POSIX systems. */ 111/* Avoid a crash on POSIX systems. */
112#include <signal.h> 112#include <signal.h>
113#include <unistd.h>
113/* A POSIX signal handler. */ 114/* A POSIX signal handler. */
114static void 115static void
115exception_handler (int sig) 116exception_handler (int sig)
116{ 117{
117 exit (1); 118 _exit (1);
118} 119}
119static void 120static void
120nocrash_init (void) 121nocrash_init (void)
diff --git a/gl/m4/off_t.m4 b/gl/m4/off_t.m4
index d355d013..880f3472 100644
--- a/gl/m4/off_t.m4
+++ b/gl/m4/off_t.m4
@@ -1,5 +1,5 @@
1# off_t.m4 serial 1 1# off_t.m4 serial 1
2dnl Copyright (C) 2012-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2012-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/onceonly.m4 b/gl/m4/onceonly.m4
deleted file mode 100644
index 0a875a3d..00000000
--- a/gl/m4/onceonly.m4
+++ /dev/null
@@ -1,104 +0,0 @@
1# onceonly.m4 serial 9
2dnl Copyright (C) 2002-2003, 2005-2006, 2008-2013 Free Software Foundation,
3dnl Inc.
4dnl
5dnl This file is free software; you can redistribute it and/or modify
6dnl it under the terms of the GNU General Public License as published by
7dnl the Free Software Foundation; either version 3 of the License, or
8dnl (at your option) any later version.
9dnl
10dnl This file is distributed in the hope that it will be useful,
11dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13dnl GNU General Public License for more details.
14dnl
15dnl You should have received a copy of the GNU General Public License
16dnl along with this file. If not, see <http://www.gnu.org/licenses/>.
17dnl
18dnl As a special exception to the GNU General Public License,
19dnl this file may be distributed as part of a program
20dnl that contains a configuration script generated by Autoconf, under
21dnl the same distribution terms as the rest of that program.
22
23dnl This file defines some "once only" variants of standard autoconf macros.
24dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS
25dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS
26dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS
27dnl AC_REQUIRE([AC_FUNC_STRCOLL]) like AC_FUNC_STRCOLL
28dnl The advantage is that the check for each of the headers/functions/decls
29dnl will be put only once into the 'configure' file. It keeps the size of
30dnl the 'configure' file down, and avoids redundant output when 'configure'
31dnl is run.
32dnl The drawback is that the checks cannot be conditionalized. If you write
33dnl if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi
34dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to
35dnl empty, and the check will be inserted before the body of the AC_DEFUNed
36dnl function.
37
38dnl The original code implemented AC_CHECK_HEADERS_ONCE and AC_CHECK_FUNCS_ONCE
39dnl in terms of AC_DEFUN and AC_REQUIRE. This implementation uses diversions to
40dnl named sections DEFAULTS and INIT_PREPARE in order to check all requested
41dnl headers at once, thus reducing the size of 'configure'. It is known to work
42dnl with autoconf 2.57..2.62 at least . The size reduction is ca. 9%.
43
44dnl Autoconf version 2.59 plus gnulib is required; this file is not needed
45dnl with Autoconf 2.60 or greater. But note that autoconf's implementation of
46dnl AC_CHECK_DECLS_ONCE expects a comma-separated list of symbols as first
47dnl argument!
48AC_PREREQ([2.59])
49
50# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of
51# AC_CHECK_HEADERS(HEADER1 HEADER2 ...).
52AC_DEFUN([AC_CHECK_HEADERS_ONCE], [
53 :
54 m4_foreach_w([gl_HEADER_NAME], [$1], [
55 AC_DEFUN([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME,
56 [./-], [___])), [
57 m4_divert_text([INIT_PREPARE],
58 [gl_header_list="$gl_header_list gl_HEADER_NAME"])
59 gl_HEADERS_EXPANSION
60 AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])),
61 [Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.])
62 ])
63 AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME,
64 [./-], [___])))
65 ])
66])
67m4_define([gl_HEADERS_EXPANSION], [
68 m4_divert_text([DEFAULTS], [gl_header_list=])
69 AC_CHECK_HEADERS([$gl_header_list])
70 m4_define([gl_HEADERS_EXPANSION], [])
71])
72
73# AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of
74# AC_CHECK_FUNCS(FUNC1 FUNC2 ...).
75AC_DEFUN([AC_CHECK_FUNCS_ONCE], [
76 :
77 m4_foreach_w([gl_FUNC_NAME], [$1], [
78 AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [
79 m4_divert_text([INIT_PREPARE],
80 [gl_func_list="$gl_func_list gl_FUNC_NAME"])
81 gl_FUNCS_EXPANSION
82 AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_FUNC_NAME])),
83 [Define to 1 if you have the ']m4_defn([gl_FUNC_NAME])[' function.])
84 ])
85 AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]))
86 ])
87])
88m4_define([gl_FUNCS_EXPANSION], [
89 m4_divert_text([DEFAULTS], [gl_func_list=])
90 AC_CHECK_FUNCS([$gl_func_list])
91 m4_define([gl_FUNCS_EXPANSION], [])
92])
93
94# AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of
95# AC_CHECK_DECLS(DECL1, DECL2, ...).
96AC_DEFUN([AC_CHECK_DECLS_ONCE], [
97 :
98 m4_foreach_w([gl_DECL_NAME], [$1], [
99 AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [
100 AC_CHECK_DECLS(m4_defn([gl_DECL_NAME]))
101 ])
102 AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]))
103 ])
104])
diff --git a/gl/m4/open-cloexec.m4 b/gl/m4/open-cloexec.m4
new file mode 100644
index 00000000..fd572fcd
--- /dev/null
+++ b/gl/m4/open-cloexec.m4
@@ -0,0 +1,21 @@
1# Test whether O_CLOEXEC is defined.
2
3dnl Copyright 2017-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_PREPROC_O_CLOEXEC],
9[
10 AC_CACHE_CHECK([for O_CLOEXEC],
11 [gl_cv_macro_O_CLOEXEC],
12 [AC_COMPILE_IFELSE(
13 [AC_LANG_PROGRAM([[#include <fcntl.h>
14 #ifndef O_CLOEXEC
15 choke me;
16 #endif
17 ]],
18 [[return O_CLOEXEC;]])],
19 [gl_cv_macro_O_CLOEXEC=yes],
20 [gl_cv_macro_O_CLOEXEC=no])])
21])
diff --git a/gl/m4/open-slash.m4 b/gl/m4/open-slash.m4
new file mode 100644
index 00000000..1f731f8a
--- /dev/null
+++ b/gl/m4/open-slash.m4
@@ -0,0 +1,60 @@
1# open-slash.m4 serial 2
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Tests whether open() and creat() recognize a trailing slash.
8dnl Sets gl_cv_func_open_slash.
9AC_DEFUN([gl_OPEN_TRAILING_SLASH_BUG],
10[
11 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12 dnl open("foo/") should not create a file when the file name has a
13 dnl trailing slash. FreeBSD only has the problem on symlinks.
14 AC_CHECK_FUNCS_ONCE([lstat])
15 AC_CACHE_CHECK([whether open recognizes a trailing slash],
16 [gl_cv_func_open_slash],
17 [# Assume that if we have lstat, we can also check symlinks.
18 if test $ac_cv_func_lstat = yes; then
19 touch conftest.tmp
20 ln -s conftest.tmp conftest.lnk
21 fi
22 AC_RUN_IFELSE(
23 [AC_LANG_SOURCE([[
24#include <fcntl.h>
25#if HAVE_UNISTD_H
26# include <unistd.h>
27#endif
28]GL_MDA_DEFINES[
29int main ()
30{
31 int result = 0;
32#if HAVE_LSTAT
33 if (open ("conftest.lnk/", O_RDONLY) != -1)
34 result |= 1;
35#endif
36 if (open ("conftest.sl/", O_CREAT, 0600) >= 0)
37 result |= 2;
38 return result;
39}]])],
40 [gl_cv_func_open_slash=yes],
41 [gl_cv_func_open_slash=no],
42 [
43changequote(,)dnl
44 case "$host_os" in
45 freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*)
46 gl_cv_func_open_slash="guessing no" ;;
47 *)
48 gl_cv_func_open_slash="guessing yes" ;;
49 esac
50changequote([,])dnl
51 ])
52 rm -f conftest.sl conftest.tmp conftest.lnk
53 ])
54 case "$gl_cv_func_open_slash" in
55 *no)
56 AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
57 [Define to 1 if open() fails to recognize a trailing slash.])
58 ;;
59 esac
60])
diff --git a/gl/m4/open.m4 b/gl/m4/open.m4
new file mode 100644
index 00000000..94fa2bb7
--- /dev/null
+++ b/gl/m4/open.m4
@@ -0,0 +1,56 @@
1# open.m4 serial 15
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_OPEN],
8[
9 AC_REQUIRE([AC_CANONICAL_HOST])
10 AC_REQUIRE([gl_PREPROC_O_CLOEXEC])
11 case "$host_os" in
12 mingw* | pw*)
13 REPLACE_OPEN=1
14 ;;
15 *)
16 dnl open("foo/") should not create a file when the file name has a
17 dnl trailing slash. FreeBSD only has the problem on symlinks.
18 AC_CHECK_FUNCS_ONCE([lstat])
19 if test "$gl_cv_macro_O_CLOEXEC" != yes; then
20 REPLACE_OPEN=1
21 fi
22 gl_OPEN_TRAILING_SLASH_BUG
23 case "$gl_cv_func_open_slash" in
24 *no)
25 REPLACE_OPEN=1
26 ;;
27 esac
28 ;;
29 esac
30 dnl Replace open() for supporting the gnulib-defined fchdir() function,
31 dnl to keep fchdir's bookkeeping up-to-date.
32 m4_ifdef([gl_FUNC_FCHDIR], [
33 if test $REPLACE_OPEN = 0; then
34 gl_TEST_FCHDIR
35 if test $HAVE_FCHDIR = 0; then
36 REPLACE_OPEN=1
37 fi
38 fi
39 ])
40 dnl Replace open() for supporting the gnulib-defined O_NONBLOCK flag.
41 m4_ifdef([gl_NONBLOCKING_IO], [
42 if test $REPLACE_OPEN = 0; then
43 gl_NONBLOCKING_IO
44 if test $gl_cv_have_open_O_NONBLOCK != yes; then
45 REPLACE_OPEN=1
46 fi
47 fi
48 ])
49])
50
51# Prerequisites of lib/open.c.
52AC_DEFUN([gl_PREREQ_OPEN],
53[
54 AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])
55 :
56])
diff --git a/gl/m4/pathmax.m4 b/gl/m4/pathmax.m4
new file mode 100644
index 00000000..6d47d2c0
--- /dev/null
+++ b/gl/m4/pathmax.m4
@@ -0,0 +1,42 @@
1# pathmax.m4 serial 11
2dnl Copyright (C) 2002-2003, 2005-2006, 2009-2023 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_PATHMAX],
9[
10 dnl Prerequisites of lib/pathmax.h.
11 AC_CHECK_HEADERS_ONCE([sys/param.h])
12])
13
14# Expands to a piece of C program that defines PATH_MAX in the same way as
15# "pathmax.h" will do.
16AC_DEFUN([gl_PATHMAX_SNIPPET], [[
17/* Arrange to define PATH_MAX, like "pathmax.h" does. */
18#if HAVE_UNISTD_H
19# include <unistd.h>
20#endif
21#include <limits.h>
22#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
23# include <sys/param.h>
24#endif
25#if !defined PATH_MAX && defined MAXPATHLEN
26# define PATH_MAX MAXPATHLEN
27#endif
28#ifdef __hpux
29# undef PATH_MAX
30# define PATH_MAX 1024
31#endif
32#if defined _WIN32 && ! defined __CYGWIN__
33# undef PATH_MAX
34# define PATH_MAX 260
35#endif
36]])
37
38# Prerequisites of gl_PATHMAX_SNIPPET.
39AC_DEFUN([gl_PATHMAX_SNIPPET_PREREQ],
40[
41 AC_CHECK_HEADERS_ONCE([unistd.h sys/param.h])
42])
diff --git a/gl/m4/pid_t.m4 b/gl/m4/pid_t.m4
new file mode 100644
index 00000000..0fd7d0a1
--- /dev/null
+++ b/gl/m4/pid_t.m4
@@ -0,0 +1,38 @@
1# pid_t.m4 serial 4
2dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# The following implementation works around a problem in autoconf <= 2.69.
8m4_version_prereq([2.70], [], [
9
10dnl Define pid_t if the headers don't define it.
11AC_DEFUN([AC_TYPE_PID_T],
12[
13 AC_CHECK_TYPE([pid_t],
14 [],
15 [dnl On 64-bit native Windows, define it to the equivalent of 'intptr_t'
16 dnl (= 'long long' = '__int64'), because that is the return type
17 dnl of the _spawnv* functions
18 dnl <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/spawnvp-wspawnvp>
19 dnl and the argument type of the _cwait function
20 dnl <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/cwait>.
21 dnl Otherwise (on 32-bit Windows and on old Unix platforms), define it
22 dnl to 'int'.
23 AC_COMPILE_IFELSE(
24 [AC_LANG_PROGRAM([[
25 #if defined _WIN64 && !defined __CYGWIN__
26 LLP64
27 #endif
28 ]])
29 ],
30 [gl_pid_type='int'],
31 [gl_pid_type='__int64'])
32 AC_DEFINE_UNQUOTED([pid_t], [$gl_pid_type],
33 [Define as a signed integer type capable of holding a process identifier.])
34 ],
35 [AC_INCLUDES_DEFAULT])
36])
37
38])# m4_version_prereq 2.70
diff --git a/gl/m4/po.m4 b/gl/m4/po.m4
deleted file mode 100644
index 1c70b6c1..00000000
--- a/gl/m4/po.m4
+++ /dev/null
@@ -1,453 +0,0 @@
1# po.m4 serial 21 (gettext-0.18.3)
2dnl Copyright (C) 1995-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003.
19
20AC_PREREQ([2.60])
21
22dnl Checks for all prerequisites of the po subdirectory.
23AC_DEFUN([AM_PO_SUBDIRS],
24[
25 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
26 AC_REQUIRE([AC_PROG_INSTALL])dnl
27 AC_REQUIRE([AC_PROG_MKDIR_P])dnl
28 AC_REQUIRE([AC_PROG_SED])dnl
29 AC_REQUIRE([AM_NLS])dnl
30
31 dnl Release version of the gettext macros. This is used to ensure that
32 dnl the gettext macros and po/Makefile.in.in are in sync.
33 AC_SUBST([GETTEXT_MACRO_VERSION], [0.18])
34
35 dnl Perform the following tests also if --disable-nls has been given,
36 dnl because they are needed for "make dist" to work.
37
38 dnl Search for GNU msgfmt in the PATH.
39 dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
40 dnl The second test excludes FreeBSD msgfmt.
41 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
42 [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
43 (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
44 :)
45 AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT])
46
47 dnl Test whether it is GNU msgfmt >= 0.15.
48changequote(,)dnl
49 case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
50 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;;
51 *) MSGFMT_015=$MSGFMT ;;
52 esac
53changequote([,])dnl
54 AC_SUBST([MSGFMT_015])
55changequote(,)dnl
56 case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
57 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;;
58 *) GMSGFMT_015=$GMSGFMT ;;
59 esac
60changequote([,])dnl
61 AC_SUBST([GMSGFMT_015])
62
63 dnl Search for GNU xgettext 0.12 or newer in the PATH.
64 dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
65 dnl The second test excludes FreeBSD xgettext.
66 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
67 [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
68 (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
69 :)
70 dnl Remove leftover from FreeBSD xgettext call.
71 rm -f messages.po
72
73 dnl Test whether it is GNU xgettext >= 0.15.
74changequote(,)dnl
75 case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
76 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;;
77 *) XGETTEXT_015=$XGETTEXT ;;
78 esac
79changequote([,])dnl
80 AC_SUBST([XGETTEXT_015])
81
82 dnl Search for GNU msgmerge 0.11 or newer in the PATH.
83 AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
84 [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :)
85
86 dnl Installation directories.
87 dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we
88 dnl have to define it here, so that it can be used in po/Makefile.
89 test -n "$localedir" || localedir='${datadir}/locale'
90 AC_SUBST([localedir])
91
92 dnl Support for AM_XGETTEXT_OPTION.
93 test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS=
94 AC_SUBST([XGETTEXT_EXTRA_OPTIONS])
95
96 AC_CONFIG_COMMANDS([po-directories], [[
97 for ac_file in $CONFIG_FILES; do
98 # Support "outfile[:infile[:infile...]]"
99 case "$ac_file" in
100 *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
101 esac
102 # PO directories have a Makefile.in generated from Makefile.in.in.
103 case "$ac_file" in */Makefile.in)
104 # Adjust a relative srcdir.
105 ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
106 ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'`
107 ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
108 # In autoconf-2.13 it is called $ac_given_srcdir.
109 # In autoconf-2.50 it is called $srcdir.
110 test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
111 case "$ac_given_srcdir" in
112 .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
113 /*) top_srcdir="$ac_given_srcdir" ;;
114 *) top_srcdir="$ac_dots$ac_given_srcdir" ;;
115 esac
116 # Treat a directory as a PO directory if and only if it has a
117 # POTFILES.in file. This allows packages to have multiple PO
118 # directories under different names or in different locations.
119 if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
120 rm -f "$ac_dir/POTFILES"
121 test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
122 gt_tab=`printf '\t'`
123 cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
124 POMAKEFILEDEPS="POTFILES.in"
125 # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend
126 # on $ac_dir but don't depend on user-specified configuration
127 # parameters.
128 if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
129 # The LINGUAS file contains the set of available languages.
130 if test -n "$OBSOLETE_ALL_LINGUAS"; then
131 test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
132 fi
133 ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
134 # Hide the ALL_LINGUAS assignment from automake < 1.5.
135 eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
136 POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
137 else
138 # The set of available languages was given in configure.in.
139 # Hide the ALL_LINGUAS assignment from automake < 1.5.
140 eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS'
141 fi
142 # Compute POFILES
143 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
144 # Compute UPDATEPOFILES
145 # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
146 # Compute DUMMYPOFILES
147 # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
148 # Compute GMOFILES
149 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
150 case "$ac_given_srcdir" in
151 .) srcdirpre= ;;
152 *) srcdirpre='$(srcdir)/' ;;
153 esac
154 POFILES=
155 UPDATEPOFILES=
156 DUMMYPOFILES=
157 GMOFILES=
158 for lang in $ALL_LINGUAS; do
159 POFILES="$POFILES $srcdirpre$lang.po"
160 UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
161 DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
162 GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
163 done
164 # CATALOGS depends on both $ac_dir and the user's LINGUAS
165 # environment variable.
166 INST_LINGUAS=
167 if test -n "$ALL_LINGUAS"; then
168 for presentlang in $ALL_LINGUAS; do
169 useit=no
170 if test "%UNSET%" != "$LINGUAS"; then
171 desiredlanguages="$LINGUAS"
172 else
173 desiredlanguages="$ALL_LINGUAS"
174 fi
175 for desiredlang in $desiredlanguages; do
176 # Use the presentlang catalog if desiredlang is
177 # a. equal to presentlang, or
178 # b. a variant of presentlang (because in this case,
179 # presentlang can be used as a fallback for messages
180 # which are not translated in the desiredlang catalog).
181 case "$desiredlang" in
182 "$presentlang"*) useit=yes;;
183 esac
184 done
185 if test $useit = yes; then
186 INST_LINGUAS="$INST_LINGUAS $presentlang"
187 fi
188 done
189 fi
190 CATALOGS=
191 if test -n "$INST_LINGUAS"; then
192 for lang in $INST_LINGUAS; do
193 CATALOGS="$CATALOGS $lang.gmo"
194 done
195 fi
196 test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
197 sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
198 for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do
199 if test -f "$f"; then
200 case "$f" in
201 *.orig | *.bak | *~) ;;
202 *) cat "$f" >> "$ac_dir/Makefile" ;;
203 esac
204 fi
205 done
206 fi
207 ;;
208 esac
209 done]],
210 [# Capture the value of obsolete ALL_LINGUAS because we need it to compute
211 # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it
212 # from automake < 1.5.
213 eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"'
214 # Capture the value of LINGUAS because we need it to compute CATALOGS.
215 LINGUAS="${LINGUAS-%UNSET%}"
216 ])
217])
218
219dnl Postprocesses a Makefile in a directory containing PO files.
220AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE],
221[
222 # When this code is run, in config.status, two variables have already been
223 # set:
224 # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in,
225 # - LINGUAS is the value of the environment variable LINGUAS at configure
226 # time.
227
228changequote(,)dnl
229 # Adjust a relative srcdir.
230 ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
231 ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'`
232 ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
233 # In autoconf-2.13 it is called $ac_given_srcdir.
234 # In autoconf-2.50 it is called $srcdir.
235 test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
236 case "$ac_given_srcdir" in
237 .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
238 /*) top_srcdir="$ac_given_srcdir" ;;
239 *) top_srcdir="$ac_dots$ac_given_srcdir" ;;
240 esac
241
242 # Find a way to echo strings without interpreting backslash.
243 if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then
244 gt_echo='echo'
245 else
246 if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then
247 gt_echo='printf %s\n'
248 else
249 echo_func () {
250 cat <<EOT
251$*
252EOT
253 }
254 gt_echo='echo_func'
255 fi
256 fi
257
258 # A sed script that extracts the value of VARIABLE from a Makefile.
259 tab=`printf '\t'`
260 sed_x_variable='
261# Test if the hold space is empty.
262x
263s/P/P/
264x
265ta
266# Yes it was empty. Look if we have the expected variable definition.
267/^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=/{
268 # Seen the first line of the variable definition.
269 s/^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=//
270 ba
271}
272bd
273:a
274# Here we are processing a line from the variable definition.
275# Remove comment, more precisely replace it with a space.
276s/#.*$/ /
277# See if the line ends in a backslash.
278tb
279:b
280s/\\$//
281# Print the line, without the trailing backslash.
282p
283tc
284# There was no trailing backslash. The end of the variable definition is
285# reached. Clear the hold space.
286s/^.*$//
287x
288bd
289:c
290# A trailing backslash means that the variable definition continues in the
291# next line. Put a nonempty string into the hold space to indicate this.
292s/^.*$/P/
293x
294:d
295'
296changequote([,])dnl
297
298 # Set POTFILES to the value of the Makefile variable POTFILES.
299 sed_x_POTFILES=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/POTFILES/g'`
300 POTFILES=`sed -n -e "$sed_x_POTFILES" < "$ac_file"`
301 # Compute POTFILES_DEPS as
302 # $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
303 POTFILES_DEPS=
304 for file in $POTFILES; do
305 POTFILES_DEPS="$POTFILES_DEPS "'$(top_srcdir)/'"$file"
306 done
307 POMAKEFILEDEPS=""
308
309 if test -n "$OBSOLETE_ALL_LINGUAS"; then
310 test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
311 fi
312 if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
313 # The LINGUAS file contains the set of available languages.
314 ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
315 POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
316 else
317 # Set ALL_LINGUAS to the value of the Makefile variable LINGUAS.
318 sed_x_LINGUAS=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/LINGUAS/g'`
319 ALL_LINGUAS_=`sed -n -e "$sed_x_LINGUAS" < "$ac_file"`
320 fi
321 # Hide the ALL_LINGUAS assignment from automake < 1.5.
322 eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
323 # Compute POFILES
324 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
325 # Compute UPDATEPOFILES
326 # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
327 # Compute DUMMYPOFILES
328 # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
329 # Compute GMOFILES
330 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
331 # Compute PROPERTIESFILES
332 # as $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).properties)
333 # Compute CLASSFILES
334 # as $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).class)
335 # Compute QMFILES
336 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).qm)
337 # Compute MSGFILES
338 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang)).msg)
339 # Compute RESOURCESDLLFILES
340 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang))/$(DOMAIN).resources.dll)
341 case "$ac_given_srcdir" in
342 .) srcdirpre= ;;
343 *) srcdirpre='$(srcdir)/' ;;
344 esac
345 POFILES=
346 UPDATEPOFILES=
347 DUMMYPOFILES=
348 GMOFILES=
349 PROPERTIESFILES=
350 CLASSFILES=
351 QMFILES=
352 MSGFILES=
353 RESOURCESDLLFILES=
354 for lang in $ALL_LINGUAS; do
355 POFILES="$POFILES $srcdirpre$lang.po"
356 UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
357 DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
358 GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
359 PROPERTIESFILES="$PROPERTIESFILES \$(top_srcdir)/\$(DOMAIN)_$lang.properties"
360 CLASSFILES="$CLASSFILES \$(top_srcdir)/\$(DOMAIN)_$lang.class"
361 QMFILES="$QMFILES $srcdirpre$lang.qm"
362 frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
363 MSGFILES="$MSGFILES $srcdirpre$frobbedlang.msg"
364 frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
365 RESOURCESDLLFILES="$RESOURCESDLLFILES $srcdirpre$frobbedlang/\$(DOMAIN).resources.dll"
366 done
367 # CATALOGS depends on both $ac_dir and the user's LINGUAS
368 # environment variable.
369 INST_LINGUAS=
370 if test -n "$ALL_LINGUAS"; then
371 for presentlang in $ALL_LINGUAS; do
372 useit=no
373 if test "%UNSET%" != "$LINGUAS"; then
374 desiredlanguages="$LINGUAS"
375 else
376 desiredlanguages="$ALL_LINGUAS"
377 fi
378 for desiredlang in $desiredlanguages; do
379 # Use the presentlang catalog if desiredlang is
380 # a. equal to presentlang, or
381 # b. a variant of presentlang (because in this case,
382 # presentlang can be used as a fallback for messages
383 # which are not translated in the desiredlang catalog).
384 case "$desiredlang" in
385 "$presentlang"*) useit=yes;;
386 esac
387 done
388 if test $useit = yes; then
389 INST_LINGUAS="$INST_LINGUAS $presentlang"
390 fi
391 done
392 fi
393 CATALOGS=
394 JAVACATALOGS=
395 QTCATALOGS=
396 TCLCATALOGS=
397 CSHARPCATALOGS=
398 if test -n "$INST_LINGUAS"; then
399 for lang in $INST_LINGUAS; do
400 CATALOGS="$CATALOGS $lang.gmo"
401 JAVACATALOGS="$JAVACATALOGS \$(DOMAIN)_$lang.properties"
402 QTCATALOGS="$QTCATALOGS $lang.qm"
403 frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
404 TCLCATALOGS="$TCLCATALOGS $frobbedlang.msg"
405 frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
406 CSHARPCATALOGS="$CSHARPCATALOGS $frobbedlang/\$(DOMAIN).resources.dll"
407 done
408 fi
409
410 sed -e "s|@POTFILES_DEPS@|$POTFILES_DEPS|g" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@PROPERTIESFILES@|$PROPERTIESFILES|g" -e "s|@CLASSFILES@|$CLASSFILES|g" -e "s|@QMFILES@|$QMFILES|g" -e "s|@MSGFILES@|$MSGFILES|g" -e "s|@RESOURCESDLLFILES@|$RESOURCESDLLFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@JAVACATALOGS@|$JAVACATALOGS|g" -e "s|@QTCATALOGS@|$QTCATALOGS|g" -e "s|@TCLCATALOGS@|$TCLCATALOGS|g" -e "s|@CSHARPCATALOGS@|$CSHARPCATALOGS|g" -e 's,^#distdir:,distdir:,' < "$ac_file" > "$ac_file.tmp"
411 tab=`printf '\t'`
412 if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then
413 # Add dependencies that cannot be formulated as a simple suffix rule.
414 for lang in $ALL_LINGUAS; do
415 frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
416 cat >> "$ac_file.tmp" <<EOF
417$frobbedlang.msg: $lang.po
418${tab}@echo "\$(MSGFMT) -c --tcl -d \$(srcdir) -l $lang $srcdirpre$lang.po"; \
419${tab}\$(MSGFMT) -c --tcl -d "\$(srcdir)" -l $lang $srcdirpre$lang.po || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
420EOF
421 done
422 fi
423 if grep -l '@CSHARPCATALOGS@' "$ac_file" > /dev/null; then
424 # Add dependencies that cannot be formulated as a simple suffix rule.
425 for lang in $ALL_LINGUAS; do
426 frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
427 cat >> "$ac_file.tmp" <<EOF
428$frobbedlang/\$(DOMAIN).resources.dll: $lang.po
429${tab}@echo "\$(MSGFMT) -c --csharp -d \$(srcdir) -l $lang $srcdirpre$lang.po -r \$(DOMAIN)"; \
430${tab}\$(MSGFMT) -c --csharp -d "\$(srcdir)" -l $lang $srcdirpre$lang.po -r "\$(DOMAIN)" || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
431EOF
432 done
433 fi
434 if test -n "$POMAKEFILEDEPS"; then
435 cat >> "$ac_file.tmp" <<EOF
436Makefile: $POMAKEFILEDEPS
437EOF
438 fi
439 mv "$ac_file.tmp" "$ac_file"
440])
441
442dnl Initializes the accumulator used by AM_XGETTEXT_OPTION.
443AC_DEFUN([AM_XGETTEXT_OPTION_INIT],
444[
445 XGETTEXT_EXTRA_OPTIONS=
446])
447
448dnl Registers an option to be passed to xgettext in the po subdirectory.
449AC_DEFUN([AM_XGETTEXT_OPTION],
450[
451 AC_REQUIRE([AM_XGETTEXT_OPTION_INIT])
452 XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS $1"
453])
diff --git a/gl/m4/printf-posix.m4 b/gl/m4/printf-posix.m4
deleted file mode 100644
index d7dfb60f..00000000
--- a/gl/m4/printf-posix.m4
+++ /dev/null
@@ -1,48 +0,0 @@
1# printf-posix.m4 serial 6 (gettext-0.18.2)
2dnl Copyright (C) 2003, 2007, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8dnl Test whether the printf() function supports POSIX/XSI format strings with
9dnl positions.
10
11AC_DEFUN([gt_PRINTF_POSIX],
12[
13 AC_REQUIRE([AC_PROG_CC])
14 AC_CACHE_CHECK([whether printf() supports POSIX/XSI format strings],
15 gt_cv_func_printf_posix,
16 [
17 AC_RUN_IFELSE(
18 [AC_LANG_SOURCE([[
19#include <stdio.h>
20#include <string.h>
21/* The string "%2$d %1$d", with dollar characters protected from the shell's
22 dollar expansion (possibly an autoconf bug). */
23static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' };
24static char buf[100];
25int main ()
26{
27 sprintf (buf, format, 33, 55);
28 return (strcmp (buf, "55 33") != 0);
29}]])],
30 [gt_cv_func_printf_posix=yes],
31 [gt_cv_func_printf_posix=no],
32 [
33 AC_EGREP_CPP([notposix], [
34#if defined __NetBSD__ || defined __BEOS__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__
35 notposix
36#endif
37 ],
38 [gt_cv_func_printf_posix="guessing no"],
39 [gt_cv_func_printf_posix="guessing yes"])
40 ])
41 ])
42 case $gt_cv_func_printf_posix in
43 *yes)
44 AC_DEFINE([HAVE_POSIX_PRINTF], [1],
45 [Define if your printf() function supports format strings with positions.])
46 ;;
47 esac
48])
diff --git a/gl/m4/printf.m4 b/gl/m4/printf.m4
index ef44f785..4e65abc6 100644
--- a/gl/m4/printf.m4
+++ b/gl/m4/printf.m4
@@ -1,5 +1,5 @@
1# printf.m4 serial 50 1# printf.m4 serial 73
2dnl Copyright (C) 2003, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -38,6 +38,8 @@ int main ()
38 if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0 38 if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0
39 || strcmp (buf, "12345671 33") != 0) 39 || strcmp (buf, "12345671 33") != 0)
40 result |= 1; 40 result |= 1;
41#else
42 result |= 1;
41#endif 43#endif
42 buf[0] = '\0'; 44 buf[0] = '\0';
43 if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0 45 if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0
@@ -56,13 +58,16 @@ int main ()
56 [gl_cv_func_printf_sizes_c99=yes], 58 [gl_cv_func_printf_sizes_c99=yes],
57 [gl_cv_func_printf_sizes_c99=no], 59 [gl_cv_func_printf_sizes_c99=no],
58 [ 60 [
59changequote(,)dnl
60 case "$host_os" in 61 case "$host_os" in
62changequote(,)dnl
61 # Guess yes on glibc systems. 63 # Guess yes on glibc systems.
62 *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; 64 *-gnu* | gnu*) gl_cv_func_printf_sizes_c99="guessing yes";;
65 # Guess yes on musl systems.
66 *-musl*) gl_cv_func_printf_sizes_c99="guessing yes";;
63 # Guess yes on FreeBSD >= 5. 67 # Guess yes on FreeBSD >= 5.
64 freebsd[1-4]*) gl_cv_func_printf_sizes_c99="guessing no";; 68 freebsd[1-4].*) gl_cv_func_printf_sizes_c99="guessing no";;
65 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; 69 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
70 midnightbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
66 # Guess yes on Mac OS X >= 10.3. 71 # Guess yes on Mac OS X >= 10.3.
67 darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";; 72 darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";;
68 darwin*) gl_cv_func_printf_sizes_c99="guessing yes";; 73 darwin*) gl_cv_func_printf_sizes_c99="guessing yes";;
@@ -77,10 +82,21 @@ changequote(,)dnl
77 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 82 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
78 gl_cv_func_printf_sizes_c99="guessing no";; 83 gl_cv_func_printf_sizes_c99="guessing no";;
79 netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; 84 netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
80 # If we don't know, assume the worst. 85 # Guess yes on Android.
81 *) gl_cv_func_printf_sizes_c99="guessing no";; 86 linux*-android*) gl_cv_func_printf_sizes_c99="guessing yes";;
82 esac
83changequote([,])dnl 87changequote([,])dnl
88 # Guess yes on MSVC, no on mingw.
89 mingw*) AC_EGREP_CPP([Known], [
90#ifdef _MSC_VER
91 Known
92#endif
93 ],
94 [gl_cv_func_printf_sizes_c99="guessing yes"],
95 [gl_cv_func_printf_sizes_c99="guessing no"])
96 ;;
97 # If we don't know, obey --enable-cross-guesses.
98 *) gl_cv_func_printf_sizes_c99="$gl_cross_guess_normal";;
99 esac
84 ]) 100 ])
85 ]) 101 ])
86]) 102])
@@ -120,14 +136,22 @@ int main ()
120}]])], 136}]])],
121 [gl_cv_func_printf_long_double=yes], 137 [gl_cv_func_printf_long_double=yes],
122 [gl_cv_func_printf_long_double=no], 138 [gl_cv_func_printf_long_double=no],
123 [ 139 [case "$host_os" in
124changequote(,)dnl 140 # Guess no on BeOS.
125 case "$host_os" in 141 beos*) gl_cv_func_printf_long_double="guessing no";;
126 beos*) gl_cv_func_printf_long_double="guessing no";; 142 # Guess yes on Android.
127 mingw* | pw*) gl_cv_func_printf_long_double="guessing no";; 143 linux*-android*) gl_cv_func_printf_long_double="guessing yes";;
128 *) gl_cv_func_printf_long_double="guessing yes";; 144 # Guess yes on MSVC, no on mingw.
145 mingw*) AC_EGREP_CPP([Known], [
146#ifdef _MSC_VER
147 Known
148#endif
149 ],
150 [gl_cv_func_printf_long_double="guessing yes"],
151 [gl_cv_func_printf_long_double="guessing no"])
152 ;;
153 *) gl_cv_func_printf_long_double="guessing yes";;
129 esac 154 esac
130changequote([,])dnl
131 ]) 155 ])
132 ]) 156 ])
133]) 157])
@@ -215,13 +239,16 @@ int main ()
215 [gl_cv_func_printf_infinite=yes], 239 [gl_cv_func_printf_infinite=yes],
216 [gl_cv_func_printf_infinite=no], 240 [gl_cv_func_printf_infinite=no],
217 [ 241 [
218changequote(,)dnl
219 case "$host_os" in 242 case "$host_os" in
243changequote(,)dnl
220 # Guess yes on glibc systems. 244 # Guess yes on glibc systems.
221 *-gnu*) gl_cv_func_printf_infinite="guessing yes";; 245 *-gnu* | gnu*) gl_cv_func_printf_infinite="guessing yes";;
246 # Guess yes on musl systems.
247 *-musl*) gl_cv_func_printf_infinite="guessing yes";;
222 # Guess yes on FreeBSD >= 6. 248 # Guess yes on FreeBSD >= 6.
223 freebsd[1-5]*) gl_cv_func_printf_infinite="guessing no";; 249 freebsd[1-5].*) gl_cv_func_printf_infinite="guessing no";;
224 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; 250 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";;
251 midnightbsd*) gl_cv_func_printf_infinite="guessing yes";;
225 # Guess yes on Mac OS X >= 10.3. 252 # Guess yes on Mac OS X >= 10.3.
226 darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";; 253 darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";;
227 darwin*) gl_cv_func_printf_infinite="guessing yes";; 254 darwin*) gl_cv_func_printf_infinite="guessing yes";;
@@ -232,12 +259,26 @@ changequote(,)dnl
232 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 259 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
233 gl_cv_func_printf_infinite="guessing no";; 260 gl_cv_func_printf_infinite="guessing no";;
234 netbsd*) gl_cv_func_printf_infinite="guessing yes";; 261 netbsd*) gl_cv_func_printf_infinite="guessing yes";;
262 # Guess yes on OpenBSD >= 6.0.
263 openbsd[1-5].*) gl_cv_func_printf_infinite="guessing no";;
264 openbsd*) gl_cv_func_printf_infinite="guessing yes";;
235 # Guess yes on BeOS. 265 # Guess yes on BeOS.
236 beos*) gl_cv_func_printf_infinite="guessing yes";; 266 beos*) gl_cv_func_printf_infinite="guessing yes";;
237 # If we don't know, assume the worst. 267 # Guess no on Android.
238 *) gl_cv_func_printf_infinite="guessing no";; 268 linux*-android*) gl_cv_func_printf_infinite="guessing no";;
239 esac
240changequote([,])dnl 269changequote([,])dnl
270 # Guess yes on MSVC, no on mingw.
271 mingw*) AC_EGREP_CPP([Known], [
272#ifdef _MSC_VER
273 Known
274#endif
275 ],
276 [gl_cv_func_printf_infinite="guessing yes"],
277 [gl_cv_func_printf_infinite="guessing no"])
278 ;;
279 # If we don't know, obey --enable-cross-guesses.
280 *) gl_cv_func_printf_infinite="$gl_cross_guess_normal";;
281 esac
241 ]) 282 ])
242 ]) 283 ])
243]) 284])
@@ -328,7 +369,7 @@ int main ()
328# ifdef WORDS_BIGENDIAN 369# ifdef WORDS_BIGENDIAN
329# define LDBL80_WORDS(exponent,manthi,mantlo) \ 370# define LDBL80_WORDS(exponent,manthi,mantlo) \
330 { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \ 371 { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \
331 ((unsigned int) (manthi) << 16) | (unsigned int) (mantlo) >> 16), \ 372 ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), \
332 (unsigned int) (mantlo) << 16 \ 373 (unsigned int) (mantlo) << 16 \
333 } 374 }
334# else 375# else
@@ -365,66 +406,51 @@ int main ()
365 { /* Pseudo-NaN. */ 406 { /* Pseudo-NaN. */
366 static union { unsigned int word[4]; long double value; } x = 407 static union { unsigned int word[4]; long double value; } x =
367 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; 408 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) };
368 if (sprintf (buf, "%Lf", x.value) < 0 409 if (sprintf (buf, "%Lf", x.value) <= 0)
369 || !strisnan (buf, 0, strlen (buf)))
370 result |= 4; 410 result |= 4;
371 if (sprintf (buf, "%Le", x.value) < 0 411 if (sprintf (buf, "%Le", x.value) <= 0)
372 || !strisnan (buf, 0, strlen (buf)))
373 result |= 4; 412 result |= 4;
374 if (sprintf (buf, "%Lg", x.value) < 0 413 if (sprintf (buf, "%Lg", x.value) <= 0)
375 || !strisnan (buf, 0, strlen (buf)))
376 result |= 4; 414 result |= 4;
377 } 415 }
378 { /* Pseudo-Infinity. */ 416 { /* Pseudo-Infinity. */
379 static union { unsigned int word[4]; long double value; } x = 417 static union { unsigned int word[4]; long double value; } x =
380 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; 418 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) };
381 if (sprintf (buf, "%Lf", x.value) < 0 419 if (sprintf (buf, "%Lf", x.value) <= 0)
382 || !strisnan (buf, 0, strlen (buf)))
383 result |= 8; 420 result |= 8;
384 if (sprintf (buf, "%Le", x.value) < 0 421 if (sprintf (buf, "%Le", x.value) <= 0)
385 || !strisnan (buf, 0, strlen (buf)))
386 result |= 8; 422 result |= 8;
387 if (sprintf (buf, "%Lg", x.value) < 0 423 if (sprintf (buf, "%Lg", x.value) <= 0)
388 || !strisnan (buf, 0, strlen (buf)))
389 result |= 8; 424 result |= 8;
390 } 425 }
391 { /* Pseudo-Zero. */ 426 { /* Pseudo-Zero. */
392 static union { unsigned int word[4]; long double value; } x = 427 static union { unsigned int word[4]; long double value; } x =
393 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; 428 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) };
394 if (sprintf (buf, "%Lf", x.value) < 0 429 if (sprintf (buf, "%Lf", x.value) <= 0)
395 || !strisnan (buf, 0, strlen (buf)))
396 result |= 16; 430 result |= 16;
397 if (sprintf (buf, "%Le", x.value) < 0 431 if (sprintf (buf, "%Le", x.value) <= 0)
398 || !strisnan (buf, 0, strlen (buf)))
399 result |= 16; 432 result |= 16;
400 if (sprintf (buf, "%Lg", x.value) < 0 433 if (sprintf (buf, "%Lg", x.value) <= 0)
401 || !strisnan (buf, 0, strlen (buf)))
402 result |= 16; 434 result |= 16;
403 } 435 }
404 { /* Unnormalized number. */ 436 { /* Unnormalized number. */
405 static union { unsigned int word[4]; long double value; } x = 437 static union { unsigned int word[4]; long double value; } x =
406 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; 438 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) };
407 if (sprintf (buf, "%Lf", x.value) < 0 439 if (sprintf (buf, "%Lf", x.value) <= 0)
408 || !strisnan (buf, 0, strlen (buf)))
409 result |= 32; 440 result |= 32;
410 if (sprintf (buf, "%Le", x.value) < 0 441 if (sprintf (buf, "%Le", x.value) <= 0)
411 || !strisnan (buf, 0, strlen (buf)))
412 result |= 32; 442 result |= 32;
413 if (sprintf (buf, "%Lg", x.value) < 0 443 if (sprintf (buf, "%Lg", x.value) <= 0)
414 || !strisnan (buf, 0, strlen (buf)))
415 result |= 32; 444 result |= 32;
416 } 445 }
417 { /* Pseudo-Denormal. */ 446 { /* Pseudo-Denormal. */
418 static union { unsigned int word[4]; long double value; } x = 447 static union { unsigned int word[4]; long double value; } x =
419 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; 448 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) };
420 if (sprintf (buf, "%Lf", x.value) < 0 449 if (sprintf (buf, "%Lf", x.value) <= 0)
421 || !strisnan (buf, 0, strlen (buf)))
422 result |= 64; 450 result |= 64;
423 if (sprintf (buf, "%Le", x.value) < 0 451 if (sprintf (buf, "%Le", x.value) <= 0)
424 || !strisnan (buf, 0, strlen (buf)))
425 result |= 64; 452 result |= 64;
426 if (sprintf (buf, "%Lg", x.value) < 0 453 if (sprintf (buf, "%Lg", x.value) <= 0)
427 || !strisnan (buf, 0, strlen (buf)))
428 result |= 64; 454 result |= 64;
429 } 455 }
430#endif 456#endif
@@ -432,27 +458,43 @@ int main ()
432}]])], 458}]])],
433 [gl_cv_func_printf_infinite_long_double=yes], 459 [gl_cv_func_printf_infinite_long_double=yes],
434 [gl_cv_func_printf_infinite_long_double=no], 460 [gl_cv_func_printf_infinite_long_double=no],
435 [ 461 [case "$host_cpu" in
436changequote(,)dnl
437 case "$host_cpu" in
438 # Guess no on ia64, x86_64, i386. 462 # Guess no on ia64, x86_64, i386.
439 ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";; 463 ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";;
440 *) 464 *)
441 case "$host_os" in 465 case "$host_os" in
466changequote(,)dnl
442 # Guess yes on glibc systems. 467 # Guess yes on glibc systems.
443 *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; 468 *-gnu* | gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";;
469 # Guess yes on musl systems.
470 *-musl*) gl_cv_func_printf_infinite_long_double="guessing yes";;
444 # Guess yes on FreeBSD >= 6. 471 # Guess yes on FreeBSD >= 6.
445 freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";; 472 freebsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";;
446 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; 473 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
474 midnightbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
447 # Guess yes on HP-UX >= 11. 475 # Guess yes on HP-UX >= 11.
448 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";; 476 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";;
449 hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";; 477 hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";;
450 # If we don't know, assume the worst. 478 # Guess yes on OpenBSD >= 6.0.
451 *) gl_cv_func_printf_infinite_long_double="guessing no";; 479 openbsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";;
480 openbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
481 # Guess no on Android.
482 linux*-android*) gl_cv_func_printf_infinite_long_double="guessing no";;
483changequote([,])dnl
484 # Guess yes on MSVC, no on mingw.
485 mingw*) AC_EGREP_CPP([Known], [
486#ifdef _MSC_VER
487 Known
488#endif
489 ],
490 [gl_cv_func_printf_infinite_long_double="guessing yes"],
491 [gl_cv_func_printf_infinite_long_double="guessing no"])
492 ;;
493 # If we don't know, obey --enable-cross-guesses.
494 *) gl_cv_func_printf_infinite_long_double="$gl_cross_guess_normal";;
452 esac 495 esac
453 ;; 496 ;;
454 esac 497 esac
455changequote([,])dnl
456 ]) 498 ])
457 ]) 499 ])
458 ;; 500 ;;
@@ -495,15 +537,22 @@ int main ()
495 && strcmp (buf, "-0X6.488P-1 33") != 0 537 && strcmp (buf, "-0X6.488P-1 33") != 0
496 && strcmp (buf, "-0XC.91P-2 33") != 0)) 538 && strcmp (buf, "-0XC.91P-2 33") != 0))
497 result |= 2; 539 result |= 2;
498 /* This catches a FreeBSD 6.1 bug: it doesn't round. */ 540 /* This catches a FreeBSD 13.0 bug: it doesn't round. */
499 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0 541 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0
500 || (strcmp (buf, "0x1.83p+0 33") != 0 542 || (strcmp (buf, "0x1.83p+0 33") != 0
501 && strcmp (buf, "0x3.05p-1 33") != 0 543 && strcmp (buf, "0x3.05p-1 33") != 0
502 && strcmp (buf, "0x6.0ap-2 33") != 0 544 && strcmp (buf, "0x6.0ap-2 33") != 0
503 && strcmp (buf, "0xc.14p-3 33") != 0)) 545 && strcmp (buf, "0xc.14p-3 33") != 0))
504 result |= 4; 546 result |= 4;
547 /* This catches a Mac OS X 10.12.4 (Darwin 16.5) bug: it doesn't round. */
548 if (sprintf (buf, "%.0a %d", 1.51, 33, 44, 55) < 0
549 || (strcmp (buf, "0x2p+0 33") != 0
550 && strcmp (buf, "0x3p-1 33") != 0
551 && strcmp (buf, "0x6p-2 33") != 0
552 && strcmp (buf, "0xcp-3 33") != 0))
553 result |= 4;
505 /* This catches a FreeBSD 6.1 bug. See 554 /* This catches a FreeBSD 6.1 bug. See
506 <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ 555 <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html> */
507 if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0 556 if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0
508 || buf[0] == '0') 557 || buf[0] == '0')
509 result |= 8; 558 result |= 8;
@@ -515,7 +564,7 @@ int main ()
515 && strcmp (buf, "0x8.0p-2") != 0)) 564 && strcmp (buf, "0x8.0p-2") != 0))
516 result |= 16; 565 result |= 16;
517 /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a 566 /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a
518 glibc 2.4 bug <http://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */ 567 glibc 2.4 bug <https://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */
519 if (sprintf (buf, "%.1La", 1.999L) < 0 568 if (sprintf (buf, "%.1La", 1.999L) < 0
520 || (strcmp (buf, "0x1.0p+1") != 0 569 || (strcmp (buf, "0x1.0p+1") != 0
521 && strcmp (buf, "0x2.0p+0") != 0 570 && strcmp (buf, "0x2.0p+0") != 0
@@ -529,7 +578,7 @@ int main ()
529 [ 578 [
530 case "$host_os" in 579 case "$host_os" in
531 # Guess yes on glibc >= 2.5 systems. 580 # Guess yes on glibc >= 2.5 systems.
532 *-gnu*) 581 *-gnu* | gnu*)
533 AC_EGREP_CPP([BZ2908], [ 582 AC_EGREP_CPP([BZ2908], [
534 #include <features.h> 583 #include <features.h>
535 #ifdef __GNU_LIBRARY__ 584 #ifdef __GNU_LIBRARY__
@@ -541,8 +590,14 @@ int main ()
541 [gl_cv_func_printf_directive_a="guessing yes"], 590 [gl_cv_func_printf_directive_a="guessing yes"],
542 [gl_cv_func_printf_directive_a="guessing no"]) 591 [gl_cv_func_printf_directive_a="guessing no"])
543 ;; 592 ;;
544 # If we don't know, assume the worst. 593 # Guess yes on musl systems.
545 *) gl_cv_func_printf_directive_a="guessing no";; 594 *-musl*) gl_cv_func_printf_directive_a="guessing yes";;
595 # Guess no on Android.
596 linux*-android*) gl_cv_func_printf_directive_a="guessing no";;
597 # Guess no on native Windows.
598 mingw*) gl_cv_func_printf_directive_a="guessing no";;
599 # If we don't know, obey --enable-cross-guesses.
600 *) gl_cv_func_printf_directive_a="$gl_cross_guess_normal";;
546 esac 601 esac
547 ]) 602 ])
548 ]) 603 ])
@@ -583,23 +638,40 @@ int main ()
583 [gl_cv_func_printf_directive_f=yes], 638 [gl_cv_func_printf_directive_f=yes],
584 [gl_cv_func_printf_directive_f=no], 639 [gl_cv_func_printf_directive_f=no],
585 [ 640 [
586changequote(,)dnl
587 case "$host_os" in 641 case "$host_os" in
642changequote(,)dnl
588 # Guess yes on glibc systems. 643 # Guess yes on glibc systems.
589 *-gnu*) gl_cv_func_printf_directive_f="guessing yes";; 644 *-gnu* | gnu*) gl_cv_func_printf_directive_f="guessing yes";;
645 # Guess yes on musl systems.
646 *-musl*) gl_cv_func_printf_directive_f="guessing yes";;
590 # Guess yes on FreeBSD >= 6. 647 # Guess yes on FreeBSD >= 6.
591 freebsd[1-5]*) gl_cv_func_printf_directive_f="guessing no";; 648 freebsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";;
592 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";; 649 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";;
650 midnightbsd*) gl_cv_func_printf_directive_f="guessing yes";;
593 # Guess yes on Mac OS X >= 10.3. 651 # Guess yes on Mac OS X >= 10.3.
594 darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";; 652 darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";;
595 darwin*) gl_cv_func_printf_directive_f="guessing yes";; 653 darwin*) gl_cv_func_printf_directive_f="guessing yes";;
654 # Guess yes on OpenBSD >= 6.0.
655 openbsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";;
656 openbsd*) gl_cv_func_printf_directive_f="guessing yes";;
596 # Guess yes on Solaris >= 2.10. 657 # Guess yes on Solaris >= 2.10.
597 solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";; 658 solaris2.[1-9][0-9]*) gl_cv_func_printf_directive_f="guessing yes";;
598 solaris*) gl_cv_func_printf_sizes_c99="guessing no";; 659 solaris*) gl_cv_func_printf_directive_f="guessing no";;
599 # If we don't know, assume the worst. 660 # Guess no on Android.
600 *) gl_cv_func_printf_directive_f="guessing no";; 661 linux*-android*) gl_cv_func_printf_directive_f="guessing no";;
601 esac
602changequote([,])dnl 662changequote([,])dnl
663 # Guess yes on MSVC, no on mingw.
664 mingw*) AC_EGREP_CPP([Known], [
665#ifdef _MSC_VER
666 Known
667#endif
668 ],
669 [gl_cv_func_printf_directive_f="guessing yes"],
670 [gl_cv_func_printf_directive_f="guessing no"])
671 ;;
672 # If we don't know, obey --enable-cross-guesses.
673 *) gl_cv_func_printf_directive_f="$gl_cross_guess_normal";;
674 esac
603 ]) 675 ])
604 ]) 676 ])
605]) 677])
@@ -621,7 +693,10 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
621#include <stdlib.h> 693#include <stdlib.h>
622#include <string.h> 694#include <string.h>
623#ifdef _MSC_VER 695#ifdef _MSC_VER
624/* See page about "Parameter Validation" on msdn.microsoft.com. */ 696#include <inttypes.h>
697/* See page about "Parameter Validation" on msdn.microsoft.com.
698 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/parameter-validation>
699 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/set-invalid-parameter-handler-set-thread-local-invalid-parameter-handler> */
625static void cdecl 700static void cdecl
626invalid_parameter_handler (const wchar_t *expression, 701invalid_parameter_handler (const wchar_t *expression,
627 const wchar_t *function, 702 const wchar_t *function,
@@ -651,13 +726,23 @@ int main ()
651}]])], 726}]])],
652 [gl_cv_func_printf_directive_n=yes], 727 [gl_cv_func_printf_directive_n=yes],
653 [gl_cv_func_printf_directive_n=no], 728 [gl_cv_func_printf_directive_n=no],
654 [ 729 [case "$host_os" in
655changequote(,)dnl 730 # Guess no on glibc when _FORTIFY_SOURCE >= 2.
656 case "$host_os" in 731 *-gnu* | gnu*) AC_COMPILE_IFELSE(
657 mingw*) gl_cv_func_printf_directive_n="guessing no";; 732 [AC_LANG_SOURCE(
658 *) gl_cv_func_printf_directive_n="guessing yes";; 733 [[#if _FORTIFY_SOURCE >= 2
734 error fail
735 #endif
736 ]])],
737 [gl_cv_func_printf_directive_n="guessing yes"],
738 [gl_cv_func_printf_directive_n="guessing no"])
739 ;;
740 # Guess no on Android.
741 linux*-android*) gl_cv_func_printf_directive_n="guessing no";;
742 # Guess no on native Windows.
743 mingw*) gl_cv_func_printf_directive_n="guessing no";;
744 *) gl_cv_func_printf_directive_n="guessing yes";;
659 esac 745 esac
660changequote([,])dnl
661 ]) 746 ])
662 ]) 747 ])
663]) 748])
@@ -678,13 +763,7 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_LS],
678 [ 763 [
679 AC_RUN_IFELSE( 764 AC_RUN_IFELSE(
680 [AC_LANG_SOURCE([[ 765 [AC_LANG_SOURCE([[
681/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
682 <wchar.h>.
683 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
684 included before <wchar.h>. */
685#include <stddef.h>
686#include <stdio.h> 766#include <stdio.h>
687#include <time.h>
688#include <wchar.h> 767#include <wchar.h>
689#include <string.h> 768#include <string.h>
690int main () 769int main ()
@@ -732,11 +811,17 @@ int main ()
732 [ 811 [
733changequote(,)dnl 812changequote(,)dnl
734 case "$host_os" in 813 case "$host_os" in
735 openbsd*) gl_cv_func_printf_directive_ls="guessing no";; 814 # Guess yes on OpenBSD >= 6.0.
815 openbsd[1-5].*) gl_cv_func_printf_directive_ls="guessing no";;
816 openbsd*) gl_cv_func_printf_directive_ls="guessing yes";;
736 irix*) gl_cv_func_printf_directive_ls="guessing no";; 817 irix*) gl_cv_func_printf_directive_ls="guessing no";;
737 solaris*) gl_cv_func_printf_directive_ls="guessing no";; 818 solaris*) gl_cv_func_printf_directive_ls="guessing no";;
738 cygwin*) gl_cv_func_printf_directive_ls="guessing no";; 819 cygwin*) gl_cv_func_printf_directive_ls="guessing no";;
739 beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; 820 beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";;
821 # Guess no on Android.
822 linux*-android*) gl_cv_func_printf_directive_ls="guessing no";;
823 # Guess yes on native Windows.
824 mingw*) gl_cv_func_printf_directive_ls="guessing yes";;
740 *) gl_cv_func_printf_directive_ls="guessing yes";; 825 *) gl_cv_func_printf_directive_ls="guessing yes";;
741 esac 826 esac
742changequote([,])dnl 827changequote([,])dnl
@@ -774,10 +859,13 @@ int main ()
774changequote(,)dnl 859changequote(,)dnl
775 case "$host_os" in 860 case "$host_os" in
776 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) 861 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*)
777 gl_cv_func_printf_positions="guessing no";; 862 gl_cv_func_printf_positions="guessing no";;
778 beos*) gl_cv_func_printf_positions="guessing no";; 863 beos*) gl_cv_func_printf_positions="guessing no";;
779 mingw* | pw*) gl_cv_func_printf_positions="guessing no";; 864 # Guess yes on Android.
780 *) gl_cv_func_printf_positions="guessing yes";; 865 linux*-android*) gl_cv_func_printf_positions="guessing yes";;
866 # Guess no on native Windows.
867 mingw* | pw*) gl_cv_func_printf_positions="guessing no";;
868 *) gl_cv_func_printf_positions="guessing yes";;
781 esac 869 esac
782changequote([,])dnl 870changequote([,])dnl
783 ]) 871 ])
@@ -812,10 +900,13 @@ int main ()
812 [ 900 [
813changequote(,)dnl 901changequote(,)dnl
814 case "$host_os" in 902 case "$host_os" in
815 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; 903 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";;
816 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; 904 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";;
817 mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; 905 # Guess no on Android.
818 *) gl_cv_func_printf_flag_grouping="guessing yes";; 906 linux*-android*) gl_cv_func_printf_flag_grouping="guessing no";;
907 # Guess no on native Windows.
908 mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
909 *) gl_cv_func_printf_flag_grouping="guessing yes";;
819 esac 910 esac
820changequote([,])dnl 911changequote([,])dnl
821 ]) 912 ])
@@ -824,7 +915,7 @@ changequote([,])dnl
824 915
825dnl Test whether the *printf family of functions supports the - flag correctly. 916dnl Test whether the *printf family of functions supports the - flag correctly.
826dnl (ISO C99.) See 917dnl (ISO C99.) See
827dnl <http://lists.gnu.org/archive/html/bug-coreutils/2008-02/msg00035.html> 918dnl <https://lists.gnu.org/r/bug-coreutils/2008-02/msg00035.html>
828dnl Result is gl_cv_func_printf_flag_leftadjust. 919dnl Result is gl_cv_func_printf_flag_leftadjust.
829 920
830AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST], 921AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST],
@@ -852,12 +943,16 @@ int main ()
852 [ 943 [
853changequote(,)dnl 944changequote(,)dnl
854 case "$host_os" in 945 case "$host_os" in
855 # Guess yes on HP-UX 11. 946 # Guess yes on HP-UX 11.
856 hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";; 947 hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
857 # Guess no on HP-UX 10 and older. 948 # Guess no on HP-UX 10 and older.
858 hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";; 949 hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";;
859 # Guess yes otherwise. 950 # Guess yes on Android.
860 *) gl_cv_func_printf_flag_leftadjust="guessing yes";; 951 linux*-android*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
952 # Guess yes on native Windows.
953 mingw*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
954 # Guess yes otherwise.
955 *) gl_cv_func_printf_flag_leftadjust="guessing yes";;
861 esac 956 esac
862changequote([,])dnl 957changequote([,])dnl
863 ]) 958 ])
@@ -866,7 +961,7 @@ changequote([,])dnl
866 961
867dnl Test whether the *printf family of functions supports padding of non-finite 962dnl Test whether the *printf family of functions supports padding of non-finite
868dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See 963dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See
869dnl <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> 964dnl <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html>
870dnl Result is gl_cv_func_printf_flag_zero. 965dnl Result is gl_cv_func_printf_flag_zero.
871 966
872AC_DEFUN([gl_PRINTF_FLAG_ZERO], 967AC_DEFUN([gl_PRINTF_FLAG_ZERO],
@@ -895,12 +990,18 @@ int main ()
895 [ 990 [
896changequote(,)dnl 991changequote(,)dnl
897 case "$host_os" in 992 case "$host_os" in
898 # Guess yes on glibc systems. 993 # Guess yes on glibc systems.
899 *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";; 994 *-gnu* | gnu*) gl_cv_func_printf_flag_zero="guessing yes";;
900 # Guess yes on BeOS. 995 # Guess yes on musl systems.
901 beos*) gl_cv_func_printf_flag_zero="guessing yes";; 996 *-musl*) gl_cv_func_printf_flag_zero="guessing yes";;
902 # If we don't know, assume the worst. 997 # Guess yes on BeOS.
903 *) gl_cv_func_printf_flag_zero="guessing no";; 998 beos*) gl_cv_func_printf_flag_zero="guessing yes";;
999 # Guess no on Android.
1000 linux*-android*) gl_cv_func_printf_flag_zero="guessing no";;
1001 # Guess no on native Windows.
1002 mingw*) gl_cv_func_printf_flag_zero="guessing no";;
1003 # If we don't know, obey --enable-cross-guesses.
1004 *) gl_cv_func_printf_flag_zero="$gl_cross_guess_normal";;
904 esac 1005 esac
905changequote([,])dnl 1006changequote([,])dnl
906 ]) 1007 ])
@@ -953,10 +1054,12 @@ int main ()
953changequote(,)dnl 1054changequote(,)dnl
954 case "$host_os" in 1055 case "$host_os" in
955 # Guess no only on Solaris, native Windows, and BeOS systems. 1056 # Guess no only on Solaris, native Windows, and BeOS systems.
956 solaris*) gl_cv_func_printf_precision="guessing no" ;; 1057 solaris*) gl_cv_func_printf_precision="guessing no" ;;
957 mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; 1058 mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;;
958 beos*) gl_cv_func_printf_precision="guessing no" ;; 1059 beos*) gl_cv_func_printf_precision="guessing no" ;;
959 *) gl_cv_func_printf_precision="guessing yes" ;; 1060 # Guess yes on Android.
1061 linux*-android*) gl_cv_func_printf_precision="guessing yes" ;;
1062 *) gl_cv_func_printf_precision="guessing yes" ;;
960 esac 1063 esac
961changequote([,])dnl 1064changequote([,])dnl
962 ]) 1065 ])
@@ -978,9 +1081,8 @@ AC_DEFUN([gl_PRINTF_ENOMEM],
978 gl_cv_func_printf_enomem="guessing no" 1081 gl_cv_func_printf_enomem="guessing no"
979 if test "$cross_compiling" = no; then 1082 if test "$cross_compiling" = no; then
980 if test $APPLE_UNIVERSAL_BUILD = 0; then 1083 if test $APPLE_UNIVERSAL_BUILD = 0; then
981 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 1084 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
982]GL_NOCRASH[ 1085]GL_NOCRASH[
983changequote(,)dnl
984#include <stdio.h> 1086#include <stdio.h>
985#include <sys/types.h> 1087#include <sys/types.h>
986#include <sys/time.h> 1088#include <sys/time.h>
@@ -1025,8 +1127,7 @@ int main()
1025 ret = printf ("%.5000000f", 1.0); 1127 ret = printf ("%.5000000f", 1.0);
1026 return !(ret == 5000002 || (ret < 0 && errno == ENOMEM)); 1128 return !(ret == 5000002 || (ret < 0 && errno == ENOMEM));
1027} 1129}
1028changequote([,])dnl 1130 ]])])
1029 ])])
1030 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 1131 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
1031 (./conftest 2>&AS_MESSAGE_LOG_FD 1132 (./conftest 2>&AS_MESSAGE_LOG_FD
1032 result=$? 1133 result=$?
@@ -1053,28 +1154,30 @@ changequote([,])dnl
1053 if test "$gl_cv_func_printf_enomem" = "guessing no"; then 1154 if test "$gl_cv_func_printf_enomem" = "guessing no"; then
1054changequote(,)dnl 1155changequote(,)dnl
1055 case "$host_os" in 1156 case "$host_os" in
1056 # Guess yes on glibc systems. 1157 # Guess yes on glibc systems.
1057 *-gnu*) gl_cv_func_printf_enomem="guessing yes";; 1158 *-gnu* | gnu*) gl_cv_func_printf_enomem="guessing yes";;
1058 # Guess yes on Solaris. 1159 # Guess yes on Solaris.
1059 solaris*) gl_cv_func_printf_enomem="guessing yes";; 1160 solaris*) gl_cv_func_printf_enomem="guessing yes";;
1060 # Guess yes on AIX. 1161 # Guess yes on AIX.
1061 aix*) gl_cv_func_printf_enomem="guessing yes";; 1162 aix*) gl_cv_func_printf_enomem="guessing yes";;
1062 # Guess yes on HP-UX/hppa. 1163 # Guess yes on HP-UX/hppa.
1063 hpux*) case "$host_cpu" in 1164 hpux*) case "$host_cpu" in
1064 hppa*) gl_cv_func_printf_enomem="guessing yes";; 1165 hppa*) gl_cv_func_printf_enomem="guessing yes";;
1065 *) gl_cv_func_printf_enomem="guessing no";; 1166 *) gl_cv_func_printf_enomem="guessing no";;
1066 esac 1167 esac
1067 ;; 1168 ;;
1068 # Guess yes on IRIX. 1169 # Guess yes on IRIX.
1069 irix*) gl_cv_func_printf_enomem="guessing yes";; 1170 irix*) gl_cv_func_printf_enomem="guessing yes";;
1070 # Guess yes on OSF/1. 1171 # Guess yes on OSF/1.
1071 osf*) gl_cv_func_printf_enomem="guessing yes";; 1172 osf*) gl_cv_func_printf_enomem="guessing yes";;
1072 # Guess yes on BeOS. 1173 # Guess yes on BeOS.
1073 beos*) gl_cv_func_printf_enomem="guessing yes";; 1174 beos*) gl_cv_func_printf_enomem="guessing yes";;
1074 # Guess yes on Haiku. 1175 # Guess yes on Haiku.
1075 haiku*) gl_cv_func_printf_enomem="guessing yes";; 1176 haiku*) gl_cv_func_printf_enomem="guessing yes";;
1076 # If we don't know, assume the worst. 1177 # Guess no on Android.
1077 *) gl_cv_func_printf_enomem="guessing no";; 1178 linux*-android*) gl_cv_func_printf_enomem="guessing no";;
1179 # If we don't know, obey --enable-cross-guesses.
1180 *) gl_cv_func_printf_enomem="$gl_cross_guess_normal";;
1078 esac 1181 esac
1079changequote([,])dnl 1182changequote([,])dnl
1080 fi 1183 fi
@@ -1093,7 +1196,7 @@ dnl Test whether the string produced by the snprintf function is always NUL
1093dnl terminated. (ISO C99, POSIX:2001) 1196dnl terminated. (ISO C99, POSIX:2001)
1094dnl Result is gl_cv_func_snprintf_truncation_c99. 1197dnl Result is gl_cv_func_snprintf_truncation_c99.
1095 1198
1096AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99], 1199AC_DEFUN_ONCE([gl_SNPRINTF_TRUNCATION_C99],
1097[ 1200[
1098 AC_REQUIRE([AC_PROG_CC]) 1201 AC_REQUIRE([AC_PROG_CC])
1099 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 1202 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
@@ -1134,10 +1237,13 @@ int main ()
1134changequote(,)dnl 1237changequote(,)dnl
1135 case "$host_os" in 1238 case "$host_os" in
1136 # Guess yes on glibc systems. 1239 # Guess yes on glibc systems.
1137 *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1240 *-gnu* | gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1241 # Guess yes on musl systems.
1242 *-musl*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1138 # Guess yes on FreeBSD >= 5. 1243 # Guess yes on FreeBSD >= 5.
1139 freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1244 freebsd[1-4].*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1140 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1245 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1246 midnightbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1141 # Guess yes on Mac OS X >= 10.3. 1247 # Guess yes on Mac OS X >= 10.3.
1142 darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1248 darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1143 darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1249 darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
@@ -1166,8 +1272,12 @@ changequote(,)dnl
1166 netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1272 netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1167 # Guess yes on BeOS. 1273 # Guess yes on BeOS.
1168 beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1274 beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1169 # If we don't know, assume the worst. 1275 # Guess yes on Android.
1170 *) gl_cv_func_snprintf_truncation_c99="guessing no";; 1276 linux*-android*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1277 # Guess no on native Windows.
1278 mingw*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1279 # If we don't know, obey --enable-cross-guesses.
1280 *) gl_cv_func_snprintf_truncation_c99="$gl_cross_guess_normal";;
1171 esac 1281 esac
1172changequote([,])dnl 1282changequote([,])dnl
1173 ]) 1283 ])
@@ -1229,14 +1339,16 @@ int main ()
1229}]])], 1339}]])],
1230 [gl_cv_func_snprintf_retval_c99=yes], 1340 [gl_cv_func_snprintf_retval_c99=yes],
1231 [gl_cv_func_snprintf_retval_c99=no], 1341 [gl_cv_func_snprintf_retval_c99=no],
1232 [ 1342 [case "$host_os" in
1233changequote(,)dnl 1343changequote(,)dnl
1234 case "$host_os" in
1235 # Guess yes on glibc systems. 1344 # Guess yes on glibc systems.
1236 *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1345 *-gnu* | gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1346 # Guess yes on musl systems.
1347 *-musl*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1237 # Guess yes on FreeBSD >= 5. 1348 # Guess yes on FreeBSD >= 5.
1238 freebsd[1-4]*) gl_cv_func_snprintf_retval_c99="guessing no";; 1349 freebsd[1-4].*) gl_cv_func_snprintf_retval_c99="guessing no";;
1239 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1350 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1351 midnightbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1240 # Guess yes on Mac OS X >= 10.3. 1352 # Guess yes on Mac OS X >= 10.3.
1241 darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";; 1353 darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";;
1242 darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1354 darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";;
@@ -1256,10 +1368,21 @@ changequote(,)dnl
1256 netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1368 netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1257 # Guess yes on BeOS. 1369 # Guess yes on BeOS.
1258 beos*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1370 beos*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1259 # If we don't know, assume the worst. 1371 # Guess yes on Android.
1260 *) gl_cv_func_snprintf_retval_c99="guessing no";; 1372 linux*-android*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1261 esac
1262changequote([,])dnl 1373changequote([,])dnl
1374 # Guess yes on MSVC, no on mingw.
1375 mingw*) AC_EGREP_CPP([Known], [
1376#ifdef _MSC_VER
1377 Known
1378#endif
1379 ],
1380 [gl_cv_func_snprintf_retval_c99="guessing yes"],
1381 [gl_cv_func_snprintf_retval_c99="guessing no"])
1382 ;;
1383 # If we don't know, obey --enable-cross-guesses.
1384 *) gl_cv_func_snprintf_retval_c99="$gl_cross_guess_normal";;
1385 esac
1263 ]) 1386 ])
1264 ]) 1387 ])
1265]) 1388])
@@ -1311,13 +1434,24 @@ int main ()
1311 [gl_cv_func_snprintf_directive_n=yes], 1434 [gl_cv_func_snprintf_directive_n=yes],
1312 [gl_cv_func_snprintf_directive_n=no], 1435 [gl_cv_func_snprintf_directive_n=no],
1313 [ 1436 [
1314changequote(,)dnl
1315 case "$host_os" in 1437 case "$host_os" in
1316 # Guess yes on glibc systems. 1438 # Guess no on glibc when _FORTIFY_SOURCE >= 2.
1317 *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";; 1439 *-gnu* | gnu*) AC_COMPILE_IFELSE(
1440 [AC_LANG_SOURCE(
1441 [[#if _FORTIFY_SOURCE >= 2
1442 error fail
1443 #endif
1444 ]])],
1445 [gl_cv_func_snprintf_directive_n="guessing yes"],
1446 [gl_cv_func_snprintf_directive_n="guessing no"])
1447 ;;
1448changequote(,)dnl
1449 # Guess yes on musl systems.
1450 *-musl*) gl_cv_func_snprintf_directive_n="guessing yes";;
1318 # Guess yes on FreeBSD >= 5. 1451 # Guess yes on FreeBSD >= 5.
1319 freebsd[1-4]*) gl_cv_func_snprintf_directive_n="guessing no";; 1452 freebsd[1-4].*) gl_cv_func_snprintf_directive_n="guessing no";;
1320 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";; 1453 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
1454 midnightbsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
1321 # Guess yes on Mac OS X >= 10.3. 1455 # Guess yes on Mac OS X >= 10.3.
1322 darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";; 1456 darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";;
1323 darwin*) gl_cv_func_snprintf_directive_n="guessing yes";; 1457 darwin*) gl_cv_func_snprintf_directive_n="guessing yes";;
@@ -1339,10 +1473,14 @@ changequote(,)dnl
1339 netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";; 1473 netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
1340 # Guess yes on BeOS. 1474 # Guess yes on BeOS.
1341 beos*) gl_cv_func_snprintf_directive_n="guessing yes";; 1475 beos*) gl_cv_func_snprintf_directive_n="guessing yes";;
1342 # If we don't know, assume the worst. 1476 # Guess no on Android.
1343 *) gl_cv_func_snprintf_directive_n="guessing no";; 1477 linux*-android*) gl_cv_func_snprintf_directive_n="guessing no";;
1344 esac 1478 # Guess no on native Windows.
1479 mingw*) gl_cv_func_snprintf_directive_n="guessing no";;
1480 # If we don't know, obey --enable-cross-guesses.
1481 *) gl_cv_func_snprintf_directive_n="$gl_cross_guess_normal";;
1345changequote([,])dnl 1482changequote([,])dnl
1483 esac
1346 ]) 1484 ])
1347 ]) 1485 ])
1348]) 1486])
@@ -1355,6 +1493,7 @@ dnl Result is gl_cv_func_snprintf_size1.
1355AC_DEFUN([gl_SNPRINTF_SIZE1], 1493AC_DEFUN([gl_SNPRINTF_SIZE1],
1356[ 1494[
1357 AC_REQUIRE([AC_PROG_CC]) 1495 AC_REQUIRE([AC_PROG_CC])
1496 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1358 AC_REQUIRE([gl_SNPRINTF_PRESENCE]) 1497 AC_REQUIRE([gl_SNPRINTF_PRESENCE])
1359 AC_CACHE_CHECK([whether snprintf respects a size of 1], 1498 AC_CACHE_CHECK([whether snprintf respects a size of 1],
1360 [gl_cv_func_snprintf_size1], 1499 [gl_cv_func_snprintf_size1],
@@ -1384,7 +1523,14 @@ int main()
1384}]])], 1523}]])],
1385 [gl_cv_func_snprintf_size1=yes], 1524 [gl_cv_func_snprintf_size1=yes],
1386 [gl_cv_func_snprintf_size1=no], 1525 [gl_cv_func_snprintf_size1=no],
1387 [gl_cv_func_snprintf_size1="guessing yes"]) 1526 [case "$host_os" in
1527 # Guess yes on Android.
1528 linux*-android*) gl_cv_func_snprintf_size1="guessing yes" ;;
1529 # Guess yes on native Windows.
1530 mingw*) gl_cv_func_snprintf_size1="guessing yes" ;;
1531 *) gl_cv_func_snprintf_size1="guessing yes" ;;
1532 esac
1533 ])
1388 ]) 1534 ])
1389]) 1535])
1390 1536
@@ -1456,10 +1602,13 @@ int main()
1456changequote(,)dnl 1602changequote(,)dnl
1457 case "$host_os" in 1603 case "$host_os" in
1458 # Guess yes on glibc systems. 1604 # Guess yes on glibc systems.
1459 *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1605 *-gnu* | gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1606 # Guess yes on musl systems.
1607 *-musl*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1460 # Guess yes on FreeBSD >= 5. 1608 # Guess yes on FreeBSD >= 5.
1461 freebsd[1-4]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1609 freebsd[1-4].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1462 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1610 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1611 midnightbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1463 # Guess yes on Mac OS X >= 10.3. 1612 # Guess yes on Mac OS X >= 10.3.
1464 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1613 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1465 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1614 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
@@ -1480,10 +1629,12 @@ changequote(,)dnl
1480 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1629 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1481 # Guess yes on BeOS. 1630 # Guess yes on BeOS.
1482 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1631 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1483 # Guess yes on mingw. 1632 # Guess yes on Android.
1633 linux*-android*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1634 # Guess yes on native Windows.
1484 mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1635 mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1485 # If we don't know, assume the worst. 1636 # If we don't know, obey --enable-cross-guesses.
1486 *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1637 *) gl_cv_func_vsnprintf_zerosize_c99="$gl_cross_guess_normal";;
1487 esac 1638 esac
1488changequote([,])dnl 1639changequote([,])dnl
1489 ]) 1640 ])
@@ -1539,14 +1690,19 @@ dnl
1539dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1690dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1540dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . . 1691dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . .
1541dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . . 1692dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . .
1693dnl FreeBSD 13.0 . . . . # . . . . . . . . # . . . . . .
1542dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . . 1694dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . .
1695dnl Mac OS X 10.13.5 . . . # # . # . . . . . . . . . . # . .
1543dnl Mac OS X 10.5.8 . . . # # . . . . . . # . . . . . . . . 1696dnl Mac OS X 10.5.8 . . . # # . . . . . . # . . . . . . . .
1544dnl Mac OS X 10.3.9 . . . . # . . . . . . # . # . . . . . . 1697dnl Mac OS X 10.3.9 . . . . # . . . . . . # . # . . . . . .
1698dnl OpenBSD 6.0, 6.7 . . . . # . . . . . . . . # . . . . . .
1545dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . . 1699dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . .
1546dnl Cygwin 1.7.0 (2009) . . . # . . . ? . . . . . ? . . . . . . 1700dnl Cygwin 1.7.0 (2009) . . . # . . . ? . . . . . ? . . . . . .
1547dnl Cygwin 1.5.25 (2008) . . . # # . . # . . . . . # . . . . . . 1701dnl Cygwin 1.5.25 (2008) . . . # # . . # . . . . . # . . . . . .
1548dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . . 1702dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . .
1549dnl Solaris 11 2011-11 . . # # # . . # . . . # . . . . . . . . 1703dnl Solaris 11.4 . . # # # . . # . . . # . . . . . . . .
1704dnl Solaris 11.3 . . . . # . . # . . . . . . . . . . . .
1705dnl Solaris 11.0 . . # # # . . # . . . # . . . . . . . .
1550dnl Solaris 10 . . # # # . . # . . . # # . . . . . . . 1706dnl Solaris 10 . . # # # . . # . . . # # . . . . . . .
1551dnl Solaris 2.6 ... 9 # . # # # # . # . . . # # . . . # . . . 1707dnl Solaris 2.6 ... 9 # . # # # # . # . . . # # . . . # . . .
1552dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # # 1708dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # #
@@ -1559,11 +1715,13 @@ dnl HP-UX 10.20 # . # . # # . ? . . # # . . .
1559dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . . 1715dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . .
1560dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . # 1716dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . #
1561dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # # 1717dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # #
1718dnl NetBSD 9.0 . . . . # . . . . . . . . . . . . . . .
1562dnl NetBSD 5.0 . . . # # . . . . . . # . # . . . . . . 1719dnl NetBSD 5.0 . . . # # . . . . . . # . # . . . . . .
1563dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ? 1720dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ?
1564dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . . 1721dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . .
1565dnl Haiku . . . # # # . # . . . . . ? . . ? . . . 1722dnl Haiku . . . # # # . # . . . . . ? . . ? . . .
1566dnl BeOS # # . # # # . ? # . ? . # ? . . ? . . . 1723dnl BeOS # # . # # # . ? # . ? . # ? . . ? . . .
1724dnl Android 4.3 . . # # # # # # . # . # . # . . . # . .
1567dnl old mingw / msvcrt # # # # # # . . # # . # # ? . # # # . . 1725dnl old mingw / msvcrt # # # # # # . . # # . # # ? . # # # . .
1568dnl MSVC 9 # # # # # # # . # # . # # ? # # # # . . 1726dnl MSVC 9 # # # # # # # . # # . # # ? # # # # . .
1569dnl mingw 2009-2011 . # . # . . . . # # . . . ? . . . . . . 1727dnl mingw 2009-2011 . # . # . . . . # # . . . ? . . . . . .
diff --git a/gl/m4/progtest.m4 b/gl/m4/progtest.m4
deleted file mode 100644
index 7b391232..00000000
--- a/gl/m4/progtest.m4
+++ /dev/null
@@ -1,91 +0,0 @@
1# progtest.m4 serial 7 (gettext-0.18.2)
2dnl Copyright (C) 1996-2003, 2005, 2008-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1996.
18
19AC_PREREQ([2.50])
20
21# Search path for a program which passes the given test.
22
23dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
24dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
25AC_DEFUN([AM_PATH_PROG_WITH_TEST],
26[
27# Prepare PATH_SEPARATOR.
28# The user is always right.
29if test "${PATH_SEPARATOR+set}" != set; then
30 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
31 # contains only /bin. Note that ksh looks also at the FPATH variable,
32 # so we have to set that as well for the test.
33 PATH_SEPARATOR=:
34 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
35 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
36 || PATH_SEPARATOR=';'
37 }
38fi
39
40# Find out how to test for executable files. Don't use a zero-byte file,
41# as systems may use methods other than mode bits to determine executability.
42cat >conf$$.file <<_ASEOF
43#! /bin/sh
44exit 0
45_ASEOF
46chmod +x conf$$.file
47if test -x conf$$.file >/dev/null 2>&1; then
48 ac_executable_p="test -x"
49else
50 ac_executable_p="test -f"
51fi
52rm -f conf$$.file
53
54# Extract the first word of "$2", so it can be a program name with args.
55set dummy $2; ac_word=[$]2
56AC_MSG_CHECKING([for $ac_word])
57AC_CACHE_VAL([ac_cv_path_$1],
58[case "[$]$1" in
59 [[\\/]]* | ?:[[\\/]]*)
60 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
61 ;;
62 *)
63 ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR
64 for ac_dir in ifelse([$5], , $PATH, [$5]); do
65 IFS="$ac_save_IFS"
66 test -z "$ac_dir" && ac_dir=.
67 for ac_exec_ext in '' $ac_executable_extensions; do
68 if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then
69 echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD
70 if [$3]; then
71 ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext"
72 break 2
73 fi
74 fi
75 done
76 done
77 IFS="$ac_save_IFS"
78dnl If no 4th arg is given, leave the cache variable unset,
79dnl so AC_PATH_PROGS will keep looking.
80ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
81])dnl
82 ;;
83esac])dnl
84$1="$ac_cv_path_$1"
85if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
86 AC_MSG_RESULT([$][$1])
87else
88 AC_MSG_RESULT([no])
89fi
90AC_SUBST([$1])dnl
91])
diff --git a/gl/m4/pthread_rwlock_rdlock.m4 b/gl/m4/pthread_rwlock_rdlock.m4
new file mode 100644
index 00000000..ae6a8853
--- /dev/null
+++ b/gl/m4/pthread_rwlock_rdlock.m4
@@ -0,0 +1,185 @@
1# pthread_rwlock_rdlock.m4 serial 4
2dnl Copyright (C) 2017-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8dnl Inspired by
9dnl https://github.com/linux-test-project/ltp/blob/master/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c
10dnl by Intel Corporation.
11
12dnl Test whether in a situation where
13dnl - an rwlock is taken by a reader and has a writer waiting,
14dnl - an additional reader requests the lock,
15dnl - the waiting writer and the requesting reader threads have the same
16dnl priority,
17dnl the requesting reader thread gets blocked, so that at some point the
18dnl waiting writer can acquire the lock.
19dnl Without such a guarantee, when there a N readers and each of the readers
20dnl spends more than 1/Nth of the time with the lock held, there is a high
21dnl probability that the waiting writer will not get the lock in a given finite
22dnl time, a phenomenon called "writer starvation".
23dnl Without such a guarantee, applications have a hard time avoiding writer
24dnl starvation.
25dnl
26dnl POSIX:2017 makes this requirement only for implementations that support TPS
27dnl (Thread Priority Scheduling) and only for the scheduling policies SCHED_FIFO
28dnl and SCHED_RR, see
29dnl https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_rdlock.html
30dnl but this test verifies the guarantee regardless of TPS and regardless of
31dnl scheduling policy.
32dnl Glibc does not provide this guarantee (and never will on Linux), see
33dnl https://sourceware.org/bugzilla/show_bug.cgi?id=13701
34dnl https://bugzilla.redhat.com/show_bug.cgi?id=1410052
35AC_DEFUN([gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER],
36[
37 AC_REQUIRE([gl_THREADLIB_EARLY])
38 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
39 AC_CACHE_CHECK([whether pthread_rwlock_rdlock prefers a writer to a reader],
40 [gl_cv_pthread_rwlock_rdlock_prefer_writer],
41 [save_LIBS="$LIBS"
42 LIBS="$LIBS $LIBMULTITHREAD"
43 AC_RUN_IFELSE(
44 [AC_LANG_SOURCE([[
45#include <errno.h>
46#include <pthread.h>
47#include <stdlib.h>
48#include <unistd.h>
49
50#define SUCCEED() exit (0)
51#define FAILURE() exit (1)
52#define UNEXPECTED(n) (exit (10 + (n)))
53
54/* The main thread creates the waiting writer and the requesting reader threads
55 in the default way; this guarantees that they have the same priority.
56 We can reuse the main thread as first reader thread. */
57
58static pthread_rwlock_t lock;
59static pthread_t reader1;
60static pthread_t writer;
61static pthread_t reader2;
62static pthread_t timer;
63/* Used to pass control from writer to reader2 and from reader2 to timer,
64 as in a relay race.
65 Passing control from one running thread to another running thread
66 is most likely faster than to create the second thread. */
67static pthread_mutex_t baton;
68
69static void *
70timer_func (void *ignored)
71{
72 /* Step 13 (can be before or after step 12):
73 The timer thread takes the baton, then waits a moment to make sure
74 it can tell whether the second reader thread is blocked at step 12. */
75 if (pthread_mutex_lock (&baton))
76 UNEXPECTED (13);
77 usleep (100000);
78 /* By the time we get here, it's clear that the second reader thread is
79 blocked at step 12. This is the desired behaviour. */
80 SUCCEED ();
81}
82
83static void *
84reader2_func (void *ignored)
85{
86 int err;
87
88 /* Step 8 (can be before or after step 7):
89 The second reader thread takes the baton, then waits a moment to make sure
90 the writer thread has reached step 7. */
91 if (pthread_mutex_lock (&baton))
92 UNEXPECTED (8);
93 usleep (100000);
94 /* Step 9: The second reader thread requests the lock. */
95 err = pthread_rwlock_tryrdlock (&lock);
96 if (err == 0)
97 FAILURE ();
98 else if (err != EBUSY)
99 UNEXPECTED (9);
100 /* Step 10: Launch a timer, to test whether the next call blocks. */
101 if (pthread_create (&timer, NULL, timer_func, NULL))
102 UNEXPECTED (10);
103 /* Step 11: Release the baton. */
104 if (pthread_mutex_unlock (&baton))
105 UNEXPECTED (11);
106 /* Step 12: The second reader thread requests the lock. */
107 err = pthread_rwlock_rdlock (&lock);
108 if (err == 0)
109 FAILURE ();
110 else
111 UNEXPECTED (12);
112}
113
114static void *
115writer_func (void *ignored)
116{
117 /* Step 4: Take the baton, so that the second reader thread does not go ahead
118 too early. */
119 if (pthread_mutex_lock (&baton))
120 UNEXPECTED (4);
121 /* Step 5: Create the second reader thread. */
122 if (pthread_create (&reader2, NULL, reader2_func, NULL))
123 UNEXPECTED (5);
124 /* Step 6: Release the baton. */
125 if (pthread_mutex_unlock (&baton))
126 UNEXPECTED (6);
127 /* Step 7: The writer thread requests the lock. */
128 if (pthread_rwlock_wrlock (&lock))
129 UNEXPECTED (7);
130 return NULL;
131}
132
133int
134main ()
135{
136 reader1 = pthread_self ();
137
138 /* Step 1: The main thread initializes the lock and the baton. */
139 if (pthread_rwlock_init (&lock, NULL))
140 UNEXPECTED (1);
141 if (pthread_mutex_init (&baton, NULL))
142 UNEXPECTED (1);
143 /* Step 2: The main thread acquires the lock as a reader. */
144 if (pthread_rwlock_rdlock (&lock))
145 UNEXPECTED (2);
146 /* Step 3: Create the writer thread. */
147 if (pthread_create (&writer, NULL, writer_func, NULL))
148 UNEXPECTED (3);
149 /* Job done. Go to sleep. */
150 for (;;)
151 {
152 sleep (1);
153 }
154}
155]])],
156 [gl_cv_pthread_rwlock_rdlock_prefer_writer=yes],
157 [gl_cv_pthread_rwlock_rdlock_prefer_writer=no],
158 [case "$host_os" in
159 # Guess no on glibc systems.
160 *-gnu* | gnu*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
161 # Guess no on musl systems.
162 *-musl*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
163 # Guess no on bionic systems.
164 *-android*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
165 # Guess yes on native Windows with the mingw-w64 winpthreads library.
166 # Guess no on native Windows with the gnulib windows-rwlock module.
167 mingw*) if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
168 gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes"
169 else
170 gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no"
171 fi
172 ;;
173 # If we don't know, obey --enable-cross-guesses.
174 *) gl_cv_pthread_rwlock_rdlock_prefer_writer="$gl_cross_guess_normal" ;;
175 esac
176 ])
177 LIBS="$save_LIBS"
178 ])
179 case "$gl_cv_pthread_rwlock_rdlock_prefer_writer" in
180 *yes)
181 AC_DEFINE([HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER], [1],
182 [Define if the 'pthread_rwlock_rdlock' function prefers a writer to a reader.])
183 ;;
184 esac
185])
diff --git a/gl/m4/read.m4 b/gl/m4/read.m4
deleted file mode 100644
index 81f0f3a9..00000000
--- a/gl/m4/read.m4
+++ /dev/null
@@ -1,26 +0,0 @@
1# read.m4 serial 4
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_READ],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([gl_MSVC_INVAL])
11 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
12 REPLACE_READ=1
13 fi
14 dnl This ifdef is just an optimization, to avoid performing a configure
15 dnl check whose result is not used. It does not make the test of
16 dnl GNULIB_UNISTD_H_NONBLOCKING or GNULIB_NONBLOCKING redundant.
17 m4_ifdef([gl_NONBLOCKING_IO], [
18 gl_NONBLOCKING_IO
19 if test $gl_cv_have_nonblocking != yes; then
20 REPLACE_READ=1
21 fi
22 ])
23])
24
25# Prerequisites of lib/read.c.
26AC_DEFUN([gl_PREREQ_READ], [:])
diff --git a/gl/m4/realloc.m4 b/gl/m4/realloc.m4
new file mode 100644
index 00000000..d22138fc
--- /dev/null
+++ b/gl/m4/realloc.m4
@@ -0,0 +1,63 @@
1# realloc.m4 serial 26
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# This is adapted with modifications from upstream Autoconf here:
8# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n1455
9AC_DEFUN([_AC_FUNC_REALLOC_IF],
10[
11 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
12 AC_CACHE_CHECK([whether realloc (0, 0) returns nonnull],
13 [ac_cv_func_realloc_0_nonnull],
14 [AC_RUN_IFELSE(
15 [AC_LANG_PROGRAM(
16 [[#include <stdlib.h>
17 ]],
18 [[void *p = realloc (0, 0);
19 int result = !p;
20 free (p);
21 return result;]])
22 ],
23 [ac_cv_func_realloc_0_nonnull=yes],
24 [ac_cv_func_realloc_0_nonnull=no],
25 [case "$host_os" in
26 # Guess yes on platforms where we know the result.
27 *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
28 | gnu* | *-musl* | midnightbsd* \
29 | hpux* | solaris* | cygwin* | mingw* | msys* )
30 ac_cv_func_realloc_0_nonnull="guessing yes" ;;
31 # If we don't know, obey --enable-cross-guesses.
32 *) ac_cv_func_realloc_0_nonnull="$gl_cross_guess_normal" ;;
33 esac
34 ])
35 ])
36 AS_CASE([$ac_cv_func_realloc_0_nonnull], [*yes], [$1], [$2])
37])# AC_FUNC_REALLOC
38
39# gl_FUNC_REALLOC_GNU
40# -------------------
41# Replace realloc if it is not compatible with GNU libc.
42AC_DEFUN([gl_FUNC_REALLOC_GNU],
43[
44 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
45 AC_REQUIRE([gl_FUNC_REALLOC_POSIX])
46 if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 0; then
47 _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC_FOR_REALLOC_GNU=1])
48 fi
49])# gl_FUNC_REALLOC_GNU
50
51# gl_FUNC_REALLOC_POSIX
52# ---------------------
53# Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it
54# fails, and doesn't mess up with ptrdiff_t overflow),
55# and replace realloc if it is not.
56AC_DEFUN([gl_FUNC_REALLOC_POSIX],
57[
58 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
59 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
60 if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
61 REPLACE_REALLOC_FOR_REALLOC_POSIX=1
62 fi
63])
diff --git a/gl/m4/reallocarray.m4 b/gl/m4/reallocarray.m4
new file mode 100644
index 00000000..1607b7a9
--- /dev/null
+++ b/gl/m4/reallocarray.m4
@@ -0,0 +1,23 @@
1# reallocarray.m4 serial 3
2dnl Copyright (C) 2017-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_REALLOCARRAY],
8[
9 dnl Persuade glibc <stdlib.h> to declare reallocarray.
10 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
11
12 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
13 AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF])
14 AC_CHECK_FUNCS([reallocarray])
15 if test "$ac_cv_func_reallocarray" = no; then
16 HAVE_REALLOCARRAY=0
17 elif test "$gl_cv_malloc_ptrdiff" = no; then
18 REPLACE_REALLOCARRAY=1
19 fi
20])
21
22# Prerequisites of lib/reallocarray.c.
23AC_DEFUN([gl_PREREQ_REALLOCARRAY], [:])
diff --git a/gl/m4/regex.m4 b/gl/m4/regex.m4
index 0945c11a..c89a1432 100644
--- a/gl/m4/regex.m4
+++ b/gl/m4/regex.m4
@@ -1,6 +1,6 @@
1# serial 64 1# serial 73
2 2
3# Copyright (C) 1996-2001, 2003-2013 Free Software Foundation, Inc. 3# Copyright (C) 1996-2001, 2003-2023 Free Software Foundation, Inc.
4# 4#
5# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
@@ -13,6 +13,7 @@ AC_PREREQ([2.50])
13 13
14AC_DEFUN([gl_REGEX], 14AC_DEFUN([gl_REGEX],
15[ 15[
16 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
16 AC_ARG_WITH([included-regex], 17 AC_ARG_WITH([included-regex],
17 [AS_HELP_STRING([--without-included-regex], 18 [AS_HELP_STRING([--without-included-regex],
18 [don't compile regex; this is the default on systems 19 [don't compile regex; this is the default on systems
@@ -28,6 +29,7 @@ AC_DEFUN([gl_REGEX],
28 # If cross compiling, assume the test would fail and use the included 29 # If cross compiling, assume the test would fail and use the included
29 # regex.c. 30 # regex.c.
30 AC_CHECK_DECLS_ONCE([alarm]) 31 AC_CHECK_DECLS_ONCE([alarm])
32 AC_CHECK_HEADERS_ONCE([malloc.h])
31 AC_CACHE_CHECK([for working re_compile_pattern], 33 AC_CACHE_CHECK([for working re_compile_pattern],
32 [gl_cv_func_re_compile_pattern_working], 34 [gl_cv_func_re_compile_pattern_working],
33 [AC_RUN_IFELSE( 35 [AC_RUN_IFELSE(
@@ -37,9 +39,19 @@ AC_DEFUN([gl_REGEX],
37 #include <locale.h> 39 #include <locale.h>
38 #include <limits.h> 40 #include <limits.h>
39 #include <string.h> 41 #include <string.h>
40 #if HAVE_DECL_ALARM 42
41 # include <unistd.h> 43 #if defined M_CHECK_ACTION || HAVE_DECL_ALARM
42 # include <signal.h> 44 # include <signal.h>
45 # include <unistd.h>
46 #endif
47
48 #if HAVE_MALLOC_H
49 # include <malloc.h>
50 #endif
51
52 #ifdef M_CHECK_ACTION
53 /* Exit with distinguishable exit code. */
54 static void sigabrt_no_core (int sig) { raise (SIGTERM); }
43 #endif 55 #endif
44 ]], 56 ]],
45 [[int result = 0; 57 [[int result = 0;
@@ -49,15 +61,22 @@ AC_DEFUN([gl_REGEX],
49 const char *s; 61 const char *s;
50 struct re_registers regs; 62 struct re_registers regs;
51 63
64 /* Some builds of glibc go into an infinite loop on this
65 test. Use alarm to force death, and mallopt to avoid
66 malloc recursion in diagnosing the corrupted heap. */
52#if HAVE_DECL_ALARM 67#if HAVE_DECL_ALARM
53 /* Some builds of glibc go into an infinite loop on this test. */
54 signal (SIGALRM, SIG_DFL); 68 signal (SIGALRM, SIG_DFL);
55 alarm (2); 69 alarm (2);
56#endif 70#endif
71#ifdef M_CHECK_ACTION
72 signal (SIGABRT, sigabrt_no_core);
73 mallopt (M_CHECK_ACTION, 2);
74#endif
75
57 if (setlocale (LC_ALL, "en_US.UTF-8")) 76 if (setlocale (LC_ALL, "en_US.UTF-8"))
58 { 77 {
59 { 78 {
60 /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html 79 /* https://sourceware.org/ml/libc-hacker/2006-09/msg00008.html
61 This test needs valgrind to catch the bug on Debian 80 This test needs valgrind to catch the bug on Debian
62 GNU/Linux 3.1 x86, but it might catch the bug better 81 GNU/Linux 3.1 x86, but it might catch the bug better
63 on other platforms and it shouldn't hurt to try the 82 on other platforms and it shouldn't hurt to try the
@@ -71,16 +90,20 @@ AC_DEFUN([gl_REGEX],
71 s = re_compile_pattern (pat, sizeof pat - 1, &regex); 90 s = re_compile_pattern (pat, sizeof pat - 1, &regex);
72 if (s) 91 if (s)
73 result |= 1; 92 result |= 1;
74 else if (re_search (&regex, data, sizeof data - 1, 93 else
75 0, sizeof data - 1, &regs) 94 {
76 != -1) 95 if (re_search (&regex, data, sizeof data - 1,
77 result |= 1; 96 0, sizeof data - 1, &regs)
97 != -1)
98 result |= 1;
99 regfree (&regex);
100 }
78 } 101 }
79 102
80 { 103 {
81 /* This test is from glibc bug 15078. 104 /* This test is from glibc bug 15078.
82 The test case is from Andreas Schwab in 105 The test case is from Andreas Schwab in
83 <http://www.sourceware.org/ml/libc-alpha/2013-01/msg00967.html>. 106 <https://sourceware.org/ml/libc-alpha/2013-01/msg00967.html>.
84 */ 107 */
85 static char const pat[] = "[^x]x"; 108 static char const pat[] = "[^x]x";
86 static char const data[] = 109 static char const data[] =
@@ -105,6 +128,7 @@ AC_DEFUN([gl_REGEX],
105 0, sizeof data - 1, 0); 128 0, sizeof data - 1, 0);
106 if (i != 0 && i != 21) 129 if (i != 0 && i != 21)
107 result |= 1; 130 result |= 1;
131 regfree (&regex);
108 } 132 }
109 } 133 }
110 134
@@ -118,9 +142,13 @@ AC_DEFUN([gl_REGEX],
118 s = re_compile_pattern ("a[^x]b", 6, &regex); 142 s = re_compile_pattern ("a[^x]b", 6, &regex);
119 if (s) 143 if (s)
120 result |= 2; 144 result |= 2;
121 /* This should fail, but succeeds for glibc-2.5. */ 145 else
122 else if (re_search (&regex, "a\nb", 3, 0, 3, &regs) != -1) 146 {
123 result |= 2; 147 /* This should fail, but succeeds for glibc-2.5. */
148 if (re_search (&regex, "a\nb", 3, 0, 3, &regs) != -1)
149 result |= 2;
150 regfree (&regex);
151 }
124 152
125 /* This regular expression is from Spencer ere test number 75 153 /* This regular expression is from Spencer ere test number 75
126 in grep-2.3. */ 154 in grep-2.3. */
@@ -132,7 +160,10 @@ AC_DEFUN([gl_REGEX],
132 s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, &regex); 160 s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, &regex);
133 /* This should fail with _Invalid character class name_ error. */ 161 /* This should fail with _Invalid character class name_ error. */
134 if (!s) 162 if (!s)
135 result |= 4; 163 {
164 result |= 4;
165 regfree (&regex);
166 }
136 167
137 /* Ensure that [b-a] is diagnosed as invalid, when 168 /* Ensure that [b-a] is diagnosed as invalid, when
138 using RE_NO_EMPTY_RANGES. */ 169 using RE_NO_EMPTY_RANGES. */
@@ -140,13 +171,18 @@ AC_DEFUN([gl_REGEX],
140 memset (&regex, 0, sizeof regex); 171 memset (&regex, 0, sizeof regex);
141 s = re_compile_pattern ("a[b-a]", 6, &regex); 172 s = re_compile_pattern ("a[b-a]", 6, &regex);
142 if (s == 0) 173 if (s == 0)
143 result |= 8; 174 {
175 result |= 8;
176 regfree (&regex);
177 }
144 178
145 /* This should succeed, but does not for glibc-2.1.3. */ 179 /* This should succeed, but does not for glibc-2.1.3. */
146 memset (&regex, 0, sizeof regex); 180 memset (&regex, 0, sizeof regex);
147 s = re_compile_pattern ("{1", 2, &regex); 181 s = re_compile_pattern ("{1", 2, &regex);
148 if (s) 182 if (s)
149 result |= 8; 183 result |= 8;
184 else
185 regfree (&regex);
150 186
151 /* The following example is derived from a problem report 187 /* The following example is derived from a problem report
152 against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */ 188 against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */
@@ -154,17 +190,35 @@ AC_DEFUN([gl_REGEX],
154 s = re_compile_pattern ("[an\371]*n", 7, &regex); 190 s = re_compile_pattern ("[an\371]*n", 7, &regex);
155 if (s) 191 if (s)
156 result |= 8; 192 result |= 8;
157 /* This should match, but does not for glibc-2.2.1. */ 193 else
158 else if (re_match (&regex, "an", 2, 0, &regs) != 2) 194 {
159 result |= 8; 195 /* This should match, but does not for glibc-2.2.1. */
196 if (re_match (&regex, "an", 2, 0, &regs) != 2)
197 result |= 8;
198 else
199 {
200 free (regs.start);
201 free (regs.end);
202 }
203 regfree (&regex);
204 }
160 205
161 memset (&regex, 0, sizeof regex); 206 memset (&regex, 0, sizeof regex);
162 s = re_compile_pattern ("x", 1, &regex); 207 s = re_compile_pattern ("x", 1, &regex);
163 if (s) 208 if (s)
164 result |= 8; 209 result |= 8;
165 /* glibc-2.2.93 does not work with a negative RANGE argument. */ 210 else
166 else if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1) 211 {
167 result |= 8; 212 /* glibc-2.2.93 does not work with a negative RANGE argument. */
213 if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)
214 result |= 8;
215 else
216 {
217 free (regs.start);
218 free (regs.end);
219 }
220 regfree (&regex);
221 }
168 222
169 /* The version of regex.c in older versions of gnulib 223 /* The version of regex.c in older versions of gnulib
170 ignored RE_ICASE. Detect that problem too. */ 224 ignored RE_ICASE. Detect that problem too. */
@@ -173,25 +227,89 @@ AC_DEFUN([gl_REGEX],
173 s = re_compile_pattern ("x", 1, &regex); 227 s = re_compile_pattern ("x", 1, &regex);
174 if (s) 228 if (s)
175 result |= 16; 229 result |= 16;
176 else if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0) 230 else
177 result |= 16; 231 {
232 if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0)
233 result |= 16;
234 else
235 {
236 free (regs.start);
237 free (regs.end);
238 }
239 regfree (&regex);
240 }
178 241
179 /* Catch a bug reported by Vin Shelton in 242 /* Catch a bug reported by Vin Shelton in
180 http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00089.html 243 https://lists.gnu.org/r/bug-coreutils/2007-06/msg00089.html
181 */ 244 */
182 re_set_syntax (RE_SYNTAX_POSIX_BASIC 245 re_set_syntax (RE_SYNTAX_POSIX_BASIC
183 & ~RE_CONTEXT_INVALID_DUP 246 & ~RE_CONTEXT_INVALID_DUP
184 & ~RE_NO_EMPTY_RANGES); 247 & ~RE_NO_EMPTY_RANGES);
185 memset (&regex, 0, sizeof regex); 248 memset (&regex, 0, sizeof regex);
186 s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, &regex); 249 s = re_compile_pattern ("[[:alnum:]_-]\\\\+\$", 16, &regex);
187 if (s) 250 if (s)
188 result |= 32; 251 result |= 32;
252 else
253 regfree (&regex);
189 254
190 /* REG_STARTEND was added to glibc on 2004-01-15. 255 /* REG_STARTEND was added to glibc on 2004-01-15.
191 Reject older versions. */ 256 Reject older versions. */
192 if (! REG_STARTEND) 257 if (! REG_STARTEND)
193 result |= 64; 258 result |= 64;
194 259
260 /* Matching with the compiled form of this regexp would provoke
261 an assertion failure prior to glibc-2.28:
262 regexec.c:1375: pop_fail_stack: Assertion 'num >= 0' failed
263 With glibc-2.28, compilation fails and reports the invalid
264 back reference. */
265 re_set_syntax (RE_SYNTAX_POSIX_EGREP);
266 memset (&regex, 0, sizeof regex);
267 s = re_compile_pattern ("0|()0|\\\\1|0", 10, &regex);
268 if (!s)
269 {
270 memset (&regs, 0, sizeof regs);
271 i = re_search (&regex, "x", 1, 0, 1, &regs);
272 if (i != -1)
273 result |= 64;
274 if (0 <= i)
275 {
276 free (regs.start);
277 free (regs.end);
278 }
279 regfree (&regex);
280 }
281 else
282 {
283 if (strcmp (s, "Invalid back reference"))
284 result |= 64;
285 }
286
287 /* glibc bug 11053. */
288 re_set_syntax (RE_SYNTAX_POSIX_BASIC);
289 memset (&regex, 0, sizeof regex);
290 static char const pat_sub2[] = "\\\\(a*\\\\)*a*\\\\1";
291 s = re_compile_pattern (pat_sub2, sizeof pat_sub2 - 1, &regex);
292 if (s)
293 result |= 64;
294 else
295 {
296 memset (&regs, 0, sizeof regs);
297 static char const data[] = "a";
298 int datalen = sizeof data - 1;
299 i = re_search (&regex, data, datalen, 0, datalen, &regs);
300 if (i != 0)
301 result |= 64;
302 else if (regs.num_regs < 2)
303 result |= 64;
304 else if (! (regs.start[0] == 0 && regs.end[0] == 1))
305 result |= 64;
306 else if (! (regs.start[1] == 0 && regs.end[1] == 0))
307 result |= 64;
308 regfree (&regex);
309 free (regs.start);
310 free (regs.end);
311 }
312
195#if 0 313#if 0
196 /* It would be nice to reject hosts whose regoff_t values are too 314 /* It would be nice to reject hosts whose regoff_t values are too
197 narrow (including glibc on hosts with 64-bit ptrdiff_t and 315 narrow (including glibc on hosts with 64-bit ptrdiff_t and
@@ -206,13 +324,19 @@ AC_DEFUN([gl_REGEX],
206 324
207 return result; 325 return result;
208 ]])], 326 ]])],
209 [gl_cv_func_re_compile_pattern_working=yes], 327 [gl_cv_func_re_compile_pattern_working=yes],
210 [gl_cv_func_re_compile_pattern_working=no], 328 [gl_cv_func_re_compile_pattern_working=no],
211 dnl When crosscompiling, assume it is not working. 329 [case "$host_os" in
212 [gl_cv_func_re_compile_pattern_working=no])]) 330 # Guess no on native Windows.
213 case $gl_cv_func_re_compile_pattern_working in #( 331 mingw*) gl_cv_func_re_compile_pattern_working="guessing no" ;;
214 yes) ac_use_included_regex=no;; #( 332 # Otherwise obey --enable-cross-guesses.
215 no) ac_use_included_regex=yes;; 333 *) gl_cv_func_re_compile_pattern_working="$gl_cross_guess_normal" ;;
334 esac
335 ])
336 ])
337 case "$gl_cv_func_re_compile_pattern_working" in #(
338 *yes) ac_use_included_regex=no;; #(
339 *no) ac_use_included_regex=yes;;
216 esac 340 esac
217 ;; 341 ;;
218 *) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex]) 342 *) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex])
@@ -266,8 +390,7 @@ AC_DEFUN([gl_PREREQ_REGEX],
266 AC_REQUIRE([AC_C_RESTRICT]) 390 AC_REQUIRE([AC_C_RESTRICT])
267 AC_REQUIRE([AC_TYPE_MBSTATE_T]) 391 AC_REQUIRE([AC_TYPE_MBSTATE_T])
268 AC_REQUIRE([gl_EEMALLOC]) 392 AC_REQUIRE([gl_EEMALLOC])
269 AC_REQUIRE([gl_GLIBC21])
270 AC_CHECK_HEADERS([libintl.h]) 393 AC_CHECK_HEADERS([libintl.h])
271 AC_CHECK_FUNCS_ONCE([isblank iswctype wcscoll]) 394 AC_CHECK_FUNCS_ONCE([isblank iswctype])
272 AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]]) 395 AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]])
273]) 396])
diff --git a/gl/m4/safe-read.m4 b/gl/m4/safe-read.m4
deleted file mode 100644
index be5207a5..00000000
--- a/gl/m4/safe-read.m4
+++ /dev/null
@@ -1,12 +0,0 @@
1# safe-read.m4 serial 6
2dnl Copyright (C) 2002-2003, 2005-2006, 2009-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8# Prerequisites of lib/safe-read.c.
9AC_DEFUN([gl_PREREQ_SAFE_READ],
10[
11 AC_REQUIRE([gt_TYPE_SSIZE_T])
12])
diff --git a/gl/m4/servent.m4 b/gl/m4/servent.m4
index 01c037a8..0f35b8b8 100644
--- a/gl/m4/servent.m4
+++ b/gl/m4/servent.m4
@@ -1,5 +1,5 @@
1# servent.m4 serial 2 1# servent.m4 serial 4
2dnl Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -10,12 +10,12 @@ AC_DEFUN([gl_SERVENT],
10 dnl getservbyport() defined? 10 dnl getservbyport() defined?
11 dnl Where are getprotoent(), setprotoent(), endprotoent(), getprotobyname(), 11 dnl Where are getprotoent(), setprotoent(), endprotoent(), getprotobyname(),
12 dnl getprotobynumber() defined? 12 dnl getprotobynumber() defined?
13 dnl - On Solaris, they are in libsocket. Ignore libxnet. 13 dnl - On Solaris < 11.4, they are in libsocket. Ignore libxnet.
14 dnl - On Haiku, they are in libnetwork. 14 dnl - On Haiku, they are in libnetwork.
15 dnl - On BeOS, they are in libnet. 15 dnl - On BeOS, they are in libnet.
16 dnl - On native Windows, they are in ws2_32.dll. 16 dnl - On native Windows, they are in ws2_32.dll.
17 dnl - Otherwise they are in libc. 17 dnl - Otherwise they are in libc.
18 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 18 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
19 SERVENT_LIB= 19 SERVENT_LIB=
20 gl_saved_libs="$LIBS" 20 gl_saved_libs="$LIBS"
21 AC_SEARCH_LIBS([getservbyname], [socket network net], 21 AC_SEARCH_LIBS([getservbyname], [socket network net],
diff --git a/gl/m4/setenv.m4 b/gl/m4/setenv.m4
index cb5351a0..16f9eb55 100644
--- a/gl/m4/setenv.m4
+++ b/gl/m4/setenv.m4
@@ -1,5 +1,5 @@
1# setenv.m4 serial 26 1# setenv.m4 serial 30
2dnl Copyright (C) 2001-2004, 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2004, 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -35,10 +35,12 @@ AC_DEFUN([gl_FUNC_SETENV],
35 ]])], 35 ]])],
36 [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no], 36 [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no],
37 [case "$host_os" in 37 [case "$host_os" in
38 # Guess yes on glibc systems. 38 # Guess yes on glibc systems.
39 *-gnu*) gl_cv_func_setenv_works="guessing yes" ;; 39 *-gnu* | gnu*) gl_cv_func_setenv_works="guessing yes" ;;
40 # If we don't know, assume the worst. 40 # Guess yes on musl systems.
41 *) gl_cv_func_setenv_works="guessing no" ;; 41 *-musl*) gl_cv_func_setenv_works="guessing yes" ;;
42 # If we don't know, obey --enable-cross-guesses.
43 *) gl_cv_func_setenv_works="$gl_cross_guess_normal" ;;
42 esac 44 esac
43 ])]) 45 ])])
44 case "$gl_cv_func_setenv_works" in 46 case "$gl_cv_func_setenv_works" in
@@ -104,35 +106,39 @@ int unsetenv (const char *name);
104 dnl OpenBSD 4.7 unsetenv("") does not fail. 106 dnl OpenBSD 4.7 unsetenv("") does not fail.
105 AC_CACHE_CHECK([whether unsetenv obeys POSIX], 107 AC_CACHE_CHECK([whether unsetenv obeys POSIX],
106 [gl_cv_func_unsetenv_works], 108 [gl_cv_func_unsetenv_works],
107 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 109 [AC_RUN_IFELSE(
108 #include <stdlib.h> 110 [AC_LANG_PROGRAM([[
109 #include <errno.h> 111 #include <stdlib.h>
110 extern char **environ; 112 #include <errno.h>
111 ]], [[ 113 extern char **environ;
112 char entry1[] = "a=1"; 114 ]GL_MDA_DEFINES],
113 char entry2[] = "b=2"; 115 [[
114 char *env[] = { entry1, entry2, NULL }; 116 char entry1[] = "a=1";
115 if (putenv ((char *) "a=1")) return 1; 117 char entry2[] = "b=2";
116 if (putenv (entry2)) return 2; 118 char *env[] = { entry1, entry2, NULL };
117 entry2[0] = 'a'; 119 if (putenv ((char *) "a=1")) return 1;
118 unsetenv ("a"); 120 if (putenv (entry2)) return 2;
119 if (getenv ("a")) return 3; 121 entry2[0] = 'a';
120 if (!unsetenv ("") || errno != EINVAL) return 4; 122 unsetenv ("a");
121 entry2[0] = 'b'; 123 if (getenv ("a")) return 3;
122 environ = env; 124 if (!unsetenv ("") || errno != EINVAL) return 4;
123 if (!getenv ("a")) return 5; 125 entry2[0] = 'b';
124 entry2[0] = 'a'; 126 environ = env;
125 unsetenv ("a"); 127 if (!getenv ("a")) return 5;
126 if (getenv ("a")) return 6; 128 entry2[0] = 'a';
127 ]])], 129 unsetenv ("a");
128 [gl_cv_func_unsetenv_works=yes], [gl_cv_func_unsetenv_works=no], 130 if (getenv ("a")) return 6;
129 [case "$host_os" in 131 ]])],
130 # Guess yes on glibc systems. 132 [gl_cv_func_unsetenv_works=yes],
131 *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;; 133 [gl_cv_func_unsetenv_works=no],
132 # If we don't know, assume the worst. 134 [case "$host_os" in
133 *) gl_cv_func_unsetenv_works="guessing no" ;; 135 # Guess yes on glibc systems.
134 esac 136 *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;;
135 ])]) 137 # If we don't know, obey --enable-cross-guesses.
138 *) gl_cv_func_unsetenv_works="$gl_cross_guess_normal" ;;
139 esac
140 ])
141 ])
136 case "$gl_cv_func_unsetenv_works" in 142 case "$gl_cv_func_unsetenv_works" in
137 *yes) ;; 143 *yes) ;;
138 *) 144 *)
diff --git a/gl/m4/setlocale_null.m4 b/gl/m4/setlocale_null.m4
new file mode 100644
index 00000000..032119d0
--- /dev/null
+++ b/gl/m4/setlocale_null.m4
@@ -0,0 +1,98 @@
1# setlocale_null.m4 serial 5
2dnl Copyright (C) 2019-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_SETLOCALE_NULL],
8[
9 AC_REQUIRE([AC_CANONICAL_HOST])
10 AC_REQUIRE([gl_PTHREADLIB])
11 AC_CHECK_HEADERS_ONCE([threads.h])
12
13 AC_CACHE_CHECK([whether setlocale (LC_ALL, NULL) is multithread-safe],
14 [gl_cv_func_setlocale_null_all_mtsafe],
15 [case "$host_os" in
16 # Guess no on musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin.
17 *-musl* | darwin* | freebsd* | midnightbsd* | netbsd* | openbsd* | aix* | haiku* | cygwin*)
18 gl_cv_func_setlocale_null_all_mtsafe=no ;;
19 # Guess yes on glibc, HP-UX, IRIX, Solaris, native Windows.
20 *-gnu* | gnu* | hpux* | irix* | solaris* | mingw*)
21 gl_cv_func_setlocale_null_all_mtsafe=yes ;;
22 # If we don't know, obey --enable-cross-guesses.
23 *)
24 gl_cv_func_setlocale_null_all_mtsafe="$gl_cross_guess_normal" ;;
25 esac
26 ])
27 dnl On platforms without multithreading, there is no issue.
28 case "$host_os" in
29 mingw*) ;;
30 *)
31 if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then
32 gl_cv_func_setlocale_null_all_mtsafe="trivially yes"
33 fi
34 ;;
35 esac
36 case "$gl_cv_func_setlocale_null_all_mtsafe" in
37 *yes) SETLOCALE_NULL_ALL_MTSAFE=1 ;;
38 *) SETLOCALE_NULL_ALL_MTSAFE=0 ;;
39 esac
40 AC_DEFINE_UNQUOTED([SETLOCALE_NULL_ALL_MTSAFE], [$SETLOCALE_NULL_ALL_MTSAFE],
41 [Define to 1 if setlocale (LC_ALL, NULL) is multithread-safe.])
42
43 dnl This is about a single category (not LC_ALL).
44 AC_CACHE_CHECK([whether setlocale (category, NULL) is multithread-safe],
45 [gl_cv_func_setlocale_null_one_mtsafe],
46 [case "$host_os" in
47 # Guess no on OpenBSD, AIX.
48 openbsd* | aix*)
49 gl_cv_func_setlocale_null_one_mtsafe=no ;;
50 # Guess yes on glibc, musl libc, macOS, FreeBSD, NetBSD, HP-UX, IRIX, Solaris, Haiku, Cygwin, native Windows.
51 *-gnu* | gnu* | *-musl* | darwin* | freebsd* | midnightbsd* | netbsd* | hpux* | irix* | solaris* | haiku* | cygwin* | mingw*)
52 gl_cv_func_setlocale_null_one_mtsafe=yes ;;
53 # If we don't know, obey --enable-cross-guesses.
54 *)
55 gl_cv_func_setlocale_null_one_mtsafe="$gl_cross_guess_normal" ;;
56 esac
57 ])
58 dnl On platforms without multithreading, there is no issue.
59 case "$host_os" in
60 mingw*) ;;
61 *)
62 if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then
63 gl_cv_func_setlocale_null_one_mtsafe="trivially yes"
64 fi
65 ;;
66 esac
67 case "$gl_cv_func_setlocale_null_one_mtsafe" in
68 *yes) SETLOCALE_NULL_ONE_MTSAFE=1 ;;
69 *) SETLOCALE_NULL_ONE_MTSAFE=0 ;;
70 esac
71 AC_DEFINE_UNQUOTED([SETLOCALE_NULL_ONE_MTSAFE], [$SETLOCALE_NULL_ONE_MTSAFE],
72 [Define to 1 if setlocale (category, NULL) is multithread-safe.])
73
74 dnl Determine link dependencies of lib/setlocale_null.c and lib/setlocale-lock.c.
75 if test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0; then
76 case "$host_os" in
77 mingw*) LIB_SETLOCALE_NULL= ;;
78 *)
79 gl_WEAK_SYMBOLS
80 case "$gl_cv_have_weak" in
81 *yes) LIB_SETLOCALE_NULL= ;;
82 *) LIB_SETLOCALE_NULL="$LIBPTHREAD" ;;
83 esac
84 ;;
85 esac
86 else
87 LIB_SETLOCALE_NULL=
88 fi
89 dnl LIB_SETLOCALE_NULL is expected to be '-pthread' or '-lpthread' on AIX
90 dnl with gcc or xlc, and empty otherwise.
91 AC_SUBST([LIB_SETLOCALE_NULL])
92])
93
94# Prerequisites of lib/setlocale-lock.c.
95AC_DEFUN([gl_PREREQ_SETLOCALE_LOCK],
96[
97 gl_VISIBILITY
98])
diff --git a/gl/m4/sha256.m4 b/gl/m4/sha256.m4
new file mode 100644
index 00000000..4d1d1dda
--- /dev/null
+++ b/gl/m4/sha256.m4
@@ -0,0 +1,14 @@
1# sha256.m4 serial 8
2dnl Copyright (C) 2005, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_SHA256],
8[
9 dnl Prerequisites of lib/sha256.c.
10 AC_REQUIRE([gl_BIGENDIAN])
11
12 dnl Determine HAVE_OPENSSL_SHA256 and LIB_CRYPTO
13 gl_CRYPTO_CHECK([SHA256])
14])
diff --git a/gl/m4/size_max.m4 b/gl/m4/size_max.m4
index 4b247abc..0763366d 100644
--- a/gl/m4/size_max.m4
+++ b/gl/m4/size_max.m4
@@ -1,17 +1,19 @@
1# size_max.m4 serial 10 1# size_max.m4 serial 12
2dnl Copyright (C) 2003, 2005-2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Bruno Haible. 7dnl From Bruno Haible.
8 8
9AC_PREREQ([2.61])
10
9AC_DEFUN([gl_SIZE_MAX], 11AC_DEFUN([gl_SIZE_MAX],
10[ 12[
11 AC_CHECK_HEADERS([stdint.h]) 13 AC_CHECK_HEADERS([stdint.h])
12 dnl First test whether the system already has SIZE_MAX. 14 dnl First test whether the system already has SIZE_MAX.
13 AC_CACHE_CHECK([for SIZE_MAX], [gl_cv_size_max], [ 15 AC_CACHE_CHECK([for SIZE_MAX], [gl_cv_size_max], [
14 gl_cv_size_max= 16 gl_cv_size_max=no
15 AC_EGREP_CPP([Found it], [ 17 AC_EGREP_CPP([Found it], [
16#include <limits.h> 18#include <limits.h>
17#if HAVE_STDINT_H 19#if HAVE_STDINT_H
@@ -21,7 +23,7 @@ AC_DEFUN([gl_SIZE_MAX],
21Found it 23Found it
22#endif 24#endif
23], [gl_cv_size_max=yes]) 25], [gl_cv_size_max=yes])
24 if test -z "$gl_cv_size_max"; then 26 if test $gl_cv_size_max != yes; then
25 dnl Define it ourselves. Here we assume that the type 'size_t' is not wider 27 dnl Define it ourselves. Here we assume that the type 'size_t' is not wider
26 dnl than the type 'unsigned long'. Try hard to find a definition that can 28 dnl than the type 'unsigned long'. Try hard to find a definition that can
27 dnl be used in a preprocessor #if, i.e. doesn't contain a cast. 29 dnl be used in a preprocessor #if, i.e. doesn't contain a cast.
@@ -71,9 +73,3 @@ Found it
71# undef SIZE_MAX 73# undef SIZE_MAX
72#endif]) 74#endif])
73]) 75])
74
75dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
76dnl Remove this when we can assume autoconf >= 2.61.
77m4_ifdef([AC_COMPUTE_INT], [], [
78 AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
79])
diff --git a/gl/m4/snprintf.m4 b/gl/m4/snprintf.m4
index 3698e844..4b5fbdbf 100644
--- a/gl/m4/snprintf.m4
+++ b/gl/m4/snprintf.m4
@@ -1,5 +1,5 @@
1# snprintf.m4 serial 6 1# snprintf.m4 serial 7
2dnl Copyright (C) 2002-2004, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -46,6 +46,14 @@ AC_DEFUN([gl_REPLACE_SNPRINTF],
46 AC_LIBOBJ([snprintf]) 46 AC_LIBOBJ([snprintf])
47 if test $ac_cv_func_snprintf = yes; then 47 if test $ac_cv_func_snprintf = yes; then
48 REPLACE_SNPRINTF=1 48 REPLACE_SNPRINTF=1
49 else
50 AC_CHECK_DECLS_ONCE([snprintf])
51 if test $ac_cv_have_decl_snprintf = yes; then
52 dnl If the function is declared but does not appear to exist, it may be
53 dnl defined as an inline function. In order to avoid a conflict, we have
54 dnl to define rpl_snprintf, not snprintf.
55 REPLACE_SNPRINTF=1
56 fi
49 fi 57 fi
50 gl_PREREQ_SNPRINTF 58 gl_PREREQ_SNPRINTF
51]) 59])
diff --git a/gl/m4/socketlib.m4 b/gl/m4/socketlib.m4
index b08a72f6..a556af1e 100644
--- a/gl/m4/socketlib.m4
+++ b/gl/m4/socketlib.m4
@@ -1,5 +1,5 @@
1# socketlib.m4 serial 1 1# socketlib.m4 serial 3
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -14,21 +14,27 @@ AC_DEFUN([gl_SOCKETLIB],
14 LIBSOCKET= 14 LIBSOCKET=
15 if test $HAVE_WINSOCK2_H = 1; then 15 if test $HAVE_WINSOCK2_H = 1; then
16 dnl Native Windows API (not Cygwin). 16 dnl Native Windows API (not Cygwin).
17 AC_CACHE_CHECK([if we need to call WSAStartup in winsock2.h and -lws2_32], 17 dnl If the function WSAStartup exists (declared in <winsock2.h> and
18 [gl_cv_func_wsastartup], [ 18 dnl defined through -lws2_32), we need to call it.
19 gl_save_LIBS="$LIBS" 19 AC_CACHE_CHECK([for WSAStartup],
20 LIBS="$LIBS -lws2_32" 20 [gl_cv_func_wsastartup], [
21 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 21 gl_save_LIBS="$LIBS"
22 LIBS="$LIBS -lws2_32"
23 AC_LINK_IFELSE(
24 [AC_LANG_PROGRAM([[
22#ifdef HAVE_WINSOCK2_H 25#ifdef HAVE_WINSOCK2_H
23# include <winsock2.h> 26# include <winsock2.h>
24#endif]], [[ 27#endif]], [[
25 WORD wVersionRequested = MAKEWORD(1, 1); 28 WORD wVersionRequested = MAKEWORD(1, 1);
26 WSADATA wsaData; 29 WSADATA wsaData;
27 int err = WSAStartup(wVersionRequested, &wsaData); 30 int err = WSAStartup(wVersionRequested, &wsaData);
28 WSACleanup ();]])], 31 WSACleanup ();
29 gl_cv_func_wsastartup=yes, gl_cv_func_wsastartup=no) 32 ]])
30 LIBS="$gl_save_LIBS" 33 ],
31 ]) 34 [gl_cv_func_wsastartup=yes],
35 [gl_cv_func_wsastartup=no])
36 LIBS="$gl_save_LIBS"
37 ])
32 if test "$gl_cv_func_wsastartup" = "yes"; then 38 if test "$gl_cv_func_wsastartup" = "yes"; then
33 AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.]) 39 AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.])
34 LIBSOCKET='-lws2_32' 40 LIBSOCKET='-lws2_32'
@@ -38,6 +44,10 @@ AC_DEFUN([gl_SOCKETLIB],
38 dnl Solaris has most socket functions in libsocket. 44 dnl Solaris has most socket functions in libsocket.
39 dnl Haiku has most socket functions in libnetwork. 45 dnl Haiku has most socket functions in libnetwork.
40 dnl BeOS has most socket functions in libnet. 46 dnl BeOS has most socket functions in libnet.
47 dnl On HP-UX, do NOT link with libxnet, because in 64-bit mode this would
48 dnl break code (e.g. in libraries) that invokes accept(), getpeername(),
49 dnl getsockname(), getsockopt(), or recvfrom() with a 32-bit addrlen. See
50 dnl "man xopen_networking" for details.
41 AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [ 51 AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [
42 gl_cv_lib_socket= 52 gl_cv_lib_socket=
43 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern 53 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
diff --git a/gl/m4/sockets.m4 b/gl/m4/sockets.m4
index b407391c..ed9cb873 100644
--- a/gl/m4/sockets.m4
+++ b/gl/m4/sockets.m4
@@ -1,5 +1,5 @@
1# sockets.m4 serial 7 1# sockets.m4 serial 7
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/socklen.m4 b/gl/m4/socklen.m4
index e3efd6ef..1c63a853 100644
--- a/gl/m4/socklen.m4
+++ b/gl/m4/socklen.m4
@@ -1,5 +1,5 @@
1# socklen.m4 serial 10 1# socklen.m4 serial 11
2dnl Copyright (C) 2005-2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -15,8 +15,8 @@ dnl So we have to test to find something that will work.
15AC_DEFUN([gl_TYPE_SOCKLEN_T], 15AC_DEFUN([gl_TYPE_SOCKLEN_T],
16 [AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])dnl 16 [AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])dnl
17 AC_CHECK_TYPE([socklen_t], , 17 AC_CHECK_TYPE([socklen_t], ,
18 [AC_MSG_CHECKING([for socklen_t equivalent]) 18 [AC_CACHE_CHECK([for socklen_t equivalent],
19 AC_CACHE_VAL([gl_cv_socklen_t_equiv], 19 [gl_cv_socklen_t_equiv],
20 [# Systems have either "struct sockaddr *" or 20 [# Systems have either "struct sockaddr *" or
21 # "void *" as the second argument to getpeername 21 # "void *" as the second argument to getpeername
22 gl_cv_socklen_t_equiv= 22 gl_cv_socklen_t_equiv=
@@ -34,11 +34,10 @@ AC_DEFUN([gl_TYPE_SOCKLEN_T],
34 done 34 done
35 test "$gl_cv_socklen_t_equiv" != "" && break 35 test "$gl_cv_socklen_t_equiv" != "" && break
36 done 36 done
37 ]) 37 if test "$gl_cv_socklen_t_equiv" = ""; then
38 if test "$gl_cv_socklen_t_equiv" = ""; then 38 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
39 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) 39 fi
40 fi 40 ])
41 AC_MSG_RESULT([$gl_cv_socklen_t_equiv])
42 AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv], 41 AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv],
43 [type to use in place of socklen_t if not defined])], 42 [type to use in place of socklen_t if not defined])],
44 [gl_SOCKET_HEADERS])]) 43 [gl_SOCKET_HEADERS])])
diff --git a/gl/m4/sockpfaf.m4 b/gl/m4/sockpfaf.m4
index 89557b18..6c6dc2f7 100644
--- a/gl/m4/sockpfaf.m4
+++ b/gl/m4/sockpfaf.m4
@@ -1,5 +1,5 @@
1# sockpfaf.m4 serial 8 1# sockpfaf.m4 serial 10
2dnl Copyright (C) 2004, 2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2004, 2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -13,11 +13,11 @@ dnl From Bruno Haible.
13 13
14AC_DEFUN([gl_SOCKET_FAMILIES], 14AC_DEFUN([gl_SOCKET_FAMILIES],
15[ 15[
16 AC_REQUIRE([gl_HEADER_SYS_SOCKET]) 16 AC_REQUIRE([gl_SYS_SOCKET_H])
17 AC_CHECK_HEADERS_ONCE([netinet/in.h]) 17 AC_CHECK_HEADERS_ONCE([netinet/in.h])
18 18
19 AC_MSG_CHECKING([for IPv4 sockets]) 19 AC_CACHE_CHECK([for IPv4 sockets],
20 AC_CACHE_VAL([gl_cv_socket_ipv4], 20 [gl_cv_socket_ipv4],
21 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 21 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
22#ifdef HAVE_SYS_SOCKET_H 22#ifdef HAVE_SYS_SOCKET_H
23#include <sys/socket.h> 23#include <sys/socket.h>
@@ -31,13 +31,12 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
31[[int x = AF_INET; struct in_addr y; struct sockaddr_in z; 31[[int x = AF_INET; struct in_addr y; struct sockaddr_in z;
32 if (&x && &y && &z) return 0;]])], 32 if (&x && &y && &z) return 0;]])],
33 gl_cv_socket_ipv4=yes, gl_cv_socket_ipv4=no)]) 33 gl_cv_socket_ipv4=yes, gl_cv_socket_ipv4=no)])
34 AC_MSG_RESULT([$gl_cv_socket_ipv4])
35 if test $gl_cv_socket_ipv4 = yes; then 34 if test $gl_cv_socket_ipv4 = yes; then
36 AC_DEFINE([HAVE_IPV4], [1], [Define to 1 if <sys/socket.h> defines AF_INET.]) 35 AC_DEFINE([HAVE_IPV4], [1], [Define to 1 if <sys/socket.h> defines AF_INET.])
37 fi 36 fi
38 37
39 AC_MSG_CHECKING([for IPv6 sockets]) 38 AC_CACHE_CHECK([for IPv6 sockets],
40 AC_CACHE_VAL([gl_cv_socket_ipv6], 39 [gl_cv_socket_ipv6],
41 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 40 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
42#ifdef HAVE_SYS_SOCKET_H 41#ifdef HAVE_SYS_SOCKET_H
43#include <sys/socket.h> 42#include <sys/socket.h>
@@ -54,7 +53,6 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
54[[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z; 53[[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z;
55 if (&x && &y && &z) return 0;]])], 54 if (&x && &y && &z) return 0;]])],
56 gl_cv_socket_ipv6=yes, gl_cv_socket_ipv6=no)]) 55 gl_cv_socket_ipv6=yes, gl_cv_socket_ipv6=no)])
57 AC_MSG_RESULT([$gl_cv_socket_ipv6])
58 if test $gl_cv_socket_ipv6 = yes; then 56 if test $gl_cv_socket_ipv6 = yes; then
59 AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if <sys/socket.h> defines AF_INET6.]) 57 AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if <sys/socket.h> defines AF_INET6.])
60 fi 58 fi
@@ -62,11 +60,11 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
62 60
63AC_DEFUN([gl_SOCKET_FAMILY_UNIX], 61AC_DEFUN([gl_SOCKET_FAMILY_UNIX],
64[ 62[
65 AC_REQUIRE([gl_HEADER_SYS_SOCKET]) 63 AC_REQUIRE([gl_SYS_SOCKET_H])
66 AC_CHECK_HEADERS_ONCE([sys/un.h]) 64 AC_CHECK_HEADERS_ONCE([sys/un.h])
67 65
68 AC_MSG_CHECKING([for UNIX domain sockets]) 66 AC_CACHE_CHECK([for UNIX domain sockets],
69 AC_CACHE_VAL([gl_cv_socket_unix], 67 [gl_cv_socket_unix],
70 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 68 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
71#ifdef HAVE_SYS_SOCKET_H 69#ifdef HAVE_SYS_SOCKET_H
72#include <sys/socket.h> 70#include <sys/socket.h>
@@ -80,7 +78,6 @@ AC_DEFUN([gl_SOCKET_FAMILY_UNIX],
80[[int x = AF_UNIX; struct sockaddr_un y; 78[[int x = AF_UNIX; struct sockaddr_un y;
81 if (&x && &y) return 0;]])], 79 if (&x && &y) return 0;]])],
82 gl_cv_socket_unix=yes, gl_cv_socket_unix=no)]) 80 gl_cv_socket_unix=yes, gl_cv_socket_unix=no)])
83 AC_MSG_RESULT([$gl_cv_socket_unix])
84 if test $gl_cv_socket_unix = yes; then 81 if test $gl_cv_socket_unix = yes; then
85 AC_DEFINE([HAVE_UNIXSOCKET], [1], [Define to 1 if <sys/socket.h> defines AF_UNIX.]) 82 AC_DEFINE([HAVE_UNIXSOCKET], [1], [Define to 1 if <sys/socket.h> defines AF_UNIX.])
86 fi 83 fi
diff --git a/gl/m4/ssize_t.m4 b/gl/m4/ssize_t.m4
index 63381343..1c12c33e 100644
--- a/gl/m4/ssize_t.m4
+++ b/gl/m4/ssize_t.m4
@@ -1,5 +1,5 @@
1# ssize_t.m4 serial 5 (gettext-0.18.2) 1# ssize_t.m4 serial 5 (gettext-0.18.2)
2dnl Copyright (C) 2001-2003, 2006, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2003, 2006, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/stat-time.m4 b/gl/m4/stat-time.m4
new file mode 100644
index 00000000..40993d57
--- /dev/null
+++ b/gl/m4/stat-time.m4
@@ -0,0 +1,83 @@
1# Checks for stat-related time functions.
2
3# Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2023 Free Software
4# Foundation, Inc.
5
6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved.
9
10dnl From Paul Eggert.
11
12# st_atim.tv_nsec - Linux, Solaris, Cygwin
13# st_atimespec.tv_nsec - FreeBSD, NetBSD, if ! defined _POSIX_SOURCE
14# st_atimensec - FreeBSD, NetBSD, if defined _POSIX_SOURCE
15# st_atim.st__tim.tv_nsec - UnixWare (at least 2.1.2 through 7.1)
16
17# st_birthtimespec - FreeBSD, NetBSD (hidden on OpenBSD 3.9, anyway)
18# st_birthtim - Cygwin 1.7.0+
19
20AC_DEFUN([gl_STAT_TIME],
21[
22 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
23 AC_CHECK_HEADERS_ONCE([sys/time.h])
24
25 AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec],
26 [AC_CACHE_CHECK([whether struct stat.st_atim is of type struct timespec],
27 [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec],
28 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
29 [[
30 #include <sys/types.h>
31 #include <sys/stat.h>
32 #if HAVE_SYS_TIME_H
33 # include <sys/time.h>
34 #endif
35 #include <time.h>
36 struct timespec ts;
37 struct stat st;
38 ]],
39 [[
40 st.st_atim = ts;
41 ]])],
42 [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=yes],
43 [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=no])])
44 if test $ac_cv_typeof_struct_stat_st_atim_is_struct_timespec = yes; then
45 AC_DEFINE([TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC], [1],
46 [Define to 1 if the type of the st_atim member of a struct stat is
47 struct timespec.])
48 fi],
49 [AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec], [],
50 [AC_CHECK_MEMBERS([struct stat.st_atimensec], [],
51 [AC_CHECK_MEMBERS([struct stat.st_atim.st__tim.tv_nsec], [], [],
52 [#include <sys/types.h>
53 #include <sys/stat.h>])],
54 [#include <sys/types.h>
55 #include <sys/stat.h>])],
56 [#include <sys/types.h>
57 #include <sys/stat.h>])],
58 [#include <sys/types.h>
59 #include <sys/stat.h>])
60])
61
62# Check for st_birthtime, a feature from UFS2 (FreeBSD, NetBSD, OpenBSD, etc.)
63# and NTFS (Cygwin).
64# There was a time when this field was named st_createtime (21 June
65# 2002 to 16 July 2002) But that window is very small and applied only
66# to development code, so systems still using that configuration are
67# not supported. See revisions 1.10 and 1.11 of FreeBSD's
68# src/sys/ufs/ufs/dinode.h.
69#
70AC_DEFUN([gl_STAT_BIRTHTIME],
71[
72 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
73 AC_CHECK_HEADERS_ONCE([sys/time.h])
74 AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec], [],
75 [AC_CHECK_MEMBERS([struct stat.st_birthtimensec], [],
76 [AC_CHECK_MEMBERS([struct stat.st_birthtim.tv_nsec], [], [],
77 [#include <sys/types.h>
78 #include <sys/stat.h>])],
79 [#include <sys/types.h>
80 #include <sys/stat.h>])],
81 [#include <sys/types.h>
82 #include <sys/stat.h>])
83])
diff --git a/gl/m4/stat.m4 b/gl/m4/stat.m4
new file mode 100644
index 00000000..4d241e27
--- /dev/null
+++ b/gl/m4/stat.m4
@@ -0,0 +1,85 @@
1# serial 18
2
3# Copyright (C) 2009-2023 Free Software Foundation, Inc.
4#
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8
9AC_DEFUN([gl_FUNC_STAT],
10[
11 AC_REQUIRE([AC_CANONICAL_HOST])
12 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
13 AC_CHECK_FUNCS_ONCE([lstat])
14 case "$host_os" in
15 mingw*)
16 dnl On this platform, the original stat() returns st_atime, st_mtime,
17 dnl st_ctime values that are affected by the time zone.
18 REPLACE_STAT=1
19 ;;
20 *)
21 dnl AIX 7.1, Solaris 9, mingw64 mistakenly succeed on stat("file/").
22 dnl (For mingw, this is due to a broken stat() override in libmingwex.a.)
23 dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/").
24 AC_CACHE_CHECK([whether stat handles trailing slashes on files],
25 [gl_cv_func_stat_file_slash],
26 [touch conftest.tmp
27 # Assume that if we have lstat, we can also check symlinks.
28 if test $ac_cv_func_lstat = yes; then
29 ln -s conftest.tmp conftest.lnk
30 fi
31 AC_RUN_IFELSE(
32 [AC_LANG_PROGRAM(
33 [[#include <sys/stat.h>
34]], [[int result = 0;
35 struct stat st;
36 if (!stat ("conftest.tmp/", &st))
37 result |= 1;
38#if HAVE_LSTAT
39 if (!stat ("conftest.lnk/", &st))
40 result |= 2;
41#endif
42 return result;
43 ]])],
44 [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
45 [case "$host_os" in
46 # Guess yes on Linux systems.
47 linux-* | linux) gl_cv_func_stat_file_slash="guessing yes" ;;
48 # Guess yes on glibc systems.
49 *-gnu* | gnu*) gl_cv_func_stat_file_slash="guessing yes" ;;
50 # If we don't know, obey --enable-cross-guesses.
51 *) gl_cv_func_stat_file_slash="$gl_cross_guess_normal" ;;
52 esac
53 ])
54 rm -f conftest.tmp conftest.lnk])
55 case $gl_cv_func_stat_file_slash in
56 *no)
57 REPLACE_STAT=1
58 AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs
59 help when passed a file name with a trailing slash]);;
60 esac
61 case $host_os in
62 dnl Solaris stat can return a negative tv_nsec.
63 solaris*)
64 REPLACE_FSTAT=1 ;;
65 esac
66 ;;
67 esac
68])
69
70# Prerequisites of lib/stat.c and lib/stat-w32.c.
71AC_DEFUN([gl_PREREQ_STAT], [
72 AC_REQUIRE([gl_SYS_STAT_H])
73 AC_REQUIRE([gl_PREREQ_STAT_W32])
74 :
75])
76
77# Prerequisites of lib/stat-w32.c.
78AC_DEFUN([gl_PREREQ_STAT_W32], [
79 AC_REQUIRE([AC_CANONICAL_HOST])
80 case "$host_os" in
81 mingw*)
82 AC_CHECK_HEADERS([sdkddkver.h])
83 ;;
84 esac
85])
diff --git a/gl/m4/std-gnu11.m4 b/gl/m4/std-gnu11.m4
new file mode 100644
index 00000000..4179470e
--- /dev/null
+++ b/gl/m4/std-gnu11.m4
@@ -0,0 +1,829 @@
1# Prefer GNU C11 and C++11 to earlier versions. -*- coding: utf-8 -*-
2
3# This implementation is taken from GNU Autoconf lib/autoconf/c.m4
4# commit 017d5ddd82854911f0119691d91ea8a1438824d6
5# dated Sun Apr 3 13:57:17 2016 -0700
6# This implementation will be obsolete once we can assume Autoconf 2.70
7# or later is installed everywhere a Gnulib program might be developed.
8
9m4_version_prereq([2.70], [], [
10
11
12# Copyright (C) 2001-2023 Free Software Foundation, Inc.
13
14# This program is free software; you can redistribute it and/or modify
15# it under the terms of the GNU General Public License as published by
16# the Free Software Foundation, either version 3 of the License, or
17# (at your option) any later version.
18#
19# This program is distributed in the hope that it will be useful,
20# but WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22# GNU General Public License for more details.
23#
24# You should have received a copy of the GNU General Public License
25# along with this program. If not, see <https://www.gnu.org/licenses/>.
26
27# Written by David MacKenzie, with help from
28# Akim Demaille, Paul Eggert,
29# François Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
30# Roland McGrath, Noah Friedman, david d zuhn, and many others.
31
32
33# AC_PROG_CC([COMPILER ...])
34# --------------------------
35# COMPILER ... is a space separated list of C compilers to search for.
36# This just gives the user an opportunity to specify an alternative
37# search list for the C compiler.
38AC_DEFUN_ONCE([AC_PROG_CC],
39[AC_LANG_PUSH(C)dnl
40AC_ARG_VAR([CC], [C compiler command])dnl
41AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
42_AC_ARG_VAR_LDFLAGS()dnl
43_AC_ARG_VAR_LIBS()dnl
44_AC_ARG_VAR_CPPFLAGS()dnl
45m4_ifval([$1],
46 [AC_CHECK_TOOLS(CC, [$1])],
47[AC_CHECK_TOOL(CC, gcc)
48if test -z "$CC"; then
49 dnl Here we want:
50 dnl AC_CHECK_TOOL(CC, cc)
51 dnl but without the check for a tool without the prefix.
52 dnl Until the check is removed from there, copy the code:
53 if test -n "$ac_tool_prefix"; then
54 AC_CHECK_PROG(CC, [${ac_tool_prefix}cc], [${ac_tool_prefix}cc])
55 fi
56fi
57if test -z "$CC"; then
58 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
59fi
60if test -z "$CC"; then
61 AC_CHECK_TOOLS(CC, cl.exe)
62fi
63if test -z "$CC"; then
64 AC_CHECK_TOOL(CC, clang)
65fi
66])
67
68test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
69
70# Provide some information about the compiler.
71_AS_ECHO_LOG([checking for _AC_LANG compiler version])
72set X $ac_compile
73ac_compiler=$[2]
74for ac_option in --version -v -V -qversion -version; do
75 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
76done
77
78m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
79m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
80_AC_LANG_COMPILER_GNU
81if test $ac_compiler_gnu = yes; then
82 GCC=yes
83else
84 GCC=
85fi
86_AC_PROG_CC_G
87dnl
88dnl Set ac_prog_cc_stdc to the supported C version.
89dnl Also set the documented variable ac_cv_prog_cc_stdc;
90dnl its name was chosen when it was cached, but it is no longer cached.
91_AC_PROG_CC_C11([ac_prog_cc_stdc=c11
92 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11],
93 [_AC_PROG_CC_C99([ac_prog_cc_stdc=c99
94 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99],
95 [_AC_PROG_CC_C89([ac_prog_cc_stdc=c89
96 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89],
97 [ac_prog_cc_stdc=no
98 ac_cv_prog_cc_stdc=no])])])
99dnl
100AC_LANG_POP(C)dnl
101])# AC_PROG_CC
102
103
104
105# AC_PROG_CXX([LIST-OF-COMPILERS])
106# --------------------------------
107# LIST-OF-COMPILERS is a space separated list of C++ compilers to search
108# for (if not specified, a default list is used). This just gives the
109# user an opportunity to specify an alternative search list for the C++
110# compiler.
111# aCC HP-UX C++ compiler much better than `CC', so test before.
112# FCC Fujitsu C++ compiler
113# KCC KAI C++ compiler
114# RCC Rational C++
115# xlC_r AIX C Set++ (with support for reentrant code)
116# xlC AIX C Set++
117AC_DEFUN([AC_PROG_CXX],
118[AC_LANG_PUSH(C++)dnl
119AC_ARG_VAR([CXX], [C++ compiler command])dnl
120AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl
121_AC_ARG_VAR_LDFLAGS()dnl
122_AC_ARG_VAR_LIBS()dnl
123_AC_ARG_VAR_CPPFLAGS()dnl
124_AC_ARG_VAR_PRECIOUS([CCC])dnl
125if test -z "$CXX"; then
126 if test -n "$CCC"; then
127 CXX=$CCC
128 else
129 AC_CHECK_TOOLS(CXX,
130 [m4_default([$1],
131 [g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++])],
132 g++)
133 fi
134fi
135# Provide some information about the compiler.
136_AS_ECHO_LOG([checking for _AC_LANG compiler version])
137set X $ac_compile
138ac_compiler=$[2]
139for ac_option in --version -v -V -qversion; do
140 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
141done
142
143m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
144m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
145_AC_LANG_COMPILER_GNU
146if test $ac_compiler_gnu = yes; then
147 GXX=yes
148else
149 GXX=
150fi
151_AC_PROG_CXX_G
152_AC_PROG_CXX_CXX11([ac_prog_cxx_stdcxx=cxx11
153 ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11
154 ac_cv_prog_cxx_cxx98=$ac_cv_prog_cxx_cxx11],
155 [_AC_PROG_CXX_CXX98([ac_prog_cxx_stdcxx=cxx98
156 ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98],
157 [ac_prog_cxx_stdcxx=no
158 ac_cv_prog_cxx_stdcxx=no])])
159AC_LANG_POP(C++)dnl
160])# AC_PROG_CXX
161
162
163# _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
164# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
165# --------------------------------------------------------------
166# Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99')
167# by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails,
168# try again with each compiler option in the space-separated OPTION-LIST; if one
169# helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE,
170# else ACTION-IF-UNAVAILABLE.
171AC_DEFUN([_AC_C_STD_TRY],
172[AC_MSG_CHECKING([for $CC option to enable ]m4_translit($1, [c], [C])[ features])
173AC_CACHE_VAL(ac_cv_prog_cc_$1,
174[ac_cv_prog_cc_$1=no
175ac_save_CC=$CC
176AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
177for ac_arg in '' $4
178do
179 CC="$ac_save_CC $ac_arg"
180 _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg])
181 test "x$ac_cv_prog_cc_$1" != "xno" && break
182done
183rm -f conftest.$ac_ext
184CC=$ac_save_CC
185])# AC_CACHE_VAL
186ac_prog_cc_stdc_options=
187case "x$ac_cv_prog_cc_$1" in
188 x)
189 AC_MSG_RESULT([none needed]) ;;
190 xno)
191 AC_MSG_RESULT([unsupported]) ;;
192 *)
193 ac_prog_cc_stdc_options=" $ac_cv_prog_cc_$1"
194 CC=$CC$ac_prog_cc_stdc_options
195 AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;
196esac
197AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
198])# _AC_C_STD_TRY
199
200# _AC_C_C99_TEST_HEADER
201# ---------------------
202# A C header suitable for testing for C99.
203AC_DEFUN([_AC_C_C99_TEST_HEADER],
204[[#include <stdarg.h>
205#include <stdbool.h>
206#include <stddef.h>
207#include <stdlib.h>
208#include <wchar.h>
209#include <stdio.h>
210
211// Check varargs macros. These examples are taken from C99 6.10.3.5.
212#define debug(...) fprintf (stderr, __VA_ARGS__)
213#define showlist(...) puts (#__VA_ARGS__)
214#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
215static void
216test_varargs_macros (void)
217{
218 int x = 1234;
219 int y = 5678;
220 debug ("Flag");
221 debug ("X = %d\n", x);
222 showlist (The first, second, and third items.);
223 report (x>y, "x is %d but y is %d", x, y);
224}
225
226// Check long long types.
227#define BIG64 18446744073709551615ull
228#define BIG32 4294967295ul
229#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
230#if !BIG_OK
231 your preprocessor is broken;
232#endif
233#if BIG_OK
234#else
235 your preprocessor is broken;
236#endif
237static long long int bignum = -9223372036854775807LL;
238static unsigned long long int ubignum = BIG64;
239
240struct incomplete_array
241{
242 int datasize;
243 double data[];
244};
245
246struct named_init {
247 int number;
248 const wchar_t *name;
249 double average;
250};
251
252typedef const char *ccp;
253
254static inline int
255test_restrict (ccp restrict text)
256{
257 // See if C++-style comments work.
258 // Iterate through items via the restricted pointer.
259 // Also check for declarations in for loops.
260 for (unsigned int i = 0; *(text+i) != '\0'; ++i)
261 continue;
262 return 0;
263}
264
265// Check varargs and va_copy.
266static bool
267test_varargs (const char *format, ...)
268{
269 va_list args;
270 va_start (args, format);
271 va_list args_copy;
272 va_copy (args_copy, args);
273
274 const char *str = "";
275 int number = 0;
276 float fnumber = 0;
277
278 while (*format)
279 {
280 switch (*format++)
281 {
282 case 's': // string
283 str = va_arg (args_copy, const char *);
284 break;
285 case 'd': // int
286 number = va_arg (args_copy, int);
287 break;
288 case 'f': // float
289 fnumber = va_arg (args_copy, double);
290 break;
291 default:
292 break;
293 }
294 }
295 va_end (args_copy);
296 va_end (args);
297
298 return *str && number && fnumber;
299}]])# _AC_C_C99_TEST_HEADER
300
301# _AC_C_C99_TEST_BODY
302# -------------------
303# A C body suitable for testing for C99, assuming the corresponding header.
304AC_DEFUN([_AC_C_C99_TEST_BODY],
305[[
306 // Check bool.
307 _Bool success = false;
308
309 // Check restrict.
310 if (test_restrict ("String literal") == 0)
311 success = true;
312 char *restrict newvar = "Another string";
313
314 // Check varargs.
315 success &= test_varargs ("s, d' f .", "string", 65, 34.234);
316 test_varargs_macros ();
317
318 // Check flexible array members.
319 struct incomplete_array *ia =
320 malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
321 ia->datasize = 10;
322 for (int i = 0; i < ia->datasize; ++i)
323 ia->data[i] = i * 1.234;
324
325 // Check named initializers.
326 struct named_init ni = {
327 .number = 34,
328 .name = L"Test wide string",
329 .average = 543.34343,
330 };
331
332 ni.number = 58;
333
334 int dynamic_array[ni.number];
335 dynamic_array[ni.number - 1] = 543;
336
337 // work around unused variable warnings
338 return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
339 || dynamic_array[ni.number - 1] != 543);
340]])
341
342# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
343# ----------------------------------------------------------------
344# If the C compiler is not in ISO C99 mode by default, try to add an
345# option to output variable CC to make it so. This macro tries
346# various options that select ISO C99 on some system or another. It
347# considers the compiler to be in ISO C99 mode if it handles _Bool,
348# // comments, flexible array members, inline, long long int, mixed
349# code and declarations, named initialization of structs, restrict,
350# va_copy, varargs macros, variable declarations in for loops and
351# variable length arrays.
352AC_DEFUN([_AC_PROG_CC_C99],
353[_AC_C_STD_TRY([c99],
354[_AC_C_C99_TEST_HEADER],
355[_AC_C_C99_TEST_BODY],
356dnl Try
357dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999)
358dnl IBM XL C -qlanglvl=extc1x (V12.1; does not pass C11 test)
359dnl IBM XL C -qlanglvl=extc99
360dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdc99)
361dnl HP cc -AC99
362dnl Intel ICC -std=c99, -c99 (deprecated)
363dnl IRIX -c99
364dnl Solaris -D_STDC_C99=
365dnl cc's -xc99 option uses linker magic to define the external
366dnl symbol __xpg4 as if by "int __xpg4 = 1;", which enables C99
367dnl behavior for C library functions. This is not wanted here,
368dnl because it means that a single module compiled with -xc99
369dnl alters C runtime behavior for the entire program, not for
370dnl just the module. Instead, define the (private) symbol
371dnl _STDC_C99, which suppresses a bogus failure in <stdbool.h>.
372dnl The resulting compiler passes the test case here, and that's
373dnl good enough. For more, please see the thread starting at:
374dnl https://lists.gnu.org/r/autoconf/2010-12/msg00059.html
375dnl Tru64 -c99
376dnl with extended modes being tried first.
377[[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x -qlanglvl=extc99]], [$1], [$2])[]dnl
378])# _AC_PROG_CC_C99
379
380
381# _AC_PROG_CC_C11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
382# ----------------------------------------------------------------
383# If the C compiler is not in ISO C11 mode by default, try to add an
384# option to output variable CC to make it so. This macro tries
385# various options that select ISO C11 on some system or another. It
386# considers the compiler to be in ISO C11 mode if it handles _Alignas,
387# _Alignof, _Noreturn, _Static_assert, UTF-8 string literals,
388# duplicate typedefs, and anonymous structures and unions.
389AC_DEFUN([_AC_PROG_CC_C11],
390[_AC_C_STD_TRY([c11],
391[_AC_C_C99_TEST_HEADER[
392// Check _Alignas.
393char _Alignas (double) aligned_as_double;
394char _Alignas (0) no_special_alignment;
395extern char aligned_as_int;
396char _Alignas (0) _Alignas (int) aligned_as_int;
397
398// Check _Alignof.
399enum
400{
401 int_alignment = _Alignof (int),
402 int_array_alignment = _Alignof (int[100]),
403 char_alignment = _Alignof (char)
404};
405_Static_assert (0 < -_Alignof (int), "_Alignof is signed");
406
407// Check _Noreturn.
408int _Noreturn does_not_return (void) { for (;;) continue; }
409
410// Check _Static_assert.
411struct test_static_assert
412{
413 int x;
414 _Static_assert (sizeof (int) <= sizeof (long int),
415 "_Static_assert does not work in struct");
416 long int y;
417};
418
419// Check UTF-8 literals.
420#define u8 syntax error!
421char const utf8_literal[] = u8"happens to be ASCII" "another string";
422
423// Check duplicate typedefs.
424typedef long *long_ptr;
425typedef long int *long_ptr;
426typedef long_ptr long_ptr;
427
428// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.
429struct anonymous
430{
431 union {
432 struct { int i; int j; };
433 struct { int k; long int l; } w;
434 };
435 int m;
436} v1;
437]],
438[_AC_C_C99_TEST_BODY[
439 v1.i = 2;
440 v1.w.k = 5;
441 _Static_assert ((offsetof (struct anonymous, i)
442 == offsetof (struct anonymous, w.k)),
443 "Anonymous union alignment botch");
444]],
445dnl Try
446dnl GCC -std=gnu11 (unused restrictive mode: -std=c11)
447dnl with extended modes being tried first.
448dnl
449dnl Do not try -qlanglvl=extc1x, because IBM XL C V12.1 (the latest version as
450dnl of September 2012) does not pass the C11 test. For now, try extc1x when
451dnl compiling the C99 test instead, since it enables _Static_assert and
452dnl _Noreturn, which is a win. If -qlanglvl=extc11 or -qlanglvl=extc1x passes
453dnl the C11 test in some future version of IBM XL C, we'll add it here,
454dnl preferably extc11.
455[[-std=gnu11]], [$1], [$2])[]dnl
456])# _AC_PROG_CC_C11
457
458
459# AC_PROG_CC_C89
460# --------------
461# Do not use AU_ALIAS here and in AC_PROG_CC_C99 and AC_PROG_CC_STDC,
462# as that'd be incompatible with how Automake redefines AC_PROG_CC. See
463# <https://lists.gnu.org/r/autoconf/2012-10/msg00048.html>.
464AU_DEFUN([AC_PROG_CC_C89],
465 [AC_REQUIRE([AC_PROG_CC])],
466 [$0 is obsolete; use AC_PROG_CC]
467)
468
469# AC_PROG_CC_C99
470# --------------
471AU_DEFUN([AC_PROG_CC_C99],
472 [AC_REQUIRE([AC_PROG_CC])],
473 [$0 is obsolete; use AC_PROG_CC]
474)
475
476# AC_PROG_CC_STDC
477# ---------------
478AU_DEFUN([AC_PROG_CC_STDC],
479 [AC_REQUIRE([AC_PROG_CC])],
480 [$0 is obsolete; use AC_PROG_CC]
481)
482
483
484# AC_C_PROTOTYPES
485# ---------------
486# Check if the C compiler supports prototypes, included if it needs
487# options.
488AC_DEFUN([AC_C_PROTOTYPES],
489[AC_REQUIRE([AC_PROG_CC])dnl
490if test "$ac_prog_cc_stdc" != no; then
491 AC_DEFINE(PROTOTYPES, 1,
492 [Define to 1 if the C compiler supports function prototypes.])
493 AC_DEFINE(__PROTOTYPES, 1,
494 [Define like PROTOTYPES; this can be used by system headers.])
495fi
496])# AC_C_PROTOTYPES
497
498
499# _AC_CXX_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
500# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
501# ----------------------------------------------------------------
502# Check whether the C++ compiler accepts features of STANDARD (e.g
503# `cxx98', `cxx11') by trying to compile a program of TEST-PROLOGUE
504# and TEST-BODY. If this fails, try again with each compiler option
505# in the space-separated OPTION-LIST; if one helps, append it to CXX.
506# If eventually successful, run ACTION-IF-AVAILABLE, else
507# ACTION-IF-UNAVAILABLE.
508AC_DEFUN([_AC_CXX_STD_TRY],
509[AC_MSG_CHECKING([for $CXX option to enable ]m4_translit(m4_translit($1, [x], [+]), [a-z], [A-Z])[ features])
510AC_LANG_PUSH(C++)dnl
511AC_CACHE_VAL(ac_cv_prog_cxx_$1,
512[ac_cv_prog_cxx_$1=no
513ac_save_CXX=$CXX
514AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
515for ac_arg in '' $4
516do
517 CXX="$ac_save_CXX $ac_arg"
518 _AC_COMPILE_IFELSE([], [ac_cv_prog_cxx_$1=$ac_arg])
519 test "x$ac_cv_prog_cxx_$1" != "xno" && break
520done
521rm -f conftest.$ac_ext
522CXX=$ac_save_CXX
523])# AC_CACHE_VAL
524ac_prog_cxx_stdcxx_options=
525case "x$ac_cv_prog_cxx_$1" in
526 x)
527 AC_MSG_RESULT([none needed]) ;;
528 xno)
529 AC_MSG_RESULT([unsupported]) ;;
530 *)
531 ac_prog_cxx_stdcxx_options=" $ac_cv_prog_cxx_$1"
532 CXX=$CXX$ac_prog_cxx_stdcxx_options
533 AC_MSG_RESULT([$ac_cv_prog_cxx_$1]) ;;
534esac
535AC_LANG_POP(C++)dnl
536AS_IF([test "x$ac_cv_prog_cxx_$1" != xno], [$5], [$6])
537])# _AC_CXX_STD_TRY
538
539# _AC_CXX_CXX98_TEST_HEADER
540# -------------------------
541# A C++ header suitable for testing for CXX98.
542AC_DEFUN([_AC_CXX_CXX98_TEST_HEADER],
543[[
544#include <algorithm>
545#include <cstdlib>
546#include <fstream>
547#include <iomanip>
548#include <iostream>
549#include <list>
550#include <map>
551#include <set>
552#include <sstream>
553#include <stdexcept>
554#include <string>
555#include <utility>
556#include <vector>
557
558namespace test {
559 typedef std::vector<std::string> string_vec;
560 typedef std::pair<int,bool> map_value;
561 typedef std::map<std::string,map_value> map_type;
562 typedef std::set<int> set_type;
563
564 template<typename T>
565 class printer {
566 public:
567 printer(std::ostringstream& os): os(os) {}
568 void operator() (T elem) { os << elem << std::endl; }
569 private:
570 std::ostringstream& os;
571 };
572}
573]])# _AC_CXX_CXX98_TEST_HEADER
574
575# _AC_CXX_CXX98_TEST_BODY
576# -----------------------
577# A C++ body suitable for testing for CXX98, assuming the corresponding header.
578AC_DEFUN([_AC_CXX_CXX98_TEST_BODY],
579[[
580
581try {
582 // Basic string.
583 std::string teststr("ASCII text");
584 teststr += " string";
585
586 // Simple vector.
587 test::string_vec testvec;
588 testvec.push_back(teststr);
589 testvec.push_back("foo");
590 testvec.push_back("bar");
591 if (testvec.size() != 3) {
592 throw std::runtime_error("vector size is not 1");
593 }
594
595 // Dump vector into stringstream and obtain string.
596 std::ostringstream os;
597 for (test::string_vec::const_iterator i = testvec.begin();
598 i != testvec.end(); ++i) {
599 if (i + 1 != testvec.end()) {
600 os << teststr << '\n';
601 }
602 }
603 // Check algorithms work.
604 std::for_each(testvec.begin(), testvec.end(), test::printer<std::string>(os));
605 std::string os_out = os.str();
606
607 // Test pair and map.
608 test::map_type testmap;
609 testmap.insert(std::make_pair(std::string("key"),
610 std::make_pair(53,false)));
611
612 // Test set.
613 int values[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
614 test::set_type testset(values, values + sizeof(values)/sizeof(values[0]));
615 std::list<int> testlist(testset.begin(), testset.end());
616 std::copy(testset.begin(), testset.end(), std::back_inserter(testlist));
617} catch (const std::exception& e) {
618 std::cerr << "Caught exception: " << e.what() << std::endl;
619
620 // Test fstream
621 std::ofstream of("test.txt");
622 of << "Test ASCII text\n" << std::flush;
623 of << "N= " << std::hex << std::setw(8) << std::left << 534 << std::endl;
624 of.close();
625}
626std::exit(0);
627]])
628
629# _AC_CXX_CXX11_TEST_HEADER
630# -------------------------
631# A C++ header suitable for testing for CXX11.
632AC_DEFUN([_AC_CXX_CXX11_TEST_HEADER],
633[[
634#include <deque>
635#include <functional>
636#include <memory>
637#include <tuple>
638#include <array>
639#include <regex>
640#include <iostream>
641
642namespace cxx11test
643{
644 typedef std::shared_ptr<std::string> sptr;
645 typedef std::weak_ptr<std::string> wptr;
646
647 typedef std::tuple<std::string,int,double> tp;
648 typedef std::array<int, 20> int_array;
649
650 constexpr int get_val() { return 20; }
651
652 struct testinit
653 {
654 int i;
655 double d;
656 };
657
658 class delegate {
659 public:
660 delegate(int n) : n(n) {}
661 delegate(): delegate(2354) {}
662
663 virtual int getval() { return this->n; };
664 protected:
665 int n;
666 };
667
668 class overridden : public delegate {
669 public:
670 overridden(int n): delegate(n) {}
671 virtual int getval() override final { return this->n * 2; }
672 };
673
674 class nocopy {
675 public:
676 nocopy(int i): i(i) {}
677 nocopy() = default;
678 nocopy(const nocopy&) = delete;
679 nocopy & operator=(const nocopy&) = delete;
680 private:
681 int i;
682 };
683}
684]])# _AC_CXX_CXX11_TEST_HEADER
685
686# _AC_CXX_CXX11_TEST_BODY
687# -----------------------
688# A C++ body suitable for testing for CXX11, assuming the corresponding header.
689AC_DEFUN([_AC_CXX_CXX11_TEST_BODY],
690[[
691{
692 // Test auto and decltype
693 std::deque<int> d;
694 d.push_front(43);
695 d.push_front(484);
696 d.push_front(3);
697 d.push_front(844);
698 int total = 0;
699 for (auto i = d.begin(); i != d.end(); ++i) { total += *i; }
700
701 auto a1 = 6538;
702 auto a2 = 48573953.4;
703 auto a3 = "String literal";
704
705 decltype(a2) a4 = 34895.034;
706}
707{
708 // Test constexpr
709 short sa[cxx11test::get_val()] = { 0 };
710}
711{
712 // Test initializer lists
713 cxx11test::testinit il = { 4323, 435234.23544 };
714}
715{
716 // Test range-based for and lambda
717 cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
718 for (int &x : array) { x += 23; }
719 std::for_each(array.begin(), array.end(), [](int v1){ std::cout << v1; });
720}
721{
722 using cxx11test::sptr;
723 using cxx11test::wptr;
724
725 sptr sp(new std::string("ASCII string"));
726 wptr wp(sp);
727 sptr sp2(wp);
728}
729{
730 cxx11test::tp tuple("test", 54, 45.53434);
731 double d = std::get<2>(tuple);
732 std::string s;
733 int i;
734 std::tie(s,i,d) = tuple;
735}
736{
737 static std::regex filename_regex("^_?([a-z0-9_.]+-)+[a-z0-9]+$");
738 std::string testmatch("Test if this string matches");
739 bool match = std::regex_search(testmatch, filename_regex);
740}
741{
742 cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
743 cxx11test::int_array::size_type size = array.size();
744}
745{
746 // Test constructor delegation
747 cxx11test::delegate d1;
748 cxx11test::delegate d2();
749 cxx11test::delegate d3(45);
750}
751{
752 // Test override and final
753 cxx11test::overridden o1(55464);
754}
755{
756 // Test nullptr
757 char *c = nullptr;
758}
759{
760 // Test template brackets
761 std::vector<std::pair<int,char*>> v1;
762}
763{
764 // Unicode literals
765 char const *utf8 = u8"UTF-8 string \u2500";
766 char16_t const *utf16 = u"UTF-8 string \u2500";
767 char32_t const *utf32 = U"UTF-32 string \u2500";
768}
769]])
770
771# _AC_PROG_CXX_CXX98 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
772# -------------------------------------------------------------------
773
774# If the C++ compiler is not in ISO C++98 mode by default, try to add
775# an option to output variable CXX to make it so. This macro tries
776# various options that select ISO C++98 on some system or another. It
777# considers the compiler to be in ISO C++98 mode if it handles basic
778# features of the std namespace including: string, containers (list,
779# map, set, vector), streams (fstreams, iostreams, stringstreams,
780# iomanip), pair, exceptions and algorithms.
781
782
783AC_DEFUN([_AC_PROG_CXX_CXX98],
784[_AC_CXX_STD_TRY([cxx98],
785[_AC_CXX_CXX98_TEST_HEADER],
786[_AC_CXX_CXX98_TEST_BODY],
787dnl Try
788dnl GCC -std=gnu++98 (unused restrictive mode: -std=c++98)
789dnl IBM XL C -qlanglvl=extended
790dnl HP aC++ -AA
791dnl Intel ICC -std=gnu++98
792dnl Solaris N/A (default)
793dnl Tru64 N/A (default, but -std gnu could be used)
794dnl with extended modes being tried first.
795[[-std=gnu++98 -std=c++98 -qlanglvl=extended -AA]], [$1], [$2])[]dnl
796])# _AC_PROG_CXX_CXX98
797
798# _AC_PROG_CXX_CXX11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
799# -------------------------------------------------------------------
800# If the C++ compiler is not in ISO CXX11 mode by default, try to add
801# an option to output variable CXX to make it so. This macro tries
802# various options that select ISO C++11 on some system or another. It
803# considers the compiler to be in ISO C++11 mode if it handles all the
804# tests from the C++98 checks, plus the following: Language features
805# (auto, constexpr, decltype, default/deleted constructors, delegate
806# constructors, final, initializer lists, lambda functions, nullptr,
807# override, range-based for loops, template brackets without spaces,
808# unicode literals) and library features (array, memory (shared_ptr,
809# weak_ptr), regex and tuple types).
810AC_DEFUN([_AC_PROG_CXX_CXX11],
811[_AC_CXX_STD_TRY([cxx11],
812[_AC_CXX_CXX11_TEST_HEADER
813_AC_CXX_CXX98_TEST_HEADER],
814[_AC_CXX_CXX11_TEST_BODY
815_AC_CXX_CXX98_TEST_BODY],
816dnl Try
817dnl GCC -std=gnu++11 (unused restrictive mode: -std=c++11) [and 0x variants]
818dnl IBM XL C -qlanglvl=extended0x
819dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdcxx11)
820dnl HP aC++ -AA
821dnl Intel ICC -std=c++11 -std=c++0x
822dnl Solaris N/A (no support)
823dnl Tru64 N/A (no support)
824dnl with extended modes being tried first.
825[[-std=gnu++11 -std=c++11 -std=gnu++0x -std=c++0x -qlanglvl=extended0x -AA]], [$1], [$2])[]dnl
826])# _AC_PROG_CXX_CXX11
827
828
829])# m4_version_prereq
diff --git a/gl/m4/stdalign.m4 b/gl/m4/stdalign.m4
index 20be01aa..dc297175 100644
--- a/gl/m4/stdalign.m4
+++ b/gl/m4/stdalign.m4
@@ -1,6 +1,6 @@
1# Check for stdalign.h that conforms to C11. 1# Check for alignas and alignof that conform to C23.
2 2
3dnl Copyright 2011-2013 Free Software Foundation, Inc. 3dnl Copyright 2011-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
@@ -9,16 +9,23 @@ dnl with or without modifications, as long as this notice is preserved.
9 9
10AC_DEFUN([gl_STDALIGN_H], 10AC_DEFUN([gl_STDALIGN_H],
11[ 11[
12 AC_CACHE_CHECK([for working stdalign.h], 12 AC_CACHE_CHECK([for alignas and alignof],
13 [gl_cv_header_working_stdalign_h], 13 [gl_cv_header_working_stdalign_h],
14 [AC_COMPILE_IFELSE( 14 [gl_save_CFLAGS=$CFLAGS
15 for gl_working in "yes, keywords" "yes, <stdalign.h> macros"; do
16 AS_CASE([$gl_working],
17 [*stdalign.h*], [CFLAGS="$gl_save_CFLAGS -DINCLUDE_STDALIGN_H"])
18 AC_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM( 19 [AC_LANG_PROGRAM(
16 [[#include <stdalign.h> 20 [[#include <stdint.h>
21 #ifdef INCLUDE_STDALIGN_H
22 #include <stdalign.h>
23 #endif
17 #include <stddef.h> 24 #include <stddef.h>
18 25
19 /* Test that alignof yields a result consistent with offsetof. 26 /* Test that alignof yields a result consistent with offsetof.
20 This catches GCC bug 52023 27 This catches GCC bug 52023
21 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */ 28 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */
22 #ifdef __cplusplus 29 #ifdef __cplusplus
23 template <class t> struct alignof_helper { char a; t b; }; 30 template <class t> struct alignof_helper { char a; t b; };
24 # define ao(type) offsetof (alignof_helper<type>, b) 31 # define ao(type) offsetof (alignof_helper<type>, b)
@@ -29,25 +36,103 @@ AC_DEFUN([gl_STDALIGN_H],
29 char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1]; 36 char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1];
30 char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1]; 37 char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1];
31 38
32 /* Test _Alignas only on platforms where gnulib can help. */ 39 /* Test alignas only on platforms where gnulib can help. */
33 #if \ 40 #if \
34 ((defined __cplusplus && 201103 <= __cplusplus) \ 41 ((defined __cplusplus && 201103 <= __cplusplus) \
35 || __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC \ 42 || (__TINYC__ && defined __attribute__) \
36 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER) 43 || (defined __APPLE__ && defined __MACH__ \
44 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
45 : __GNUC__) \
46 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
47 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__ \
48 || 1300 <= _MSC_VER)
37 struct alignas_test { char c; char alignas (8) alignas_8; }; 49 struct alignas_test { char c; char alignas (8) alignas_8; };
38 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8 50 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8
39 ? 1 : -1]; 51 ? 1 : -1];
40 #endif 52 #endif
41 ]])], 53 ]])],
42 [gl_cv_header_working_stdalign_h=yes], 54 [gl_cv_header_working_stdalign_h=$gl_working],
43 [gl_cv_header_working_stdalign_h=no])]) 55 [gl_cv_header_working_stdalign_h=no])
56
57 CFLAGS=$gl_save_CFLAGS
58 test "$gl_cv_header_working_stdalign_h" != no && break
59 done])
60
61 GL_GENERATE_STDALIGN_H=false
62 AS_CASE([$gl_cv_header_working_stdalign_h],
63 [no],
64 [GL_GENERATE_STDALIGN_H=true],
65 [yes*keyword*],
66 [AC_DEFINE([HAVE_C_ALIGNASOF], [1],
67 [Define to 1 if the alignas and alignof keywords work.])])
44 68
45 if test $gl_cv_header_working_stdalign_h = yes; then 69 AC_CHECK_HEADERS_ONCE([stdalign.h])
46 STDALIGN_H=''
47 else
48 STDALIGN_H='stdalign.h'
49 fi
50 70
51 AC_SUBST([STDALIGN_H]) 71 dnl The "zz" puts this toward config.h's end, to avoid potential
52 AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"]) 72 dnl collisions with other definitions.
73 AH_VERBATIM([zzalignas],
74[#if !defined HAVE_C_ALIGNASOF && __cplusplus < 201103 && !defined alignof
75# if HAVE_STDALIGN_H
76# include <stdalign.h>
77# else
78 /* Substitute. Keep consistent with gnulib/lib/stdalign.in.h. */
79# ifndef _GL_STDALIGN_H
80# define _GL_STDALIGN_H
81# undef _Alignas
82# undef _Alignof
83# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
84 || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
85 && !defined __clang__) \
86 || (defined __clang__ && __clang_major__ < 8))
87# ifdef __cplusplus
88# if (201103 <= __cplusplus || defined _MSC_VER)
89# define _Alignof(type) alignof (type)
90# else
91 template <class __t> struct __alignof_helper { char __a; __t __b; };
92# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
93# define _GL_STDALIGN_NEEDS_STDDEF 1
94# endif
95# else
96# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__
97# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b)
98# else
99# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
100# define _GL_STDALIGN_NEEDS_STDDEF 1
101# endif
102# endif
103# endif
104# if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))
105# define alignof _Alignof
106# endif
107# define __alignof_is_defined 1
108# if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
109# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)
110# define _Alignas(a) alignas (a)
111# elif (!defined __attribute__ \
112 && ((defined __APPLE__ && defined __MACH__ \
113 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
114 : __GNUC__ && !defined __ibmxl__) \
115 || (4 <= __clang_major__) \
116 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
117 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__))
118# define _Alignas(a) __attribute__ ((__aligned__ (a)))
119# elif 1300 <= _MSC_VER
120# define _Alignas(a) __declspec (align (a))
121# endif
122# endif
123# if ((defined _Alignas \
124 && !(defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) \
125 || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
126# define alignas _Alignas
127# endif
128# if (defined alignas \
129 || (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)))
130# define __alignas_is_defined 1
131# endif
132# if _GL_STDALIGN_NEEDS_STDDEF
133# include <stddef.h>
134# endif
135# endif /* _GL_STDALIGN_H */
136# endif
137#endif])
53]) 138])
diff --git a/gl/m4/stdbool.m4 b/gl/m4/stdbool.m4
deleted file mode 100644
index 80d5559a..00000000
--- a/gl/m4/stdbool.m4
+++ /dev/null
@@ -1,100 +0,0 @@
1# Check for stdbool.h that conforms to C99.
2
3dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8#serial 5
9
10# Prepare for substituting <stdbool.h> if it is not supported.
11
12AC_DEFUN([AM_STDBOOL_H],
13[
14 AC_REQUIRE([AC_CHECK_HEADER_STDBOOL])
15
16 # Define two additional variables used in the Makefile substitution.
17
18 if test "$ac_cv_header_stdbool_h" = yes; then
19 STDBOOL_H=''
20 else
21 STDBOOL_H='stdbool.h'
22 fi
23 AC_SUBST([STDBOOL_H])
24 AM_CONDITIONAL([GL_GENERATE_STDBOOL_H], [test -n "$STDBOOL_H"])
25
26 if test "$ac_cv_type__Bool" = yes; then
27 HAVE__BOOL=1
28 else
29 HAVE__BOOL=0
30 fi
31 AC_SUBST([HAVE__BOOL])
32])
33
34# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
35AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
36
37# This version of the macro is needed in autoconf <= 2.68.
38
39AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
40 [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
41 [ac_cv_header_stdbool_h],
42 [AC_COMPILE_IFELSE(
43 [AC_LANG_PROGRAM(
44 [[
45 #include <stdbool.h>
46 #ifndef bool
47 "error: bool is not defined"
48 #endif
49 #ifndef false
50 "error: false is not defined"
51 #endif
52 #if false
53 "error: false is not 0"
54 #endif
55 #ifndef true
56 "error: true is not defined"
57 #endif
58 #if true != 1
59 "error: true is not 1"
60 #endif
61 #ifndef __bool_true_false_are_defined
62 "error: __bool_true_false_are_defined is not defined"
63 #endif
64
65 struct s { _Bool s: 1; _Bool t; } s;
66
67 char a[true == 1 ? 1 : -1];
68 char b[false == 0 ? 1 : -1];
69 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
70 char d[(bool) 0.5 == true ? 1 : -1];
71 /* See body of main program for 'e'. */
72 char f[(_Bool) 0.0 == false ? 1 : -1];
73 char g[true];
74 char h[sizeof (_Bool)];
75 char i[sizeof s.t];
76 enum { j = false, k = true, l = false * true, m = true * 256 };
77 /* The following fails for
78 HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
79 _Bool n[m];
80 char o[sizeof n == m * sizeof n[0] ? 1 : -1];
81 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
82 /* Catch a bug in an HP-UX C compiler. See
83 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
84 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
85 */
86 _Bool q = true;
87 _Bool *pq = &q;
88 ]],
89 [[
90 bool e = &s;
91 *pq |= q;
92 *pq |= ! q;
93 /* Refer to every declared value, to avoid compiler optimizations. */
94 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
95 + !m + !n + !o + !p + !q + !pq);
96 ]])],
97 [ac_cv_header_stdbool_h=yes],
98 [ac_cv_header_stdbool_h=no])])
99 AC_CHECK_TYPES([_Bool])
100])
diff --git a/gl/m4/stddef_h.m4 b/gl/m4/stddef_h.m4
index 5da8ab1e..a2322ebb 100644
--- a/gl/m4/stddef_h.m4
+++ b/gl/m4/stddef_h.m4
@@ -1,19 +1,61 @@
1dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have issues. 1# stddef_h.m4 serial 13
2# stddef_h.m4 serial 4 2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl Copyright (C) 2009-2013 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
7 6
8AC_DEFUN([gl_STDDEF_H], 7dnl A placeholder for <stddef.h>, for platforms that have issues.
8
9AC_DEFUN_ONCE([gl_STDDEF_H],
9[ 10[
10 AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) 11 AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
11 AC_REQUIRE([gt_TYPE_WCHAR_T]) 12 AC_REQUIRE([gt_TYPE_WCHAR_T])
12 STDDEF_H= 13
14 dnl Persuade OpenBSD <stddef.h> to declare max_align_t.
15 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16
17 GL_GENERATE_STDDEF_H=false
18
19 dnl Test whether the type max_align_t exists and whether its alignment
20 dnl "is as great as is supported by the implementation in all contexts".
21 AC_CACHE_CHECK([for good max_align_t],
22 [gl_cv_type_max_align_t],
23 [AC_COMPILE_IFELSE(
24 [AC_LANG_PROGRAM(
25 [[/* On FreeBSD 12.0/x86, max_align_t defined by <stddef.h> has
26 the correct alignment with the default (wrong) definition of
27 _Alignof, but a wrong alignment as soon as we activate an
28 ISO C compliant _Alignof definition. */
29 #if ((defined __GNUC__ && 4 <= __GNUC__) || defined __clang__) && !defined __cplusplus
30 #define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b)
31 #endif
32 #include <stddef.h>
33 unsigned int s = sizeof (max_align_t);
34 #if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__
35 int check1[2 * (__alignof__ (double) <= __alignof__ (max_align_t)) - 1];
36 int check2[2 * (__alignof__ (long double) <= __alignof__ (max_align_t)) - 1];
37 #endif
38 typedef struct { char a; max_align_t b; } max_helper;
39 typedef struct { char a; long b; } long_helper;
40 typedef struct { char a; double b; } double_helper;
41 typedef struct { char a; long double b; } long_double_helper;
42 int check3[2 * (offsetof (long_helper, b) <= offsetof (max_helper, b)) - 1];
43 int check4[2 * (offsetof (double_helper, b) <= offsetof (max_helper, b)) - 1];
44 int check5[2 * (offsetof (long_double_helper, b) <= offsetof (max_helper, b)) - 1];
45 ]])],
46 [gl_cv_type_max_align_t=yes],
47 [gl_cv_type_max_align_t=no])
48 ])
49 if test $gl_cv_type_max_align_t = no; then
50 HAVE_MAX_ALIGN_T=0
51 GL_GENERATE_STDDEF_H=true
52 fi
53
13 if test $gt_cv_c_wchar_t = no; then 54 if test $gt_cv_c_wchar_t = no; then
14 HAVE_WCHAR_T=0 55 HAVE_WCHAR_T=0
15 STDDEF_H=stddef.h 56 GL_GENERATE_STDDEF_H=true
16 fi 57 fi
58
17 AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions], 59 AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions],
18 [gl_cv_decl_null_works], 60 [gl_cv_decl_null_works],
19 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h> 61 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
@@ -23,25 +65,40 @@ AC_DEFUN([gl_STDDEF_H],
23 [gl_cv_decl_null_works=no])]) 65 [gl_cv_decl_null_works=no])])
24 if test $gl_cv_decl_null_works = no; then 66 if test $gl_cv_decl_null_works = no; then
25 REPLACE_NULL=1 67 REPLACE_NULL=1
26 STDDEF_H=stddef.h 68 GL_GENERATE_STDDEF_H=true
27 fi 69 fi
28 AC_SUBST([STDDEF_H]) 70
29 AM_CONDITIONAL([GL_GENERATE_STDDEF_H], [test -n "$STDDEF_H"]) 71 if $GL_GENERATE_STDDEF_H; then
30 if test -n "$STDDEF_H"; then
31 gl_NEXT_HEADERS([stddef.h]) 72 gl_NEXT_HEADERS([stddef.h])
32 fi 73 fi
33]) 74])
34 75
76# gl_STDDEF_MODULE_INDICATOR([modulename])
77# sets the shell variable that indicates the presence of the given module
78# to a C preprocessor expression that will evaluate to 1.
79# This macro invocation must not occur in macros that are AC_REQUIREd.
35AC_DEFUN([gl_STDDEF_MODULE_INDICATOR], 80AC_DEFUN([gl_STDDEF_MODULE_INDICATOR],
36[ 81[
37 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 82 dnl Ensure to expand the default settings once only.
38 AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) 83 gl_STDDEF_H_REQUIRE_DEFAULTS
39 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 84 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
40]) 85])
41 86
87# Initializes the default values for AC_SUBSTed shell variables.
88# This macro must not be AC_REQUIREd. It must only be invoked, and only
89# outside of macros or in macros that are not AC_REQUIREd.
90AC_DEFUN([gl_STDDEF_H_REQUIRE_DEFAULTS],
91[
92 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDDEF_H_MODULE_INDICATOR_DEFAULTS], [
93 ])
94 m4_require(GL_MODULE_INDICATOR_PREFIX[_STDDEF_H_MODULE_INDICATOR_DEFAULTS])
95 AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
96])
97
42AC_DEFUN([gl_STDDEF_H_DEFAULTS], 98AC_DEFUN([gl_STDDEF_H_DEFAULTS],
43[ 99[
44 dnl Assume proper GNU behavior unless another module says otherwise. 100 dnl Assume proper GNU behavior unless another module says otherwise.
45 REPLACE_NULL=0; AC_SUBST([REPLACE_NULL]) 101 REPLACE_NULL=0; AC_SUBST([REPLACE_NULL])
102 HAVE_MAX_ALIGN_T=1; AC_SUBST([HAVE_MAX_ALIGN_T])
46 HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T]) 103 HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T])
47]) 104])
diff --git a/gl/m4/stdint.m4 b/gl/m4/stdint.m4
index 27cdcdb9..d6961b09 100644
--- a/gl/m4/stdint.m4
+++ b/gl/m4/stdint.m4
@@ -1,5 +1,5 @@
1# stdint.m4 serial 43 1# stdint.m4 serial 61
2dnl Copyright (C) 2001-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,25 +7,22 @@ dnl with or without modifications, as long as this notice is preserved.
7dnl From Paul Eggert and Bruno Haible. 7dnl From Paul Eggert and Bruno Haible.
8dnl Test whether <stdint.h> is supported or must be substituted. 8dnl Test whether <stdint.h> is supported or must be substituted.
9 9
10AC_PREREQ([2.61])
11
10AC_DEFUN_ONCE([gl_STDINT_H], 12AC_DEFUN_ONCE([gl_STDINT_H],
11[ 13[
12 AC_PREREQ([2.59])dnl 14 AC_PREREQ([2.59])dnl
15 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13 16
14 dnl Check for long long int and unsigned long long int. 17 AC_REQUIRE([gl_LIMITS_H])
15 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 18 AC_REQUIRE([gt_TYPE_WINT_T])
16 if test $ac_cv_type_long_long_int = yes; then 19
17 HAVE_LONG_LONG_INT=1 20 dnl For backward compatibility. Some packages may still be testing these
18 else 21 dnl macros.
19 HAVE_LONG_LONG_INT=0 22 AC_DEFINE([HAVE_LONG_LONG_INT], [1],
20 fi 23 [Define to 1 if the system has the type 'long long int'.])
21 AC_SUBST([HAVE_LONG_LONG_INT]) 24 AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
22 AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) 25 [Define to 1 if the system has the type 'unsigned long long int'.])
23 if test $ac_cv_type_unsigned_long_long_int = yes; then
24 HAVE_UNSIGNED_LONG_LONG_INT=1
25 else
26 HAVE_UNSIGNED_LONG_LONG_INT=0
27 fi
28 AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT])
29 26
30 dnl Check for <wchar.h>, in the same way as gl_WCHAR_H does. 27 dnl Check for <wchar.h>, in the same way as gl_WCHAR_H does.
31 AC_CHECK_HEADERS_ONCE([wchar.h]) 28 AC_CHECK_HEADERS_ONCE([wchar.h])
@@ -37,7 +34,7 @@ AC_DEFUN_ONCE([gl_STDINT_H],
37 AC_SUBST([HAVE_WCHAR_H]) 34 AC_SUBST([HAVE_WCHAR_H])
38 35
39 dnl Check for <inttypes.h>. 36 dnl Check for <inttypes.h>.
40 dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h. 37 AC_CHECK_HEADERS_ONCE([inttypes.h])
41 if test $ac_cv_header_inttypes_h = yes; then 38 if test $ac_cv_header_inttypes_h = yes; then
42 HAVE_INTTYPES_H=1 39 HAVE_INTTYPES_H=1
43 else 40 else
@@ -46,7 +43,7 @@ AC_DEFUN_ONCE([gl_STDINT_H],
46 AC_SUBST([HAVE_INTTYPES_H]) 43 AC_SUBST([HAVE_INTTYPES_H])
47 44
48 dnl Check for <sys/types.h>. 45 dnl Check for <sys/types.h>.
49 dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_sys_types_h. 46 AC_CHECK_HEADERS_ONCE([sys/types.h])
50 if test $ac_cv_header_sys_types_h = yes; then 47 if test $ac_cv_header_sys_types_h = yes; then
51 HAVE_SYS_TYPES_H=1 48 HAVE_SYS_TYPES_H=1
52 else 49 else
@@ -70,6 +67,8 @@ AC_DEFUN_ONCE([gl_STDINT_H],
70 AC_COMPILE_IFELSE([ 67 AC_COMPILE_IFELSE([
71 AC_LANG_PROGRAM([[ 68 AC_LANG_PROGRAM([[
72#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ 69#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
70#define __STDC_CONSTANT_MACROS 1
71#define __STDC_LIMIT_MACROS 1
73#include <stdint.h> 72#include <stdint.h>
74/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>. */ 73/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>. */
75#if !(defined WCHAR_MIN && defined WCHAR_MAX) 74#if !(defined WCHAR_MIN && defined WCHAR_MAX)
@@ -150,6 +149,15 @@ uintptr_t h = UINTPTR_MAX;
150intmax_t i = INTMAX_MAX; 149intmax_t i = INTMAX_MAX;
151uintmax_t j = UINTMAX_MAX; 150uintmax_t j = UINTMAX_MAX;
152 151
152/* Check that SIZE_MAX has the correct type, if possible. */
153#if 201112 <= __STDC_VERSION__
154int k = _Generic (SIZE_MAX, size_t: 0);
155#elif (2 <= __GNUC__ || 4 <= __clang_major__ || defined __IBM__TYPEOF__ \
156 || (0x5110 <= __SUNPRO_C && !__STDC__))
157extern size_t k;
158extern __typeof__ (SIZE_MAX) k;
159#endif
160
153#include <limits.h> /* for CHAR_BIT */ 161#include <limits.h> /* for CHAR_BIT */
154#define TYPE_MINIMUM(t) \ 162#define TYPE_MINIMUM(t) \
155 ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t))) 163 ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t)))
@@ -162,7 +170,7 @@ struct s {
162 PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t) 170 PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t)
163 && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t) 171 && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t)
164 ? 1 : -1; 172 ? 1 : -1;
165 /* Detect bug in FreeBSD 6.0 / ia64. */ 173 /* Detect bug in FreeBSD 6.0/ia64 and FreeBSD 13.0/arm64. */
166 int check_SIG_ATOMIC: 174 int check_SIG_ATOMIC:
167 SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t) 175 SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t)
168 && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t) 176 && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t)
@@ -218,6 +226,8 @@ struct s {
218 AC_RUN_IFELSE([ 226 AC_RUN_IFELSE([
219 AC_LANG_PROGRAM([[ 227 AC_LANG_PROGRAM([[
220#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ 228#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
229#define __STDC_CONSTANT_MACROS 1
230#define __STDC_LIMIT_MACROS 1
221#include <stdint.h> 231#include <stdint.h>
222] 232]
223gl_STDINT_INCLUDES 233gl_STDINT_INCLUDES
@@ -272,36 +282,88 @@ static const char *macro_values[] =
272]])], 282]])],
273 [gl_cv_header_working_stdint_h=yes], 283 [gl_cv_header_working_stdint_h=yes],
274 [], 284 [],
275 [dnl When cross-compiling, assume it works. 285 [case "$host_os" in
276 gl_cv_header_working_stdint_h=yes 286 # Guess yes on native Windows.
287 mingw*) gl_cv_header_working_stdint_h="guessing yes" ;;
288 # In general, assume it works.
289 *) gl_cv_header_working_stdint_h="guessing yes" ;;
290 esac
277 ]) 291 ])
278 ]) 292 ])
279 ]) 293 ])
280 fi 294 fi
281 if test "$gl_cv_header_working_stdint_h" = yes; then
282 STDINT_H=
283 else
284 dnl Check for <sys/inttypes.h>, and for
285 dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
286 AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
287 if test $ac_cv_header_sys_inttypes_h = yes; then
288 HAVE_SYS_INTTYPES_H=1
289 else
290 HAVE_SYS_INTTYPES_H=0
291 fi
292 AC_SUBST([HAVE_SYS_INTTYPES_H])
293 if test $ac_cv_header_sys_bitypes_h = yes; then
294 HAVE_SYS_BITYPES_H=1
295 else
296 HAVE_SYS_BITYPES_H=0
297 fi
298 AC_SUBST([HAVE_SYS_BITYPES_H])
299 295
300 gl_STDINT_TYPE_PROPERTIES 296 HAVE_C99_STDINT_H=0
301 STDINT_H=stdint.h 297 HAVE_SYS_BITYPES_H=0
302 fi 298 HAVE_SYS_INTTYPES_H=0
303 AC_SUBST([STDINT_H]) 299 GL_GENERATE_STDINT_H=true
304 AM_CONDITIONAL([GL_GENERATE_STDINT_H], [test -n "$STDINT_H"]) 300 case "$gl_cv_header_working_stdint_h" in
301 *yes)
302 HAVE_C99_STDINT_H=1
303 dnl Now see whether the system <stdint.h> works without
304 dnl __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined.
305 dnl If not, there would be problems when stdint.h is included from C++.
306 AC_CACHE_CHECK([whether stdint.h works without ISO C predefines],
307 [gl_cv_header_stdint_without_STDC_macros],
308 [gl_cv_header_stdint_without_STDC_macros=no
309 AC_COMPILE_IFELSE([
310 AC_LANG_PROGRAM([[
311#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
312#include <stdint.h>
313]
314gl_STDINT_INCLUDES
315[
316intmax_t im = INTMAX_MAX;
317int32_t i32 = INT32_C (0x7fffffff);
318 ]])],
319 [gl_cv_header_stdint_without_STDC_macros=yes])
320 ])
321
322 if test $gl_cv_header_stdint_without_STDC_macros = no; then
323 AC_DEFINE([__STDC_CONSTANT_MACROS], [1],
324 [Define to 1 if the system <stdint.h> predates C++11.])
325 AC_DEFINE([__STDC_LIMIT_MACROS], [1],
326 [Define to 1 if the system <stdint.h> predates C++11.])
327 fi
328 AC_CACHE_CHECK([whether stdint.h has UINTMAX_WIDTH etc.],
329 [gl_cv_header_stdint_width],
330 [gl_cv_header_stdint_width=no
331 AC_COMPILE_IFELSE(
332 [AC_LANG_PROGRAM([[
333 /* Work if build is not clean. */
334 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1
335 #ifndef __STDC_WANT_IEC_60559_BFP_EXT__
336 #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
337 #endif
338 #include <stdint.h>
339 ]gl_STDINT_INCLUDES[
340 int iw = UINTMAX_WIDTH;
341 ]])],
342 [gl_cv_header_stdint_width=yes])])
343 if test "$gl_cv_header_stdint_width" = yes; then
344 GL_GENERATE_STDINT_H=false
345 fi
346 ;;
347 *)
348 dnl Check for <sys/inttypes.h>, and for
349 dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
350 AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
351 if test $ac_cv_header_sys_inttypes_h = yes; then
352 HAVE_SYS_INTTYPES_H=1
353 fi
354 if test $ac_cv_header_sys_bitypes_h = yes; then
355 HAVE_SYS_BITYPES_H=1
356 fi
357 gl_STDINT_TYPE_PROPERTIES
358 ;;
359 esac
360
361 dnl The substitute stdint.h needs the substitute limit.h's _GL_INTEGER_WIDTH.
362 gl_REPLACE_LIMITS_H
363
364 AC_SUBST([HAVE_C99_STDINT_H])
365 AC_SUBST([HAVE_SYS_BITYPES_H])
366 AC_SUBST([HAVE_SYS_INTTYPES_H])
305]) 367])
306 368
307dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES) 369dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
@@ -429,13 +491,9 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
429dnl gl_STDINT_INCLUDES 491dnl gl_STDINT_INCLUDES
430AC_DEFUN([gl_STDINT_INCLUDES], 492AC_DEFUN([gl_STDINT_INCLUDES],
431[[ 493[[
432 /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
433 included before <wchar.h>. */
434 #include <stddef.h> 494 #include <stddef.h>
435 #include <signal.h> 495 #include <signal.h>
436 #if HAVE_WCHAR_H 496 #if HAVE_WCHAR_H
437 # include <stdio.h>
438 # include <time.h>
439 # include <wchar.h> 497 # include <wchar.h>
440 #endif 498 #endif
441]]) 499]])
@@ -467,18 +525,7 @@ AC_DEFUN([gl_STDINT_TYPE_PROPERTIES],
467 dnl requirement that wint_t is "unchanged by default argument promotions". 525 dnl requirement that wint_t is "unchanged by default argument promotions".
468 dnl In this case gnulib's <wchar.h> and <wctype.h> override wint_t. 526 dnl In this case gnulib's <wchar.h> and <wctype.h> override wint_t.
469 dnl Set the variable BITSIZEOF_WINT_T accordingly. 527 dnl Set the variable BITSIZEOF_WINT_T accordingly.
470 if test $BITSIZEOF_WINT_T -lt 32; then 528 if test $GNULIBHEADERS_OVERRIDE_WINT_T = 1; then
471 BITSIZEOF_WINT_T=32 529 BITSIZEOF_WINT_T=32
472 fi 530 fi
473]) 531])
474
475dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
476dnl Remove this when we can assume autoconf >= 2.61.
477m4_ifdef([AC_COMPUTE_INT], [], [
478 AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
479])
480
481# Hey Emacs!
482# Local Variables:
483# indent-tabs-mode: nil
484# End:
diff --git a/gl/m4/stdint_h.m4 b/gl/m4/stdint_h.m4
index 511ab4e9..70349f6c 100644
--- a/gl/m4/stdint_h.m4
+++ b/gl/m4/stdint_h.m4
@@ -1,5 +1,5 @@
1# stdint_h.m4 serial 9 1# stdint_h.m4 serial 9
2dnl Copyright (C) 1997-2004, 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 1997-2004, 2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4
index ebade067..94271e11 100644
--- a/gl/m4/stdio_h.m4
+++ b/gl/m4/stdio_h.m4
@@ -1,72 +1,71 @@
1# stdio_h.m4 serial 43 1# stdio_h.m4 serial 59
2dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_STDIO_H], 7AC_DEFUN_ONCE([gl_STDIO_H],
8[ 8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AH_VERBATIM([MINGW_ANSI_STDIO],
11[/* Use GNU style printf and scanf. */
12#ifndef __USE_MINGW_ANSI_STDIO
13# undef __USE_MINGW_ANSI_STDIO
14#endif
15])
16 AC_DEFINE([__USE_MINGW_ANSI_STDIO])
10 gl_NEXT_HEADERS([stdio.h]) 17 gl_NEXT_HEADERS([stdio.h])
11 18
12 dnl No need to create extra modules for these functions. Everyone who uses 19 dnl Determine whether __USE_MINGW_ANSI_STDIO makes printf and
13 dnl <stdio.h> likely needs them. 20 dnl inttypes.h behave like gnu instead of system; we must give our
14 GNULIB_FSCANF=1 21 dnl printf wrapper the right attribute to match.
15 gl_MODULE_INDICATOR([fscanf]) 22 AC_CACHE_CHECK([which flavor of printf attribute matches inttypes macros],
16 GNULIB_SCANF=1 23 [gl_cv_func_printf_attribute_flavor],
17 gl_MODULE_INDICATOR([scanf]) 24 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
18 GNULIB_FGETC=1 25 #define __STDC_FORMAT_MACROS 1
19 GNULIB_GETC=1 26 #include <stdio.h>
20 GNULIB_GETCHAR=1 27 #include <inttypes.h>
21 GNULIB_FGETS=1 28 /* For non-mingw systems, compilation will trivially succeed.
22 GNULIB_FREAD=1 29 For mingw, compilation will succeed for older mingw (system
23 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-read.c" 30 printf, "I64d") and fail for newer mingw (gnu printf, "lld"). */
24 dnl "expected source file, required through AC_LIBSOURCES, not found". It is 31 #if (defined _WIN32 && ! defined __CYGWIN__) && \
25 dnl also an optimization, to avoid performing a configure check whose result 32 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
26 dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING 33 extern char PRIdMAX_probe[sizeof PRIdMAX == sizeof "I64d" ? 1 : -1];
27 dnl or GNULIB_NONBLOCKING redundant. 34 #endif
35 ]])], [gl_cv_func_printf_attribute_flavor=system],
36 [gl_cv_func_printf_attribute_flavor=gnu])])
37 if test "$gl_cv_func_printf_attribute_flavor" = gnu; then
38 AC_DEFINE([GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU], [1],
39 [Define to 1 if printf and friends should be labeled with
40 attribute "__gnu_printf__" instead of "__printf__"])
41 fi
42
43 dnl This ifdef is an optimization, to avoid performing a configure check whose
44 dnl result is not used. But it does not make the test of
45 dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant.
28 m4_ifdef([gl_NONBLOCKING_IO], [ 46 m4_ifdef([gl_NONBLOCKING_IO], [
29 gl_NONBLOCKING_IO 47 gl_NONBLOCKING_IO
30 if test $gl_cv_have_nonblocking != yes; then 48 if test $gl_cv_have_nonblocking != yes; then
31 REPLACE_STDIO_READ_FUNCS=1 49 REPLACE_STDIO_READ_FUNCS=1
32 AC_LIBOBJ([stdio-read])
33 fi 50 fi
34 ]) 51 ])
35 52
36 dnl No need to create extra modules for these functions. Everyone who uses 53 dnl This ifdef is an optimization, to avoid performing a configure check whose
37 dnl <stdio.h> likely needs them. 54 dnl result is not used. But it does not make the test of
38 GNULIB_FPRINTF=1 55 dnl GNULIB_STDIO_H_SIGPIPE or GNULIB_SIGPIPE redundant.
39 GNULIB_PRINTF=1
40 GNULIB_VFPRINTF=1
41 GNULIB_VPRINTF=1
42 GNULIB_FPUTC=1
43 GNULIB_PUTC=1
44 GNULIB_PUTCHAR=1
45 GNULIB_FPUTS=1
46 GNULIB_PUTS=1
47 GNULIB_FWRITE=1
48 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
49 dnl "expected source file, required through AC_LIBSOURCES, not found". It is
50 dnl also an optimization, to avoid performing a configure check whose result
51 dnl is not used. But it does not make the test of GNULIB_STDIO_H_SIGPIPE or
52 dnl GNULIB_SIGPIPE redundant.
53 m4_ifdef([gl_SIGNAL_SIGPIPE], [ 56 m4_ifdef([gl_SIGNAL_SIGPIPE], [
54 gl_SIGNAL_SIGPIPE 57 gl_SIGNAL_SIGPIPE
55 if test $gl_cv_header_signal_h_SIGPIPE != yes; then 58 if test $gl_cv_header_signal_h_SIGPIPE != yes; then
56 REPLACE_STDIO_WRITE_FUNCS=1 59 REPLACE_STDIO_WRITE_FUNCS=1
57 AC_LIBOBJ([stdio-write])
58 fi 60 fi
59 ]) 61 ])
60 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c" 62 dnl This ifdef is an optimization, to avoid performing a configure check whose
61 dnl "expected source file, required through AC_LIBSOURCES, not found". It is 63 dnl result is not used. But it does not make the test of
62 dnl also an optimization, to avoid performing a configure check whose result 64 dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant.
63 dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING
64 dnl or GNULIB_NONBLOCKING redundant.
65 m4_ifdef([gl_NONBLOCKING_IO], [ 65 m4_ifdef([gl_NONBLOCKING_IO], [
66 gl_NONBLOCKING_IO 66 gl_NONBLOCKING_IO
67 if test $gl_cv_have_nonblocking != yes; then 67 if test $gl_cv_have_nonblocking != yes; then
68 REPLACE_STDIO_WRITE_FUNCS=1 68 REPLACE_STDIO_WRITE_FUNCS=1
69 AC_LIBOBJ([stdio-write])
70 fi 69 fi
71 ]) 70 ])
72 71
@@ -76,73 +75,104 @@ AC_DEFUN([gl_STDIO_H],
76 gl_WARN_ON_USE_PREPARE([[#include <stdio.h> 75 gl_WARN_ON_USE_PREPARE([[#include <stdio.h>
77 ]], [dprintf fpurge fseeko ftello getdelim getline gets pclose popen 76 ]], [dprintf fpurge fseeko ftello getdelim getline gets pclose popen
78 renameat snprintf tmpfile vdprintf vsnprintf]) 77 renameat snprintf tmpfile vdprintf vsnprintf])
78
79 AC_REQUIRE([AC_C_RESTRICT])
80
81 AC_CHECK_DECLS_ONCE([fcloseall])
82 if test $ac_cv_have_decl_fcloseall = no; then
83 HAVE_DECL_FCLOSEALL=0
84 fi
79]) 85])
80 86
87# gl_STDIO_MODULE_INDICATOR([modulename])
88# sets the shell variable that indicates the presence of the given module
89# to a C preprocessor expression that will evaluate to 1.
90# This macro invocation must not occur in macros that are AC_REQUIREd.
81AC_DEFUN([gl_STDIO_MODULE_INDICATOR], 91AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
82[ 92[
83 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 93 dnl Ensure to expand the default settings once only.
84 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 94 gl_STDIO_H_REQUIRE_DEFAULTS
85 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 95 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
86 dnl Define it also as a C macro, for the benefit of the unit tests. 96 dnl Define it also as a C macro, for the benefit of the unit tests.
87 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 97 gl_MODULE_INDICATOR_FOR_TESTS([$1])
88]) 98])
89 99
100# Initializes the default values for AC_SUBSTed shell variables.
101# This macro must not be AC_REQUIREd. It must only be invoked, and only
102# outside of macros or in macros that are not AC_REQUIREd.
103AC_DEFUN([gl_STDIO_H_REQUIRE_DEFAULTS],
104[
105 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDIO_H_MODULE_INDICATOR_DEFAULTS], [
106 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DPRINTF])
107 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCLOSE])
108 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDOPEN])
109 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFLUSH])
110 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETC])
111 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETS])
112 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN])
113 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN_GNU])
114 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF])
115 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF_POSIX])
116 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPURGE])
117 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPUTC])
118 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPUTS])
119 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREAD])
120 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREOPEN])
121 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSCANF])
122 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSEEK])
123 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSEEKO])
124 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELL])
125 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELLO])
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FWRITE])
127 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETC])
128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETCHAR])
129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDELIM])
130 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLINE])
131 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF])
132 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF_POSIX])
133 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PCLOSE])
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PERROR])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POPEN])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PRINTF])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PRINTF_POSIX])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTC])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTCHAR])
140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTS])
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMOVE])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RENAME])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RENAMEAT])
144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCANF])
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SNPRINTF])
146 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SPRINTF_POSIX])
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_NONBLOCKING])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_SIGPIPE])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TMPFILE])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VASPRINTF])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFSCANF])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSCANF])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VDPRINTF])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF_POSIX])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF_POSIX])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSNPRINTF])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSPRINTF_POSIX])
160 dnl Support Microsoft deprecated alias function names by default.
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FCLOSEALL], [1])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FDOPEN], [1])
163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FILENO], [1])
164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETW], [1])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_PUTW], [1])
166 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TEMPNAM], [1])
167 ])
168 m4_require(GL_MODULE_INDICATOR_PREFIX[_STDIO_H_MODULE_INDICATOR_DEFAULTS])
169 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
170])
171
90AC_DEFUN([gl_STDIO_H_DEFAULTS], 172AC_DEFUN([gl_STDIO_H_DEFAULTS],
91[ 173[
92 GNULIB_DPRINTF=0; AC_SUBST([GNULIB_DPRINTF])
93 GNULIB_FCLOSE=0; AC_SUBST([GNULIB_FCLOSE])
94 GNULIB_FDOPEN=0; AC_SUBST([GNULIB_FDOPEN])
95 GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH])
96 GNULIB_FGETC=0; AC_SUBST([GNULIB_FGETC])
97 GNULIB_FGETS=0; AC_SUBST([GNULIB_FGETS])
98 GNULIB_FOPEN=0; AC_SUBST([GNULIB_FOPEN])
99 GNULIB_FPRINTF=0; AC_SUBST([GNULIB_FPRINTF])
100 GNULIB_FPRINTF_POSIX=0; AC_SUBST([GNULIB_FPRINTF_POSIX])
101 GNULIB_FPURGE=0; AC_SUBST([GNULIB_FPURGE])
102 GNULIB_FPUTC=0; AC_SUBST([GNULIB_FPUTC])
103 GNULIB_FPUTS=0; AC_SUBST([GNULIB_FPUTS])
104 GNULIB_FREAD=0; AC_SUBST([GNULIB_FREAD])
105 GNULIB_FREOPEN=0; AC_SUBST([GNULIB_FREOPEN])
106 GNULIB_FSCANF=0; AC_SUBST([GNULIB_FSCANF])
107 GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK])
108 GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO])
109 GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL])
110 GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO])
111 GNULIB_FWRITE=0; AC_SUBST([GNULIB_FWRITE])
112 GNULIB_GETC=0; AC_SUBST([GNULIB_GETC])
113 GNULIB_GETCHAR=0; AC_SUBST([GNULIB_GETCHAR])
114 GNULIB_GETDELIM=0; AC_SUBST([GNULIB_GETDELIM])
115 GNULIB_GETLINE=0; AC_SUBST([GNULIB_GETLINE])
116 GNULIB_OBSTACK_PRINTF=0; AC_SUBST([GNULIB_OBSTACK_PRINTF])
117 GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX])
118 GNULIB_PCLOSE=0; AC_SUBST([GNULIB_PCLOSE])
119 GNULIB_PERROR=0; AC_SUBST([GNULIB_PERROR])
120 GNULIB_POPEN=0; AC_SUBST([GNULIB_POPEN])
121 GNULIB_PRINTF=0; AC_SUBST([GNULIB_PRINTF])
122 GNULIB_PRINTF_POSIX=0; AC_SUBST([GNULIB_PRINTF_POSIX])
123 GNULIB_PUTC=0; AC_SUBST([GNULIB_PUTC])
124 GNULIB_PUTCHAR=0; AC_SUBST([GNULIB_PUTCHAR])
125 GNULIB_PUTS=0; AC_SUBST([GNULIB_PUTS])
126 GNULIB_REMOVE=0; AC_SUBST([GNULIB_REMOVE])
127 GNULIB_RENAME=0; AC_SUBST([GNULIB_RENAME])
128 GNULIB_RENAMEAT=0; AC_SUBST([GNULIB_RENAMEAT])
129 GNULIB_SCANF=0; AC_SUBST([GNULIB_SCANF])
130 GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF])
131 GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX])
132 GNULIB_STDIO_H_NONBLOCKING=0; AC_SUBST([GNULIB_STDIO_H_NONBLOCKING])
133 GNULIB_STDIO_H_SIGPIPE=0; AC_SUBST([GNULIB_STDIO_H_SIGPIPE])
134 GNULIB_TMPFILE=0; AC_SUBST([GNULIB_TMPFILE])
135 GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF])
136 GNULIB_VFSCANF=0; AC_SUBST([GNULIB_VFSCANF])
137 GNULIB_VSCANF=0; AC_SUBST([GNULIB_VSCANF])
138 GNULIB_VDPRINTF=0; AC_SUBST([GNULIB_VDPRINTF])
139 GNULIB_VFPRINTF=0; AC_SUBST([GNULIB_VFPRINTF])
140 GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX])
141 GNULIB_VPRINTF=0; AC_SUBST([GNULIB_VPRINTF])
142 GNULIB_VPRINTF_POSIX=0; AC_SUBST([GNULIB_VPRINTF_POSIX])
143 GNULIB_VSNPRINTF=0; AC_SUBST([GNULIB_VSNPRINTF])
144 GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX])
145 dnl Assume proper GNU behavior unless another module says otherwise. 174 dnl Assume proper GNU behavior unless another module says otherwise.
175 HAVE_DECL_FCLOSEALL=1; AC_SUBST([HAVE_DECL_FCLOSEALL])
146 HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE]) 176 HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE])
147 HAVE_DECL_FSEEKO=1; AC_SUBST([HAVE_DECL_FSEEKO]) 177 HAVE_DECL_FSEEKO=1; AC_SUBST([HAVE_DECL_FSEEKO])
148 HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO]) 178 HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO])
@@ -164,6 +194,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
164 REPLACE_FDOPEN=0; AC_SUBST([REPLACE_FDOPEN]) 194 REPLACE_FDOPEN=0; AC_SUBST([REPLACE_FDOPEN])
165 REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH]) 195 REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH])
166 REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN]) 196 REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN])
197 REPLACE_FOPEN_FOR_FOPEN_GNU=0; AC_SUBST([REPLACE_FOPEN_FOR_FOPEN_GNU])
167 REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF]) 198 REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF])
168 REPLACE_FPURGE=0; AC_SUBST([REPLACE_FPURGE]) 199 REPLACE_FPURGE=0; AC_SUBST([REPLACE_FPURGE])
169 REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN]) 200 REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN])
diff --git a/gl/m4/stdlib_h.m4 b/gl/m4/stdlib_h.m4
index 2027ab3c..e96be22f 100644
--- a/gl/m4/stdlib_h.m4
+++ b/gl/m4/stdlib_h.m4
@@ -1,10 +1,10 @@
1# stdlib_h.m4 serial 42 1# stdlib_h.m4 serial 66
2dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_STDLIB_H], 7AC_DEFUN_ONCE([gl_STDLIB_H],
8[ 8[
9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
10 gl_NEXT_HEADERS([stdlib.h]) 10 gl_NEXT_HEADERS([stdlib.h])
@@ -14,104 +14,187 @@ AC_DEFUN([gl_STDLIB_H],
14 dnl guaranteed by C89. 14 dnl guaranteed by C89.
15 gl_WARN_ON_USE_PREPARE([[#include <stdlib.h> 15 gl_WARN_ON_USE_PREPARE([[#include <stdlib.h>
16#if HAVE_SYS_LOADAVG_H 16#if HAVE_SYS_LOADAVG_H
17/* OpenIndiana has a bug: <sys/time.h> must be included before
18 <sys/loadavg.h>. */
19# include <sys/time.h>
17# include <sys/loadavg.h> 20# include <sys/loadavg.h>
18#endif 21#endif
19#if HAVE_RANDOM_H 22#if HAVE_RANDOM_H
20# include <random.h> 23# include <random.h>
21#endif 24#endif
22 ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt 25 ]], [_Exit aligned_alloc atoll canonicalize_file_name free
23 initstate initstate_r mkdtemp mkostemp mkostemps mkstemp mkstemps 26 getloadavg getsubopt grantpt
24 posix_openpt ptsname ptsname_r random random_r realpath rpmatch 27 initstate initstate_r mbtowc mkdtemp mkostemp mkostemps mkstemp mkstemps
25 secure_getenv setenv setstate setstate_r srandom srandom_r 28 posix_memalign posix_openpt ptsname ptsname_r qsort_r
26 strtod strtoll strtoull unlockpt unsetenv]) 29 random random_r reallocarray realpath rpmatch secure_getenv setenv
30 setstate setstate_r srandom srandom_r
31 strtod strtol strtold strtoll strtoul strtoull unlockpt unsetenv])
32
33 AC_REQUIRE([AC_C_RESTRICT])
34
35 AC_CHECK_DECLS_ONCE([ecvt])
36 if test $ac_cv_have_decl_ecvt = no; then
37 HAVE_DECL_ECVT=0
38 fi
39 AC_CHECK_DECLS_ONCE([fcvt])
40 if test $ac_cv_have_decl_fcvt = no; then
41 HAVE_DECL_FCVT=0
42 fi
43 AC_CHECK_DECLS_ONCE([gcvt])
44 if test $ac_cv_have_decl_gcvt = no; then
45 HAVE_DECL_GCVT=0
46 fi
27]) 47])
28 48
49# gl_STDLIB_MODULE_INDICATOR([modulename])
50# sets the shell variable that indicates the presence of the given module
51# to a C preprocessor expression that will evaluate to 1.
52# This macro invocation must not occur in macros that are AC_REQUIREd.
29AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], 53AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
30[ 54[
31 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 55 dnl Ensure to expand the default settings once only.
32 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 56 gl_STDLIB_H_REQUIRE_DEFAULTS
33 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 57 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
34 dnl Define it also as a C macro, for the benefit of the unit tests. 58 dnl Define it also as a C macro, for the benefit of the unit tests.
35 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 59 gl_MODULE_INDICATOR_FOR_TESTS([$1])
36]) 60])
37 61
62# Initializes the default values for AC_SUBSTed shell variables.
63# This macro must not be AC_REQUIREd. It must only be invoked, and only
64# outside of macros or in macros that are not AC_REQUIREd.
65AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS],
66[
67 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS], [
68 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB__EXIT])
69 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALIGNED_ALLOC])
70 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATOLL])
71 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_GNU])
72 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_POSIX])
73 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CANONICALIZE_FILE_NAME])
74 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREE_POSIX])
75 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOADAVG])
76 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSUBOPT])
77 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GRANTPT])
78 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_GNU])
79 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_POSIX])
80 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBTOWC])
81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDTEMP])
82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMP])
83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMPS])
84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKSTEMP])
85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKSTEMPS])
86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_MEMALIGN])
87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_OPENPT])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTSNAME])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTSNAME_R])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTENV])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_QSORT_R])
92 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM])
93 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM_R])
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOCARRAY])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_GNU])
96 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_POSIX])
97 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALPATH])
98 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RPMATCH])
99 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SECURE_GETENV])
100 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETENV])
101 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOD])
102 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOL])
103 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLD])
104 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLL])
105 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOUL])
106 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOULL])
107 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYSTEM_POSIX])
108 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLOCKPT])
109 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNSETENV])
110 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTOMB])
111 dnl Support Microsoft deprecated alias function names by default.
112 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ECVT], [1])
113 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FCVT], [1])
114 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GCVT], [1])
115 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MKTEMP], [1])
116 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_PUTENV], [1])
117 ])
118 m4_require(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS])
119 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
120])
121
38AC_DEFUN([gl_STDLIB_H_DEFAULTS], 122AC_DEFUN([gl_STDLIB_H_DEFAULTS],
39[ 123[
40 GNULIB__EXIT=0; AC_SUBST([GNULIB__EXIT])
41 GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL])
42 GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX])
43 GNULIB_CANONICALIZE_FILE_NAME=0; AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME])
44 GNULIB_GETLOADAVG=0; AC_SUBST([GNULIB_GETLOADAVG])
45 GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT])
46 GNULIB_GRANTPT=0; AC_SUBST([GNULIB_GRANTPT])
47 GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX])
48 GNULIB_MBTOWC=0; AC_SUBST([GNULIB_MBTOWC])
49 GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP])
50 GNULIB_MKOSTEMP=0; AC_SUBST([GNULIB_MKOSTEMP])
51 GNULIB_MKOSTEMPS=0; AC_SUBST([GNULIB_MKOSTEMPS])
52 GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP])
53 GNULIB_MKSTEMPS=0; AC_SUBST([GNULIB_MKSTEMPS])
54 GNULIB_POSIX_OPENPT=0; AC_SUBST([GNULIB_POSIX_OPENPT])
55 GNULIB_PTSNAME=0; AC_SUBST([GNULIB_PTSNAME])
56 GNULIB_PTSNAME_R=0; AC_SUBST([GNULIB_PTSNAME_R])
57 GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV])
58 GNULIB_RANDOM=0; AC_SUBST([GNULIB_RANDOM])
59 GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R])
60 GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
61 GNULIB_REALPATH=0; AC_SUBST([GNULIB_REALPATH])
62 GNULIB_RPMATCH=0; AC_SUBST([GNULIB_RPMATCH])
63 GNULIB_SECURE_GETENV=0; AC_SUBST([GNULIB_SECURE_GETENV])
64 GNULIB_SETENV=0; AC_SUBST([GNULIB_SETENV])
65 GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD])
66 GNULIB_STRTOLL=0; AC_SUBST([GNULIB_STRTOLL])
67 GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL])
68 GNULIB_SYSTEM_POSIX=0; AC_SUBST([GNULIB_SYSTEM_POSIX])
69 GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT])
70 GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV])
71 GNULIB_WCTOMB=0; AC_SUBST([GNULIB_WCTOMB])
72 dnl Assume proper GNU behavior unless another module says otherwise. 124 dnl Assume proper GNU behavior unless another module says otherwise.
73 HAVE__EXIT=1; AC_SUBST([HAVE__EXIT]) 125 HAVE__EXIT=1; AC_SUBST([HAVE__EXIT])
126 HAVE_ALIGNED_ALLOC=1; AC_SUBST([HAVE_ALIGNED_ALLOC])
74 HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL]) 127 HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL])
75 HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME]) 128 HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME])
129 HAVE_DECL_ECVT=1; AC_SUBST([HAVE_DECL_ECVT])
130 HAVE_DECL_FCVT=1; AC_SUBST([HAVE_DECL_FCVT])
131 HAVE_DECL_GCVT=1; AC_SUBST([HAVE_DECL_GCVT])
76 HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG]) 132 HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG])
77 HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) 133 HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT])
78 HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT]) 134 HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT])
135 HAVE_INITSTATE=1; AC_SUBST([HAVE_INITSTATE])
136 HAVE_DECL_INITSTATE=1; AC_SUBST([HAVE_DECL_INITSTATE])
137 HAVE_MBTOWC=1; AC_SUBST([HAVE_MBTOWC])
79 HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP]) 138 HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP])
80 HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP]) 139 HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP])
81 HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) 140 HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS])
82 HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP]) 141 HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP])
83 HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS]) 142 HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS])
143 HAVE_POSIX_MEMALIGN=1; AC_SUBST([HAVE_POSIX_MEMALIGN])
84 HAVE_POSIX_OPENPT=1; AC_SUBST([HAVE_POSIX_OPENPT]) 144 HAVE_POSIX_OPENPT=1; AC_SUBST([HAVE_POSIX_OPENPT])
85 HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME]) 145 HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME])
86 HAVE_PTSNAME_R=1; AC_SUBST([HAVE_PTSNAME_R]) 146 HAVE_PTSNAME_R=1; AC_SUBST([HAVE_PTSNAME_R])
147 HAVE_QSORT_R=1; AC_SUBST([HAVE_QSORT_R])
87 HAVE_RANDOM=1; AC_SUBST([HAVE_RANDOM]) 148 HAVE_RANDOM=1; AC_SUBST([HAVE_RANDOM])
88 HAVE_RANDOM_H=1; AC_SUBST([HAVE_RANDOM_H]) 149 HAVE_RANDOM_H=1; AC_SUBST([HAVE_RANDOM_H])
89 HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R]) 150 HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
151 HAVE_REALLOCARRAY=1; AC_SUBST([HAVE_REALLOCARRAY])
90 HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH]) 152 HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH])
91 HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH]) 153 HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH])
92 HAVE_SECURE_GETENV=1; AC_SUBST([HAVE_SECURE_GETENV]) 154 HAVE_SECURE_GETENV=1; AC_SUBST([HAVE_SECURE_GETENV])
93 HAVE_SETENV=1; AC_SUBST([HAVE_SETENV]) 155 HAVE_SETENV=1; AC_SUBST([HAVE_SETENV])
94 HAVE_DECL_SETENV=1; AC_SUBST([HAVE_DECL_SETENV]) 156 HAVE_DECL_SETENV=1; AC_SUBST([HAVE_DECL_SETENV])
157 HAVE_SETSTATE=1; AC_SUBST([HAVE_SETSTATE])
158 HAVE_DECL_SETSTATE=1; AC_SUBST([HAVE_DECL_SETSTATE])
95 HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD]) 159 HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD])
160 HAVE_STRTOL=1; AC_SUBST([HAVE_STRTOL])
161 HAVE_STRTOLD=1; AC_SUBST([HAVE_STRTOLD])
96 HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL]) 162 HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL])
163 HAVE_STRTOUL=1; AC_SUBST([HAVE_STRTOUL])
97 HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL]) 164 HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL])
98 HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA]) 165 HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA])
99 HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H]) 166 HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H])
100 HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT]) 167 HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT])
101 HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV]) 168 HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV])
102 REPLACE_CALLOC=0; AC_SUBST([REPLACE_CALLOC]) 169 REPLACE_ALIGNED_ALLOC=0; AC_SUBST([REPLACE_ALIGNED_ALLOC])
170 REPLACE_CALLOC_FOR_CALLOC_GNU=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_GNU])
171 REPLACE_CALLOC_FOR_CALLOC_POSIX=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_POSIX])
103 REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) 172 REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
104 REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC]) 173 REPLACE_FREE=0; AC_SUBST([REPLACE_FREE])
174 REPLACE_INITSTATE=0; AC_SUBST([REPLACE_INITSTATE])
175 REPLACE_MALLOC_FOR_MALLOC_GNU=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_GNU])
176 REPLACE_MALLOC_FOR_MALLOC_POSIX=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_POSIX])
105 REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC]) 177 REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC])
106 REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) 178 REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
179 REPLACE_POSIX_MEMALIGN=0; AC_SUBST([REPLACE_POSIX_MEMALIGN])
107 REPLACE_PTSNAME=0; AC_SUBST([REPLACE_PTSNAME]) 180 REPLACE_PTSNAME=0; AC_SUBST([REPLACE_PTSNAME])
108 REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R]) 181 REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R])
109 REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) 182 REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
183 REPLACE_QSORT_R=0; AC_SUBST([REPLACE_QSORT_R])
184 REPLACE_RANDOM=0; AC_SUBST([REPLACE_RANDOM])
110 REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R]) 185 REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R])
111 REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC]) 186 REPLACE_REALLOC_FOR_REALLOC_GNU=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_GNU])
187 REPLACE_REALLOC_FOR_REALLOC_POSIX=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_POSIX])
188 REPLACE_REALLOCARRAY=0; AC_SUBST([REPLACE_REALLOCARRAY])
112 REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) 189 REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH])
113 REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV]) 190 REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV])
191 REPLACE_SETSTATE=0; AC_SUBST([REPLACE_SETSTATE])
114 REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD]) 192 REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD])
193 REPLACE_STRTOL=0; AC_SUBST([REPLACE_STRTOL])
194 REPLACE_STRTOLD=0; AC_SUBST([REPLACE_STRTOLD])
195 REPLACE_STRTOLL=0; AC_SUBST([REPLACE_STRTOLL])
196 REPLACE_STRTOUL=0; AC_SUBST([REPLACE_STRTOUL])
197 REPLACE_STRTOULL=0; AC_SUBST([REPLACE_STRTOULL])
115 REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV]) 198 REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV])
116 REPLACE_WCTOMB=0; AC_SUBST([REPLACE_WCTOMB]) 199 REPLACE_WCTOMB=0; AC_SUBST([REPLACE_WCTOMB])
117]) 200])
diff --git a/gl/m4/strcase.m4 b/gl/m4/strcase.m4
index 22bf57c9..3cf740d2 100644
--- a/gl/m4/strcase.m4
+++ b/gl/m4/strcase.m4
@@ -1,5 +1,5 @@
1# strcase.m4 serial 11 1# strcase.m4 serial 12
2dnl Copyright (C) 2002, 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,7 +12,7 @@ AC_DEFUN([gl_STRCASE],
12 12
13AC_DEFUN([gl_FUNC_STRCASECMP], 13AC_DEFUN([gl_FUNC_STRCASECMP],
14[ 14[
15 AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) 15 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
16 AC_CHECK_FUNCS([strcasecmp]) 16 AC_CHECK_FUNCS([strcasecmp])
17 if test $ac_cv_func_strcasecmp = no; then 17 if test $ac_cv_func_strcasecmp = no; then
18 HAVE_STRCASECMP=0 18 HAVE_STRCASECMP=0
@@ -21,7 +21,7 @@ AC_DEFUN([gl_FUNC_STRCASECMP],
21 21
22AC_DEFUN([gl_FUNC_STRNCASECMP], 22AC_DEFUN([gl_FUNC_STRNCASECMP],
23[ 23[
24 AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) 24 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
25 AC_CHECK_FUNCS([strncasecmp]) 25 AC_CHECK_FUNCS([strncasecmp])
26 if test $ac_cv_func_strncasecmp = yes; then 26 if test $ac_cv_func_strncasecmp = yes; then
27 HAVE_STRNCASECMP=1 27 HAVE_STRNCASECMP=1
diff --git a/gl/m4/strcasestr.m4 b/gl/m4/strcasestr.m4
index 8681a6a4..971e0b23 100644
--- a/gl/m4/strcasestr.m4
+++ b/gl/m4/strcasestr.m4
@@ -1,5 +1,5 @@
1# strcasestr.m4 serial 21 1# strcasestr.m4 serial 28
2dnl Copyright (C) 2005, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
7dnl Check that strcasestr is present and works. 7dnl Check that strcasestr is present and works.
8AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE], 8AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
9[ 9[
10 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 10 AC_REQUIRE([gl_STRING_H_DEFAULTS])
11 11
12 dnl Persuade glibc <string.h> to declare strcasestr(). 12 dnl Persuade glibc <string.h> to declare strcasestr().
13 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 13 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
@@ -17,28 +17,38 @@ AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
17 if test $ac_cv_func_strcasestr = no; then 17 if test $ac_cv_func_strcasestr = no; then
18 HAVE_STRCASESTR=0 18 HAVE_STRCASESTR=0
19 else 19 else
20 if test "$gl_cv_func_memchr_works" != yes; then 20 if test $REPLACE_MEMCHR = 1; then
21 REPLACE_STRCASESTR=1 21 REPLACE_STRCASESTR=1
22 else 22 else
23 dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092. 23 dnl Detect https://sourceware.org/bugzilla/show_bug.cgi?id=12092
24 dnl and https://sourceware.org/bugzilla/show_bug.cgi?id=23637.
24 AC_CACHE_CHECK([whether strcasestr works], 25 AC_CACHE_CHECK([whether strcasestr works],
25 [gl_cv_func_strcasestr_works_always], 26 [gl_cv_func_strcasestr_works_always],
26 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 27 [AC_RUN_IFELSE(
27#include <string.h> /* for strcasestr */ 28 [AC_LANG_PROGRAM([[
29#include <string.h> /* for __GNU_LIBRARY__, strcasestr */
30#ifdef __GNU_LIBRARY__
31 #include <features.h>
32 #if __GLIBC__ == 2 && __GLIBC_MINOR__ == 28
33 Unlucky user
34 #endif
35#endif
28#define P "_EF_BF_BD" 36#define P "_EF_BF_BD"
29#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P 37#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P
30#define NEEDLE P P P P P 38#define NEEDLE P P P P P
31]], [[return !!strcasestr (HAYSTACK, NEEDLE); 39]],
32 ]])], 40 [[return !!strcasestr (HAYSTACK, NEEDLE);
33 [gl_cv_func_strcasestr_works_always=yes], 41 ]])],
34 [gl_cv_func_strcasestr_works_always=no], 42 [gl_cv_func_strcasestr_works_always=yes],
35 [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not 43 [gl_cv_func_strcasestr_works_always=no],
36 dnl affected, since it uses different source code for strcasestr 44 [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not
37 dnl than glibc. 45 dnl affected, since it uses different source code for strcasestr
38 dnl Assume that it works on all other platforms, even if it is not 46 dnl than glibc.
39 dnl linear. 47 dnl Assume that it works on all other platforms, even if it is not
40 AC_EGREP_CPP([Lucky user], 48 dnl linear.
41 [ 49 AC_EGREP_CPP([Lucky user],
50 [
51#include <string.h> /* for __GNU_LIBRARY__ */
42#ifdef __GNU_LIBRARY__ 52#ifdef __GNU_LIBRARY__
43 #include <features.h> 53 #include <features.h>
44 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \ 54 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
@@ -53,10 +63,10 @@ AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
53#else 63#else
54 Lucky user 64 Lucky user
55#endif 65#endif
56 ], 66 ],
57 [gl_cv_func_strcasestr_works_always="guessing yes"], 67 [gl_cv_func_strcasestr_works_always="guessing yes"],
58 [gl_cv_func_strcasestr_works_always="guessing no"]) 68 [gl_cv_func_strcasestr_works_always="$gl_cross_guess_normal"])
59 ]) 69 ])
60 ]) 70 ])
61 case "$gl_cv_func_strcasestr_works_always" in 71 case "$gl_cv_func_strcasestr_works_always" in
62 *yes) ;; 72 *yes) ;;
@@ -80,7 +90,7 @@ AC_DEFUN([gl_FUNC_STRCASESTR],
80#include <string.h> /* for strcasestr */ 90#include <string.h> /* for strcasestr */
81#include <stdlib.h> /* for malloc */ 91#include <stdlib.h> /* for malloc */
82#include <unistd.h> /* for alarm */ 92#include <unistd.h> /* for alarm */
83static void quit (int sig) { exit (sig + 128); } 93static void quit (int sig) { _exit (sig + 128); }
84]], [[ 94]], [[
85 int result = 0; 95 int result = 0;
86 size_t m = 1000000; 96 size_t m = 1000000;
@@ -102,6 +112,9 @@ static void quit (int sig) { exit (sig + 128); }
102 if (!strcasestr (haystack, needle)) 112 if (!strcasestr (haystack, needle))
103 result |= 1; 113 result |= 1;
104 } 114 }
115 /* Free allocated memory, in case some sanitizer is watching. */
116 free (haystack);
117 free (needle);
105 return result; 118 return result;
106 ]])], 119 ]])],
107 [gl_cv_func_strcasestr_linear=yes], [gl_cv_func_strcasestr_linear=no], 120 [gl_cv_func_strcasestr_linear=yes], [gl_cv_func_strcasestr_linear=no],
@@ -124,7 +137,7 @@ static void quit (int sig) { exit (sig + 128); }
124#endif 137#endif
125 ], 138 ],
126 [gl_cv_func_strcasestr_linear="guessing yes"], 139 [gl_cv_func_strcasestr_linear="guessing yes"],
127 [gl_cv_func_strcasestr_linear="guessing no"]) 140 [gl_cv_func_strcasestr_linear="$gl_cross_guess_normal"])
128 ]) 141 ])
129 ]) 142 ])
130 case "$gl_cv_func_strcasestr_linear" in 143 case "$gl_cv_func_strcasestr_linear" in
diff --git a/gl/m4/strerror.m4 b/gl/m4/strerror.m4
index 3989844b..8879eb08 100644
--- a/gl/m4/strerror.m4
+++ b/gl/m4/strerror.m4
@@ -1,19 +1,19 @@
1# strerror.m4 serial 17 1# strerror.m4 serial 23
2dnl Copyright (C) 2002, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_FUNC_STRERROR], 7AC_DEFUN([gl_FUNC_STRERROR],
8[ 8[
9 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 9 AC_REQUIRE([gl_STRING_H_DEFAULTS])
10 AC_REQUIRE([gl_HEADER_ERRNO_H]) 10 AC_REQUIRE([gl_HEADER_ERRNO_H])
11 AC_REQUIRE([gl_FUNC_STRERROR_0]) 11 AC_REQUIRE([gl_FUNC_STRERROR_0])
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13 m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [ 13 m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [
14 AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS]) 14 AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS])
15 ]) 15 ])
16 if test "$ERRNO_H:$REPLACE_STRERROR_0" = :0; then 16 if test "$GL_GENERATE_ERRNO_H:$REPLACE_STRERROR_0" = false:0; then
17 AC_CACHE_CHECK([for working strerror function], 17 AC_CACHE_CHECK([for working strerror function],
18 [gl_cv_func_working_strerror], 18 [gl_cv_func_working_strerror],
19 [AC_RUN_IFELSE( 19 [AC_RUN_IFELSE(
@@ -24,10 +24,12 @@ AC_DEFUN([gl_FUNC_STRERROR],
24 [gl_cv_func_working_strerror=yes], 24 [gl_cv_func_working_strerror=yes],
25 [gl_cv_func_working_strerror=no], 25 [gl_cv_func_working_strerror=no],
26 [case "$host_os" in 26 [case "$host_os" in
27 # Guess yes on glibc systems. 27 # Guess yes on glibc systems.
28 *-gnu*) gl_cv_func_working_strerror="guessing yes" ;; 28 *-gnu* | gnu*) gl_cv_func_working_strerror="guessing yes" ;;
29 # If we don't know, assume the worst. 29 # Guess yes on musl systems.
30 *) gl_cv_func_working_strerror="guessing no" ;; 30 *-musl*) gl_cv_func_working_strerror="guessing yes" ;;
31 # If we don't know, obey --enable-cross-guesses.
32 *) gl_cv_func_working_strerror="$gl_cross_guess_normal" ;;
31 esac 33 esac
32 ]) 34 ])
33 ]) 35 ])
@@ -78,10 +80,14 @@ AC_DEFUN([gl_FUNC_STRERROR_0],
78 [gl_cv_func_strerror_0_works=yes], 80 [gl_cv_func_strerror_0_works=yes],
79 [gl_cv_func_strerror_0_works=no], 81 [gl_cv_func_strerror_0_works=no],
80 [case "$host_os" in 82 [case "$host_os" in
81 # Guess yes on glibc systems. 83 # Guess yes on glibc systems.
82 *-gnu*) gl_cv_func_strerror_0_works="guessing yes" ;; 84 *-gnu* | gnu*) gl_cv_func_strerror_0_works="guessing yes" ;;
83 # If we don't know, assume the worst. 85 # Guess yes on musl systems.
84 *) gl_cv_func_strerror_0_works="guessing no" ;; 86 *-musl*) gl_cv_func_strerror_0_works="guessing yes" ;;
87 # Guess yes on native Windows.
88 mingw*) gl_cv_func_strerror_0_works="guessing yes" ;;
89 # If we don't know, obey --enable-cross-guesses.
90 *) gl_cv_func_strerror_0_works="$gl_cross_guess_normal" ;;
85 esac 91 esac
86 ]) 92 ])
87 ]) 93 ])
diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4
index cc5fbbb3..5da3cc25 100644
--- a/gl/m4/string_h.m4
+++ b/gl/m4/string_h.m4
@@ -1,25 +1,19 @@
1# Configure a GNU-like replacement for <string.h>. 1# Configure a GNU-like replacement for <string.h>.
2 2
3# Copyright (C) 2007-2013 Free Software Foundation, Inc. 3# Copyright (C) 2007-2023 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation 4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it, 5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved. 6# with or without modifications, as long as this notice is preserved.
7 7
8# serial 21 8# serial 35
9 9
10# Written by Paul Eggert. 10# Written by Paul Eggert.
11 11
12AC_DEFUN([gl_HEADER_STRING_H], 12AC_DEFUN_ONCE([gl_STRING_H],
13[ 13[
14 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 14 dnl Ensure to expand the default settings once only, before all statements
15 dnl once only, before all statements that occur in other macros. 15 dnl that occur in other macros.
16 AC_REQUIRE([gl_HEADER_STRING_H_BODY]) 16 AC_REQUIRE([gl_STRING_H_DEFAULTS])
17])
18
19AC_DEFUN([gl_HEADER_STRING_H_BODY],
20[
21 AC_REQUIRE([AC_C_RESTRICT])
22 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
23 gl_NEXT_HEADERS([string.h]) 17 gl_NEXT_HEADERS([string.h])
24 18
25 dnl Check for declarations of anything we want to poison if the 19 dnl Check for declarations of anything we want to poison if the
@@ -27,66 +21,95 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY],
27 dnl guaranteed by C89. 21 dnl guaranteed by C89.
28 gl_WARN_ON_USE_PREPARE([[#include <string.h> 22 gl_WARN_ON_USE_PREPARE([[#include <string.h>
29 ]], 23 ]],
30 [ffsl ffsll memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul 24 [explicit_bzero ffsl ffsll memmem mempcpy memrchr memset_explicit
25 rawmemchr stpcpy stpncpy strchrnul
31 strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r 26 strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r
32 strerror_r strsignal strverscmp]) 27 strerror_r strerrorname_np sigabbrev_np sigdescr_np strsignal strverscmp])
28
29 AC_REQUIRE([AC_C_RESTRICT])
33]) 30])
34 31
32# gl_STRING_MODULE_INDICATOR([modulename])
33# sets the shell variable that indicates the presence of the given module
34# to a C preprocessor expression that will evaluate to 1.
35# This macro invocation must not occur in macros that are AC_REQUIREd.
35AC_DEFUN([gl_STRING_MODULE_INDICATOR], 36AC_DEFUN([gl_STRING_MODULE_INDICATOR],
36[ 37[
37 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 38 dnl Ensure to expand the default settings once only.
38 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 39 gl_STRING_H_REQUIRE_DEFAULTS
39 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 40 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
40 dnl Define it also as a C macro, for the benefit of the unit tests. 41 dnl Define it also as a C macro, for the benefit of the unit tests.
41 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 42 gl_MODULE_INDICATOR_FOR_TESTS([$1])
42]) 43])
43 44
44AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], 45# Initializes the default values for AC_SUBSTed shell variables.
46# This macro must not be AC_REQUIREd. It must only be invoked, and only
47# outside of macros or in macros that are not AC_REQUIREd.
48AC_DEFUN([gl_STRING_H_REQUIRE_DEFAULTS],
45[ 49[
46 GNULIB_FFSL=0; AC_SUBST([GNULIB_FFSL]) 50 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STRING_H_MODULE_INDICATOR_DEFAULTS], [
47 GNULIB_FFSLL=0; AC_SUBST([GNULIB_FFSLL]) 51 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPLICIT_BZERO])
48 GNULIB_MEMCHR=0; AC_SUBST([GNULIB_MEMCHR]) 52 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFSL])
49 GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM]) 53 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFSLL])
50 GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY]) 54 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMCHR])
51 GNULIB_MEMRCHR=0; AC_SUBST([GNULIB_MEMRCHR]) 55 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMMEM])
52 GNULIB_RAWMEMCHR=0; AC_SUBST([GNULIB_RAWMEMCHR]) 56 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMPCPY])
53 GNULIB_STPCPY=0; AC_SUBST([GNULIB_STPCPY]) 57 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMRCHR])
54 GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY]) 58 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMSET_EXPLICIT])
55 GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL]) 59 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RAWMEMCHR])
56 GNULIB_STRDUP=0; AC_SUBST([GNULIB_STRDUP]) 60 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STPCPY])
57 GNULIB_STRNCAT=0; AC_SUBST([GNULIB_STRNCAT]) 61 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STPNCPY])
58 GNULIB_STRNDUP=0; AC_SUBST([GNULIB_STRNDUP]) 62 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCHRNUL])
59 GNULIB_STRNLEN=0; AC_SUBST([GNULIB_STRNLEN]) 63 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRDUP])
60 GNULIB_STRPBRK=0; AC_SUBST([GNULIB_STRPBRK]) 64 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNCAT])
61 GNULIB_STRSEP=0; AC_SUBST([GNULIB_STRSEP]) 65 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNDUP])
62 GNULIB_STRSTR=0; AC_SUBST([GNULIB_STRSTR]) 66 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNLEN])
63 GNULIB_STRCASESTR=0; AC_SUBST([GNULIB_STRCASESTR]) 67 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPBRK])
64 GNULIB_STRTOK_R=0; AC_SUBST([GNULIB_STRTOK_R]) 68 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSEP])
65 GNULIB_MBSLEN=0; AC_SUBST([GNULIB_MBSLEN]) 69 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSTR])
66 GNULIB_MBSNLEN=0; AC_SUBST([GNULIB_MBSNLEN]) 70 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCASESTR])
67 GNULIB_MBSCHR=0; AC_SUBST([GNULIB_MBSCHR]) 71 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOK_R])
68 GNULIB_MBSRCHR=0; AC_SUBST([GNULIB_MBSRCHR]) 72 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSLEN])
69 GNULIB_MBSSTR=0; AC_SUBST([GNULIB_MBSSTR]) 73 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNLEN])
70 GNULIB_MBSCASECMP=0; AC_SUBST([GNULIB_MBSCASECMP]) 74 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCHR])
71 GNULIB_MBSNCASECMP=0; AC_SUBST([GNULIB_MBSNCASECMP]) 75 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSRCHR])
72 GNULIB_MBSPCASECMP=0; AC_SUBST([GNULIB_MBSPCASECMP]) 76 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSTR])
73 GNULIB_MBSCASESTR=0; AC_SUBST([GNULIB_MBSCASESTR]) 77 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCASECMP])
74 GNULIB_MBSCSPN=0; AC_SUBST([GNULIB_MBSCSPN]) 78 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNCASECMP])
75 GNULIB_MBSPBRK=0; AC_SUBST([GNULIB_MBSPBRK]) 79 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSPCASECMP])
76 GNULIB_MBSSPN=0; AC_SUBST([GNULIB_MBSSPN]) 80 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCASESTR])
77 GNULIB_MBSSEP=0; AC_SUBST([GNULIB_MBSSEP]) 81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCSPN])
78 GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R]) 82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSPBRK])
79 GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR]) 83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSPN])
80 GNULIB_STRERROR_R=0; AC_SUBST([GNULIB_STRERROR_R]) 84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSEP])
81 GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL]) 85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSTOK_R])
82 GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP]) 86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR])
83 HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN]) 87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR_R])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERRORNAME_NP])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGABBREV_NP])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGDESCR_NP])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSIGNAL])
92 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRVERSCMP])
93 dnl Support Microsoft deprecated alias function names by default.
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MEMCCPY], [1])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_STRDUP], [1])
96 ])
97 m4_require(GL_MODULE_INDICATOR_PREFIX[_STRING_H_MODULE_INDICATOR_DEFAULTS])
98 dnl Make sure the shell variable for GNULIB_FREE_POSIX is initialized.
99 gl_STDLIB_H_REQUIRE_DEFAULTS
100 AC_REQUIRE([gl_STRING_H_DEFAULTS])
101])
102
103AC_DEFUN([gl_STRING_H_DEFAULTS],
104[
105 HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN])
84 dnl Assume proper GNU behavior unless another module says otherwise. 106 dnl Assume proper GNU behavior unless another module says otherwise.
107 HAVE_EXPLICIT_BZERO=1; AC_SUBST([HAVE_EXPLICIT_BZERO])
85 HAVE_FFSL=1; AC_SUBST([HAVE_FFSL]) 108 HAVE_FFSL=1; AC_SUBST([HAVE_FFSL])
86 HAVE_FFSLL=1; AC_SUBST([HAVE_FFSLL]) 109 HAVE_FFSLL=1; AC_SUBST([HAVE_FFSLL])
87 HAVE_MEMCHR=1; AC_SUBST([HAVE_MEMCHR])
88 HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) 110 HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
89 HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) 111 HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
112 HAVE_MEMSET_EXPLICIT=1; AC_SUBST([HAVE_MEMSET_EXPLICIT])
90 HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR]) 113 HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
91 HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR]) 114 HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR])
92 HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY]) 115 HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY])
@@ -100,21 +123,26 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
100 HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR]) 123 HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
101 HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) 124 HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
102 HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R]) 125 HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R])
126 HAVE_STRERRORNAME_NP=1; AC_SUBST([HAVE_STRERRORNAME_NP])
127 HAVE_SIGABBREV_NP=1; AC_SUBST([HAVE_SIGABBREV_NP])
128 HAVE_SIGDESCR_NP=1; AC_SUBST([HAVE_SIGDESCR_NP])
103 HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL]) 129 HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
104 HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP]) 130 HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
131 REPLACE_FFSLL=0; AC_SUBST([REPLACE_FFSLL])
105 REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR]) 132 REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
106 REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM]) 133 REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
107 REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY]) 134 REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY])
135 REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL])
108 REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP]) 136 REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
137 REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT])
138 REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
139 REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN])
109 REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR]) 140 REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
110 REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR]) 141 REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
111 REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL]) 142 REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
112 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) 143 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
113 REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R]) 144 REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R])
114 REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT]) 145 REPLACE_STRERRORNAME_NP=0; AC_SUBST([REPLACE_STRERRORNAME_NP])
115 REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
116 REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN])
117 REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) 146 REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
118 REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
119 UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) 147 UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
120]) 148])
diff --git a/gl/m4/strings_h.m4 b/gl/m4/strings_h.m4
index 76ef2424..4c41221b 100644
--- a/gl/m4/strings_h.m4
+++ b/gl/m4/strings_h.m4
@@ -1,21 +1,16 @@
1# Configure a replacement for <strings.h>. 1# Configure a replacement for <strings.h>.
2# serial 6 2# serial 9
3 3
4# Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 4# Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
5# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved. 7# with or without modifications, as long as this notice is preserved.
8 8
9AC_DEFUN([gl_HEADER_STRINGS_H], 9AC_DEFUN_ONCE([gl_STRINGS_H],
10[ 10[
11 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 11 dnl Ensure to expand the default settings once only, before all statements
12 dnl once only, before all statements that occur in other macros. 12 dnl that occur in other macros.
13 AC_REQUIRE([gl_HEADER_STRINGS_H_BODY]) 13 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
14])
15
16AC_DEFUN([gl_HEADER_STRINGS_H_BODY],
17[
18 AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
19 14
20 gl_CHECK_NEXT_HEADERS([strings.h]) 15 gl_CHECK_NEXT_HEADERS([strings.h])
21 if test $ac_cv_header_strings_h = yes; then 16 if test $ac_cv_header_strings_h = yes; then
@@ -35,16 +30,31 @@ AC_DEFUN([gl_HEADER_STRINGS_H_BODY],
35 ]], [ffs strcasecmp strncasecmp]) 30 ]], [ffs strcasecmp strncasecmp])
36]) 31])
37 32
33# gl_STRINGS_MODULE_INDICATOR([modulename])
34# sets the shell variable that indicates the presence of the given module
35# to a C preprocessor expression that will evaluate to 1.
36# This macro invocation must not occur in macros that are AC_REQUIREd.
38AC_DEFUN([gl_STRINGS_MODULE_INDICATOR], 37AC_DEFUN([gl_STRINGS_MODULE_INDICATOR],
39[ 38[
40 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 39 dnl Ensure to expand the default settings once only.
41 AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) 40 gl_STRINGS_H_REQUIRE_DEFAULTS
42 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 41 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
43]) 42])
44 43
45AC_DEFUN([gl_HEADER_STRINGS_H_DEFAULTS], 44# Initializes the default values for AC_SUBSTed shell variables.
45# This macro must not be AC_REQUIREd. It must only be invoked, and only
46# outside of macros or in macros that are not AC_REQUIREd.
47AC_DEFUN([gl_STRINGS_H_REQUIRE_DEFAULTS],
48[
49 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS], [
50 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFS])
51 ])
52 m4_require(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS])
53 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
54])
55
56AC_DEFUN([gl_STRINGS_H_DEFAULTS],
46[ 57[
47 GNULIB_FFS=0; AC_SUBST([GNULIB_FFS])
48 dnl Assume proper GNU behavior unless another module says otherwise. 58 dnl Assume proper GNU behavior unless another module says otherwise.
49 HAVE_FFS=1; AC_SUBST([HAVE_FFS]) 59 HAVE_FFS=1; AC_SUBST([HAVE_FFS])
50 HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP]) 60 HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP])
diff --git a/gl/m4/strndup.m4 b/gl/m4/strndup.m4
deleted file mode 100644
index a1f82743..00000000
--- a/gl/m4/strndup.m4
+++ /dev/null
@@ -1,55 +0,0 @@
1# strndup.m4 serial 21
2dnl Copyright (C) 2002-2003, 2005-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_STRNDUP],
8[
9 dnl Persuade glibc <string.h> to declare strndup().
10 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
11
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
14 AC_CHECK_DECLS_ONCE([strndup])
15 AC_CHECK_FUNCS_ONCE([strndup])
16 if test $ac_cv_have_decl_strndup = no; then
17 HAVE_DECL_STRNDUP=0
18 fi
19
20 if test $ac_cv_func_strndup = yes; then
21 HAVE_STRNDUP=1
22 # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
23 AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup_works],
24 [AC_RUN_IFELSE([
25 AC_LANG_PROGRAM([[#include <string.h>
26 #include <stdlib.h>]], [[
27#if !HAVE_DECL_STRNDUP
28 extern
29 #ifdef __cplusplus
30 "C"
31 #endif
32 char *strndup (const char *, size_t);
33#endif
34 char *s;
35 s = strndup ("some longer string", 15);
36 free (s);
37 s = strndup ("shorter string", 13);
38 return s[13] != '\0';]])],
39 [gl_cv_func_strndup_works=yes],
40 [gl_cv_func_strndup_works=no],
41 [
42changequote(,)dnl
43 case $host_os in
44 aix | aix[3-6]*) gl_cv_func_strndup_works="guessing no";;
45 *) gl_cv_func_strndup_works="guessing yes";;
46 esac
47changequote([,])dnl
48 ])])
49 case $gl_cv_func_strndup_works in
50 *no) REPLACE_STRNDUP=1 ;;
51 esac
52 else
53 HAVE_STRNDUP=0
54 fi
55])
diff --git a/gl/m4/strnlen.m4 b/gl/m4/strnlen.m4
deleted file mode 100644
index eae82b77..00000000
--- a/gl/m4/strnlen.m4
+++ /dev/null
@@ -1,30 +0,0 @@
1# strnlen.m4 serial 13
2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_FUNC_STRNLEN],
9[
10 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
11
12 dnl Persuade glibc <string.h> to declare strnlen().
13 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
14
15 AC_CHECK_DECLS_ONCE([strnlen])
16 if test $ac_cv_have_decl_strnlen = no; then
17 HAVE_DECL_STRNLEN=0
18 else
19 m4_pushdef([AC_LIBOBJ], [:])
20 dnl Note: AC_FUNC_STRNLEN does AC_LIBOBJ([strnlen]).
21 AC_FUNC_STRNLEN
22 m4_popdef([AC_LIBOBJ])
23 if test $ac_cv_func_strnlen_working = no; then
24 REPLACE_STRNLEN=1
25 fi
26 fi
27])
28
29# Prerequisites of lib/strnlen.c.
30AC_DEFUN([gl_PREREQ_STRNLEN], [:])
diff --git a/gl/m4/strsep.m4 b/gl/m4/strsep.m4
index 825fdb81..e0da09a3 100644
--- a/gl/m4/strsep.m4
+++ b/gl/m4/strsep.m4
@@ -1,5 +1,5 @@
1# strsep.m4 serial 10 1# strsep.m4 serial 11
2dnl Copyright (C) 2002-2004, 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,7 +12,7 @@ AC_DEFUN([gl_FUNC_STRSEP],
12 dnl The strsep() declaration in lib/string.in.h uses 'restrict'. 12 dnl The strsep() declaration in lib/string.in.h uses 'restrict'.
13 AC_REQUIRE([AC_C_RESTRICT]) 13 AC_REQUIRE([AC_C_RESTRICT])
14 14
15 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 15 AC_REQUIRE([gl_STRING_H_DEFAULTS])
16 AC_CHECK_FUNCS([strsep]) 16 AC_CHECK_FUNCS([strsep])
17 if test $ac_cv_func_strsep = no; then 17 if test $ac_cv_func_strsep = no; then
18 HAVE_STRSEP=0 18 HAVE_STRSEP=0
diff --git a/gl/m4/strstr.m4 b/gl/m4/strstr.m4
index c486bdb0..7de203a7 100644
--- a/gl/m4/strstr.m4
+++ b/gl/m4/strstr.m4
@@ -1,5 +1,5 @@
1# strstr.m4 serial 16 1# strstr.m4 serial 24
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,30 +7,40 @@ dnl with or without modifications, as long as this notice is preserved.
7dnl Check that strstr works. 7dnl Check that strstr works.
8AC_DEFUN([gl_FUNC_STRSTR_SIMPLE], 8AC_DEFUN([gl_FUNC_STRSTR_SIMPLE],
9[ 9[
10 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 10 AC_REQUIRE([gl_STRING_H_DEFAULTS])
11 AC_REQUIRE([gl_FUNC_MEMCHR]) 11 AC_REQUIRE([gl_FUNC_MEMCHR])
12 if test "$gl_cv_func_memchr_works" != yes; then 12 if test $REPLACE_MEMCHR = 1; then
13 REPLACE_STRSTR=1 13 REPLACE_STRSTR=1
14 else 14 else
15 dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092. 15 dnl Detect https://sourceware.org/bugzilla/show_bug.cgi?id=12092
16 dnl and https://sourceware.org/bugzilla/show_bug.cgi?id=23637.
16 AC_CACHE_CHECK([whether strstr works], 17 AC_CACHE_CHECK([whether strstr works],
17 [gl_cv_func_strstr_works_always], 18 [gl_cv_func_strstr_works_always],
18 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 19 [AC_RUN_IFELSE(
19#include <string.h> /* for strstr */ 20 [AC_LANG_PROGRAM([[
21#include <string.h> /* for __GNU_LIBRARY__, strstr */
22#ifdef __GNU_LIBRARY__
23 #include <features.h>
24 #if __GLIBC__ == 2 && __GLIBC_MINOR__ == 28
25 Unlucky user
26 #endif
27#endif
20#define P "_EF_BF_BD" 28#define P "_EF_BF_BD"
21#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P 29#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P
22#define NEEDLE P P P P P 30#define NEEDLE P P P P P
23]], [[return !!strstr (HAYSTACK, NEEDLE); 31]],
24 ]])], 32 [[return !!strstr (HAYSTACK, NEEDLE);
25 [gl_cv_func_strstr_works_always=yes], 33 ]])],
26 [gl_cv_func_strstr_works_always=no], 34 [gl_cv_func_strstr_works_always=yes],
27 [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not 35 [gl_cv_func_strstr_works_always=no],
28 dnl affected, since it uses different source code for strstr than 36 [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not
29 dnl glibc. 37 dnl affected, since it uses different source code for strstr than
30 dnl Assume that it works on all other platforms, even if it is not 38 dnl glibc.
31 dnl linear. 39 dnl Assume that it works on all other platforms, even if it is not
32 AC_EGREP_CPP([Lucky user], 40 dnl linear.
33 [ 41 AC_EGREP_CPP([Lucky user],
42 [
43#include <string.h> /* for __GNU_LIBRARY__ */
34#ifdef __GNU_LIBRARY__ 44#ifdef __GNU_LIBRARY__
35 #include <features.h> 45 #include <features.h>
36 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \ 46 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
@@ -45,10 +55,10 @@ AC_DEFUN([gl_FUNC_STRSTR_SIMPLE],
45#else 55#else
46 Lucky user 56 Lucky user
47#endif 57#endif
48 ], 58 ],
49 [gl_cv_func_strstr_works_always="guessing yes"], 59 [gl_cv_func_strstr_works_always="guessing yes"],
50 [gl_cv_func_strstr_works_always="guessing no"]) 60 [gl_cv_func_strstr_works_always="$gl_cross_guess_normal"])
51 ]) 61 ])
52 ]) 62 ])
53 case "$gl_cv_func_strstr_works_always" in 63 case "$gl_cv_func_strstr_works_always" in
54 *yes) ;; 64 *yes) ;;
@@ -67,11 +77,17 @@ AC_DEFUN([gl_FUNC_STRSTR],
67 AC_CACHE_CHECK([whether strstr works in linear time], 77 AC_CACHE_CHECK([whether strstr works in linear time],
68 [gl_cv_func_strstr_linear], 78 [gl_cv_func_strstr_linear],
69 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 79 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
80#ifdef __MVS__
81/* z/OS does not deliver signals while strstr() is running (thanks to
82 restrictions on its LE runtime), which prevents us from limiting the
83 running time of this test. */
84# error "This test does not work properly on z/OS"
85#endif
70#include <signal.h> /* for signal */ 86#include <signal.h> /* for signal */
71#include <string.h> /* for strstr */ 87#include <string.h> /* for strstr */
72#include <stdlib.h> /* for malloc */ 88#include <stdlib.h> /* for malloc */
73#include <unistd.h> /* for alarm */ 89#include <unistd.h> /* for alarm */
74static void quit (int sig) { exit (sig + 128); } 90static void quit (int sig) { _exit (sig + 128); }
75]], [[ 91]], [[
76 int result = 0; 92 int result = 0;
77 size_t m = 1000000; 93 size_t m = 1000000;
@@ -93,6 +109,9 @@ static void quit (int sig) { exit (sig + 128); }
93 if (!strstr (haystack, needle)) 109 if (!strstr (haystack, needle))
94 result |= 1; 110 result |= 1;
95 } 111 }
112 /* Free allocated memory, in case some sanitizer is watching. */
113 free (haystack);
114 free (needle);
96 return result; 115 return result;
97 ]])], 116 ]])],
98 [gl_cv_func_strstr_linear=yes], [gl_cv_func_strstr_linear=no], 117 [gl_cv_func_strstr_linear=yes], [gl_cv_func_strstr_linear=no],
@@ -117,7 +136,7 @@ static void quit (int sig) { exit (sig + 128); }
117#endif 136#endif
118 ], 137 ],
119 [gl_cv_func_strstr_linear="guessing yes"], 138 [gl_cv_func_strstr_linear="guessing yes"],
120 [gl_cv_func_strstr_linear="guessing no"]) 139 [gl_cv_func_strstr_linear="$gl_cross_guess_normal"])
121 ]) 140 ])
122 ]) 141 ])
123 case "$gl_cv_func_strstr_linear" in 142 case "$gl_cv_func_strstr_linear" in
diff --git a/gl/m4/sys_socket_h.m4 b/gl/m4/sys_socket_h.m4
index 94863776..98a10416 100644
--- a/gl/m4/sys_socket_h.m4
+++ b/gl/m4/sys_socket_h.m4
@@ -1,12 +1,12 @@
1# sys_socket_h.m4 serial 23 1# sys_socket_h.m4 serial 29
2dnl Copyright (C) 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Simon Josefsson. 7dnl From Simon Josefsson.
8 8
9AC_DEFUN([gl_HEADER_SYS_SOCKET], 9AC_DEFUN_ONCE([gl_SYS_SOCKET_H],
10[ 10[
11 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) 11 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS])
12 AC_REQUIRE([AC_CANONICAL_HOST]) 12 AC_REQUIRE([AC_CANONICAL_HOST])
@@ -22,6 +22,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
22 ;; 22 ;;
23 esac 23 esac
24 24
25 GL_GENERATE_SYS_SOCKET_H=false
25 AC_CACHE_CHECK([whether <sys/socket.h> is self-contained], 26 AC_CACHE_CHECK([whether <sys/socket.h> is self-contained],
26 [gl_cv_header_sys_socket_h_selfcontained], 27 [gl_cv_header_sys_socket_h_selfcontained],
27 [ 28 [
@@ -44,7 +45,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
44 [gl_cv_header_sys_socket_h_shut=no]) 45 [gl_cv_header_sys_socket_h_shut=no])
45 ]) 46 ])
46 if test $gl_cv_header_sys_socket_h_shut = no; then 47 if test $gl_cv_header_sys_socket_h_shut = no; then
47 SYS_SOCKET_H='sys/socket.h' 48 GL_GENERATE_SYS_SOCKET_H=true
48 fi 49 fi
49 fi 50 fi
50 fi 51 fi
@@ -83,7 +84,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
83 fi 84 fi
84 if test $HAVE_STRUCT_SOCKADDR_STORAGE = 0 || test $HAVE_SA_FAMILY_T = 0 \ 85 if test $HAVE_STRUCT_SOCKADDR_STORAGE = 0 || test $HAVE_SA_FAMILY_T = 0 \
85 || test $HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = 0; then 86 || test $HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = 0; then
86 SYS_SOCKET_H='sys/socket.h' 87 GL_GENERATE_SYS_SOCKET_H=true
87 fi 88 fi
88 gl_PREREQ_SYS_H_WINSOCK2 89 gl_PREREQ_SYS_H_WINSOCK2
89 90
@@ -95,6 +96,8 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
95#include <sys/socket.h> 96#include <sys/socket.h>
96 ]], [socket connect accept bind getpeername getsockname getsockopt 97 ]], [socket connect accept bind getpeername getsockname getsockopt
97 listen recv send recvfrom sendto setsockopt shutdown accept4]) 98 listen recv send recvfrom sendto setsockopt shutdown accept4])
99
100 AC_REQUIRE([AC_C_RESTRICT])
98]) 101])
99 102
100AC_DEFUN([gl_PREREQ_SYS_H_SOCKET], 103AC_DEFUN([gl_PREREQ_SYS_H_SOCKET],
@@ -104,17 +107,11 @@ AC_DEFUN([gl_PREREQ_SYS_H_SOCKET],
104 gl_CHECK_NEXT_HEADERS([sys/socket.h]) 107 gl_CHECK_NEXT_HEADERS([sys/socket.h])
105 if test $ac_cv_header_sys_socket_h = yes; then 108 if test $ac_cv_header_sys_socket_h = yes; then
106 HAVE_SYS_SOCKET_H=1 109 HAVE_SYS_SOCKET_H=1
107 HAVE_WS2TCPIP_H=0
108 else 110 else
109 HAVE_SYS_SOCKET_H=0 111 HAVE_SYS_SOCKET_H=0
110 if test $ac_cv_header_ws2tcpip_h = yes; then
111 HAVE_WS2TCPIP_H=1
112 else
113 HAVE_WS2TCPIP_H=0
114 fi
115 fi 112 fi
116 AC_SUBST([HAVE_SYS_SOCKET_H]) 113 AC_SUBST([HAVE_SYS_SOCKET_H])
117 AC_SUBST([HAVE_WS2TCPIP_H]) 114 gl_PREREQ_SYS_H_WS2TCPIP
118]) 115])
119 116
120# Common prerequisites of the <sys/socket.h> replacement and of the 117# Common prerequisites of the <sys/socket.h> replacement and of the
@@ -142,32 +139,65 @@ AC_DEFUN([gl_PREREQ_SYS_H_WINSOCK2],
142 AC_SUBST([HAVE_WINSOCK2_H]) 139 AC_SUBST([HAVE_WINSOCK2_H])
143]) 140])
144 141
142# Common prerequisites of the <sys/socket.h> replacement and of the
143# <arpa/inet.h> replacement.
144# Sets and substitutes HAVE_WS2TCPIP_H.
145AC_DEFUN([gl_PREREQ_SYS_H_WS2TCPIP],
146[
147 AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])
148 if test $ac_cv_header_sys_socket_h = yes; then
149 HAVE_WS2TCPIP_H=0
150 else
151 if test $ac_cv_header_ws2tcpip_h = yes; then
152 HAVE_WS2TCPIP_H=1
153 else
154 HAVE_WS2TCPIP_H=0
155 fi
156 fi
157 AC_SUBST([HAVE_WS2TCPIP_H])
158])
159
160# gl_SYS_SOCKET_MODULE_INDICATOR([modulename])
161# sets the shell variable that indicates the presence of the given module
162# to a C preprocessor expression that will evaluate to 1.
163# This macro invocation must not occur in macros that are AC_REQUIREd.
145AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR], 164AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR],
146[ 165[
147 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 166 dnl Ensure to expand the default settings once only.
148 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) 167 gl_SYS_SOCKET_H_REQUIRE_DEFAULTS
149 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 168 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
150 dnl Define it also as a C macro, for the benefit of the unit tests. 169 dnl Define it also as a C macro, for the benefit of the unit tests.
151 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 170 gl_MODULE_INDICATOR_FOR_TESTS([$1])
152]) 171])
153 172
173# Initializes the default values for AC_SUBSTed shell variables.
174# This macro must not be AC_REQUIREd. It must only be invoked, and only
175# outside of macros or in macros that are not AC_REQUIREd.
176AC_DEFUN([gl_SYS_SOCKET_H_REQUIRE_DEFAULTS],
177[
178 m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_SOCKET_H_MODULE_INDICATOR_DEFAULTS], [
179 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SOCKET])
180 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CONNECT])
181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCEPT])
182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_BIND])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPEERNAME])
184 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSOCKNAME])
185 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSOCKOPT])
186 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LISTEN])
187 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RECV])
188 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SEND])
189 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RECVFROM])
190 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SENDTO])
191 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETSOCKOPT])
192 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SHUTDOWN])
193 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCEPT4])
194 ])
195 m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_SOCKET_H_MODULE_INDICATOR_DEFAULTS])
196 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS])
197])
198
154AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS], 199AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS],
155[ 200[
156 GNULIB_SOCKET=0; AC_SUBST([GNULIB_SOCKET])
157 GNULIB_CONNECT=0; AC_SUBST([GNULIB_CONNECT])
158 GNULIB_ACCEPT=0; AC_SUBST([GNULIB_ACCEPT])
159 GNULIB_BIND=0; AC_SUBST([GNULIB_BIND])
160 GNULIB_GETPEERNAME=0; AC_SUBST([GNULIB_GETPEERNAME])
161 GNULIB_GETSOCKNAME=0; AC_SUBST([GNULIB_GETSOCKNAME])
162 GNULIB_GETSOCKOPT=0; AC_SUBST([GNULIB_GETSOCKOPT])
163 GNULIB_LISTEN=0; AC_SUBST([GNULIB_LISTEN])
164 GNULIB_RECV=0; AC_SUBST([GNULIB_RECV])
165 GNULIB_SEND=0; AC_SUBST([GNULIB_SEND])
166 GNULIB_RECVFROM=0; AC_SUBST([GNULIB_RECVFROM])
167 GNULIB_SENDTO=0; AC_SUBST([GNULIB_SENDTO])
168 GNULIB_SETSOCKOPT=0; AC_SUBST([GNULIB_SETSOCKOPT])
169 GNULIB_SHUTDOWN=0; AC_SUBST([GNULIB_SHUTDOWN])
170 GNULIB_ACCEPT4=0; AC_SUBST([GNULIB_ACCEPT4])
171 HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE]) 201 HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE])
172 HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1; 202 HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1;
173 AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY]) 203 AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY])
diff --git a/gl/m4/sys_stat_h.m4 b/gl/m4/sys_stat_h.m4
new file mode 100644
index 00000000..ca57398a
--- /dev/null
+++ b/gl/m4/sys_stat_h.m4
@@ -0,0 +1,129 @@
1# sys_stat_h.m4 serial 42 -*- Autoconf -*-
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Eric Blake.
8dnl Provide a GNU-like <sys/stat.h>.
9
10AC_DEFUN_ONCE([gl_SYS_STAT_H],
11[
12 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
13
14 dnl Check for broken stat macros.
15 AC_REQUIRE([AC_HEADER_STAT])
16
17 gl_CHECK_NEXT_HEADERS([sys/stat.h])
18
19 dnl Ensure the type mode_t gets defined.
20 AC_REQUIRE([AC_TYPE_MODE_T])
21
22 dnl Whether to enable precise timestamps in 'struct stat'.
23 m4_ifdef([gl_WINDOWS_STAT_TIMESPEC], [
24 AC_REQUIRE([gl_WINDOWS_STAT_TIMESPEC])
25 ], [
26 WINDOWS_STAT_TIMESPEC=0
27 ])
28 AC_SUBST([WINDOWS_STAT_TIMESPEC])
29
30 dnl Whether to ensure that struct stat.st_size is 64-bit wide.
31 m4_ifdef([gl_LARGEFILE], [
32 AC_REQUIRE([gl_LARGEFILE])
33 ], [
34 WINDOWS_64_BIT_ST_SIZE=0
35 ])
36 AC_SUBST([WINDOWS_64_BIT_ST_SIZE])
37
38 dnl Define types that are supposed to be defined in <sys/types.h> or
39 dnl <sys/stat.h>.
40 AC_CHECK_TYPE([nlink_t], [],
41 [AC_DEFINE([nlink_t], [int],
42 [Define to the type of st_nlink in struct stat, or a supertype.])],
43 [#include <sys/types.h>
44 #include <sys/stat.h>])
45
46 dnl Check for declarations of anything we want to poison if the
47 dnl corresponding gnulib module is not in use.
48 gl_WARN_ON_USE_PREPARE([[#include <sys/stat.h>
49 ]], [chmod fchmodat fstat fstatat futimens getumask lchmod lstat
50 mkdirat mkfifo mkfifoat mknod mknodat stat utimensat])
51
52 AC_REQUIRE([AC_C_RESTRICT])
53])
54
55# gl_SYS_STAT_MODULE_INDICATOR([modulename])
56# sets the shell variable that indicates the presence of the given module
57# to a C preprocessor expression that will evaluate to 1.
58# This macro invocation must not occur in macros that are AC_REQUIREd.
59AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR],
60[
61 dnl Ensure to expand the default settings once only.
62 gl_SYS_STAT_H_REQUIRE_DEFAULTS
63 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
64 dnl Define it also as a C macro, for the benefit of the unit tests.
65 gl_MODULE_INDICATOR_FOR_TESTS([$1])
66])
67
68# Initializes the default values for AC_SUBSTed shell variables.
69# This macro must not be AC_REQUIREd. It must only be invoked, and only
70# outside of macros or in macros that are not AC_REQUIREd.
71AC_DEFUN([gl_SYS_STAT_H_REQUIRE_DEFAULTS],
72[
73 m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_STAT_H_MODULE_INDICATOR_DEFAULTS], [
74 gl_UNISTD_H_REQUIRE_DEFAULTS dnl for REPLACE_FCHDIR
75 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHMOD])
76 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHMODAT])
77 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTAT])
78 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTATAT])
79 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FUTIMENS])
80 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETUMASK])
81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LCHMOD])
82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LSTAT])
83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDIR])
84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDIRAT])
85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKFIFO])
86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKFIFOAT])
87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKNOD])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKNODAT])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STAT])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UTIMENSAT])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OVERRIDES_STRUCT_STAT])
92 dnl Support Microsoft deprecated alias function names by default.
93 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CHMOD], [1])
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MKDIR], [1])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_UMASK], [1])
96 ])
97 m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_STAT_H_MODULE_INDICATOR_DEFAULTS])
98 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
99])
100
101AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
102[
103 dnl Assume proper GNU behavior unless another module says otherwise.
104 HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT])
105 HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT])
106 HAVE_FUTIMENS=1; AC_SUBST([HAVE_FUTIMENS])
107 HAVE_GETUMASK=1; AC_SUBST([HAVE_GETUMASK])
108 HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD])
109 HAVE_LSTAT=1; AC_SUBST([HAVE_LSTAT])
110 HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT])
111 HAVE_MKFIFO=1; AC_SUBST([HAVE_MKFIFO])
112 HAVE_MKFIFOAT=1; AC_SUBST([HAVE_MKFIFOAT])
113 HAVE_MKNOD=1; AC_SUBST([HAVE_MKNOD])
114 HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT])
115 HAVE_UTIMENSAT=1; AC_SUBST([HAVE_UTIMENSAT])
116 REPLACE_CHMOD=0; AC_SUBST([REPLACE_CHMOD])
117 REPLACE_FCHMODAT=0; AC_SUBST([REPLACE_FCHMODAT])
118 REPLACE_FSTAT=0; AC_SUBST([REPLACE_FSTAT])
119 REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT])
120 REPLACE_FUTIMENS=0; AC_SUBST([REPLACE_FUTIMENS])
121 REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT])
122 REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR])
123 REPLACE_MKFIFO=0; AC_SUBST([REPLACE_MKFIFO])
124 REPLACE_MKFIFOAT=0; AC_SUBST([REPLACE_MKFIFOAT])
125 REPLACE_MKNOD=0; AC_SUBST([REPLACE_MKNOD])
126 REPLACE_MKNODAT=0; AC_SUBST([REPLACE_MKNODAT])
127 REPLACE_STAT=0; AC_SUBST([REPLACE_STAT])
128 REPLACE_UTIMENSAT=0; AC_SUBST([REPLACE_UTIMENSAT])
129])
diff --git a/gl/m4/sys_types_h.m4 b/gl/m4/sys_types_h.m4
index d15c1b37..627671fb 100644
--- a/gl/m4/sys_types_h.m4
+++ b/gl/m4/sys_types_h.m4
@@ -1,5 +1,5 @@
1# sys_types_h.m4 serial 5 1# sys_types_h.m4 serial 13
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,6 +7,10 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN_ONCE([gl_SYS_TYPES_H], 7AC_DEFUN_ONCE([gl_SYS_TYPES_H],
8[ 8[
9 AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS]) 9 AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS])
10
11 dnl Use sane struct stat types in OpenVMS 8.2 and later.
12 AC_DEFINE([_USE_STD_STAT], 1, [For standard stat data types on VMS.])
13
10 gl_NEXT_HEADERS([sys/types.h]) 14 gl_NEXT_HEADERS([sys/types.h])
11 15
12 dnl Ensure the type pid_t gets defined. 16 dnl Ensure the type pid_t gets defined.
@@ -17,8 +21,50 @@ AC_DEFUN_ONCE([gl_SYS_TYPES_H],
17 21
18 dnl Whether to override the 'off_t' type. 22 dnl Whether to override the 'off_t' type.
19 AC_REQUIRE([gl_TYPE_OFF_T]) 23 AC_REQUIRE([gl_TYPE_OFF_T])
24
25 dnl Whether to override the 'dev_t' and 'ino_t' types.
26 m4_ifdef([gl_WINDOWS_STAT_INODES], [
27 AC_REQUIRE([gl_WINDOWS_STAT_INODES])
28 ], [
29 WINDOWS_STAT_INODES=0
30 ])
31 AC_SUBST([WINDOWS_STAT_INODES])
32])
33
34# Initializes the default values for AC_SUBSTed shell variables.
35# This macro must not be AC_REQUIREd. It must only be invoked, and only
36# outside of macros or in macros that are not AC_REQUIREd.
37AC_DEFUN([gl_SYS_TYPES_H_REQUIRE_DEFAULTS],
38[
39 m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_TYPE_H_MODULE_INDICATOR_DEFAULTS], [
40 ])
41 m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_TYPE_H_MODULE_INDICATOR_DEFAULTS])
42 AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS])
20]) 43])
21 44
22AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS], 45AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS],
23[ 46[
24]) 47])
48
49# This works around a buggy version in autoconf <= 2.69.
50# See <https://lists.gnu.org/r/autoconf/2016-08/msg00014.html>
51# The 2.70 version isn't quoted properly, so override it too.
52
53m4_version_prereq([2.70.1], [], [
54
55m4_undefine([AC_HEADER_MAJOR])
56AC_DEFUN([AC_HEADER_MAJOR],
57[AC_CHECK_HEADERS_ONCE([sys/types.h])
58AC_CHECK_HEADER([sys/mkdev.h],
59 [AC_DEFINE([MAJOR_IN_MKDEV], [1],
60 [Define to 1 if `major', `minor', and `makedev' are
61 declared in <mkdev.h>.])])
62if test $ac_cv_header_sys_mkdev_h = no; then
63 AC_CHECK_HEADER([sys/sysmacros.h],
64 [AC_DEFINE([MAJOR_IN_SYSMACROS], [1],
65 [Define to 1 if `major', `minor', and `makedev'
66 are declared in <sysmacros.h>.])])
67fi
68])# AC_HEADER_MAJOR
69
70])
diff --git a/gl/m4/sys_uio_h.m4 b/gl/m4/sys_uio_h.m4
index c75cbbd0..93a65d26 100644
--- a/gl/m4/sys_uio_h.m4
+++ b/gl/m4/sys_uio_h.m4
@@ -1,10 +1,10 @@
1# sys_uio_h.m4 serial 1 1# sys_uio_h.m4 serial 3
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_HEADER_SYS_UIO], 7AC_DEFUN_ONCE([gl_SYS_UIO_H],
8[ 8[
9 AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS]) 9 AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS])
10 dnl <sys/uio.h> is always overridden, because of GNULIB_POSIXCHECK. 10 dnl <sys/uio.h> is always overridden, because of GNULIB_POSIXCHECK.
@@ -17,15 +17,30 @@ AC_DEFUN([gl_HEADER_SYS_UIO],
17 AC_SUBST([HAVE_SYS_UIO_H]) 17 AC_SUBST([HAVE_SYS_UIO_H])
18]) 18])
19 19
20# gl_SYS_UIO_MODULE_INDICATOR([modulename])
21# sets the shell variable that indicates the presence of the given module
22# to a C preprocessor expression that will evaluate to 1.
23# This macro invocation must not occur in macros that are AC_REQUIREd.
20AC_DEFUN([gl_SYS_UIO_MODULE_INDICATOR], 24AC_DEFUN([gl_SYS_UIO_MODULE_INDICATOR],
21[ 25[
22 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 26 dnl Ensure to expand the default settings once only.
23 AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS]) 27 gl_SYS_UIO_H_REQUIRE_DEFAULTS
24 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 28 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
25 dnl Define it also as a C macro, for the benefit of the unit tests. 29 dnl Define it also as a C macro, for the benefit of the unit tests.
26 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 30 gl_MODULE_INDICATOR_FOR_TESTS([$1])
27]) 31])
28 32
33# Initializes the default values for AC_SUBSTed shell variables.
34# This macro must not be AC_REQUIREd. It must only be invoked, and only
35# outside of macros or in macros that are not AC_REQUIREd.
36AC_DEFUN([gl_SYS_UIO_H_REQUIRE_DEFAULTS],
37[
38 m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_UIO_H_MODULE_INDICATOR_DEFAULTS], [
39 ])
40 m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_UIO_H_MODULE_INDICATOR_DEFAULTS])
41 AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS])
42])
43
29AC_DEFUN([gl_SYS_UIO_H_DEFAULTS], 44AC_DEFUN([gl_SYS_UIO_H_DEFAULTS],
30[ 45[
31]) 46])
diff --git a/gl/m4/threadlib.m4 b/gl/m4/threadlib.m4
index 26bdeb58..b536b047 100644
--- a/gl/m4/threadlib.m4
+++ b/gl/m4/threadlib.m4
@@ -1,11 +1,390 @@
1# threadlib.m4 serial 10 (gettext-0.18.2) 1# threadlib.m4 serial 32a
2dnl Copyright (C) 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Bruno Haible. 7dnl From Bruno Haible.
8 8
9AC_PREREQ([2.60])
10
11dnl The general structure of the multithreading modules in gnulib is that we
12dnl have three set of modules:
13dnl
14dnl * POSIX API:
15dnl pthread, which combines
16dnl pthread-h
17dnl pthread-thread
18dnl pthread-once
19dnl pthread-mutex
20dnl pthread-rwlock
21dnl pthread-cond
22dnl pthread-tss
23dnl pthread-spin
24dnl sched_yield
25dnl
26dnl * ISO C API:
27dnl threads, which combines
28dnl threads-h
29dnl thrd
30dnl mtx
31dnl cnd
32dnl tss
33dnl
34dnl * Gnulib API, with an implementation that can be chosen at configure
35dnl time through the option --enable-threads=...
36dnl thread
37dnl lock
38dnl cond
39dnl tls
40dnl yield
41dnl
42dnl They are independent, except for the fact that
43dnl - the implementation of the ISO C API may use the POSIX (or some other
44dnl platform dependent) API,
45dnl - the implementation of the Gnulib API may use the POSIX or ISO C or
46dnl some other platform dependent API, depending on the --enable-threads
47dnl option.
48dnl
49dnl This file contains macros for all of these APIs!
50
51dnl ============================================================================
52dnl Macros for all thread APIs
53
54AC_DEFUN([gl_ANYTHREADLIB_EARLY],
55[
56 AC_REQUIRE([AC_CANONICAL_HOST])
57 if test -z "$gl_anythreadlib_early_done"; then
58 case "$host_os" in
59 osf*)
60 # On OSF/1, the compiler needs the flag -D_REENTRANT so that it
61 # groks <pthread.h>. cc also understands the flag -pthread, but
62 # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
63 # 2. putting a flag into CPPFLAGS that has an effect on the linker
64 # causes the AC_LINK_IFELSE test below to succeed unexpectedly,
65 # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
66 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
67 ;;
68 esac
69 # Some systems optimize for single-threaded programs by default, and
70 # need special flags to disable these optimizations. For example, the
71 # definition of 'errno' in <errno.h>.
72 case "$host_os" in
73 aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
74 solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
75 esac
76 gl_anythreadlib_early_done=done
77 fi
78])
79
80dnl Checks whether the compiler and linker support weak declarations of symbols.
81
82AC_DEFUN([gl_WEAK_SYMBOLS],
83[
84 AC_REQUIRE([AC_CANONICAL_HOST])
85 AC_CACHE_CHECK([whether imported symbols can be declared weak],
86 [gl_cv_have_weak],
87 [case "$host_os" in
88 cygwin*)
89 dnl On Cygwin 3.2.0 with gcc 10.2, the test below would succeed, but
90 dnl programs that use pthread_in_use() with weak symbol references
91 dnl crash miserably at runtime.
92 gl_cv_have_weak="guessing no"
93 ;;
94 *)
95 gl_cv_have_weak=no
96 dnl First, test whether the compiler accepts it syntactically.
97 AC_LINK_IFELSE(
98 [AC_LANG_PROGRAM(
99 [[extern void xyzzy ();
100#pragma weak xyzzy]],
101 [[xyzzy();]])],
102 [gl_cv_have_weak=maybe])
103 if test $gl_cv_have_weak = maybe; then
104 dnl Second, test whether it actually works. On Cygwin 1.7.2, with
105 dnl gcc 4.3, symbols declared weak always evaluate to the address 0.
106 AC_RUN_IFELSE(
107 [AC_LANG_SOURCE([[
108#include <stdio.h>
109#pragma weak fputs
110int main ()
111{
112 return (fputs == NULL);
113}]])],
114 [gl_cv_have_weak=yes],
115 [gl_cv_have_weak=no],
116 [dnl When cross-compiling, assume that only ELF platforms support
117 dnl weak symbols.
118 AC_EGREP_CPP([Extensible Linking Format],
119 [#ifdef __ELF__
120 Extensible Linking Format
121 #endif
122 ],
123 [gl_cv_have_weak="guessing yes"],
124 [gl_cv_have_weak="guessing no"])
125 ])
126 fi
127 ;;
128 esac
129 dnl But when linking statically, weak symbols don't work.
130 case " $LDFLAGS " in
131 *" -static "*) gl_cv_have_weak=no ;;
132 esac
133 dnl Test for a bug in FreeBSD 11: A link error occurs when using a weak
134 dnl symbol and linking against a shared library that has a dependency on
135 dnl the shared library that defines the symbol.
136 case "$gl_cv_have_weak" in
137 *yes)
138 case "$host_os" in
139 freebsd* | dragonfly* | midnightbsd*)
140 : > conftest1.c
141 $CC $CPPFLAGS $CFLAGS $LDFLAGS -fPIC -shared -o libempty.so conftest1.c -lpthread >&AS_MESSAGE_LOG_FD 2>&1
142 cat <<EOF > conftest2.c
143#include <pthread.h>
144#pragma weak pthread_mutexattr_gettype
145int main ()
146{
147 return (pthread_mutexattr_gettype != NULL);
148}
149EOF
150 $CC $CPPFLAGS $CFLAGS $LDFLAGS -o conftest conftest2.c libempty.so >&AS_MESSAGE_LOG_FD 2>&1 \
151 || gl_cv_have_weak=no
152 rm -f conftest1.c libempty.so conftest2.c conftest
153 ;;
154 esac
155 ;;
156 esac
157 ])
158 case "$gl_cv_have_weak" in
159 *yes)
160 AC_DEFINE([HAVE_WEAK_SYMBOLS], [1],
161 [Define to 1 if the compiler and linker support weak declarations of symbols.])
162 ;;
163 esac
164])
165
166dnl ============================================================================
167dnl Macros for the POSIX API
168
169dnl gl_PTHREADLIB
170dnl -------------
171dnl Tests for the libraries needs for using the POSIX threads API.
172dnl Sets the variable LIBPTHREAD to the linker options for use in a Makefile.
173dnl Sets the variable LIBPMULTITHREAD, for programs that really need
174dnl multithread functionality. The difference between LIBPTHREAD and
175dnl LIBPMULTITHREAD is that on platforms supporting weak symbols, typically
176dnl LIBPTHREAD is empty whereas LIBPMULTITHREAD is not.
177dnl Sets the variable LIB_SCHED_YIELD to the linker options needed to use the
178dnl sched_yield() function.
179dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
180dnl multithread-safe programs.
181dnl Defines the C macro HAVE_PTHREAD_API if (at least parts of) the POSIX
182dnl threads API is available.
183
184dnl The guts of gl_PTHREADLIB. Needs to be expanded only once.
185
186AC_DEFUN([gl_PTHREADLIB_BODY],
187[
188 AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
189 if test -z "$gl_pthreadlib_body_done"; then
190 gl_pthread_api=no
191 LIBPTHREAD=
192 LIBPMULTITHREAD=
193 # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
194 # it groks <pthread.h>. It's added above, in gl_ANYTHREADLIB_EARLY.
195 AC_CHECK_HEADER([pthread.h],
196 [gl_have_pthread_h=yes], [gl_have_pthread_h=no])
197 if test "$gl_have_pthread_h" = yes; then
198 # Other possible tests:
199 # -lpthreads (FSU threads, PCthreads)
200 # -lgthreads
201 # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
202 # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
203 # the second one only in libpthread, and lock.c needs it.
204 #
205 # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04
206 # needs -pthread for some reason. See:
207 # https://lists.gnu.org/r/bug-gnulib/2014-09/msg00023.html
208 save_LIBS=$LIBS
209 for gl_pthread in '' '-pthread'; do
210 LIBS="$LIBS $gl_pthread"
211 AC_LINK_IFELSE(
212 [AC_LANG_PROGRAM(
213 [[#include <pthread.h>
214 pthread_mutex_t m;
215 pthread_mutexattr_t ma;
216 ]],
217 [[pthread_mutex_lock (&m);
218 pthread_mutexattr_init (&ma);]])],
219 [gl_pthread_api=yes
220 LIBPTHREAD=$gl_pthread
221 LIBPMULTITHREAD=$gl_pthread])
222 LIBS=$save_LIBS
223 test $gl_pthread_api = yes && break
224 done
225 echo "$as_me:__oline__: gl_pthread_api=$gl_pthread_api" >&AS_MESSAGE_LOG_FD
226 echo "$as_me:__oline__: LIBPTHREAD=$LIBPTHREAD" >&AS_MESSAGE_LOG_FD
227
228 gl_pthread_in_glibc=no
229 # On Linux with glibc >= 2.34, libc contains the fully functional
230 # pthread functions.
231 case "$host_os" in
232 linux*)
233 AC_EGREP_CPP([Lucky user],
234 [#include <features.h>
235 #ifdef __GNU_LIBRARY__
236 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 34) || (__GLIBC__ > 2)
237 Lucky user
238 #endif
239 #endif
240 ],
241 [gl_pthread_in_glibc=yes],
242 [])
243 ;;
244 esac
245 echo "$as_me:__oline__: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&AS_MESSAGE_LOG_FD
246
247 # Test for libpthread by looking for pthread_kill. (Not pthread_self,
248 # since it is defined as a macro on OSF/1.)
249 if test $gl_pthread_api = yes && test -z "$LIBPTHREAD"; then
250 # The program links fine without libpthread. But it may actually
251 # need to link with libpthread in order to create multiple threads.
252 AC_CHECK_LIB([pthread], [pthread_kill],
253 [if test $gl_pthread_in_glibc = yes; then
254 LIBPMULTITHREAD=
255 else
256 LIBPMULTITHREAD=-lpthread
257 # On Solaris and HP-UX, most pthread functions exist also in libc.
258 # Therefore pthread_in_use() needs to actually try to create a
259 # thread: pthread_create from libc will fail, whereas
260 # pthread_create will actually create a thread.
261 # On Solaris 10 or newer, this test is no longer needed, because
262 # libc contains the fully functional pthread functions.
263 case "$host_os" in
264changequote(,)dnl
265 solaris | solaris2.[1-9] | solaris2.[1-9].* | hpux*)
266changequote([,])dnl
267 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
268 [Define if the pthread_in_use() detection is hard.])
269 esac
270 fi
271 ])
272 elif test $gl_pthread_api != yes; then
273 # Some library is needed. Try libpthread and libc_r.
274 AC_CHECK_LIB([pthread], [pthread_kill],
275 [gl_pthread_api=yes
276 LIBPTHREAD=-lpthread
277 LIBPMULTITHREAD=-lpthread])
278 if test $gl_pthread_api != yes; then
279 # For FreeBSD 4.
280 AC_CHECK_LIB([c_r], [pthread_kill],
281 [gl_pthread_api=yes
282 LIBPTHREAD=-lc_r
283 LIBPMULTITHREAD=-lc_r])
284 fi
285 fi
286 echo "$as_me:__oline__: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&AS_MESSAGE_LOG_FD
287 fi
288 AC_MSG_CHECKING([whether POSIX threads API is available])
289 AC_MSG_RESULT([$gl_pthread_api])
290 AC_SUBST([LIBPTHREAD])
291 AC_SUBST([LIBPMULTITHREAD])
292 if test $gl_pthread_api = yes; then
293 AC_DEFINE([HAVE_PTHREAD_API], [1],
294 [Define if you have the <pthread.h> header and the POSIX threads API.])
295 fi
296
297 dnl On some systems, sched_yield is in librt, rather than in libpthread.
298 AC_LINK_IFELSE(
299 [AC_LANG_PROGRAM(
300 [[#include <sched.h>]],
301 [[sched_yield ();]])],
302 [LIB_SCHED_YIELD=
303 ],
304 [dnl Solaris 7...10 has sched_yield in librt, not in libpthread or libc.
305 AC_CHECK_LIB([rt], [sched_yield], [LIB_SCHED_YIELD=-lrt],
306 [dnl Solaris 2.5.1, 2.6 has sched_yield in libposix4, not librt.
307 AC_CHECK_LIB([posix4], [sched_yield], [LIB_SCHED_YIELD=-lposix4])])
308 ])
309 AC_SUBST([LIB_SCHED_YIELD])
310
311 gl_pthreadlib_body_done=done
312 fi
313])
314
315AC_DEFUN([gl_PTHREADLIB],
316[
317 AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
318 gl_PTHREADLIB_BODY
319])
320
321dnl ============================================================================
322dnl Macros for the ISO C API
323
324dnl gl_STDTHREADLIB
325dnl ---------------
326dnl Tests for the libraries needs for using the ISO C threads API.
327dnl Sets the variable LIBSTDTHREAD to the linker options for use in a Makefile.
328dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
329dnl multithread-safe programs.
330dnl Defines the C macro HAVE_THREADS_H if (at least parts of) the ISO C threads
331dnl API is available.
332
333dnl The guts of gl_STDTHREADLIB. Needs to be expanded only once.
334
335AC_DEFUN([gl_STDTHREADLIB_BODY],
336[
337 AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
338 AC_REQUIRE([AC_CANONICAL_HOST])
339 if test -z "$gl_stdthreadlib_body_done"; then
340 AC_CHECK_HEADERS_ONCE([threads.h])
341
342 case "$host_os" in
343 mingw*)
344 LIBSTDTHREAD=
345 ;;
346 *)
347 gl_PTHREADLIB_BODY
348 if test $ac_cv_header_threads_h = yes; then
349 dnl glibc >= 2.29 has thrd_create in libpthread.
350 dnl FreeBSD >= 10 has thrd_create in libstdthreads; this library depends
351 dnl on libpthread (for the symbol 'pthread_mutexattr_gettype').
352 dnl glibc >= 2.34, AIX >= 7.1, and Solaris >= 11.4 have thrd_create in
353 dnl libc.
354 AC_CHECK_FUNCS([thrd_create])
355 if test $ac_cv_func_thrd_create = yes; then
356 LIBSTDTHREAD=
357 else
358 AC_CHECK_LIB([stdthreads], [thrd_create], [
359 LIBSTDTHREAD='-lstdthreads -lpthread'
360 ], [
361 dnl Guess that thrd_create is in libpthread.
362 LIBSTDTHREAD="$LIBPMULTITHREAD"
363 ])
364 fi
365 else
366 dnl Libraries needed by thrd.c, mtx.c, cnd.c, tss.c.
367 LIBSTDTHREAD="$LIBPMULTITHREAD $LIB_SCHED_YIELD"
368 fi
369 ;;
370 esac
371 AC_SUBST([LIBSTDTHREAD])
372
373 AC_MSG_CHECKING([whether ISO C threads API is available])
374 AC_MSG_RESULT([$ac_cv_header_threads_h])
375 gl_stdthreadlib_body_done=done
376 fi
377])
378
379AC_DEFUN([gl_STDTHREADLIB],
380[
381 AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
382 gl_STDTHREADLIB_BODY
383])
384
385dnl ============================================================================
386dnl Macros for the Gnulib API
387
9dnl gl_THREADLIB 388dnl gl_THREADLIB
10dnl ------------ 389dnl ------------
11dnl Tests for a multithreading library to be used. 390dnl Tests for a multithreading library to be used.
@@ -14,17 +393,25 @@ dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the
14dnl default is 'no', otherwise it is system dependent. In both cases, the user 393dnl default is 'no', otherwise it is system dependent. In both cases, the user
15dnl can change the choice through the options --enable-threads=choice or 394dnl can change the choice through the options --enable-threads=choice or
16dnl --disable-threads. 395dnl --disable-threads.
17dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, 396dnl Defines at most one of the macros USE_ISOC_THREADS, USE_POSIX_THREADS,
18dnl USE_PTH_THREADS, USE_WINDOWS_THREADS 397dnl USE_ISOC_AND_POSIX_THREADS, USE_WINDOWS_THREADS.
398dnl The choice --enable-threads=isoc+posix is available only on platforms that
399dnl have both the ISO C and the POSIX threads APIs. It has the effect of using
400dnl the ISO C API for most things and the POSIX API only for creating and
401dnl controlling threads (because there is no equivalent to pthread_atfork in
402dnl the ISO C API).
19dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use 403dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use
20dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with 404dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with
21dnl libtool). 405dnl libtool).
22dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for 406dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for
23dnl programs that really need multithread functionality. The difference 407dnl programs that really need multithread functionality. The difference
24dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak 408dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak
25dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread". 409dnl symbols, typically LIBTHREAD is empty whereas LIBMULTITHREAD is not.
26dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for 410dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
27dnl multithread-safe programs. 411dnl multithread-safe programs.
412dnl Since support for GNU pth was removed, $LTLIBTHREAD and $LIBTHREAD have the
413dnl same value, and similarly $LTLIBMULTITHREAD and $LIBMULTITHREAD have the
414dnl same value. Only system libraries are needed.
28 415
29AC_DEFUN([gl_THREADLIB_EARLY], 416AC_DEFUN([gl_THREADLIB_EARLY],
30[ 417[
@@ -43,18 +430,15 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY],
43 430
44 AC_REQUIRE([AC_CANONICAL_HOST]) 431 AC_REQUIRE([AC_CANONICAL_HOST])
45 dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems. 432 dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems.
46 dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes 433 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
47 dnl AC_GNU_SOURCE.
48 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
49 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
50 [AC_REQUIRE([AC_GNU_SOURCE])])
51 dnl Check for multithreading. 434 dnl Check for multithreading.
52 m4_ifdef([gl_THREADLIB_DEFAULT_NO], 435 m4_ifdef([gl_THREADLIB_DEFAULT_NO],
53 [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], 436 [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])],
54 [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) 437 [m4_divert_text([DEFAULTS], [gl_use_threads_default=])])
438 m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=])
55 AC_ARG_ENABLE([threads], 439 AC_ARG_ENABLE([threads],
56AC_HELP_STRING([--enable-threads={posix|solaris|pth|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ 440AS_HELP_STRING([--enable-threads={isoc|posix|isoc+posix|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [
57AC_HELP_STRING([--disable-threads], [build without multithread safety])]), 441AS_HELP_STRING([--disable-threads], [build without multithread safety])]),
58 [gl_use_threads=$enableval], 442 [gl_use_threads=$enableval],
59 [if test -n "$gl_use_threads_default"; then 443 [if test -n "$gl_use_threads_default"; then
60 gl_use_threads="$gl_use_threads_default" 444 gl_use_threads="$gl_use_threads_default"
@@ -64,41 +448,35 @@ changequote(,)dnl
64 dnl Disable multithreading by default on OSF/1, because it interferes 448 dnl Disable multithreading by default on OSF/1, because it interferes
65 dnl with fork()/exec(): When msgexec is linked with -lpthread, its 449 dnl with fork()/exec(): When msgexec is linked with -lpthread, its
66 dnl child process gets an endless segmentation fault inside execvp(). 450 dnl child process gets an endless segmentation fault inside execvp().
451 osf*) gl_use_threads=no ;;
67 dnl Disable multithreading by default on Cygwin 1.5.x, because it has 452 dnl Disable multithreading by default on Cygwin 1.5.x, because it has
68 dnl bugs that lead to endless loops or crashes. See 453 dnl bugs that lead to endless loops or crashes. See
69 dnl <http://cygwin.com/ml/cygwin/2009-08/msg00283.html>. 454 dnl <https://cygwin.com/ml/cygwin/2009-08/msg00283.html>.
70 osf*) gl_use_threads=no ;;
71 cygwin*) 455 cygwin*)
72 case `uname -r` in 456 case `uname -r` in
73 1.[0-5].*) gl_use_threads=no ;; 457 1.[0-5].*) gl_use_threads=no ;;
74 *) gl_use_threads=yes ;; 458 *) gl_use_threads=yes ;;
75 esac 459 esac
76 ;; 460 ;;
461 dnl Obey gl_AVOID_WINPTHREAD on mingw.
462 mingw*)
463 case "$gl_use_winpthreads_default" in
464 yes) gl_use_threads=posix ;;
465 no) gl_use_threads=windows ;;
466 *) gl_use_threads=yes ;;
467 esac
468 ;;
77 *) gl_use_threads=yes ;; 469 *) gl_use_threads=yes ;;
78 esac 470 esac
79changequote([,])dnl 471changequote([,])dnl
80 fi 472 fi
81 ]) 473 ])
82 if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then 474 if test "$gl_use_threads" = yes \
83 # For using <pthread.h>: 475 || test "$gl_use_threads" = isoc \
84 case "$host_os" in 476 || test "$gl_use_threads" = posix \
85 osf*) 477 || test "$gl_use_threads" = isoc+posix; then
86 # On OSF/1, the compiler needs the flag -D_REENTRANT so that it 478 # For using <threads.h> or <pthread.h>:
87 # groks <pthread.h>. cc also understands the flag -pthread, but 479 gl_ANYTHREADLIB_EARLY
88 # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
89 # 2. putting a flag into CPPFLAGS that has an effect on the linker
90 # causes the AC_LINK_IFELSE test below to succeed unexpectedly,
91 # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
92 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
93 ;;
94 esac
95 # Some systems optimize for single-threaded programs by default, and
96 # need special flags to disable these optimizations. For example, the
97 # definition of 'errno' in <errno.h>.
98 case "$host_os" in
99 aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
100 solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
101 esac
102 fi 480 fi
103]) 481])
104 482
@@ -114,168 +492,69 @@ AC_DEFUN([gl_THREADLIB_BODY],
114 LTLIBMULTITHREAD= 492 LTLIBMULTITHREAD=
115 if test "$gl_use_threads" != no; then 493 if test "$gl_use_threads" != no; then
116 dnl Check whether the compiler and linker support weak declarations. 494 dnl Check whether the compiler and linker support weak declarations.
117 AC_CACHE_CHECK([whether imported symbols can be declared weak], 495 gl_WEAK_SYMBOLS
118 [gl_cv_have_weak], 496 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
119 [gl_cv_have_weak=no 497 dnl If we use weak symbols to implement pthread_in_use / pth_in_use /
120 dnl First, test whether the compiler accepts it syntactically. 498 dnl thread_in_use, we also need to test whether the ISO C 11 thrd_create
121 AC_LINK_IFELSE( 499 dnl facility is in use.
122 [AC_LANG_PROGRAM( 500 AC_CHECK_HEADERS_ONCE([threads.h])
123 [[extern void xyzzy (); 501 :
124#pragma weak xyzzy]], 502 fi
125 [[xyzzy();]])], 503 if test "$gl_use_threads" = isoc || test "$gl_use_threads" = isoc+posix; then
126 [gl_cv_have_weak=maybe]) 504 AC_CHECK_HEADERS_ONCE([threads.h])
127 if test $gl_cv_have_weak = maybe; then 505 gl_have_isoc_threads="$ac_cv_header_threads_h"
128 dnl Second, test whether it actually works. On Cygwin 1.7.2, with 506 fi
129 dnl gcc 4.3, symbols declared weak always evaluate to the address 0. 507 if test "$gl_use_threads" = yes \
130 AC_RUN_IFELSE( 508 || test "$gl_use_threads" = posix \
131 [AC_LANG_SOURCE([[ 509 || test "$gl_use_threads" = isoc+posix; then
132#include <stdio.h> 510 gl_PTHREADLIB_BODY
133#pragma weak fputs 511 LIBTHREAD=$LIBPTHREAD LTLIBTHREAD=$LIBPTHREAD
134int main () 512 LIBMULTITHREAD=$LIBPMULTITHREAD LTLIBMULTITHREAD=$LIBPMULTITHREAD
135{ 513 if test $gl_pthread_api = yes; then
136 return (fputs == NULL); 514 if test "$gl_use_threads" = isoc+posix && test "$gl_have_isoc_threads" = yes; then
137}]])], 515 gl_threads_api='isoc+posix'
138 [gl_cv_have_weak=yes], 516 AC_DEFINE([USE_ISOC_AND_POSIX_THREADS], [1],
139 [gl_cv_have_weak=no], 517 [Define if the combination of the ISO C and POSIX multithreading APIs can be used.])
140 [dnl When cross-compiling, assume that only ELF platforms support 518 LIBTHREAD= LTLIBTHREAD=
141 dnl weak symbols.
142 AC_EGREP_CPP([Extensible Linking Format],
143 [#ifdef __ELF__
144 Extensible Linking Format
145 #endif
146 ],
147 [gl_cv_have_weak="guessing yes"],
148 [gl_cv_have_weak="guessing no"])
149 ])
150 fi
151 ])
152 if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
153 # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
154 # it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY.
155 AC_CHECK_HEADER([pthread.h],
156 [gl_have_pthread_h=yes], [gl_have_pthread_h=no])
157 if test "$gl_have_pthread_h" = yes; then
158 # Other possible tests:
159 # -lpthreads (FSU threads, PCthreads)
160 # -lgthreads
161 gl_have_pthread=
162 # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
163 # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
164 # the second one only in libpthread, and lock.c needs it.
165 AC_LINK_IFELSE(
166 [AC_LANG_PROGRAM(
167 [[#include <pthread.h>]],
168 [[pthread_mutex_lock((pthread_mutex_t*)0);
169 pthread_mutexattr_init((pthread_mutexattr_t*)0);]])],
170 [gl_have_pthread=yes])
171 # Test for libpthread by looking for pthread_kill. (Not pthread_self,
172 # since it is defined as a macro on OSF/1.)
173 if test -n "$gl_have_pthread"; then
174 # The program links fine without libpthread. But it may actually
175 # need to link with libpthread in order to create multiple threads.
176 AC_CHECK_LIB([pthread], [pthread_kill],
177 [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread
178 # On Solaris and HP-UX, most pthread functions exist also in libc.
179 # Therefore pthread_in_use() needs to actually try to create a
180 # thread: pthread_create from libc will fail, whereas
181 # pthread_create will actually create a thread.
182 case "$host_os" in
183 solaris* | hpux*)
184 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
185 [Define if the pthread_in_use() detection is hard.])
186 esac
187 ])
188 else 519 else
189 # Some library is needed. Try libpthread and libc_r.
190 AC_CHECK_LIB([pthread], [pthread_kill],
191 [gl_have_pthread=yes
192 LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread
193 LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread])
194 if test -z "$gl_have_pthread"; then
195 # For FreeBSD 4.
196 AC_CHECK_LIB([c_r], [pthread_kill],
197 [gl_have_pthread=yes
198 LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r
199 LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r])
200 fi
201 fi
202 if test -n "$gl_have_pthread"; then
203 gl_threads_api=posix 520 gl_threads_api=posix
204 AC_DEFINE([USE_POSIX_THREADS], [1], 521 AC_DEFINE([USE_POSIX_THREADS], [1],
205 [Define if the POSIX multithreading library can be used.]) 522 [Define if the POSIX multithreading library can be used.])
206 if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then 523 if test -z "$LIBMULTITHREAD" && test -z "$LTLIBMULTITHREAD"; then
524 AC_DEFINE([USE_POSIX_THREADS_FROM_LIBC], [1],
525 [Define if references to the POSIX multithreading library are satisfied by libc.])
526 else
207 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then 527 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
208 AC_DEFINE([USE_POSIX_THREADS_WEAK], [1], 528 AC_DEFINE([USE_POSIX_THREADS_WEAK], [1],
209 [Define if references to the POSIX multithreading library should be made weak.]) 529 [Define if references to the POSIX multithreading library should be made weak.])
210 LIBTHREAD= 530 LIBTHREAD= LTLIBTHREAD=
211 LTLIBTHREAD= 531 else
532 case "$host_os" in
533 freebsd* | dragonfly* | midnightbsd*)
534 if test "x$LIBTHREAD" != "x$LIBMULTITHREAD"; then
535 dnl If weak symbols can't tell whether pthread_create(), pthread_key_create()
536 dnl etc. will succeed, we need a runtime test.
537 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
538 [Define if the pthread_in_use() detection is hard.])
539 fi
540 ;;
541 esac
212 fi 542 fi
213 fi 543 fi
214 fi 544 fi
215 fi 545 fi
216 fi 546 fi
217 if test -z "$gl_have_pthread"; then 547 if test $gl_threads_api = none; then
218 if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then 548 if test "$gl_use_threads" = isoc && test "$gl_have_isoc_threads" = yes; then
219 gl_have_solaristhread= 549 gl_STDTHREADLIB_BODY
220 gl_save_LIBS="$LIBS" 550 LIBTHREAD=$LIBSTDTHREAD LTLIBTHREAD=$LIBSTDTHREAD
221 LIBS="$LIBS -lthread" 551 LIBMULTITHREAD=$LIBSTDTHREAD LTLIBMULTITHREAD=$LIBSTDTHREAD
222 AC_LINK_IFELSE( 552 gl_threads_api=isoc
223 [AC_LANG_PROGRAM( 553 AC_DEFINE([USE_ISOC_THREADS], [1],
224 [[ 554 [Define if the ISO C multithreading library can be used.])
225#include <thread.h>
226#include <synch.h>
227 ]],
228 [[thr_self();]])],
229 [gl_have_solaristhread=yes])
230 LIBS="$gl_save_LIBS"
231 if test -n "$gl_have_solaristhread"; then
232 gl_threads_api=solaris
233 LIBTHREAD=-lthread
234 LTLIBTHREAD=-lthread
235 LIBMULTITHREAD="$LIBTHREAD"
236 LTLIBMULTITHREAD="$LTLIBTHREAD"
237 AC_DEFINE([USE_SOLARIS_THREADS], [1],
238 [Define if the old Solaris multithreading library can be used.])
239 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
240 AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1],
241 [Define if references to the old Solaris multithreading library should be made weak.])
242 LIBTHREAD=
243 LTLIBTHREAD=
244 fi
245 fi
246 fi 555 fi
247 fi 556 fi
248 if test "$gl_use_threads" = pth; then 557 if test $gl_threads_api = none; then
249 gl_save_CPPFLAGS="$CPPFLAGS"
250 AC_LIB_LINKFLAGS([pth])
251 gl_have_pth=
252 gl_save_LIBS="$LIBS"
253 LIBS="$LIBS $LIBPTH"
254 AC_LINK_IFELSE(
255 [AC_LANG_PROGRAM([[#include <pth.h>]], [[pth_self();]])],
256 [gl_have_pth=yes])
257 LIBS="$gl_save_LIBS"
258 if test -n "$gl_have_pth"; then
259 gl_threads_api=pth
260 LIBTHREAD="$LIBPTH"
261 LTLIBTHREAD="$LTLIBPTH"
262 LIBMULTITHREAD="$LIBTHREAD"
263 LTLIBMULTITHREAD="$LTLIBTHREAD"
264 AC_DEFINE([USE_PTH_THREADS], [1],
265 [Define if the GNU Pth multithreading library can be used.])
266 if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
267 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
268 AC_DEFINE([USE_PTH_THREADS_WEAK], [1],
269 [Define if references to the GNU Pth multithreading library should be made weak.])
270 LIBTHREAD=
271 LTLIBTHREAD=
272 fi
273 fi
274 else
275 CPPFLAGS="$gl_save_CPPFLAGS"
276 fi
277 fi
278 if test -z "$gl_have_pthread"; then
279 case "$gl_use_threads" in 558 case "$gl_use_threads" in
280 yes | windows | win32) # The 'win32' is for backward compatibility. 559 yes | windows | win32) # The 'win32' is for backward compatibility.
281 if { case "$host_os" in 560 if { case "$host_os" in
@@ -317,6 +596,21 @@ AC_DEFUN([gl_DISABLE_THREADS], [
317]) 596])
318 597
319 598
599dnl gl_AVOID_WINPTHREAD
600dnl -------------------
601dnl Sets the gl_THREADLIB default so that on mingw, a dependency to the
602dnl libwinpthread DLL (mingw-w64 winpthreads library) is avoided.
603dnl The user can still override it at installation time, by using the
604dnl configure option '--enable-threads'.
605
606AC_DEFUN([gl_AVOID_WINPTHREAD], [
607 m4_divert_text([INIT_PREPARE], [gl_use_winpthreads_default=no])
608])
609
610
611dnl ============================================================================
612
613
320dnl Survey of platforms: 614dnl Survey of platforms:
321dnl 615dnl
322dnl Platform Available Compiler Supports test-lock 616dnl Platform Available Compiler Supports test-lock
@@ -324,7 +618,11 @@ dnl flavours option weak result
324dnl --------------- --------- --------- -------- --------- 618dnl --------------- --------- --------- -------- ---------
325dnl Linux 2.4/glibc posix -lpthread Y OK 619dnl Linux 2.4/glibc posix -lpthread Y OK
326dnl 620dnl
327dnl GNU Hurd/glibc posix 621dnl Linux/glibc 2.34 posix Y OK
622dnl
623dnl GNU Hurd/glibc posix -lpthread Y OK
624dnl
625dnl Ubuntu 14.04 posix -pthread Y OK
328dnl 626dnl
329dnl FreeBSD 5.3 posix -lc_r Y 627dnl FreeBSD 5.3 posix -lc_r Y
330dnl posix -lkse ? Y 628dnl posix -lkse ? Y
@@ -344,7 +642,6 @@ dnl
344dnl Mac OS X 10.[123] posix -lpthread Y OK 642dnl Mac OS X 10.[123] posix -lpthread Y OK
345dnl 643dnl
346dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK 644dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK
347dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK
348dnl 645dnl
349dnl HP-UX 11 posix -lpthread N (cc) OK 646dnl HP-UX 11 posix -lpthread N (cc) OK
350dnl Y (gcc) 647dnl Y (gcc)
@@ -358,8 +655,6 @@ dnl -lpthread (gcc) Y
358dnl 655dnl
359dnl Cygwin posix -lpthread Y OK 656dnl Cygwin posix -lpthread Y OK
360dnl 657dnl
361dnl Any of the above pth -lpth 0.0
362dnl
363dnl Mingw windows N OK 658dnl Mingw windows N OK
364dnl 659dnl
365dnl BeOS 5 -- 660dnl BeOS 5 --
diff --git a/gl/m4/time_h.m4 b/gl/m4/time_h.m4
index 3b839005..f6bf3a4f 100644
--- a/gl/m4/time_h.m4
+++ b/gl/m4/time_h.m4
@@ -1,8 +1,8 @@
1# Configure a more-standard replacement for <time.h>. 1# Configure a more-standard replacement for <time.h>.
2 2
3# Copyright (C) 2000-2001, 2003-2007, 2009-2013 Free Software Foundation, Inc. 3# Copyright (C) 2000-2001, 2003-2007, 2009-2023 Free Software Foundation, Inc.
4 4
5# serial 7 5# serial 20
6 6
7# This file is free software; the Free Software Foundation 7# This file is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it, 8# gives unlimited permission to copy and/or distribute it,
@@ -10,23 +10,42 @@
10 10
11# Written by Paul Eggert and Jim Meyering. 11# Written by Paul Eggert and Jim Meyering.
12 12
13AC_DEFUN([gl_HEADER_TIME_H], 13AC_DEFUN_ONCE([gl_TIME_H],
14[ 14[
15 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 15 dnl Ensure to expand the default settings once only, before all statements
16 dnl once only, before all statements that occur in other macros. 16 dnl that occur in other macros.
17 AC_REQUIRE([gl_HEADER_TIME_H_BODY]) 17 AC_REQUIRE([gl_TIME_H_DEFAULTS])
18])
19 18
20AC_DEFUN([gl_HEADER_TIME_H_BODY],
21[
22 AC_REQUIRE([AC_C_RESTRICT])
23 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
24 gl_NEXT_HEADERS([time.h]) 19 gl_NEXT_HEADERS([time.h])
25 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC]) 20 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
21
22 dnl Check for declarations of anything we want to poison if the
23 dnl corresponding gnulib module is not in use.
24 gl_WARN_ON_USE_PREPARE([[
25#include <time.h>
26 ]], [asctime_r ctime_r])
27
28 AC_REQUIRE([AC_C_RESTRICT])
29
30 AC_CACHE_CHECK([for TIME_UTC in <time.h>],
31 [gl_cv_time_h_has_TIME_UTC],
32 [AC_COMPILE_IFELSE(
33 [AC_LANG_PROGRAM(
34 [[#include <time.h>
35 ]],
36 [[static int x = TIME_UTC; x++;]])],
37 [gl_cv_time_h_has_TIME_UTC=yes],
38 [gl_cv_time_h_has_TIME_UTC=no])])
39 if test $gl_cv_time_h_has_TIME_UTC = yes; then
40 TIME_H_DEFINES_TIME_UTC=1
41 else
42 TIME_H_DEFINES_TIME_UTC=0
43 fi
44 AC_SUBST([TIME_H_DEFINES_TIME_UTC])
26]) 45])
27 46
28dnl Check whether 'struct timespec' is declared 47dnl Check whether 'struct timespec' is declared
29dnl in time.h, sys/time.h, or pthread.h. 48dnl in time.h, sys/time.h, pthread.h, or unistd.h.
30 49
31AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], 50AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
32[ 51[
@@ -44,6 +63,7 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
44 TIME_H_DEFINES_STRUCT_TIMESPEC=0 63 TIME_H_DEFINES_STRUCT_TIMESPEC=0
45 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 64 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
46 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 65 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0
66 UNISTD_H_DEFINES_STRUCT_TIMESPEC=0
47 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then 67 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
48 TIME_H_DEFINES_STRUCT_TIMESPEC=1 68 TIME_H_DEFINES_STRUCT_TIMESPEC=1
49 else 69 else
@@ -70,40 +90,94 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
70 [gl_cv_sys_struct_timespec_in_pthread_h=no])]) 90 [gl_cv_sys_struct_timespec_in_pthread_h=no])])
71 if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then 91 if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then
72 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 92 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1
93 else
94 AC_CACHE_CHECK([for struct timespec in <unistd.h>],
95 [gl_cv_sys_struct_timespec_in_unistd_h],
96 [AC_COMPILE_IFELSE(
97 [AC_LANG_PROGRAM(
98 [[#include <unistd.h>
99 ]],
100 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
101 [gl_cv_sys_struct_timespec_in_unistd_h=yes],
102 [gl_cv_sys_struct_timespec_in_unistd_h=no])])
103 if test $gl_cv_sys_struct_timespec_in_unistd_h = yes; then
104 UNISTD_H_DEFINES_STRUCT_TIMESPEC=1
105 fi
73 fi 106 fi
74 fi 107 fi
75 fi 108 fi
76 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) 109 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
77 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) 110 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
78 AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC]) 111 AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC])
112 AC_SUBST([UNISTD_H_DEFINES_STRUCT_TIMESPEC])
79]) 113])
80 114
115# gl_TIME_MODULE_INDICATOR([modulename])
116# sets the shell variable that indicates the presence of the given module
117# to a C preprocessor expression that will evaluate to 1.
118# This macro invocation must not occur in macros that are AC_REQUIREd.
81AC_DEFUN([gl_TIME_MODULE_INDICATOR], 119AC_DEFUN([gl_TIME_MODULE_INDICATOR],
82[ 120[
83 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 121 dnl Ensure to expand the default settings once only.
84 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 122 gl_TIME_H_REQUIRE_DEFAULTS
85 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 123 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
86 dnl Define it also as a C macro, for the benefit of the unit tests. 124 dnl Define it also as a C macro, for the benefit of the unit tests.
87 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 125 gl_MODULE_INDICATOR_FOR_TESTS([$1])
88]) 126])
89 127
90AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], 128# Initializes the default values for AC_SUBSTed shell variables.
129# This macro must not be AC_REQUIREd. It must only be invoked, and only
130# outside of macros or in macros that are not AC_REQUIREd.
131AC_DEFUN([gl_TIME_H_REQUIRE_DEFAULTS],
132[
133 m4_defun(GL_MODULE_INDICATOR_PREFIX[_TIME_H_MODULE_INDICATOR_DEFAULTS], [
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CTIME])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKTIME])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALTIME])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NANOSLEEP])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRFTIME])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPTIME])
140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMEGM])
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GET])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GETRES])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_R])
144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_RZ])
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TZSET])
146 dnl Support Microsoft deprecated alias function names by default.
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TZSET], [1])
148 ])
149 m4_require(GL_MODULE_INDICATOR_PREFIX[_TIME_H_MODULE_INDICATOR_DEFAULTS])
150 AC_REQUIRE([gl_TIME_H_DEFAULTS])
151])
152
153AC_DEFUN([gl_TIME_H_DEFAULTS],
91[ 154[
92 GNULIB_MKTIME=0; AC_SUBST([GNULIB_MKTIME])
93 GNULIB_NANOSLEEP=0; AC_SUBST([GNULIB_NANOSLEEP])
94 GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME])
95 GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM])
96 GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R])
97 dnl Assume proper GNU behavior unless another module says otherwise. 155 dnl Assume proper GNU behavior unless another module says otherwise.
98 HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R]) 156 HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R])
99 HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) 157 HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP])
100 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) 158 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME])
101 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) 159 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM])
160 HAVE_TIMESPEC_GET=1; AC_SUBST([HAVE_TIMESPEC_GET])
161 HAVE_TIMESPEC_GETRES=1; AC_SUBST([HAVE_TIMESPEC_GETRES])
162 dnl Even GNU libc does not have timezone_t yet.
163 HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T])
102 dnl If another module says to replace or to not replace, do that. 164 dnl If another module says to replace or to not replace, do that.
103 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; 165 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
104 dnl this lets maintainers check for portability. 166 dnl this lets maintainers check for portability.
167 REPLACE_CTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_CTIME])
105 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R]) 168 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R])
106 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME]) 169 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME])
107 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) 170 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP])
171 REPLACE_STRFTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRFTIME])
108 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) 172 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM])
173 REPLACE_TZSET=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TZSET])
174
175 dnl Hack so that the time module doesn't depend on the sys_time module.
176 dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent.
177 : ${GNULIB_GETTIMEOFDAY=0}; AC_SUBST([GNULIB_GETTIMEOFDAY])
178 dnl Second, it's OK to not use GNULIB_PORTCHECK for REPLACE_GMTIME
179 dnl and REPLACE_LOCALTIME, as portability to Solaris 2.6 and earlier
180 dnl is no longer a big deal.
181 REPLACE_GMTIME=0; AC_SUBST([REPLACE_GMTIME])
182 REPLACE_LOCALTIME=0; AC_SUBST([REPLACE_LOCALTIME])
109]) 183])
diff --git a/gl/m4/time_r.m4 b/gl/m4/time_r.m4
index c388a831..adce438a 100644
--- a/gl/m4/time_r.m4
+++ b/gl/m4/time_r.m4
@@ -1,6 +1,6 @@
1dnl Reentrant time functions: localtime_r, gmtime_r. 1dnl Reentrant time functions: localtime_r, gmtime_r.
2 2
3dnl Copyright (C) 2003, 2006-2013 Free Software Foundation, Inc. 3dnl Copyright (C) 2003, 2006-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
@@ -12,12 +12,20 @@ AC_DEFUN([gl_TIME_R],
12 dnl Persuade glibc and Solaris <time.h> to declare localtime_r. 12 dnl Persuade glibc and Solaris <time.h> to declare localtime_r.
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14 14
15 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 15 AC_REQUIRE([gl_TIME_H_DEFAULTS])
16 AC_REQUIRE([AC_C_RESTRICT]) 16 AC_REQUIRE([AC_C_RESTRICT])
17 17
18 dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is 18 dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is
19 dnl not defined. 19 dnl not defined.
20 AC_CHECK_DECLS([localtime_r], [], [], [[#include <time.h>]]) 20 AC_CHECK_DECLS([localtime_r], [], [],
21 [[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
22 gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
23 been included before. */
24 #if defined __MINGW32__
25 # include <unistd.h>
26 #endif
27 #include <time.h>
28 ]])
21 if test $ac_cv_have_decl_localtime_r = no; then 29 if test $ac_cv_have_decl_localtime_r = no; then
22 HAVE_DECL_LOCALTIME_R=0 30 HAVE_DECL_LOCALTIME_R=0
23 fi 31 fi
@@ -29,7 +37,14 @@ AC_DEFUN([gl_TIME_R],
29 [gl_cv_time_r_posix], 37 [gl_cv_time_r_posix],
30 [AC_COMPILE_IFELSE( 38 [AC_COMPILE_IFELSE(
31 [AC_LANG_PROGRAM( 39 [AC_LANG_PROGRAM(
32 [[#include <time.h>]], 40 [[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
41 gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
42 been included before. */
43 #if defined __MINGW32__
44 # include <unistd.h>
45 #endif
46 #include <time.h>
47 ]],
33 [[/* We don't need to append 'restrict's to the argument types, 48 [[/* We don't need to append 'restrict's to the argument types,
34 even though the POSIX signature has the 'restrict's, 49 even though the POSIX signature has the 'restrict's,
35 since C99 says they can't affect type compatibility. */ 50 since C99 says they can't affect type compatibility. */
@@ -49,6 +64,32 @@ AC_DEFUN([gl_TIME_R],
49 fi 64 fi
50 else 65 else
51 HAVE_LOCALTIME_R=0 66 HAVE_LOCALTIME_R=0
67 dnl On mingw, localtime_r() is defined as an inline function; use through a
68 dnl direct function call works but the use as a function pointer leads to a
69 dnl link error.
70 AC_CACHE_CHECK([whether localtime_r exists as an inline function],
71 [gl_cv_func_localtime_r_inline],
72 [AC_LINK_IFELSE(
73 [AC_LANG_PROGRAM(
74 [[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
75 gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
76 been included before. */
77 #if defined __MINGW32__
78 # include <unistd.h>
79 #endif
80 #include <time.h>
81 ]],
82 [[time_t a;
83 struct tm r;
84 localtime_r (&a, &r);
85 ]])
86 ],
87 [gl_cv_func_localtime_r_inline=yes],
88 [gl_cv_func_localtime_r_inline=no])
89 ])
90 if test $gl_cv_func_localtime_r_inline = yes; then
91 REPLACE_LOCALTIME_R=1
92 fi
52 fi 93 fi
53]) 94])
54 95
diff --git a/gl/m4/timegm.m4 b/gl/m4/timegm.m4
index 997953c0..6079f1a3 100644
--- a/gl/m4/timegm.m4
+++ b/gl/m4/timegm.m4
@@ -1,17 +1,17 @@
1# timegm.m4 serial 11 1# timegm.m4 serial 13
2dnl Copyright (C) 2003, 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_FUNC_TIMEGM], 7AC_DEFUN([gl_FUNC_TIMEGM],
8[ 8[
9 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 9 AC_REQUIRE([gl_TIME_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_MKTIME]) 10 AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
11 REPLACE_TIMEGM=0 11 REPLACE_TIMEGM=0
12 AC_CHECK_FUNCS_ONCE([timegm]) 12 AC_CHECK_FUNCS_ONCE([timegm])
13 if test $ac_cv_func_timegm = yes; then 13 if test $ac_cv_func_timegm = yes; then
14 if test $gl_cv_func_working_mktime = no; then 14 if test "$gl_cv_func_working_mktime" != yes; then
15 # Assume that timegm is buggy if mktime is. 15 # Assume that timegm is buggy if mktime is.
16 REPLACE_TIMEGM=1 16 REPLACE_TIMEGM=1
17 fi 17 fi
diff --git a/gl/m4/uintmax_t.m4 b/gl/m4/uintmax_t.m4
deleted file mode 100644
index c6ff8006..00000000
--- a/gl/m4/uintmax_t.m4
+++ /dev/null
@@ -1,30 +0,0 @@
1# uintmax_t.m4 serial 12
2dnl Copyright (C) 1997-2004, 2007-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Paul Eggert.
8
9AC_PREREQ([2.13])
10
11# Define uintmax_t to 'unsigned long' or 'unsigned long long'
12# if it is not already defined in <stdint.h> or <inttypes.h>.
13
14AC_DEFUN([gl_AC_TYPE_UINTMAX_T],
15[
16 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
17 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
18 if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then
19 AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
20 test $ac_cv_type_unsigned_long_long_int = yes \
21 && ac_type='unsigned long long' \
22 || ac_type='unsigned long'
23 AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type],
24 [Define to unsigned long or unsigned long long
25 if <stdint.h> and <inttypes.h> don't define.])
26 else
27 AC_DEFINE([HAVE_UINTMAX_T], [1],
28 [Define if you have the 'uintmax_t' type in <stdint.h> or <inttypes.h>.])
29 fi
30])
diff --git a/gl/m4/ungetc.m4 b/gl/m4/ungetc.m4
new file mode 100644
index 00000000..8977a346
--- /dev/null
+++ b/gl/m4/ungetc.m4
@@ -0,0 +1,73 @@
1# ungetc.m4 serial 10
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS],
8[
9 AC_REQUIRE([AC_PROG_CC])
10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
11
12 AC_CACHE_CHECK([whether ungetc works on arbitrary bytes],
13 [gl_cv_func_ungetc_works],
14 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
15#include <stdio.h>
16 ]], [[FILE *f;
17 if (!(f = fopen ("conftest.tmp", "w+")))
18 return 1;
19 if (fputs ("abc", f) < 0)
20 { fclose (f); return 2; }
21 rewind (f);
22 if (fgetc (f) != 'a')
23 { fclose (f); return 3; }
24 if (fgetc (f) != 'b')
25 { fclose (f); return 4; }
26 if (ungetc ('d', f) != 'd')
27 { fclose (f); return 5; }
28 if (ftell (f) != 1)
29 { fclose (f); return 6; }
30 if (fgetc (f) != 'd')
31 { fclose (f); return 7; }
32 if (ftell (f) != 2)
33 { fclose (f); return 8; }
34 if (fseek (f, 0, SEEK_CUR) != 0)
35 { fclose (f); return 9; }
36 if (ftell (f) != 2)
37 { fclose (f); return 10; }
38 if (fgetc (f) != 'c')
39 { fclose (f); return 11; }
40 fclose (f);
41 remove ("conftest.tmp");
42 ]])],
43 [gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no],
44 [case "$host_os" in
45 # Guess yes on glibc systems.
46 *-gnu* | gnu*) gl_cv_func_ungetc_works="guessing yes" ;;
47 # Guess yes on musl systems.
48 *-musl*) gl_cv_func_ungetc_works="guessing yes" ;;
49 # Guess yes on bionic systems.
50 *-android*) gl_cv_func_ungetc_works="guessing yes" ;;
51 # Guess yes on native Windows.
52 mingw*) gl_cv_func_ungetc_works="guessing yes" ;;
53 # If we don't know, obey --enable-cross-guesses.
54 *) gl_cv_func_ungetc_works="$gl_cross_guess_normal" ;;
55 esac
56 ])
57 ])
58 gl_ftello_broken_after_ungetc=no
59 case "$gl_cv_func_ungetc_works" in
60 *yes) ;;
61 *)
62 dnl On macOS >= 10.15, where the above program fails with exit code 6,
63 dnl we fix it through an ftello override.
64 case "$host_os" in
65 darwin*) gl_ftello_broken_after_ungetc=yes ;;
66 *)
67 AC_DEFINE([FUNC_UNGETC_BROKEN], [1],
68 [Define to 1 if ungetc is broken when used on arbitrary bytes.])
69 ;;
70 esac
71 ;;
72 esac
73])
diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4
index 32dcfa58..f4384027 100644
--- a/gl/m4/unistd_h.m4
+++ b/gl/m4/unistd_h.m4
@@ -1,15 +1,15 @@
1# unistd_h.m4 serial 66 1# unistd_h.m4 serial 90
2dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl Written by Simon Josefsson, Bruno Haible. 7dnl Written by Simon Josefsson, Bruno Haible.
8 8
9AC_DEFUN([gl_UNISTD_H], 9AC_DEFUN_ONCE([gl_UNISTD_H],
10[ 10[
11 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 11 dnl Ensure to expand the default settings once only, before all statements
12 dnl once only, before all statements that occur in other macros. 12 dnl that occur in other macros.
13 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 13 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
14 14
15 gl_CHECK_NEXT_HEADERS([unistd.h]) 15 gl_CHECK_NEXT_HEADERS([unistd.h])
@@ -37,150 +37,234 @@ AC_DEFUN([gl_UNISTD_H],
37# include <fcntl.h> 37# include <fcntl.h>
38# include <stdio.h> 38# include <stdio.h>
39# include <stdlib.h> 39# include <stdlib.h>
40# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 40# if defined _WIN32 && ! defined __CYGWIN__
41# include <io.h> 41# include <io.h>
42# endif 42# endif
43#endif 43#endif
44 ]], [chdir chown dup dup2 dup3 environ euidaccess faccessat fchdir fchownat 44 ]], [access chdir chown copy_file_range dup dup2 dup3 environ euidaccess
45 fdatasync fsync ftruncate getcwd getdomainname getdtablesize getgroups 45 execl execle execlp execv execve execvp execvpe
46 gethostname getlogin getlogin_r getpagesize 46 faccessat fchdir
47 fchownat fdatasync fsync ftruncate getcwd getdomainname getdtablesize
48 getentropy getgroups gethostname getlogin getlogin_r getpagesize getpass
47 getusershell setusershell endusershell 49 getusershell setusershell endusershell
48 group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite 50 group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite
49 readlink readlinkat rmdir sethostname sleep symlink symlinkat ttyname_r 51 readlink readlinkat rmdir sethostname sleep symlink symlinkat
50 unlink unlinkat usleep]) 52 truncate ttyname_r unlink unlinkat usleep])
53
54 AC_REQUIRE([AC_C_RESTRICT])
55
56 AC_CHECK_DECLS_ONCE([execvpe])
57 if test $ac_cv_have_decl_execvpe = no; then
58 HAVE_DECL_EXECVPE=0
59 fi
51]) 60])
52 61
62# gl_UNISTD_MODULE_INDICATOR([modulename])
63# sets the shell variable that indicates the presence of the given module
64# to a C preprocessor expression that will evaluate to 1.
65# This macro invocation must not occur in macros that are AC_REQUIREd.
53AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], 66AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
54[ 67[
55 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 68 dnl Ensure to expand the default settings once only.
56 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 69 gl_UNISTD_H_REQUIRE_DEFAULTS
57 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 70 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
58 dnl Define it also as a C macro, for the benefit of the unit tests. 71 dnl Define it also as a C macro, for the benefit of the unit tests.
59 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 72 gl_MODULE_INDICATOR_FOR_TESTS([$1])
60]) 73])
61 74
75# Initializes the default values for AC_SUBSTed shell variables.
76# This macro must not be AC_REQUIREd. It must only be invoked, and only
77# outside of macros or in macros that are not AC_REQUIREd.
78AC_DEFUN([gl_UNISTD_H_REQUIRE_DEFAULTS],
79[
80 m4_defun(GL_MODULE_INDICATOR_PREFIX[_UNISTD_H_MODULE_INDICATOR_DEFAULTS], [
81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCESS])
82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHDIR])
83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHOWN])
84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CLOSE])
85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPY_FILE_RANGE])
86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP])
87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP2])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP3])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ENVIRON])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EUIDACCESS])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECL])
92 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECLE])
93 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECLP])
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECV])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVE])
96 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVP])
97 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVPE])
98 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FACCESSAT])
99 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHDIR])
100 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHOWNAT])
101 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDATASYNC])
102 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSYNC])
103 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTRUNCATE])
104 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETCWD])
105 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDOMAINNAME])
106 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDTABLESIZE])
107 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETENTROPY])
108 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETGROUPS])
109 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETHOSTNAME])
110 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOGIN])
111 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOGIN_R])
112 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETOPT_POSIX])
113 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPAGESIZE])
114 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPASS])
115 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPASS_GNU])
116 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETUSERSHELL])
117 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GROUP_MEMBER])
118 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISATTY])
119 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LCHOWN])
120 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LINK])
121 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LINKAT])
122 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LSEEK])
123 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PIPE])
124 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PIPE2])
125 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PREAD])
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PWRITE])
127 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READ])
128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READLINK])
129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READLINKAT])
130 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RMDIR])
131 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETHOSTNAME])
132 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SLEEP])
133 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYMLINK])
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYMLINKAT])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCATE])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TTYNAME_R])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_NONBLOCKING])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_SIGPIPE])
140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLINK])
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLINKAT])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_USLEEP])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WRITE])
144 dnl Support Microsoft deprecated alias function names by default.
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ACCESS], [1])
146 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CHDIR], [1])
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CLOSE], [1])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_DUP], [1])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_DUP2], [1])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECL], [1])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECLE], [1])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECLP], [1])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECV], [1])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVE], [1])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVP], [1])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVPE], [1])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETCWD], [1])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETPID], [1])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ISATTY], [1])
160 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_LSEEK], [1])
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_READ], [1])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_RMDIR], [1])
163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_SWAB], [1])
164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_UNLINK], [1])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_WRITE], [1])
166 ])
167 m4_require(GL_MODULE_INDICATOR_PREFIX[_UNISTD_H_MODULE_INDICATOR_DEFAULTS])
168 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
169])
170
62AC_DEFUN([gl_UNISTD_H_DEFAULTS], 171AC_DEFUN([gl_UNISTD_H_DEFAULTS],
63[ 172[
64 GNULIB_CHDIR=0; AC_SUBST([GNULIB_CHDIR])
65 GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN])
66 GNULIB_CLOSE=0; AC_SUBST([GNULIB_CLOSE])
67 GNULIB_DUP=0; AC_SUBST([GNULIB_DUP])
68 GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2])
69 GNULIB_DUP3=0; AC_SUBST([GNULIB_DUP3])
70 GNULIB_ENVIRON=0; AC_SUBST([GNULIB_ENVIRON])
71 GNULIB_EUIDACCESS=0; AC_SUBST([GNULIB_EUIDACCESS])
72 GNULIB_FACCESSAT=0; AC_SUBST([GNULIB_FACCESSAT])
73 GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR])
74 GNULIB_FCHOWNAT=0; AC_SUBST([GNULIB_FCHOWNAT])
75 GNULIB_FDATASYNC=0; AC_SUBST([GNULIB_FDATASYNC])
76 GNULIB_FSYNC=0; AC_SUBST([GNULIB_FSYNC])
77 GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE])
78 GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD])
79 GNULIB_GETDOMAINNAME=0; AC_SUBST([GNULIB_GETDOMAINNAME])
80 GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE])
81 GNULIB_GETGROUPS=0; AC_SUBST([GNULIB_GETGROUPS])
82 GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME])
83 GNULIB_GETLOGIN=0; AC_SUBST([GNULIB_GETLOGIN])
84 GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R])
85 GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE])
86 GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL])
87 GNULIB_GROUP_MEMBER=0; AC_SUBST([GNULIB_GROUP_MEMBER])
88 GNULIB_ISATTY=0; AC_SUBST([GNULIB_ISATTY])
89 GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN])
90 GNULIB_LINK=0; AC_SUBST([GNULIB_LINK])
91 GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT])
92 GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK])
93 GNULIB_PIPE=0; AC_SUBST([GNULIB_PIPE])
94 GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2])
95 GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD])
96 GNULIB_PWRITE=0; AC_SUBST([GNULIB_PWRITE])
97 GNULIB_READ=0; AC_SUBST([GNULIB_READ])
98 GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
99 GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT])
100 GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR])
101 GNULIB_SETHOSTNAME=0; AC_SUBST([GNULIB_SETHOSTNAME])
102 GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP])
103 GNULIB_SYMLINK=0; AC_SUBST([GNULIB_SYMLINK])
104 GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT])
105 GNULIB_TTYNAME_R=0; AC_SUBST([GNULIB_TTYNAME_R])
106 GNULIB_UNISTD_H_NONBLOCKING=0; AC_SUBST([GNULIB_UNISTD_H_NONBLOCKING])
107 GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
108 GNULIB_UNLINK=0; AC_SUBST([GNULIB_UNLINK])
109 GNULIB_UNLINKAT=0; AC_SUBST([GNULIB_UNLINKAT])
110 GNULIB_USLEEP=0; AC_SUBST([GNULIB_USLEEP])
111 GNULIB_WRITE=0; AC_SUBST([GNULIB_WRITE])
112 dnl Assume proper GNU behavior unless another module says otherwise. 173 dnl Assume proper GNU behavior unless another module says otherwise.
113 HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN]) 174 HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN])
114 HAVE_DUP2=1; AC_SUBST([HAVE_DUP2]) 175 HAVE_COPY_FILE_RANGE=1; AC_SUBST([HAVE_COPY_FILE_RANGE])
115 HAVE_DUP3=1; AC_SUBST([HAVE_DUP3]) 176 HAVE_DUP3=1; AC_SUBST([HAVE_DUP3])
116 HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS]) 177 HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS])
117 HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT]) 178 HAVE_EXECVPE=1; AC_SUBST([HAVE_EXECVPE])
118 HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR]) 179 HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT])
119 HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT]) 180 HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR])
120 HAVE_FDATASYNC=1; AC_SUBST([HAVE_FDATASYNC]) 181 HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT])
121 HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC]) 182 HAVE_FDATASYNC=1; AC_SUBST([HAVE_FDATASYNC])
122 HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE]) 183 HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC])
123 HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE]) 184 HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE])
124 HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS]) 185 HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE])
125 HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME]) 186 HAVE_GETENTROPY=1; AC_SUBST([HAVE_GETENTROPY])
126 HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN]) 187 HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS])
127 HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE]) 188 HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME])
128 HAVE_GROUP_MEMBER=1; AC_SUBST([HAVE_GROUP_MEMBER]) 189 HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN])
129 HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN]) 190 HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE])
130 HAVE_LINK=1; AC_SUBST([HAVE_LINK]) 191 HAVE_GETPASS=1; AC_SUBST([HAVE_GETPASS])
131 HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT]) 192 HAVE_GROUP_MEMBER=1; AC_SUBST([HAVE_GROUP_MEMBER])
132 HAVE_PIPE=1; AC_SUBST([HAVE_PIPE]) 193 HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN])
133 HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2]) 194 HAVE_LINK=1; AC_SUBST([HAVE_LINK])
134 HAVE_PREAD=1; AC_SUBST([HAVE_PREAD]) 195 HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT])
135 HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE]) 196 HAVE_PIPE=1; AC_SUBST([HAVE_PIPE])
136 HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) 197 HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2])
137 HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT]) 198 HAVE_PREAD=1; AC_SUBST([HAVE_PREAD])
138 HAVE_SETHOSTNAME=1; AC_SUBST([HAVE_SETHOSTNAME]) 199 HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE])
139 HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) 200 HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
140 HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK]) 201 HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT])
141 HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT]) 202 HAVE_SETHOSTNAME=1; AC_SUBST([HAVE_SETHOSTNAME])
142 HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) 203 HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
143 HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP]) 204 HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK])
144 HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON]) 205 HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT])
145 HAVE_DECL_FCHDIR=1; AC_SUBST([HAVE_DECL_FCHDIR]) 206 HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT])
146 HAVE_DECL_FDATASYNC=1; AC_SUBST([HAVE_DECL_FDATASYNC]) 207 HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP])
147 HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME]) 208 HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON])
148 HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R]) 209 HAVE_DECL_EXECVPE=1; AC_SUBST([HAVE_DECL_EXECVPE])
149 HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE]) 210 HAVE_DECL_FCHDIR=1; AC_SUBST([HAVE_DECL_FCHDIR])
150 HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL]) 211 HAVE_DECL_FDATASYNC=1; AC_SUBST([HAVE_DECL_FDATASYNC])
151 HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME]) 212 HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME])
152 HAVE_DECL_TTYNAME_R=1; AC_SUBST([HAVE_DECL_TTYNAME_R]) 213 HAVE_DECL_GETLOGIN=1; AC_SUBST([HAVE_DECL_GETLOGIN])
153 HAVE_OS_H=0; AC_SUBST([HAVE_OS_H]) 214 HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
154 HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H]) 215 HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE])
155 REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) 216 HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL])
156 REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE]) 217 HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME])
157 REPLACE_DUP=0; AC_SUBST([REPLACE_DUP]) 218 HAVE_DECL_TRUNCATE=1; AC_SUBST([HAVE_DECL_TRUNCATE])
158 REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) 219 HAVE_DECL_TTYNAME_R=1; AC_SUBST([HAVE_DECL_TTYNAME_R])
159 REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT]) 220 HAVE_OS_H=0; AC_SUBST([HAVE_OS_H])
160 REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE]) 221 HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H])
161 REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) 222 REPLACE_ACCESS=0; AC_SUBST([REPLACE_ACCESS])
162 REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME]) 223 REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
163 REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R]) 224 REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE])
164 REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) 225 REPLACE_COPY_FILE_RANGE=0; AC_SUBST([REPLACE_COPY_FILE_RANGE])
165 REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) 226 REPLACE_DUP=0; AC_SUBST([REPLACE_DUP])
166 REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY]) 227 REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2])
167 REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN]) 228 REPLACE_EXECL=0; AC_SUBST([REPLACE_EXECL])
168 REPLACE_LINK=0; AC_SUBST([REPLACE_LINK]) 229 REPLACE_EXECLE=0; AC_SUBST([REPLACE_EXECLE])
169 REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) 230 REPLACE_EXECLP=0; AC_SUBST([REPLACE_EXECLP])
170 REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) 231 REPLACE_EXECV=0; AC_SUBST([REPLACE_EXECV])
171 REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD]) 232 REPLACE_EXECVE=0; AC_SUBST([REPLACE_EXECVE])
172 REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE]) 233 REPLACE_EXECVP=0; AC_SUBST([REPLACE_EXECVP])
173 REPLACE_READ=0; AC_SUBST([REPLACE_READ]) 234 REPLACE_EXECVPE=0; AC_SUBST([REPLACE_EXECVPE])
174 REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) 235 REPLACE_FACCESSAT=0; AC_SUBST([REPLACE_FACCESSAT])
175 REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) 236 REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT])
176 REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) 237 REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE])
177 REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) 238 REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
178 REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R]) 239 REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME])
179 REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK]) 240 REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE])
180 REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT]) 241 REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R])
181 REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP]) 242 REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS])
182 REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE]) 243 REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE])
183 UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H]) 244 REPLACE_GETPASS=0; AC_SUBST([REPLACE_GETPASS])
245 REPLACE_GETPASS_FOR_GETPASS_GNU=0; AC_SUBST([REPLACE_GETPASS_FOR_GETPASS_GNU])
246 REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY])
247 REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN])
248 REPLACE_LINK=0; AC_SUBST([REPLACE_LINK])
249 REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT])
250 REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
251 REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD])
252 REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE])
253 REPLACE_READ=0; AC_SUBST([REPLACE_READ])
254 REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK])
255 REPLACE_READLINKAT=0; AC_SUBST([REPLACE_READLINKAT])
256 REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR])
257 REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP])
258 REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK])
259 REPLACE_SYMLINKAT=0; AC_SUBST([REPLACE_SYMLINKAT])
260 REPLACE_TRUNCATE=0; AC_SUBST([REPLACE_TRUNCATE])
261 REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R])
262 REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK])
263 REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT])
264 REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP])
265 REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE])
266 UNISTD_H_HAVE_SYS_RANDOM_H=0; AC_SUBST([UNISTD_H_HAVE_SYS_RANDOM_H])
267 UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
184 UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0; 268 UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
185 AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS]) 269 AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS])
186]) 270])
diff --git a/gl/m4/unlocked-io.m4 b/gl/m4/unlocked-io.m4
new file mode 100644
index 00000000..407c0bac
--- /dev/null
+++ b/gl/m4/unlocked-io.m4
@@ -0,0 +1,36 @@
1# unlocked-io.m4 serial 16
2
3# Copyright (C) 1998-2006, 2009-2023 Free Software Foundation, Inc.
4#
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8
9dnl From Jim Meyering.
10dnl
11dnl See if the glibc *_unlocked I/O macros or functions are available.
12dnl Use only those *_unlocked macros or functions that are declared
13dnl (because some of them were declared in Solaris 2.5.1 but were removed
14dnl in Solaris 2.6, whereas we want binaries built on Solaris 2.5.1 to run
15dnl on Solaris 2.6).
16
17AC_DEFUN([gl_FUNC_GLIBC_UNLOCKED_IO],
18[
19 dnl Persuade glibc and Solaris <stdio.h> to declare
20 dnl fgets_unlocked(), fputs_unlocked() etc.
21 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
22
23 AC_CHECK_DECLS_ONCE([clearerr_unlocked])
24 AC_CHECK_DECLS_ONCE([feof_unlocked])
25 AC_CHECK_DECLS_ONCE([ferror_unlocked])
26 AC_CHECK_DECLS_ONCE([fflush_unlocked])
27 AC_CHECK_DECLS_ONCE([fgets_unlocked])
28 AC_CHECK_DECLS_ONCE([fputc_unlocked])
29 AC_CHECK_DECLS_ONCE([fputs_unlocked])
30 AC_CHECK_DECLS_ONCE([fread_unlocked])
31 AC_CHECK_DECLS_ONCE([fwrite_unlocked])
32 AC_CHECK_DECLS_ONCE([getc_unlocked])
33 AC_CHECK_DECLS_ONCE([getchar_unlocked])
34 AC_CHECK_DECLS_ONCE([putc_unlocked])
35 AC_CHECK_DECLS_ONCE([putchar_unlocked])
36])
diff --git a/gl/m4/vararrays.m4 b/gl/m4/vararrays.m4
new file mode 100644
index 00000000..fd6230c2
--- /dev/null
+++ b/gl/m4/vararrays.m4
@@ -0,0 +1,72 @@
1# Check for variable-length arrays.
2
3# serial 6
4
5# From Paul Eggert
6
7# Copyright (C) 2001, 2009-2023 Free Software Foundation, Inc.
8# This file is free software; the Free Software Foundation
9# gives unlimited permission to copy and/or distribute it,
10# with or without modifications, as long as this notice is preserved.
11
12m4_version_prereq([2.70], [], [
13
14# AC_C_VARARRAYS
15# --------------
16# Check whether the C compiler supports variable-length arrays.
17AC_DEFUN([AC_C_VARARRAYS],
18[
19 AC_CACHE_CHECK([for variable-length arrays],
20 ac_cv_c_vararrays,
21 [AC_EGREP_CPP([defined],
22 [#ifdef __STDC_NO_VLA__
23 defined
24 #endif
25 ],
26 [ac_cv_c_vararrays='no: __STDC_NO_VLA__ is defined'],
27 [AC_COMPILE_IFELSE(
28 [AC_LANG_PROGRAM(
29 [[/* Test for VLA support. This test is partly inspired
30 from examples in the C standard. Use at least two VLA
31 functions to detect the GCC 3.4.3 bug described in:
32 https://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00014.html
33 */
34 #ifdef __STDC_NO_VLA__
35 syntax error;
36 #else
37 extern int n;
38 int B[100];
39 int fvla (int m, int C[m][m]);
40
41 int
42 simple (int count, int all[static count])
43 {
44 return all[count - 1];
45 }
46
47 int
48 fvla (int m, int C[m][m])
49 {
50 typedef int VLA[m][m];
51 VLA x;
52 int D[m];
53 static int (*q)[m] = &B;
54 int (*s)[n] = q;
55 return C && &x[0][0] == &D[0] && &D[0] == s[0];
56 }
57 #endif
58 ]])],
59 [ac_cv_c_vararrays=yes],
60 [ac_cv_c_vararrays=no])])])
61 if test "$ac_cv_c_vararrays" = yes; then
62 dnl This is for compatibility with Autoconf 2.61-2.69.
63 AC_DEFINE([HAVE_C_VARARRAYS], 1,
64 [Define to 1 if C supports variable-length arrays.])
65 elif test "$ac_cv_c_vararrays" = no; then
66 AC_DEFINE([__STDC_NO_VLA__], 1,
67 [Define to 1 if C does not support variable-length arrays, and
68 if the compiler does not already define this.])
69 fi
70])
71
72])
diff --git a/gl/m4/vasnprintf.m4 b/gl/m4/vasnprintf.m4
index d730e435..6361c843 100644
--- a/gl/m4/vasnprintf.m4
+++ b/gl/m4/vasnprintf.m4
@@ -1,5 +1,5 @@
1# vasnprintf.m4 serial 36 1# vasnprintf.m4 serial 38
2dnl Copyright (C) 2002-2004, 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -32,7 +32,6 @@ AC_DEFUN([gl_REPLACE_VASNPRINTF],
32# Prerequisites of lib/printf-args.h, lib/printf-args.c. 32# Prerequisites of lib/printf-args.h, lib/printf-args.c.
33AC_DEFUN([gl_PREREQ_PRINTF_ARGS], 33AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
34[ 34[
35 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
36 AC_REQUIRE([gt_TYPE_WCHAR_T]) 35 AC_REQUIRE([gt_TYPE_WCHAR_T])
37 AC_REQUIRE([gt_TYPE_WINT_T]) 36 AC_REQUIRE([gt_TYPE_WINT_T])
38]) 37])
@@ -41,7 +40,6 @@ AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
41AC_DEFUN([gl_PREREQ_PRINTF_PARSE], 40AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
42[ 41[
43 AC_REQUIRE([gl_FEATURES_H]) 42 AC_REQUIRE([gl_FEATURES_H])
44 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
45 AC_REQUIRE([gt_TYPE_WCHAR_T]) 43 AC_REQUIRE([gt_TYPE_WCHAR_T])
46 AC_REQUIRE([gt_TYPE_WINT_T]) 44 AC_REQUIRE([gt_TYPE_WINT_T])
47 AC_REQUIRE([AC_TYPE_SIZE_T]) 45 AC_REQUIRE([AC_TYPE_SIZE_T])
@@ -56,7 +54,6 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
56AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], 54AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
57[ 55[
58 AC_REQUIRE([AC_FUNC_ALLOCA]) 56 AC_REQUIRE([AC_FUNC_ALLOCA])
59 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
60 AC_REQUIRE([gt_TYPE_WCHAR_T]) 57 AC_REQUIRE([gt_TYPE_WCHAR_T])
61 AC_REQUIRE([gt_TYPE_WINT_T]) 58 AC_REQUIRE([gt_TYPE_WINT_T])
62 AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb]) 59 AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
@@ -77,6 +74,16 @@ AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
77 if the buffer had been large enough.]) 74 if the buffer had been large enough.])
78 ;; 75 ;;
79 esac 76 esac
77 dnl Additionally, the use of %n can be eliminated by assuming that snprintf
78 dnl always produces NUL-terminated strings (no truncation).
79 AC_REQUIRE([gl_SNPRINTF_TRUNCATION_C99])
80 case "$gl_cv_func_snprintf_truncation_c99" in
81 *yes)
82 AC_DEFINE([HAVE_SNPRINTF_TRUNCATION_C99], [1],
83 [Define if the string produced by the snprintf function is always NUL
84 terminated.])
85 ;;
86 esac
80]) 87])
81 88
82# Extra prerequisites of lib/vasnprintf.c for supporting 'long double' 89# Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
diff --git a/gl/m4/vasprintf.m4 b/gl/m4/vasprintf.m4
index c214ff11..6e6156a7 100644
--- a/gl/m4/vasprintf.m4
+++ b/gl/m4/vasprintf.m4
@@ -1,5 +1,5 @@
1# vasprintf.m4 serial 6 1# vasprintf.m4 serial 6
2dnl Copyright (C) 2002-2003, 2006-2007, 2009-2013 Free Software Foundation, 2dnl Copyright (C) 2002-2003, 2006-2007, 2009-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/visibility.m4 b/gl/m4/visibility.m4
index 6cbd7e5f..f0468e89 100644
--- a/gl/m4/visibility.m4
+++ b/gl/m4/visibility.m4
@@ -1,5 +1,5 @@
1# visibility.m4 serial 5 (gettext-0.18.2) 1# visibility.m4 serial 8
2dnl Copyright (C) 2005, 2008, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2008, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -29,42 +29,47 @@ AC_DEFUN([gl_VISIBILITY],
29 dnl First, check whether -Werror can be added to the command line, or 29 dnl First, check whether -Werror can be added to the command line, or
30 dnl whether it leads to an error because of some other option that the 30 dnl whether it leads to an error because of some other option that the
31 dnl user has put into $CC $CFLAGS $CPPFLAGS. 31 dnl user has put into $CC $CFLAGS $CPPFLAGS.
32 AC_MSG_CHECKING([whether the -Werror option is usable]) 32 AC_CACHE_CHECK([whether the -Werror option is usable],
33 AC_CACHE_VAL([gl_cv_cc_vis_werror], [ 33 [gl_cv_cc_vis_werror],
34 gl_save_CFLAGS="$CFLAGS" 34 [gl_save_CFLAGS="$CFLAGS"
35 CFLAGS="$CFLAGS -Werror" 35 CFLAGS="$CFLAGS -Werror"
36 AC_COMPILE_IFELSE( 36 AC_COMPILE_IFELSE(
37 [AC_LANG_PROGRAM([[]], [[]])], 37 [AC_LANG_PROGRAM([[]], [[]])],
38 [gl_cv_cc_vis_werror=yes], 38 [gl_cv_cc_vis_werror=yes],
39 [gl_cv_cc_vis_werror=no]) 39 [gl_cv_cc_vis_werror=no])
40 CFLAGS="$gl_save_CFLAGS"]) 40 CFLAGS="$gl_save_CFLAGS"
41 AC_MSG_RESULT([$gl_cv_cc_vis_werror]) 41 ])
42 dnl Now check whether visibility declarations are supported. 42 dnl Now check whether visibility declarations are supported.
43 AC_MSG_CHECKING([for simple visibility declarations]) 43 AC_CACHE_CHECK([for simple visibility declarations],
44 AC_CACHE_VAL([gl_cv_cc_visibility], [ 44 [gl_cv_cc_visibility],
45 gl_save_CFLAGS="$CFLAGS" 45 [gl_save_CFLAGS="$CFLAGS"
46 CFLAGS="$CFLAGS -fvisibility=hidden" 46 CFLAGS="$CFLAGS -fvisibility=hidden"
47 dnl We use the option -Werror and a function dummyfunc, because on some 47 dnl We use the option -Werror and a function dummyfunc, because on some
48 dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning 48 dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
49 dnl "visibility attribute not supported in this configuration; ignored" 49 dnl "visibility attribute not supported in this configuration; ignored"
50 dnl at the first function definition in every compilation unit, and we 50 dnl at the first function definition in every compilation unit, and we
51 dnl don't want to use the option in this case. 51 dnl don't want to use the option in this case.
52 if test $gl_cv_cc_vis_werror = yes; then 52 if test $gl_cv_cc_vis_werror = yes; then
53 CFLAGS="$CFLAGS -Werror" 53 CFLAGS="$CFLAGS -Werror"
54 fi 54 fi
55 AC_COMPILE_IFELSE( 55 AC_COMPILE_IFELSE(
56 [AC_LANG_PROGRAM( 56 [AC_LANG_PROGRAM(
57 [[extern __attribute__((__visibility__("hidden"))) int hiddenvar; 57 [[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
58 extern __attribute__((__visibility__("default"))) int exportedvar; 58 extern __attribute__((__visibility__("default"))) int exportedvar;
59 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); 59 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
60 extern __attribute__((__visibility__("default"))) int exportedfunc (void); 60 extern __attribute__((__visibility__("default"))) int exportedfunc (void);
61 void dummyfunc (void) {} 61 void dummyfunc (void);
62 ]], 62 int hiddenvar;
63 [[]])], 63 int exportedvar;
64 [gl_cv_cc_visibility=yes], 64 int hiddenfunc (void) { return 51; }
65 [gl_cv_cc_visibility=no]) 65 int exportedfunc (void) { return 1225736919; }
66 CFLAGS="$gl_save_CFLAGS"]) 66 void dummyfunc (void) {}
67 AC_MSG_RESULT([$gl_cv_cc_visibility]) 67 ]],
68 [[]])],
69 [gl_cv_cc_visibility=yes],
70 [gl_cv_cc_visibility=no])
71 CFLAGS="$gl_save_CFLAGS"
72 ])
68 if test $gl_cv_cc_visibility = yes; then 73 if test $gl_cv_cc_visibility = yes; then
69 CFLAG_VISIBILITY="-fvisibility=hidden" 74 CFLAG_VISIBILITY="-fvisibility=hidden"
70 HAVE_VISIBILITY=1 75 HAVE_VISIBILITY=1
diff --git a/gl/m4/vsnprintf.m4 b/gl/m4/vsnprintf.m4
index 4900764e..7fbb11c4 100644
--- a/gl/m4/vsnprintf.m4
+++ b/gl/m4/vsnprintf.m4
@@ -1,5 +1,5 @@
1# vsnprintf.m4 serial 6 1# vsnprintf.m4 serial 7
2dnl Copyright (C) 2002-2004, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -46,6 +46,14 @@ AC_DEFUN([gl_REPLACE_VSNPRINTF],
46 AC_LIBOBJ([vsnprintf]) 46 AC_LIBOBJ([vsnprintf])
47 if test $ac_cv_func_vsnprintf = yes; then 47 if test $ac_cv_func_vsnprintf = yes; then
48 REPLACE_VSNPRINTF=1 48 REPLACE_VSNPRINTF=1
49 else
50 AC_CHECK_DECLS_ONCE([vsnprintf])
51 if test $ac_cv_have_decl_vsnprintf = yes; then
52 dnl If the function is declared but does not appear to exist, it may be
53 dnl defined as an inline function. In order to avoid a conflict, we have
54 dnl to define rpl_vsnprintf, not vsnprintf.
55 REPLACE_VSNPRINTF=1
56 fi
49 fi 57 fi
50 gl_PREREQ_VSNPRINTF 58 gl_PREREQ_VSNPRINTF
51]) 59])
diff --git a/gl/m4/warn-on-use.m4 b/gl/m4/warn-on-use.m4
index e43beebd..10649c5c 100644
--- a/gl/m4/warn-on-use.m4
+++ b/gl/m4/warn-on-use.m4
@@ -1,11 +1,13 @@
1# warn-on-use.m4 serial 5 1# warn-on-use.m4 serial 10
2dnl Copyright (C) 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES) 7# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES)
8# --------------------------------------- 8# ---------------------------------------
9# If the module 'posixcheck' is in use:
10#
9# For each whitespace-separated element in the list of NAMES, define 11# For each whitespace-separated element in the list of NAMES, define
10# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES 12# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES
11# even after being undefined as a macro. 13# even after being undefined as a macro.
@@ -23,25 +25,38 @@ dnl with or without modifications, as long as this notice is preserved.
23# needing gl_WARN_ON_USE_PREPARE. 25# needing gl_WARN_ON_USE_PREPARE.
24AC_DEFUN([gl_WARN_ON_USE_PREPARE], 26AC_DEFUN([gl_WARN_ON_USE_PREPARE],
25[ 27[
26 m4_foreach_w([gl_decl], [$2], 28 m4_ifdef([gl_POSIXCHECK],
27 [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])), 29 [m4_foreach_w([gl_decl], [$2],
28 [Define to 1 if ]m4_defn([gl_decl])[ is declared even after 30 [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
29 undefining macros.])])dnl 31 [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
30dnl FIXME: gl_Symbol must be used unquoted until we can assume 32 undefining macros.])])dnl
31dnl autoconf 2.64 or newer. 33 for gl_func in m4_flatten([$2]); do
32 for gl_func in m4_flatten([$2]); do 34 AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
33 AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl 35 dnl As a workaround to implicit built-in function declarations in
34 AC_CACHE_CHECK([whether $gl_func is declared without a macro], 36 dnl clang (e.g. strndup), reference ac_compile_for_check_decl instead
35 gl_Symbol, 37 dnl of ac_compile. If, for whatever reason, the override of AC_PROG_CC
36 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1], 38 dnl in zzgnulib.m4 is inactive, use the original ac_compile.
37[@%:@undef $gl_func 39 ac_save_ac_compile="$ac_compile"
38 (void) $gl_func;])], 40 if test -n "$ac_compile_for_check_decl"; then
39 [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])]) 41 ac_compile="$ac_compile_for_check_decl"
40 AS_VAR_IF(gl_Symbol, [yes], 42 fi
41 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1]) 43 AC_CACHE_CHECK([whether $gl_func is declared without a macro],
42 dnl shortcut - if the raw declaration exists, then set a cache 44 [gl_Symbol],
43 dnl variable to allow skipping any later AC_CHECK_DECL efforts 45 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
44 eval ac_cv_have_decl_$gl_func=yes]) 46[[#undef $gl_func
45 AS_VAR_POPDEF([gl_Symbol])dnl 47 (void) $gl_func;]])],
46 done 48 [AS_VAR_SET([gl_Symbol], [yes])], [AS_VAR_SET([gl_Symbol], [no])])])
49 ac_compile="$ac_save_ac_compile"
50 AS_VAR_IF([gl_Symbol], [yes],
51 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
52 dnl Shortcut for an AC_CHECK_DECL invocation that may come later:
53 dnl If the raw declaration exists with the given includes, then
54 dnl AC_CHECK_DECL with its many includes would see it as well.
55 dnl So, set a cache variable to allow skipping any later
56 dnl AC_CHECK_DECL invocation for $gl_func.
57 eval "ac_cv_have_decl_$gl_func=yes"
58 ])
59 AS_VAR_POPDEF([gl_Symbol])dnl
60 done
61 ])
47]) 62])
diff --git a/gl/m4/wchar_h.m4 b/gl/m4/wchar_h.m4
index bedb15a4..8ec66193 100644
--- a/gl/m4/wchar_h.m4
+++ b/gl/m4/wchar_h.m4
@@ -1,15 +1,15 @@
1dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues. 1dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
2 2
3dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. 3dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7 7
8dnl Written by Eric Blake. 8dnl Written by Eric Blake.
9 9
10# wchar_h.m4 serial 39 10# wchar_h.m4 serial 55
11 11
12AC_DEFUN([gl_WCHAR_H], 12AC_DEFUN_ONCE([gl_WCHAR_H],
13[ 13[
14 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 14 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
15 AC_REQUIRE([gl_WCHAR_H_INLINE_OK]) 15 AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
@@ -35,76 +35,82 @@ AC_DEFUN([gl_WCHAR_H],
35 fi 35 fi
36 AC_SUBST([HAVE_WINT_T]) 36 AC_SUBST([HAVE_WINT_T])
37 37
38 AC_REQUIRE([gl_TYPE_WINT_T_PREREQ])
39
38 dnl Check for declarations of anything we want to poison if the 40 dnl Check for declarations of anything we want to poison if the
39 dnl corresponding gnulib module is not in use. 41 dnl corresponding gnulib module is not in use.
40 gl_WARN_ON_USE_PREPARE([[ 42 gl_WARN_ON_USE_PREPARE([[
41/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 43 #include <wchar.h>
42 <wchar.h>.
43 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
44 included before <wchar.h>. */
45#if !(defined __GLIBC__ && !defined __UCLIBC__)
46# include <stddef.h>
47# include <stdio.h>
48# include <time.h>
49#endif
50#include <wchar.h>
51 ]], 44 ]],
52 [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb 45 [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb
53 wcsrtombs wcsnrtombs wcwidth wmemchr wmemcmp wmemcpy wmemmove wmemset 46 wcsrtombs wcsnrtombs wcwidth
47 wmemchr wmemcmp wmemcpy wmemmove wmempcpy wmemset
54 wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat wcscmp 48 wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat wcscmp
55 wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup wcschr wcsrchr 49 wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup wcschr wcsrchr
56 wcscspn wcsspn wcspbrk wcsstr wcstok wcswidth 50 wcscspn wcsspn wcspbrk wcsstr wcstok wcswidth wcsftime
57 ]) 51 ])
52
53 AC_REQUIRE([AC_C_RESTRICT])
54
55 AC_CHECK_DECLS([wcsdup], [], [], [[
56 #include <wchar.h>
57 ]])
58 if test $ac_cv_have_decl_wcsdup = no; then
59 HAVE_DECL_WCSDUP=0
60 fi
58]) 61])
59 62
60dnl Check whether <wchar.h> is usable at all. 63dnl Check whether <wchar.h> is usable at all.
61AC_DEFUN([gl_WCHAR_H_INLINE_OK], 64AC_DEFUN([gl_WCHAR_H_INLINE_OK],
62[ 65[
63 dnl Test whether <wchar.h> suffers due to the transition from '__inline' to 66 dnl Test whether <wchar.h> suffers due to the transition from '__inline' to
64 dnl 'gnu_inline'. See <http://sourceware.org/bugzilla/show_bug.cgi?id=4022> 67 dnl 'gnu_inline'. See <https://sourceware.org/bugzilla/show_bug.cgi?id=4022>
65 dnl and <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary, 68 dnl and <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary,
66 dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and 69 dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and
67 dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>. 70 dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>.
71 AC_REQUIRE([AC_CANONICAL_HOST])
68 AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly], 72 AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly],
69 [gl_cv_header_wchar_h_correct_inline], 73 [gl_cv_header_wchar_h_correct_inline],
70 [gl_cv_header_wchar_h_correct_inline=yes 74 [gl_cv_header_wchar_h_correct_inline=yes
71 AC_LANG_CONFTEST([ 75 case "$host_os" in
72 AC_LANG_SOURCE([[#define wcstod renamed_wcstod 76 *-gnu* | gnu*)
73/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 77 AC_LANG_CONFTEST([
74 <wchar.h>. 78 AC_LANG_SOURCE([[
75 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be 79 #define wcstod renamed_wcstod
76 included before <wchar.h>. */ 80 #include <wchar.h>
77#include <stddef.h> 81 extern int zero (void);
78#include <stdio.h> 82 int main () { return zero(); }
79#include <time.h> 83 ]])])
80#include <wchar.h> 84 dnl Do not rename the object file from conftest.$ac_objext to
81extern int zero (void); 85 dnl conftest1.$ac_objext, as this will cause the link to fail on
82int main () { return zero(); } 86 dnl z/OS when using the XPLINK object format (due to duplicate
83]])]) 87 dnl CSECT names). Instead, temporarily redefine $ac_compile so
84 if AC_TRY_EVAL([ac_compile]); then 88 dnl that the object file has the latter name from the start.
85 mv conftest.$ac_objext conftest1.$ac_objext 89 save_ac_compile="$ac_compile"
86 AC_LANG_CONFTEST([ 90 ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest1/`
87 AC_LANG_SOURCE([[#define wcstod renamed_wcstod 91 if echo '#include "conftest.c"' >conftest1.c \
88/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 92 && AC_TRY_EVAL([ac_compile]); then
89 <wchar.h>. 93 AC_LANG_CONFTEST([
90 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be 94 AC_LANG_SOURCE([[
91 included before <wchar.h>. */ 95 #define wcstod renamed_wcstod
92#include <stddef.h> 96 #include <wchar.h>
93#include <stdio.h> 97 int zero (void) { return 0; }
94#include <time.h> 98 ]])])
95#include <wchar.h> 99 dnl See note above about renaming object files.
96int zero (void) { return 0; } 100 ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest2/`
97]])]) 101 if echo '#include "conftest.c"' >conftest2.c \
98 if AC_TRY_EVAL([ac_compile]); then 102 && AC_TRY_EVAL([ac_compile]); then
99 mv conftest.$ac_objext conftest2.$ac_objext 103 if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then
100 if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then 104 :
101 : 105 else
102 else 106 gl_cv_header_wchar_h_correct_inline=no
103 gl_cv_header_wchar_h_correct_inline=no 107 fi
108 fi
104 fi 109 fi
105 fi 110 ac_compile="$save_ac_compile"
106 fi 111 rm -f conftest[12].c conftest[12].$ac_objext conftest$ac_exeext
107 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext 112 ;;
113 esac
108 ]) 114 ])
109 if test $gl_cv_header_wchar_h_correct_inline = no; then 115 if test $gl_cv_header_wchar_h_correct_inline = no; then
110 AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS). 116 AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
@@ -112,63 +118,84 @@ This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in
112C99 mode. You have four options: 118C99 mode. You have four options:
113 - Add the flag -fgnu89-inline to CC and reconfigure, or 119 - Add the flag -fgnu89-inline to CC and reconfigure, or
114 - Fix your include files, using parts of 120 - Fix your include files, using parts of
115 <http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or 121 <https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or
116 - Use a gcc version older than 4.3, or 122 - Use a gcc version older than 4.3, or
117 - Don't use the flags -std=c99 or -std=gnu99. 123 - Don't use the flags -std=c99 or -std=gnu99.
118Configuration aborted.]) 124Configuration aborted.])
119 fi 125 fi
120]) 126])
121 127
128# gl_WCHAR_MODULE_INDICATOR([modulename])
129# sets the shell variable that indicates the presence of the given module
130# to a C preprocessor expression that will evaluate to 1.
131# This macro invocation must not occur in macros that are AC_REQUIREd.
122AC_DEFUN([gl_WCHAR_MODULE_INDICATOR], 132AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
123[ 133[
124 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 134 dnl Ensure to expand the default settings once only.
125 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 135 gl_WCHAR_H_REQUIRE_DEFAULTS
126 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 136 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
127 dnl Define it also as a C macro, for the benefit of the unit tests. 137 dnl Define it also as a C macro, for the benefit of the unit tests.
128 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 138 gl_MODULE_INDICATOR_FOR_TESTS([$1])
129]) 139])
130 140
141# Initializes the default values for AC_SUBSTed shell variables.
142# This macro must not be AC_REQUIREd. It must only be invoked, and only
143# outside of macros or in macros that are not AC_REQUIREd.
144AC_DEFUN([gl_WCHAR_H_REQUIRE_DEFAULTS],
145[
146 m4_defun(GL_MODULE_INDICATOR_PREFIX[_WCHAR_H_MODULE_INDICATOR_DEFAULTS], [
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_BTOWC])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTOB])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSINIT])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRTOWC])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRLEN])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSRTOWCS])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNRTOWCS])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCRTOMB])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSRTOMBS])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNRTOMBS])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCWIDTH])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMCHR])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMCMP])
160 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMCPY])
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMMOVE])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMPCPY])
163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMSET])
164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSLEN])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNLEN])
166 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCPY])
167 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCPCPY])
168 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCPY])
169 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCPNCPY])
170 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCAT])
171 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCAT])
172 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCMP])
173 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCMP])
174 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCASECMP])
175 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCASECMP])
176 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCOLL])
177 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSXFRM])
178 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSDUP])
179 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCHR])
180 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSRCHR])
181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCSPN])
182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSSPN])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSPBRK])
184 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSSTR])
185 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSTOK])
186 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSWIDTH])
187 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSFTIME])
188 dnl Support Microsoft deprecated alias function names by default.
189 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_WCSDUP], [1])
190 ])
191 m4_require(GL_MODULE_INDICATOR_PREFIX[_WCHAR_H_MODULE_INDICATOR_DEFAULTS])
192 dnl Make sure the shell variable for GNULIB_FREE_POSIX is initialized.
193 gl_STDLIB_H_REQUIRE_DEFAULTS
194 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
195])
196
131AC_DEFUN([gl_WCHAR_H_DEFAULTS], 197AC_DEFUN([gl_WCHAR_H_DEFAULTS],
132[ 198[
133 GNULIB_BTOWC=0; AC_SUBST([GNULIB_BTOWC])
134 GNULIB_WCTOB=0; AC_SUBST([GNULIB_WCTOB])
135 GNULIB_MBSINIT=0; AC_SUBST([GNULIB_MBSINIT])
136 GNULIB_MBRTOWC=0; AC_SUBST([GNULIB_MBRTOWC])
137 GNULIB_MBRLEN=0; AC_SUBST([GNULIB_MBRLEN])
138 GNULIB_MBSRTOWCS=0; AC_SUBST([GNULIB_MBSRTOWCS])
139 GNULIB_MBSNRTOWCS=0; AC_SUBST([GNULIB_MBSNRTOWCS])
140 GNULIB_WCRTOMB=0; AC_SUBST([GNULIB_WCRTOMB])
141 GNULIB_WCSRTOMBS=0; AC_SUBST([GNULIB_WCSRTOMBS])
142 GNULIB_WCSNRTOMBS=0; AC_SUBST([GNULIB_WCSNRTOMBS])
143 GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH])
144 GNULIB_WMEMCHR=0; AC_SUBST([GNULIB_WMEMCHR])
145 GNULIB_WMEMCMP=0; AC_SUBST([GNULIB_WMEMCMP])
146 GNULIB_WMEMCPY=0; AC_SUBST([GNULIB_WMEMCPY])
147 GNULIB_WMEMMOVE=0; AC_SUBST([GNULIB_WMEMMOVE])
148 GNULIB_WMEMSET=0; AC_SUBST([GNULIB_WMEMSET])
149 GNULIB_WCSLEN=0; AC_SUBST([GNULIB_WCSLEN])
150 GNULIB_WCSNLEN=0; AC_SUBST([GNULIB_WCSNLEN])
151 GNULIB_WCSCPY=0; AC_SUBST([GNULIB_WCSCPY])
152 GNULIB_WCPCPY=0; AC_SUBST([GNULIB_WCPCPY])
153 GNULIB_WCSNCPY=0; AC_SUBST([GNULIB_WCSNCPY])
154 GNULIB_WCPNCPY=0; AC_SUBST([GNULIB_WCPNCPY])
155 GNULIB_WCSCAT=0; AC_SUBST([GNULIB_WCSCAT])
156 GNULIB_WCSNCAT=0; AC_SUBST([GNULIB_WCSNCAT])
157 GNULIB_WCSCMP=0; AC_SUBST([GNULIB_WCSCMP])
158 GNULIB_WCSNCMP=0; AC_SUBST([GNULIB_WCSNCMP])
159 GNULIB_WCSCASECMP=0; AC_SUBST([GNULIB_WCSCASECMP])
160 GNULIB_WCSNCASECMP=0; AC_SUBST([GNULIB_WCSNCASECMP])
161 GNULIB_WCSCOLL=0; AC_SUBST([GNULIB_WCSCOLL])
162 GNULIB_WCSXFRM=0; AC_SUBST([GNULIB_WCSXFRM])
163 GNULIB_WCSDUP=0; AC_SUBST([GNULIB_WCSDUP])
164 GNULIB_WCSCHR=0; AC_SUBST([GNULIB_WCSCHR])
165 GNULIB_WCSRCHR=0; AC_SUBST([GNULIB_WCSRCHR])
166 GNULIB_WCSCSPN=0; AC_SUBST([GNULIB_WCSCSPN])
167 GNULIB_WCSSPN=0; AC_SUBST([GNULIB_WCSSPN])
168 GNULIB_WCSPBRK=0; AC_SUBST([GNULIB_WCSPBRK])
169 GNULIB_WCSSTR=0; AC_SUBST([GNULIB_WCSSTR])
170 GNULIB_WCSTOK=0; AC_SUBST([GNULIB_WCSTOK])
171 GNULIB_WCSWIDTH=0; AC_SUBST([GNULIB_WCSWIDTH])
172 dnl Assume proper GNU behavior unless another module says otherwise. 199 dnl Assume proper GNU behavior unless another module says otherwise.
173 HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC]) 200 HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC])
174 HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT]) 201 HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT])
@@ -183,6 +210,7 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
183 HAVE_WMEMCMP=1; AC_SUBST([HAVE_WMEMCMP]) 210 HAVE_WMEMCMP=1; AC_SUBST([HAVE_WMEMCMP])
184 HAVE_WMEMCPY=1; AC_SUBST([HAVE_WMEMCPY]) 211 HAVE_WMEMCPY=1; AC_SUBST([HAVE_WMEMCPY])
185 HAVE_WMEMMOVE=1; AC_SUBST([HAVE_WMEMMOVE]) 212 HAVE_WMEMMOVE=1; AC_SUBST([HAVE_WMEMMOVE])
213 HAVE_WMEMPCPY=1; AC_SUBST([HAVE_WMEMPCPY])
186 HAVE_WMEMSET=1; AC_SUBST([HAVE_WMEMSET]) 214 HAVE_WMEMSET=1; AC_SUBST([HAVE_WMEMSET])
187 HAVE_WCSLEN=1; AC_SUBST([HAVE_WCSLEN]) 215 HAVE_WCSLEN=1; AC_SUBST([HAVE_WCSLEN])
188 HAVE_WCSNLEN=1; AC_SUBST([HAVE_WCSNLEN]) 216 HAVE_WCSNLEN=1; AC_SUBST([HAVE_WCSNLEN])
@@ -207,7 +235,9 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
207 HAVE_WCSSTR=1; AC_SUBST([HAVE_WCSSTR]) 235 HAVE_WCSSTR=1; AC_SUBST([HAVE_WCSSTR])
208 HAVE_WCSTOK=1; AC_SUBST([HAVE_WCSTOK]) 236 HAVE_WCSTOK=1; AC_SUBST([HAVE_WCSTOK])
209 HAVE_WCSWIDTH=1; AC_SUBST([HAVE_WCSWIDTH]) 237 HAVE_WCSWIDTH=1; AC_SUBST([HAVE_WCSWIDTH])
238 HAVE_WCSFTIME=1; AC_SUBST([HAVE_WCSFTIME])
210 HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB]) 239 HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB])
240 HAVE_DECL_WCSDUP=1; AC_SUBST([HAVE_DECL_WCSDUP])
211 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH]) 241 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
212 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T]) 242 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T])
213 REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC]) 243 REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC])
@@ -222,4 +252,6 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
222 REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS]) 252 REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS])
223 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH]) 253 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
224 REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH]) 254 REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH])
255 REPLACE_WCSFTIME=0; AC_SUBST([REPLACE_WCSFTIME])
256 REPLACE_WCSTOK=0; AC_SUBST([REPLACE_WCSTOK])
225]) 257])
diff --git a/gl/m4/wchar_t.m4 b/gl/m4/wchar_t.m4
index e1e1e699..50bde08a 100644
--- a/gl/m4/wchar_t.m4
+++ b/gl/m4/wchar_t.m4
@@ -1,5 +1,5 @@
1# wchar_t.m4 serial 4 (gettext-0.18.2) 1# wchar_t.m4 serial 4 (gettext-0.18.2)
2dnl Copyright (C) 2002-2003, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2003, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/wcrtomb.m4 b/gl/m4/wcrtomb.m4
index f56b5bae..d51b36e1 100644
--- a/gl/m4/wcrtomb.m4
+++ b/gl/m4/wcrtomb.m4
@@ -1,5 +1,5 @@
1# wcrtomb.m4 serial 11 1# wcrtomb.m4 serial 17
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -15,15 +15,8 @@ AC_DEFUN([gl_FUNC_WCRTOMB],
15 if test $ac_cv_func_wcrtomb = no; then 15 if test $ac_cv_func_wcrtomb = no; then
16 HAVE_WCRTOMB=0 16 HAVE_WCRTOMB=0
17 AC_CHECK_DECLS([wcrtomb],,, [[ 17 AC_CHECK_DECLS([wcrtomb],,, [[
18/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 18 #include <wchar.h>
19 <wchar.h>. 19 ]])
20 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
21 included before <wchar.h>. */
22#include <stddef.h>
23#include <stdio.h>
24#include <time.h>
25#include <wchar.h>
26]])
27 if test $ac_cv_have_decl_wcrtomb = yes; then 20 if test $ac_cv_have_decl_wcrtomb = yes; then
28 dnl On Minix 3.1.8, the system's <wchar.h> declares wcrtomb() although 21 dnl On Minix 3.1.8, the system's <wchar.h> declares wcrtomb() although
29 dnl it does not have the function. Avoid a collision with gnulib's 22 dnl it does not have the function. Avoid a collision with gnulib's
@@ -31,17 +24,56 @@ AC_DEFUN([gl_FUNC_WCRTOMB],
31 REPLACE_WCRTOMB=1 24 REPLACE_WCRTOMB=1
32 fi 25 fi
33 else 26 else
34 if test $REPLACE_MBSTATE_T = 1; then 27 dnl We don't actually need to override wcrtomb when redefining the semantics
35 REPLACE_WCRTOMB=1 28 dnl of the mbstate_t type. Tested on 32-bit AIX.
36 else 29 dnl if test $REPLACE_MBSTATE_T = 1; then
37 dnl On AIX 4.3, OSF/1 5.1 and Solaris 10, wcrtomb (NULL, 0, NULL) sometimes 30 dnl REPLACE_WCRTOMB=1
38 dnl returns 0 instead of 1. 31 dnl fi
32 if test $REPLACE_WCRTOMB = 0; then
33 dnl On Android 4.3, wcrtomb produces wrong characters in the C locale.
34 dnl On AIX 4.3, OSF/1 5.1 and Solaris <= 11.3, wcrtomb (NULL, 0, NULL)
35 dnl sometimes returns 0 instead of 1.
39 AC_REQUIRE([AC_PROG_CC]) 36 AC_REQUIRE([AC_PROG_CC])
40 AC_REQUIRE([gt_LOCALE_FR]) 37 AC_REQUIRE([gt_LOCALE_FR])
41 AC_REQUIRE([gt_LOCALE_FR_UTF8]) 38 AC_REQUIRE([gt_LOCALE_FR_UTF8])
42 AC_REQUIRE([gt_LOCALE_JA]) 39 AC_REQUIRE([gt_LOCALE_JA])
43 AC_REQUIRE([gt_LOCALE_ZH_CN]) 40 AC_REQUIRE([gt_LOCALE_ZH_CN])
44 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 41 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
42 AC_CACHE_CHECK([whether wcrtomb works in the C locale],
43 [gl_cv_func_wcrtomb_works],
44 [AC_RUN_IFELSE(
45 [AC_LANG_SOURCE([[
46#include <string.h>
47#include <stdlib.h>
48#include <wchar.h>
49int main ()
50{
51 mbstate_t state;
52 char out[64];
53 int count;
54 memset (&state, 0, sizeof (state));
55 out[0] = 'x';
56 count = wcrtomb (out, L'a', &state);
57 return !(count == 1 && out[0] == 'a');
58}]])],
59 [gl_cv_func_wcrtomb_works=yes],
60 [gl_cv_func_wcrtomb_works=no],
61 [case "$host_os" in
62 # Guess no on Android.
63 linux*-android*) gl_cv_func_wcrtomb_works="guessing no";;
64 # Guess yes otherwise.
65 *) gl_cv_func_wcrtomb_works="guessing yes";;
66 esac
67 ])
68 ])
69 case "$gl_cv_func_wcrtomb_works" in
70 *yes) ;;
71 *) AC_DEFINE([WCRTOMB_C_LOCALE_BUG], [1],
72 [Define if the wcrtomb function does not work in the C locale.])
73 REPLACE_WCRTOMB=1 ;;
74 esac
75 fi
76 if test $REPLACE_WCRTOMB = 0; then
45 AC_CACHE_CHECK([whether wcrtomb return value is correct], 77 AC_CACHE_CHECK([whether wcrtomb return value is correct],
46 [gl_cv_func_wcrtomb_retval], 78 [gl_cv_func_wcrtomb_retval],
47 [ 79 [
@@ -49,10 +81,10 @@ AC_DEFUN([gl_FUNC_WCRTOMB],
49 dnl is present. 81 dnl is present.
50changequote(,)dnl 82changequote(,)dnl
51 case "$host_os" in 83 case "$host_os" in
52 # Guess no on AIX 4, OSF/1 and Solaris. 84 # Guess no on AIX 4, OSF/1, Solaris, native Windows.
53 aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;; 85 aix4* | osf* | solaris* | mingw*) gl_cv_func_wcrtomb_retval="guessing no" ;;
54 # Guess yes otherwise. 86 # Guess yes otherwise.
55 *) gl_cv_func_wcrtomb_retval="guessing yes" ;; 87 *) gl_cv_func_wcrtomb_retval="guessing yes" ;;
56 esac 88 esac
57changequote([,])dnl 89changequote([,])dnl
58 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then 90 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
@@ -60,14 +92,8 @@ changequote([,])dnl
60 [AC_LANG_SOURCE([[ 92 [AC_LANG_SOURCE([[
61#include <locale.h> 93#include <locale.h>
62#include <string.h> 94#include <string.h>
63/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
64 <wchar.h>.
65 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
66 included before <wchar.h>. */
67#include <stddef.h>
68#include <stdio.h>
69#include <time.h>
70#include <wchar.h> 95#include <wchar.h>
96#include <stdlib.h>
71int main () 97int main ()
72{ 98{
73 int result = 0; 99 int result = 0;
@@ -80,6 +106,12 @@ int main ()
80 { 106 {
81 if (wcrtomb (NULL, 0, NULL) != 1) 107 if (wcrtomb (NULL, 0, NULL) != 1)
82 result |= 2; 108 result |= 2;
109 {
110 wchar_t wc = (wchar_t) 0xBADFACE;
111 if (mbtowc (&wc, "\303\274", 2) == 2)
112 if (wcrtomb (NULL, wc, NULL) != 1)
113 result |= 2;
114 }
83 } 115 }
84 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) 116 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
85 { 117 {
@@ -100,7 +132,9 @@ int main ()
100 ]) 132 ])
101 case "$gl_cv_func_wcrtomb_retval" in 133 case "$gl_cv_func_wcrtomb_retval" in
102 *yes) ;; 134 *yes) ;;
103 *) REPLACE_WCRTOMB=1 ;; 135 *) AC_DEFINE([WCRTOMB_RETVAL_BUG], [1],
136 [Define if the wcrtomb function has an incorrect return value.])
137 REPLACE_WCRTOMB=1 ;;
104 esac 138 esac
105 fi 139 fi
106 fi 140 fi
diff --git a/gl/m4/wctype_h.m4 b/gl/m4/wctype_h.m4
index 82ada0ee..6856a735 100644
--- a/gl/m4/wctype_h.m4
+++ b/gl/m4/wctype_h.m4
@@ -1,15 +1,15 @@
1# wctype_h.m4 serial 18 1# wctype_h.m4 serial 30
2 2
3dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it. 3dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
4 4
5dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. 5dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
6dnl This file is free software; the Free Software Foundation 6dnl This file is free software; the Free Software Foundation
7dnl gives unlimited permission to copy and/or distribute it, 7dnl gives unlimited permission to copy and/or distribute it,
8dnl with or without modifications, as long as this notice is preserved. 8dnl with or without modifications, as long as this notice is preserved.
9 9
10dnl Written by Paul Eggert. 10dnl Written by Paul Eggert.
11 11
12AC_DEFUN([gl_WCTYPE_H], 12AC_DEFUN_ONCE([gl_WCTYPE_H],
13[ 13[
14 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) 14 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
15 AC_REQUIRE([AC_PROG_CC]) 15 AC_REQUIRE([AC_PROG_CC])
@@ -30,6 +30,8 @@ AC_DEFUN([gl_WCTYPE_H],
30 fi 30 fi
31 AC_SUBST([HAVE_WINT_T]) 31 AC_SUBST([HAVE_WINT_T])
32 32
33 AC_REQUIRE([gl_TYPE_WINT_T_PREREQ])
34
33 gl_CHECK_NEXT_HEADERS([wctype.h]) 35 gl_CHECK_NEXT_HEADERS([wctype.h])
34 if test $ac_cv_header_wctype_h = yes; then 36 if test $ac_cv_header_wctype_h = yes; then
35 if test $ac_cv_func_iswcntrl = yes; then 37 if test $ac_cv_func_iswcntrl = yes; then
@@ -39,22 +41,16 @@ AC_DEFUN([gl_WCTYPE_H],
39 [ 41 [
40 AC_RUN_IFELSE( 42 AC_RUN_IFELSE(
41 [AC_LANG_SOURCE([[ 43 [AC_LANG_SOURCE([[
42 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
43 included before <wchar.h>.
44 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
45 must be included before <wchar.h>. */
46 #include <stddef.h>
47 #include <stdio.h>
48 #include <time.h>
49 #include <wchar.h> 44 #include <wchar.h>
50 #include <wctype.h> 45 #include <wctype.h>
51 int main () { return iswprint ('x') == 0; } 46 int main () { return iswprint ('x') == 0; }
52 ]])], 47 ]])],
53 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no], 48 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
54 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h> 49 [dnl Guess no on Linux libc5, yes otherwise.
50 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
55 #if __GNU_LIBRARY__ == 1 51 #if __GNU_LIBRARY__ == 1
56 Linux libc5 i18n is broken. 52 Linux libc5 i18n is broken.
57 #endif]], [])], 53 #endif]], [[]])],
58 [gl_cv_func_iswcntrl_works="guessing yes"], 54 [gl_cv_func_iswcntrl_works="guessing yes"],
59 [gl_cv_func_iswcntrl_works="guessing no"]) 55 [gl_cv_func_iswcntrl_works="guessing no"])
60 ]) 56 ])
@@ -66,10 +62,14 @@ AC_DEFUN([gl_WCTYPE_H],
66 fi 62 fi
67 AC_SUBST([HAVE_WCTYPE_H]) 63 AC_SUBST([HAVE_WCTYPE_H])
68 64
69 case "$gl_cv_func_iswcntrl_works" in 65 if test $GNULIBHEADERS_OVERRIDE_WINT_T = 1; then
70 *yes) REPLACE_ISWCNTRL=0 ;; 66 REPLACE_ISWCNTRL=1
71 *) REPLACE_ISWCNTRL=1 ;; 67 else
72 esac 68 case "$gl_cv_func_iswcntrl_works" in
69 *yes) REPLACE_ISWCNTRL=0 ;;
70 *) REPLACE_ISWCNTRL=1 ;;
71 esac
72 fi
73 AC_SUBST([REPLACE_ISWCNTRL]) 73 AC_SUBST([REPLACE_ISWCNTRL])
74 74
75 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then 75 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
@@ -85,14 +85,7 @@ AC_DEFUN([gl_WCTYPE_H],
85 REPLACE_TOWLOWER=0 85 REPLACE_TOWLOWER=0
86 else 86 else
87 AC_CHECK_DECLS([towlower],,, 87 AC_CHECK_DECLS([towlower],,,
88 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be 88 [[#include <wchar.h>
89 included before <wchar.h>.
90 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
91 must be included before <wchar.h>. */
92 #include <stddef.h>
93 #include <stdio.h>
94 #include <time.h>
95 #include <wchar.h>
96 #if HAVE_WCTYPE_H 89 #if HAVE_WCTYPE_H
97 # include <wctype.h> 90 # include <wctype.h>
98 #endif 91 #endif
@@ -121,14 +114,7 @@ AC_DEFUN([gl_WCTYPE_H],
121 AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t], 114 AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t],
122 [AC_COMPILE_IFELSE( 115 [AC_COMPILE_IFELSE(
123 [AC_LANG_PROGRAM( 116 [AC_LANG_PROGRAM(
124 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be 117 [[#include <wchar.h>
125 included before <wchar.h>.
126 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
127 must be included before <wchar.h>. */
128 #include <stddef.h>
129 #include <stdio.h>
130 #include <time.h>
131 #include <wchar.h>
132 #if HAVE_WCTYPE_H 118 #if HAVE_WCTYPE_H
133 # include <wctype.h> 119 # include <wctype.h>
134 #endif 120 #endif
@@ -147,14 +133,7 @@ AC_DEFUN([gl_WCTYPE_H],
147 AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t], 133 AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t],
148 [AC_COMPILE_IFELSE( 134 [AC_COMPILE_IFELSE(
149 [AC_LANG_PROGRAM( 135 [AC_LANG_PROGRAM(
150 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be 136 [[#include <wchar.h>
151 included before <wchar.h>.
152 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
153 must be included before <wchar.h>. */
154 #include <stddef.h>
155 #include <stdio.h>
156 #include <time.h>
157 #include <wchar.h>
158 #include <wctype.h> 137 #include <wctype.h>
159 wctrans_t a; 138 wctrans_t a;
160 ]], 139 ]],
@@ -169,14 +148,7 @@ AC_DEFUN([gl_WCTYPE_H],
169 dnl Check for declarations of anything we want to poison if the 148 dnl Check for declarations of anything we want to poison if the
170 dnl corresponding gnulib module is not in use. 149 dnl corresponding gnulib module is not in use.
171 gl_WARN_ON_USE_PREPARE([[ 150 gl_WARN_ON_USE_PREPARE([[
172/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
173 <wchar.h>.
174 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
175 included before <wchar.h>. */
176#if !(defined __GLIBC__ && !defined __UCLIBC__) 151#if !(defined __GLIBC__ && !defined __UCLIBC__)
177# include <stddef.h>
178# include <stdio.h>
179# include <time.h>
180# include <wchar.h> 152# include <wchar.h>
181#endif 153#endif
182#include <wctype.h> 154#include <wctype.h>
@@ -185,25 +157,44 @@ AC_DEFUN([gl_WCTYPE_H],
185 ]) 157 ])
186]) 158])
187 159
160# gl_WCTYPE_MODULE_INDICATOR([modulename])
161# sets the shell variable that indicates the presence of the given module
162# to a C preprocessor expression that will evaluate to 1.
163# This macro invocation must not occur in macros that are AC_REQUIREd.
188AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR], 164AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR],
189[ 165[
190 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 166 dnl Ensure to expand the default settings once only.
191 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) 167 gl_WCTYPE_H_REQUIRE_DEFAULTS
192 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 168 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
193 dnl Define it also as a C macro, for the benefit of the unit tests. 169 dnl Define it also as a C macro, for the benefit of the unit tests.
194 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 170 gl_MODULE_INDICATOR_FOR_TESTS([$1])
195]) 171])
196 172
173# Initializes the default values for AC_SUBSTed shell variables.
174# This macro must not be AC_REQUIREd. It must only be invoked, and only
175# outside of macros or in macros that are not AC_REQUIREd.
176AC_DEFUN([gl_WCTYPE_H_REQUIRE_DEFAULTS],
177[
178 m4_defun(GL_MODULE_INDICATOR_PREFIX[_WCTYPE_H_MODULE_INDICATOR_DEFAULTS], [
179 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWBLANK])
180 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWDIGIT])
181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWXDIGIT])
182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTYPE])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWCTYPE])
184 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTRANS])
185 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOWCTRANS])
186 ])
187 m4_require(GL_MODULE_INDICATOR_PREFIX[_WCTYPE_H_MODULE_INDICATOR_DEFAULTS])
188 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
189])
190
197AC_DEFUN([gl_WCTYPE_H_DEFAULTS], 191AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
198[ 192[
199 GNULIB_ISWBLANK=0; AC_SUBST([GNULIB_ISWBLANK])
200 GNULIB_WCTYPE=0; AC_SUBST([GNULIB_WCTYPE])
201 GNULIB_ISWCTYPE=0; AC_SUBST([GNULIB_ISWCTYPE])
202 GNULIB_WCTRANS=0; AC_SUBST([GNULIB_WCTRANS])
203 GNULIB_TOWCTRANS=0; AC_SUBST([GNULIB_TOWCTRANS])
204 dnl Assume proper GNU behavior unless another module says otherwise. 193 dnl Assume proper GNU behavior unless another module says otherwise.
205 HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK]) 194 HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK])
206 HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T]) 195 HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T])
207 HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T]) 196 HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T])
208 REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK]) 197 REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK])
198 REPLACE_ISWDIGIT=0; AC_SUBST([REPLACE_ISWDIGIT])
199 REPLACE_ISWXDIGIT=0; AC_SUBST([REPLACE_ISWXDIGIT])
209]) 200])
diff --git a/gl/m4/wint_t.m4 b/gl/m4/wint_t.m4
index d7cd3db9..dfd743b3 100644
--- a/gl/m4/wint_t.m4
+++ b/gl/m4/wint_t.m4
@@ -1,11 +1,12 @@
1# wint_t.m4 serial 5 (gettext-0.18.2) 1# wint_t.m4 serial 11
2dnl Copyright (C) 2003, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Bruno Haible. 7dnl From Bruno Haible.
8dnl Test whether <wchar.h> has the 'wint_t' type. 8dnl Test whether <wchar.h> has the 'wint_t' type and whether gnulib's
9dnl <wchar.h> or <wctype.h> would, if present, override 'wint_t'.
9dnl Prerequisite: AC_PROG_CC 10dnl Prerequisite: AC_PROG_CC
10 11
11AC_DEFUN([gt_TYPE_WINT_T], 12AC_DEFUN([gt_TYPE_WINT_T],
@@ -13,20 +14,44 @@ AC_DEFUN([gt_TYPE_WINT_T],
13 AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], 14 AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t],
14 [AC_COMPILE_IFELSE( 15 [AC_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM( 16 [AC_LANG_PROGRAM(
16 [[ 17 [[#include <wchar.h>
17/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
18 <wchar.h>.
19 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
20 before <wchar.h>. */
21#include <stddef.h>
22#include <stdio.h>
23#include <time.h>
24#include <wchar.h>
25 wint_t foo = (wchar_t)'\0';]], 18 wint_t foo = (wchar_t)'\0';]],
26 [[]])], 19 [[]])],
27 [gt_cv_c_wint_t=yes], 20 [gt_cv_c_wint_t=yes],
28 [gt_cv_c_wint_t=no])]) 21 [gt_cv_c_wint_t=no])])
29 if test $gt_cv_c_wint_t = yes; then 22 if test $gt_cv_c_wint_t = yes; then
30 AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.]) 23 AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.])
24
25 dnl Determine whether gnulib's <wchar.h> or <wctype.h> would, if present,
26 dnl override 'wint_t'.
27 AC_CACHE_CHECK([whether wint_t is large enough],
28 [gl_cv_type_wint_t_large_enough],
29 [AC_COMPILE_IFELSE(
30 [AC_LANG_PROGRAM(
31 [[#include <wchar.h>
32 int verify[sizeof (wint_t) < sizeof (int) ? -1 : 1];
33 ]])],
34 [gl_cv_type_wint_t_large_enough=yes],
35 [gl_cv_type_wint_t_large_enough=no])])
36 if test $gl_cv_type_wint_t_large_enough = no; then
37 GNULIBHEADERS_OVERRIDE_WINT_T=1
38 else
39 GNULIBHEADERS_OVERRIDE_WINT_T=0
40 fi
41 else
42 GNULIBHEADERS_OVERRIDE_WINT_T=0
43 fi
44 AC_SUBST([GNULIBHEADERS_OVERRIDE_WINT_T])
45])
46
47dnl Prerequisites of the 'wint_t' override.
48AC_DEFUN([gl_TYPE_WINT_T_PREREQ],
49[
50 AC_CHECK_HEADERS_ONCE([crtdefs.h])
51 if test $ac_cv_header_crtdefs_h = yes; then
52 HAVE_CRTDEFS_H=1
53 else
54 HAVE_CRTDEFS_H=0
31 fi 55 fi
56 AC_SUBST([HAVE_CRTDEFS_H])
32]) 57])
diff --git a/gl/m4/xalloc.m4 b/gl/m4/xalloc.m4
index 64ca7014..fc56f59a 100644
--- a/gl/m4/xalloc.m4
+++ b/gl/m4/xalloc.m4
@@ -1,5 +1,5 @@
1# xalloc.m4 serial 18 1# xalloc.m4 serial 18
2dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/xsize.m4 b/gl/m4/xsize.m4
index 8ea9f2cd..649db9c5 100644
--- a/gl/m4/xsize.m4
+++ b/gl/m4/xsize.m4
@@ -1,5 +1,5 @@
1# xsize.m4 serial 5 1# xsize.m4 serial 5
2dnl Copyright (C) 2003-2004, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003-2004, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/xstrndup.m4 b/gl/m4/xstrndup.m4
deleted file mode 100644
index 4a9330bb..00000000
--- a/gl/m4/xstrndup.m4
+++ /dev/null
@@ -1,15 +0,0 @@
1# xstrndup.m4 serial 2
2dnl Copyright (C) 2003, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_XSTRNDUP],
8[
9 gl_PREREQ_XSTRNDUP
10])
11
12# Prerequisites of lib/xstrndup.c.
13AC_DEFUN([gl_PREREQ_XSTRNDUP], [
14 :
15])
diff --git a/gl/m4/zzgnulib.m4 b/gl/m4/zzgnulib.m4
new file mode 100644
index 00000000..362102b6
--- /dev/null
+++ b/gl/m4/zzgnulib.m4
@@ -0,0 +1,23 @@
1# zzgnulib.m4 serial 1
2dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl This file must be named something that sorts after all other
8dnl package- or gnulib-provided .m4 files - at least for those packages
9dnl that redefine AC_PROG_CC.
10
11dnl Redefine AC_PROG_CC so that it ends with invocations of gl_COMPILER_CLANG
12dnl and gl_COMPILER_PREPARE_CHECK_DECL.
13m4_define([AC_PROG_CC],
14 m4_defn([AC_PROG_CC])[
15gl_COMPILER_CLANG
16gl_COMPILER_PREPARE_CHECK_DECL
17])
18
19# gl_ZZGNULIB
20# -----------
21# Witness macro that this file has been included. Needed to force
22# Automake to include this file after all other gnulib .m4 files.
23AC_DEFUN([gl_ZZGNULIB])