summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJosselin Poiret <dev@jpoiret.xyz>2022-09-05 08:48:13 +0200
committerLudovic Courtès <ludo@gnu.org>2023-01-12 16:41:29 +0100
commitedfca3b7e5931b5b5a83112e2a9813b068be99c2 (patch)
tree98f105cff95a668f5ecab668964bbcf1138d4d02 /lib
parentfe2a0c54ac7863a705da8f64fd548e4817b3fb72 (diff)
downloadguile-edfca3b7e5931b5b5a83112e2a9813b068be99c2.tar.gz
Update gnulib to 0.1.5414-8204d and add posix_spawn, posix_spawnp.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am1252
-rw-r--r--lib/_Noreturn.h2
-rw-r--r--lib/accept.c2
-rw-r--r--lib/accept4.c4
-rw-r--r--lib/access.c31
-rw-r--r--lib/alignof.h2
-rw-r--r--lib/alloca.c35
-rw-r--r--lib/alloca.in.h2
-rw-r--r--lib/arg-nonnull.h2
-rw-r--r--lib/arpa_inet.in.h2
-rw-r--r--lib/asnprintf.c2
-rw-r--r--lib/assure.h2
-rw-r--r--lib/attribute.h10
-rw-r--r--lib/basename-lgpl.c2
-rw-r--r--lib/basename-lgpl.h2
-rw-r--r--lib/binary-io.c2
-rw-r--r--lib/binary-io.h4
-rw-r--r--lib/bind.c2
-rw-r--r--lib/btowc.c2
-rw-r--r--lib/byteswap.in.h2
-rw-r--r--lib/c++defs.h2
-rw-r--r--lib/c-ctype.c2
-rw-r--r--lib/c-ctype.h2
-rw-r--r--lib/c-strcase.h2
-rw-r--r--lib/c-strcasecmp.c2
-rw-r--r--lib/c-strcaseeq.h2
-rw-r--r--lib/c-strncasecmp.c2
-rw-r--r--lib/canonicalize-lgpl.c2
-rw-r--r--lib/cdefs.h76
-rw-r--r--lib/ceil.c4
-rw-r--r--lib/cloexec.c2
-rw-r--r--lib/cloexec.h2
-rw-r--r--lib/close.c2
-rw-r--r--lib/concat-filename.c73
-rw-r--r--lib/concat-filename.h46
-rw-r--r--lib/connect.c2
-rw-r--r--lib/copysign.c4
-rw-r--r--lib/dirent.in.h24
-rw-r--r--lib/dirfd.c2
-rw-r--r--lib/dirname-lgpl.c2
-rw-r--r--lib/dirname.h2
-rw-r--r--lib/dup2.c2
-rw-r--r--lib/duplocale.c4
-rw-r--r--lib/dynarray.h2
-rw-r--r--lib/eloop-threshold.h2
-rw-r--r--lib/errno.in.h2
-rw-r--r--lib/fcntl.c2
-rw-r--r--lib/fcntl.in.h6
-rw-r--r--lib/fd-hook.c2
-rw-r--r--lib/fd-hook.h2
-rw-r--r--lib/filename.h2
-rw-r--r--lib/findprog-in.c399
-rw-r--r--lib/findprog.h77
-rw-r--r--lib/flexmember.h2
-rw-r--r--lib/float+.h2
-rw-r--r--lib/float.c2
-rw-r--r--lib/float.in.h2
-rw-r--r--lib/flock.c2
-rw-r--r--lib/floor.c4
-rw-r--r--lib/free.c2
-rw-r--r--lib/frexp.c2
-rw-r--r--lib/fstat.c2
-rw-r--r--lib/fsync.c2
-rw-r--r--lib/full-read.c2
-rw-r--r--lib/full-read.h2
-rw-r--r--lib/full-write.c2
-rw-r--r--lib/full-write.h2
-rw-r--r--lib/gai_strerror.c2
-rw-r--r--lib/getaddrinfo.c2
-rw-r--r--lib/getdtablesize.c2
-rw-r--r--lib/getlogin.c2
-rw-r--r--lib/getpeername.c2
-rw-r--r--lib/getrandom.c2
-rw-r--r--lib/getsockname.c2
-rw-r--r--lib/getsockopt.c2
-rw-r--r--lib/gettext.h15
-rw-r--r--lib/hard-locale.c2
-rw-r--r--lib/hard-locale.h2
-rw-r--r--lib/iconv.c2
-rw-r--r--lib/iconv.in.h2
-rw-r--r--lib/iconv_close.c2
-rw-r--r--lib/iconv_open-aix.gperf2
-rw-r--r--lib/iconv_open-hpux.gperf2
-rw-r--r--lib/iconv_open-irix.gperf2
-rw-r--r--lib/iconv_open-osf.gperf2
-rw-r--r--lib/iconv_open-solaris.gperf2
-rw-r--r--lib/iconv_open-zos.gperf2
-rw-r--r--lib/iconv_open-zos.h329
-rw-r--r--lib/iconv_open.c2
-rw-r--r--lib/iconveh.h7
-rw-r--r--lib/idx.h22
-rw-r--r--lib/inet_ntop.c2
-rw-r--r--lib/inet_pton.c2
-rw-r--r--lib/intprops-internal.h392
-rw-r--r--lib/intprops.h359
-rw-r--r--lib/inttypes.h1509
-rw-r--r--lib/inttypes.in.h2
-rw-r--r--lib/isfinite.c4
-rw-r--r--lib/isinf.c4
-rw-r--r--lib/isnan.c2
-rw-r--r--lib/isnand-nolibm.h2
-rw-r--r--lib/isnand.c2
-rw-r--r--lib/isnanf-nolibm.h2
-rw-r--r--lib/isnanf.c2
-rw-r--r--lib/isnanl-nolibm.h2
-rw-r--r--lib/isnanl.c2
-rw-r--r--lib/itold.c2
-rw-r--r--lib/langinfo.in.h2
-rw-r--r--lib/lc-charset-dispatch.c2
-rw-r--r--lib/lc-charset-dispatch.h2
-rw-r--r--lib/libc-config.h13
-rw-r--r--lib/libunistring.valgrind4
-rw-r--r--lib/limits.in.h2
-rw-r--r--lib/link.c2
-rw-r--r--lib/listen.c2
-rw-r--r--lib/localcharset.c2
-rw-r--r--lib/localcharset.h2
-rw-r--r--lib/locale.in.h2
-rw-r--r--lib/localeconv.c2
-rw-r--r--lib/log.c4
-rw-r--r--lib/log1p.c4
-rw-r--r--lib/lstat.c2
-rw-r--r--lib/malloc.c2
-rw-r--r--lib/malloc/.dirstamp0
-rw-r--r--lib/malloc/dynarray-skeleton.c2
-rw-r--r--lib/malloc/dynarray-skeleton.gl.h529
-rw-r--r--lib/malloc/dynarray.gl.h174
-rw-r--r--lib/malloc/dynarray.h2
-rw-r--r--lib/malloc/dynarray_at_failure.c2
-rw-r--r--lib/malloc/dynarray_emplace_enlarge.c2
-rw-r--r--lib/malloc/dynarray_finalize.c2
-rw-r--r--lib/malloc/dynarray_resize.c2
-rw-r--r--lib/malloc/dynarray_resize_clear.c2
-rw-r--r--lib/malloc/scratch_buffer.h2
-rw-r--r--lib/malloc/scratch_buffer_dupfree.c2
-rw-r--r--lib/malloc/scratch_buffer_grow.c2
-rw-r--r--lib/malloc/scratch_buffer_grow_preserve.c2
-rw-r--r--lib/malloc/scratch_buffer_set_array_size.c2
-rw-r--r--lib/malloca.c12
-rw-r--r--lib/malloca.h2
-rw-r--r--lib/math.c2
-rw-r--r--lib/math.in.h16
-rw-r--r--lib/mbrtowc-impl-utf8.h2
-rw-r--r--lib/mbrtowc-impl.h2
-rw-r--r--lib/mbrtowc.c2
-rw-r--r--lib/mbsinit.c2
-rw-r--r--lib/mbtowc-impl.h2
-rw-r--r--lib/mbtowc-lock.c2
-rw-r--r--lib/mbtowc-lock.h2
-rw-r--r--lib/mbtowc.c2
-rw-r--r--lib/memchr.c2
-rw-r--r--lib/memchr.valgrind2
-rw-r--r--lib/mempcpy.c2
-rw-r--r--lib/minmax.h2
-rw-r--r--lib/mkdir.c4
-rw-r--r--lib/mkostemp.c2
-rw-r--r--lib/mktime-internal.h2
-rw-r--r--lib/mktime.c30
-rw-r--r--lib/msvc-inval.c2
-rw-r--r--lib/msvc-inval.h2
-rw-r--r--lib/msvc-nothrow.c2
-rw-r--r--lib/msvc-nothrow.h2
-rw-r--r--lib/netdb.in.h2
-rw-r--r--lib/netinet_in.in.h2
-rw-r--r--lib/nl_langinfo-lock.c2
-rw-r--r--lib/nl_langinfo.c2
-rw-r--r--lib/nproc.c24
-rw-r--r--lib/nproc.h2
-rw-r--r--lib/nstrftime.c28
-rw-r--r--lib/open.c2
-rw-r--r--lib/pathmax.h2
-rw-r--r--lib/pipe.c2
-rw-r--r--lib/pipe2.c2
-rw-r--r--lib/poll.c2
-rw-r--r--lib/poll.in.h2
-rw-r--r--lib/printf-args.c2
-rw-r--r--lib/printf-args.h2
-rw-r--r--lib/printf-parse.c2
-rw-r--r--lib/printf-parse.h2
-rw-r--r--lib/putenv.c4
-rw-r--r--lib/raise.c2
-rw-r--r--lib/rawmemchr.c78
-rw-r--r--lib/rawmemchr.valgrind2
-rw-r--r--lib/read.c2
-rw-r--r--lib/readlink.c6
-rw-r--r--lib/realloc.c2
-rw-r--r--lib/recv.c2
-rw-r--r--lib/recvfrom.c2
-rw-r--r--lib/regcomp.c831
-rw-r--r--lib/regex.c3
-rw-r--r--lib/regex.h52
-rw-r--r--lib/regex_internal.c64
-rw-r--r--lib/regex_internal.h51
-rw-r--r--lib/regexec.c95
-rw-r--r--lib/rename.c4
-rw-r--r--lib/rmdir.c2
-rw-r--r--lib/round.c4
-rw-r--r--lib/safe-read.c2
-rw-r--r--lib/safe-read.h2
-rw-r--r--lib/safe-write.c2
-rw-r--r--lib/safe-write.h2
-rw-r--r--lib/same-inode.h2
-rw-r--r--lib/sched.h580
-rw-r--r--lib/sched.in.h99
-rw-r--r--lib/scratch_buffer.h2
-rw-r--r--lib/select.c2
-rw-r--r--lib/send.c2
-rw-r--r--lib/sendto.c2
-rw-r--r--lib/setenv.c2
-rw-r--r--lib/setlocale-lock.c2
-rw-r--r--lib/setlocale_null.c2
-rw-r--r--lib/setlocale_null.h2
-rw-r--r--lib/setsockopt.c2
-rw-r--r--lib/shutdown.c2
-rw-r--r--lib/signal.in.h2
-rw-r--r--lib/signbitd.c2
-rw-r--r--lib/signbitf.c2
-rw-r--r--lib/signbitl.c2
-rw-r--r--lib/size_max.h2
-rw-r--r--lib/snprintf.c2
-rw-r--r--lib/socket.c2
-rw-r--r--lib/sockets.c4
-rw-r--r--lib/sockets.h2
-rw-r--r--lib/spawn.c34
-rw-r--r--lib/spawn.h1499
-rw-r--r--lib/spawn.in.h992
-rw-r--r--lib/spawn_int.h72
-rw-r--r--lib/spawni.c965
-rw-r--r--lib/spawnp.c34
-rw-r--r--lib/stat-time.c2
-rw-r--r--lib/stat-time.h8
-rw-r--r--lib/stat-w32.c2
-rw-r--r--lib/stat-w32.h2
-rw-r--r--lib/stat.c2
-rw-r--r--lib/stdalign.in.h2
-rw-r--r--lib/stdbool.h116
-rw-r--r--lib/stdbool.in.h27
-rw-r--r--lib/stdckdint.h38
-rw-r--r--lib/stdckdint.in.h37
-rw-r--r--lib/stddef.in.h2
-rw-r--r--lib/stdint.in.h2
-rw-r--r--lib/stdio-read.c168
-rw-r--r--lib/stdio-write.c206
-rw-r--r--lib/stdio.in.h86
-rw-r--r--lib/stdlib.in.h66
-rw-r--r--lib/stpcpy.c49
-rw-r--r--lib/strchrnul.c142
-rw-r--r--lib/strchrnul.valgrind28
-rw-r--r--lib/strdup.c2
-rw-r--r--lib/streq.h2
-rw-r--r--lib/strftime.h4
-rw-r--r--lib/striconveh.c106
-rw-r--r--lib/striconveh.h2
-rw-r--r--lib/string.in.h175
-rw-r--r--lib/stripslash.c2
-rw-r--r--lib/sys-limits.h2
-rw-r--r--lib/sys_file.in.h2
-rw-r--r--lib/sys_random.in.h8
-rw-r--r--lib/sys_select.in.h15
-rw-r--r--lib/sys_socket.c2
-rw-r--r--lib/sys_socket.in.h2
-rw-r--r--lib/sys_stat.in.h30
-rw-r--r--lib/sys_time.in.h2
-rw-r--r--lib/sys_times.in.h2
-rw-r--r--lib/sys_types.in.h2
-rw-r--r--lib/sys_uio.in.h2
-rw-r--r--lib/tempname.c176
-rw-r--r--lib/tempname.h4
-rw-r--r--lib/time-internal.h4
-rw-r--r--lib/time.in.h13
-rw-r--r--lib/time_r.c2
-rw-r--r--lib/time_rz.c4
-rw-r--r--lib/timegm.c2
-rw-r--r--lib/times.c2
-rw-r--r--lib/trunc.c4
-rw-r--r--lib/tzset.c4
-rw-r--r--lib/unistd.c2
-rw-r--r--lib/unistd.in.h21
-rw-r--r--lib/unsetenv.c2
-rw-r--r--lib/vasnprintf.c241
-rw-r--r--lib/vasnprintf.h2
-rw-r--r--lib/verify.h14
-rw-r--r--lib/vsnprintf.c2
-rw-r--r--lib/w32sock.h2
-rw-r--r--lib/warn-on-use.h8
-rw-r--r--lib/wchar.in.h73
-rw-r--r--lib/wcrtomb.c2
-rw-r--r--lib/wctype-h.c2
-rw-r--r--lib/wctype.in.h2
-rw-r--r--lib/windows-initguard.h2
-rw-r--r--lib/windows-spawn.c727
-rw-r--r--lib/windows-spawn.h157
-rw-r--r--lib/write.c2
-rw-r--r--lib/xalloc-oversized.h2
-rw-r--r--lib/xsize.c2
-rw-r--r--lib/xsize.h2
296 files changed, 11802 insertions, 2374 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index cb29c3136..0e7ed9b91 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,10 +1,10 @@
## DO NOT EDIT! GENERATED AUTOMATICALLY!
## Process this file with automake to produce Makefile.in.
-# Copyright (C) 2002-2021 Free Software Foundation, Inc.
+# Copyright (C) 2002-2022 Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This file is distributed in the hope that it will be useful,
@@ -110,6 +110,7 @@
# pipe-posix \
# pipe2 \
# poll \
+# posix_spawnp \
# putenv \
# readlink \
# recv \
@@ -138,7 +139,7 @@
# warnings \
# wchar
-AUTOMAKE_OPTIONS = 1.11 gnits subdir-objects
+AUTOMAKE_OPTIONS = 1.14 gnits subdir-objects
SUBDIRS =
noinst_HEADERS =
@@ -160,6 +161,7 @@ AM_CFLAGS =
noinst_LTLIBRARIES += libgnu.la
libgnu_la_SOURCES =
+libgnu_la_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS)
libgnu_la_LIBADD = $(gl_LTLIBOBJS)
libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS)
EXTRA_libgnu_la_SOURCES =
@@ -208,10 +210,11 @@ HAVE_INCLUDE_NEXT = (__GNUC__ || __clang__ || 60000000 <= __DECC_VER)
## begin gnulib module accept
+if GL_COND_OBJ_ACCEPT
+libgnu_la_SOURCES += accept.c
+endif
-EXTRA_DIST += accept.c w32sock.h
-
-EXTRA_libgnu_la_SOURCES += accept.c
+EXTRA_DIST += w32sock.h
## end gnulib module accept
@@ -221,6 +224,16 @@ libgnu_la_SOURCES += accept4.c
## end gnulib module accept4
+## begin gnulib module access
+
+if gl_GNULIB_ENABLED_access
+if GL_COND_OBJ_ACCESS
+libgnu_la_SOURCES += access.c
+endif
+
+endif
+## end gnulib module access
+
## begin gnulib module alignof
@@ -249,11 +262,10 @@ BUILT_SOURCES += $(ALLOCA_H)
# doesn't have one that works with the given compiler.
if GL_GENERATE_ALLOCA_H
alloca.h: alloca.in.h $(top_builddir)/config.status
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''HAVE_ALLOCA_H''@|$(HAVE_ALLOCA_H)|g' < $(srcdir)/alloca.in.h; \
- } > $@-t && \
- mv -f $@-t $@
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''HAVE_ALLOCA_H''@|$(HAVE_ALLOCA_H)|g' \
+ $(srcdir)/alloca.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
else
alloca.h: $(top_builddir)/config.status
rm -f $@
@@ -278,10 +290,9 @@ BUILT_SOURCES += arpa/inet.h
# We need the following in order to create <arpa/inet.h> when the system
# doesn't have one.
arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
- $(AM_V_at)$(MKDIR_P) arpa
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/arpa'
+ $(AM_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -298,9 +309,8 @@ arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/arpa_inet.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/arpa_inet.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t
MOSTLYCLEANDIRS += arpa
@@ -340,22 +350,22 @@ libgnu_la_SOURCES += binary-io.h binary-io.c
## begin gnulib module bind
+if GL_COND_OBJ_BIND
+libgnu_la_SOURCES += bind.c
+endif
-EXTRA_DIST += bind.c w32sock.h
-
-EXTRA_libgnu_la_SOURCES += bind.c
+EXTRA_DIST += w32sock.h
## end gnulib module bind
## begin gnulib module btowc
if gl_GNULIB_ENABLED_btowc
-
+if GL_COND_OBJ_BTOWC
+libgnu_la_SOURCES += btowc.c
endif
-EXTRA_DIST += btowc.c
-
-EXTRA_libgnu_la_SOURCES += btowc.c
+endif
## end gnulib module btowc
## begin gnulib module byteswap
@@ -366,11 +376,8 @@ BUILT_SOURCES += $(BYTESWAP_H)
# doesn't have one.
if GL_GENERATE_BYTESWAP_H
byteswap.h: byteswap.in.h $(top_builddir)/config.status
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- cat $(srcdir)/byteswap.in.h; \
- } > $@-t && \
- mv -f $@-t $@
+ $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/byteswap.in.h
+ $(AM_V_at)mv $@-t $@
else
byteswap.h: $(top_builddir)/config.status
rm -f $@
@@ -402,19 +409,17 @@ EXTRA_DIST += c-strcaseeq.h
## begin gnulib module canonicalize-lgpl
-
-EXTRA_DIST += canonicalize-lgpl.c
-
-EXTRA_libgnu_la_SOURCES += canonicalize-lgpl.c
+if GL_COND_OBJ_CANONICALIZE_LGPL
+libgnu_la_SOURCES += canonicalize-lgpl.c
+endif
## end gnulib module canonicalize-lgpl
## begin gnulib module ceil
-
-EXTRA_DIST += ceil.c
-
-EXTRA_libgnu_la_SOURCES += ceil.c
+if GL_COND_OBJ_CEIL
+libgnu_la_SOURCES += ceil.c
+endif
## end gnulib module ceil
@@ -430,28 +435,37 @@ EXTRA_DIST += cloexec.h
## begin gnulib module close
+if GL_COND_OBJ_CLOSE
+libgnu_la_SOURCES += close.c
+endif
-EXTRA_DIST += close.c
+## end gnulib module close
-EXTRA_libgnu_la_SOURCES += close.c
+## begin gnulib module concat-filename
-## end gnulib module close
+if gl_GNULIB_ENABLED_6da965dc4d3aa4f87d68116dce96f1a5
+libgnu_la_SOURCES += concat-filename.c
-## begin gnulib module connect
+endif
+EXTRA_DIST += concat-filename.h
+## end gnulib module concat-filename
-EXTRA_DIST += connect.c w32sock.h
+## begin gnulib module connect
-EXTRA_libgnu_la_SOURCES += connect.c
+if GL_COND_OBJ_CONNECT
+libgnu_la_SOURCES += connect.c
+endif
+
+EXTRA_DIST += w32sock.h
## end gnulib module connect
## begin gnulib module copysign
-
-EXTRA_DIST += copysign.c
-
-EXTRA_libgnu_la_SOURCES += copysign.c
+if GL_COND_OBJ_COPYSIGN
+libgnu_la_SOURCES += copysign.c
+endif
## end gnulib module copysign
@@ -462,9 +476,8 @@ BUILT_SOURCES += dirent.h
# We need the following in order to create <dirent.h> when the system
# doesn't have one that works with the given compiler.
dirent.h: dirent.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''HAVE_DIRENT_H''@|$(HAVE_DIRENT_H)|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -494,9 +507,8 @@ dirent.h: dirent.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/dirent.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/dirent.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += dirent.h dirent.h-t
EXTRA_DIST += dirent.in.h
@@ -505,10 +517,9 @@ EXTRA_DIST += dirent.in.h
## begin gnulib module dirfd
-
-EXTRA_DIST += dirfd.c
-
-EXTRA_libgnu_la_SOURCES += dirfd.c
+if GL_COND_OBJ_DIRFD
+libgnu_la_SOURCES += dirfd.c
+endif
## end gnulib module dirfd
@@ -523,20 +534,18 @@ EXTRA_DIST += dirname.h
## begin gnulib module dup2
if gl_GNULIB_ENABLED_dup2
-
+if GL_COND_OBJ_DUP2
+libgnu_la_SOURCES += dup2.c
endif
-EXTRA_DIST += dup2.c
-
-EXTRA_libgnu_la_SOURCES += dup2.c
+endif
## end gnulib module dup2
## begin gnulib module duplocale
-
-EXTRA_DIST += duplocale.c
-
-EXTRA_libgnu_la_SOURCES += duplocale.c
+if GL_COND_OBJ_DUPLOCALE
+libgnu_la_SOURCES += duplocale.c
+endif
## end gnulib module duplocale
@@ -546,27 +555,24 @@ if gl_GNULIB_ENABLED_dynarray
BUILT_SOURCES += malloc/dynarray.gl.h malloc/dynarray-skeleton.gl.h
malloc/dynarray.gl.h: malloc/dynarray.h
- $(AM_V_at)$(MKDIR_P) malloc
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e '/libc_hidden_proto/d' < $(srcdir)/malloc/dynarray.h; \
- } > $@-t && \
- mv $@-t $@
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/malloc'
+ $(AM_V_at)$(SED_HEADER_STDOUT) \
+ -e '/libc_hidden_proto/d' \
+ $(srcdir)/malloc/dynarray.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += malloc/dynarray.gl.h malloc/dynarray.gl.h-t
malloc/dynarray-skeleton.gl.h: malloc/dynarray-skeleton.c
- $(AM_V_at)$(MKDIR_P) malloc
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|<malloc/dynarray\.h>|<malloc/dynarray.gl.h>|g' \
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/malloc'
+ $(AM_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|<malloc/dynarray\.h>|<malloc/dynarray.gl.h>|g' \
-e 's|__attribute_maybe_unused__|_GL_ATTRIBUTE_MAYBE_UNUSED|g' \
-e 's|__attribute_nonnull__|_GL_ATTRIBUTE_NONNULL|g' \
-e 's|__attribute_warn_unused_result__|_GL_ATTRIBUTE_NODISCARD|g' \
-e 's|__glibc_likely|_GL_LIKELY|g' \
-e 's|__glibc_unlikely|_GL_UNLIKELY|g' \
- < $(srcdir)/malloc/dynarray-skeleton.c; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/malloc/dynarray-skeleton.c > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += malloc/dynarray-skeleton.gl.h malloc/dynarray-skeleton.gl.h-t
libgnu_la_SOURCES += malloc/dynarray_at_failure.c malloc/dynarray_emplace_enlarge.c malloc/dynarray_finalize.c malloc/dynarray_resize.c malloc/dynarray_resize_clear.c
@@ -595,9 +601,8 @@ BUILT_SOURCES += $(ERRNO_H)
# doesn't have one that is POSIX compliant.
if GL_GENERATE_ERRNO_H
errno.h: errno.in.h $(top_builddir)/config.status
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -608,9 +613,8 @@ errno.h: errno.in.h $(top_builddir)/config.status
-e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \
-e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \
-e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \
- < $(srcdir)/errno.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/errno.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
else
errno.h: $(top_builddir)/config.status
rm -f $@
@@ -624,12 +628,11 @@ EXTRA_DIST += errno.in.h
## begin gnulib module fcntl
if gl_GNULIB_ENABLED_fcntl
-
+if GL_COND_OBJ_FCNTL
+libgnu_la_SOURCES += fcntl.c
endif
-EXTRA_DIST += fcntl.c
-
-EXTRA_libgnu_la_SOURCES += fcntl.c
+endif
## end gnulib module fcntl
## begin gnulib module fcntl-h
@@ -639,9 +642,8 @@ BUILT_SOURCES += fcntl.h
# We need the following in order to create <fcntl.h> when the system
# doesn't have one that works with the given compiler.
fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -662,9 +664,8 @@ fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/fcntl.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/fcntl.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += fcntl.h fcntl.h-t
EXTRA_DIST += fcntl.in.h
@@ -688,6 +689,14 @@ EXTRA_DIST += filename.h
## end gnulib module filename
+## begin gnulib module findprog-in
+
+if gl_GNULIB_ENABLED_7be38c8cf2027003f573b80556d26ff2
+libgnu_la_SOURCES += findprog.h findprog-in.c
+
+endif
+## end gnulib module findprog-in
+
## begin gnulib module flexmember
@@ -703,53 +712,53 @@ BUILT_SOURCES += $(FLOAT_H)
# doesn't have one that works with the given compiler.
if GL_GENERATE_FLOAT_H
float.h: float.in.h $(top_builddir)/config.status
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \
-e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \
- < $(srcdir)/float.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/float.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
else
float.h: $(top_builddir)/config.status
rm -f $@
endif
MOSTLYCLEANFILES += float.h float.h-t
-EXTRA_DIST += float.c float.in.h itold.c
+if GL_COND_OBJ_FLOAT
+libgnu_la_SOURCES += float.c
+endif
+if GL_COND_OBJ_ITOLD
+libgnu_la_SOURCES += itold.c
+endif
-EXTRA_libgnu_la_SOURCES += float.c itold.c
+EXTRA_DIST += float.in.h
## end gnulib module float
## begin gnulib module flock
-
-EXTRA_DIST += flock.c
-
-EXTRA_libgnu_la_SOURCES += flock.c
+if GL_COND_OBJ_FLOCK
+libgnu_la_SOURCES += flock.c
+endif
## end gnulib module flock
## begin gnulib module floor
-
-EXTRA_DIST += floor.c
-
-EXTRA_libgnu_la_SOURCES += floor.c
+if GL_COND_OBJ_FLOOR
+libgnu_la_SOURCES += floor.c
+endif
## end gnulib module floor
## begin gnulib module free-posix
-
-EXTRA_DIST += free.c
-
-EXTRA_libgnu_la_SOURCES += free.c
+if GL_COND_OBJ_FREE
+libgnu_la_SOURCES += free.c
+endif
## end gnulib module free-posix
@@ -764,19 +773,21 @@ EXTRA_libgnu_la_SOURCES += frexp.c
## begin gnulib module fstat
+if GL_COND_OBJ_FSTAT
+libgnu_la_SOURCES += fstat.c
+endif
-EXTRA_DIST += fstat.c stat-w32.c stat-w32.h
+EXTRA_DIST += stat-w32.c stat-w32.h
-EXTRA_libgnu_la_SOURCES += fstat.c stat-w32.c
+EXTRA_libgnu_la_SOURCES += stat-w32.c
## end gnulib module fstat
## begin gnulib module fsync
-
-EXTRA_DIST += fsync.c
-
-EXTRA_libgnu_la_SOURCES += fsync.c
+if GL_COND_OBJ_FSYNC
+libgnu_la_SOURCES += fsync.c
+endif
## end gnulib module fsync
@@ -796,6 +807,25 @@ libgnu_la_SOURCES += full-write.h full-write.c
## end gnulib module full-write
+## begin gnulib module gen-header
+
+# In 'sed', replace the pattern space with a "DO NOT EDIT" comment.
+SED_HEADER_NOEDIT = s,.*,/* DO NOT EDIT! GENERATED AUTOMATICALLY! */,
+
+# '$(SED_HEADER_STDOUT) -e "..."' runs 'sed' but first outputs "DO NOT EDIT".
+SED_HEADER_STDOUT = sed -e 1h -e '1$(SED_HEADER_NOEDIT)' -e 1G
+
+# '$(SED_HEADER_TO_AT_t) FILE' copies FILE to $@-t, prepending a leading
+# "DO_NOT_EDIT". Although this could be done more simply via:
+# SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) > $@-t
+# the -n and 'w' avoid a fork+exec, at least when GNU Make is used.
+SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) -n -e 'w $@-t'
+
+# Use $(gl_V_at) instead of $(AM_V_GEN) or $(AM_V_at) on a line that
+gl_V_at = $(AM_V_GEN)
+
+## end gnulib module gen-header
+
## begin gnulib module gendocs
@@ -805,68 +835,70 @@ EXTRA_DIST += $(top_srcdir)/build-aux/gendocs.sh
## begin gnulib module getaddrinfo
-
-EXTRA_DIST += gai_strerror.c getaddrinfo.c
-
-EXTRA_libgnu_la_SOURCES += gai_strerror.c getaddrinfo.c
+if GL_COND_OBJ_GETADDRINFO
+libgnu_la_SOURCES += getaddrinfo.c
+endif
+if GL_COND_OBJ_GAI_STRERROR
+libgnu_la_SOURCES += gai_strerror.c
+endif
## end gnulib module getaddrinfo
## begin gnulib module getdtablesize
if gl_GNULIB_ENABLED_getdtablesize
-
+if GL_COND_OBJ_GETDTABLESIZE
+libgnu_la_SOURCES += getdtablesize.c
endif
-EXTRA_DIST += getdtablesize.c
-
-EXTRA_libgnu_la_SOURCES += getdtablesize.c
+endif
## end gnulib module getdtablesize
## begin gnulib module getlogin
-
-EXTRA_DIST += getlogin.c
-
-EXTRA_libgnu_la_SOURCES += getlogin.c
+if GL_COND_OBJ_GETLOGIN
+libgnu_la_SOURCES += getlogin.c
+endif
## end gnulib module getlogin
## begin gnulib module getpeername
+if GL_COND_OBJ_GETPEERNAME
+libgnu_la_SOURCES += getpeername.c
+endif
-EXTRA_DIST += getpeername.c w32sock.h
-
-EXTRA_libgnu_la_SOURCES += getpeername.c
+EXTRA_DIST += w32sock.h
## end gnulib module getpeername
## begin gnulib module getrandom
if gl_GNULIB_ENABLED_getrandom
-
+if GL_COND_OBJ_GETRANDOM
+libgnu_la_SOURCES += getrandom.c
endif
-EXTRA_DIST += getrandom.c
-
-EXTRA_libgnu_la_SOURCES += getrandom.c
+endif
## end gnulib module getrandom
## begin gnulib module getsockname
+if GL_COND_OBJ_GETSOCKNAME
+libgnu_la_SOURCES += getsockname.c
+endif
-EXTRA_DIST += getsockname.c w32sock.h
-
-EXTRA_libgnu_la_SOURCES += getsockname.c
+EXTRA_DIST += w32sock.h
## end gnulib module getsockname
## begin gnulib module getsockopt
+if GL_COND_OBJ_GETSOCKOPT
+libgnu_la_SOURCES += getsockopt.c
+endif
-EXTRA_DIST += getsockopt.c w32sock.h
-
-EXTRA_libgnu_la_SOURCES += getsockopt.c
+EXTRA_DIST += w32sock.h
## end gnulib module getsockopt
@@ -949,9 +981,8 @@ BUILT_SOURCES += $(ICONV_H)
# doesn't have one that works with the given compiler.
if GL_GENERATE_ICONV_H
iconv.h: iconv.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -964,9 +995,8 @@ iconv.h: iconv.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/iconv.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/iconv.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
else
iconv.h: $(top_builddir)/config.status
rm -f $@
@@ -979,6 +1009,13 @@ EXTRA_DIST += iconv.in.h
## begin gnulib module iconv_open
+if GL_COND_OBJ_ICONV_OPEN
+libgnu_la_SOURCES += iconv_open.c
+endif
+if GL_COND_OBJ_ICONV
+libgnu_la_SOURCES += iconv.c iconv_close.c
+endif
+
$(srcdir)/iconv_open-aix.h: $(srcdir)/iconv_open-aix.gperf
$(V_GPERF)$(GPERF) -m 10 $(srcdir)/iconv_open-aix.gperf > $(srcdir)/iconv_open-aix.h-t && \
mv $(srcdir)/iconv_open-aix.h-t $(srcdir)/iconv_open-aix.h
@@ -1002,9 +1039,7 @@ MOSTLYCLEANFILES += iconv_open-aix.h-t iconv_open-hpux.h-t iconv_open-irix.h
MAINTAINERCLEANFILES += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h iconv_open-zos.h
EXTRA_DIST += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h iconv_open-zos.h
-EXTRA_DIST += iconv.c iconv_close.c iconv_open-aix.gperf iconv_open-hpux.gperf iconv_open-irix.gperf iconv_open-osf.gperf iconv_open-solaris.gperf iconv_open-zos.gperf iconv_open.c
-
-EXTRA_libgnu_la_SOURCES += iconv.c iconv_close.c iconv_open.c
+EXTRA_DIST += iconv_open-aix.gperf iconv_open-hpux.gperf iconv_open-irix.gperf iconv_open-osf.gperf iconv_open-solaris.gperf iconv_open-zos.gperf
## end gnulib module iconv_open
@@ -1016,26 +1051,24 @@ libgnu_la_SOURCES += idx.h
## begin gnulib module inet_ntop
-
-EXTRA_DIST += inet_ntop.c
-
-EXTRA_libgnu_la_SOURCES += inet_ntop.c
+if GL_COND_OBJ_INET_NTOP
+libgnu_la_SOURCES += inet_ntop.c
+endif
## end gnulib module inet_ntop
## begin gnulib module inet_pton
-
-EXTRA_DIST += inet_pton.c
-
-EXTRA_libgnu_la_SOURCES += inet_pton.c
+if GL_COND_OBJ_INET_PTON
+libgnu_la_SOURCES += inet_pton.c
+endif
## end gnulib module inet_pton
## begin gnulib module intprops
-EXTRA_DIST += intprops.h
+EXTRA_DIST += intprops-internal.h intprops.h
## end gnulib module intprops
@@ -1046,9 +1079,8 @@ BUILT_SOURCES += inttypes.h
# We need the following in order to create <inttypes.h> when the system
# doesn't have one that works with the given compiler.
inttypes.h: inttypes.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -1073,9 +1105,8 @@ inttypes.h: inttypes.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_U
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/inttypes.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/inttypes.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += inttypes.h inttypes.h-t
EXTRA_DIST += inttypes.in.h
@@ -1084,19 +1115,17 @@ EXTRA_DIST += inttypes.in.h
## begin gnulib module isfinite
-
-EXTRA_DIST += isfinite.c
-
-EXTRA_libgnu_la_SOURCES += isfinite.c
+if GL_COND_OBJ_ISFINITE
+libgnu_la_SOURCES += isfinite.c
+endif
## end gnulib module isfinite
## begin gnulib module isinf
-
-EXTRA_DIST += isinf.c
-
-EXTRA_libgnu_la_SOURCES += isinf.c
+if GL_COND_OBJ_ISINF
+libgnu_la_SOURCES += isinf.c
+endif
## end gnulib module isinf
@@ -1167,9 +1196,8 @@ BUILT_SOURCES += langinfo.h
# We need the following in order to create an empty placeholder for
# <langinfo.h> when the system doesn't have one.
langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -1185,9 +1213,8 @@ langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_U
-e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/langinfo.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/langinfo.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += langinfo.h langinfo.h-t
EXTRA_DIST += langinfo.in.h
@@ -1206,9 +1233,7 @@ AM_CFLAGS += $(CFLAG_VISIBILITY)
## begin gnulib module libc-config
-if gl_GNULIB_ENABLED_21ee726a3540c09237a8e70c0baf7467
-endif
EXTRA_DIST += cdefs.h libc-config.h
## end gnulib module libc-config
@@ -1228,16 +1253,14 @@ BUILT_SOURCES += $(LIMITS_H)
# doesn't have one that is compatible with GNU.
if GL_GENERATE_LIMITS_H
limits.h: limits.in.h $(top_builddir)/config.status
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_LIMITS_H''@|$(NEXT_LIMITS_H)|g' \
- < $(srcdir)/limits.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/limits.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
else
limits.h: $(top_builddir)/config.status
rm -f $@
@@ -1250,19 +1273,19 @@ EXTRA_DIST += limits.in.h
## begin gnulib module link
-
-EXTRA_DIST += link.c
-
-EXTRA_libgnu_la_SOURCES += link.c
+if GL_COND_OBJ_LINK
+libgnu_la_SOURCES += link.c
+endif
## end gnulib module link
## begin gnulib module listen
+if GL_COND_OBJ_LISTEN
+libgnu_la_SOURCES += listen.c
+endif
-EXTRA_DIST += listen.c w32sock.h
-
-EXTRA_libgnu_la_SOURCES += listen.c
+EXTRA_DIST += w32sock.h
## end gnulib module listen
@@ -1281,9 +1304,8 @@ BUILT_SOURCES += locale.h
# We need the following in order to create <locale.h> when the system
# doesn't have one that provides all definitions.
locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -1307,9 +1329,8 @@ locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/locale.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/locale.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += locale.h locale.h-t
EXTRA_DIST += locale.in.h
@@ -1319,40 +1340,36 @@ EXTRA_DIST += locale.in.h
## begin gnulib module localeconv
if gl_GNULIB_ENABLED_localeconv
-
+if GL_COND_OBJ_LOCALECONV
+libgnu_la_SOURCES += localeconv.c
endif
-EXTRA_DIST += localeconv.c
-
-EXTRA_libgnu_la_SOURCES += localeconv.c
+endif
## end gnulib module localeconv
## begin gnulib module log
if gl_GNULIB_ENABLED_log
-
+if GL_COND_OBJ_LOG
+libgnu_la_SOURCES += log.c
endif
-EXTRA_DIST += log.c
-
-EXTRA_libgnu_la_SOURCES += log.c
+endif
## end gnulib module log
## begin gnulib module log1p
-
-EXTRA_DIST += log1p.c
-
-EXTRA_libgnu_la_SOURCES += log1p.c
+if GL_COND_OBJ_LOG1P
+libgnu_la_SOURCES += log1p.c
+endif
## end gnulib module log1p
## begin gnulib module lstat
-
-EXTRA_DIST += lstat.c
-
-EXTRA_libgnu_la_SOURCES += lstat.c
+if GL_COND_OBJ_LSTAT
+libgnu_la_SOURCES += lstat.c
+endif
## end gnulib module lstat
@@ -1396,9 +1413,8 @@ libgnu_la_SOURCES += math.c
# We need the following in order to create <math.h> when the system
# doesn't have one that works with the given compiler.
math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -1685,9 +1701,9 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
- -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
- } > $@-t && \
- mv $@-t $@
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += math.h math.h-t
EXTRA_DIST += math.in.h
@@ -1697,56 +1713,59 @@ EXTRA_DIST += math.in.h
## begin gnulib module mbrtowc
if gl_GNULIB_ENABLED_mbrtowc
+if GL_COND_OBJ_MBRTOWC
+libgnu_la_SOURCES += mbrtowc.c
+endif
endif
-EXTRA_DIST += lc-charset-dispatch.c lc-charset-dispatch.h mbrtowc-impl-utf8.h mbrtowc-impl.h mbrtowc.c mbtowc-lock.c mbtowc-lock.h windows-initguard.h
+EXTRA_DIST += lc-charset-dispatch.c lc-charset-dispatch.h mbrtowc-impl-utf8.h mbrtowc-impl.h mbtowc-lock.c mbtowc-lock.h windows-initguard.h
-EXTRA_libgnu_la_SOURCES += lc-charset-dispatch.c mbrtowc.c mbtowc-lock.c
+EXTRA_libgnu_la_SOURCES += lc-charset-dispatch.c mbtowc-lock.c
## end gnulib module mbrtowc
## begin gnulib module mbsinit
if gl_GNULIB_ENABLED_mbsinit
-
+if GL_COND_OBJ_MBSINIT
+libgnu_la_SOURCES += mbsinit.c
endif
-EXTRA_DIST += mbsinit.c
-
-EXTRA_libgnu_la_SOURCES += mbsinit.c
+endif
## end gnulib module mbsinit
## begin gnulib module mbtowc
if gl_GNULIB_ENABLED_mbtowc
-
+if GL_COND_OBJ_MBTOWC
+libgnu_la_SOURCES += mbtowc.c
endif
-EXTRA_DIST += mbtowc-impl.h mbtowc.c
-EXTRA_libgnu_la_SOURCES += mbtowc.c
+endif
+EXTRA_DIST += mbtowc-impl.h
## end gnulib module mbtowc
## begin gnulib module memchr
if gl_GNULIB_ENABLED_memchr
-
+if GL_COND_OBJ_MEMCHR
+libgnu_la_SOURCES += memchr.c
endif
-EXTRA_DIST += memchr.c memchr.valgrind
-EXTRA_libgnu_la_SOURCES += memchr.c
+endif
+EXTRA_DIST += memchr.valgrind
## end gnulib module memchr
## begin gnulib module mempcpy
if gl_GNULIB_ENABLED_mempcpy
-
+if GL_COND_OBJ_MEMPCPY
+libgnu_la_SOURCES += mempcpy.c
endif
-EXTRA_DIST += mempcpy.c
-
-EXTRA_libgnu_la_SOURCES += mempcpy.c
+endif
## end gnulib module mempcpy
## begin gnulib module minmax
@@ -1757,19 +1776,17 @@ libgnu_la_SOURCES += minmax.h
## begin gnulib module mkdir
-
-EXTRA_DIST += mkdir.c
-
-EXTRA_libgnu_la_SOURCES += mkdir.c
+if GL_COND_OBJ_MKDIR
+libgnu_la_SOURCES += mkdir.c
+endif
## end gnulib module mkdir
## begin gnulib module mkostemp
-
-EXTRA_DIST += mkostemp.c
-
-EXTRA_libgnu_la_SOURCES += mkostemp.c
+if GL_COND_OBJ_MKOSTEMP
+libgnu_la_SOURCES += mkostemp.c
+endif
## end gnulib module mkostemp
@@ -1797,19 +1814,21 @@ EXTRA_libgnu_la_SOURCES += mktime.c
## begin gnulib module msvc-inval
+if GL_COND_OBJ_MSVC_INVAL
+libgnu_la_SOURCES += msvc-inval.c
+endif
-EXTRA_DIST += msvc-inval.c msvc-inval.h
-
-EXTRA_libgnu_la_SOURCES += msvc-inval.c
+EXTRA_DIST += msvc-inval.h
## end gnulib module msvc-inval
## begin gnulib module msvc-nothrow
+if GL_COND_OBJ_MSVC_NOTHROW
+libgnu_la_SOURCES += msvc-nothrow.c
+endif
-EXTRA_DIST += msvc-nothrow.c msvc-nothrow.h
-
-EXTRA_libgnu_la_SOURCES += msvc-nothrow.c
+EXTRA_DIST += msvc-nothrow.h
## end gnulib module msvc-nothrow
@@ -1820,9 +1839,8 @@ BUILT_SOURCES += netdb.h
# We need the following in order to create <netdb.h> when the system
# doesn't have one that works with the given compiler.
netdb.h: netdb.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -1839,9 +1857,8 @@ netdb.h: netdb.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/netdb.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/netdb.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += netdb.h netdb.h-t
EXTRA_DIST += netdb.in.h
@@ -1850,24 +1867,23 @@ EXTRA_DIST += netdb.in.h
## begin gnulib module netinet_in
+if gl_GNULIB_ENABLED_netinet_in
BUILT_SOURCES += $(NETINET_IN_H)
# We need the following in order to create <netinet/in.h> when the system
# doesn't have one.
if GL_GENERATE_NETINET_IN_H
netinet/in.h: netinet_in.in.h $(top_builddir)/config.status
- $(AM_V_at)$(MKDIR_P) netinet
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/netinet'
+ $(AM_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \
-e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \
- < $(srcdir)/netinet_in.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/netinet_in.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
else
netinet/in.h: $(top_builddir)/config.status
rm -f $@
@@ -1875,16 +1891,21 @@ endif
MOSTLYCLEANFILES += netinet/in.h netinet/in.h-t
MOSTLYCLEANDIRS += netinet
+endif
EXTRA_DIST += netinet_in.in.h
## end gnulib module netinet_in
## begin gnulib module nl_langinfo
+if GL_COND_OBJ_NL_LANGINFO
+libgnu_la_SOURCES += nl_langinfo.c
+endif
+if GL_COND_OBJ_NL_LANGINFO_LOCK
+libgnu_la_SOURCES += nl_langinfo-lock.c
+endif
-EXTRA_DIST += nl_langinfo-lock.c nl_langinfo.c windows-initguard.h
-
-EXTRA_libgnu_la_SOURCES += nl_langinfo-lock.c nl_langinfo.c
+EXTRA_DIST += windows-initguard.h
## end gnulib module nl_langinfo
@@ -1906,10 +1927,9 @@ EXTRA_DIST += strftime.h
## begin gnulib module open
-
-EXTRA_DIST += open.c
-
-EXTRA_libgnu_la_SOURCES += open.c
+if GL_COND_OBJ_OPEN
+libgnu_la_SOURCES += open.c
+endif
## end gnulib module open
@@ -1924,10 +1944,9 @@ EXTRA_DIST += pathmax.h
## begin gnulib module pipe-posix
-
-EXTRA_DIST += pipe.c
-
-EXTRA_libgnu_la_SOURCES += pipe.c
+if GL_COND_OBJ_PIPE
+libgnu_la_SOURCES += pipe.c
+endif
## end gnulib module pipe-posix
@@ -1939,10 +1958,9 @@ libgnu_la_SOURCES += pipe2.c
## begin gnulib module poll
-
-EXTRA_DIST += poll.c
-
-EXTRA_libgnu_la_SOURCES += poll.c
+if GL_COND_OBJ_POLL
+libgnu_la_SOURCES += poll.c
+endif
## end gnulib module poll
@@ -1953,9 +1971,8 @@ BUILT_SOURCES += poll.h
# We need the following in order to create <poll.h> when the system
# doesn't have one.
poll.h: poll.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''HAVE_POLL_H''@|$(HAVE_POLL_H)|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -1967,61 +1984,77 @@ poll.h: poll.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
-e 's|@''REPLACE_POLL''@|$(REPLACE_POLL)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/poll.in.h; \
- } > $@-t && \
- mv -f $@-t $@
+ $(srcdir)/poll.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += poll.h poll.h-t
EXTRA_DIST += poll.in.h
## end gnulib module poll-h
-## begin gnulib module putenv
+## begin gnulib module posix_spawn-internal
+
+if gl_GNULIB_ENABLED_332607f759618fb73dfc3076748afea7
+if GL_COND_OBJ_SPAWNI
+libgnu_la_SOURCES += spawni.c
+endif
+
+endif
+EXTRA_DIST += spawn_int.h
+
+## end gnulib module posix_spawn-internal
+
+## begin gnulib module posix_spawnp
+
+if GL_COND_OBJ_SPAWNP
+libgnu_la_SOURCES += spawnp.c
+endif
+## end gnulib module posix_spawnp
-EXTRA_DIST += putenv.c
+## begin gnulib module putenv
-EXTRA_libgnu_la_SOURCES += putenv.c
+if GL_COND_OBJ_PUTENV
+libgnu_la_SOURCES += putenv.c
+endif
## end gnulib module putenv
## begin gnulib module raise
if gl_GNULIB_ENABLED_raise
-
+if GL_COND_OBJ_RAISE
+libgnu_la_SOURCES += raise.c
endif
-EXTRA_DIST += raise.c
-
-EXTRA_libgnu_la_SOURCES += raise.c
+endif
## end gnulib module raise
## begin gnulib module rawmemchr
if gl_GNULIB_ENABLED_rawmemchr
-
+if GL_COND_OBJ_RAWMEMCHR
+libgnu_la_SOURCES += rawmemchr.c
endif
-EXTRA_DIST += rawmemchr.c rawmemchr.valgrind
-EXTRA_libgnu_la_SOURCES += rawmemchr.c
+endif
+EXTRA_DIST += rawmemchr.valgrind
## end gnulib module rawmemchr
## begin gnulib module read
-
-EXTRA_DIST += read.c
-
-EXTRA_libgnu_la_SOURCES += read.c
+if GL_COND_OBJ_READ
+libgnu_la_SOURCES += read.c
+endif
## end gnulib module read
## begin gnulib module readlink
-
-EXTRA_DIST += readlink.c
-
-EXTRA_libgnu_la_SOURCES += readlink.c
+if GL_COND_OBJ_READLINK
+libgnu_la_SOURCES += readlink.c
+endif
## end gnulib module readlink
@@ -2038,58 +2071,60 @@ EXTRA_libgnu_la_SOURCES += realloc.c
## begin gnulib module recv
+if GL_COND_OBJ_RECV
+libgnu_la_SOURCES += recv.c
+endif
-EXTRA_DIST += recv.c w32sock.h
-
-EXTRA_libgnu_la_SOURCES += recv.c
+EXTRA_DIST += w32sock.h
## end gnulib module recv
## begin gnulib module recvfrom
+if GL_COND_OBJ_RECVFROM
+libgnu_la_SOURCES += recvfrom.c
+endif
-EXTRA_DIST += recvfrom.c w32sock.h
-
-EXTRA_libgnu_la_SOURCES += recvfrom.c
+EXTRA_DIST += w32sock.h
## end gnulib module recvfrom
## begin gnulib module regex
+if GL_COND_OBJ_REGEX
+libgnu_la_SOURCES += regex.c
+endif
-EXTRA_DIST += regcomp.c regex.c regex.h regex_internal.c regex_internal.h regexec.c
+EXTRA_DIST += regcomp.c regex.h regex_internal.c regex_internal.h regexec.c
-EXTRA_libgnu_la_SOURCES += regcomp.c regex.c regex_internal.c regexec.c
+EXTRA_libgnu_la_SOURCES += regcomp.c regex_internal.c regexec.c
## end gnulib module regex
## begin gnulib module rename
-
-EXTRA_DIST += rename.c
-
-EXTRA_libgnu_la_SOURCES += rename.c
+if GL_COND_OBJ_RENAME
+libgnu_la_SOURCES += rename.c
+endif
## end gnulib module rename
## begin gnulib module rmdir
-
-EXTRA_DIST += rmdir.c
-
-EXTRA_libgnu_la_SOURCES += rmdir.c
+if GL_COND_OBJ_RMDIR
+libgnu_la_SOURCES += rmdir.c
+endif
## end gnulib module rmdir
## begin gnulib module round
if gl_GNULIB_ENABLED_round
-
+if GL_COND_OBJ_ROUND
+libgnu_la_SOURCES += round.c
endif
-EXTRA_DIST += round.c
-
-EXTRA_libgnu_la_SOURCES += round.c
+endif
## end gnulib module round
## begin gnulib module safe-read
@@ -2119,22 +2154,49 @@ EXTRA_DIST += same-inode.h
## end gnulib module same-inode
+## begin gnulib module sched
+
+BUILT_SOURCES += sched.h
+
+# We need the following in order to create a replacement for <sched.h> when
+# the system doesn't have one.
+sched.h: sched.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_SCHED_H''@|$(HAVE_SCHED_H)|g' \
+ -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_SCHED_H''@|$(NEXT_SCHED_H)|g' \
+ -e 's|@''HAVE_STRUCT_SCHED_PARAM''@|$(HAVE_STRUCT_SCHED_PARAM)|g' \
+ -e 's/@''GNULIB_SCHED_YIELD''@/$(GL_GNULIB_SCHED_YIELD)/g' \
+ -e 's|@''HAVE_SCHED_YIELD''@|$(HAVE_SCHED_YIELD)|g' \
+ -e 's|@''REPLACE_SCHED_YIELD''@|$(REPLACE_SCHED_YIELD)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ $(srcdir)/sched.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
+MOSTLYCLEANFILES += sched.h sched.h-t
+
+EXTRA_DIST += sched.in.h
+
+## end gnulib module sched
+
## begin gnulib module scratch_buffer
if gl_GNULIB_ENABLED_scratch_buffer
BUILT_SOURCES += malloc/scratch_buffer.gl.h
malloc/scratch_buffer.gl.h: malloc/scratch_buffer.h
- $(AM_V_at)$(MKDIR_P) malloc
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|__always_inline|inline _GL_ATTRIBUTE_ALWAYS_INLINE|g' \
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/malloc'
+ $(AM_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|__always_inline|inline _GL_ATTRIBUTE_ALWAYS_INLINE|g' \
-e 's|__glibc_likely|_GL_LIKELY|g' \
-e 's|__glibc_unlikely|_GL_UNLIKELY|g' \
-e '/libc_hidden_proto/d' \
- < $(srcdir)/malloc/scratch_buffer.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/malloc/scratch_buffer.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += malloc/scratch_buffer.gl.h malloc/scratch_buffer.gl.h-t
libgnu_la_SOURCES += malloc/scratch_buffer_dupfree.c malloc/scratch_buffer_grow.c malloc/scratch_buffer_grow_preserve.c malloc/scratch_buffer_set_array_size.c
@@ -2146,37 +2208,37 @@ EXTRA_DIST += malloc/scratch_buffer.h scratch_buffer.h
## begin gnulib module select
-
-EXTRA_DIST += select.c
-
-EXTRA_libgnu_la_SOURCES += select.c
+if GL_COND_OBJ_SELECT
+libgnu_la_SOURCES += select.c
+endif
## end gnulib module select
## begin gnulib module send
+if GL_COND_OBJ_SEND
+libgnu_la_SOURCES += send.c
+endif
-EXTRA_DIST += send.c w32sock.h
-
-EXTRA_libgnu_la_SOURCES += send.c
+EXTRA_DIST += w32sock.h
## end gnulib module send
## begin gnulib module sendto
+if GL_COND_OBJ_SENDTO
+libgnu_la_SOURCES += sendto.c
+endif
-EXTRA_DIST += sendto.c w32sock.h
-
-EXTRA_libgnu_la_SOURCES += sendto.c
+EXTRA_DIST += w32sock.h
## end gnulib module sendto
## begin gnulib module setenv
-
-EXTRA_DIST += setenv.c
-
-EXTRA_libgnu_la_SOURCES += setenv.c
+if GL_COND_OBJ_SETENV
+libgnu_la_SOURCES += setenv.c
+endif
## end gnulib module setenv
@@ -2184,29 +2246,32 @@ EXTRA_libgnu_la_SOURCES += setenv.c
if gl_GNULIB_ENABLED_e7e881d32ca02f1c997b13c737c64bbd
libgnu_la_SOURCES += setlocale_null.c
-
+if GL_COND_OBJ_SETLOCALE_LOCK
+libgnu_la_SOURCES += setlocale-lock.c
endif
-EXTRA_DIST += setlocale-lock.c setlocale_null.h windows-initguard.h
-EXTRA_libgnu_la_SOURCES += setlocale-lock.c
+endif
+EXTRA_DIST += setlocale_null.h windows-initguard.h
## end gnulib module setlocale-null
## begin gnulib module setsockopt
+if GL_COND_OBJ_SETSOCKOPT
+libgnu_la_SOURCES += setsockopt.c
+endif
-EXTRA_DIST += setsockopt.c w32sock.h
-
-EXTRA_libgnu_la_SOURCES += setsockopt.c
+EXTRA_DIST += w32sock.h
## end gnulib module setsockopt
## begin gnulib module shutdown
+if GL_COND_OBJ_SHUTDOWN
+libgnu_la_SOURCES += shutdown.c
+endif
-EXTRA_DIST += shutdown.c w32sock.h
-
-EXTRA_libgnu_la_SOURCES += shutdown.c
+EXTRA_DIST += w32sock.h
## end gnulib module shutdown
@@ -2217,9 +2282,8 @@ BUILT_SOURCES += signal.h
# We need the following in order to create <signal.h> when the system
# doesn't have a complete one.
signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -2243,9 +2307,8 @@ signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/signal.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/signal.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += signal.h signal.h-t
EXTRA_DIST += signal.in.h
@@ -2255,11 +2318,12 @@ EXTRA_DIST += signal.in.h
## begin gnulib module signbit
if gl_GNULIB_ENABLED_signbit
-
+if GL_COND_OBJ_SIGNBIT3
+libgnu_la_SOURCES += signbitf.c signbitd.c signbitl.c
endif
-EXTRA_DIST += float+.h signbitd.c signbitf.c signbitl.c
-EXTRA_libgnu_la_SOURCES += signbitd.c signbitf.c signbitl.c
+endif
+EXTRA_DIST += float+.h
## end gnulib module signbit
@@ -2332,10 +2396,11 @@ EXTRA_libgnu_la_SOURCES += snprintf.c
## begin gnulib module socket
+if GL_COND_OBJ_SOCKET
+libgnu_la_SOURCES += socket.c
+endif
-EXTRA_DIST += socket.c w32sock.h
-
-EXTRA_libgnu_la_SOURCES += socket.c
+EXTRA_DIST += w32sock.h
## end gnulib module socket
@@ -2349,14 +2414,76 @@ EXTRA_DIST += w32sock.h
## end gnulib module sockets
+## begin gnulib module spawn
+
+BUILT_SOURCES += spawn.h
+
+# We need the following in order to create a replacement for <spawn.h> when
+# the system doesn't have one.
+spawn.h: spawn.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_SPAWN_H''@|$(HAVE_SPAWN_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_SPAWN_H''@|$(NEXT_SPAWN_H)|g' \
+ -e 's/@''GNULIB_POSIX_SPAWN''@/$(GL_GNULIB_POSIX_SPAWN)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWNP''@/$(GL_GNULIB_POSIX_SPAWNP)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT''@/$(GL_GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR''@/$(GL_GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE''@/$(GL_GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2''@/$(GL_GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR''@/$(GL_GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN''@/$(GL_GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY''@/$(GL_GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWNATTR_INIT''@/$(GL_GNULIB_POSIX_SPAWNATTR_INIT)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWNATTR_GETFLAGS''@/$(GL_GNULIB_POSIX_SPAWNATTR_GETFLAGS)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWNATTR_SETFLAGS''@/$(GL_GNULIB_POSIX_SPAWNATTR_SETFLAGS)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWNATTR_GETPGROUP''@/$(GL_GNULIB_POSIX_SPAWNATTR_GETPGROUP)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWNATTR_SETPGROUP''@/$(GL_GNULIB_POSIX_SPAWNATTR_SETPGROUP)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM''@/$(GL_GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM''@/$(GL_GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY''@/$(GL_GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY''@/$(GL_GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT''@/$(GL_GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT''@/$(GL_GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSIGMASK''@/$(GL_GNULIB_POSIX_SPAWNATTR_GETSIGMASK)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSIGMASK''@/$(GL_GNULIB_POSIX_SPAWNATTR_SETSIGMASK)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWNATTR_DESTROY''@/$(GL_GNULIB_POSIX_SPAWNATTR_DESTROY)/g' \
+ -e 's|@''HAVE_POSIX_SPAWN''@|$(HAVE_POSIX_SPAWN)|g' \
+ -e 's|@''HAVE_POSIX_SPAWNATTR_T''@|$(HAVE_POSIX_SPAWNATTR_T)|g' \
+ -e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_T''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_T)|g' \
+ -e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)|g' \
+ -e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR)|g' \
+ -e 's|@''REPLACE_POSIX_SPAWN''@|$(REPLACE_POSIX_SPAWN)|g' \
+ -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)|g' \
+ -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE)|g' \
+ -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2)|g' \
+ -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR)|g' \
+ -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ $(srcdir)/spawn.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
+MOSTLYCLEANFILES += spawn.h spawn.h-t
+
+EXTRA_DIST += spawn.in.h
+
+## end gnulib module spawn
+
## begin gnulib module stat
if gl_GNULIB_ENABLED_stat
+if GL_COND_OBJ_STAT
+libgnu_la_SOURCES += stat.c
+endif
endif
-EXTRA_DIST += stat-w32.c stat-w32.h stat.c
+EXTRA_DIST += stat-w32.c stat-w32.h
-EXTRA_libgnu_la_SOURCES += stat-w32.c stat.c
+EXTRA_libgnu_la_SOURCES += stat-w32.c
## end gnulib module stat
@@ -2376,11 +2503,8 @@ BUILT_SOURCES += $(STDALIGN_H)
# doesn't have one that works.
if GL_GENERATE_STDALIGN_H
stdalign.h: stdalign.in.h $(top_builddir)/config.status
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- cat $(srcdir)/stdalign.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/stdalign.in.h
+ $(AM_V_at)mv $@-t $@
else
stdalign.h: $(top_builddir)/config.status
rm -f $@
@@ -2399,11 +2523,10 @@ BUILT_SOURCES += $(STDBOOL_H)
# doesn't have one that works.
if GL_GENERATE_STDBOOL_H
stdbool.h: stdbool.in.h $(top_builddir)/config.status
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' \
+ $(srcdir)/stdbool.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
else
stdbool.h: $(top_builddir)/config.status
rm -f $@
@@ -2414,6 +2537,27 @@ EXTRA_DIST += stdbool.in.h
## end gnulib module stdbool
+## begin gnulib module stdckdint
+
+BUILT_SOURCES += $(STDCKDINT_H)
+
+# We need the following in order to create <stdckdint.h> when the system
+# doesn't have one that works with the given compiler.
+if GL_GENERATE_STDCKDINT_H
+stdckdint.h: stdckdint.in.h $(top_builddir)/config.status
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ $(srcdir)/stdckdint.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
+else
+stdckdint.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += stdckdint.h stdckdint.h-t
+
+EXTRA_DIST += intprops-internal.h stdckdint.in.h
+
+## end gnulib module stdckdint
+
## begin gnulib module stddef
BUILT_SOURCES += $(STDDEF_H)
@@ -2422,9 +2566,8 @@ BUILT_SOURCES += $(STDDEF_H)
# doesn't have one that works with the given compiler.
if GL_GENERATE_STDDEF_H
stddef.h: stddef.in.h $(top_builddir)/config.status
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -2432,9 +2575,8 @@ stddef.h: stddef.in.h $(top_builddir)/config.status
-e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \
-e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
-e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
- < $(srcdir)/stddef.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/stddef.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
else
stddef.h: $(top_builddir)/config.status
rm -f $@
@@ -2453,9 +2595,8 @@ BUILT_SOURCES += $(STDINT_H)
# doesn't have one that works with the given compiler.
if GL_GENERATE_STDINT_H
stdint.h: stdint.in.h $(top_builddir)/config.status
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -2482,9 +2623,8 @@ stdint.h: stdint.in.h $(top_builddir)/config.status
-e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
-e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
-e 's/@''GNULIBHEADERS_OVERRIDE_WINT_T''@/$(GNULIBHEADERS_OVERRIDE_WINT_T)/g' \
- < $(srcdir)/stdint.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/stdint.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
else
stdint.h: $(top_builddir)/config.status
rm -f $@
@@ -2502,9 +2642,8 @@ BUILT_SOURCES += stdio.h
# We need the following in order to create <stdio.h> when the system
# doesn't have one that works with the given compiler.
stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -2516,6 +2655,7 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e 's/@''GNULIB_FGETC''@/$(GL_GNULIB_FGETC)/g' \
-e 's/@''GNULIB_FGETS''@/$(GL_GNULIB_FGETS)/g' \
-e 's/@''GNULIB_FOPEN''@/$(GL_GNULIB_FOPEN)/g' \
+ -e 's/@''GNULIB_FOPEN_GNU''@/$(GL_GNULIB_FOPEN_GNU)/g' \
-e 's/@''GNULIB_FPRINTF''@/$(GL_GNULIB_FPRINTF)/g' \
-e 's/@''GNULIB_FPRINTF_POSIX''@/$(GL_GNULIB_FPRINTF_POSIX)/g' \
-e 's/@''GNULIB_FPURGE''@/$(GL_GNULIB_FPURGE)/g' \
@@ -2591,6 +2731,7 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \
-e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
-e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \
+ -e 's|@''REPLACE_FOPEN_FOR_FOPEN_GNU''@|$(REPLACE_FOPEN_FOR_FOPEN_GNU)|g' \
-e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
-e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \
-e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \
@@ -2621,11 +2762,18 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
- -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
- } > $@-t && \
- mv $@-t $@
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += stdio.h stdio.h-t
+if GL_COND_OBJ_STDIO_READ
+libgnu_la_SOURCES += stdio-read.c
+endif
+if GL_COND_OBJ_STDIO_WRITE
+libgnu_la_SOURCES += stdio-write.c
+endif
+
EXTRA_DIST += stdio.in.h
## end gnulib module stdio
@@ -2638,9 +2786,8 @@ BUILT_SOURCES += stdlib.h
# doesn't have one that works with the given compiler.
stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
$(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -2648,12 +2795,14 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's/@''GNULIB__EXIT''@/$(GL_GNULIB__EXIT)/g' \
-e 's/@''GNULIB_ALIGNED_ALLOC''@/$(GL_GNULIB_ALIGNED_ALLOC)/g' \
-e 's/@''GNULIB_ATOLL''@/$(GL_GNULIB_ATOLL)/g' \
+ -e 's/@''GNULIB_CALLOC_GNU''@/$(GL_GNULIB_CALLOC_GNU)/g' \
-e 's/@''GNULIB_CALLOC_POSIX''@/$(GL_GNULIB_CALLOC_POSIX)/g' \
-e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GL_GNULIB_CANONICALIZE_FILE_NAME)/g' \
-e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \
-e 's/@''GNULIB_GETLOADAVG''@/$(GL_GNULIB_GETLOADAVG)/g' \
-e 's/@''GNULIB_GETSUBOPT''@/$(GL_GNULIB_GETSUBOPT)/g' \
-e 's/@''GNULIB_GRANTPT''@/$(GL_GNULIB_GRANTPT)/g' \
+ -e 's/@''GNULIB_MALLOC_GNU''@/$(GL_GNULIB_MALLOC_GNU)/g' \
-e 's/@''GNULIB_MALLOC_POSIX''@/$(GL_GNULIB_MALLOC_POSIX)/g' \
-e 's/@''GNULIB_MBTOWC''@/$(GL_GNULIB_MBTOWC)/g' \
-e 's/@''GNULIB_MKDTEMP''@/$(GL_GNULIB_MKDTEMP)/g' \
@@ -2669,6 +2818,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's/@''GNULIB_QSORT_R''@/$(GL_GNULIB_QSORT_R)/g' \
-e 's/@''GNULIB_RANDOM''@/$(GL_GNULIB_RANDOM)/g' \
-e 's/@''GNULIB_RANDOM_R''@/$(GL_GNULIB_RANDOM_R)/g' \
+ -e 's/@''GNULIB_REALLOC_GNU''@/$(GL_GNULIB_REALLOC_GNU)/g' \
-e 's/@''GNULIB_REALLOC_POSIX''@/$(GL_GNULIB_REALLOC_POSIX)/g' \
-e 's/@''GNULIB_REALLOCARRAY''@/$(GL_GNULIB_REALLOCARRAY)/g' \
-e 's/@''GNULIB_REALPATH''@/$(GL_GNULIB_REALPATH)/g' \
@@ -2735,11 +2885,13 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
-e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
-e 's|@''REPLACE_ALIGNED_ALLOC''@|$(REPLACE_ALIGNED_ALLOC)|g' \
- -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \
+ -e 's|@''REPLACE_CALLOC_FOR_CALLOC_GNU''@|$(REPLACE_CALLOC_FOR_CALLOC_GNU)|g' \
+ -e 's|@''REPLACE_CALLOC_FOR_CALLOC_POSIX''@|$(REPLACE_CALLOC_FOR_CALLOC_POSIX)|g' \
-e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
-e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
-e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \
- -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \
+ -e 's|@''REPLACE_MALLOC_FOR_MALLOC_GNU''@|$(REPLACE_MALLOC_FOR_MALLOC_GNU)|g' \
+ -e 's|@''REPLACE_MALLOC_FOR_MALLOC_POSIX''@|$(REPLACE_MALLOC_FOR_MALLOC_POSIX)|g' \
-e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
-e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
-e 's|@''REPLACE_POSIX_MEMALIGN''@|$(REPLACE_POSIX_MEMALIGN)|g' \
@@ -2749,7 +2901,8 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \
-e 's|@''REPLACE_RANDOM''@|$(REPLACE_RANDOM)|g' \
-e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
- -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \
+ -e 's|@''REPLACE_REALLOC_FOR_REALLOC_GNU''@|$(REPLACE_REALLOC_FOR_REALLOC_GNU)|g' \
+ -e 's|@''REPLACE_REALLOC_FOR_REALLOC_POSIX''@|$(REPLACE_REALLOC_FOR_REALLOC_POSIX)|g' \
-e 's|@''REPLACE_REALLOCARRAY''@|$(REPLACE_REALLOCARRAY)|g' \
-e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
-e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
@@ -2765,24 +2918,45 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _Noreturn/r $(_NORETURN_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
- -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
- } > $@-t && \
- mv $@-t $@
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += stdlib.h stdlib.h-t
EXTRA_DIST += stdlib.in.h
## end gnulib module stdlib
-## begin gnulib module strdup-posix
+## begin gnulib module stpcpy
-if gl_GNULIB_ENABLED_f9850631dca91859e9cddac9359921c0
+if gl_GNULIB_ENABLED_stpcpy
+if GL_COND_OBJ_STPCPY
+libgnu_la_SOURCES += stpcpy.c
+endif
endif
-EXTRA_DIST += strdup.c
+## end gnulib module stpcpy
-EXTRA_libgnu_la_SOURCES += strdup.c
+## begin gnulib module strchrnul
+if gl_GNULIB_ENABLED_strchrnul
+if GL_COND_OBJ_STRCHRNUL
+libgnu_la_SOURCES += strchrnul.c
+endif
+
+endif
+EXTRA_DIST += strchrnul.valgrind
+
+## end gnulib module strchrnul
+
+## begin gnulib module strdup-posix
+
+if gl_GNULIB_ENABLED_f9850631dca91859e9cddac9359921c0
+if GL_COND_OBJ_STRDUP
+libgnu_la_SOURCES += strdup.c
+endif
+
+endif
## end gnulib module strdup-posix
## begin gnulib module streq
@@ -2812,9 +2986,8 @@ BUILT_SOURCES += string.h
# We need the following in order to create <string.h> when the system
# doesn't have one that works with the given compiler.
string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -2862,6 +3035,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's/@''GNULIB_STRVERSCMP''@/$(GL_GNULIB_STRVERSCMP)/g' \
-e 's/@''GNULIB_MDA_MEMCCPY''@/$(GL_GNULIB_MDA_MEMCCPY)/g' \
-e 's/@''GNULIB_MDA_STRDUP''@/$(GL_GNULIB_MDA_STRDUP)/g' \
+ -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \
< $(srcdir)/string.in.h | \
sed -e 's|@''HAVE_EXPLICIT_BZERO''@|$(HAVE_EXPLICIT_BZERO)|g' \
-e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
@@ -2890,6 +3064,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''REPLACE_FFSLL''@|$(REPLACE_FFSLL)|g' \
-e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
-e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
+ -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
-e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
-e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \
-e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
@@ -2906,10 +3081,9 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
- -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
- < $(srcdir)/string.in.h; \
- } > $@-t && \
- mv $@-t $@
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += string.h string.h-t
EXTRA_DIST += string.in.h
@@ -2923,10 +3097,9 @@ BUILT_SOURCES += sys/file.h
# We need the following in order to create <sys/file.h> when the system
# has one that is incomplete.
sys/file.h: sys_file.in.h $(top_builddir)/config.status $(WARN_ON_USE_H)
- $(AM_V_at)$(MKDIR_P) sys
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
+ $(AM_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's/@''HAVE_SYS_FILE_H''@/$(HAVE_SYS_FILE_H)/g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -2935,9 +3108,8 @@ sys/file.h: sys_file.in.h $(top_builddir)/config.status $(WARN_ON_USE_H)
-e 's/@''HAVE_FLOCK''@/$(HAVE_FLOCK)/g' \
-e 's/@''GNULIB_FLOCK''@/$(GL_GNULIB_FLOCK)/g' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/sys_file.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/sys_file.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += sys/file.h sys/file.h-t
MOSTLYCLEANDIRS += sys
@@ -2953,10 +3125,9 @@ BUILT_SOURCES += sys/random.h
# We need the following in order to create <sys/random.h> when the system
# doesn't have one.
sys/random.h: sys_random.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_at)$(MKDIR_P) sys
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
+ $(AM_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -2968,9 +3139,8 @@ sys/random.h: sys_random.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_N
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/sys_random.in.h; \
- } > $@-t && \
- mv -f $@-t $@
+ $(srcdir)/sys_random.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += sys/random.h sys/random.h-t
MOSTLYCLEANDIRS += sys
@@ -2986,10 +3156,9 @@ BUILT_SOURCES += sys/select.h
# We need the following in order to create <sys/select.h> when the system
# doesn't have one that works with the given compiler.
sys/select.h: sys_select.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
- $(AM_V_at)$(MKDIR_P) sys
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
+ $(AM_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -3003,9 +3172,8 @@ sys/select.h: sys_select.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_
-e 's|@''REPLACE_SELECT''@|$(REPLACE_SELECT)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/sys_select.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/sys_select.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += sys/select.h sys/select.h-t
MOSTLYCLEANDIRS += sys
@@ -3021,10 +3189,9 @@ libgnu_la_SOURCES += sys_socket.c
# We need the following in order to create <sys/socket.h> when the system
# doesn't have one that works with the given compiler.
sys/socket.h: sys_socket.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
- $(AM_V_at)$(MKDIR_P) sys
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
+ $(AM_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -3055,9 +3222,8 @@ sys/socket.h: sys_socket.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/sys_socket.in.h; \
- } > $@-t && \
- mv -f $@-t $@
+ $(srcdir)/sys_socket.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t
MOSTLYCLEANDIRS += sys
@@ -3072,16 +3238,16 @@ BUILT_SOURCES += sys/stat.h
# We need the following in order to create <sys/stat.h> when the system
# has one that is incomplete.
sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_at)$(MKDIR_P) sys
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
+ $(AM_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
-e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \
-e 's|@''WINDOWS_STAT_TIMESPEC''@|$(WINDOWS_STAT_TIMESPEC)|g' \
+ -e 's/@''GNULIB_CHMOD''@/$(GL_GNULIB_CHMOD)/g' \
-e 's/@''GNULIB_FCHMODAT''@/$(GL_GNULIB_FCHMODAT)/g' \
-e 's/@''GNULIB_FSTAT''@/$(GL_GNULIB_FSTAT)/g' \
-e 's/@''GNULIB_FSTATAT''@/$(GL_GNULIB_FSTATAT)/g' \
@@ -3113,6 +3279,7 @@ sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU
-e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
-e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
-e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
+ -e 's|@''REPLACE_CHMOD''@|$(REPLACE_CHMOD)|g' \
-e 's|@''REPLACE_FCHMODAT''@|$(REPLACE_FCHMODAT)|g' \
-e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
-e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
@@ -3128,9 +3295,8 @@ sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/sys_stat.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/sys_stat.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t
MOSTLYCLEANDIRS += sys
@@ -3145,10 +3311,9 @@ BUILT_SOURCES += sys/time.h
# We need the following in order to create <sys/time.h> when the system
# doesn't have one that works with the given compiler.
sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_at)$(MKDIR_P) sys
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
+ $(AM_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -3163,9 +3328,8 @@ sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/sys_time.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/sys_time.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += sys/time.h sys/time.h-t
EXTRA_DIST += sys_time.in.h
@@ -3179,10 +3343,9 @@ BUILT_SOURCES += sys/times.h
# We need the following in order to create <sys/times.h> when the system
# doesn't have one that works with the given compiler.
sys/times.h: sys_times.in.h $(top_builddir)/config.status $(WARN_ON_USE_H) $(ARG_NONNULL_H)
- $(AM_V_at)$(MKDIR_P) sys
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
+ $(AM_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's/@''HAVE_SYS_TIMES_H''@/$(HAVE_SYS_TIMES_H)/g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -3193,9 +3356,8 @@ sys/times.h: sys_times.in.h $(top_builddir)/config.status $(WARN_ON_USE_H) $(ARG
-e 's|@''HAVE_TIMES''@|$(HAVE_TIMES)|g' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/sys_times.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/sys_times.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += sys/times.h sys/times.h-t
MOSTLYCLEANDIRS += sys
@@ -3210,19 +3372,17 @@ BUILT_SOURCES += sys/types.h
# We need the following in order to create <sys/types.h> when the system
# doesn't have one that works with the given compiler.
sys/types.h: sys_types.in.h $(top_builddir)/config.status
- $(AM_V_at)$(MKDIR_P) sys
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
+ $(AM_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
-e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
-e 's|@''WINDOWS_STAT_INODES''@|$(WINDOWS_STAT_INODES)|g' \
- < $(srcdir)/sys_types.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/sys_types.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += sys/types.h sys/types.h-t
EXTRA_DIST += sys_types.in.h
@@ -3236,18 +3396,16 @@ BUILT_SOURCES += sys/uio.h
# We need the following in order to create <sys/uio.h> when the system
# doesn't have one that works with the given compiler.
sys/uio.h: sys_uio.in.h $(top_builddir)/config.status
- $(AM_V_at)$(MKDIR_P) sys
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
+ $(AM_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_SYS_UIO_H''@|$(NEXT_SYS_UIO_H)|g' \
-e 's|@''HAVE_SYS_UIO_H''@|$(HAVE_SYS_UIO_H)|g' \
- < $(srcdir)/sys_uio.in.h; \
- } > $@-t && \
- mv -f $@-t $@
+ $(srcdir)/sys_uio.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += sys/uio.h sys/uio.h-t
MOSTLYCLEANDIRS += sys
@@ -3272,9 +3430,8 @@ BUILT_SOURCES += time.h
# We need the following in order to create <time.h> when the system
# doesn't have one that works with the given compiler.
time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -3287,6 +3444,7 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's/@''GNULIB_STRPTIME''@/$(GL_GNULIB_STRPTIME)/g' \
-e 's/@''GNULIB_TIMEGM''@/$(GL_GNULIB_TIMEGM)/g' \
-e 's/@''GNULIB_TIMESPEC_GET''@/$(GL_GNULIB_TIMESPEC_GET)/g' \
+ -e 's/@''GNULIB_TIMESPEC_GETRES''@/$(GL_GNULIB_TIMESPEC_GETRES)/g' \
-e 's/@''GNULIB_TIME_R''@/$(GL_GNULIB_TIME_R)/g' \
-e 's/@''GNULIB_TIME_RZ''@/$(GL_GNULIB_TIME_RZ)/g' \
-e 's/@''GNULIB_TZSET''@/$(GL_GNULIB_TZSET)/g' \
@@ -3296,6 +3454,7 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
-e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
-e 's|@''HAVE_TIMESPEC_GET''@|$(HAVE_TIMESPEC_GET)|g' \
+ -e 's|@''HAVE_TIMESPEC_GETRES''@|$(HAVE_TIMESPEC_GETRES)|g' \
-e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \
-e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \
-e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
@@ -3314,9 +3473,8 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/time.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/time.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += time.h time.h-t
EXTRA_DIST += time.in.h
@@ -3326,61 +3484,59 @@ EXTRA_DIST += time.in.h
## begin gnulib module time_r
if gl_GNULIB_ENABLED_time_r
-
+if GL_COND_OBJ_TIME_R
+libgnu_la_SOURCES += time_r.c
endif
-EXTRA_DIST += time_r.c
-
-EXTRA_libgnu_la_SOURCES += time_r.c
+endif
## end gnulib module time_r
## begin gnulib module time_rz
+if GL_COND_OBJ_TIME_RZ
+libgnu_la_SOURCES += time_rz.c
+endif
-EXTRA_DIST += time-internal.h time_rz.c
-
-EXTRA_libgnu_la_SOURCES += time_rz.c
+EXTRA_DIST += time-internal.h
## end gnulib module time_rz
## begin gnulib module timegm
if gl_GNULIB_ENABLED_timegm
-
+if GL_COND_OBJ_TIMEGM
+libgnu_la_SOURCES += timegm.c
endif
-EXTRA_DIST += mktime-internal.h timegm.c
-EXTRA_libgnu_la_SOURCES += timegm.c
+endif
+EXTRA_DIST += mktime-internal.h
## end gnulib module timegm
## begin gnulib module times
-
-EXTRA_DIST += times.c
-
-EXTRA_libgnu_la_SOURCES += times.c
+if GL_COND_OBJ_TIMES
+libgnu_la_SOURCES += times.c
+endif
## end gnulib module times
## begin gnulib module trunc
-
-EXTRA_DIST += trunc.c
-
-EXTRA_libgnu_la_SOURCES += trunc.c
+if GL_COND_OBJ_TRUNC
+libgnu_la_SOURCES += trunc.c
+endif
## end gnulib module trunc
## begin gnulib module tzset
if gl_GNULIB_ENABLED_tzset
-
+if GL_COND_OBJ_TZSET
+libgnu_la_SOURCES += tzset.c
endif
-EXTRA_DIST += tzset.c
-
-EXTRA_libgnu_la_SOURCES += tzset.c
+endif
## end gnulib module tzset
## begin gnulib module unistd
@@ -3391,9 +3547,8 @@ libgnu_la_SOURCES += unistd.c
# We need the following in order to create an empty placeholder for
# <unistd.h> when the system doesn't have one.
unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -3434,6 +3589,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's/@''GNULIB_GETOPT_POSIX''@/$(GL_GNULIB_GETOPT_POSIX)/g' \
-e 's/@''GNULIB_GETPAGESIZE''@/$(GL_GNULIB_GETPAGESIZE)/g' \
-e 's/@''GNULIB_GETPASS''@/$(GL_GNULIB_GETPASS)/g' \
+ -e 's/@''GNULIB_GETPASS_GNU''@/$(GL_GNULIB_GETPASS_GNU)/g' \
-e 's/@''GNULIB_GETUSERSHELL''@/$(GL_GNULIB_GETUSERSHELL)/g' \
-e 's/@''GNULIB_GROUP_MEMBER''@/$(GL_GNULIB_GROUP_MEMBER)/g' \
-e 's/@''GNULIB_ISATTY''@/$(GL_GNULIB_ISATTY)/g' \
@@ -3535,6 +3691,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
sed -e 's|@''REPLACE_ACCESS''@|$(REPLACE_ACCESS)|g' \
-e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
-e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
+ -e 's|@''REPLACE_COPY_FILE_RANGE''@|$(REPLACE_COPY_FILE_RANGE)|g' \
-e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
-e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
-e 's|@''REPLACE_EXECL''@|$(REPLACE_EXECL)|g' \
@@ -3554,6 +3711,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
-e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
-e 's|@''REPLACE_GETPASS''@|$(REPLACE_GETPASS)|g' \
+ -e 's|@''REPLACE_GETPASS_FOR_GETPASS_GNU''@|$(REPLACE_GETPASS_FOR_GETPASS_GNU)|g' \
-e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \
-e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
-e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
@@ -3579,9 +3737,9 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
- -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
- } > $@-t && \
- mv $@-t $@
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += unistd.h unistd.h-t
EXTRA_DIST += unistd.in.h
@@ -3591,12 +3749,11 @@ EXTRA_DIST += unistd.in.h
## begin gnulib module unsetenv
if gl_GNULIB_ENABLED_unsetenv
-
+if GL_COND_OBJ_UNSETENV
+libgnu_la_SOURCES += unsetenv.c
endif
-EXTRA_DIST += unsetenv.c
-
-EXTRA_libgnu_la_SOURCES += unsetenv.c
+endif
## end gnulib module unsetenv
## begin gnulib module useless-if-before-free
@@ -3647,9 +3804,8 @@ BUILT_SOURCES += wchar.h
# We need the following in order to create <wchar.h> when the system
# version does not work standalone.
wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -3700,6 +3856,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e 's/@''GNULIB_WCSWIDTH''@/$(GL_GNULIB_WCSWIDTH)/g' \
-e 's/@''GNULIB_WCSFTIME''@/$(GL_GNULIB_WCSFTIME)/g' \
-e 's/@''GNULIB_MDA_WCSDUP''@/$(GL_GNULIB_MDA_WCSDUP)/g' \
+ -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \
< $(srcdir)/wchar.in.h | \
sed -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \
-e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \
@@ -3748,6 +3905,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
sed -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \
-e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \
-e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \
+ -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
-e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \
-e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \
-e 's|@''REPLACE_MBRLEN''@|$(REPLACE_MBRLEN)|g' \
@@ -3762,9 +3920,9 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e 's|@''REPLACE_WCSTOK''@|$(REPLACE_WCSTOK)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
- -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
- } > $@-t && \
- mv $@-t $@
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += wchar.h wchar.h-t
EXTRA_DIST += wchar.in.h
@@ -3774,12 +3932,11 @@ EXTRA_DIST += wchar.in.h
## begin gnulib module wcrtomb
if gl_GNULIB_ENABLED_wcrtomb
-
+if GL_COND_OBJ_WCRTOMB
+libgnu_la_SOURCES += wcrtomb.c
endif
-EXTRA_DIST += wcrtomb.c
-
-EXTRA_libgnu_la_SOURCES += wcrtomb.c
+endif
## end gnulib module wcrtomb
## begin gnulib module wctype-h
@@ -3791,9 +3948,8 @@ libgnu_la_SOURCES += wctype-h.c
# We need the following in order to create <wctype.h> when the system
# doesn't have one that works with the given compiler.
wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -3820,9 +3976,8 @@ wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H
-e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/wctype.in.h; \
- } > $@-t && \
- mv $@-t $@
+ $(srcdir)/wctype.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += wctype.h wctype.h-t
endif
@@ -3830,12 +3985,23 @@ EXTRA_DIST += wctype.in.h
## end gnulib module wctype-h
-## begin gnulib module write
+## begin gnulib module windows-spawn
+if gl_GNULIB_ENABLED_fd43d02c899a251eacc999baf40b238e
+if GL_COND_OBJ_WINDOWS_SPAWN
+libgnu_la_SOURCES += windows-spawn.c
+endif
-EXTRA_DIST += write.c
+endif
+EXTRA_DIST += windows-spawn.h
-EXTRA_libgnu_la_SOURCES += write.c
+## end gnulib module windows-spawn
+
+## begin gnulib module write
+
+if GL_COND_OBJ_WRITE
+libgnu_la_SOURCES += write.c
+endif
## end gnulib module write
@@ -3862,3 +4028,7 @@ mostlyclean-local: mostlyclean-generic
fi; \
done; \
:
+distclean-local: distclean-gnulib-libobjs
+distclean-gnulib-libobjs:
+ -rm -f @gl_LIBOBJDEPS@
+maintainer-clean-local: distclean-gnulib-libobjs
diff --git a/lib/_Noreturn.h b/lib/_Noreturn.h
index 6fed3c797..e914627a8 100644
--- a/lib/_Noreturn.h
+++ b/lib/_Noreturn.h
@@ -1,5 +1,5 @@
/* A C macro for declaring that a function does not return.
- Copyright (C) 2011-2021 Free Software Foundation, Inc.
+ Copyright (C) 2011-2022 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
diff --git a/lib/accept.c b/lib/accept.c
index 71457dbf6..5c4d1f352 100644
--- a/lib/accept.c
+++ b/lib/accept.c
@@ -1,6 +1,6 @@
/* accept.c --- wrappers for Windows accept function
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/accept4.c b/lib/accept4.c
index 4c2b80e50..61ab6c77c 100644
--- a/lib/accept4.c
+++ b/lib/accept4.c
@@ -1,9 +1,9 @@
/* Accept a connection on a socket, with specific opening flags.
- Copyright (C) 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/access.c b/lib/access.c
new file mode 100644
index 000000000..e39c158ec
--- /dev/null
+++ b/lib/access.c
@@ -0,0 +1,31 @@
+/* Test the access rights of a file.
+ Copyright (C) 2019-2022 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <unistd.h>
+
+#include <fcntl.h>
+#include <io.h>
+
+int
+access (const char *file, int mode)
+{
+ if ((mode & X_OK) != 0)
+ mode = (mode & ~X_OK) | R_OK;
+ return _access (file, mode);
+}
diff --git a/lib/alignof.h b/lib/alignof.h
index e6e7a51b2..3f4a54257 100644
--- a/lib/alignof.h
+++ b/lib/alignof.h
@@ -1,5 +1,5 @@
/* Determine alignment of types.
- Copyright (C) 2003-2004, 2006, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2003-2004, 2006, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/alloca.c b/lib/alloca.c
index 48802832a..5eb16a9ff 100644
--- a/lib/alloca.c
+++ b/lib/alloca.c
@@ -30,17 +30,6 @@
#include <string.h>
#include <stdlib.h>
-#ifdef emacs
-# include "lisp.h"
-# include "blockinput.h"
-# ifdef EMACS_FREE
-# undef free
-# define free EMACS_FREE
-# endif
-#else
-# define memory_full() abort ()
-#endif
-
/* If compiling with GCC or clang, this file is not needed. */
#if !(defined __GNUC__ || defined __clang__)
@@ -48,22 +37,6 @@
there must be some other way alloca is supposed to work. */
# ifndef alloca
-# ifdef emacs
-# ifdef static
-/* actually, only want this if static is defined as ""
- -- this is for usg, in which emacs must undefine static
- in order to make unexec workable
- */
-# ifndef STACK_DIRECTION
-you
-lose
--- must know STACK_DIRECTION at compile-time
-/* Using #error here is not wise since this file should work for
- old and obscure compilers. */
-# endif /* STACK_DIRECTION undefined */
-# endif /* static */
-# endif /* emacs */
-
/* Define STACK_DIRECTION if you know the direction of stack
growth for your system; otherwise it will be automatically
deduced at run-time.
@@ -145,10 +118,6 @@ alloca (size_t size)
{
register header *hp; /* Traverses linked list. */
-# ifdef emacs
- BLOCK_INPUT;
-# endif
-
for (hp = last_alloca_header; hp != NULL;)
if ((STACK_DIR > 0 && hp->h.deep > depth)
|| (STACK_DIR < 0 && hp->h.deep < depth))
@@ -163,10 +132,6 @@ alloca (size_t size)
break; /* Rest are not deeper. */
last_alloca_header = hp; /* -> last valid storage. */
-
-# ifdef emacs
- UNBLOCK_INPUT;
-# endif
}
if (size == 0)
diff --git a/lib/alloca.in.h b/lib/alloca.in.h
index 65c2d4d93..e2b146138 100644
--- a/lib/alloca.in.h
+++ b/lib/alloca.in.h
@@ -1,6 +1,6 @@
/* Memory allocation on the stack.
- Copyright (C) 1995, 1999, 2001-2004, 2006-2021 Free Software Foundation,
+ Copyright (C) 1995, 1999, 2001-2004, 2006-2022 Free Software Foundation,
Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/arg-nonnull.h b/lib/arg-nonnull.h
index b4de241e9..e4513efe9 100644
--- a/lib/arg-nonnull.h
+++ b/lib/arg-nonnull.h
@@ -1,5 +1,5 @@
/* A C macro for declaring that specific arguments must not be NULL.
- Copyright (C) 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
diff --git a/lib/arpa_inet.in.h b/lib/arpa_inet.in.h
index 9968067aa..f5d7db2df 100644
--- a/lib/arpa_inet.in.h
+++ b/lib/arpa_inet.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <arpa/inet.h>.
- Copyright (C) 2005-2006, 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/asnprintf.c b/lib/asnprintf.c
index c5367b281..0c5c76ea5 100644
--- a/lib/asnprintf.c
+++ b/lib/asnprintf.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 1999, 2002, 2006, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/assure.h b/lib/assure.h
index 49aa82fec..20e806aa4 100644
--- a/lib/assure.h
+++ b/lib/assure.h
@@ -1,6 +1,6 @@
/* Run-time assert-like macros.
- Copyright (C) 2014-2021 Free Software Foundation, Inc.
+ Copyright (C) 2014-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/attribute.h b/lib/attribute.h
index 80a23f550..378d4f0a8 100644
--- a/lib/attribute.h
+++ b/lib/attribute.h
@@ -1,6 +1,6 @@
/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers
- Copyright 2020-2021 Free Software Foundation, Inc.
+ Copyright 2020-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -76,6 +76,14 @@
/* Applies to: function, pointer to function, function types. */
#define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args)
+/* ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
+ that can be freed by passing them as the Ith argument to the
+ function F.
+ ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
+ can be freed via 'free'; it can be used only after declaring 'free'. */
+/* Applies to: functions. Cannot be used on inline functions. */
+#define ATTRIBUTE_DEALLOC(f, i) _GL_ATTRIBUTE_DEALLOC(f, i)
+#define ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC_FREE
/* Attributes for variadic functions. */
diff --git a/lib/basename-lgpl.c b/lib/basename-lgpl.c
index 5dbd15708..eb07e2541 100644
--- a/lib/basename-lgpl.c
+++ b/lib/basename-lgpl.c
@@ -1,6 +1,6 @@
/* basename.c -- return the last element in a file name
- Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2021 Free Software
+ Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/basename-lgpl.h b/lib/basename-lgpl.h
index d520c0930..5569f2193 100644
--- a/lib/basename-lgpl.h
+++ b/lib/basename-lgpl.h
@@ -1,6 +1,6 @@
/* Extract the last component (base name) of a file name.
- Copyright (C) 1998, 2001, 2003-2006, 2009-2021 Free Software Foundation,
+ Copyright (C) 1998, 2001, 2003-2006, 2009-2022 Free Software Foundation,
Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/binary-io.c b/lib/binary-io.c
index adc0ae2b0..ea407fd74 100644
--- a/lib/binary-io.c
+++ b/lib/binary-io.c
@@ -1,5 +1,5 @@
/* Binary mode I/O.
- Copyright 2017-2021 Free Software Foundation, Inc.
+ Copyright 2017-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/binary-io.h b/lib/binary-io.h
index 0fa8d546f..5b7661e23 100644
--- a/lib/binary-io.h
+++ b/lib/binary-io.h
@@ -1,5 +1,5 @@
/* Binary mode I/O.
- Copyright (C) 2001, 2003, 2005, 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2005, 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -47,7 +47,7 @@ _GL_INLINE_HEADER_BEGIN
/* Use a function rather than a macro, to avoid gcc warnings
"warning: statement with no effect". */
BINARY_IO_INLINE int
-__gl_setmode (int fd _GL_UNUSED, int mode _GL_UNUSED)
+__gl_setmode (_GL_UNUSED int fd, _GL_UNUSED int mode)
{
return O_BINARY;
}
diff --git a/lib/bind.c b/lib/bind.c
index 0e4725446..199e0ba99 100644
--- a/lib/bind.c
+++ b/lib/bind.c
@@ -1,6 +1,6 @@
/* bind.c --- wrappers for Windows bind function
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/btowc.c b/lib/btowc.c
index b8239afae..4af58bb02 100644
--- a/lib/btowc.c
+++ b/lib/btowc.c
@@ -1,5 +1,5 @@
/* Convert unibyte character to wide character.
- Copyright (C) 2008, 2010-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2010-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/byteswap.in.h b/lib/byteswap.in.h
index 113f87802..f4746d399 100644
--- a/lib/byteswap.in.h
+++ b/lib/byteswap.in.h
@@ -1,5 +1,5 @@
/* byteswap.h - Byte swapping
- Copyright (C) 2005, 2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2007, 2009-2022 Free Software Foundation, Inc.
Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/c++defs.h b/lib/c++defs.h
index a47b61a00..ad181558f 100644
--- a/lib/c++defs.h
+++ b/lib/c++defs.h
@@ -1,5 +1,5 @@
/* C++ compatible function declaration macros.
- Copyright (C) 2010-2021 Free Software Foundation, Inc.
+ Copyright (C) 2010-2022 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
diff --git a/lib/c-ctype.c b/lib/c-ctype.c
index 300f97c29..a247514cd 100644
--- a/lib/c-ctype.c
+++ b/lib/c-ctype.c
@@ -1,6 +1,6 @@
/* Character handling in C locale.
- Copyright (C) 2003-2021 Free Software Foundation, Inc.
+ Copyright (C) 2003-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/c-ctype.h b/lib/c-ctype.h
index 3a652ac1f..1a4f60389 100644
--- a/lib/c-ctype.h
+++ b/lib/c-ctype.h
@@ -5,7 +5,7 @@
<ctype.h> functions' behaviour depends on the current locale set via
setlocale.
- Copyright (C) 2000-2003, 2006, 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2000-2003, 2006, 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/c-strcase.h b/lib/c-strcase.h
index 82f99bb06..3e874b5ea 100644
--- a/lib/c-strcase.h
+++ b/lib/c-strcase.h
@@ -1,5 +1,5 @@
/* Case-insensitive string comparison functions in C locale.
- Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2021 Free Software
+ Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/c-strcasecmp.c b/lib/c-strcasecmp.c
index 3c2245508..87b993cb2 100644
--- a/lib/c-strcasecmp.c
+++ b/lib/c-strcasecmp.c
@@ -1,5 +1,5 @@
/* c-strcasecmp.c -- case insensitive string comparator in C locale
- Copyright (C) 1998-1999, 2005-2006, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 1998-1999, 2005-2006, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/c-strcaseeq.h b/lib/c-strcaseeq.h
index 66b9cf3c1..1c4607cc9 100644
--- a/lib/c-strcaseeq.h
+++ b/lib/c-strcaseeq.h
@@ -1,5 +1,5 @@
/* Optimized case-insensitive string comparison in C locale.
- Copyright (C) 2001-2002, 2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2007, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/c-strncasecmp.c b/lib/c-strncasecmp.c
index f3ca786cb..5a5d30b6e 100644
--- a/lib/c-strncasecmp.c
+++ b/lib/c-strncasecmp.c
@@ -1,5 +1,5 @@
/* c-strncasecmp.c -- case insensitive string comparator in C locale
- Copyright (C) 1998-1999, 2005-2006, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 1998-1999, 2005-2006, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c
index 92e963972..a7fa7feb6 100644
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -1,5 +1,5 @@
/* Return the canonical absolute name of a given file.
- Copyright (C) 1996-2021 Free Software Foundation, Inc.
+ Copyright (C) 1996-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/cdefs.h b/lib/cdefs.h
index 4dac9d264..7b8ed5b34 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2022 Free Software Foundation, Inc.
+ Copyright The GNU Toolchain Authors.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -40,7 +41,9 @@
Similarly for __has_builtin, etc. */
#if (defined __has_attribute \
&& (!defined __clang_minor__ \
- || 3 < __clang_major__ + (5 <= __clang_minor__)))
+ || (defined __apple_build_version__ \
+ ? 6000000 <= __apple_build_version__ \
+ : 3 < __clang_major__ + (5 <= __clang_minor__))))
# define __glibc_has_attribute(attr) __has_attribute (attr)
#else
# define __glibc_has_attribute(attr) 0
@@ -142,7 +145,8 @@
#define __bos0(ptr) __builtin_object_size (ptr, 0)
/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
-#if __USE_FORTIFY_LEVEL == 3 && __glibc_clang_prereq (9, 0)
+#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \
+ || __GNUC_PREREQ (12, 0))
# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
#else
@@ -150,6 +154,53 @@
# define __glibc_objsize(__o) __bos (__o)
#endif
+/* Compile time conditions to choose between the regular, _chk and _chk_warn
+ variants. These conditions should get evaluated to constant and optimized
+ away. */
+
+#define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s))
+#define __glibc_unsigned_or_positive(__l) \
+ ((__typeof (__l)) 0 < (__typeof (__l)) -1 \
+ || (__builtin_constant_p (__l) && (__l) > 0))
+
+/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
+ condition can be folded to a constant and if it is true, or unknown (-1) */
+#define __glibc_safe_or_unknown_len(__l, __s, __osz) \
+ ((__osz) == (__SIZE_TYPE__) -1 \
+ || (__glibc_unsigned_or_positive (__l) \
+ && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
+ (__s), (__osz))) \
+ && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), (__s), (__osz))))
+
+/* Conversely, we know at compile time that the length is unsafe if the
+ __L * __S <= __OBJSZ condition can be folded to a constant and if it is
+ false. */
+#define __glibc_unsafe_len(__l, __s, __osz) \
+ (__glibc_unsigned_or_positive (__l) \
+ && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
+ __s, __osz)) \
+ && !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
+
+/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be
+ declared. */
+
+#define __glibc_fortify(f, __l, __s, __osz, ...) \
+ (__glibc_safe_or_unknown_len (__l, __s, __osz) \
+ ? __ ## f ## _alias (__VA_ARGS__) \
+ : (__glibc_unsafe_len (__l, __s, __osz) \
+ ? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \
+ : __ ## f ## _chk (__VA_ARGS__, __osz))) \
+
+/* Fortify function f, where object size argument passed to f is the number of
+ elements and not total size. */
+
+#define __glibc_fortify_n(f, __l, __s, __osz, ...) \
+ (__glibc_safe_or_unknown_len (__l, __s, __osz) \
+ ? __ ## f ## _alias (__VA_ARGS__) \
+ : (__glibc_unsafe_len (__l, __s, __osz) \
+ ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \
+ : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \
+
#if __GNUC_PREREQ (4,3)
# define __warnattr(msg) __attribute__((__warning__ (msg)))
# define __errordecl(name, msg) \
@@ -243,6 +294,15 @@
# define __attribute_alloc_size__(params) /* Ignore. */
#endif
+/* Tell the compiler which argument to an allocation function
+ indicates the alignment of the allocation. */
+#if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__alloc_align__)
+# define __attribute_alloc_align__(param) \
+ __attribute__ ((__alloc_align__ param))
+#else
+# define __attribute_alloc_align__(param) /* Ignore. */
+#endif
+
/* At some point during the gcc 2.96 development the `pure' attribute
for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings. */
@@ -605,12 +665,22 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
size-index is not provided:
access (access-mode, <ref-index> [, <size-index>]) */
# define __attr_access(x) __attribute__ ((__access__ x))
+/* For _FORTIFY_SOURCE == 3 we use __builtin_dynamic_object_size, which may
+ use the access attribute to get object sizes from function definition
+ arguments, so we can't use them on functions we fortify. Drop the object
+ size hints for such functions. */
+# if __USE_FORTIFY_LEVEL == 3
+# define __fortified_attr_access(a, o, s) __attribute__ ((__access__ (a, o)))
+# else
+# define __fortified_attr_access(a, o, s) __attr_access ((a, o, s))
+# endif
# if __GNUC_PREREQ (11, 0)
# define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno)))
# else
# define __attr_access_none(argno)
# endif
#else
+# define __fortified_attr_access(a, o, s)
# define __attr_access(x)
# define __attr_access_none(argno)
#endif
diff --git a/lib/ceil.c b/lib/ceil.c
index fce05d986..4ab192a54 100644
--- a/lib/ceil.c
+++ b/lib/ceil.c
@@ -1,9 +1,9 @@
/* Round towards positive infinity.
- Copyright (C) 2007, 2010-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2010-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/cloexec.c b/lib/cloexec.c
index 7defa9344..812be01a0 100644
--- a/lib/cloexec.c
+++ b/lib/cloexec.c
@@ -1,6 +1,6 @@
/* cloexec.c - set or clear the close-on-exec descriptor flag
- Copyright (C) 1991, 2004-2006, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 1991, 2004-2006, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/cloexec.h b/lib/cloexec.h
index 97a3659ef..7a22d7753 100644
--- a/lib/cloexec.h
+++ b/lib/cloexec.h
@@ -1,6 +1,6 @@
/* cloexec.c - set or clear the close-on-exec descriptor flag
- Copyright (C) 2004, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/close.c b/lib/close.c
index 5b9ab6c9f..44990ba71 100644
--- a/lib/close.c
+++ b/lib/close.c
@@ -1,5 +1,5 @@
/* close replacement.
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/concat-filename.c b/lib/concat-filename.c
new file mode 100644
index 000000000..f05484904
--- /dev/null
+++ b/lib/concat-filename.c
@@ -0,0 +1,73 @@
+/* Construct a full filename from a directory and a relative filename.
+ Copyright (C) 2001-2004, 2006-2022 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <haible@clisp.cons.org>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "concat-filename.h"
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "filename.h"
+
+/* Concatenate a directory filename, a relative filename and an optional
+ suffix. The directory may end with the directory separator. The second
+ argument may not start with the directory separator (it is relative).
+ Return a freshly allocated filename. Return NULL and set errno
+ upon memory allocation failure. */
+char *
+concatenated_filename (const char *directory, const char *filename,
+ const char *suffix)
+{
+ char *result;
+ char *p;
+
+ if (strcmp (directory, ".") == 0)
+ {
+ /* No need to prepend the directory. */
+ result = (char *) malloc (strlen (filename)
+ + (suffix != NULL ? strlen (suffix) : 0)
+ + 1);
+ if (result == NULL)
+ return NULL; /* errno is set here */
+ p = result;
+ }
+ else
+ {
+ size_t directory_len = strlen (directory);
+ int need_slash =
+ (directory_len > FILE_SYSTEM_PREFIX_LEN (directory)
+ && !ISSLASH (directory[directory_len - 1]));
+ result = (char *) malloc (directory_len + need_slash
+ + strlen (filename)
+ + (suffix != NULL ? strlen (suffix) : 0)
+ + 1);
+ if (result == NULL)
+ return NULL; /* errno is set here */
+ memcpy (result, directory, directory_len);
+ p = result + directory_len;
+ if (need_slash)
+ *p++ = '/';
+ }
+ p = stpcpy (p, filename);
+ if (suffix != NULL)
+ stpcpy (p, suffix);
+ return result;
+}
diff --git a/lib/concat-filename.h b/lib/concat-filename.h
new file mode 100644
index 000000000..0348b0d93
--- /dev/null
+++ b/lib/concat-filename.h
@@ -0,0 +1,46 @@
+/* Construct a full filename from a directory and a relative filename.
+ Copyright (C) 2001-2004, 2007-2022 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _CONCAT_FILENAME_H
+#define _CONCAT_FILENAME_H
+
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Concatenate a directory filename, a relative filename and an optional
+ suffix. Return a freshly allocated filename. Return NULL and set errno
+ upon memory allocation failure. */
+extern char *concatenated_filename (const char *directory,
+ const char *filename, const char *suffix)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
+
+/* Concatenate a directory filename, a relative filename and an optional
+ suffix. Return a freshly allocated filename. */
+extern char *xconcatenated_filename (const char *directory,
+ const char *filename, const char *suffix)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CONCAT_FILENAME_H */
diff --git a/lib/connect.c b/lib/connect.c
index b2b2e9334..d1600634e 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -1,6 +1,6 @@
/* connect.c --- wrappers for Windows connect function
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/copysign.c b/lib/copysign.c
index fee131be1..613346574 100644
--- a/lib/copysign.c
+++ b/lib/copysign.c
@@ -1,9 +1,9 @@
/* Copy sign into another 'double' number.
- Copyright (C) 2011-2021 Free Software Foundation, Inc.
+ Copyright (C) 2011-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/dirent.in.h b/lib/dirent.in.h
index 5775edf09..f28288d1a 100644
--- a/lib/dirent.in.h
+++ b/lib/dirent.in.h
@@ -1,5 +1,5 @@
/* A GNU-like <dirent.h>.
- Copyright (C) 2006-2021 Free Software Foundation, Inc.
+ Copyright (C) 2006-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -55,6 +55,28 @@ typedef struct gl_directory DIR;
# endif
#endif
+/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
+ that can be freed by passing them as the Ith argument to the
+ function F. */
+#ifndef _GL_ATTRIBUTE_DEALLOC
+# if __GNUC__ >= 11
+# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
+# else
+# define _GL_ATTRIBUTE_DEALLOC(f, i)
+# endif
+#endif
+
+/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
+ allocated memory. */
+/* Applies to: functions. */
+#ifndef _GL_ATTRIBUTE_MALLOC
+# if __GNUC__ >= 3 || defined __clang__
+# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+# define _GL_ATTRIBUTE_MALLOC
+# endif
+#endif
+
/* The __attribute__ feature is available in gcc versions 2.5 and later.
The attribute __pure__ was added in gcc 2.96. */
#ifndef _GL_ATTRIBUTE_PURE
diff --git a/lib/dirfd.c b/lib/dirfd.c
index 640cb4ff1..4104683fb 100644
--- a/lib/dirfd.c
+++ b/lib/dirfd.c
@@ -1,6 +1,6 @@
/* dirfd.c -- return the file descriptor associated with an open DIR*
- Copyright (C) 2001, 2006, 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2006, 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/dirname-lgpl.c b/lib/dirname-lgpl.c
index 95f9c9919..d54f6a910 100644
--- a/lib/dirname-lgpl.c
+++ b/lib/dirname-lgpl.c
@@ -1,6 +1,6 @@
/* dirname.c -- return all but the last element in a file name
- Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2021 Free Software
+ Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/dirname.h b/lib/dirname.h
index 25abc7b7e..e18a97ea1 100644
--- a/lib/dirname.h
+++ b/lib/dirname.h
@@ -1,6 +1,6 @@
/* Take file names apart into directory and base names.
- Copyright (C) 1998, 2001, 2003-2006, 2009-2021 Free Software Foundation,
+ Copyright (C) 1998, 2001, 2003-2006, 2009-2022 Free Software Foundation,
Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/dup2.c b/lib/dup2.c
index 53e555213..1c766ab38 100644
--- a/lib/dup2.c
+++ b/lib/dup2.c
@@ -1,6 +1,6 @@
/* Duplicate an open file descriptor to a specified file descriptor.
- Copyright (C) 1999, 2004-2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2004-2007, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/duplocale.c b/lib/duplocale.c
index bc8740d4f..0ecd989cd 100644
--- a/lib/duplocale.c
+++ b/lib/duplocale.c
@@ -1,9 +1,9 @@
/* Duplicate a locale object.
- Copyright (C) 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/dynarray.h b/lib/dynarray.h
index ec64273b3..ca6439d3a 100644
--- a/lib/dynarray.h
+++ b/lib/dynarray.h
@@ -1,5 +1,5 @@
/* Type-safe arrays which grow dynamically.
- Copyright 2021 Free Software Foundation, Inc.
+ Copyright 2021-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/eloop-threshold.h b/lib/eloop-threshold.h
index fcd30ab1e..8b3145711 100644
--- a/lib/eloop-threshold.h
+++ b/lib/eloop-threshold.h
@@ -1,5 +1,5 @@
/* Threshold at which to diagnose ELOOP. Generic version.
- Copyright (C) 2012-2021 Free Software Foundation, Inc.
+ Copyright (C) 2012-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/errno.in.h b/lib/errno.in.h
index 3cad9e2d6..3ec184569 100644
--- a/lib/errno.in.h
+++ b/lib/errno.in.h
@@ -1,6 +1,6 @@
/* A POSIX-like <errno.h>.
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/fcntl.c b/lib/fcntl.c
index c744eb91e..f9753c403 100644
--- a/lib/fcntl.c
+++ b/lib/fcntl.c
@@ -1,6 +1,6 @@
/* Provide file descriptor control.
- Copyright (C) 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index 26dedc304..9270ced89 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -1,6 +1,6 @@
/* Like <fcntl.h>, but with non-working flags defined to 0.
- Copyright (C) 2006-2021 Free Software Foundation, Inc.
+ Copyright (C) 2006-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -435,6 +435,10 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
# define AT_EACCESS 4
#endif
+/* Ignore this flag if not supported. */
+#ifndef AT_NO_AUTOMOUNT
+# define AT_NO_AUTOMOUNT 0
+#endif
#endif /* _@GUARD_PREFIX@_FCNTL_H */
#endif /* _@GUARD_PREFIX@_FCNTL_H */
diff --git a/lib/fd-hook.c b/lib/fd-hook.c
index 75b1626de..64a7a80c0 100644
--- a/lib/fd-hook.c
+++ b/lib/fd-hook.c
@@ -1,5 +1,5 @@
/* Hook for making file descriptor functions close(), ioctl() extensible.
- Copyright (C) 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/fd-hook.h b/lib/fd-hook.h
index 98e2a5263..d6c4964d1 100644
--- a/lib/fd-hook.h
+++ b/lib/fd-hook.h
@@ -1,5 +1,5 @@
/* Hook for making file descriptor functions close(), ioctl() extensible.
- Copyright (C) 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/filename.h b/lib/filename.h
index dafe3dfdd..ab77ca2df 100644
--- a/lib/filename.h
+++ b/lib/filename.h
@@ -1,5 +1,5 @@
/* Basic filename support macros.
- Copyright (C) 2001-2004, 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2001-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/findprog-in.c b/lib/findprog-in.c
new file mode 100644
index 000000000..72a05dbf5
--- /dev/null
+++ b/lib/findprog-in.c
@@ -0,0 +1,399 @@
+/* Locating a program in a given path.
+ Copyright (C) 2001-2004, 2006-2022 Free Software Foundation, Inc.
+ Written by Bruno Haible <haible@clisp.cons.org>, 2001, 2019.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+
+#include <config.h>
+
+/* Specification. */
+#include "findprog.h"
+
+#include <errno.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include "filename.h"
+#include "concat-filename.h"
+
+#if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
+ /* Native Windows, OS/2, DOS */
+# define NATIVE_SLASH '\\'
+#else
+ /* Unix */
+# define NATIVE_SLASH '/'
+#endif
+
+/* Separator in PATH like lists of pathnames. */
+#if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
+ /* Native Windows, OS/2, DOS */
+# define PATH_SEPARATOR ';'
+#else
+ /* Unix */
+# define PATH_SEPARATOR ':'
+#endif
+
+/* The list of suffixes that the execlp/execvp function tries when searching
+ for the program. */
+static const char * const suffixes[] =
+ {
+ #if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
+ "", ".com", ".exe", ".bat", ".cmd"
+ /* Note: Files without any suffix are not considered executable. */
+ /* Note: The cmd.exe program does a different lookup: It searches according
+ to the PATHEXT environment variable.
+ See <https://stackoverflow.com/questions/7839150/>.
+ Also, it executes files ending in .bat and .cmd directly without letting
+ the kernel interpret the program file. */
+ #elif defined __CYGWIN__
+ "", ".exe", ".com"
+ #elif defined __EMX__
+ "", ".exe"
+ #elif defined __DJGPP__
+ "", ".com", ".exe", ".bat"
+ #else /* Unix */
+ ""
+ #endif
+ };
+
+const char *
+find_in_given_path (const char *progname, const char *path,
+ const char *directory, bool optimize_for_exec)
+{
+ {
+ bool has_slash = false;
+ {
+ const char *p;
+
+ for (p = progname; *p != '\0'; p++)
+ if (ISSLASH (*p))
+ {
+ has_slash = true;
+ break;
+ }
+ }
+ if (has_slash)
+ {
+ /* If progname contains a slash, it is either absolute or relative to
+ the current directory. PATH is not used. */
+ if (optimize_for_exec)
+ /* The execl/execv/execlp/execvp functions will try the various
+ suffixes anyway and fail if no executable is found. */
+ return progname;
+ else
+ {
+ /* Try the various suffixes and see whether one of the files
+ with such a suffix is actually executable. */
+ int failure_errno;
+ size_t i;
+
+ const char *directory_as_prefix =
+ (directory != NULL && IS_RELATIVE_FILE_NAME (progname)
+ ? directory
+ : "");
+
+ #if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
+ const char *progbasename;
+
+ {
+ const char *p;
+
+ progbasename = progname;
+ for (p = progname; *p != '\0'; p++)
+ if (ISSLASH (*p))
+ progbasename = p + 1;
+ }
+
+ bool progbasename_has_dot = (strchr (progbasename, '.') != NULL);
+ #endif
+
+ /* Try all platform-dependent suffixes. */
+ failure_errno = ENOENT;
+ for (i = 0; i < sizeof (suffixes) / sizeof (suffixes[0]); i++)
+ {
+ const char *suffix = suffixes[i];
+
+ #if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
+ /* File names without a '.' are not considered executable, and
+ for file names with a '.' no additional suffix is tried. */
+ if ((*suffix != '\0') != progbasename_has_dot)
+ #endif
+ {
+ /* Concatenate directory_as_prefix, progname, suffix. */
+ char *progpathname =
+ concatenated_filename (directory_as_prefix, progname,
+ suffix);
+
+ if (progpathname == NULL)
+ return NULL; /* errno is set here */
+
+ /* On systems which have the eaccess() system call, let's
+ use it. On other systems, let's hope that this program
+ is not installed setuid or setgid, so that it is ok to
+ call access() despite its design flaw. */
+ if (eaccess (progpathname, X_OK) == 0)
+ {
+ /* Check that the progpathname does not point to a
+ directory. */
+ struct stat statbuf;
+
+ if (stat (progpathname, &statbuf) >= 0)
+ {
+ if (! S_ISDIR (statbuf.st_mode))
+ {
+ /* Found! */
+ if (strcmp (progpathname, progname) == 0)
+ {
+ free (progpathname);
+ return progname;
+ }
+ else
+ return progpathname;
+ }
+
+ errno = EACCES;
+ }
+ }
+
+ if (errno != ENOENT)
+ failure_errno = errno;
+
+ free (progpathname);
+ }
+ }
+ #if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
+ if (failure_errno == ENOENT && !progbasename_has_dot)
+ {
+ /* In the loop above, we skipped suffix = "". Do this loop
+ round now, merely to provide a better errno than ENOENT. */
+
+ char *progpathname =
+ concatenated_filename (directory_as_prefix, progname, "");
+
+ if (progpathname == NULL)
+ return NULL; /* errno is set here */
+
+ if (eaccess (progpathname, X_OK) == 0)
+ {
+ struct stat statbuf;
+
+ if (stat (progpathname, &statbuf) >= 0)
+ {
+ if (! S_ISDIR (statbuf.st_mode))
+ errno = ENOEXEC;
+ else
+ errno = EACCES;
+ }
+ }
+
+ failure_errno = errno;
+
+ free (progpathname);
+ }
+ #endif
+
+ errno = failure_errno;
+ return NULL;
+ }
+ }
+ }
+
+ if (path == NULL)
+ /* If PATH is not set, the default search path is implementation dependent.
+ In practice, it is treated like an empty PATH. */
+ path = "";
+
+ {
+ /* Make a copy, to prepare for destructive modifications. */
+ char *path_copy = strdup (path);
+ if (path_copy == NULL)
+ return NULL; /* errno is set here */
+
+ int failure_errno;
+ char *path_rest;
+ char *cp;
+
+ #if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
+ bool progname_has_dot = (strchr (progname, '.') != NULL);
+ #endif
+
+ failure_errno = ENOENT;
+ for (path_rest = path_copy; ; path_rest = cp + 1)
+ {
+ const char *dir;
+ bool last;
+ char *dir_as_prefix_to_free;
+ const char *dir_as_prefix;
+ size_t i;
+
+ /* Extract next directory in PATH. */
+ dir = path_rest;
+ for (cp = path_rest; *cp != '\0' && *cp != PATH_SEPARATOR; cp++)
+ ;
+ last = (*cp == '\0');
+ *cp = '\0';
+
+ /* Empty PATH components designate the current directory. */
+ if (dir == cp)
+ dir = ".";
+
+ /* Concatenate directory and dir. */
+ if (directory != NULL && IS_RELATIVE_FILE_NAME (dir))
+ {
+ dir_as_prefix_to_free =
+ concatenated_filename (directory, dir, NULL);
+ if (dir_as_prefix_to_free == NULL)
+ {
+ /* errno is set here. */
+ failure_errno = errno;
+ goto failed;
+ }
+ dir_as_prefix = dir_as_prefix_to_free;
+ }
+ else
+ {
+ dir_as_prefix_to_free = NULL;
+ dir_as_prefix = dir;
+ }
+
+ /* Try all platform-dependent suffixes. */
+ for (i = 0; i < sizeof (suffixes) / sizeof (suffixes[0]); i++)
+ {
+ const char *suffix = suffixes[i];
+
+ #if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
+ /* File names without a '.' are not considered executable, and
+ for file names with a '.' no additional suffix is tried. */
+ if ((*suffix != '\0') != progname_has_dot)
+ #endif
+ {
+ /* Concatenate dir_as_prefix, progname, and suffix. */
+ char *progpathname =
+ concatenated_filename (dir_as_prefix, progname, suffix);
+
+ if (progpathname == NULL)
+ {
+ /* errno is set here. */
+ failure_errno = errno;
+ free (dir_as_prefix_to_free);
+ goto failed;
+ }
+
+ /* On systems which have the eaccess() system call, let's
+ use it. On other systems, let's hope that this program
+ is not installed setuid or setgid, so that it is ok to
+ call access() despite its design flaw. */
+ if (eaccess (progpathname, X_OK) == 0)
+ {
+ /* Check that the progpathname does not point to a
+ directory. */
+ struct stat statbuf;
+
+ if (stat (progpathname, &statbuf) >= 0)
+ {
+ if (! S_ISDIR (statbuf.st_mode))
+ {
+ /* Found! */
+ if (strcmp (progpathname, progname) == 0)
+ {
+ free (progpathname);
+
+ /* Add the "./" prefix for real, that
+ concatenated_filename() optimized away.
+ This avoids a second PATH search when the
+ caller uses execl/execv/execlp/execvp. */
+ progpathname =
+ (char *) malloc (2 + strlen (progname) + 1);
+ if (progpathname == NULL)
+ {
+ /* errno is set here. */
+ failure_errno = errno;
+ free (dir_as_prefix_to_free);
+ goto failed;
+ }
+ progpathname[0] = '.';
+ progpathname[1] = NATIVE_SLASH;
+ memcpy (progpathname + 2, progname,
+ strlen (progname) + 1);
+ }
+
+ free (dir_as_prefix_to_free);
+ free (path_copy);
+ return progpathname;
+ }
+
+ errno = EACCES;
+ }
+ }
+
+ if (errno != ENOENT)
+ failure_errno = errno;
+
+ free (progpathname);
+ }
+ }
+ #if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
+ if (failure_errno == ENOENT && !progname_has_dot)
+ {
+ /* In the loop above, we skipped suffix = "". Do this loop
+ round now, merely to provide a better errno than ENOENT. */
+
+ char *progpathname =
+ concatenated_filename (dir_as_prefix, progname, "");
+
+ if (progpathname == NULL)
+ {
+ /* errno is set here. */
+ failure_errno = errno;
+ free (dir_as_prefix_to_free);
+ goto failed;
+ }
+
+ if (eaccess (progpathname, X_OK) == 0)
+ {
+ struct stat statbuf;
+
+ if (stat (progpathname, &statbuf) >= 0)
+ {
+ if (! S_ISDIR (statbuf.st_mode))
+ errno = ENOEXEC;
+ else
+ errno = EACCES;
+ }
+ }
+
+ failure_errno = errno;
+
+ free (progpathname);
+ }
+ #endif
+
+ free (dir_as_prefix_to_free);
+
+ if (last)
+ break;
+ }
+
+ failed:
+ /* Not found in PATH. */
+ free (path_copy);
+
+ errno = failure_errno;
+ return NULL;
+ }
+}
diff --git a/lib/findprog.h b/lib/findprog.h
new file mode 100644
index 000000000..e47acc5e4
--- /dev/null
+++ b/lib/findprog.h
@@ -0,0 +1,77 @@
+/* Locating a program in PATH.
+ Copyright (C) 2001-2003, 2009-2022 Free Software Foundation, Inc.
+ Written by Bruno Haible <haible@clisp.cons.org>, 2001.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _FINDPROG_H
+#define _FINDPROG_H
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Looks up a program in the PATH.
+ Attempts to determine the pathname that would be called by execlp/execvp
+ of PROGNAME. If successful, it returns a pathname containing a slash
+ (either absolute or relative to the current directory). Otherwise, it
+ returns PROGNAME unmodified.
+ Because of the latter case, callers should use execlp/execvp, not
+ execl/execv on the returned pathname.
+ The returned string is freshly malloc()ed if it is != PROGNAME. */
+extern const char *find_in_path (const char *progname);
+
+/* Looks up a program in the given PATH-like string.
+
+ The PATH argument consists of a list of directories, separated by ':' or
+ (on native Windows) by ';'. An empty PATH element designates the current
+ directory. A null PATH is equivalent to an empty PATH, that is, to the
+ singleton list that contains only the current directory.
+
+ If DIRECTORY is not NULL, all relative filenames (i.e. PROGNAME when it
+ contains a slash, and the PATH elements) are considered relative to
+ DIRECTORY instead of relative to the current directory of this process.
+
+ Determines the pathname that would be called by execlp/execvp of PROGNAME.
+ - If successful, it returns a pathname containing a slash (either absolute
+ or relative to the current directory). The returned string can be used
+ with either execl/execv or execlp/execvp. It is freshly malloc()ed if it
+ is != PROGNAME.
+ - Otherwise, it sets errno and returns NULL.
+ Specific errno values include:
+ - ENOENT: means that the program's file was not found.
+ - EACCES: means that the program's file cannot be accessed (due to some
+ issue with one of the ancestor directories) or lacks the execute
+ permissions.
+ - ENOMEM: means out of memory.
+ If OPTIMIZE_FOR_EXEC is true, the function saves some work, under the
+ assumption that the resulting pathname will not be accessed directly,
+ only through execl/execv or execlp/execvp.
+
+ Here, a "slash" means:
+ - On POSIX systems excluding Cygwin: a '/',
+ - On Windows, OS/2, DOS platforms: a '/' or '\'. */
+extern const char *find_in_given_path (const char *progname, const char *path,
+ const char *directory,
+ bool optimize_for_exec);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _FINDPROG_H */
diff --git a/lib/flexmember.h b/lib/flexmember.h
index 1b19a2bfd..1545639f7 100644
--- a/lib/flexmember.h
+++ b/lib/flexmember.h
@@ -1,6 +1,6 @@
/* Sizes of structs with flexible array members.
- Copyright 2016-2021 Free Software Foundation, Inc.
+ Copyright 2016-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
diff --git a/lib/float+.h b/lib/float+.h
index ad891f65d..9ab45208d 100644
--- a/lib/float+.h
+++ b/lib/float+.h
@@ -1,5 +1,5 @@
/* Supplemental information about the floating-point formats.
- Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2007.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/float.c b/lib/float.c
index dd1e84ad1..de8506450 100644
--- a/lib/float.c
+++ b/lib/float.c
@@ -1,5 +1,5 @@
/* Auxiliary definitions for <float.h>.
- Copyright (C) 2011-2021 Free Software Foundation, Inc.
+ Copyright (C) 2011-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/float.in.h b/lib/float.in.h
index f52aba36e..a4183765d 100644
--- a/lib/float.in.h
+++ b/lib/float.in.h
@@ -1,6 +1,6 @@
/* A correct <float.h>.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/flock.c b/lib/flock.c
index 95c354eb0..28773d5c3 100644
--- a/lib/flock.c
+++ b/lib/flock.c
@@ -6,7 +6,7 @@
Written by Richard W.M. Jones <rjones.at.redhat.com>
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
diff --git a/lib/floor.c b/lib/floor.c
index 15303004f..3e4f8d058 100644
--- a/lib/floor.c
+++ b/lib/floor.c
@@ -1,9 +1,9 @@
/* Round towards negative infinity.
- Copyright (C) 2007, 2010-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2010-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/free.c b/lib/free.c
index 780f03dd1..86ebe6c63 100644
--- a/lib/free.c
+++ b/lib/free.c
@@ -1,6 +1,6 @@
/* Make free() preserve errno.
- Copyright (C) 2003, 2006, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2006, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/frexp.c b/lib/frexp.c
index ab5f34315..2c15733e2 100644
--- a/lib/frexp.c
+++ b/lib/frexp.c
@@ -1,5 +1,5 @@
/* Split a double into fraction and mantissa.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/fstat.c b/lib/fstat.c
index 512c688c4..3928c8602 100644
--- a/lib/fstat.c
+++ b/lib/fstat.c
@@ -1,5 +1,5 @@
/* fstat() replacement.
- Copyright (C) 2011-2021 Free Software Foundation, Inc.
+ Copyright (C) 2011-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/fsync.c b/lib/fsync.c
index 99a932d77..9b561ab96 100644
--- a/lib/fsync.c
+++ b/lib/fsync.c
@@ -7,7 +7,7 @@
Written by Richard W.M. Jones <rjones.at.redhat.com>
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/full-read.c b/lib/full-read.c
index 53be6596a..7b5308771 100644
--- a/lib/full-read.c
+++ b/lib/full-read.c
@@ -1,5 +1,5 @@
/* An interface to read that retries after partial reads and interrupts.
- Copyright (C) 2002-2003, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/full-read.h b/lib/full-read.h
index b36f2e169..b30c68ad5 100644
--- a/lib/full-read.h
+++ b/lib/full-read.h
@@ -1,6 +1,6 @@
/* An interface to read() that reads all it is asked to read.
- Copyright (C) 2002, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/full-write.c b/lib/full-write.c
index 614ca0b4f..2d593727c 100644
--- a/lib/full-write.c
+++ b/lib/full-write.c
@@ -1,6 +1,6 @@
/* An interface to read and write that retries (if necessary) until complete.
- Copyright (C) 1993-1994, 1997-2006, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 1993-1994, 1997-2006, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/full-write.h b/lib/full-write.h
index c316224b4..7e006d1f4 100644
--- a/lib/full-write.h
+++ b/lib/full-write.h
@@ -1,6 +1,6 @@
/* An interface to write() that writes all it is asked to write.
- Copyright (C) 2002-2003, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/gai_strerror.c b/lib/gai_strerror.c
index 4874ef5e3..c7eedb2f3 100644
--- a/lib/gai_strerror.c
+++ b/lib/gai_strerror.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2021 Free Software
+/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2022 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c
index 0c42d1b7b..392289858 100644
--- a/lib/getaddrinfo.c
+++ b/lib/getaddrinfo.c
@@ -1,5 +1,5 @@
/* Get address information (partial implementation).
- Copyright (C) 1997, 2001-2002, 2004-2021 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2001-2002, 2004-2022 Free Software Foundation, Inc.
Contributed by Simon Josefsson <simon@josefsson.org>.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c
index 5006c2d5c..793e0f889 100644
--- a/lib/getdtablesize.c
+++ b/lib/getdtablesize.c
@@ -1,5 +1,5 @@
/* getdtablesize() function: Return maximum possible file descriptor value + 1.
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/getlogin.c b/lib/getlogin.c
index 7b78c67ce..97b6ed659 100644
--- a/lib/getlogin.c
+++ b/lib/getlogin.c
@@ -1,6 +1,6 @@
/* Provide a working getlogin for systems which lack it.
- Copyright (C) 2010-2021 Free Software Foundation, Inc.
+ Copyright (C) 2010-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/getpeername.c b/lib/getpeername.c
index 468bb3d7c..ac4926f38 100644
--- a/lib/getpeername.c
+++ b/lib/getpeername.c
@@ -1,6 +1,6 @@
/* getpeername.c --- wrappers for Windows getpeername function
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/getrandom.c b/lib/getrandom.c
index a186c4d3b..e14687309 100644
--- a/lib/getrandom.c
+++ b/lib/getrandom.c
@@ -1,6 +1,6 @@
/* Obtain a series of random bytes.
- Copyright 2020-2021 Free Software Foundation, Inc.
+ Copyright 2020-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/getsockname.c b/lib/getsockname.c
index d1f17b3ed..3ab3a7545 100644
--- a/lib/getsockname.c
+++ b/lib/getsockname.c
@@ -1,6 +1,6 @@
/* getsockname.c --- wrappers for Windows getsockname function
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/getsockopt.c b/lib/getsockopt.c
index b92d034bb..9c87afadb 100644
--- a/lib/getsockopt.c
+++ b/lib/getsockopt.c
@@ -1,6 +1,6 @@
/* getsockopt.c --- wrappers for Windows getsockopt function
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/gettext.h b/lib/gettext.h
index f1c7a2407..b3577a043 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -1,5 +1,5 @@
/* Convenience header for conditional use of GNU <libintl.h>.
- Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2021 Free Software
+ Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
@@ -138,7 +138,7 @@
#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
-#ifdef __GNUC__
+#if defined __GNUC__ || defined __clang__
__inline
#else
#ifdef __cplusplus
@@ -157,7 +157,7 @@ pgettext_aux (const char *domain,
return translation;
}
-#ifdef __GNUC__
+#if defined __GNUC__ || defined __clang__
__inline
#else
#ifdef __cplusplus
@@ -191,9 +191,8 @@ npgettext_aux (const char *domain,
or may have security implications due to non-deterministic stack usage. */
#if (!defined GNULIB_NO_VLA \
- && (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
- /* || (__STDC_VERSION__ == 199901L && !defined __HP_cc)
- || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ ))
+ && defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \
+ && !defined __STDC_NO_VLA__)
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
#else
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
@@ -208,7 +207,7 @@ npgettext_aux (const char *domain,
#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
-#ifdef __GNUC__
+#if defined __GNUC__ || defined __clang__
__inline
#else
#ifdef __cplusplus
@@ -255,7 +254,7 @@ dcpgettext_expr (const char *domain,
#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
-#ifdef __GNUC__
+#if defined __GNUC__ || defined __clang__
__inline
#else
#ifdef __cplusplus
diff --git a/lib/hard-locale.c b/lib/hard-locale.c
index 8b6802d10..f7fbc470b 100644
--- a/lib/hard-locale.c
+++ b/lib/hard-locale.c
@@ -1,6 +1,6 @@
/* hard-locale.c -- Determine whether a locale is hard.
- Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2021 Free Software
+ Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/hard-locale.h b/lib/hard-locale.h
index eba66018c..6066f4ed4 100644
--- a/lib/hard-locale.h
+++ b/lib/hard-locale.h
@@ -1,6 +1,6 @@
/* Determine whether a locale is hard.
- Copyright (C) 1999, 2003-2004, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2003-2004, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/iconv.c b/lib/iconv.c
index bf5149349..efab53d88 100644
--- a/lib/iconv.c
+++ b/lib/iconv.c
@@ -1,5 +1,5 @@
/* Character set conversion.
- Copyright (C) 1999-2001, 2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 1999-2001, 2007, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/iconv.in.h b/lib/iconv.in.h
index 3a2f94e75..4c5a31c3b 100644
--- a/lib/iconv.in.h
+++ b/lib/iconv.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <iconv.h>.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/iconv_close.c b/lib/iconv_close.c
index 7429b925b..2d7fb17ef 100644
--- a/lib/iconv_close.c
+++ b/lib/iconv_close.c
@@ -1,5 +1,5 @@
/* Character set conversion.
- Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/iconv_open-aix.gperf b/lib/iconv_open-aix.gperf
index d07375914..024da2158 100644
--- a/lib/iconv_open-aix.gperf
+++ b/lib/iconv_open-aix.gperf
@@ -1,5 +1,5 @@
/* Character set conversion.
- Copyright (C) 2007, 2020-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2020-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/iconv_open-hpux.gperf b/lib/iconv_open-hpux.gperf
index f4664d615..12057505d 100644
--- a/lib/iconv_open-hpux.gperf
+++ b/lib/iconv_open-hpux.gperf
@@ -1,5 +1,5 @@
/* Character set conversion.
- Copyright (C) 2007, 2020-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2020-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/iconv_open-irix.gperf b/lib/iconv_open-irix.gperf
index 9885d9278..92a2689df 100644
--- a/lib/iconv_open-irix.gperf
+++ b/lib/iconv_open-irix.gperf
@@ -1,5 +1,5 @@
/* Character set conversion.
- Copyright (C) 2007, 2020-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2020-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/iconv_open-osf.gperf b/lib/iconv_open-osf.gperf
index d818d79dc..746f56302 100644
--- a/lib/iconv_open-osf.gperf
+++ b/lib/iconv_open-osf.gperf
@@ -1,5 +1,5 @@
/* Character set conversion.
- Copyright (C) 2007, 2020-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2020-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/iconv_open-solaris.gperf b/lib/iconv_open-solaris.gperf
index 648dd3afb..fbd6f9d74 100644
--- a/lib/iconv_open-solaris.gperf
+++ b/lib/iconv_open-solaris.gperf
@@ -1,5 +1,5 @@
/* Character set conversion.
- Copyright (C) 2007, 2009, 2020-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009, 2020-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/iconv_open-zos.gperf b/lib/iconv_open-zos.gperf
index 1c3552e0f..6912485e1 100644
--- a/lib/iconv_open-zos.gperf
+++ b/lib/iconv_open-zos.gperf
@@ -1,5 +1,5 @@
/* Character set conversion.
- Copyright (C) 2019-2021 Free Software Foundation, Inc.
+ Copyright (C) 2019-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/iconv_open-zos.h b/lib/iconv_open-zos.h
new file mode 100644
index 000000000..5f847251f
--- /dev/null
+++ b/lib/iconv_open-zos.h
@@ -0,0 +1,329 @@
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf -m 10 ./iconv_open-zos.gperf */
+/* Computed positions: -k'4,$' */
+
+#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
+ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
+ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
+ && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
+ && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
+ && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
+ && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
+ && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
+ && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
+ && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
+ && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
+ && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
+ && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
+ && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
+ && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
+ && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
+ && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
+ && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
+ && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
+ && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
+ && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
+ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
+ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
+/* The character set is not based on ISO-646. */
+#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
+#endif
+
+#line 17 "./iconv_open-zos.gperf"
+struct mapping { int standard_name; const char vendor_name[10 + 1]; };
+
+#define TOTAL_KEYWORDS 49
+#define MIN_WORD_LENGTH 3
+#define MAX_WORD_LENGTH 11
+#define MIN_HASH_VALUE 3
+#define MAX_HASH_VALUE 64
+/* maximum key range = 62, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static unsigned int
+mapping_hash (register const char *str, register size_t len)
+{
+ static const unsigned char asso_values[] =
+ {
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 16, 38,
+ 14, 1, 32, 22, 29, 3, 0, 7, 40, 2,
+ 5, 18, 23, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 0, 65, 0, 65, 65, 65, 0,
+ 43, 65, 1, 65, 65, 8, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65
+ };
+ register unsigned int hval = len;
+
+ switch (hval)
+ {
+ default:
+ hval += asso_values[(unsigned char)str[3]+6];
+ /*FALLTHROUGH*/
+ case 3:
+ break;
+ }
+ return hval + asso_values[(unsigned char)str[len - 1]];
+}
+
+struct stringpool_t
+ {
+ char stringpool_str3[sizeof("GBK")];
+ char stringpool_str5[sizeof("ASCII")];
+ char stringpool_str7[sizeof("CP1253")];
+ char stringpool_str8[sizeof("EUC-KR")];
+ char stringpool_str9[sizeof("CP1257")];
+ char stringpool_str10[sizeof("CP857")];
+ char stringpool_str11[sizeof("ISO-8859-8")];
+ char stringpool_str12[sizeof("ISO-8859-3")];
+ char stringpool_str13[sizeof("ISO-8859-13")];
+ char stringpool_str14[sizeof("ISO-8859-7")];
+ char stringpool_str15[sizeof("CP437")];
+ char stringpool_str16[sizeof("CP1129")];
+ char stringpool_str17[sizeof("CP869")];
+ char stringpool_str18[sizeof("ISO-8859-9")];
+ char stringpool_str19[sizeof("CP922")];
+ char stringpool_str20[sizeof("CP1252")];
+ char stringpool_str21[sizeof("CP852")];
+ char stringpool_str22[sizeof("CP1250")];
+ char stringpool_str23[sizeof("CP850")];
+ char stringpool_str24[sizeof("CP862")];
+ char stringpool_str25[sizeof("ISO-8859-2")];
+ char stringpool_str26[sizeof("CP932")];
+ char stringpool_str27[sizeof("GB2312")];
+ char stringpool_str28[sizeof("CP1255")];
+ char stringpool_str29[sizeof("CP855")];
+ char stringpool_str30[sizeof("KOI8-R")];
+ char stringpool_str31[sizeof("CP1125")];
+ char stringpool_str32[sizeof("CP865")];
+ char stringpool_str33[sizeof("ISO-8859-5")];
+ char stringpool_str34[sizeof("ISO-8859-15")];
+ char stringpool_str35[sizeof("CP1256")];
+ char stringpool_str36[sizeof("CP856")];
+ char stringpool_str37[sizeof("KOI8-U")];
+ char stringpool_str38[sizeof("CP1254")];
+ char stringpool_str39[sizeof("CP866")];
+ char stringpool_str40[sizeof("ISO-8859-6")];
+ char stringpool_str41[sizeof("CP1124")];
+ char stringpool_str42[sizeof("CP864")];
+ char stringpool_str43[sizeof("ISO-8859-4")];
+ char stringpool_str44[sizeof("CP1251")];
+ char stringpool_str45[sizeof("CP775")];
+ char stringpool_str46[sizeof("CP943")];
+ char stringpool_str47[sizeof("CP1131")];
+ char stringpool_str48[sizeof("CP861")];
+ char stringpool_str49[sizeof("ISO-8859-1")];
+ char stringpool_str50[sizeof("EUC-JP")];
+ char stringpool_str52[sizeof("CP949")];
+ char stringpool_str55[sizeof("CP874")];
+ char stringpool_str64[sizeof("CP1046")];
+ };
+static const struct stringpool_t stringpool_contents =
+ {
+ "GBK",
+ "ASCII",
+ "CP1253",
+ "EUC-KR",
+ "CP1257",
+ "CP857",
+ "ISO-8859-8",
+ "ISO-8859-3",
+ "ISO-8859-13",
+ "ISO-8859-7",
+ "CP437",
+ "CP1129",
+ "CP869",
+ "ISO-8859-9",
+ "CP922",
+ "CP1252",
+ "CP852",
+ "CP1250",
+ "CP850",
+ "CP862",
+ "ISO-8859-2",
+ "CP932",
+ "GB2312",
+ "CP1255",
+ "CP855",
+ "KOI8-R",
+ "CP1125",
+ "CP865",
+ "ISO-8859-5",
+ "ISO-8859-15",
+ "CP1256",
+ "CP856",
+ "KOI8-U",
+ "CP1254",
+ "CP866",
+ "ISO-8859-6",
+ "CP1124",
+ "CP864",
+ "ISO-8859-4",
+ "CP1251",
+ "CP775",
+ "CP943",
+ "CP1131",
+ "CP861",
+ "ISO-8859-1",
+ "EUC-JP",
+ "CP949",
+ "CP874",
+ "CP1046"
+ };
+#define stringpool ((const char *) &stringpool_contents)
+
+static const struct mapping mappings[] =
+ {
+ {-1}, {-1}, {-1},
+#line 76 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3, "IBM-1386"},
+ {-1},
+#line 28 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str5, "00367"},
+ {-1},
+#line 68 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str7, "IBM-5349"},
+#line 75 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str8, "IBM-eucKR"},
+#line 72 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str9, "09449"},
+#line 48 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str10, "00857"},
+#line 36 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str11, "05012"},
+#line 31 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str12, "00913"},
+#line 38 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str13, "ISO8859-13"},
+#line 35 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str14, "ISO8859-7"},
+#line 42 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str15, "IBM-437"},
+#line 63 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str16, "01129"},
+#line 54 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str17, "IBM-869"},
+#line 37 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str18, "ISO8859-9"},
+#line 56 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str19, "IBM-922"},
+#line 67 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str20, "IBM-5348"},
+#line 45 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str21, "IBM-852"},
+#line 65 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str22, "IBM-5346"},
+#line 44 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str23, "09042"},
+#line 50 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str24, "IBM-862"},
+#line 30 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str25, "ISO8859-2"},
+#line 57 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str26, "IBM-943"},
+#line 73 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str27, "IBM-eucCN"},
+#line 70 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str28, "09447"},
+#line 46 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str29, "13143"},
+#line 40 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str30, "00878"},
+#line 62 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str31, "IBM-1125"},
+#line 52 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str32, "00865"},
+#line 33 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str33, "ISO8859-5"},
+#line 39 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str34, "ISO8859-15"},
+#line 71 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str35, "09448"},
+#line 47 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str36, "IBM-856"},
+#line 41 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str37, "01168"},
+#line 69 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str38, "IBM-5350"},
+#line 53 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str39, "04962"},
+#line 34 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str40, "ISO8859-6"},
+#line 61 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str41, "IBM-1124"},
+#line 51 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str42, "IBM-864"},
+#line 32 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str43, "ISO8859-4"},
+#line 66 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str44, "IBM-5347"},
+#line 43 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str45, "00775"},
+#line 58 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str46, "IBM-943"},
+#line 64 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str47, "01131"},
+#line 49 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str48, "IBM-861"},
+#line 29 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str49, "ISO8859-1"},
+#line 74 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str50, "01350"},
+ {-1},
+#line 59 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str52, "IBM-1363"},
+ {-1}, {-1},
+#line 55 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str55, "TIS-620"},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#line 60 "./iconv_open-zos.gperf"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str64, "IBM-1046"}
+ };
+
+const struct mapping *
+mapping_lookup (register const char *str, register size_t len)
+{
+ if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
+ {
+ register unsigned int key = mapping_hash (str, len);
+
+ if (key <= MAX_HASH_VALUE)
+ {
+ register int o = mappings[key].standard_name;
+ if (o >= 0)
+ {
+ register const char *s = o + stringpool;
+
+ if (*str == *s && !strcmp (str + 1, s + 1))
+ return &mappings[key];
+ }
+ }
+ }
+ return 0;
+}
diff --git a/lib/iconv_open.c b/lib/iconv_open.c
index e573556e9..02c240ee9 100644
--- a/lib/iconv_open.c
+++ b/lib/iconv_open.c
@@ -1,5 +1,5 @@
/* Character set conversion.
- Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/iconveh.h b/lib/iconveh.h
index cbf692ebe..058f68ca2 100644
--- a/lib/iconveh.h
+++ b/lib/iconveh.h
@@ -1,5 +1,5 @@
/* Character set conversion handler type.
- Copyright (C) 2001-2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2001-2007, 2009-2022 Free Software Foundation, Inc.
Written by Bruno Haible.
This file is free software: you can redistribute it and/or modify
@@ -29,7 +29,10 @@ enum iconv_ilseq_handler
{
iconveh_error, /* return and set errno = EILSEQ */
iconveh_question_mark, /* use one '?' per unconvertible character */
- iconveh_escape_sequence /* use escape sequence \uxxxx or \Uxxxxxxxx */
+ iconveh_escape_sequence, /* use escape sequence \uxxxx or \Uxxxxxxxx */
+ iconveh_replacement_character /* use one U+FFFD per unconvertible character
+ if that fits in the target encoding,
+ otherwise one '?' */
};
diff --git a/lib/idx.h b/lib/idx.h
index 483587eab..c3669ddac 100644
--- a/lib/idx.h
+++ b/lib/idx.h
@@ -1,5 +1,5 @@
/* A type for indices and sizes.
- Copyright (C) 2020-2021 Free Software Foundation, Inc.
+ Copyright (C) 2020-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -56,6 +56,26 @@
* Because 'size_t' is an unsigned type, and a signed type is better.
See above.
+ Why not use 'ssize_t'?
+
+ * 'ptrdiff_t' is more portable; it is standardized by ISO C
+ whereas 'ssize_t' is standardized only by POSIX.
+
+ * 'ssize_t' is not required to be as wide as 'size_t', and some
+ now-obsolete POSIX platforms had 'size_t' wider than 'ssize_t'.
+
+ * Conversely, some now-obsolete platforms had 'ptrdiff_t' wider
+ than 'size_t', which can be a win and conforms to POSIX.
+
+ Won't this cause a problem with objects larger than PTRDIFF_MAX?
+
+ * Typical modern or large platforms do not allocate such objects,
+ so this is not much of a problem in practice; for example, you
+ can safely write 'idx_t len = strlen (s);'. To port to older
+ small platforms where allocations larger than PTRDIFF_MAX could
+ in theory be a problem, you can use Gnulib's ialloc module, or
+ functions like ximalloc in Gnulib's xalloc module.
+
Why not use 'ptrdiff_t' directly?
* Maintainability: When reading and modifying code, it helps to know that
diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c
index 409e88c76..2d401d22b 100644
--- a/lib/inet_ntop.c
+++ b/lib/inet_ntop.c
@@ -1,6 +1,6 @@
/* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
- Copyright (C) 2005-2006, 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/inet_pton.c b/lib/inet_pton.c
index 14e8b0acd..a239b7d1e 100644
--- a/lib/inet_pton.c
+++ b/lib/inet_pton.c
@@ -1,6 +1,6 @@
/* inet_pton.c -- convert IPv4 and IPv6 addresses from text to binary form
- Copyright (C) 2006, 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/intprops-internal.h b/lib/intprops-internal.h
new file mode 100644
index 000000000..f6455f785
--- /dev/null
+++ b/lib/intprops-internal.h
@@ -0,0 +1,392 @@
+/* intprops-internal.h -- properties of integer types not visible to users
+
+ Copyright (C) 2001-2022 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_INTPROPS_INTERNAL_H
+#define _GL_INTPROPS_INTERNAL_H
+
+#include <limits.h>
+
+/* Return a value with the common real type of E and V and the value of V.
+ Do not evaluate E. */
+#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v))
+
+/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
+ <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */
+#define _GL_INT_NEGATE_CONVERT(e, v) ((1 ? 0 : (e)) - (v))
+
+/* The extra casts in the following macros work around compiler bugs,
+ e.g., in Cray C 5.0.3.0. */
+
+/* True if the real type T is signed. */
+#define _GL_TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+
+/* Return 1 if the real expression E, after promotion, has a
+ signed or floating type. Do not evaluate E. */
+#define _GL_EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
+
+
+/* Minimum and maximum values for integer types and expressions. */
+
+/* The width in bits of the integer type or expression T.
+ Do not evaluate T. T must not be a bit-field expression.
+ Padding bits are not supported; this is checked at compile-time below. */
+#define _GL_TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
+
+/* The maximum and minimum values for the type of the expression E,
+ after integer promotion. E is not evaluated. */
+#define _GL_INT_MINIMUM(e) \
+ (_GL_EXPR_SIGNED (e) \
+ ? ~ _GL_SIGNED_INT_MAXIMUM (e) \
+ : _GL_INT_CONVERT (e, 0))
+#define _GL_INT_MAXIMUM(e) \
+ (_GL_EXPR_SIGNED (e) \
+ ? _GL_SIGNED_INT_MAXIMUM (e) \
+ : _GL_INT_NEGATE_CONVERT (e, 1))
+#define _GL_SIGNED_INT_MAXIMUM(e) \
+ (((_GL_INT_CONVERT (e, 1) << (_GL_TYPE_WIDTH (+ (e)) - 2)) - 1) * 2 + 1)
+
+/* Work around OpenVMS incompatibility with C99. */
+#if !defined LLONG_MAX && defined __INT64_MAX
+# define LLONG_MAX __INT64_MAX
+# define LLONG_MIN __INT64_MIN
+#endif
+
+/* This include file assumes that signed types are two's complement without
+ padding bits; the above macros have undefined behavior otherwise.
+ If this is a problem for you, please let us know how to fix it for your host.
+ This assumption is tested by the intprops-tests module. */
+
+/* Does the __typeof__ keyword work? This could be done by
+ 'configure', but for now it's easier to do it by hand. */
+#if (2 <= __GNUC__ \
+ || (4 <= __clang_major__) \
+ || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
+ || (0x5110 <= __SUNPRO_C && !__STDC__))
+# define _GL_HAVE___TYPEOF__ 1
+#else
+# define _GL_HAVE___TYPEOF__ 0
+#endif
+
+/* Return 1 if the integer type or expression T might be signed. Return 0
+ if it is definitely unsigned. T must not be a bit-field expression.
+ This macro does not evaluate its argument, and expands to an
+ integer constant expression. */
+#if _GL_HAVE___TYPEOF__
+# define _GL_SIGNED_TYPE_OR_EXPR(t) _GL_TYPE_SIGNED (__typeof__ (t))
+#else
+# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
+#endif
+
+/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
+ A should not have side effects, and A's type should be an
+ integer with minimum value MIN and maximum MAX. */
+#define _GL_INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
+ ((min) < 0 ? (a) < - (max) : 0 < (a))
+
+/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow
+ (A, B, P) work when P is non-null. */
+#ifdef __EDG__
+/* EDG-based compilers like nvc 22.1 cannot add 64-bit signed to unsigned
+ <https://bugs.gnu.org/53256>. */
+# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
+#elif defined __has_builtin
+# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)
+/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x,
+ see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */
+#elif 7 <= __GNUC__
+# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
+#else
+# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
+#endif
+
+/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */
+#if defined __clang_major__ && __clang_major__ < 14
+/* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */
+# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0
+#else
+# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW
+#endif
+
+/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
+ __builtin_sub_overflow_p and __builtin_mul_overflow_p. */
+#ifdef __EDG__
+/* In EDG-based compilers like ICC 2021.3 and earlier,
+ __builtin_add_overflow_p etc. are not treated as integral constant
+ expressions even when all arguments are. */
+# define _GL_HAS_BUILTIN_OVERFLOW_P 0
+#elif defined __has_builtin
+# define _GL_HAS_BUILTIN_OVERFLOW_P __has_builtin (__builtin_mul_overflow_p)
+#else
+# define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
+#endif
+
+#if (!defined _GL_STDCKDINT_H && 202311 <= __STDC_VERSION__ \
+ && ! (_GL_HAS_BUILTIN_ADD_OVERFLOW && _GL_HAS_BUILTIN_MUL_OVERFLOW))
+# include <stdckdint.h>
+#endif
+
+/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
+ Return 1 if the result overflows. Arguments should not have side
+ effects and A, B and *R can be of any integer type other than char,
+ bool, a bit-precise integer type, or an enumeration type. */
+#if _GL_HAS_BUILTIN_ADD_OVERFLOW
+# define _GL_INT_ADD_WRAPV(a, b, r) __builtin_add_overflow (a, b, r)
+# define _GL_INT_SUBTRACT_WRAPV(a, b, r) __builtin_sub_overflow (a, b, r)
+#elif defined ckd_add && defined ckd_sub && !defined _GL_STDCKDINT_H
+# define _GL_INT_ADD_WRAPV(a, b, r) ckd_add (r, + (a), + (b))
+# define _GL_INT_SUBTRACT_WRAPV(a, b, r) ckd_sub (r, + (a), + (b))
+#else
+# define _GL_INT_ADD_WRAPV(a, b, r) \
+ _GL_INT_OP_WRAPV (a, b, r, +, _GL_INT_ADD_RANGE_OVERFLOW)
+# define _GL_INT_SUBTRACT_WRAPV(a, b, r) \
+ _GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW)
+#endif
+#if _GL_HAS_BUILTIN_MUL_OVERFLOW
+# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \
+ || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \
+ && !defined __EDG__)
+# define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r)
+# else
+ /* Work around GCC bug 91450. */
+# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \
+ ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && _GL_EXPR_SIGNED (a) && _GL_EXPR_SIGNED (b) \
+ && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
+ ? ((void) __builtin_mul_overflow (a, b, r), 1) \
+ : __builtin_mul_overflow (a, b, r))
+# endif
+#elif defined ckd_mul && !defined _GL_STDCKDINT_H
+# define _GL_INT_MULTIPLY_WRAPV(a, b, r) ckd_mul (r, + (a), + (b))
+#else
+# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \
+ _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW)
+#endif
+
+/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See:
+ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
+ https://llvm.org/bugs/show_bug.cgi?id=25390
+ For now, assume all versions of GCC-like compilers generate bogus
+ warnings for _Generic. This matters only for compilers that
+ lack relevant builtins. */
+#if __GNUC__ || defined __clang__
+# define _GL__GENERIC_BOGUS 1
+#else
+# define _GL__GENERIC_BOGUS 0
+#endif
+
+/* Store the low-order bits of A <op> B into *R, where OP specifies
+ the operation and OVERFLOW the overflow predicate. Return 1 if the
+ result overflows. Arguments should not have side effects,
+ and A, B and *R can be of any integer type other than char, bool, a
+ bit-precise integer type, or an enumeration type. */
+#if 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
+# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
+ (_Generic \
+ (*(r), \
+ signed char: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ signed char, SCHAR_MIN, SCHAR_MAX), \
+ unsigned char: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ unsigned char, 0, UCHAR_MAX), \
+ short int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ short int, SHRT_MIN, SHRT_MAX), \
+ unsigned short int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ unsigned short int, 0, USHRT_MAX), \
+ int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ int, INT_MIN, INT_MAX), \
+ unsigned int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ unsigned int, 0, UINT_MAX), \
+ long int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
+ long int, LONG_MIN, LONG_MAX), \
+ unsigned long int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
+ unsigned long int, 0, ULONG_MAX), \
+ long long int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
+ long long int, LLONG_MIN, LLONG_MAX), \
+ unsigned long long int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
+ unsigned long long int, 0, ULLONG_MAX)))
+#else
+/* Store the low-order bits of A <op> B into *R, where OP specifies
+ the operation and OVERFLOW the overflow predicate. If *R is
+ signed, its type is ST with bounds SMIN..SMAX; otherwise its type
+ is UT with bounds U..UMAX. ST and UT are narrower than int.
+ Return 1 if the result overflows. Arguments should not have side
+ effects, and A, B and *R can be of any integer type other than
+ char, bool, a bit-precise integer type, or an enumeration type. */
+# if _GL_HAVE___TYPEOF__
+# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
+ (_GL_TYPE_SIGNED (__typeof__ (*(r))) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, st, smin, smax) \
+ : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, ut, 0, umax))
+# else
+# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
+ (overflow (a, b, smin, smax) \
+ ? (overflow (a, b, 0, umax) \
+ ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 1) \
+ : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) < 0) \
+ : (overflow (a, b, 0, umax) \
+ ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) >= 0 \
+ : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 0)))
+# endif
+
+# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
+ (sizeof *(r) == sizeof (signed char) \
+ ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
+ signed char, SCHAR_MIN, SCHAR_MAX, \
+ unsigned char, UCHAR_MAX) \
+ : sizeof *(r) == sizeof (short int) \
+ ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
+ short int, SHRT_MIN, SHRT_MAX, \
+ unsigned short int, USHRT_MAX) \
+ : sizeof *(r) == sizeof (int) \
+ ? (_GL_EXPR_SIGNED (*(r)) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ int, INT_MIN, INT_MAX) \
+ : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ unsigned int, 0, UINT_MAX)) \
+ : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
+# ifdef LLONG_MAX
+# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
+ (sizeof *(r) == sizeof (long int) \
+ ? (_GL_EXPR_SIGNED (*(r)) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
+ long int, LONG_MIN, LONG_MAX) \
+ : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
+ unsigned long int, 0, ULONG_MAX)) \
+ : (_GL_EXPR_SIGNED (*(r)) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
+ long long int, LLONG_MIN, LLONG_MAX) \
+ : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
+ unsigned long long int, 0, ULLONG_MAX)))
+# else
+# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
+ (_GL_EXPR_SIGNED (*(r)) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
+ long int, LONG_MIN, LONG_MAX) \
+ : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
+ unsigned long int, 0, ULONG_MAX))
+# endif
+#endif
+
+/* Store the low-order bits of A <op> B into *R, where the operation
+ is given by OP. Use the unsigned type UT for calculation to avoid
+ overflow problems. *R's type is T, with extrema TMIN and TMAX.
+ T can be any signed integer type other than char, bool, a
+ bit-precise integer type, or an enumeration type.
+ Return 1 if the result overflows. */
+#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
+ (overflow (a, b, tmin, tmax) \
+ ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \
+ : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0))
+
+/* Return 1 if the integer expressions A - B and -A would overflow,
+ respectively. Arguments should not have side effects,
+ and can be any signed integer type other than char, bool, a
+ bit-precise integer type, or an enumeration type.
+ These macros are tuned for their last input argument being a constant. */
+
+#if _GL_HAS_BUILTIN_OVERFLOW_P
+# define _GL_INT_NEGATE_OVERFLOW(a) \
+ __builtin_sub_overflow_p (0, a, (__typeof__ (- (a))) 0)
+#else
+# define _GL_INT_NEGATE_OVERFLOW(a) \
+ _GL_INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
+#endif
+
+/* Return the low-order bits of A <op> B, where the operation is given
+ by OP. Use the unsigned type UT for calculation to avoid undefined
+ behavior on signed integer overflow, and convert the result to type T.
+ UT is at least as wide as T and is no narrower than unsigned int,
+ T is two's complement, and there is no padding or trap representations.
+ Assume that converting UT to T yields the low-order bits, as is
+ done in all known two's-complement C compilers. E.g., see:
+ https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
+
+ According to the C standard, converting UT to T yields an
+ implementation-defined result or signal for values outside T's
+ range. However, code that works around this theoretical problem
+ runs afoul of a compiler bug in Oracle Studio 12.3 x86. See:
+ https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html
+ As the compiler bug is real, don't try to work around the
+ theoretical problem. */
+
+#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \
+ ((t) ((ut) (a) op (ut) (b)))
+
+/* Return true if the numeric values A + B, A - B, A * B fall outside
+ the range TMIN..TMAX. Arguments should not have side effects
+ and can be any integer type other than char, bool,
+ a bit-precise integer type, or an enumeration type.
+ TMIN should be signed and nonpositive.
+ TMAX should be positive, and should be signed unless TMIN is zero. */
+#define _GL_INT_ADD_RANGE_OVERFLOW(a, b, tmin, tmax) \
+ ((b) < 0 \
+ ? (((tmin) \
+ ? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, (tmin) - (b))) || (b) < (tmin)) \
+ && (a) < (tmin) - (b)) \
+ : (a) <= -1 - (b)) \
+ || ((_GL_EXPR_SIGNED (a) ? 0 <= (a) : (tmax) < (a)) && (tmax) < (a) + (b))) \
+ : (a) < 0 \
+ ? (((tmin) \
+ ? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (b, (tmin) - (a))) || (a) < (tmin)) \
+ && (b) < (tmin) - (a)) \
+ : (b) <= -1 - (a)) \
+ || ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, b)) || (tmax) < (b)) \
+ && (tmax) < (a) + (b))) \
+ : (tmax) < (b) || (tmax) - (b) < (a))
+#define _GL_INT_SUBTRACT_RANGE_OVERFLOW(a, b, tmin, tmax) \
+ (((a) < 0) == ((b) < 0) \
+ ? ((a) < (b) \
+ ? !(tmin) || -1 - (tmin) < (b) - (a) - 1 \
+ : (tmax) < (a) - (b)) \
+ : (a) < 0 \
+ ? ((!_GL_EXPR_SIGNED (_GL_INT_CONVERT ((a) - (tmin), b)) && (a) - (tmin) < 0) \
+ || (a) - (tmin) < (b)) \
+ : ((! (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
+ && _GL_EXPR_SIGNED (_GL_INT_CONVERT ((tmax) + (b), a))) \
+ && (tmax) <= -1 - (b)) \
+ || (tmax) + (b) < (a)))
+#define _GL_INT_MULTIPLY_RANGE_OVERFLOW(a, b, tmin, tmax) \
+ ((b) < 0 \
+ ? ((a) < 0 \
+ ? (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
+ ? (a) < (tmax) / (b) \
+ : ((_GL_INT_NEGATE_OVERFLOW (b) \
+ ? _GL_INT_CONVERT (b, tmax) >> (_GL_TYPE_WIDTH (+ (b)) - 1) \
+ : (tmax) / -(b)) \
+ <= -1 - (a))) \
+ : _GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (b, tmin)) && (b) == -1 \
+ ? (_GL_EXPR_SIGNED (a) \
+ ? 0 < (a) + (tmin) \
+ : 0 < (a) && -1 - (tmin) < (a) - 1) \
+ : (tmin) / (b) < (a)) \
+ : (b) == 0 \
+ ? 0 \
+ : ((a) < 0 \
+ ? (_GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (a, tmin)) && (a) == -1 \
+ ? (_GL_EXPR_SIGNED (b) ? 0 < (b) + (tmin) : -1 - (tmin) < (b) - 1) \
+ : (tmin) / (a) < (b)) \
+ : (tmax) / (b) < (a)))
+
+#endif /* _GL_INTPROPS_INTERNAL_H */
diff --git a/lib/intprops.h b/lib/intprops.h
index 9d10028a5..f182ddc1f 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -1,6 +1,6 @@
/* intprops.h -- properties of integer types
- Copyright (C) 2001-2021 Free Software Foundation, Inc.
+ Copyright (C) 2001-2022 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
@@ -15,20 +15,10 @@
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
-/* Written by Paul Eggert. */
-
#ifndef _GL_INTPROPS_H
#define _GL_INTPROPS_H
-#include <limits.h>
-
-/* Return a value with the common real type of E and V and the value of V.
- Do not evaluate E. */
-#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v))
-
-/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
- <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */
-#define _GL_INT_NEGATE_CONVERT(e, v) ((1 ? 0 : (e)) - (v))
+#include "intprops-internal.h"
/* The extra casts in the following macros work around compiler bugs,
e.g., in Cray C 5.0.3.0. */
@@ -38,11 +28,11 @@
#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
/* True if the real type T is signed. */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+#define TYPE_SIGNED(t) _GL_TYPE_SIGNED (t)
/* Return 1 if the real expression E, after promotion, has a
signed or floating type. Do not evaluate E. */
-#define EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
+#define EXPR_SIGNED(e) _GL_EXPR_SIGNED (e)
/* Minimum and maximum values for integer types and expressions. */
@@ -50,7 +40,7 @@
/* The width in bits of the integer type or expression T.
Do not evaluate T. T must not be a bit-field expression.
Padding bits are not supported; this is checked at compile-time below. */
-#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
+#define TYPE_WIDTH(t) _GL_TYPE_WIDTH (t)
/* The maximum and minimum values for the integer type T. */
#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
@@ -59,51 +49,6 @@
? (t) -1 \
: ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1)))
-/* The maximum and minimum values for the type of the expression E,
- after integer promotion. E is not evaluated. */
-#define _GL_INT_MINIMUM(e) \
- (EXPR_SIGNED (e) \
- ? ~ _GL_SIGNED_INT_MAXIMUM (e) \
- : _GL_INT_CONVERT (e, 0))
-#define _GL_INT_MAXIMUM(e) \
- (EXPR_SIGNED (e) \
- ? _GL_SIGNED_INT_MAXIMUM (e) \
- : _GL_INT_NEGATE_CONVERT (e, 1))
-#define _GL_SIGNED_INT_MAXIMUM(e) \
- (((_GL_INT_CONVERT (e, 1) << (TYPE_WIDTH (+ (e)) - 2)) - 1) * 2 + 1)
-
-/* Work around OpenVMS incompatibility with C99. */
-#if !defined LLONG_MAX && defined __INT64_MAX
-# define LLONG_MAX __INT64_MAX
-# define LLONG_MIN __INT64_MIN
-#endif
-
-/* This include file assumes that signed types are two's complement without
- padding bits; the above macros have undefined behavior otherwise.
- If this is a problem for you, please let us know how to fix it for your host.
- This assumption is tested by the intprops-tests module. */
-
-/* Does the __typeof__ keyword work? This could be done by
- 'configure', but for now it's easier to do it by hand. */
-#if (2 <= __GNUC__ \
- || (4 <= __clang_major__) \
- || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
- || (0x5110 <= __SUNPRO_C && !__STDC__))
-# define _GL_HAVE___TYPEOF__ 1
-#else
-# define _GL_HAVE___TYPEOF__ 0
-#endif
-
-/* Return 1 if the integer type or expression T might be signed. Return 0
- if it is definitely unsigned. T must not be a bit-field expression.
- This macro does not evaluate its argument, and expands to an
- integer constant expression. */
-#if _GL_HAVE___TYPEOF__
-# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t))
-#else
-# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
-#endif
-
/* Bound on length of the string representing an unsigned integer
value representable in B bits. log10 (2.0) < 146/485. The
smallest value of B where this bound is not tight is 2621. */
@@ -130,12 +75,11 @@
/* Range overflow checks.
The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C
- operators might not yield numerically correct answers due to
- arithmetic overflow. They do not rely on undefined or
- implementation-defined behavior. Their implementations are simple
- and straightforward, but they are harder to use and may be less
- efficient than the INT_<op>_WRAPV, INT_<op>_OK, and
- INT_<op>_OVERFLOW macros described below.
+ operators overflow arithmetically when given the same arguments.
+ These macros do not rely on undefined or implementation-defined behavior.
+ Although their implementations are simple and straightforward,
+ they are harder to use and may be less efficient than the
+ INT_<op>_WRAPV, INT_<op>_OK, and INT_<op>_OVERFLOW macros described below.
Example usage:
@@ -182,9 +126,7 @@
/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
See above for restrictions. */
#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
- ((min) < 0 \
- ? (a) < - (max) \
- : 0 < (a))
+ _GL_INT_NEGATE_RANGE_OVERFLOW (a, min, max)
/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. Avoid && and || as they tickle
@@ -228,40 +170,6 @@
? (a) < (min) >> (b) \
: (max) >> (b) < (a))
-/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow
- (A, B, P) work when P is non-null. */
-/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x,
- see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */
-#if 7 <= __GNUC__ && !defined __ICC
-# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
-#elif defined __has_builtin
-# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)
-#else
-# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
-#endif
-
-/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */
-#ifdef __clang__
-/* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */
-# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0
-#else
-# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW
-#endif
-
-/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
- __builtin_sub_overflow_p and __builtin_mul_overflow_p. */
-#if defined __clang__ || defined __ICC
-/* Clang 11 lacks __builtin_mul_overflow_p, and even if it did it
- would presumably run afoul of Clang bug 16404. ICC 2021.1's
- __builtin_add_overflow_p etc. are not treated as integral constant
- expressions even when all arguments are. */
-# define _GL_HAS_BUILTIN_OVERFLOW_P 0
-#elif defined __has_builtin
-# define _GL_HAS_BUILTIN_OVERFLOW_P __has_builtin (__builtin_mul_overflow_p)
-#else
-# define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
-#endif
-
/* The _GL*_OVERFLOW macros have the same restrictions as the
*_RANGE_OVERFLOW macros, except that they do not assume that operands
(e.g., A and B) have the same type as MIN and MAX. Instead, they assume
@@ -348,13 +256,18 @@
Because the WRAPV macros convert the result, they report overflow
in different circumstances than the OVERFLOW macros do. For
example, in the typical case with 16-bit 'short' and 32-bit 'int',
- if A, B and R are all of type 'short' then INT_ADD_OVERFLOW (A, B)
+ if A, B and *R are all of type 'short' then INT_ADD_OVERFLOW (A, B)
returns false because the addition cannot overflow after A and B
- are converted to 'int', whereas INT_ADD_WRAPV (A, B, &R) returns
+ are converted to 'int', whereas INT_ADD_WRAPV (A, B, R) returns
true or false depending on whether the sum fits into 'short'.
These macros are tuned for their last input argument being a constant.
+ A, B, and *R should be integers; they need not be the same type,
+ and they need not be all signed or all unsigned.
+ However, none of the integer types should be bit-precise,
+ and *R's type should not be char, bool, or an enumeration type.
+
Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B,
A % B, and A << B would overflow, respectively. */
@@ -362,12 +275,7 @@
_GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
#define INT_SUBTRACT_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
-#if _GL_HAS_BUILTIN_OVERFLOW_P
-# define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a)
-#else
-# define INT_NEGATE_OVERFLOW(a) \
- INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
-#endif
+#define INT_NEGATE_OVERFLOW(a) _GL_INT_NEGATE_OVERFLOW (a)
#define INT_MULTIPLY_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
#define INT_DIVIDE_OVERFLOW(a, b) \
@@ -389,224 +297,9 @@
/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
Return 1 if the result overflows. See above for restrictions. */
-#if _GL_HAS_BUILTIN_ADD_OVERFLOW
-# define INT_ADD_WRAPV(a, b, r) __builtin_add_overflow (a, b, r)
-# define INT_SUBTRACT_WRAPV(a, b, r) __builtin_sub_overflow (a, b, r)
-#else
-# define INT_ADD_WRAPV(a, b, r) \
- _GL_INT_OP_WRAPV (a, b, r, +, _GL_INT_ADD_RANGE_OVERFLOW)
-# define INT_SUBTRACT_WRAPV(a, b, r) \
- _GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW)
-#endif
-#if _GL_HAS_BUILTIN_MUL_OVERFLOW
-# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \
- || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \
- && !defined __ICC)
-# define INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r)
-# else
- /* Work around GCC bug 91450. */
-# define INT_MULTIPLY_WRAPV(a, b, r) \
- ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && EXPR_SIGNED (a) && EXPR_SIGNED (b) \
- && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
- ? ((void) __builtin_mul_overflow (a, b, r), 1) \
- : __builtin_mul_overflow (a, b, r))
-# endif
-#else
-# define INT_MULTIPLY_WRAPV(a, b, r) \
- _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW)
-#endif
-
-/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See:
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
- https://llvm.org/bugs/show_bug.cgi?id=25390
- For now, assume all versions of GCC-like compilers generate bogus
- warnings for _Generic. This matters only for compilers that
- lack relevant builtins. */
-#if __GNUC__ || defined __clang__
-# define _GL__GENERIC_BOGUS 1
-#else
-# define _GL__GENERIC_BOGUS 0
-#endif
-
-/* Store the low-order bits of A <op> B into *R, where OP specifies
- the operation and OVERFLOW the overflow predicate. Return 1 if the
- result overflows. See above for restrictions. */
-#if 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
-# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
- (_Generic \
- (*(r), \
- signed char: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- signed char, SCHAR_MIN, SCHAR_MAX), \
- unsigned char: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- unsigned char, 0, UCHAR_MAX), \
- short int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- short int, SHRT_MIN, SHRT_MAX), \
- unsigned short int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- unsigned short int, 0, USHRT_MAX), \
- int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- int, INT_MIN, INT_MAX), \
- unsigned int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- unsigned int, 0, UINT_MAX), \
- long int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
- long int, LONG_MIN, LONG_MAX), \
- unsigned long int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
- unsigned long int, 0, ULONG_MAX), \
- long long int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
- long long int, LLONG_MIN, LLONG_MAX), \
- unsigned long long int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
- unsigned long long int, 0, ULLONG_MAX)))
-#else
-/* Store the low-order bits of A <op> B into *R, where OP specifies
- the operation and OVERFLOW the overflow predicate. If *R is
- signed, its type is ST with bounds SMIN..SMAX; otherwise its type
- is UT with bounds U..UMAX. ST and UT are narrower than int.
- Return 1 if the result overflows. See above for restrictions. */
-# if _GL_HAVE___TYPEOF__
-# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
- (TYPE_SIGNED (__typeof__ (*(r))) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, st, smin, smax) \
- : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, ut, 0, umax))
-# else
-# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
- (overflow (a, b, smin, smax) \
- ? (overflow (a, b, 0, umax) \
- ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 1) \
- : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) < 0) \
- : (overflow (a, b, 0, umax) \
- ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) >= 0 \
- : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 0)))
-# endif
-
-# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
- (sizeof *(r) == sizeof (signed char) \
- ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
- signed char, SCHAR_MIN, SCHAR_MAX, \
- unsigned char, UCHAR_MAX) \
- : sizeof *(r) == sizeof (short int) \
- ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
- short int, SHRT_MIN, SHRT_MAX, \
- unsigned short int, USHRT_MAX) \
- : sizeof *(r) == sizeof (int) \
- ? (EXPR_SIGNED (*(r)) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- int, INT_MIN, INT_MAX) \
- : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- unsigned int, 0, UINT_MAX)) \
- : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
-# ifdef LLONG_MAX
-# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
- (sizeof *(r) == sizeof (long int) \
- ? (EXPR_SIGNED (*(r)) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
- long int, LONG_MIN, LONG_MAX) \
- : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
- unsigned long int, 0, ULONG_MAX)) \
- : (EXPR_SIGNED (*(r)) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
- long long int, LLONG_MIN, LLONG_MAX) \
- : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
- unsigned long long int, 0, ULLONG_MAX)))
-# else
-# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
- (EXPR_SIGNED (*(r)) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
- long int, LONG_MIN, LONG_MAX) \
- : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
- unsigned long int, 0, ULONG_MAX))
-# endif
-#endif
-
-/* Store the low-order bits of A <op> B into *R, where the operation
- is given by OP. Use the unsigned type UT for calculation to avoid
- overflow problems. *R's type is T, with extrema TMIN and TMAX.
- T must be a signed integer type. Return 1 if the result overflows. */
-#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
- (overflow (a, b, tmin, tmax) \
- ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \
- : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0))
-
-/* Return the low-order bits of A <op> B, where the operation is given
- by OP. Use the unsigned type UT for calculation to avoid undefined
- behavior on signed integer overflow, and convert the result to type T.
- UT is at least as wide as T and is no narrower than unsigned int,
- T is two's complement, and there is no padding or trap representations.
- Assume that converting UT to T yields the low-order bits, as is
- done in all known two's-complement C compilers. E.g., see:
- https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
-
- According to the C standard, converting UT to T yields an
- implementation-defined result or signal for values outside T's
- range. However, code that works around this theoretical problem
- runs afoul of a compiler bug in Oracle Studio 12.3 x86. See:
- https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html
- As the compiler bug is real, don't try to work around the
- theoretical problem. */
-
-#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \
- ((t) ((ut) (a) op (ut) (b)))
-
-/* Return true if the numeric values A + B, A - B, A * B fall outside
- the range TMIN..TMAX. Arguments should be integer expressions
- without side effects. TMIN should be signed and nonpositive.
- TMAX should be positive, and should be signed unless TMIN is zero. */
-#define _GL_INT_ADD_RANGE_OVERFLOW(a, b, tmin, tmax) \
- ((b) < 0 \
- ? (((tmin) \
- ? ((EXPR_SIGNED (_GL_INT_CONVERT (a, (tmin) - (b))) || (b) < (tmin)) \
- && (a) < (tmin) - (b)) \
- : (a) <= -1 - (b)) \
- || ((EXPR_SIGNED (a) ? 0 <= (a) : (tmax) < (a)) && (tmax) < (a) + (b))) \
- : (a) < 0 \
- ? (((tmin) \
- ? ((EXPR_SIGNED (_GL_INT_CONVERT (b, (tmin) - (a))) || (a) < (tmin)) \
- && (b) < (tmin) - (a)) \
- : (b) <= -1 - (a)) \
- || ((EXPR_SIGNED (_GL_INT_CONVERT (a, b)) || (tmax) < (b)) \
- && (tmax) < (a) + (b))) \
- : (tmax) < (b) || (tmax) - (b) < (a))
-#define _GL_INT_SUBTRACT_RANGE_OVERFLOW(a, b, tmin, tmax) \
- (((a) < 0) == ((b) < 0) \
- ? ((a) < (b) \
- ? !(tmin) || -1 - (tmin) < (b) - (a) - 1 \
- : (tmax) < (a) - (b)) \
- : (a) < 0 \
- ? ((!EXPR_SIGNED (_GL_INT_CONVERT ((a) - (tmin), b)) && (a) - (tmin) < 0) \
- || (a) - (tmin) < (b)) \
- : ((! (EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
- && EXPR_SIGNED (_GL_INT_CONVERT ((tmax) + (b), a))) \
- && (tmax) <= -1 - (b)) \
- || (tmax) + (b) < (a)))
-#define _GL_INT_MULTIPLY_RANGE_OVERFLOW(a, b, tmin, tmax) \
- ((b) < 0 \
- ? ((a) < 0 \
- ? (EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
- ? (a) < (tmax) / (b) \
- : ((INT_NEGATE_OVERFLOW (b) \
- ? _GL_INT_CONVERT (b, tmax) >> (TYPE_WIDTH (+ (b)) - 1) \
- : (tmax) / -(b)) \
- <= -1 - (a))) \
- : INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (b, tmin)) && (b) == -1 \
- ? (EXPR_SIGNED (a) \
- ? 0 < (a) + (tmin) \
- : 0 < (a) && -1 - (tmin) < (a) - 1) \
- : (tmin) / (b) < (a)) \
- : (b) == 0 \
- ? 0 \
- : ((a) < 0 \
- ? (INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (a, tmin)) && (a) == -1 \
- ? (EXPR_SIGNED (b) ? 0 < (b) + (tmin) : -1 - (tmin) < (b) - 1) \
- : (tmin) / (a) < (b)) \
- : (tmax) / (b) < (a)))
+#define INT_ADD_WRAPV(a, b, r) _GL_INT_ADD_WRAPV (a, b, r)
+#define INT_SUBTRACT_WRAPV(a, b, r) _GL_INT_SUBTRACT_WRAPV (a, b, r)
+#define INT_MULTIPLY_WRAPV(a, b, r) _GL_INT_MULTIPLY_WRAPV (a, b, r)
/* The following macros compute A + B, A - B, and A * B, respectively.
If no overflow occurs, they set *R to the result and return 1;
@@ -622,6 +315,8 @@
A, B, and *R should be integers; they need not be the same type,
and they need not be all signed or all unsigned.
+ However, none of the integer types should be bit-precise,
+ and *R's type should not be char, bool, or an enumeration type.
These macros work correctly on all known practical hosts, and do not rely
on undefined behavior due to signed arithmetic overflow.
@@ -633,8 +328,8 @@
These macros are tuned for B being a constant. */
-#define INT_ADD_OK(a, b, r) ! INT_ADD_WRAPV (a, b, r)
-#define INT_SUBTRACT_OK(a, b, r) ! INT_SUBTRACT_WRAPV (a, b, r)
-#define INT_MULTIPLY_OK(a, b, r) ! INT_MULTIPLY_WRAPV (a, b, r)
+#define INT_ADD_OK(a, b, r) (! INT_ADD_WRAPV (a, b, r))
+#define INT_SUBTRACT_OK(a, b, r) (! INT_SUBTRACT_WRAPV (a, b, r))
+#define INT_MULTIPLY_OK(a, b, r) (! INT_MULTIPLY_WRAPV (a, b, r))
#endif /* _GL_INTPROPS_H */
diff --git a/lib/inttypes.h b/lib/inttypes.h
new file mode 100644
index 000000000..445a59959
--- /dev/null
+++ b/lib/inttypes.h
@@ -0,0 +1,1509 @@
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+/* Copyright (C) 2006-2022 Free Software Foundation, Inc.
+ Written by Paul Eggert, Bruno Haible, Derek Price.
+ This file is part of gnulib.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/*
+ * ISO C 99 <inttypes.h> for platforms that lack it.
+ * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/inttypes.h.html>
+ */
+
+#if __GNUC__ >= 3
+#pragma GCC system_header
+#endif
+
+
+/* Include the original <inttypes.h> if it exists, and if this file
+ has not been included yet or if this file includes gnulib stdint.h
+ which in turn includes this file.
+ The include_next requires a split double-inclusion guard. */
+#if ! defined INTTYPES_H || defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
+# if 1
+
+ /* Some pre-C++11 <stdint.h> implementations need this. */
+# if defined __cplusplus && ! defined __STDC_FORMAT_MACROS
+# define __STDC_FORMAT_MACROS 1
+# endif
+
+# include_next <inttypes.h>
+
+# define _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H
+# endif
+#endif
+
+#if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
+#define INTTYPES_H
+
+/* Include <stdint.h> or the gnulib replacement.
+ But avoid namespace pollution on glibc systems. */
+#ifndef __GLIBC__
+# include <stdint.h>
+#endif
+/* Get CHAR_BIT, INT_MAX, LONG_MAX, etc. */
+#include <limits.h>
+/* On mingw, __USE_MINGW_ANSI_STDIO only works if <stdio.h> is also included */
+#if defined _WIN32 && ! defined __CYGWIN__
+# include <stdio.h>
+#endif
+
+#if !(INT_MAX == 0x7fffffff && INT_MIN + INT_MAX == -1)
+# error "This file assumes that 'int' is 32-bit two's complement. Please report your platform and compiler to <bug-gnulib@gnu.org>."
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+/* C++ compatible function declaration macros.
+ Copyright (C) 2010-2022 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_CXXDEFS_H
+#define _GL_CXXDEFS_H
+
+/* Begin/end the GNULIB_NAMESPACE namespace. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
+# define _GL_END_NAMESPACE }
+#else
+# define _GL_BEGIN_NAMESPACE
+# define _GL_END_NAMESPACE
+#endif
+
+/* The three most frequent use cases of these macros are:
+
+ * For providing a substitute for a function that is missing on some
+ platforms, but is declared and works fine on the platforms on which
+ it exists:
+
+ #if @GNULIB_FOO@
+ # if !@HAVE_FOO@
+ _GL_FUNCDECL_SYS (foo, ...);
+ # endif
+ _GL_CXXALIAS_SYS (foo, ...);
+ _GL_CXXALIASWARN (foo);
+ #elif defined GNULIB_POSIXCHECK
+ ...
+ #endif
+
+ * For providing a replacement for a function that exists on all platforms,
+ but is broken/insufficient and needs to be replaced on some platforms:
+
+ #if @GNULIB_FOO@
+ # if @REPLACE_FOO@
+ # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+ # undef foo
+ # define foo rpl_foo
+ # endif
+ _GL_FUNCDECL_RPL (foo, ...);
+ _GL_CXXALIAS_RPL (foo, ...);
+ # else
+ _GL_CXXALIAS_SYS (foo, ...);
+ # endif
+ _GL_CXXALIASWARN (foo);
+ #elif defined GNULIB_POSIXCHECK
+ ...
+ #endif
+
+ * For providing a replacement for a function that exists on some platforms
+ but is broken/insufficient and needs to be replaced on some of them and
+ is additionally either missing or undeclared on some other platforms:
+
+ #if @GNULIB_FOO@
+ # if @REPLACE_FOO@
+ # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+ # undef foo
+ # define foo rpl_foo
+ # endif
+ _GL_FUNCDECL_RPL (foo, ...);
+ _GL_CXXALIAS_RPL (foo, ...);
+ # else
+ # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
+ _GL_FUNCDECL_SYS (foo, ...);
+ # endif
+ _GL_CXXALIAS_SYS (foo, ...);
+ # endif
+ _GL_CXXALIASWARN (foo);
+ #elif defined GNULIB_POSIXCHECK
+ ...
+ #endif
+*/
+
+/* _GL_EXTERN_C declaration;
+ performs the declaration with C linkage. */
+#if defined __cplusplus
+# define _GL_EXTERN_C extern "C"
+#else
+# define _GL_EXTERN_C extern
+#endif
+
+/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
+ declares a replacement function, named rpl_func, with the given prototype,
+ consisting of return type, parameters, and attributes.
+ Example:
+ _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
+ _GL_ARG_NONNULL ((1)));
+ */
+#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
+ _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
+#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
+ _GL_EXTERN_C rettype rpl_func parameters_and_attributes
+
+/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
+ declares the system function, named func, with the given prototype,
+ consisting of return type, parameters, and attributes.
+ Example:
+ _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
+ _GL_ARG_NONNULL ((1)));
+ */
+#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
+ _GL_EXTERN_C rettype func parameters_and_attributes
+
+/* _GL_CXXALIAS_RPL (func, rettype, parameters);
+ declares a C++ alias called GNULIB_NAMESPACE::func
+ that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
+ Example:
+ _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
+
+ Wrapping rpl_func in an object with an inline conversion operator
+ avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
+ actually used in the program. */
+#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
+ _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return ::rpl_func; \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_MDA (func, rettype, parameters);
+ is to be used when func is a Microsoft deprecated alias, on native Windows.
+ It declares a C++ alias called GNULIB_NAMESPACE::func
+ that redirects to _func, if GNULIB_NAMESPACE is defined.
+ Example:
+ _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
+ */
+#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
+ _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
+
+/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
+ is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
+ except that the C function rpl_func may have a slightly different
+ declaration. A cast is used to silence the "invalid conversion" error
+ that would otherwise occur. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast<type>(::rpl_func); \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
+ is like _GL_CXXALIAS_MDA (func, rettype, parameters);
+ except that the C function func may have a slightly different declaration.
+ A cast is used to silence the "invalid conversion" error that would
+ otherwise occur. */
+#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
+ _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
+
+/* _GL_CXXALIAS_SYS (func, rettype, parameters);
+ declares a C++ alias called GNULIB_NAMESPACE::func
+ that redirects to the system provided function func, if GNULIB_NAMESPACE
+ is defined.
+ Example:
+ _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
+
+ Wrapping func in an object with an inline conversion operator
+ avoids a reference to func unless GNULIB_NAMESPACE::func is
+ actually used in the program. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return ::func; \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
+ is like _GL_CXXALIAS_SYS (func, rettype, parameters);
+ except that the C function func may have a slightly different declaration.
+ A cast is used to silence the "invalid conversion" error that would
+ otherwise occur. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast<type>(::func); \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
+ is like _GL_CXXALIAS_SYS (func, rettype, parameters);
+ except that the C function is picked among a set of overloaded functions,
+ namely the one with rettype2 and parameters2. Two consecutive casts
+ are used to silence the "cannot find a match" and "invalid conversion"
+ errors that would otherwise occur. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+ /* The outer cast must be a reinterpret_cast.
+ The inner cast: When the function is defined as a set of overloaded
+ functions, it works as a static_cast<>, choosing the designated variant.
+ When the function is defined as a single variant, it works as a
+ reinterpret_cast<>. The parenthesized cast syntax works both ways. */
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIASWARN (func);
+ causes a warning to be emitted when ::func is used but not when
+ GNULIB_NAMESPACE::func is used. func must be defined without overloaded
+ variants. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIASWARN(func) \
+ _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
+# define _GL_CXXALIASWARN_1(func,namespace) \
+ _GL_CXXALIASWARN_2 (func, namespace)
+/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+ we enable the warning only when not optimizing. */
+# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
+# define _GL_CXXALIASWARN_2(func,namespace) \
+ _GL_WARN_ON_USE (func, \
+ "The symbol ::" #func " refers to the system function. " \
+ "Use " #namespace "::" #func " instead.")
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+# define _GL_CXXALIASWARN_2(func,namespace) \
+ extern __typeof__ (func) func
+# else
+# define _GL_CXXALIASWARN_2(func,namespace) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+# endif
+#else
+# define _GL_CXXALIASWARN(func) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
+ causes a warning to be emitted when the given overloaded variant of ::func
+ is used but not when GNULIB_NAMESPACE::func is used. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
+ _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
+ GNULIB_NAMESPACE)
+# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
+ _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
+/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+ we enable the warning only when not optimizing. */
+# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+ _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
+ "The symbol ::" #func " refers to the system function. " \
+ "Use " #namespace "::" #func " instead.")
+# else
+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+# endif
+#else
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+#endif /* _GL_CXXDEFS_H */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+/* A C macro for declaring that specific arguments must not be NULL.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
+ that the values passed as arguments n, ..., m must be non-NULL pointers.
+ n = 1 stands for the first argument, n = 2 for the second argument etc. */
+#ifndef _GL_ARG_NONNULL
+# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
+# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
+# else
+# define _GL_ARG_NONNULL(params)
+# endif
+#endif
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+/* A C macro for emitting warnings if a function is used.
+ Copyright (C) 2010-2022 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
+ for FUNCTION which will then trigger a compiler warning containing
+ the text of "literal string" anywhere that function is called, if
+ supported by the compiler. If the compiler does not support this
+ feature, the macro expands to an unused extern declaration.
+
+ _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
+ attribute used in _GL_WARN_ON_USE. If the compiler does not support
+ this feature, it expands to empty.
+
+ These macros are useful for marking a function as a potential
+ portability trap, with the intent that "literal string" include
+ instructions on the replacement function that should be used
+ instead.
+ _GL_WARN_ON_USE is for functions with 'extern' linkage.
+ _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
+ linkage.
+
+ However, one of the reasons that a function is a portability trap is
+ if it has the wrong signature. Declaring FUNCTION with a different
+ signature in C is a compilation error, so this macro must use the
+ same type as any existing declaration so that programs that avoid
+ the problematic FUNCTION do not fail to compile merely because they
+ included a header that poisoned the function. But this implies that
+ _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
+ have a declaration. Use of this macro implies that there must not
+ be any other macro hiding the declaration of FUNCTION; but
+ undefining FUNCTION first is part of the poisoning process anyway
+ (although for symbols that are provided only via a macro, the result
+ is a compilation error rather than a warning containing
+ "literal string"). Also note that in C++, it is only safe to use if
+ FUNCTION has no overloads.
+
+ For an example, it is possible to poison 'getline' by:
+ - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
+ [getline]) in configure.ac, which potentially defines
+ HAVE_RAW_DECL_GETLINE
+ - adding this code to a header that wraps the system <stdio.h>:
+ #undef getline
+ #if HAVE_RAW_DECL_GETLINE
+ _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
+ "not universally present; use the gnulib module getline");
+ #endif
+
+ It is not possible to directly poison global variables. But it is
+ possible to write a wrapper accessor function, and poison that
+ (less common usage, like &environ, will cause a compilation error
+ rather than issue the nice warning, but the end result of informing
+ the developer about their portability problem is still achieved):
+ #if HAVE_RAW_DECL_ENVIRON
+ static char ***
+ rpl_environ (void) { return &environ; }
+ _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
+ # undef environ
+ # define environ (*rpl_environ ())
+ #endif
+ or better (avoiding contradictory use of 'static' and 'extern'):
+ #if HAVE_RAW_DECL_ENVIRON
+ static char ***
+ _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
+ rpl_environ (void) { return &environ; }
+ # undef environ
+ # define environ (*rpl_environ ())
+ #endif
+ */
+#ifndef _GL_WARN_ON_USE
+
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
+/* A compiler attribute is available in gcc versions 4.3.0 and later. */
+# define _GL_WARN_ON_USE(function, message) \
+_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
+# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
+ __attribute__ ((__warning__ (message)))
+# elif __clang_major__ >= 4
+/* Another compiler attribute is available in clang. */
+# define _GL_WARN_ON_USE(function, message) \
+_GL_WARN_EXTERN_C __typeof__ (function) function \
+ __attribute__ ((__diagnose_if__ (1, message, "warning")))
+# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
+ __attribute__ ((__diagnose_if__ (1, message, "warning")))
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+/* Verify the existence of the function. */
+# define _GL_WARN_ON_USE(function, message) \
+_GL_WARN_EXTERN_C __typeof__ (function) function
+# define _GL_WARN_ON_USE_ATTRIBUTE(message)
+# else /* Unsupported. */
+# define _GL_WARN_ON_USE(function, message) \
+_GL_WARN_EXTERN_C int _gl_warn_on_use
+# define _GL_WARN_ON_USE_ATTRIBUTE(message)
+# endif
+#endif
+
+/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
+ is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
+ function is declared with the given prototype, consisting of return type,
+ parameters, and attributes.
+ This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
+ not work in this case. */
+#ifndef _GL_WARN_ON_USE_CXX
+# if !defined __cplusplus
+# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+ _GL_WARN_ON_USE (function, msg)
+# else
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
+/* A compiler attribute is available in gcc versions 4.3.0 and later. */
+# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+extern rettype_gcc function parameters_and_attributes \
+ __attribute__ ((__warning__ (msg)))
+# elif __clang_major__ >= 4
+/* Another compiler attribute is available in clang. */
+# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+extern rettype_clang function parameters_and_attributes \
+ __attribute__ ((__diagnose_if__ (1, msg, "warning")))
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+/* Verify the existence of the function. */
+# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+extern rettype_gcc function parameters_and_attributes
+# else /* Unsupported. */
+# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+_GL_WARN_EXTERN_C int _gl_warn_on_use
+# endif
+# endif
+#endif
+
+/* _GL_WARN_EXTERN_C declaration;
+ performs the declaration with C linkage. */
+#ifndef _GL_WARN_EXTERN_C
+# if defined __cplusplus
+# define _GL_WARN_EXTERN_C extern "C"
+# else
+# define _GL_WARN_EXTERN_C extern
+# endif
+#endif
+
+/* 7.8.1 Macros for format specifiers */
+
+#if defined _TNS_R_TARGET
+ /* Tandem NonStop R series and compatible platforms released before
+ July 2005 support %Ld but not %lld. */
+# define _LONG_LONG_FORMAT_PREFIX "L"
+#else
+# define _LONG_LONG_FORMAT_PREFIX "ll"
+#endif
+
+#if !defined PRId8
+# ifdef INT8_MAX
+# define PRId8 "d"
+# endif
+#endif
+#if !defined PRIi8
+# ifdef INT8_MAX
+# define PRIi8 "i"
+# endif
+#endif
+#if !defined PRIo8
+# ifdef UINT8_MAX
+# define PRIo8 "o"
+# endif
+#endif
+#if !defined PRIu8
+# ifdef UINT8_MAX
+# define PRIu8 "u"
+# endif
+#endif
+#if !defined PRIx8
+# ifdef UINT8_MAX
+# define PRIx8 "x"
+# endif
+#endif
+#if !defined PRIX8
+# ifdef UINT8_MAX
+# define PRIX8 "X"
+# endif
+#endif
+#if !defined PRId16
+# ifdef INT16_MAX
+# define PRId16 "d"
+# endif
+#endif
+#if !defined PRIi16
+# ifdef INT16_MAX
+# define PRIi16 "i"
+# endif
+#endif
+#if !defined PRIo16
+# ifdef UINT16_MAX
+# define PRIo16 "o"
+# endif
+#endif
+#if !defined PRIu16
+# ifdef UINT16_MAX
+# define PRIu16 "u"
+# endif
+#endif
+#if !defined PRIx16
+# ifdef UINT16_MAX
+# define PRIx16 "x"
+# endif
+#endif
+#if !defined PRIX16
+# ifdef UINT16_MAX
+# define PRIX16 "X"
+# endif
+#endif
+#if !defined PRId32
+# ifdef INT32_MAX
+# define PRId32 "d"
+# endif
+#endif
+#if !defined PRIi32
+# ifdef INT32_MAX
+# define PRIi32 "i"
+# endif
+#endif
+#if !defined PRIo32
+# ifdef UINT32_MAX
+# define PRIo32 "o"
+# endif
+#endif
+#if !defined PRIu32
+# ifdef UINT32_MAX
+# define PRIu32 "u"
+# endif
+#endif
+#if !defined PRIx32
+# ifdef UINT32_MAX
+# define PRIx32 "x"
+# endif
+#endif
+#if !defined PRIX32
+# ifdef UINT32_MAX
+# define PRIX32 "X"
+# endif
+#endif
+#ifdef INT64_MAX
+# if (0 ? defined _LP64 : defined _LP64)
+# define _PRI64_PREFIX "l"
+# elif defined _MSC_VER || defined __MINGW32__
+# define _PRI64_PREFIX "I64"
+# elif LONG_MAX >> 30 == 1
+# define _PRI64_PREFIX _LONG_LONG_FORMAT_PREFIX
+# endif
+# if !defined PRId64
+# define PRId64 _PRI64_PREFIX "d"
+# endif
+# if !defined PRIi64
+# define PRIi64 _PRI64_PREFIX "i"
+# endif
+#endif
+#ifdef UINT64_MAX
+# if (0 ? defined _LP64 : defined _LP64)
+# define _PRIu64_PREFIX "l"
+# elif defined _MSC_VER || defined __MINGW32__
+# define _PRIu64_PREFIX "I64"
+# elif ULONG_MAX >> 31 == 1
+# define _PRIu64_PREFIX _LONG_LONG_FORMAT_PREFIX
+# endif
+# if !defined PRIo64
+# define PRIo64 _PRIu64_PREFIX "o"
+# endif
+# if !defined PRIu64
+# define PRIu64 _PRIu64_PREFIX "u"
+# endif
+# if !defined PRIx64
+# define PRIx64 _PRIu64_PREFIX "x"
+# endif
+# if !defined PRIX64
+# define PRIX64 _PRIu64_PREFIX "X"
+# endif
+#endif
+
+#if !defined PRIdLEAST8
+# define PRIdLEAST8 "d"
+#endif
+#if !defined PRIiLEAST8
+# define PRIiLEAST8 "i"
+#endif
+#if !defined PRIoLEAST8
+# define PRIoLEAST8 "o"
+#endif
+#if !defined PRIuLEAST8
+# define PRIuLEAST8 "u"
+#endif
+#if !defined PRIxLEAST8
+# define PRIxLEAST8 "x"
+#endif
+#if !defined PRIXLEAST8
+# define PRIXLEAST8 "X"
+#endif
+#if !defined PRIdLEAST16
+# define PRIdLEAST16 "d"
+#endif
+#if !defined PRIiLEAST16
+# define PRIiLEAST16 "i"
+#endif
+#if !defined PRIoLEAST16
+# define PRIoLEAST16 "o"
+#endif
+#if !defined PRIuLEAST16
+# define PRIuLEAST16 "u"
+#endif
+#if !defined PRIxLEAST16
+# define PRIxLEAST16 "x"
+#endif
+#if !defined PRIXLEAST16
+# define PRIXLEAST16 "X"
+#endif
+#if !defined PRIdLEAST32
+# define PRIdLEAST32 "d"
+#endif
+#if !defined PRIiLEAST32
+# define PRIiLEAST32 "i"
+#endif
+#if !defined PRIoLEAST32
+# define PRIoLEAST32 "o"
+#endif
+#if !defined PRIuLEAST32
+# define PRIuLEAST32 "u"
+#endif
+#if !defined PRIxLEAST32
+# define PRIxLEAST32 "x"
+#endif
+#if !defined PRIXLEAST32
+# define PRIXLEAST32 "X"
+#endif
+#ifdef INT64_MAX
+# if !defined PRIdLEAST64
+# define PRIdLEAST64 PRId64
+# endif
+# if !defined PRIiLEAST64
+# define PRIiLEAST64 PRIi64
+# endif
+#endif
+#ifdef UINT64_MAX
+# if !defined PRIoLEAST64
+# define PRIoLEAST64 PRIo64
+# endif
+# if !defined PRIuLEAST64
+# define PRIuLEAST64 PRIu64
+# endif
+# if !defined PRIxLEAST64
+# define PRIxLEAST64 PRIx64
+# endif
+# if !defined PRIXLEAST64
+# define PRIXLEAST64 PRIX64
+# endif
+#endif
+
+#if !defined PRIdFAST8
+# if INT_FAST8_MAX > INT32_MAX
+# define PRIdFAST8 PRId64
+# else
+# define PRIdFAST8 "d"
+# endif
+#endif
+#if !defined PRIiFAST8
+# if INT_FAST8_MAX > INT32_MAX
+# define PRIiFAST8 PRIi64
+# else
+# define PRIiFAST8 "i"
+# endif
+#endif
+#if !defined PRIoFAST8
+# if UINT_FAST8_MAX > UINT32_MAX
+# define PRIoFAST8 PRIo64
+# else
+# define PRIoFAST8 "o"
+# endif
+#endif
+#if !defined PRIuFAST8
+# if UINT_FAST8_MAX > UINT32_MAX
+# define PRIuFAST8 PRIu64
+# else
+# define PRIuFAST8 "u"
+# endif
+#endif
+#if !defined PRIxFAST8
+# if UINT_FAST8_MAX > UINT32_MAX
+# define PRIxFAST8 PRIx64
+# else
+# define PRIxFAST8 "x"
+# endif
+#endif
+#if !defined PRIXFAST8
+# if UINT_FAST8_MAX > UINT32_MAX
+# define PRIXFAST8 PRIX64
+# else
+# define PRIXFAST8 "X"
+# endif
+#endif
+#if !defined PRIdFAST16
+# if INT_FAST16_MAX > INT32_MAX
+# define PRIdFAST16 PRId64
+# else
+# define PRIdFAST16 "d"
+# endif
+#endif
+#if !defined PRIiFAST16
+# if INT_FAST16_MAX > INT32_MAX
+# define PRIiFAST16 PRIi64
+# else
+# define PRIiFAST16 "i"
+# endif
+#endif
+#if !defined PRIoFAST16
+# if UINT_FAST16_MAX > UINT32_MAX
+# define PRIoFAST16 PRIo64
+# else
+# define PRIoFAST16 "o"
+# endif
+#endif
+#if !defined PRIuFAST16
+# if UINT_FAST16_MAX > UINT32_MAX
+# define PRIuFAST16 PRIu64
+# else
+# define PRIuFAST16 "u"
+# endif
+#endif
+#if !defined PRIxFAST16
+# if UINT_FAST16_MAX > UINT32_MAX
+# define PRIxFAST16 PRIx64
+# else
+# define PRIxFAST16 "x"
+# endif
+#endif
+#if !defined PRIXFAST16
+# if UINT_FAST16_MAX > UINT32_MAX
+# define PRIXFAST16 PRIX64
+# else
+# define PRIXFAST16 "X"
+# endif
+#endif
+#if !defined PRIdFAST32
+# if INT_FAST32_MAX > INT32_MAX
+# define PRIdFAST32 PRId64
+# else
+# define PRIdFAST32 "d"
+# endif
+#endif
+#if !defined PRIiFAST32
+# if INT_FAST32_MAX > INT32_MAX
+# define PRIiFAST32 PRIi64
+# else
+# define PRIiFAST32 "i"
+# endif
+#endif
+#if !defined PRIoFAST32
+# if UINT_FAST32_MAX > UINT32_MAX
+# define PRIoFAST32 PRIo64
+# else
+# define PRIoFAST32 "o"
+# endif
+#endif
+#if !defined PRIuFAST32
+# if UINT_FAST32_MAX > UINT32_MAX
+# define PRIuFAST32 PRIu64
+# else
+# define PRIuFAST32 "u"
+# endif
+#endif
+#if !defined PRIxFAST32
+# if UINT_FAST32_MAX > UINT32_MAX
+# define PRIxFAST32 PRIx64
+# else
+# define PRIxFAST32 "x"
+# endif
+#endif
+#if !defined PRIXFAST32
+# if UINT_FAST32_MAX > UINT32_MAX
+# define PRIXFAST32 PRIX64
+# else
+# define PRIXFAST32 "X"
+# endif
+#endif
+#ifdef INT64_MAX
+# if !defined PRIdFAST64
+# define PRIdFAST64 PRId64
+# endif
+# if !defined PRIiFAST64
+# define PRIiFAST64 PRIi64
+# endif
+#endif
+#ifdef UINT64_MAX
+# if !defined PRIoFAST64
+# define PRIoFAST64 PRIo64
+# endif
+# if !defined PRIuFAST64
+# define PRIuFAST64 PRIu64
+# endif
+# if !defined PRIxFAST64
+# define PRIxFAST64 PRIx64
+# endif
+# if !defined PRIXFAST64
+# define PRIXFAST64 PRIX64
+# endif
+#endif
+
+#if !defined PRIdMAX
+# if 1
+# define PRIdMAX PRId64
+# else
+# define PRIdMAX "ld"
+# endif
+#endif
+#if !defined PRIiMAX
+# if 1
+# define PRIiMAX PRIi64
+# else
+# define PRIiMAX "li"
+# endif
+#endif
+#if !defined PRIoMAX
+# if 1
+# define PRIoMAX PRIo64
+# else
+# define PRIoMAX "lo"
+# endif
+#endif
+#if !defined PRIuMAX
+# if 1
+# define PRIuMAX PRIu64
+# else
+# define PRIuMAX "lu"
+# endif
+#endif
+#if !defined PRIxMAX
+# if 1
+# define PRIxMAX PRIx64
+# else
+# define PRIxMAX "lx"
+# endif
+#endif
+#if !defined PRIXMAX
+# if 1
+# define PRIXMAX PRIX64
+# else
+# define PRIXMAX "lX"
+# endif
+#endif
+
+#if !defined PRIdPTR
+# ifdef INTPTR_MAX
+# define PRIdPTR __PRIPTR_PREFIX "d"
+# endif
+#endif
+#if !defined PRIiPTR
+# ifdef INTPTR_MAX
+# define PRIiPTR __PRIPTR_PREFIX "i"
+# endif
+#endif
+#if !defined PRIoPTR
+# ifdef UINTPTR_MAX
+# define PRIoPTR __PRIPTR_PREFIX "o"
+# endif
+#endif
+#if !defined PRIuPTR
+# ifdef UINTPTR_MAX
+# define PRIuPTR __PRIPTR_PREFIX "u"
+# endif
+#endif
+#if !defined PRIxPTR
+# ifdef UINTPTR_MAX
+# define PRIxPTR __PRIPTR_PREFIX "x"
+# endif
+#endif
+#if !defined PRIXPTR
+# ifdef UINTPTR_MAX
+# define PRIXPTR __PRIPTR_PREFIX "X"
+# endif
+#endif
+
+#if !defined SCNd8
+# ifdef INT8_MAX
+# define SCNd8 "hhd"
+# endif
+#endif
+#if !defined SCNi8
+# ifdef INT8_MAX
+# define SCNi8 "hhi"
+# endif
+#endif
+#if !defined SCNo8
+# ifdef UINT8_MAX
+# define SCNo8 "hho"
+# endif
+#endif
+#if !defined SCNu8
+# ifdef UINT8_MAX
+# define SCNu8 "hhu"
+# endif
+#endif
+#if !defined SCNx8
+# ifdef UINT8_MAX
+# define SCNx8 "hhx"
+# endif
+#endif
+#if !defined SCNd16
+# ifdef INT16_MAX
+# define SCNd16 "hd"
+# endif
+#endif
+#if !defined SCNi16
+# ifdef INT16_MAX
+# define SCNi16 "hi"
+# endif
+#endif
+#if !defined SCNo16
+# ifdef UINT16_MAX
+# define SCNo16 "ho"
+# endif
+#endif
+#if !defined SCNu16
+# ifdef UINT16_MAX
+# define SCNu16 "hu"
+# endif
+#endif
+#if !defined SCNx16
+# ifdef UINT16_MAX
+# define SCNx16 "hx"
+# endif
+#endif
+#if !defined SCNd32
+# ifdef INT32_MAX
+# define SCNd32 "d"
+# endif
+#endif
+#if !defined SCNi32
+# ifdef INT32_MAX
+# define SCNi32 "i"
+# endif
+#endif
+#if !defined SCNo32
+# ifdef UINT32_MAX
+# define SCNo32 "o"
+# endif
+#endif
+#if !defined SCNu32
+# ifdef UINT32_MAX
+# define SCNu32 "u"
+# endif
+#endif
+#if !defined SCNx32
+# ifdef UINT32_MAX
+# define SCNx32 "x"
+# endif
+#endif
+#ifdef INT64_MAX
+# if (0 ? defined _LP64 : defined _LP64)
+# define _SCN64_PREFIX "l"
+# elif defined _MSC_VER || defined __MINGW32__
+# define _SCN64_PREFIX "I64"
+# elif LONG_MAX >> 30 == 1
+# define _SCN64_PREFIX _LONG_LONG_FORMAT_PREFIX
+# endif
+# if !defined SCNd64
+# define SCNd64 _SCN64_PREFIX "d"
+# endif
+# if !defined SCNi64
+# define SCNi64 _SCN64_PREFIX "i"
+# endif
+#endif
+#ifdef UINT64_MAX
+# if (0 ? defined _LP64 : defined _LP64)
+# define _SCNu64_PREFIX "l"
+# elif defined _MSC_VER || defined __MINGW32__
+# define _SCNu64_PREFIX "I64"
+# elif ULONG_MAX >> 31 == 1
+# define _SCNu64_PREFIX _LONG_LONG_FORMAT_PREFIX
+# endif
+# if !defined SCNo64
+# define SCNo64 _SCNu64_PREFIX "o"
+# endif
+# if !defined SCNu64
+# define SCNu64 _SCNu64_PREFIX "u"
+# endif
+# if !defined SCNx64
+# define SCNx64 _SCNu64_PREFIX "x"
+# endif
+#endif
+
+#if !defined SCNdLEAST8
+# define SCNdLEAST8 "hhd"
+#endif
+#if !defined SCNiLEAST8
+# define SCNiLEAST8 "hhi"
+#endif
+#if !defined SCNoLEAST8
+# define SCNoLEAST8 "hho"
+#endif
+#if !defined SCNuLEAST8
+# define SCNuLEAST8 "hhu"
+#endif
+#if !defined SCNxLEAST8
+# define SCNxLEAST8 "hhx"
+#endif
+#if !defined SCNdLEAST16
+# define SCNdLEAST16 "hd"
+#endif
+#if !defined SCNiLEAST16
+# define SCNiLEAST16 "hi"
+#endif
+#if !defined SCNoLEAST16
+# define SCNoLEAST16 "ho"
+#endif
+#if !defined SCNuLEAST16
+# define SCNuLEAST16 "hu"
+#endif
+#if !defined SCNxLEAST16
+# define SCNxLEAST16 "hx"
+#endif
+#if !defined SCNdLEAST32
+# define SCNdLEAST32 "d"
+#endif
+#if !defined SCNiLEAST32
+# define SCNiLEAST32 "i"
+#endif
+#if !defined SCNoLEAST32
+# define SCNoLEAST32 "o"
+#endif
+#if !defined SCNuLEAST32
+# define SCNuLEAST32 "u"
+#endif
+#if !defined SCNxLEAST32
+# define SCNxLEAST32 "x"
+#endif
+#ifdef INT64_MAX
+# if !defined SCNdLEAST64
+# define SCNdLEAST64 SCNd64
+# endif
+# if !defined SCNiLEAST64
+# define SCNiLEAST64 SCNi64
+# endif
+#endif
+#ifdef UINT64_MAX
+# if !defined SCNoLEAST64
+# define SCNoLEAST64 SCNo64
+# endif
+# if !defined SCNuLEAST64
+# define SCNuLEAST64 SCNu64
+# endif
+# if !defined SCNxLEAST64
+# define SCNxLEAST64 SCNx64
+# endif
+#endif
+
+#if !defined SCNdFAST8
+# if INT_FAST8_MAX > INT32_MAX
+# define SCNdFAST8 SCNd64
+# elif INT_FAST8_MAX == 0x7fff
+# define SCNdFAST8 "hd"
+# elif INT_FAST8_MAX == 0x7f
+# define SCNdFAST8 "hhd"
+# else
+# define SCNdFAST8 "d"
+# endif
+#endif
+#if !defined SCNiFAST8
+# if INT_FAST8_MAX > INT32_MAX
+# define SCNiFAST8 SCNi64
+# elif INT_FAST8_MAX == 0x7fff
+# define SCNiFAST8 "hi"
+# elif INT_FAST8_MAX == 0x7f
+# define SCNiFAST8 "hhi"
+# else
+# define SCNiFAST8 "i"
+# endif
+#endif
+#if !defined SCNoFAST8
+# if UINT_FAST8_MAX > UINT32_MAX
+# define SCNoFAST8 SCNo64
+# elif UINT_FAST8_MAX == 0xffff
+# define SCNoFAST8 "ho"
+# elif UINT_FAST8_MAX == 0xff
+# define SCNoFAST8 "hho"
+# else
+# define SCNoFAST8 "o"
+# endif
+#endif
+#if !defined SCNuFAST8
+# if UINT_FAST8_MAX > UINT32_MAX
+# define SCNuFAST8 SCNu64
+# elif UINT_FAST8_MAX == 0xffff
+# define SCNuFAST8 "hu"
+# elif UINT_FAST8_MAX == 0xff
+# define SCNuFAST8 "hhu"
+# else
+# define SCNuFAST8 "u"
+# endif
+#endif
+#if !defined SCNxFAST8
+# if UINT_FAST8_MAX > UINT32_MAX
+# define SCNxFAST8 SCNx64
+# elif UINT_FAST8_MAX == 0xffff
+# define SCNxFAST8 "hx"
+# elif UINT_FAST8_MAX == 0xff
+# define SCNxFAST8 "hhx"
+# else
+# define SCNxFAST8 "x"
+# endif
+#endif
+#if !defined SCNdFAST16
+# if INT_FAST16_MAX > INT32_MAX
+# define SCNdFAST16 SCNd64
+# elif INT_FAST16_MAX == 0x7fff
+# define SCNdFAST16 "hd"
+# else
+# define SCNdFAST16 "d"
+# endif
+#endif
+#if !defined SCNiFAST16
+# if INT_FAST16_MAX > INT32_MAX
+# define SCNiFAST16 SCNi64
+# elif INT_FAST16_MAX == 0x7fff
+# define SCNiFAST16 "hi"
+# else
+# define SCNiFAST16 "i"
+# endif
+#endif
+#if !defined SCNoFAST16
+# if UINT_FAST16_MAX > UINT32_MAX
+# define SCNoFAST16 SCNo64
+# elif UINT_FAST16_MAX == 0xffff
+# define SCNoFAST16 "ho"
+# else
+# define SCNoFAST16 "o"
+# endif
+#endif
+#if !defined SCNuFAST16
+# if UINT_FAST16_MAX > UINT32_MAX
+# define SCNuFAST16 SCNu64
+# elif UINT_FAST16_MAX == 0xffff
+# define SCNuFAST16 "hu"
+# else
+# define SCNuFAST16 "u"
+# endif
+#endif
+#if !defined SCNxFAST16
+# if UINT_FAST16_MAX > UINT32_MAX
+# define SCNxFAST16 SCNx64
+# elif UINT_FAST16_MAX == 0xffff
+# define SCNxFAST16 "hx"
+# else
+# define SCNxFAST16 "x"
+# endif
+#endif
+#if !defined SCNdFAST32
+# if INT_FAST32_MAX > INT32_MAX
+# define SCNdFAST32 SCNd64
+# else
+# define SCNdFAST32 "d"
+# endif
+#endif
+#if !defined SCNiFAST32
+# if INT_FAST32_MAX > INT32_MAX
+# define SCNiFAST32 SCNi64
+# else
+# define SCNiFAST32 "i"
+# endif
+#endif
+#if !defined SCNoFAST32
+# if UINT_FAST32_MAX > UINT32_MAX
+# define SCNoFAST32 SCNo64
+# else
+# define SCNoFAST32 "o"
+# endif
+#endif
+#if !defined SCNuFAST32
+# if UINT_FAST32_MAX > UINT32_MAX
+# define SCNuFAST32 SCNu64
+# else
+# define SCNuFAST32 "u"
+# endif
+#endif
+#if !defined SCNxFAST32
+# if UINT_FAST32_MAX > UINT32_MAX
+# define SCNxFAST32 SCNx64
+# else
+# define SCNxFAST32 "x"
+# endif
+#endif
+#ifdef INT64_MAX
+# if !defined SCNdFAST64
+# define SCNdFAST64 SCNd64
+# endif
+# if !defined SCNiFAST64
+# define SCNiFAST64 SCNi64
+# endif
+#endif
+#ifdef UINT64_MAX
+# if !defined SCNoFAST64
+# define SCNoFAST64 SCNo64
+# endif
+# if !defined SCNuFAST64
+# define SCNuFAST64 SCNu64
+# endif
+# if !defined SCNxFAST64
+# define SCNxFAST64 SCNx64
+# endif
+#endif
+
+#if !defined SCNdMAX
+# if 1
+# define SCNdMAX SCNd64
+# else
+# define SCNdMAX "ld"
+# endif
+#endif
+#if !defined SCNiMAX
+# if 1
+# define SCNiMAX SCNi64
+# else
+# define SCNiMAX "li"
+# endif
+#endif
+#if !defined SCNoMAX
+# if 1
+# define SCNoMAX SCNo64
+# else
+# define SCNoMAX "lo"
+# endif
+#endif
+#if !defined SCNuMAX
+# if 1
+# define SCNuMAX SCNu64
+# else
+# define SCNuMAX "lu"
+# endif
+#endif
+#if !defined SCNxMAX
+# if 1
+# define SCNxMAX SCNx64
+# else
+# define SCNxMAX "lx"
+# endif
+#endif
+
+#if !defined SCNdPTR
+# ifdef INTPTR_MAX
+# define SCNdPTR __PRIPTR_PREFIX "d"
+# endif
+#endif
+#if !defined SCNiPTR
+# ifdef INTPTR_MAX
+# define SCNiPTR __PRIPTR_PREFIX "i"
+# endif
+#endif
+#if !defined SCNoPTR
+# ifdef UINTPTR_MAX
+# define SCNoPTR __PRIPTR_PREFIX "o"
+# endif
+#endif
+#if !defined SCNuPTR
+# ifdef UINTPTR_MAX
+# define SCNuPTR __PRIPTR_PREFIX "u"
+# endif
+#endif
+#if !defined SCNxPTR
+# ifdef UINTPTR_MAX
+# define SCNxPTR __PRIPTR_PREFIX "x"
+# endif
+#endif
+
+/* 7.8.2 Functions for greatest-width integer types */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if 0
+# if !1
+extern intmax_t imaxabs (intmax_t);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef imaxabs
+# if HAVE_RAW_DECL_IMAXABS
+_GL_WARN_ON_USE (imaxabs, "imaxabs is unportable - "
+ "use gnulib module imaxabs for portability");
+# endif
+#endif
+
+#if 0
+# if !1
+# if !GNULIB_defined_imaxdiv_t
+typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t;
+# define GNULIB_defined_imaxdiv_t 1
+# endif
+# endif
+# if !1
+extern imaxdiv_t imaxdiv (intmax_t, intmax_t);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef imaxdiv
+# if HAVE_RAW_DECL_IMAXDIV
+_GL_WARN_ON_USE (imaxdiv, "imaxdiv is unportable - "
+ "use gnulib module imaxdiv for portability");
+# endif
+#endif
+
+#if 0
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strtoimax
+# define strtoimax rpl_strtoimax
+# endif
+_GL_FUNCDECL_RPL (strtoimax, intmax_t,
+ (const char *restrict, char **restrict, int)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strtoimax, intmax_t,
+ (const char *restrict, char **restrict, int));
+# else
+# if !1
+# undef strtoimax
+_GL_FUNCDECL_SYS (strtoimax, intmax_t,
+ (const char *restrict, char **restrict, int)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (strtoimax, intmax_t,
+ (const char *restrict, char **restrict, int));
+# endif
+_GL_CXXALIASWARN (strtoimax);
+#elif defined GNULIB_POSIXCHECK
+# undef strtoimax
+# if HAVE_RAW_DECL_STRTOIMAX
+_GL_WARN_ON_USE (strtoimax, "strtoimax is unportable - "
+ "use gnulib module strtoimax for portability");
+# endif
+#endif
+
+#if 0
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strtoumax
+# define strtoumax rpl_strtoumax
+# endif
+_GL_FUNCDECL_RPL (strtoumax, uintmax_t,
+ (const char *restrict, char **restrict, int)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strtoumax, uintmax_t,
+ (const char *restrict, char **restrict, int));
+# else
+# if !1
+# undef strtoumax
+_GL_FUNCDECL_SYS (strtoumax, uintmax_t,
+ (const char *restrict, char **restrict, int)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (strtoumax, uintmax_t,
+ (const char *restrict, char **restrict, int));
+# endif
+_GL_CXXALIASWARN (strtoumax);
+#elif defined GNULIB_POSIXCHECK
+# undef strtoumax
+# if HAVE_RAW_DECL_STRTOUMAX
+_GL_WARN_ON_USE (strtoumax, "strtoumax is unportable - "
+ "use gnulib module strtoumax for portability");
+# endif
+#endif
+
+/* Don't bother defining or declaring wcstoimax and wcstoumax, since
+ wide-character functions like this are hardly ever useful. */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !defined INTTYPES_H && !defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H */
diff --git a/lib/inttypes.in.h b/lib/inttypes.in.h
index 41cb4220c..853eca087 100644
--- a/lib/inttypes.in.h
+++ b/lib/inttypes.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2006-2021 Free Software Foundation, Inc.
+/* Copyright (C) 2006-2022 Free Software Foundation, Inc.
Written by Paul Eggert, Bruno Haible, Derek Price.
This file is part of gnulib.
diff --git a/lib/isfinite.c b/lib/isfinite.c
index f1373b90e..c3a0da57c 100644
--- a/lib/isfinite.c
+++ b/lib/isfinite.c
@@ -1,9 +1,9 @@
/* Test for finite value (zero, subnormal, or normal, and not infinite or NaN).
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/isinf.c b/lib/isinf.c
index 62becf22d..c3a505304 100644
--- a/lib/isinf.c
+++ b/lib/isinf.c
@@ -1,9 +1,9 @@
/* Test for positive or negative infinity.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/isnan.c b/lib/isnan.c
index ed3452f90..bd119f691 100644
--- a/lib/isnan.c
+++ b/lib/isnan.c
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/isnand-nolibm.h b/lib/isnand-nolibm.h
index df64f4e17..aad139159 100644
--- a/lib/isnand-nolibm.h
+++ b/lib/isnand-nolibm.h
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/isnand.c b/lib/isnand.c
index 7c5df9072..26501b5d6 100644
--- a/lib/isnand.c
+++ b/lib/isnand.c
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/isnanf-nolibm.h b/lib/isnanf-nolibm.h
index bd858117b..4ce81d6cd 100644
--- a/lib/isnanf-nolibm.h
+++ b/lib/isnanf-nolibm.h
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/isnanf.c b/lib/isnanf.c
index 3b60340a2..e8b721acf 100644
--- a/lib/isnanf.c
+++ b/lib/isnanf.c
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/isnanl-nolibm.h b/lib/isnanl-nolibm.h
index 41fe15699..a4374e70d 100644
--- a/lib/isnanl-nolibm.h
+++ b/lib/isnanl-nolibm.h
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/isnanl.c b/lib/isnanl.c
index e8dedf0f4..2f71d6c3e 100644
--- a/lib/isnanl.c
+++ b/lib/isnanl.c
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/itold.c b/lib/itold.c
index 798486636..fe4a38423 100644
--- a/lib/itold.c
+++ b/lib/itold.c
@@ -1,5 +1,5 @@
/* Replacement for 'int' to 'long double' conversion routine.
- Copyright (C) 2011-2021 Free Software Foundation, Inc.
+ Copyright (C) 2011-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/langinfo.in.h b/lib/langinfo.in.h
index 4873899d8..98aea6a84 100644
--- a/lib/langinfo.in.h
+++ b/lib/langinfo.in.h
@@ -1,5 +1,5 @@
/* Substitute for and wrapper around <langinfo.h>.
- Copyright (C) 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/lc-charset-dispatch.c b/lib/lc-charset-dispatch.c
index 88a0bd325..66d78fd3e 100644
--- a/lib/lc-charset-dispatch.c
+++ b/lib/lc-charset-dispatch.c
@@ -1,5 +1,5 @@
/* Dispatching based on the current locale's character encoding.
- Copyright (C) 2018-2021 Free Software Foundation, Inc.
+ Copyright (C) 2018-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/lc-charset-dispatch.h b/lib/lc-charset-dispatch.h
index 59b485de4..3867c3232 100644
--- a/lib/lc-charset-dispatch.h
+++ b/lib/lc-charset-dispatch.h
@@ -1,5 +1,5 @@
/* Dispatching based on the current locale's character encoding.
- Copyright (C) 2018-2021 Free Software Foundation, Inc.
+ Copyright (C) 2018-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/libc-config.h b/lib/libc-config.h
index 886c11f37..a56665b1c 100644
--- a/lib/libc-config.h
+++ b/lib/libc-config.h
@@ -1,6 +1,6 @@
/* System definitions for code taken from the GNU C Library
- Copyright 2017-2021 Free Software Foundation, Inc.
+ Copyright 2017-2022 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -121,6 +121,7 @@
# undef __attr_dealloc
# undef __attr_dealloc_free
# undef __attribute__
+# undef __attribute_alloc_align__
# undef __attribute_alloc_size__
# undef __attribute_artificial__
# undef __attribute_const__
@@ -129,6 +130,7 @@
# undef __attribute_format_arg__
# undef __attribute_format_strfmon__
# undef __attribute_malloc__
+# undef __attribute_maybe_unused__
# undef __attribute_noinline__
# undef __attribute_nonstring__
# undef __attribute_pure__
@@ -142,16 +144,24 @@
# undef __extern_always_inline
# undef __extern_inline
# undef __flexarr
+# undef __fortified_attr_access
# undef __fortify_function
# undef __glibc_c99_flexarr_available
+# undef __glibc_fortify
+# undef __glibc_fortify_n
# undef __glibc_has_attribute
# undef __glibc_has_builtin
# undef __glibc_has_extension
+# undef __glibc_likely
# undef __glibc_macro_warning
# undef __glibc_macro_warning1
# undef __glibc_objsize
# undef __glibc_objsize0
+# undef __glibc_safe_len_cond
+# undef __glibc_safe_or_unknown_len
# undef __glibc_unlikely
+# undef __glibc_unsafe_len
+# undef __glibc_unsigned_or_positive
# undef __inline
# undef __ptr_t
# undef __restrict
@@ -159,6 +169,7 @@
# undef __va_arg_pack
# undef __va_arg_pack_len
# undef __warnattr
+# undef __wur
/* Include our copy of glibc <sys/cdefs.h>. */
# include <cdefs.h>
diff --git a/lib/libunistring.valgrind b/lib/libunistring.valgrind
index 9eee19afa..630ded08b 100644
--- a/lib/libunistring.valgrind
+++ b/lib/libunistring.valgrind
@@ -1,12 +1,12 @@
# Suppress valgrind messages in an installed libunistring.
-# Copyright (C) 2010-2021 Free Software Foundation, Inc.
+# Copyright (C) 2010-2022 Free Software Foundation, Inc.
#
# This file is free software.
# It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+".
# You can redistribute it and/or modify it under either
# - the terms of the GNU Lesser General Public License as published
-# by the Free Software Foundation; either version 3, or (at your
+# by the Free Software Foundation, either version 3, or (at your
# option) any later version, or
# - the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option)
diff --git a/lib/limits.in.h b/lib/limits.in.h
index 2ecafebb0..b77bf75c5 100644
--- a/lib/limits.in.h
+++ b/lib/limits.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <limits.h>.
- Copyright 2016-2021 Free Software Foundation, Inc.
+ Copyright 2016-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/link.c b/lib/link.c
index bd4bef9f8..2023d75bc 100644
--- a/lib/link.c
+++ b/lib/link.c
@@ -1,6 +1,6 @@
/* Emulate link on platforms that lack it, namely native Windows platforms.
- Copyright (C) 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/listen.c b/lib/listen.c
index a145f82c5..e67bdc9e9 100644
--- a/lib/listen.c
+++ b/lib/listen.c
@@ -1,6 +1,6 @@
/* listen.c --- wrappers for Windows listen function
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/localcharset.c b/lib/localcharset.c
index 9c22050dc..383e50f70 100644
--- a/lib/localcharset.c
+++ b/lib/localcharset.c
@@ -1,6 +1,6 @@
/* Determine a canonical name for the current locale's character encoding.
- Copyright (C) 2000-2006, 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2000-2006, 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/localcharset.h b/lib/localcharset.h
index 27c3ab60e..14b4c7ef4 100644
--- a/lib/localcharset.h
+++ b/lib/localcharset.h
@@ -1,5 +1,5 @@
/* Determine a canonical name for the current locale's character encoding.
- Copyright (C) 2000-2003, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2000-2003, 2009-2022 Free Software Foundation, Inc.
This file is part of the GNU CHARSET Library.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/locale.in.h b/lib/locale.in.h
index 106307069..4aef74d48 100644
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -1,5 +1,5 @@
/* A POSIX <locale.h>.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/localeconv.c b/lib/localeconv.c
index 25e95a112..ef261205d 100644
--- a/lib/localeconv.c
+++ b/lib/localeconv.c
@@ -1,5 +1,5 @@
/* Query locale dependent information for formatting numbers.
- Copyright (C) 2012-2021 Free Software Foundation, Inc.
+ Copyright (C) 2012-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/log.c b/lib/log.c
index 3f142e88d..84ff5e9f7 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -1,9 +1,9 @@
/* Logarithm.
- Copyright (C) 2012-2021 Free Software Foundation, Inc.
+ Copyright (C) 2012-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/log1p.c b/lib/log1p.c
index c45c6ff34..31070a37b 100644
--- a/lib/log1p.c
+++ b/lib/log1p.c
@@ -1,9 +1,9 @@
/* Natural logarithm of 1 plus argument.
- Copyright (C) 2012-2021 Free Software Foundation, Inc.
+ Copyright (C) 2012-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/lstat.c b/lib/lstat.c
index 7de0bf102..472bfbceb 100644
--- a/lib/lstat.c
+++ b/lib/lstat.c
@@ -1,6 +1,6 @@
/* Work around a bug of lstat on some systems
- Copyright (C) 1997-2006, 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 1997-2006, 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/malloc.c b/lib/malloc.c
index 0d8b3596c..f334dd6e9 100644
--- a/lib/malloc.c
+++ b/lib/malloc.c
@@ -1,6 +1,6 @@
/* malloc() function that is glibc compatible.
- Copyright (C) 1997-1998, 2006-2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 1997-1998, 2006-2007, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/malloc/.dirstamp b/lib/malloc/.dirstamp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/lib/malloc/.dirstamp
diff --git a/lib/malloc/dynarray-skeleton.c b/lib/malloc/dynarray-skeleton.c
index 48210e325..bad548a49 100644
--- a/lib/malloc/dynarray-skeleton.c
+++ b/lib/malloc/dynarray-skeleton.c
@@ -1,5 +1,5 @@
/* Type-safe arrays which grow dynamically.
- Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ Copyright (C) 2017-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/malloc/dynarray-skeleton.gl.h b/lib/malloc/dynarray-skeleton.gl.h
new file mode 100644
index 000000000..b48c6a920
--- /dev/null
+++ b/lib/malloc/dynarray-skeleton.gl.h
@@ -0,0 +1,529 @@
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+/* Type-safe arrays which grow dynamically.
+ Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* Pre-processor macros which act as parameters:
+
+ DYNARRAY_STRUCT
+ The struct tag of dynamic array to be defined.
+ DYNARRAY_ELEMENT
+ The type name of the element type. Elements are copied
+ as if by memcpy, and can change address as the dynamic
+ array grows.
+ DYNARRAY_PREFIX
+ The prefix of the functions which are defined.
+
+ The following parameters are optional:
+
+ DYNARRAY_ELEMENT_FREE
+ DYNARRAY_ELEMENT_FREE (E) is evaluated to deallocate the
+ contents of elements. E is of type DYNARRAY_ELEMENT *.
+ DYNARRAY_ELEMENT_INIT
+ DYNARRAY_ELEMENT_INIT (E) is evaluated to initialize a new
+ element. E is of type DYNARRAY_ELEMENT *.
+ If DYNARRAY_ELEMENT_FREE but not DYNARRAY_ELEMENT_INIT is
+ defined, new elements are automatically zero-initialized.
+ Otherwise, new elements have undefined contents.
+ DYNARRAY_INITIAL_SIZE
+ The size of the statically allocated array (default:
+ at least 2, more elements if they fit into 128 bytes).
+ Must be a preprocessor constant. If DYNARRAY_INITIAL_SIZE is 0,
+ there is no statically allocated array at, and all non-empty
+ arrays are heap-allocated.
+ DYNARRAY_FINAL_TYPE
+ The name of the type which holds the final array. If not
+ defined, is PREFIX##finalize not provided. DYNARRAY_FINAL_TYPE
+ must be a struct type, with members of type DYNARRAY_ELEMENT and
+ size_t at the start (in this order).
+
+ These macros are undefined after this header file has been
+ included.
+
+ The following types are provided (their members are private to the
+ dynarray implementation):
+
+ struct DYNARRAY_STRUCT
+
+ The following functions are provided:
+
+ void DYNARRAY_PREFIX##init (struct DYNARRAY_STRUCT *);
+ void DYNARRAY_PREFIX##free (struct DYNARRAY_STRUCT *);
+ bool DYNARRAY_PREFIX##has_failed (const struct DYNARRAY_STRUCT *);
+ void DYNARRAY_PREFIX##mark_failed (struct DYNARRAY_STRUCT *);
+ size_t DYNARRAY_PREFIX##size (const struct DYNARRAY_STRUCT *);
+ DYNARRAY_ELEMENT *DYNARRAY_PREFIX##begin (const struct DYNARRAY_STRUCT *);
+ DYNARRAY_ELEMENT *DYNARRAY_PREFIX##end (const struct DYNARRAY_STRUCT *);
+ DYNARRAY_ELEMENT *DYNARRAY_PREFIX##at (struct DYNARRAY_STRUCT *, size_t);
+ void DYNARRAY_PREFIX##add (struct DYNARRAY_STRUCT *, DYNARRAY_ELEMENT);
+ DYNARRAY_ELEMENT *DYNARRAY_PREFIX##emplace (struct DYNARRAY_STRUCT *);
+ bool DYNARRAY_PREFIX##resize (struct DYNARRAY_STRUCT *, size_t);
+ void DYNARRAY_PREFIX##remove_last (struct DYNARRAY_STRUCT *);
+ void DYNARRAY_PREFIX##clear (struct DYNARRAY_STRUCT *);
+
+ The following functions are provided are provided if the
+ prerequisites are met:
+
+ bool DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *,
+ DYNARRAY_FINAL_TYPE *);
+ (if DYNARRAY_FINAL_TYPE is defined)
+ DYNARRAY_ELEMENT *DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *,
+ size_t *);
+ (if DYNARRAY_FINAL_TYPE is not defined)
+*/
+
+#include <malloc/dynarray.gl.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef DYNARRAY_STRUCT
+# error "DYNARRAY_STRUCT must be defined"
+#endif
+
+#ifndef DYNARRAY_ELEMENT
+# error "DYNARRAY_ELEMENT must be defined"
+#endif
+
+#ifndef DYNARRAY_PREFIX
+# error "DYNARRAY_PREFIX must be defined"
+#endif
+
+#ifdef DYNARRAY_INITIAL_SIZE
+# if DYNARRAY_INITIAL_SIZE < 0
+# error "DYNARRAY_INITIAL_SIZE must be non-negative"
+# endif
+# if DYNARRAY_INITIAL_SIZE > 0
+# define DYNARRAY_HAVE_SCRATCH 1
+# else
+# define DYNARRAY_HAVE_SCRATCH 0
+# endif
+#else
+/* Provide a reasonable default which limits the size of
+ DYNARRAY_STRUCT. */
+# define DYNARRAY_INITIAL_SIZE \
+ (sizeof (DYNARRAY_ELEMENT) > 64 ? 2 : 128 / sizeof (DYNARRAY_ELEMENT))
+# define DYNARRAY_HAVE_SCRATCH 1
+#endif
+
+/* Public type definitions. */
+
+/* All fields of this struct are private to the implementation. */
+struct DYNARRAY_STRUCT
+{
+ union
+ {
+ struct dynarray_header dynarray_abstract;
+ struct
+ {
+ /* These fields must match struct dynarray_header. */
+ size_t used;
+ size_t allocated;
+ DYNARRAY_ELEMENT *array;
+ } dynarray_header;
+ } u;
+
+#if DYNARRAY_HAVE_SCRATCH
+ /* Initial inline allocation. */
+ DYNARRAY_ELEMENT scratch[DYNARRAY_INITIAL_SIZE];
+#endif
+};
+
+/* Internal use only: Helper macros. */
+
+/* Ensure macro-expansion of DYNARRAY_PREFIX. */
+#define DYNARRAY_CONCAT0(prefix, name) prefix##name
+#define DYNARRAY_CONCAT1(prefix, name) DYNARRAY_CONCAT0(prefix, name)
+#define DYNARRAY_NAME(name) DYNARRAY_CONCAT1(DYNARRAY_PREFIX, name)
+
+/* Use DYNARRAY_FREE instead of DYNARRAY_NAME (free),
+ so that Gnulib does not change 'free' to 'rpl_free'. */
+#define DYNARRAY_FREE DYNARRAY_CONCAT1 (DYNARRAY_NAME (f), ree)
+
+/* Address of the scratch buffer if any. */
+#if DYNARRAY_HAVE_SCRATCH
+# define DYNARRAY_SCRATCH(list) (list)->scratch
+#else
+# define DYNARRAY_SCRATCH(list) NULL
+#endif
+
+/* Internal use only: Helper functions. */
+
+/* Internal function. Call DYNARRAY_ELEMENT_FREE with the array
+ elements. Name mangling needed due to the DYNARRAY_ELEMENT_FREE
+ macro expansion. */
+static inline void
+DYNARRAY_NAME (free__elements__) (DYNARRAY_ELEMENT *__dynarray_array,
+ size_t __dynarray_used)
+{
+#ifdef DYNARRAY_ELEMENT_FREE
+ for (size_t __dynarray_i = 0; __dynarray_i < __dynarray_used; ++__dynarray_i)
+ DYNARRAY_ELEMENT_FREE (&__dynarray_array[__dynarray_i]);
+#endif /* DYNARRAY_ELEMENT_FREE */
+}
+
+/* Internal function. Free the non-scratch array allocation. */
+static inline void
+DYNARRAY_NAME (free__array__) (struct DYNARRAY_STRUCT *list)
+{
+#if DYNARRAY_HAVE_SCRATCH
+ if (list->u.dynarray_header.array != list->scratch)
+ free (list->u.dynarray_header.array);
+#else
+ free (list->u.dynarray_header.array);
+#endif
+}
+
+/* Public functions. */
+
+/* Initialize a dynamic array object. This must be called before any
+ use of the object. */
+_GL_ATTRIBUTE_NONNULL ((1))
+static void
+DYNARRAY_NAME (init) (struct DYNARRAY_STRUCT *list)
+{
+ list->u.dynarray_header.used = 0;
+ list->u.dynarray_header.allocated = DYNARRAY_INITIAL_SIZE;
+ list->u.dynarray_header.array = DYNARRAY_SCRATCH (list);
+}
+
+/* Deallocate the dynamic array and its elements. */
+_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NONNULL ((1))
+static void
+DYNARRAY_FREE (struct DYNARRAY_STRUCT *list)
+{
+ DYNARRAY_NAME (free__elements__)
+ (list->u.dynarray_header.array, list->u.dynarray_header.used);
+ DYNARRAY_NAME (free__array__) (list);
+ DYNARRAY_NAME (init) (list);
+}
+
+/* Return true if the dynamic array is in an error state. */
+_GL_ATTRIBUTE_NONNULL ((1))
+static inline bool
+DYNARRAY_NAME (has_failed) (const struct DYNARRAY_STRUCT *list)
+{
+ return list->u.dynarray_header.allocated == __dynarray_error_marker ();
+}
+
+/* Mark the dynamic array as failed. All elements are deallocated as
+ a side effect. */
+_GL_ATTRIBUTE_NONNULL ((1))
+static void
+DYNARRAY_NAME (mark_failed) (struct DYNARRAY_STRUCT *list)
+{
+ DYNARRAY_NAME (free__elements__)
+ (list->u.dynarray_header.array, list->u.dynarray_header.used);
+ DYNARRAY_NAME (free__array__) (list);
+ list->u.dynarray_header.array = DYNARRAY_SCRATCH (list);
+ list->u.dynarray_header.used = 0;
+ list->u.dynarray_header.allocated = __dynarray_error_marker ();
+}
+
+/* Return the number of elements which have been added to the dynamic
+ array. */
+_GL_ATTRIBUTE_NONNULL ((1))
+static inline size_t
+DYNARRAY_NAME (size) (const struct DYNARRAY_STRUCT *list)
+{
+ return list->u.dynarray_header.used;
+}
+
+/* Return a pointer to the array element at INDEX. Terminate the
+ process if INDEX is out of bounds. */
+_GL_ATTRIBUTE_NONNULL ((1))
+static inline DYNARRAY_ELEMENT *
+DYNARRAY_NAME (at) (struct DYNARRAY_STRUCT *list, size_t index)
+{
+ if (_GL_UNLIKELY (index >= DYNARRAY_NAME (size) (list)))
+ __libc_dynarray_at_failure (DYNARRAY_NAME (size) (list), index);
+ return list->u.dynarray_header.array + index;
+}
+
+/* Return a pointer to the first array element, if any. For a
+ zero-length array, the pointer can be NULL even though the dynamic
+ array has not entered the failure state. */
+_GL_ATTRIBUTE_NONNULL ((1))
+static inline DYNARRAY_ELEMENT *
+DYNARRAY_NAME (begin) (struct DYNARRAY_STRUCT *list)
+{
+ return list->u.dynarray_header.array;
+}
+
+/* Return a pointer one element past the last array element. For a
+ zero-length array, the pointer can be NULL even though the dynamic
+ array has not entered the failure state. */
+_GL_ATTRIBUTE_NONNULL ((1))
+static inline DYNARRAY_ELEMENT *
+DYNARRAY_NAME (end) (struct DYNARRAY_STRUCT *list)
+{
+ return list->u.dynarray_header.array + list->u.dynarray_header.used;
+}
+
+/* Internal function. Slow path for the add function below. */
+static void
+DYNARRAY_NAME (add__) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
+{
+ if (_GL_UNLIKELY
+ (!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract,
+ DYNARRAY_SCRATCH (list),
+ sizeof (DYNARRAY_ELEMENT))))
+ {
+ DYNARRAY_NAME (mark_failed) (list);
+ return;
+ }
+
+ /* Copy the new element and increase the array length. */
+ list->u.dynarray_header.array[list->u.dynarray_header.used++] = item;
+}
+
+/* Add ITEM at the end of the array, enlarging it by one element.
+ Mark *LIST as failed if the dynamic array allocation size cannot be
+ increased. */
+_GL_ATTRIBUTE_NONNULL ((1))
+static inline void
+DYNARRAY_NAME (add) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
+{
+ /* Do nothing in case of previous error. */
+ if (DYNARRAY_NAME (has_failed) (list))
+ return;
+
+ /* Enlarge the array if necessary. */
+ if (_GL_UNLIKELY (list->u.dynarray_header.used
+ == list->u.dynarray_header.allocated))
+ {
+ DYNARRAY_NAME (add__) (list, item);
+ return;
+ }
+
+ /* Copy the new element and increase the array length. */
+ list->u.dynarray_header.array[list->u.dynarray_header.used++] = item;
+}
+
+/* Internal function. Building block for the emplace functions below.
+ Assumes space for one more element in *LIST. */
+static inline DYNARRAY_ELEMENT *
+DYNARRAY_NAME (emplace__tail__) (struct DYNARRAY_STRUCT *list)
+{
+ DYNARRAY_ELEMENT *result
+ = &list->u.dynarray_header.array[list->u.dynarray_header.used];
+ ++list->u.dynarray_header.used;
+#if defined (DYNARRAY_ELEMENT_INIT)
+ DYNARRAY_ELEMENT_INIT (result);
+#elif defined (DYNARRAY_ELEMENT_FREE)
+ memset (result, 0, sizeof (*result));
+#endif
+ return result;
+}
+
+/* Internal function. Slow path for the emplace function below. */
+static DYNARRAY_ELEMENT *
+DYNARRAY_NAME (emplace__) (struct DYNARRAY_STRUCT *list)
+{
+ if (_GL_UNLIKELY
+ (!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract,
+ DYNARRAY_SCRATCH (list),
+ sizeof (DYNARRAY_ELEMENT))))
+ {
+ DYNARRAY_NAME (mark_failed) (list);
+ return NULL;
+ }
+ return DYNARRAY_NAME (emplace__tail__) (list);
+}
+
+/* Allocate a place for a new element in *LIST and return a pointer to
+ it. The pointer can be NULL if the dynamic array cannot be
+ enlarged due to a memory allocation failure. */
+_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NODISCARD
+_GL_ATTRIBUTE_NONNULL ((1))
+static
+/* Avoid inlining with the larger initialization code. */
+#if !(defined (DYNARRAY_ELEMENT_INIT) || defined (DYNARRAY_ELEMENT_FREE))
+inline
+#endif
+DYNARRAY_ELEMENT *
+DYNARRAY_NAME (emplace) (struct DYNARRAY_STRUCT *list)
+{
+ /* Do nothing in case of previous error. */
+ if (DYNARRAY_NAME (has_failed) (list))
+ return NULL;
+
+ /* Enlarge the array if necessary. */
+ if (_GL_UNLIKELY (list->u.dynarray_header.used
+ == list->u.dynarray_header.allocated))
+ return (DYNARRAY_NAME (emplace__) (list));
+ return DYNARRAY_NAME (emplace__tail__) (list);
+}
+
+/* Change the size of *LIST to SIZE. If SIZE is larger than the
+ existing size, new elements are added (which can be initialized).
+ Otherwise, the list is truncated, and elements are freed. Return
+ false on memory allocation failure (and mark *LIST as failed). */
+_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NONNULL ((1))
+static bool
+DYNARRAY_NAME (resize) (struct DYNARRAY_STRUCT *list, size_t size)
+{
+ if (size > list->u.dynarray_header.used)
+ {
+ bool ok;
+#if defined (DYNARRAY_ELEMENT_INIT)
+ /* The new elements have to be initialized. */
+ size_t old_size = list->u.dynarray_header.used;
+ ok = __libc_dynarray_resize (&list->u.dynarray_abstract,
+ size, DYNARRAY_SCRATCH (list),
+ sizeof (DYNARRAY_ELEMENT));
+ if (ok)
+ for (size_t i = old_size; i < size; ++i)
+ {
+ DYNARRAY_ELEMENT_INIT (&list->u.dynarray_header.array[i]);
+ }
+#elif defined (DYNARRAY_ELEMENT_FREE)
+ /* Zero initialization is needed so that the elements can be
+ safely freed. */
+ ok = __libc_dynarray_resize_clear
+ (&list->u.dynarray_abstract, size,
+ DYNARRAY_SCRATCH (list), sizeof (DYNARRAY_ELEMENT));
+#else
+ ok = __libc_dynarray_resize (&list->u.dynarray_abstract,
+ size, DYNARRAY_SCRATCH (list),
+ sizeof (DYNARRAY_ELEMENT));
+#endif
+ if (_GL_UNLIKELY (!ok))
+ DYNARRAY_NAME (mark_failed) (list);
+ return ok;
+ }
+ else
+ {
+ /* The list has shrunk in size. Free the removed elements. */
+ DYNARRAY_NAME (free__elements__)
+ (list->u.dynarray_header.array + size,
+ list->u.dynarray_header.used - size);
+ list->u.dynarray_header.used = size;
+ return true;
+ }
+}
+
+/* Remove the last element of LIST if it is present. */
+_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NONNULL ((1))
+static void
+DYNARRAY_NAME (remove_last) (struct DYNARRAY_STRUCT *list)
+{
+ /* used > 0 implies that the array is the non-failed state. */
+ if (list->u.dynarray_header.used > 0)
+ {
+ size_t new_length = list->u.dynarray_header.used - 1;
+#ifdef DYNARRAY_ELEMENT_FREE
+ DYNARRAY_ELEMENT_FREE (&list->u.dynarray_header.array[new_length]);
+#endif
+ list->u.dynarray_header.used = new_length;
+ }
+}
+
+/* Remove all elements from the list. The elements are freed, but the
+ list itself is not. */
+_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NONNULL ((1))
+static void
+DYNARRAY_NAME (clear) (struct DYNARRAY_STRUCT *list)
+{
+ /* free__elements__ does nothing if the list is in the failed
+ state. */
+ DYNARRAY_NAME (free__elements__)
+ (list->u.dynarray_header.array, list->u.dynarray_header.used);
+ list->u.dynarray_header.used = 0;
+}
+
+#ifdef DYNARRAY_FINAL_TYPE
+/* Transfer the dynamic array to a permanent location at *RESULT.
+ Returns true on success on false on allocation failure. In either
+ case, *LIST is re-initialized and can be reused. A NULL pointer is
+ stored in *RESULT if LIST refers to an empty list. On success, the
+ pointer in *RESULT is heap-allocated and must be deallocated using
+ free. */
+_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NODISCARD
+_GL_ATTRIBUTE_NONNULL ((1, 2))
+static bool
+DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list,
+ DYNARRAY_FINAL_TYPE *result)
+{
+ struct dynarray_finalize_result res;
+ if (__libc_dynarray_finalize (&list->u.dynarray_abstract,
+ DYNARRAY_SCRATCH (list),
+ sizeof (DYNARRAY_ELEMENT), &res))
+ {
+ /* On success, the result owns all the data. */
+ DYNARRAY_NAME (init) (list);
+ *result = (DYNARRAY_FINAL_TYPE) { res.array, res.length };
+ return true;
+ }
+ else
+ {
+ /* On error, we need to free all data. */
+ DYNARRAY_FREE (list);
+ errno = ENOMEM;
+ return false;
+ }
+}
+#else /* !DYNARRAY_FINAL_TYPE */
+/* Transfer the dynamic array to a heap-allocated array and return a
+ pointer to it. The pointer is NULL if memory allocation fails, or
+ if the array is empty, so this function should be used only for
+ arrays which are known not be empty (usually because they always
+ have a sentinel at the end). If LENGTHP is not NULL, the array
+ length is written to *LENGTHP. *LIST is re-initialized and can be
+ reused. */
+_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NODISCARD
+_GL_ATTRIBUTE_NONNULL ((1))
+static DYNARRAY_ELEMENT *
+DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, size_t *lengthp)
+{
+ struct dynarray_finalize_result res;
+ if (__libc_dynarray_finalize (&list->u.dynarray_abstract,
+ DYNARRAY_SCRATCH (list),
+ sizeof (DYNARRAY_ELEMENT), &res))
+ {
+ /* On success, the result owns all the data. */
+ DYNARRAY_NAME (init) (list);
+ if (lengthp != NULL)
+ *lengthp = res.length;
+ return res.array;
+ }
+ else
+ {
+ /* On error, we need to free all data. */
+ DYNARRAY_FREE (list);
+ errno = ENOMEM;
+ return NULL;
+ }
+}
+#endif /* !DYNARRAY_FINAL_TYPE */
+
+/* Undo macro definitions. */
+
+#undef DYNARRAY_CONCAT0
+#undef DYNARRAY_CONCAT1
+#undef DYNARRAY_NAME
+#undef DYNARRAY_SCRATCH
+#undef DYNARRAY_HAVE_SCRATCH
+
+#undef DYNARRAY_STRUCT
+#undef DYNARRAY_ELEMENT
+#undef DYNARRAY_PREFIX
+#undef DYNARRAY_ELEMENT_FREE
+#undef DYNARRAY_ELEMENT_INIT
+#undef DYNARRAY_INITIAL_SIZE
+#undef DYNARRAY_FINAL_TYPE
diff --git a/lib/malloc/dynarray.gl.h b/lib/malloc/dynarray.gl.h
new file mode 100644
index 000000000..8227362bb
--- /dev/null
+++ b/lib/malloc/dynarray.gl.h
@@ -0,0 +1,174 @@
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+/* Type-safe arrays which grow dynamically. Shared definitions.
+ Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* To use the dynarray facility, you need to include
+ <malloc/dynarray-skeleton.c> and define the parameter macros
+ documented in that file.
+
+ A minimal example which provides a growing list of integers can be
+ defined like this:
+
+ struct int_array
+ {
+ // Pointer to result array followed by its length,
+ // as required by DYNARRAY_FINAL_TYPE.
+ int *array;
+ size_t length;
+ };
+
+ #define DYNARRAY_STRUCT dynarray_int
+ #define DYNARRAY_ELEMENT int
+ #define DYNARRAY_PREFIX dynarray_int_
+ #define DYNARRAY_FINAL_TYPE struct int_array
+ #include <malloc/dynarray-skeleton.c>
+
+ To create a three-element array with elements 1, 2, 3, use this
+ code:
+
+ struct dynarray_int dyn;
+ dynarray_int_init (&dyn);
+ for (int i = 1; i <= 3; ++i)
+ {
+ int *place = dynarray_int_emplace (&dyn);
+ assert (place != NULL);
+ *place = i;
+ }
+ struct int_array result;
+ bool ok = dynarray_int_finalize (&dyn, &result);
+ assert (ok);
+ assert (result.length == 3);
+ assert (result.array[0] == 1);
+ assert (result.array[1] == 2);
+ assert (result.array[2] == 3);
+ free (result.array);
+
+ If the elements contain resources which must be freed, define
+ DYNARRAY_ELEMENT_FREE appropriately, like this:
+
+ struct str_array
+ {
+ char **array;
+ size_t length;
+ };
+
+ #define DYNARRAY_STRUCT dynarray_str
+ #define DYNARRAY_ELEMENT char *
+ #define DYNARRAY_ELEMENT_FREE(ptr) free (*ptr)
+ #define DYNARRAY_PREFIX dynarray_str_
+ #define DYNARRAY_FINAL_TYPE struct str_array
+ #include <malloc/dynarray-skeleton.c>
+
+ Compared to scratch buffers, dynamic arrays have the following
+ features:
+
+ - They have an element type, and are not just an untyped buffer of
+ bytes.
+
+ - When growing, previously stored elements are preserved. (It is
+ expected that scratch_buffer_grow_preserve and
+ scratch_buffer_set_array_size eventually go away because all
+ current users are moved to dynamic arrays.)
+
+ - Scratch buffers have a more aggressive growth policy because
+ growing them typically means a retry of an operation (across an
+ NSS service module boundary), which is expensive.
+
+ - For the same reason, scratch buffers have a much larger initial
+ stack allocation. */
+
+#ifndef _DYNARRAY_H
+#define _DYNARRAY_H
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <string.h>
+
+struct dynarray_header
+{
+ size_t used;
+ size_t allocated;
+ void *array;
+};
+
+/* Marker used in the allocated member to indicate that an error was
+ encountered. */
+static inline size_t
+__dynarray_error_marker (void)
+{
+ return -1;
+}
+
+/* Internal function. See the has_failed function in
+ dynarray-skeleton.c. */
+static inline bool
+__dynarray_error (struct dynarray_header *list)
+{
+ return list->allocated == __dynarray_error_marker ();
+}
+
+/* Internal function. Enlarge the dynamically allocated area of the
+ array to make room for one more element. SCRATCH is a pointer to
+ the scratch area (which is not heap-allocated and must not be
+ freed). ELEMENT_SIZE is the size, in bytes, of one element.
+ Return false on failure, true on success. */
+bool __libc_dynarray_emplace_enlarge (struct dynarray_header *,
+ void *scratch, size_t element_size);
+
+/* Internal function. Enlarge the dynamically allocated area of the
+ array to make room for at least SIZE elements (which must be larger
+ than the existing used part of the dynamic array). SCRATCH is a
+ pointer to the scratch area (which is not heap-allocated and must
+ not be freed). ELEMENT_SIZE is the size, in bytes, of one element.
+ Return false on failure, true on success. */
+bool __libc_dynarray_resize (struct dynarray_header *, size_t size,
+ void *scratch, size_t element_size);
+
+/* Internal function. Like __libc_dynarray_resize, but clear the new
+ part of the dynamic array. */
+bool __libc_dynarray_resize_clear (struct dynarray_header *, size_t size,
+ void *scratch, size_t element_size);
+
+/* Internal type. */
+struct dynarray_finalize_result
+{
+ void *array;
+ size_t length;
+};
+
+/* Internal function. Copy the dynamically-allocated area to an
+ explicitly-sized heap allocation. SCRATCH is a pointer to the
+ embedded scratch space. ELEMENT_SIZE is the size, in bytes, of the
+ element type. On success, true is returned, and pointer and length
+ are written to *RESULT. On failure, false is returned. The caller
+ has to take care of some of the memory management; this function is
+ expected to be called from dynarray-skeleton.c. */
+bool __libc_dynarray_finalize (struct dynarray_header *list, void *scratch,
+ size_t element_size,
+ struct dynarray_finalize_result *result);
+
+
+/* Internal function. Terminate the process after an index error.
+ SIZE is the number of elements of the dynamic array. INDEX is the
+ lookup index which triggered the failure. */
+_Noreturn void __libc_dynarray_at_failure (size_t size, size_t index);
+
+#ifndef _ISOMAC
+#endif
+
+#endif /* _DYNARRAY_H */
diff --git a/lib/malloc/dynarray.h b/lib/malloc/dynarray.h
index 638c33f98..f16fd950d 100644
--- a/lib/malloc/dynarray.h
+++ b/lib/malloc/dynarray.h
@@ -1,5 +1,5 @@
/* Type-safe arrays which grow dynamically. Shared definitions.
- Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ Copyright (C) 2017-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/malloc/dynarray_at_failure.c b/lib/malloc/dynarray_at_failure.c
index 8dd685078..062ab7062 100644
--- a/lib/malloc/dynarray_at_failure.c
+++ b/lib/malloc/dynarray_at_failure.c
@@ -1,5 +1,5 @@
/* Report an dynamic array index out of bounds condition.
- Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ Copyright (C) 2017-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/malloc/dynarray_emplace_enlarge.c b/lib/malloc/dynarray_emplace_enlarge.c
index 0f8baf94a..0cff2e705 100644
--- a/lib/malloc/dynarray_emplace_enlarge.c
+++ b/lib/malloc/dynarray_emplace_enlarge.c
@@ -1,5 +1,5 @@
/* Increase the size of a dynamic array in preparation of an emplace operation.
- Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ Copyright (C) 2017-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/malloc/dynarray_finalize.c b/lib/malloc/dynarray_finalize.c
index c33da4138..3f360c3aa 100644
--- a/lib/malloc/dynarray_finalize.c
+++ b/lib/malloc/dynarray_finalize.c
@@ -1,5 +1,5 @@
/* Copy the dynamically-allocated area to an explicitly-sized heap allocation.
- Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ Copyright (C) 2017-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/malloc/dynarray_resize.c b/lib/malloc/dynarray_resize.c
index 5a57166a8..8d1922e5c 100644
--- a/lib/malloc/dynarray_resize.c
+++ b/lib/malloc/dynarray_resize.c
@@ -1,5 +1,5 @@
/* Increase the size of a dynamic array.
- Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ Copyright (C) 2017-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/malloc/dynarray_resize_clear.c b/lib/malloc/dynarray_resize_clear.c
index 9c43b00c3..8cf1b0d02 100644
--- a/lib/malloc/dynarray_resize_clear.c
+++ b/lib/malloc/dynarray_resize_clear.c
@@ -1,5 +1,5 @@
/* Increase the size of a dynamic array and clear the new part.
- Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ Copyright (C) 2017-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/malloc/scratch_buffer.h b/lib/malloc/scratch_buffer.h
index 36d0bef4b..e4c5c8a85 100644
--- a/lib/malloc/scratch_buffer.h
+++ b/lib/malloc/scratch_buffer.h
@@ -1,5 +1,5 @@
/* Variable-sized buffer with on-stack default allocation.
- Copyright (C) 2015-2021 Free Software Foundation, Inc.
+ Copyright (C) 2015-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/malloc/scratch_buffer_dupfree.c b/lib/malloc/scratch_buffer_dupfree.c
index 07363b9bc..eb3b95c1b 100644
--- a/lib/malloc/scratch_buffer_dupfree.c
+++ b/lib/malloc/scratch_buffer_dupfree.c
@@ -1,5 +1,5 @@
/* Variable-sized buffer with on-stack default allocation.
- Copyright (C) 2020-2021 Free Software Foundation, Inc.
+ Copyright (C) 2020-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/malloc/scratch_buffer_grow.c b/lib/malloc/scratch_buffer_grow.c
index 22c8c7781..9a5e4dbb1 100644
--- a/lib/malloc/scratch_buffer_grow.c
+++ b/lib/malloc/scratch_buffer_grow.c
@@ -1,5 +1,5 @@
/* Variable-sized buffer with on-stack default allocation.
- Copyright (C) 2015-2021 Free Software Foundation, Inc.
+ Copyright (C) 2015-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/malloc/scratch_buffer_grow_preserve.c b/lib/malloc/scratch_buffer_grow_preserve.c
index 2b2b81928..3fe5a0720 100644
--- a/lib/malloc/scratch_buffer_grow_preserve.c
+++ b/lib/malloc/scratch_buffer_grow_preserve.c
@@ -1,5 +1,5 @@
/* Variable-sized buffer with on-stack default allocation.
- Copyright (C) 2015-2021 Free Software Foundation, Inc.
+ Copyright (C) 2015-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/malloc/scratch_buffer_set_array_size.c b/lib/malloc/scratch_buffer_set_array_size.c
index a47f9276a..89c37a950 100644
--- a/lib/malloc/scratch_buffer_set_array_size.c
+++ b/lib/malloc/scratch_buffer_set_array_size.c
@@ -1,5 +1,5 @@
/* Variable-sized buffer with on-stack default allocation.
- Copyright (C) 2015-2021 Free Software Foundation, Inc.
+ Copyright (C) 2015-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/malloca.c b/lib/malloca.c
index b4884234a..183783a71 100644
--- a/lib/malloca.c
+++ b/lib/malloca.c
@@ -1,5 +1,5 @@
/* Safe automatic memory allocation.
- Copyright (C) 2003, 2006-2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2006-2007, 2009-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003, 2018.
This file is free software: you can redistribute it and/or modify
@@ -21,8 +21,9 @@
/* Specification. */
#include "malloca.h"
+#include <stdckdint.h>
+
#include "idx.h"
-#include "intprops.h"
#include "verify.h"
/* The speed critical point in this file is freea() applied to an alloca()
@@ -50,17 +51,16 @@ mmalloca (size_t n)
uintptr_t alignment2_mask = 2 * sa_alignment_max - 1;
int plus = sizeof (small_t) + alignment2_mask;
idx_t nplus;
- if (!INT_ADD_WRAPV (n, plus, &nplus) && !xalloc_oversized (nplus, 1))
+ if (!ckd_add (&nplus, n, plus) && !xalloc_oversized (nplus, 1))
{
char *mem = (char *) malloc (nplus);
if (mem != NULL)
{
uintptr_t umem = (uintptr_t)mem, umemplus;
- /* The INT_ADD_WRAPV avoids signed integer overflow on
+ /* The ckd_add avoids signed integer overflow on
theoretical platforms where UINTPTR_MAX <= INT_MAX. */
- INT_ADD_WRAPV (umem, sizeof (small_t) + sa_alignment_max - 1,
- &umemplus);
+ ckd_add (&umemplus, umem, sizeof (small_t) + sa_alignment_max - 1);
idx_t offset = ((umemplus & ~alignment2_mask)
+ sa_alignment_max - umem);
void *vp = mem + offset;
diff --git a/lib/malloca.h b/lib/malloca.h
index 7eb63d2a7..7ec235f37 100644
--- a/lib/malloca.h
+++ b/lib/malloca.h
@@ -1,5 +1,5 @@
/* Safe automatic memory allocation.
- Copyright (C) 2003-2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2003-2007, 2009-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/math.c b/lib/math.c
index 3ffd1d728..1502a1fd6 100644
--- a/lib/math.c
+++ b/lib/math.c
@@ -1,6 +1,6 @@
/* Inline functions for <math.h>.
- Copyright (C) 2012-2021 Free Software Foundation, Inc.
+ Copyright (C) 2012-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/math.in.h b/lib/math.in.h
index 6a055fbf5..a74a95da3 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <math.h>.
- Copyright (C) 2002-2003, 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -56,6 +56,16 @@ _GL_INLINE_HEADER_BEGIN
# define _GL_MATH_INLINE _GL_INLINE
#endif
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+ The attribute __const__ was added in gcc 2.95. */
+#ifndef _GL_ATTRIBUTE_CONST
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) || defined __clang__
+# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
+# else
+# define _GL_ATTRIBUTE_CONST /* empty */
+# endif
+#endif
+
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -2423,6 +2433,7 @@ _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite)
functions. */
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite, rpl_isfinite, bool)
# define isfinite rpl_isfinite
+# define GNULIB_NAMESPACE_LACKS_ISFINITE 1
# else
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite, isfinite, bool)
# endif
@@ -2457,6 +2468,7 @@ _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf)
functions. */
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf, rpl_isinf, bool)
# define isinf rpl_isinf
+# define GNULIB_NAMESPACE_LACKS_ISINF 1
# else
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf, isinf, bool)
# endif
@@ -2584,6 +2596,7 @@ _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan)
functions. */
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, rpl_isnan, bool)
# define isnan rpl_isnan
+# define GNULIB_NAMESPACE_LACKS_ISNAN 1
# else
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, isnan, bool)
# endif
@@ -2667,6 +2680,7 @@ _GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit)
functions. */
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit, rpl_signbit, bool)
# define signbit rpl_signbit
+# define GNULIB_NAMESPACE_LACKS_SIGNBIT 1
# else
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit, signbit, bool)
# endif
diff --git a/lib/mbrtowc-impl-utf8.h b/lib/mbrtowc-impl-utf8.h
index 330fb1051..8e5ac14ea 100644
--- a/lib/mbrtowc-impl-utf8.h
+++ b/lib/mbrtowc-impl-utf8.h
@@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
- Copyright (C) 1999-2002, 2005-2021 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2005-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/mbrtowc-impl.h b/lib/mbrtowc-impl.h
index bc3e68823..65538e744 100644
--- a/lib/mbrtowc-impl.h
+++ b/lib/mbrtowc-impl.h
@@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
- Copyright (C) 1999-2002, 2005-2021 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2005-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/mbrtowc.c b/lib/mbrtowc.c
index 8832f6e80..4b164edd4 100644
--- a/lib/mbrtowc.c
+++ b/lib/mbrtowc.c
@@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
- Copyright (C) 1999-2002, 2005-2021 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2005-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/mbsinit.c b/lib/mbsinit.c
index f44015534..9621defc7 100644
--- a/lib/mbsinit.c
+++ b/lib/mbsinit.c
@@ -1,5 +1,5 @@
/* Test for initial conversion state.
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/mbtowc-impl.h b/lib/mbtowc-impl.h
index 30d715d6a..2b27bafd6 100644
--- a/lib/mbtowc-impl.h
+++ b/lib/mbtowc-impl.h
@@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
- Copyright (C) 2011-2021 Free Software Foundation, Inc.
+ Copyright (C) 2011-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/mbtowc-lock.c b/lib/mbtowc-lock.c
index 0f7ae6c21..06d32246d 100644
--- a/lib/mbtowc-lock.c
+++ b/lib/mbtowc-lock.c
@@ -1,5 +1,5 @@
/* Return the internal lock used by mbrtowc and mbrtoc32.
- Copyright (C) 2019-2021 Free Software Foundation, Inc.
+ Copyright (C) 2019-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/mbtowc-lock.h b/lib/mbtowc-lock.h
index d31b0b6c7..ecfd44e8d 100644
--- a/lib/mbtowc-lock.h
+++ b/lib/mbtowc-lock.h
@@ -1,5 +1,5 @@
/* Use the internal lock used by mbrtowc and mbrtoc32.
- Copyright (C) 2019-2021 Free Software Foundation, Inc.
+ Copyright (C) 2019-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/mbtowc.c b/lib/mbtowc.c
index 47b431a42..a9a799510 100644
--- a/lib/mbtowc.c
+++ b/lib/mbtowc.c
@@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
- Copyright (C) 2011-2021 Free Software Foundation, Inc.
+ Copyright (C) 2011-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/memchr.c b/lib/memchr.c
index 56fd59d79..0ca7b30a4 100644
--- a/lib/memchr.c
+++ b/lib/memchr.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2021
+/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2022
Free Software Foundation, Inc.
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
diff --git a/lib/memchr.valgrind b/lib/memchr.valgrind
index 4f16481ce..cb0f351cc 100644
--- a/lib/memchr.valgrind
+++ b/lib/memchr.valgrind
@@ -1,6 +1,6 @@
# Suppress a valgrind message about use of uninitialized memory in memchr().
-# Copyright (C) 2009-2021 Free Software Foundation, Inc.
+# Copyright (C) 2009-2022 Free Software Foundation, Inc.
#
# This file is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
diff --git a/lib/mempcpy.c b/lib/mempcpy.c
index cacacdbc6..9aae418ef 100644
--- a/lib/mempcpy.c
+++ b/lib/mempcpy.c
@@ -1,5 +1,5 @@
/* Copy memory area and return pointer after last written byte.
- Copyright (C) 2003, 2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2007, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/minmax.h b/lib/minmax.h
index a03361baf..b4b1345bb 100644
--- a/lib/minmax.h
+++ b/lib/minmax.h
@@ -1,5 +1,5 @@
/* MIN, MAX macros.
- Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2021 Free Software
+ Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/mkdir.c b/lib/mkdir.c
index 2766cc786..490170181 100644
--- a/lib/mkdir.c
+++ b/lib/mkdir.c
@@ -1,7 +1,7 @@
/* On some systems, mkdir ("foo/", 0700) fails because of the trailing
slash. On those systems, this wrapper removes the trailing slash.
- Copyright (C) 2001, 2003, 2006, 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2006, 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -48,7 +48,7 @@
/* This function is required at least for NetBSD 1.5.2. */
int
-rpl_mkdir (char const *dir, mode_t mode maybe_unused)
+rpl_mkdir (char const *dir, maybe_unused mode_t mode)
{
int ret_val;
char *tmp_dir;
diff --git a/lib/mkostemp.c b/lib/mkostemp.c
index 285f1badf..eae289aff 100644
--- a/lib/mkostemp.c
+++ b/lib/mkostemp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2021 Free Software
+/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2022 Free Software
Foundation, Inc.
This file is derived from the one in the GNU C Library.
diff --git a/lib/mktime-internal.h b/lib/mktime-internal.h
index 7386625d3..170764eab 100644
--- a/lib/mktime-internal.h
+++ b/lib/mktime-internal.h
@@ -1,5 +1,5 @@
/* Internals of mktime and related functions
- Copyright 2016-2021 Free Software Foundation, Inc.
+ Copyright 2016-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Paul Eggert <eggert@cs.ucla.edu>.
diff --git a/lib/mktime.c b/lib/mktime.c
index ae721c72e..7dc9d67ef 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -1,5 +1,5 @@
/* Convert a 'struct tm' to a time_t value.
- Copyright (C) 1993-2021 Free Software Foundation, Inc.
+ Copyright (C) 1993-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Paul Eggert <eggert@twinsun.com>.
@@ -429,8 +429,13 @@ __mktime_internal (struct tm *tp,
time with the right value, and use its UTC offset.
Heuristic: probe the adjacent timestamps in both directions,
- looking for the desired isdst. This should work for all real
- time zone histories in the tz database. */
+ looking for the desired isdst. If none is found within a
+ reasonable duration bound, assume a one-hour DST difference.
+ This should work for all real time zone histories in the tz
+ database. */
+
+ /* +1 if we wanted standard time but got DST, -1 if the reverse. */
+ int dst_difference = (isdst == 0) - (tm.tm_isdst == 0);
/* Distance between probes when looking for a DST boundary. In
tzdata2003a, the shortest period of DST is 601200 seconds
@@ -441,12 +446,14 @@ __mktime_internal (struct tm *tp,
periods when probing. */
int stride = 601200;
- /* The longest period of DST in tzdata2003a is 536454000 seconds
- (e.g., America/Jujuy starting 1946-10-01 01:00). The longest
- period of non-DST is much longer, but it makes no real sense
- to search for more than a year of non-DST, so use the DST
- max. */
- int duration_max = 536454000;
+ /* In TZDB 2021e, the longest period of DST (or of non-DST), in
+ which the DST (or adjacent DST) difference is not one hour,
+ is 457243209 seconds: e.g., America/Cambridge_Bay with leap
+ seconds, starting 1965-10-31 00:00 in a switch from
+ double-daylight time (-05) to standard time (-07), and
+ continuing to 1980-04-27 02:00 in a switch from standard time
+ (-07) to daylight time (-06). */
+ int duration_max = 457243209;
/* Search in both directions, so the maximum distance is half
the duration; add the stride to avoid off-by-1 problems. */
@@ -483,6 +490,11 @@ __mktime_internal (struct tm *tp,
}
}
+ /* No unusual DST offset was found nearby. Assume one-hour DST. */
+ t += 60 * 60 * dst_difference;
+ if (mktime_min <= t && t <= mktime_max && convert_time (convert, t, &tm))
+ goto offset_found;
+
__set_errno (EOVERFLOW);
return -1;
}
diff --git a/lib/msvc-inval.c b/lib/msvc-inval.c
index a23dac958..d6651caa8 100644
--- a/lib/msvc-inval.c
+++ b/lib/msvc-inval.c
@@ -1,5 +1,5 @@
/* Invalid parameter handler for MSVC runtime libraries.
- Copyright (C) 2011-2021 Free Software Foundation, Inc.
+ Copyright (C) 2011-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/msvc-inval.h b/lib/msvc-inval.h
index e115a3514..1230b8994 100644
--- a/lib/msvc-inval.h
+++ b/lib/msvc-inval.h
@@ -1,5 +1,5 @@
/* Invalid parameter handler for MSVC runtime libraries.
- Copyright (C) 2011-2021 Free Software Foundation, Inc.
+ Copyright (C) 2011-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/msvc-nothrow.c b/lib/msvc-nothrow.c
index d3c1f54be..aa069643f 100644
--- a/lib/msvc-nothrow.c
+++ b/lib/msvc-nothrow.c
@@ -1,6 +1,6 @@
/* Wrappers that don't throw invalid parameter notifications
with MSVC runtime libraries.
- Copyright (C) 2011-2021 Free Software Foundation, Inc.
+ Copyright (C) 2011-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/msvc-nothrow.h b/lib/msvc-nothrow.h
index 057b5dd8e..53451557e 100644
--- a/lib/msvc-nothrow.h
+++ b/lib/msvc-nothrow.h
@@ -1,6 +1,6 @@
/* Wrappers that don't throw invalid parameter notifications
with MSVC runtime libraries.
- Copyright (C) 2011-2021 Free Software Foundation, Inc.
+ Copyright (C) 2011-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/netdb.in.h b/lib/netdb.in.h
index eb5c960ba..e05cf4b13 100644
--- a/lib/netdb.in.h
+++ b/lib/netdb.in.h
@@ -1,5 +1,5 @@
/* Provide a netdb.h header file for systems lacking it (read: MinGW).
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
Written by Simon Josefsson.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/netinet_in.in.h b/lib/netinet_in.in.h
index 21f3a64f9..e23807cac 100644
--- a/lib/netinet_in.in.h
+++ b/lib/netinet_in.in.h
@@ -1,5 +1,5 @@
/* Substitute for <netinet/in.h>.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/nl_langinfo-lock.c b/lib/nl_langinfo-lock.c
index fcdf56dc6..c36882d5c 100644
--- a/lib/nl_langinfo-lock.c
+++ b/lib/nl_langinfo-lock.c
@@ -1,5 +1,5 @@
/* Return the internal lock used by nl_langinfo.
- Copyright (C) 2019-2021 Free Software Foundation, Inc.
+ Copyright (C) 2019-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/nl_langinfo.c b/lib/nl_langinfo.c
index b481f209d..3fa478223 100644
--- a/lib/nl_langinfo.c
+++ b/lib/nl_langinfo.c
@@ -1,6 +1,6 @@
/* nl_langinfo() replacement: query locale dependent information.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/nproc.c b/lib/nproc.c
index e3ddb9288..378d3ff3f 100644
--- a/lib/nproc.c
+++ b/lib/nproc.c
@@ -1,6 +1,6 @@
/* Detect the number of processors.
- Copyright (C) 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -307,15 +307,23 @@ num_processors_ignoring_omp (enum nproc_query query)
NPROC_CURRENT and NPROC_ALL. */
#if HAVE_SYSCTL && ! defined __GLIBC__ && defined HW_NCPU
- { /* This works on Mac OS X, FreeBSD, NetBSD, OpenBSD. */
+ { /* This works on macOS, FreeBSD, NetBSD, OpenBSD.
+ macOS 10.14 does not allow mib to be const. */
int nprocs;
size_t len = sizeof (nprocs);
- static int mib[2] = { CTL_HW, HW_NCPU };
-
- if (sysctl (mib, ARRAY_SIZE (mib), &nprocs, &len, NULL, 0) == 0
- && len == sizeof (nprocs)
- && 0 < nprocs)
- return nprocs;
+ static int mib[][2] = {
+# ifdef HW_NCPUONLINE
+ { CTL_HW, HW_NCPUONLINE },
+# endif
+ { CTL_HW, HW_NCPU }
+ };
+ for (int i = 0; i < ARRAY_SIZE (mib); i++)
+ {
+ if (sysctl (mib[i], ARRAY_SIZE (mib[i]), &nprocs, &len, NULL, 0) == 0
+ && len == sizeof (nprocs)
+ && 0 < nprocs)
+ return nprocs;
+ }
}
#endif
diff --git a/lib/nproc.h b/lib/nproc.h
index d7659a5ca..505351d95 100644
--- a/lib/nproc.h
+++ b/lib/nproc.h
@@ -1,6 +1,6 @@
/* Detect the number of processors.
- Copyright (C) 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/nstrftime.c b/lib/nstrftime.c
index 7f258e872..c1dd55424 100644
--- a/lib/nstrftime.c
+++ b/lib/nstrftime.c
@@ -1,9 +1,9 @@
-/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
@@ -22,7 +22,7 @@
# define HAVE_TZNAME 1
# include "../locale/localeinfo.h"
#else
-# include <config.h>
+# include <libc-config.h>
# if FPRINTFTIME
# include "fprintftime.h"
# else
@@ -367,10 +367,7 @@ tm_diff (const struct tm *a, const struct tm *b)
#define ISO_WEEK1_WDAY 4 /* Thursday */
#define YDAY_MINIMUM (-366)
static int iso_week_days (int, int);
-#if defined __GNUC__ || defined __clang__
-__inline__
-#endif
-static int
+static __inline int
iso_week_days (int yday, int wday)
{
/* Add enough to the first operand of % to make it nonnegative. */
@@ -428,9 +425,7 @@ my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, false,
0, -1, &tzset_called extra_args LOCALE_ARG);
}
-#if defined _LIBC && ! FPRINTFTIME
libc_hidden_def (my_strftime)
-#endif
/* Just like my_strftime, above, but with more parameters.
UPCASE indicates that the result should be converted to upper case.
@@ -656,6 +651,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
#endif /* ! DO_MULTIBYTE */
+ char const *percent = f;
+
/* Check for flags that can modify a format. */
while (1)
{
@@ -757,8 +754,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
while (0)
case L_('%'):
- if (modifier != 0)
- goto bad_format;
+ if (f - 1 != percent)
+ goto bad_percent;
add1 (*f);
break;
@@ -1161,7 +1158,6 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
case L_('q'): /* GNU extension. */
DO_SIGNED_NUMBER (1, false, ((tp->tm_mon * 11) >> 5) + 1);
- break;
case L_('R'):
subfmt = L_("%H:%M");
@@ -1472,6 +1468,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
}
case L_('\0'): /* GNU extension: % at end of format. */
+ bad_percent:
--f;
FALLTHROUGH;
default:
@@ -1479,12 +1476,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
since this is most likely the right thing to do if a
multibyte string has been misparsed. */
bad_format:
- {
- int flen;
- for (flen = 1; f[1 - flen] != L_('%'); flen++)
- continue;
- cpy (flen, &f[1 - flen]);
- }
+ cpy (f - percent + 1, percent);
break;
}
}
diff --git a/lib/open.c b/lib/open.c
index 372cda881..170bff108 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -1,5 +1,5 @@
/* Open a descriptor to a file.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/pathmax.h b/lib/pathmax.h
index 716f4a9aa..19b93d7ea 100644
--- a/lib/pathmax.h
+++ b/lib/pathmax.h
@@ -1,5 +1,5 @@
/* Define PATH_MAX somehow. Requires sys/types.h.
- Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2021 Free Software
+ Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/pipe.c b/lib/pipe.c
index fc978f2eb..ce909b9f0 100644
--- a/lib/pipe.c
+++ b/lib/pipe.c
@@ -1,5 +1,5 @@
/* Create a pipe.
- Copyright (C) 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/pipe2.c b/lib/pipe2.c
index 9ba8c3b70..400aff001 100644
--- a/lib/pipe2.c
+++ b/lib/pipe2.c
@@ -1,5 +1,5 @@
/* Create a pipe, with specific opening flags.
- Copyright (C) 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/poll.c b/lib/poll.c
index 8d5ba9655..9cfde5f81 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -1,7 +1,7 @@
/* Emulation for poll(2)
Contributed by Paolo Bonzini.
- Copyright 2001-2003, 2006-2021 Free Software Foundation, Inc.
+ Copyright 2001-2003, 2006-2022 Free Software Foundation, Inc.
This file is part of gnulib.
diff --git a/lib/poll.in.h b/lib/poll.in.h
index e94cd31de..1af6a232f 100644
--- a/lib/poll.in.h
+++ b/lib/poll.in.h
@@ -1,7 +1,7 @@
/* Header for poll(2) emulation
Contributed by Paolo Bonzini.
- Copyright 2001-2003, 2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright 2001-2003, 2007, 2009-2022 Free Software Foundation, Inc.
This file is part of gnulib.
diff --git a/lib/printf-args.c b/lib/printf-args.c
index b822682c3..669c24a40 100644
--- a/lib/printf-args.c
+++ b/lib/printf-args.c
@@ -1,5 +1,5 @@
/* Decomposed printf argument list.
- Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2021 Free Software
+ Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/printf-args.h b/lib/printf-args.h
index c8d91747b..553fe9619 100644
--- a/lib/printf-args.h
+++ b/lib/printf-args.h
@@ -1,5 +1,5 @@
/* Decomposed printf argument list.
- Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2021 Free Software
+ Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/printf-parse.c b/lib/printf-parse.c
index f21cc17c0..aab02dc5b 100644
--- a/lib/printf-parse.c
+++ b/lib/printf-parse.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 1999-2000, 2002-2003, 2006-2021 Free Software Foundation, Inc.
+ Copyright (C) 1999-2000, 2002-2003, 2006-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/printf-parse.h b/lib/printf-parse.h
index 77b74093c..b12ccea3c 100644
--- a/lib/printf-parse.h
+++ b/lib/printf-parse.h
@@ -1,5 +1,5 @@
/* Parse printf format string.
- Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2021 Free Software
+ Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/putenv.c b/lib/putenv.c
index 435d10fdc..b0d27e2f6 100644
--- a/lib/putenv.c
+++ b/lib/putenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2021 Free Software
+/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2022 Free Software
Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C
@@ -6,7 +6,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/raise.c b/lib/raise.c
index 37c100dd8..385ddd384 100644
--- a/lib/raise.c
+++ b/lib/raise.c
@@ -1,6 +1,6 @@
/* Provide a non-threads replacement for the POSIX raise function.
- Copyright (C) 2002-2003, 2005-2006, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2006, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/rawmemchr.c b/lib/rawmemchr.c
index 896d435af..ea68c1bfc 100644
--- a/lib/rawmemchr.c
+++ b/lib/rawmemchr.c
@@ -1,5 +1,5 @@
/* Searching in a string.
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -22,68 +22,54 @@
/* A function definition is only needed if HAVE_RAWMEMCHR is not defined. */
#if !HAVE_RAWMEMCHR
+# include <limits.h>
+# include <stdalign.h>
+# include <stdint.h>
+
+# include "verify.h"
+
/* Find the first occurrence of C in S. */
void *
rawmemchr (const void *s, int c_in)
{
- /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
- long instead of a 64-bit uintmax_t tends to give better
- performance. On 64-bit hardware, unsigned long is generally 64
- bits already. Change this typedef to experiment with
- performance. */
- typedef unsigned long int longword;
+ /* Change this typedef to experiment with performance. */
+ typedef uintptr_t longword;
+ /* If you change the "uintptr_t", you should change UINTPTR_WIDTH to match.
+ This verifies that the type does not have padding bits. */
+ verify (UINTPTR_WIDTH == UCHAR_WIDTH * sizeof (longword));
const unsigned char *char_ptr;
- const longword *longword_ptr;
- longword repeated_one;
- longword repeated_c;
- unsigned char c;
-
- c = (unsigned char) c_in;
+ unsigned char c = c_in;
/* Handle the first few bytes by reading one byte at a time.
Do this until CHAR_PTR is aligned on a longword boundary. */
for (char_ptr = (const unsigned char *) s;
- (size_t) char_ptr % sizeof (longword) != 0;
+ (uintptr_t) char_ptr % alignof (longword) != 0;
++char_ptr)
if (*char_ptr == c)
return (void *) char_ptr;
- longword_ptr = (const longword *) char_ptr;
-
- /* All these elucidatory comments refer to 4-byte longwords,
- but the theory applies equally well to any size longwords. */
+ longword const *longword_ptr = s = char_ptr;
/* Compute auxiliary longword values:
repeated_one is a value which has a 1 in every byte.
repeated_c has c in every byte. */
- repeated_one = 0x01010101;
- repeated_c = c | (c << 8);
- repeated_c |= repeated_c << 16;
- if (0xffffffffU < (longword) -1)
- {
- repeated_one |= repeated_one << 31 << 1;
- repeated_c |= repeated_c << 31 << 1;
- if (8 < sizeof (longword))
- {
- size_t i;
-
- for (i = 64; i < sizeof (longword) * 8; i *= 2)
- {
- repeated_one |= repeated_one << i;
- repeated_c |= repeated_c << i;
- }
- }
- }
+ longword repeated_one = (longword) -1 / UCHAR_MAX;
+ longword repeated_c = repeated_one * c;
+ longword repeated_hibit = repeated_one * (UCHAR_MAX / 2 + 1);
/* Instead of the traditional loop which tests each byte, we will
- test a longword at a time. The tricky part is testing if *any of
- the four* bytes in the longword in question are equal to NUL or
+ test a longword at a time. The tricky part is testing if any of
+ the bytes in the longword in question are equal to
c. We first use an xor with repeated_c. This reduces the task
- to testing whether *any of the four* bytes in longword1 is zero.
+ to testing whether any of the bytes in longword1 is zero.
+
+ (The following comments assume 8-bit bytes, as POSIX requires;
+ the code's use of UCHAR_MAX should work even if bytes have more
+ than 8 bits.)
We compute tmp =
- ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
+ ((longword1 - repeated_one) & ~longword1) & (repeated_one * 0x80).
That is, we perform the following operations:
1. Subtract repeated_one.
2. & ~longword1.
@@ -117,22 +103,20 @@ rawmemchr (const void *s, int c_in)
{
longword longword1 = *longword_ptr ^ repeated_c;
- if ((((longword1 - repeated_one) & ~longword1)
- & (repeated_one << 7)) != 0)
+ if ((((longword1 - repeated_one) & ~longword1) & repeated_hibit) != 0)
break;
longword_ptr++;
}
- char_ptr = (const unsigned char *) longword_ptr;
+ char_ptr = s = longword_ptr;
/* At this point, we know that one of the sizeof (longword) bytes
- starting at char_ptr is == c. On little-endian machines, we
+ starting at char_ptr is == c. If we knew endianness, we
could determine the first such byte without any further memory
accesses, just by looking at the tmp result from the last loop
- iteration. But this does not work on big-endian machines.
- Choose code that works in both cases. */
+ iteration. However, the following simple and portable code does
+ not attempt this potential optimization. */
- char_ptr = (unsigned char *) longword_ptr;
while (*char_ptr != c)
char_ptr++;
return (void *) char_ptr;
diff --git a/lib/rawmemchr.valgrind b/lib/rawmemchr.valgrind
index d489c320c..64cf86c84 100644
--- a/lib/rawmemchr.valgrind
+++ b/lib/rawmemchr.valgrind
@@ -1,6 +1,6 @@
# Suppress a valgrind message about use of uninitialized memory in rawmemchr().
-# Copyright (C) 2008-2021 Free Software Foundation, Inc.
+# Copyright (C) 2008-2022 Free Software Foundation, Inc.
#
# This file is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
diff --git a/lib/read.c b/lib/read.c
index 840d9ed5a..1bb7d90ce 100644
--- a/lib/read.c
+++ b/lib/read.c
@@ -1,5 +1,5 @@
/* POSIX compatible read() function.
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/readlink.c b/lib/readlink.c
index d4f4b08e9..ed03cc8de 100644
--- a/lib/readlink.c
+++ b/lib/readlink.c
@@ -1,5 +1,5 @@
/* Read the contents of a symbolic link.
- Copyright (C) 2003-2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2003-2007, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -29,8 +29,8 @@
such as DJGPP 2.03 and mingw32. */
ssize_t
-readlink (char const *file, char *buf _GL_UNUSED,
- size_t bufsize _GL_UNUSED)
+readlink (char const *file, _GL_UNUSED char *buf,
+ _GL_UNUSED size_t bufsize)
{
struct stat statbuf;
diff --git a/lib/realloc.c b/lib/realloc.c
index af03f0c57..c87838157 100644
--- a/lib/realloc.c
+++ b/lib/realloc.c
@@ -1,6 +1,6 @@
/* realloc() function that is glibc compatible.
- Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2021 Free Software
+ Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/recv.c b/lib/recv.c
index 3eb2b4d4b..4910731ed 100644
--- a/lib/recv.c
+++ b/lib/recv.c
@@ -1,6 +1,6 @@
/* recv.c --- wrappers for Windows recv function
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/recvfrom.c b/lib/recvfrom.c
index 25231ffe1..3c9f5b21d 100644
--- a/lib/recvfrom.c
+++ b/lib/recvfrom.c
@@ -1,6 +1,6 @@
/* recvfrom.c --- wrappers for Windows recvfrom function
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 887e5b506..122c3de58 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -27,14 +27,10 @@ static void re_compile_fastmap_iter (regex_t *bufp,
const re_dfastate_t *init_state,
char *fastmap);
static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len);
-#ifdef RE_ENABLE_I18N
static void free_charset (re_charset_t *cset);
-#endif /* RE_ENABLE_I18N */
static void free_workarea_compile (regex_t *preg);
static reg_errcode_t create_initial_state (re_dfa_t *dfa);
-#ifdef RE_ENABLE_I18N
static void optimize_utf8 (re_dfa_t *dfa);
-#endif
static reg_errcode_t analyze (regex_t *preg);
static reg_errcode_t preorder (bin_tree_t *root,
reg_errcode_t (fn (void *, bin_tree_t *)),
@@ -89,7 +85,6 @@ static reg_errcode_t parse_bracket_element (bracket_elem_t *elem,
static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem,
re_string_t *regexp,
re_token_t *token);
-#ifdef RE_ENABLE_I18N
static reg_errcode_t build_equiv_class (bitset_t sbcset,
re_charset_t *mbcset,
Idx *equiv_class_alloc,
@@ -100,14 +95,6 @@ static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
Idx *char_class_alloc,
const char *class_name,
reg_syntax_t syntax);
-#else /* not RE_ENABLE_I18N */
-static reg_errcode_t build_equiv_class (bitset_t sbcset,
- const unsigned char *name);
-static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
- bitset_t sbcset,
- const char *class_name,
- reg_syntax_t syntax);
-#endif /* not RE_ENABLE_I18N */
static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
RE_TRANSLATE_TYPE trans,
const char *class_name,
@@ -279,8 +266,7 @@ re_compile_fastmap (struct re_pattern_buffer *bufp)
}
weak_alias (__re_compile_fastmap, re_compile_fastmap)
-static inline void
-__attribute__ ((always_inline))
+static __always_inline void
re_set_fastmap (char *fastmap, bool icase, int ch)
{
fastmap[ch] = 1;
@@ -306,7 +292,6 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
if (type == CHARACTER)
{
re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
-#ifdef RE_ENABLE_I18N
if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
{
unsigned char buf[MB_LEN_MAX];
@@ -327,7 +312,6 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
!= (size_t) -1))
re_set_fastmap (fastmap, false, buf[0]);
}
-#endif
}
else if (type == SIMPLE_BRACKET)
{
@@ -341,13 +325,12 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
re_set_fastmap (fastmap, icase, ch);
}
}
-#ifdef RE_ENABLE_I18N
else if (type == COMPLEX_BRACKET)
{
re_charset_t *cset = dfa->nodes[node].opr.mbcset;
Idx i;
-# ifdef _LIBC
+#ifdef _LIBC
/* See if we have to try all bytes which start multiple collation
elements.
e.g. In da_DK, we want to catch 'a' since "aa" is a valid
@@ -363,7 +346,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
if (table[i] < 0)
re_set_fastmap (fastmap, icase, i);
}
-# endif /* _LIBC */
+#endif /* _LIBC */
/* See if we have to start the match at all multibyte characters,
i.e. where we would not find an invalid sequence. This only
@@ -371,9 +354,9 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
sets, the SIMPLE_BRACKET again suffices. */
if (dfa->mb_cur_max > 1
&& (cset->nchar_classes || cset->non_match || cset->nranges
-# ifdef _LIBC
+#ifdef _LIBC
|| cset->nequiv_classes
-# endif /* _LIBC */
+#endif /* _LIBC */
))
{
unsigned char c = 0;
@@ -406,12 +389,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
}
}
}
-#endif /* RE_ENABLE_I18N */
- else if (type == OP_PERIOD
-#ifdef RE_ENABLE_I18N
- || type == OP_UTF8_PERIOD
-#endif /* RE_ENABLE_I18N */
- || type == END_OF_RE)
+ else if (type == OP_PERIOD || type == OP_UTF8_PERIOD || type == END_OF_RE)
{
memset (fastmap, '\1', sizeof (char) * SBC_MAX);
if (type == END_OF_RE)
@@ -550,7 +528,6 @@ regerror (int errcode, const regex_t *__restrict preg, char *__restrict errbuf,
weak_alias (__regerror, regerror)
-#ifdef RE_ENABLE_I18N
/* This static array is used for the map to single-byte characters when
UTF-8 is used. Otherwise we would allocate memory just to initialize
it the same all the time. UTF-8 is the preferred encoding so this is
@@ -558,25 +535,24 @@ weak_alias (__regerror, regerror)
static const bitset_t utf8_sb_map =
{
/* Set the first 128 bits. */
-# if (defined __GNUC__ || __clang_major__ >= 4) && !defined __STRICT_ANSI__
+#if (defined __GNUC__ || __clang_major__ >= 4) && !defined __STRICT_ANSI__
[0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX
-# else
-# if 4 * BITSET_WORD_BITS < ASCII_CHARS
-# error "bitset_word_t is narrower than 32 bits"
-# elif 3 * BITSET_WORD_BITS < ASCII_CHARS
+#else
+# if 4 * BITSET_WORD_BITS < ASCII_CHARS
+# error "bitset_word_t is narrower than 32 bits"
+# elif 3 * BITSET_WORD_BITS < ASCII_CHARS
BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX,
-# elif 2 * BITSET_WORD_BITS < ASCII_CHARS
+# elif 2 * BITSET_WORD_BITS < ASCII_CHARS
BITSET_WORD_MAX, BITSET_WORD_MAX,
-# elif 1 * BITSET_WORD_BITS < ASCII_CHARS
+# elif 1 * BITSET_WORD_BITS < ASCII_CHARS
BITSET_WORD_MAX,
-# endif
+# endif
(BITSET_WORD_MAX
>> (SBC_MAX % BITSET_WORD_BITS == 0
? 0
: BITSET_WORD_BITS - SBC_MAX % BITSET_WORD_BITS))
-# endif
-};
#endif
+};
static void
@@ -614,10 +590,8 @@ free_dfa_content (re_dfa_t *dfa)
re_free (entry->array);
}
re_free (dfa->state_table);
-#ifdef RE_ENABLE_I18N
if (dfa->sb_char != utf8_sb_map)
re_free (dfa->sb_char);
-#endif
re_free (dfa->subexp_map);
#ifdef DEBUG
re_free (dfa->re_str);
@@ -796,11 +770,9 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
if (__glibc_unlikely (err != REG_NOERROR))
goto re_compile_internal_free_return;
-#ifdef RE_ENABLE_I18N
/* If possible, do searching in single byte encoding to speed things up. */
if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL)
optimize_utf8 (dfa);
-#endif
/* Then create the initial state of the dfa. */
err = create_initial_state (dfa);
@@ -830,11 +802,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
#ifndef _LIBC
const char *codeset_name;
#endif
-#ifdef RE_ENABLE_I18N
size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t));
-#else
- size_t max_i18n_object_size = 0;
-#endif
size_t max_object_size =
MAX (sizeof (struct re_state_table_entry),
MAX (sizeof (re_token_t),
@@ -886,7 +854,6 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
dfa->map_notascii = 0;
#endif
-#ifdef RE_ENABLE_I18N
if (dfa->mb_cur_max > 1)
{
if (dfa->is_utf8)
@@ -906,14 +873,13 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
wint_t wch = __btowc (ch);
if (wch != WEOF)
dfa->sb_char[i] |= (bitset_word_t) 1 << j;
-# ifndef _LIBC
+#ifndef _LIBC
if (isascii (ch) && wch != ch)
dfa->map_notascii = 1;
-# endif
+#endif
}
}
}
-#endif
if (__glibc_unlikely (dfa->nodes == NULL || dfa->state_table == NULL))
return REG_ESPACE;
@@ -933,8 +899,6 @@ init_word_char (re_dfa_t *dfa)
dfa->word_ops_used = 1;
if (__glibc_likely (dfa->map_notascii == 0))
{
- /* Avoid uint32_t and uint64_t as some non-GCC platforms lack
- them, an issue when this code is used in Gnulib. */
bitset_word_t bits0 = 0x00000000;
bitset_word_t bits1 = 0x03ff0000;
bitset_word_t bits2 = 0x87fffffe;
@@ -1074,7 +1038,6 @@ create_initial_state (re_dfa_t *dfa)
return REG_NOERROR;
}
-#ifdef RE_ENABLE_I18N
/* If it is possible to do searching in single byte encoding instead of UTF-8
to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change
DFA nodes where needed. */
@@ -1154,7 +1117,6 @@ optimize_utf8 (re_dfa_t *dfa)
dfa->is_utf8 = 0;
dfa->has_mb_node = dfa->nbackref > 0 || has_period;
}
-#endif
/* Analyze the structure tree, and calculate "first", "next", "edest",
"eclosure", and "inveclosure". */
@@ -1792,7 +1754,6 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
token->opr.c = c;
token->word_char = 0;
-#ifdef RE_ENABLE_I18N
token->mb_partial = 0;
if (input->mb_cur_max > 1
&& !re_string_first_byte (input, re_string_cur_idx (input)))
@@ -1801,7 +1762,6 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
token->mb_partial = 1;
return 1;
}
-#endif
if (c == '\\')
{
unsigned char c2;
@@ -1814,7 +1774,6 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
c2 = re_string_peek_byte_case (input, 1);
token->opr.c = c2;
token->type = CHARACTER;
-#ifdef RE_ENABLE_I18N
if (input->mb_cur_max > 1)
{
wint_t wc = re_string_wchar_at (input,
@@ -1822,7 +1781,6 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
}
else
-#endif
token->word_char = IS_WORD_CHAR (c2) != 0;
switch (c2)
@@ -1928,14 +1886,12 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
}
token->type = CHARACTER;
-#ifdef RE_ENABLE_I18N
if (input->mb_cur_max > 1)
{
wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input));
token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
}
else
-#endif
token->word_char = IS_WORD_CHAR (token->opr.c);
switch (c)
@@ -2027,14 +1983,12 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
c = re_string_peek_byte (input, 0);
token->opr.c = c;
-#ifdef RE_ENABLE_I18N
if (input->mb_cur_max > 1
&& !re_string_first_byte (input, re_string_cur_idx (input)))
{
token->type = CHARACTER;
return 1;
}
-#endif /* RE_ENABLE_I18N */
if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS)
&& re_string_cur_idx (input) + 1 < re_string_length (input))
@@ -2084,15 +2038,25 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
}
switch (c)
{
- case '-':
- token->type = OP_CHARSET_RANGE;
- break;
case ']':
token->type = OP_CLOSE_BRACKET;
break;
case '^':
token->type = OP_NON_MATCH_LIST;
break;
+ case '-':
+ /* In V7 Unix grep and Unix awk and mawk, [...---...]
+ (3 adjacent minus signs) stands for a single minus sign.
+ Support that without breaking anything else. */
+ if (! (re_string_cur_idx (input) + 2 < re_string_length (input)
+ && re_string_peek_byte (input, 1) == '-'
+ && re_string_peek_byte (input, 2) == '-'))
+ {
+ token->type = OP_CHARSET_RANGE;
+ break;
+ }
+ re_string_skip_bytes (input, 2);
+ FALLTHROUGH;
default:
token->type = CHARACTER;
}
@@ -2256,7 +2220,6 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
*err = REG_ESPACE;
return NULL;
}
-#ifdef RE_ENABLE_I18N
if (dfa->mb_cur_max > 1)
{
while (!re_string_eoi (regexp)
@@ -2273,7 +2236,6 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
}
}
}
-#endif
break;
case OP_OPEN_SUBEXP:
@@ -2666,40 +2628,30 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
#ifndef _LIBC
-# ifdef RE_ENABLE_I18N
/* Convert the byte B to the corresponding wide character. In a
unibyte locale, treat B as itself. In a multibyte locale, return
WEOF if B is an encoding error. */
static wint_t
-parse_byte (unsigned char b, re_charset_t *mbcset)
+parse_byte (unsigned char b, re_dfa_t const *dfa)
{
- return mbcset == NULL ? b : __btowc (b);
+ return dfa->mb_cur_max > 1 ? __btowc (b) : b;
}
-# endif
- /* Local function for parse_bracket_exp only used in case of NOT _LIBC.
- Build the range expression which starts from START_ELEM, and ends
- at END_ELEM. The result are written to MBCSET and SBCSET.
- RANGE_ALLOC is the allocated size of mbcset->range_starts, and
- mbcset->range_ends, is a pointer argument since we may
- update it. */
+/* Local function for parse_bracket_exp used in _LIBC environment.
+ Build the range expression which starts from START_ELEM, and ends
+ at END_ELEM. The result are written to MBCSET and SBCSET.
+ RANGE_ALLOC is the allocated size of mbcset->range_starts, and
+ mbcset->range_ends, is a pointer argument since we may
+ update it. */
static reg_errcode_t
-# ifdef RE_ENABLE_I18N
-build_range_exp (const reg_syntax_t syntax,
- bitset_t sbcset,
- re_charset_t *mbcset,
- Idx *range_alloc,
- const bracket_elem_t *start_elem,
- const bracket_elem_t *end_elem)
-# else /* not RE_ENABLE_I18N */
-build_range_exp (const reg_syntax_t syntax,
- bitset_t sbcset,
- const bracket_elem_t *start_elem,
- const bracket_elem_t *end_elem)
-# endif /* not RE_ENABLE_I18N */
+build_range_exp (bitset_t sbcset, re_charset_t *mbcset, Idx *range_alloc,
+ bracket_elem_t *start_elem, bracket_elem_t *end_elem,
+ re_dfa_t *dfa, reg_syntax_t syntax, uint_fast32_t nrules,
+ const unsigned char *collseqmb, const char *collseqwc,
+ int_fast32_t table_size, const void *symb_table,
+ const unsigned char *extra)
{
- unsigned int start_ch, end_ch;
/* Equivalence Classes and Character Classes can't be a range start/end. */
if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
|| start_elem->type == CHAR_CLASS
@@ -2715,110 +2667,88 @@ build_range_exp (const reg_syntax_t syntax,
&& strlen ((char *) end_elem->opr.name) > 1)))
return REG_ECOLLATE;
-# ifdef RE_ENABLE_I18N
- {
- wchar_t wc;
- wint_t start_wc;
- wint_t end_wc;
-
+ unsigned int
start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch
: ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
- : 0));
+ : 0)),
end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch
: ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
: 0));
+ wint_t
start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM)
- ? parse_byte (start_ch, mbcset) : start_elem->opr.wch);
+ ? parse_byte (start_ch, dfa) : start_elem->opr.wch),
end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM)
- ? parse_byte (end_ch, mbcset) : end_elem->opr.wch);
- if (start_wc == WEOF || end_wc == WEOF)
- return REG_ECOLLATE;
- else if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
- && start_wc > end_wc))
- return REG_ERANGE;
-
- /* Got valid collation sequence values, add them as a new entry.
- However, for !_LIBC we have no collation elements: if the
- character set is single byte, the single byte character set
- that we build below suffices. parse_bracket_exp passes
- no MBCSET if dfa->mb_cur_max == 1. */
- if (mbcset)
- {
- /* Check the space of the arrays. */
- if (__glibc_unlikely (*range_alloc == mbcset->nranges))
- {
- /* There is not enough space, need realloc. */
- wchar_t *new_array_start, *new_array_end;
- Idx new_nranges;
-
- /* +1 in case of mbcset->nranges is 0. */
- new_nranges = 2 * mbcset->nranges + 1;
- /* Use realloc since mbcset->range_starts and mbcset->range_ends
- are NULL if *range_alloc == 0. */
- new_array_start = re_realloc (mbcset->range_starts, wchar_t,
- new_nranges);
- new_array_end = re_realloc (mbcset->range_ends, wchar_t,
- new_nranges);
+ ? parse_byte (end_ch, dfa) : end_elem->opr.wch);
- if (__glibc_unlikely (new_array_start == NULL
- || new_array_end == NULL))
- {
- re_free (new_array_start);
- re_free (new_array_end);
- return REG_ESPACE;
- }
+ if (start_wc == WEOF || end_wc == WEOF)
+ return REG_ECOLLATE;
+ else if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
+ && start_wc > end_wc))
+ return REG_ERANGE;
- mbcset->range_starts = new_array_start;
- mbcset->range_ends = new_array_end;
- *range_alloc = new_nranges;
- }
+ /* Got valid collation sequence values, add them as a new entry.
+ However, for !_LIBC we have no collation elements: if the
+ character set is single byte, the single byte character set
+ that we build below suffices. parse_bracket_exp passes
+ no MBCSET if dfa->mb_cur_max == 1. */
+ if (dfa->mb_cur_max > 1)
+ {
+ /* Check the space of the arrays. */
+ if (__glibc_unlikely (*range_alloc == mbcset->nranges))
+ {
+ /* There is not enough space, need realloc. */
+ wchar_t *new_array_start, *new_array_end;
+ Idx new_nranges;
- mbcset->range_starts[mbcset->nranges] = start_wc;
- mbcset->range_ends[mbcset->nranges++] = end_wc;
- }
+ /* +1 in case of mbcset->nranges is 0. */
+ new_nranges = 2 * mbcset->nranges + 1;
+ /* Use realloc since mbcset->range_starts and mbcset->range_ends
+ are NULL if *range_alloc == 0. */
+ new_array_start = re_realloc (mbcset->range_starts, wchar_t,
+ new_nranges);
+ new_array_end = re_realloc (mbcset->range_ends, wchar_t,
+ new_nranges);
+
+ if (__glibc_unlikely (new_array_start == NULL
+ || new_array_end == NULL))
+ {
+ re_free (new_array_start);
+ re_free (new_array_end);
+ return REG_ESPACE;
+ }
+
+ mbcset->range_starts = new_array_start;
+ mbcset->range_ends = new_array_end;
+ *range_alloc = new_nranges;
+ }
+
+ mbcset->range_starts[mbcset->nranges] = start_wc;
+ mbcset->range_ends[mbcset->nranges++] = end_wc;
+ }
+
+ /* Build the table for single byte characters. */
+ for (wchar_t wc = 0; wc < SBC_MAX; ++wc)
+ {
+ if (start_wc <= wc && wc <= end_wc)
+ bitset_set (sbcset, wc);
+ }
- /* Build the table for single byte characters. */
- for (wc = 0; wc < SBC_MAX; ++wc)
- {
- if (start_wc <= wc && wc <= end_wc)
- bitset_set (sbcset, wc);
- }
- }
-# else /* not RE_ENABLE_I18N */
- {
- unsigned int ch;
- start_ch = ((start_elem->type == SB_CHAR ) ? start_elem->opr.ch
- : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
- : 0));
- end_ch = ((end_elem->type == SB_CHAR ) ? end_elem->opr.ch
- : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
- : 0));
- if (start_ch > end_ch)
- return REG_ERANGE;
- /* Build the table for single byte characters. */
- for (ch = 0; ch < SBC_MAX; ++ch)
- if (start_ch <= ch && ch <= end_ch)
- bitset_set (sbcset, ch);
- }
-# endif /* not RE_ENABLE_I18N */
return REG_NOERROR;
}
#endif /* not _LIBC */
#ifndef _LIBC
-/* Helper function for parse_bracket_exp only used in case of NOT _LIBC..
+/* Helper function for parse_bracket_exp only used in case of NOT _LIBC.
Build the collating element which is represented by NAME.
The result are written to MBCSET and SBCSET.
COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
pointer argument since we may update it. */
static reg_errcode_t
-# ifdef RE_ENABLE_I18N
build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
- Idx *coll_sym_alloc, const unsigned char *name)
-# else /* not RE_ENABLE_I18N */
-build_collating_symbol (bitset_t sbcset, const unsigned char *name)
-# endif /* not RE_ENABLE_I18N */
+ Idx *coll_sym_alloc, const unsigned char *name,
+ uint_fast32_t nrules, int_fast32_t table_size,
+ const void *symb_table, const unsigned char *extra)
{
size_t name_len = strlen ((const char *) name);
if (__glibc_unlikely (name_len != 1))
@@ -2831,271 +2761,280 @@ build_collating_symbol (bitset_t sbcset, const unsigned char *name)
}
#endif /* not _LIBC */
-/* This function parse bracket expression like "[abc]", "[a-c]",
- "[[.a-a.]]" etc. */
-
-static bin_tree_t *
-parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
- reg_syntax_t syntax, reg_errcode_t *err)
-{
#ifdef _LIBC
- const unsigned char *collseqmb;
- const char *collseqwc;
- uint32_t nrules;
- int32_t table_size;
- const int32_t *symb_table;
- const unsigned char *extra;
-
- /* Local function for parse_bracket_exp used in _LIBC environment.
- Seek the collating symbol entry corresponding to NAME.
- Return the index of the symbol in the SYMB_TABLE,
- or -1 if not found. */
-
- auto inline int32_t
- __attribute__ ((always_inline))
- seek_collating_symbol_entry (const unsigned char *name, size_t name_len)
- {
- int32_t elem;
-
- for (elem = 0; elem < table_size; elem++)
- if (symb_table[2 * elem] != 0)
- {
- int32_t idx = symb_table[2 * elem + 1];
- /* Skip the name of collating element name. */
- idx += 1 + extra[idx];
- if (/* Compare the length of the name. */
- name_len == extra[idx]
- /* Compare the name. */
- && memcmp (name, &extra[idx + 1], name_len) == 0)
- /* Yep, this is the entry. */
- return elem;
- }
- return -1;
- }
+/* Local function for parse_bracket_exp used in _LIBC environment.
+ Seek the collating symbol entry corresponding to NAME.
+ Return the index of the symbol in the SYMB_TABLE,
+ or -1 if not found. */
+
+static __always_inline int32_t
+seek_collating_symbol_entry (const unsigned char *name, size_t name_len,
+ const int32_t *symb_table,
+ int_fast32_t table_size,
+ const unsigned char *extra)
+{
+ int_fast32_t elem;
- /* Local function for parse_bracket_exp used in _LIBC environment.
- Look up the collation sequence value of BR_ELEM.
- Return the value if succeeded, UINT_MAX otherwise. */
+ for (elem = 0; elem < table_size; elem++)
+ if (symb_table[2 * elem] != 0)
+ {
+ int32_t idx = symb_table[2 * elem + 1];
+ /* Skip the name of collating element name. */
+ idx += 1 + extra[idx];
+ if (/* Compare the length of the name. */
+ name_len == extra[idx]
+ /* Compare the name. */
+ && memcmp (name, &extra[idx + 1], name_len) == 0)
+ /* Yep, this is the entry. */
+ return elem;
+ }
+ return -1;
+}
- auto inline unsigned int
- __attribute__ ((always_inline))
- lookup_collation_sequence_value (bracket_elem_t *br_elem)
+/* Local function for parse_bracket_exp used in _LIBC environment.
+ Look up the collation sequence value of BR_ELEM.
+ Return the value if succeeded, UINT_MAX otherwise. */
+
+static __always_inline unsigned int
+lookup_collation_sequence_value (bracket_elem_t *br_elem, uint32_t nrules,
+ const unsigned char *collseqmb,
+ const char *collseqwc,
+ int_fast32_t table_size,
+ const int32_t *symb_table,
+ const unsigned char *extra)
+{
+ if (br_elem->type == SB_CHAR)
{
- if (br_elem->type == SB_CHAR)
- {
- /*
- if (MB_CUR_MAX == 1)
- */
- if (nrules == 0)
- return collseqmb[br_elem->opr.ch];
- else
- {
- wint_t wc = __btowc (br_elem->opr.ch);
- return __collseq_table_lookup (collseqwc, wc);
- }
- }
- else if (br_elem->type == MB_CHAR)
+ /* if (MB_CUR_MAX == 1) */
+ if (nrules == 0)
+ return collseqmb[br_elem->opr.ch];
+ else
{
- if (nrules != 0)
- return __collseq_table_lookup (collseqwc, br_elem->opr.wch);
+ wint_t wc = __btowc (br_elem->opr.ch);
+ return __collseq_table_lookup (collseqwc, wc);
}
- else if (br_elem->type == COLL_SYM)
+ }
+ else if (br_elem->type == MB_CHAR)
+ {
+ if (nrules != 0)
+ return __collseq_table_lookup (collseqwc, br_elem->opr.wch);
+ }
+ else if (br_elem->type == COLL_SYM)
+ {
+ size_t sym_name_len = strlen ((char *) br_elem->opr.name);
+ if (nrules != 0)
{
- size_t sym_name_len = strlen ((char *) br_elem->opr.name);
- if (nrules != 0)
+ int32_t elem, idx;
+ elem = seek_collating_symbol_entry (br_elem->opr.name,
+ sym_name_len,
+ symb_table, table_size,
+ extra);
+ if (elem != -1)
{
- int32_t elem, idx;
- elem = seek_collating_symbol_entry (br_elem->opr.name,
- sym_name_len);
- if (elem != -1)
- {
- /* We found the entry. */
- idx = symb_table[2 * elem + 1];
- /* Skip the name of collating element name. */
- idx += 1 + extra[idx];
- /* Skip the byte sequence of the collating element. */
- idx += 1 + extra[idx];
- /* Adjust for the alignment. */
- idx = (idx + 3) & ~3;
- /* Skip the multibyte collation sequence value. */
- idx += sizeof (unsigned int);
- /* Skip the wide char sequence of the collating element. */
- idx += sizeof (unsigned int) *
- (1 + *(unsigned int *) (extra + idx));
- /* Return the collation sequence value. */
- return *(unsigned int *) (extra + idx);
- }
- else if (sym_name_len == 1)
- {
- /* No valid character. Match it as a single byte
- character. */
- return collseqmb[br_elem->opr.name[0]];
- }
+ /* We found the entry. */
+ idx = symb_table[2 * elem + 1];
+ /* Skip the name of collating element name. */
+ idx += 1 + extra[idx];
+ /* Skip the byte sequence of the collating element. */
+ idx += 1 + extra[idx];
+ /* Adjust for the alignment. */
+ idx = (idx + 3) & ~3;
+ /* Skip the multibyte collation sequence value. */
+ idx += sizeof (unsigned int);
+ /* Skip the wide char sequence of the collating element. */
+ idx += sizeof (unsigned int) *
+ (1 + *(unsigned int *) (extra + idx));
+ /* Return the collation sequence value. */
+ return *(unsigned int *) (extra + idx);
}
else if (sym_name_len == 1)
- return collseqmb[br_elem->opr.name[0]];
+ {
+ /* No valid character. Match it as a single byte
+ character. */
+ return collseqmb[br_elem->opr.name[0]];
+ }
}
- return UINT_MAX;
+ else if (sym_name_len == 1)
+ return collseqmb[br_elem->opr.name[0]];
}
+ return UINT_MAX;
+}
- /* Local function for parse_bracket_exp used in _LIBC environment.
- Build the range expression which starts from START_ELEM, and ends
- at END_ELEM. The result are written to MBCSET and SBCSET.
- RANGE_ALLOC is the allocated size of mbcset->range_starts, and
- mbcset->range_ends, is a pointer argument since we may
- update it. */
+/* Local function for parse_bracket_exp used in _LIBC environment.
+ Build the range expression which starts from START_ELEM, and ends
+ at END_ELEM. The result are written to MBCSET and SBCSET.
+ RANGE_ALLOC is the allocated size of mbcset->range_starts, and
+ mbcset->range_ends, is a pointer argument since we may
+ update it. */
+
+static __always_inline reg_errcode_t
+build_range_exp (bitset_t sbcset, re_charset_t *mbcset, Idx *range_alloc,
+ bracket_elem_t *start_elem, bracket_elem_t *end_elem,
+ re_dfa_t *dfa, reg_syntax_t syntax, uint32_t nrules,
+ const unsigned char *collseqmb, const char *collseqwc,
+ int_fast32_t table_size, const int32_t *symb_table,
+ const unsigned char *extra)
+{
+ unsigned int ch;
+ uint32_t start_collseq;
+ uint32_t end_collseq;
- auto inline reg_errcode_t
- __attribute__ ((always_inline))
- build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc,
- bracket_elem_t *start_elem, bracket_elem_t *end_elem)
- {
- unsigned int ch;
- uint32_t start_collseq;
- uint32_t end_collseq;
-
- /* Equivalence Classes and Character Classes can't be a range
- start/end. */
- if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
- || start_elem->type == CHAR_CLASS
- || end_elem->type == EQUIV_CLASS
- || end_elem->type == CHAR_CLASS))
- return REG_ERANGE;
+ /* Equivalence Classes and Character Classes can't be a range
+ start/end. */
+ if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
+ || start_elem->type == CHAR_CLASS
+ || end_elem->type == EQUIV_CLASS
+ || end_elem->type == CHAR_CLASS))
+ return REG_ERANGE;
- /* FIXME: Implement rational ranges here, too. */
- start_collseq = lookup_collation_sequence_value (start_elem);
- end_collseq = lookup_collation_sequence_value (end_elem);
- /* Check start/end collation sequence values. */
- if (__glibc_unlikely (start_collseq == UINT_MAX
- || end_collseq == UINT_MAX))
- return REG_ECOLLATE;
- if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
- && start_collseq > end_collseq))
- return REG_ERANGE;
+ /* FIXME: Implement rational ranges here, too. */
+ start_collseq = lookup_collation_sequence_value (start_elem, nrules, collseqmb, collseqwc,
+ table_size, symb_table, extra);
+ end_collseq = lookup_collation_sequence_value (end_elem, nrules, collseqmb, collseqwc,
+ table_size, symb_table, extra);
+ /* Check start/end collation sequence values. */
+ if (__glibc_unlikely (start_collseq == UINT_MAX
+ || end_collseq == UINT_MAX))
+ return REG_ECOLLATE;
+ if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
+ && start_collseq > end_collseq))
+ return REG_ERANGE;
- /* Got valid collation sequence values, add them as a new entry.
- However, if we have no collation elements, and the character set
- is single byte, the single byte character set that we
- build below suffices. */
- if (nrules > 0 || dfa->mb_cur_max > 1)
+ /* Got valid collation sequence values, add them as a new entry.
+ However, if we have no collation elements, and the character set
+ is single byte, the single byte character set that we
+ build below suffices. */
+ if (nrules > 0 || dfa->mb_cur_max > 1)
+ {
+ /* Check the space of the arrays. */
+ if (__glibc_unlikely (*range_alloc == mbcset->nranges))
{
- /* Check the space of the arrays. */
- if (__glibc_unlikely (*range_alloc == mbcset->nranges))
- {
- /* There is not enough space, need realloc. */
- uint32_t *new_array_start;
- uint32_t *new_array_end;
- Idx new_nranges;
-
- /* +1 in case of mbcset->nranges is 0. */
- new_nranges = 2 * mbcset->nranges + 1;
- new_array_start = re_realloc (mbcset->range_starts, uint32_t,
- new_nranges);
- new_array_end = re_realloc (mbcset->range_ends, uint32_t,
- new_nranges);
-
- if (__glibc_unlikely (new_array_start == NULL
- || new_array_end == NULL))
- return REG_ESPACE;
+ /* There is not enough space, need realloc. */
+ uint32_t *new_array_start;
+ uint32_t *new_array_end;
+ int new_nranges;
- mbcset->range_starts = new_array_start;
- mbcset->range_ends = new_array_end;
- *range_alloc = new_nranges;
- }
+ /* +1 in case of mbcset->nranges is 0. */
+ new_nranges = 2 * mbcset->nranges + 1;
+ new_array_start = re_realloc (mbcset->range_starts, uint32_t,
+ new_nranges);
+ new_array_end = re_realloc (mbcset->range_ends, uint32_t,
+ new_nranges);
- mbcset->range_starts[mbcset->nranges] = start_collseq;
- mbcset->range_ends[mbcset->nranges++] = end_collseq;
- }
+ if (__glibc_unlikely (new_array_start == NULL
+ || new_array_end == NULL))
+ return REG_ESPACE;
- /* Build the table for single byte characters. */
- for (ch = 0; ch < SBC_MAX; ch++)
- {
- uint32_t ch_collseq;
- /*
- if (MB_CUR_MAX == 1)
- */
- if (nrules == 0)
- ch_collseq = collseqmb[ch];
- else
- ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch));
- if (start_collseq <= ch_collseq && ch_collseq <= end_collseq)
- bitset_set (sbcset, ch);
+ mbcset->range_starts = new_array_start;
+ mbcset->range_ends = new_array_end;
+ *range_alloc = new_nranges;
}
- return REG_NOERROR;
+
+ mbcset->range_starts[mbcset->nranges] = start_collseq;
+ mbcset->range_ends[mbcset->nranges++] = end_collseq;
}
- /* Local function for parse_bracket_exp used in _LIBC environment.
- Build the collating element which is represented by NAME.
- The result are written to MBCSET and SBCSET.
- COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
- pointer argument since we may update it. */
+ /* Build the table for single byte characters. */
+ for (ch = 0; ch < SBC_MAX; ch++)
+ {
+ uint32_t ch_collseq;
+ /* if (MB_CUR_MAX == 1) */
+ if (nrules == 0)
+ ch_collseq = collseqmb[ch];
+ else
+ ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch));
+ if (start_collseq <= ch_collseq && ch_collseq <= end_collseq)
+ bitset_set (sbcset, ch);
+ }
+ return REG_NOERROR;
+}
- auto inline reg_errcode_t
- __attribute__ ((always_inline))
- build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
- Idx *coll_sym_alloc, const unsigned char *name)
+/* Local function for parse_bracket_exp used in _LIBC environment.
+ Build the collating element which is represented by NAME.
+ The result are written to MBCSET and SBCSET.
+ COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
+ pointer argument since we may update it. */
+
+static __always_inline reg_errcode_t
+build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
+ Idx *coll_sym_alloc, const unsigned char *name,
+ uint_fast32_t nrules, int_fast32_t table_size,
+ const int32_t *symb_table, const unsigned char *extra)
+{
+ int32_t elem, idx;
+ size_t name_len = strlen ((const char *) name);
+ if (nrules != 0)
{
- int32_t elem, idx;
- size_t name_len = strlen ((const char *) name);
- if (nrules != 0)
+ elem = seek_collating_symbol_entry (name, name_len, symb_table,
+ table_size, extra);
+ if (elem != -1)
{
- elem = seek_collating_symbol_entry (name, name_len);
- if (elem != -1)
- {
- /* We found the entry. */
- idx = symb_table[2 * elem + 1];
- /* Skip the name of collating element name. */
- idx += 1 + extra[idx];
- }
- else if (name_len == 1)
- {
- /* No valid character, treat it as a normal
- character. */
- bitset_set (sbcset, name[0]);
- return REG_NOERROR;
- }
- else
- return REG_ECOLLATE;
-
- /* Got valid collation sequence, add it as a new entry. */
- /* Check the space of the arrays. */
- if (__glibc_unlikely (*coll_sym_alloc == mbcset->ncoll_syms))
- {
- /* Not enough, realloc it. */
- /* +1 in case of mbcset->ncoll_syms is 0. */
- Idx new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1;
- /* Use realloc since mbcset->coll_syms is NULL
- if *alloc == 0. */
- int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
- new_coll_sym_alloc);
- if (__glibc_unlikely (new_coll_syms == NULL))
- return REG_ESPACE;
- mbcset->coll_syms = new_coll_syms;
- *coll_sym_alloc = new_coll_sym_alloc;
- }
- mbcset->coll_syms[mbcset->ncoll_syms++] = idx;
+ /* We found the entry. */
+ idx = symb_table[2 * elem + 1];
+ /* Skip the name of collating element name. */
+ idx += 1 + extra[idx];
+ }
+ else if (name_len == 1)
+ {
+ /* No valid character, treat it as a normal
+ character. */
+ bitset_set (sbcset, name[0]);
return REG_NOERROR;
}
else
+ return REG_ECOLLATE;
+
+ /* Got valid collation sequence, add it as a new entry. */
+ /* Check the space of the arrays. */
+ if (__glibc_unlikely (*coll_sym_alloc == mbcset->ncoll_syms))
{
- if (__glibc_unlikely (name_len != 1))
- return REG_ECOLLATE;
- else
- {
- bitset_set (sbcset, name[0]);
- return REG_NOERROR;
- }
+ /* Not enough, realloc it. */
+ /* +1 in case of mbcset->ncoll_syms is 0. */
+ int new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1;
+ /* Use realloc since mbcset->coll_syms is NULL
+ if *alloc == 0. */
+ int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
+ new_coll_sym_alloc);
+ if (__glibc_unlikely (new_coll_syms == NULL))
+ return REG_ESPACE;
+ mbcset->coll_syms = new_coll_syms;
+ *coll_sym_alloc = new_coll_sym_alloc;
}
+ mbcset->coll_syms[mbcset->ncoll_syms++] = idx;
+ return REG_NOERROR;
}
-#endif
+ else
+ {
+ if (__glibc_unlikely (name_len != 1))
+ return REG_ECOLLATE;
+ else
+ {
+ bitset_set (sbcset, name[0]);
+ return REG_NOERROR;
+ }
+ }
+}
+#endif /* _LIBC */
+
+/* This function parse bracket expression like "[abc]", "[a-c]",
+ "[[.a-a.]]" etc. */
+
+static bin_tree_t *
+parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
+ reg_syntax_t syntax, reg_errcode_t *err)
+{
+ const unsigned char *collseqmb = NULL;
+ const char *collseqwc = NULL;
+ uint_fast32_t nrules = 0;
+ int_fast32_t table_size = 0;
+ const void *symb_table = NULL;
+ const unsigned char *extra = NULL;
re_token_t br_token;
re_bitset_ptr_t sbcset;
-#ifdef RE_ENABLE_I18N
re_charset_t *mbcset;
Idx coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0;
Idx equiv_class_alloc = 0, char_class_alloc = 0;
-#endif /* not RE_ENABLE_I18N */
bool non_match = false;
bin_tree_t *work_tree;
int token_len;
@@ -3111,26 +3050,17 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
*/
collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC);
table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB);
- symb_table = (const int32_t *) _NL_CURRENT (LC_COLLATE,
- _NL_COLLATE_SYMB_TABLEMB);
+ symb_table = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_TABLEMB);
extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
_NL_COLLATE_SYMB_EXTRAMB);
}
#endif
sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
-#ifdef RE_ENABLE_I18N
mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
-#endif /* RE_ENABLE_I18N */
-#ifdef RE_ENABLE_I18N
if (__glibc_unlikely (sbcset == NULL || mbcset == NULL))
-#else
- if (__glibc_unlikely (sbcset == NULL))
-#endif /* RE_ENABLE_I18N */
{
re_free (sbcset);
-#ifdef RE_ENABLE_I18N
re_free (mbcset);
-#endif
*err = REG_ESPACE;
return NULL;
}
@@ -3143,9 +3073,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
}
if (token->type == OP_NON_MATCH_LIST)
{
-#ifdef RE_ENABLE_I18N
mbcset->non_match = 1;
-#endif /* not RE_ENABLE_I18N */
non_match = true;
if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
bitset_set (sbcset, '\n');
@@ -3228,18 +3156,10 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
token_len = peek_token_bracket (token, regexp, syntax);
-#ifdef _LIBC
*err = build_range_exp (sbcset, mbcset, &range_alloc,
- &start_elem, &end_elem);
-#else
-# ifdef RE_ENABLE_I18N
- *err = build_range_exp (syntax, sbcset,
- dfa->mb_cur_max > 1 ? mbcset : NULL,
- &range_alloc, &start_elem, &end_elem);
-# else
- *err = build_range_exp (syntax, sbcset, &start_elem, &end_elem);
-# endif
-#endif /* RE_ENABLE_I18N */
+ &start_elem, &end_elem,
+ dfa, syntax, nrules, collseqmb, collseqwc,
+ table_size, symb_table, extra);
if (__glibc_unlikely (*err != REG_NOERROR))
goto parse_bracket_exp_free_return;
}
@@ -3250,7 +3170,6 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
case SB_CHAR:
bitset_set (sbcset, start_elem.opr.ch);
break;
-#ifdef RE_ENABLE_I18N
case MB_CHAR:
/* Check whether the array has enough space. */
if (__glibc_unlikely (mbchar_alloc == mbcset->nmbchars))
@@ -3268,30 +3187,24 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
}
mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch;
break;
-#endif /* RE_ENABLE_I18N */
case EQUIV_CLASS:
*err = build_equiv_class (sbcset,
-#ifdef RE_ENABLE_I18N
mbcset, &equiv_class_alloc,
-#endif /* RE_ENABLE_I18N */
start_elem.opr.name);
if (__glibc_unlikely (*err != REG_NOERROR))
goto parse_bracket_exp_free_return;
break;
case COLL_SYM:
*err = build_collating_symbol (sbcset,
-#ifdef RE_ENABLE_I18N
mbcset, &coll_sym_alloc,
-#endif /* RE_ENABLE_I18N */
- start_elem.opr.name);
+ start_elem.opr.name,
+ nrules, table_size, symb_table, extra);
if (__glibc_unlikely (*err != REG_NOERROR))
goto parse_bracket_exp_free_return;
break;
case CHAR_CLASS:
*err = build_charclass (regexp->trans, sbcset,
-#ifdef RE_ENABLE_I18N
mbcset, &char_class_alloc,
-#endif /* RE_ENABLE_I18N */
(const char *) start_elem.opr.name,
syntax);
if (__glibc_unlikely (*err != REG_NOERROR))
@@ -3317,7 +3230,6 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
if (non_match)
bitset_not (sbcset);
-#ifdef RE_ENABLE_I18N
/* Ensure only single byte characters are set. */
if (dfa->mb_cur_max > 1)
bitset_mask (sbcset, dfa->sb_char);
@@ -3361,11 +3273,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
}
}
else
-#endif /* not RE_ENABLE_I18N */
{
-#ifdef RE_ENABLE_I18N
free_charset (mbcset);
-#endif
/* Build a tree for simple bracket. */
br_token.type = SIMPLE_BRACKET;
br_token.opr.sbcset = sbcset;
@@ -3379,9 +3288,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
*err = REG_ESPACE;
parse_bracket_exp_free_return:
re_free (sbcset);
-#ifdef RE_ENABLE_I18N
free_charset (mbcset);
-#endif /* RE_ENABLE_I18N */
return NULL;
}
@@ -3392,7 +3299,6 @@ parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
re_token_t *token, int token_len, re_dfa_t *dfa,
reg_syntax_t syntax, bool accept_hyphen)
{
-#ifdef RE_ENABLE_I18N
int cur_char_size;
cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp));
if (cur_char_size > 1)
@@ -3402,7 +3308,6 @@ parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
re_string_skip_bytes (regexp, cur_char_size);
return REG_NOERROR;
}
-#endif /* RE_ENABLE_I18N */
re_string_skip_bytes (regexp, token_len); /* Skip a token. */
if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS
|| token->type == OP_OPEN_EQUIV_CLASS)
@@ -3475,12 +3380,8 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
is a pointer argument since we may update it. */
static reg_errcode_t
-#ifdef RE_ENABLE_I18N
build_equiv_class (bitset_t sbcset, re_charset_t *mbcset,
Idx *equiv_class_alloc, const unsigned char *name)
-#else /* not RE_ENABLE_I18N */
-build_equiv_class (bitset_t sbcset, const unsigned char *name)
-#endif /* not RE_ENABLE_I18N */
{
#ifdef _LIBC
uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
@@ -3560,14 +3461,9 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
is a pointer argument since we may update it. */
static reg_errcode_t
-#ifdef RE_ENABLE_I18N
build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
re_charset_t *mbcset, Idx *char_class_alloc,
const char *class_name, reg_syntax_t syntax)
-#else /* not RE_ENABLE_I18N */
-build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
- const char *class_name, reg_syntax_t syntax)
-#endif /* not RE_ENABLE_I18N */
{
int i;
const char *name = class_name;
@@ -3578,7 +3474,6 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
&& (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0))
name = "alpha";
-#ifdef RE_ENABLE_I18N
/* Check the space of the arrays. */
if (__glibc_unlikely (*char_class_alloc == mbcset->nchar_classes))
{
@@ -3594,7 +3489,6 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
*char_class_alloc = new_char_class_alloc;
}
mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name);
-#endif /* RE_ENABLE_I18N */
#define BUILD_CHARCLASS_LOOP(ctype_func) \
do { \
@@ -3649,10 +3543,8 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
reg_errcode_t *err)
{
re_bitset_ptr_t sbcset;
-#ifdef RE_ENABLE_I18N
re_charset_t *mbcset;
Idx alloc = 0;
-#endif /* not RE_ENABLE_I18N */
reg_errcode_t ret;
bin_tree_t *tree;
@@ -3662,7 +3554,6 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
*err = REG_ESPACE;
return NULL;
}
-#ifdef RE_ENABLE_I18N
mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
if (__glibc_unlikely (mbcset == NULL))
{
@@ -3671,21 +3562,14 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
return NULL;
}
mbcset->non_match = non_match;
-#endif /* RE_ENABLE_I18N */
/* We don't care the syntax in this case. */
- ret = build_charclass (trans, sbcset,
-#ifdef RE_ENABLE_I18N
- mbcset, &alloc,
-#endif /* RE_ENABLE_I18N */
- class_name, 0);
+ ret = build_charclass (trans, sbcset, mbcset, &alloc, class_name, 0);
if (__glibc_unlikely (ret != REG_NOERROR))
{
re_free (sbcset);
-#ifdef RE_ENABLE_I18N
free_charset (mbcset);
-#endif /* RE_ENABLE_I18N */
*err = ret;
return NULL;
}
@@ -3697,11 +3581,9 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
if (non_match)
bitset_not (sbcset);
-#ifdef RE_ENABLE_I18N
/* Ensure only single byte characters are set. */
if (dfa->mb_cur_max > 1)
bitset_mask (sbcset, dfa->sb_char);
-#endif
/* Build a tree for simple bracket. */
re_token_t br_token = { .type = SIMPLE_BRACKET, .opr.sbcset = sbcset };
@@ -3709,7 +3591,6 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
if (__glibc_unlikely (tree == NULL))
goto build_word_op_espace;
-#ifdef RE_ENABLE_I18N
if (dfa->mb_cur_max > 1)
{
bin_tree_t *mbc_tree;
@@ -3730,15 +3611,10 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
free_charset (mbcset);
return tree;
}
-#else /* not RE_ENABLE_I18N */
- return tree;
-#endif /* not RE_ENABLE_I18N */
build_word_op_espace:
re_free (sbcset);
-#ifdef RE_ENABLE_I18N
free_charset (mbcset);
-#endif /* RE_ENABLE_I18N */
*err = REG_ESPACE;
return NULL;
}
@@ -3771,21 +3647,19 @@ fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
return num;
}
-#ifdef RE_ENABLE_I18N
static void
free_charset (re_charset_t *cset)
{
re_free (cset->mbchars);
-# ifdef _LIBC
+#ifdef _LIBC
re_free (cset->coll_syms);
re_free (cset->equiv_classes);
-# endif
+#endif
re_free (cset->range_starts);
re_free (cset->range_ends);
re_free (cset->char_classes);
re_free (cset);
}
-#endif /* RE_ENABLE_I18N */
/* Functions for binary tree operation. */
@@ -3851,13 +3725,10 @@ mark_opt_subexp (void *extra, bin_tree_t *node)
static void
free_token (re_token_t *node)
{
-#ifdef RE_ENABLE_I18N
if (node->type == COMPLEX_BRACKET && node->duplicated == 0)
free_charset (node->opr.mbcset);
- else
-#endif /* RE_ENABLE_I18N */
- if (node->type == SIMPLE_BRACKET && node->duplicated == 0)
- re_free (node->opr.sbcset);
+ else if (node->type == SIMPLE_BRACKET && node->duplicated == 0)
+ re_free (node->opr.sbcset);
}
/* Worker function for tree walking. Free the allocated memory inside NODE
diff --git a/lib/regex.c b/lib/regex.c
index 7296be0f0..ff1176782 100644
--- a/lib/regex.c
+++ b/lib/regex.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -24,6 +24,7 @@
# if __GNUC_PREREQ (4, 6)
# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
+# pragma GCC diagnostic ignored "-Wvla"
# endif
# if __GNUC_PREREQ (4, 3)
# pragma GCC diagnostic ignored "-Wold-style-definition"
diff --git a/lib/regex.h b/lib/regex.h
index 8e4ef4557..a7e0bd027 100644
--- a/lib/regex.h
+++ b/lib/regex.h
@@ -1,6 +1,6 @@
/* Definitions for data structures and routines for the regular
expression library.
- Copyright (C) 1985, 1989-2021 Free Software Foundation, Inc.
+ Copyright (C) 1985, 1989-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -522,6 +522,30 @@ typedef struct
/* Declarations for routines. */
+#ifndef _REGEX_NELTS
+# if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \
+ && !defined __STDC_NO_VLA__)
+# define _REGEX_NELTS(n) n
+# else
+# define _REGEX_NELTS(n)
+# endif
+#endif
+
+#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wvla"
+#endif
+
+#ifndef _Attr_access_
+# ifdef __attr_access
+# define _Attr_access_(arg) __attr_access (arg)
+# elif defined __GNUC__ && 10 <= __GNUC__
+# define _Attr_access_(x) __attribute__ ((__access__ x))
+# else
+# define _Attr_access_(x)
+# endif
+#endif
+
#ifdef __USE_GNU
/* Sets the current default syntax to SYNTAX, and return the old syntax.
You can also simply assign to the 're_syntax_options' variable. */
@@ -536,7 +560,8 @@ extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
'regcomp', with a malloc'ed value, or set to NULL before calling
'regfree'. */
extern const char *re_compile_pattern (const char *__pattern, size_t __length,
- struct re_pattern_buffer *__buffer);
+ struct re_pattern_buffer *__buffer)
+ _Attr_access_ ((__read_only__, 1, 2));
/* Compile a fastmap for the compiled pattern in BUFFER; used to
@@ -553,7 +578,8 @@ extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);
extern regoff_t re_search (struct re_pattern_buffer *__buffer,
const char *__String, regoff_t __length,
regoff_t __start, regoff_t __range,
- struct re_registers *__regs);
+ struct re_registers *__regs)
+ _Attr_access_ ((__read_only__, 2, 3));
/* Like 're_search', but search in the concatenation of STRING1 and
@@ -563,14 +589,17 @@ extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer,
const char *__string2, regoff_t __length2,
regoff_t __start, regoff_t __range,
struct re_registers *__regs,
- regoff_t __stop);
+ regoff_t __stop)
+ _Attr_access_ ((__read_only__, 2, 3))
+ _Attr_access_ ((__read_only__, 4, 5));
/* Like 're_search', but return how many characters in STRING the regexp
in BUFFER matched, starting at position START. */
extern regoff_t re_match (struct re_pattern_buffer *__buffer,
const char *__String, regoff_t __length,
- regoff_t __start, struct re_registers *__regs);
+ regoff_t __start, struct re_registers *__regs)
+ _Attr_access_ ((__read_only__, 2, 3));
/* Relates to 're_match' as 're_search_2' relates to 're_search'. */
@@ -578,7 +607,9 @@ extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer,
const char *__string1, regoff_t __length1,
const char *__string2, regoff_t __length2,
regoff_t __start, struct re_registers *__regs,
- regoff_t __stop);
+ regoff_t __stop)
+ _Attr_access_ ((__read_only__, 2, 3))
+ _Attr_access_ ((__read_only__, 4, 5));
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
@@ -647,14 +678,19 @@ extern int regcomp (regex_t *_Restrict_ __preg,
extern int regexec (const regex_t *_Restrict_ __preg,
const char *_Restrict_ __String, size_t __nmatch,
- regmatch_t __pmatch[_Restrict_arr_],
+ regmatch_t __pmatch[_Restrict_arr_
+ _REGEX_NELTS (__nmatch)],
int __eflags);
extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg,
- char *_Restrict_ __errbuf, size_t __errbuf_size);
+ char *_Restrict_ __errbuf, size_t __errbuf_size)
+ _Attr_access_ ((__write_only__, 3, 4));
extern void regfree (regex_t *__preg);
+#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
+# pragma GCC diagnostic pop
+#endif
#ifdef __cplusplus
}
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index aefcfa2f5..0e6919f34 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -30,10 +30,8 @@ static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
re_hashval_t hash);
static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
Idx new_buf_len);
-#ifdef RE_ENABLE_I18N
static void build_wcs_buffer (re_string_t *pstr);
static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr);
-#endif /* RE_ENABLE_I18N */
static void build_upper_buffer (re_string_t *pstr);
static void re_string_translate_buffer (re_string_t *pstr);
static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
@@ -91,7 +89,6 @@ re_string_construct (re_string_t *pstr, const char *str, Idx len,
if (icase)
{
-#ifdef RE_ENABLE_I18N
if (dfa->mb_cur_max > 1)
{
while (1)
@@ -109,16 +106,13 @@ re_string_construct (re_string_t *pstr, const char *str, Idx len,
}
}
else
-#endif /* RE_ENABLE_I18N */
build_upper_buffer (pstr);
}
else
{
-#ifdef RE_ENABLE_I18N
if (dfa->mb_cur_max > 1)
build_wcs_buffer (pstr);
else
-#endif /* RE_ENABLE_I18N */
{
if (trans != NULL)
re_string_translate_buffer (pstr);
@@ -139,7 +133,6 @@ static reg_errcode_t
__attribute_warn_unused_result__
re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
{
-#ifdef RE_ENABLE_I18N
if (pstr->mb_cur_max > 1)
{
wint_t *new_wcs;
@@ -162,7 +155,6 @@ re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
pstr->offsets = new_offsets;
}
}
-#endif /* RE_ENABLE_I18N */
if (pstr->mbs_allocated)
{
unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char,
@@ -194,7 +186,6 @@ re_string_construct_common (const char *str, Idx len, re_string_t *pstr,
pstr->raw_stop = pstr->stop;
}
-#ifdef RE_ENABLE_I18N
/* Build wide character buffer PSTR->WCS.
If the byte sequence of the string are:
@@ -530,7 +521,6 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
*last_wc = wc;
return rawbuf_idx;
}
-#endif /* RE_ENABLE_I18N */
/* Build the buffer PSTR->MBS, and apply the translation if we need.
This function is used in case of REG_ICASE. */
@@ -585,10 +575,8 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
else
{
/* Reset buffer. */
-#ifdef RE_ENABLE_I18N
if (pstr->mb_cur_max > 1)
memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
-#endif /* RE_ENABLE_I18N */
pstr->len = pstr->raw_len;
pstr->stop = pstr->raw_stop;
pstr->valid_len = 0;
@@ -608,7 +596,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
if (__glibc_likely (offset < pstr->valid_raw_len))
{
/* Yes, move them to the front of the buffer. */
-#ifdef RE_ENABLE_I18N
if (__glibc_unlikely (pstr->offsets_needed))
{
Idx low = 0, high = pstr->valid_len, mid;
@@ -672,15 +659,12 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
}
}
else
-#endif
{
pstr->tip_context = re_string_context_at (pstr, offset - 1,
eflags);
-#ifdef RE_ENABLE_I18N
if (pstr->mb_cur_max > 1)
memmove (pstr->wcs, pstr->wcs + offset,
(pstr->valid_len - offset) * sizeof (wint_t));
-#endif /* RE_ENABLE_I18N */
if (__glibc_unlikely (pstr->mbs_allocated))
memmove (pstr->mbs, pstr->mbs + offset,
pstr->valid_len - offset);
@@ -691,7 +675,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
}
else
{
-#ifdef RE_ENABLE_I18N
/* No, skip all characters until IDX. */
Idx prev_valid_len = pstr->valid_len;
@@ -701,9 +684,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
pstr->stop = pstr->raw_stop - idx + offset;
pstr->offsets_needed = 0;
}
-#endif
pstr->valid_len = 0;
-#ifdef RE_ENABLE_I18N
if (pstr->mb_cur_max > 1)
{
Idx wcs_idx;
@@ -787,7 +768,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
pstr->valid_raw_len = pstr->valid_len;
}
else
-#endif /* RE_ENABLE_I18N */
{
int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1];
pstr->valid_raw_len = 0;
@@ -807,7 +787,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
pstr->stop -= offset;
/* Then build the buffers. */
-#ifdef RE_ENABLE_I18N
if (pstr->mb_cur_max > 1)
{
if (pstr->icase)
@@ -820,7 +799,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
build_wcs_buffer (pstr);
}
else
-#endif /* RE_ENABLE_I18N */
if (__glibc_unlikely (pstr->mbs_allocated))
{
if (pstr->icase)
@@ -846,28 +824,22 @@ re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
if (__glibc_likely (!pstr->mbs_allocated))
return re_string_peek_byte (pstr, idx);
-#ifdef RE_ENABLE_I18N
if (pstr->mb_cur_max > 1
&& ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx))
return re_string_peek_byte (pstr, idx);
-#endif
off = pstr->cur_idx + idx;
-#ifdef RE_ENABLE_I18N
if (pstr->offsets_needed)
off = pstr->offsets[off];
-#endif
ch = pstr->raw_mbs[pstr->raw_mbs_idx + off];
-#ifdef RE_ENABLE_I18N
/* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I
this function returns CAPITAL LETTER I instead of first byte of
DOTLESS SMALL LETTER I. The latter would confuse the parser,
since peek_byte_case doesn't advance cur_idx in any way. */
if (pstr->offsets_needed && !isascii (ch))
return re_string_peek_byte (pstr, idx);
-#endif
return ch;
}
@@ -878,7 +850,6 @@ re_string_fetch_byte_case (re_string_t *pstr)
if (__glibc_likely (!pstr->mbs_allocated))
return re_string_fetch_byte (pstr);
-#ifdef RE_ENABLE_I18N
if (pstr->offsets_needed)
{
Idx off;
@@ -904,7 +875,6 @@ re_string_fetch_byte_case (re_string_t *pstr)
re_string_char_size_at (pstr, pstr->cur_idx));
return ch;
}
-#endif
return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++];
}
@@ -912,10 +882,8 @@ re_string_fetch_byte_case (re_string_t *pstr)
static void
re_string_destruct (re_string_t *pstr)
{
-#ifdef RE_ENABLE_I18N
re_free (pstr->wcs);
re_free (pstr->offsets);
-#endif /* RE_ENABLE_I18N */
if (pstr->mbs_allocated)
re_free (pstr->mbs);
}
@@ -933,7 +901,6 @@ re_string_context_at (const re_string_t *input, Idx idx, int eflags)
if (__glibc_unlikely (idx == input->len))
return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF
: CONTEXT_NEWLINE | CONTEXT_ENDBUF);
-#ifdef RE_ENABLE_I18N
if (input->mb_cur_max > 1)
{
wint_t wc;
@@ -953,7 +920,6 @@ re_string_context_at (const re_string_t *input, Idx idx, int eflags)
? CONTEXT_NEWLINE : 0);
}
else
-#endif
{
c = re_string_byte_at (input, idx);
if (bitset_contain (input->word_char, c))
@@ -1430,32 +1396,28 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
if (__glibc_unlikely (new_nodes == NULL))
return -1;
dfa->nodes = new_nodes;
+ dfa->nodes_alloc = new_nodes_alloc;
new_nexts = re_realloc (dfa->nexts, Idx, new_nodes_alloc);
+ if (new_nexts != NULL)
+ dfa->nexts = new_nexts;
new_indices = re_realloc (dfa->org_indices, Idx, new_nodes_alloc);
+ if (new_indices != NULL)
+ dfa->org_indices = new_indices;
new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc);
+ if (new_edests != NULL)
+ dfa->edests = new_edests;
new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc);
+ if (new_eclosures != NULL)
+ dfa->eclosures = new_eclosures;
if (__glibc_unlikely (new_nexts == NULL || new_indices == NULL
|| new_edests == NULL || new_eclosures == NULL))
- {
- re_free (new_nexts);
- re_free (new_indices);
- re_free (new_edests);
- re_free (new_eclosures);
- return -1;
- }
- dfa->nexts = new_nexts;
- dfa->org_indices = new_indices;
- dfa->edests = new_edests;
- dfa->eclosures = new_eclosures;
- dfa->nodes_alloc = new_nodes_alloc;
+ return -1;
}
dfa->nodes[dfa->nodes_len] = token;
dfa->nodes[dfa->nodes_len].constraint = 0;
-#ifdef RE_ENABLE_I18N
dfa->nodes[dfa->nodes_len].accept_mb =
((token.type == OP_PERIOD && dfa->mb_cur_max > 1)
|| token.type == COMPLEX_BRACKET);
-#endif
dfa->nexts[dfa->nodes_len] = -1;
re_node_set_init_empty (dfa->edests + dfa->nodes_len);
re_node_set_init_empty (dfa->eclosures + dfa->nodes_len);
@@ -1651,9 +1613,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
re_token_type_t type = node->type;
if (type == CHARACTER && !node->constraint)
continue;
-#ifdef RE_ENABLE_I18N
newstate->accept_mb |= node->accept_mb;
-#endif /* RE_ENABLE_I18N */
/* If the state has the halt node, the state is a halt state. */
if (type == END_OF_RE)
@@ -1705,9 +1665,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
if (type == CHARACTER && !constraint)
continue;
-#ifdef RE_ENABLE_I18N
newstate->accept_mb |= node->accept_mb;
-#endif /* RE_ENABLE_I18N */
/* If the state has the halt node, the state is a halt state. */
if (type == END_OF_RE)
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index 1245e782f..57a455b1f 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -116,10 +116,6 @@
# define gettext_noop(String) String
#endif
-#if (defined MB_CUR_MAX && HAVE_WCTYPE_H && HAVE_ISWCTYPE) || _LIBC
-# define RE_ENABLE_I18N
-#endif
-
/* Number of ASCII characters. */
#define ASCII_CHARS 0x80
@@ -150,6 +146,11 @@
# define __regfree regfree
#endif /* not _LIBC */
+/* Types related to integers. Unless protected by #ifdef _LIBC, the
+ regex code should avoid exact-width types like int32_t and uint64_t
+ as some non-GCC platforms lack them, an issue when this code is
+ used in Gnulib. */
+
#ifndef SSIZE_MAX
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
#endif
@@ -246,10 +247,8 @@ typedef enum
SIMPLE_BRACKET = 3,
OP_BACK_REF = 4,
OP_PERIOD = 5,
-#ifdef RE_ENABLE_I18N
COMPLEX_BRACKET = 6,
OP_UTF8_PERIOD = 7,
-#endif /* RE_ENABLE_I18N */
/* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used
when the debugger shows values of this enum type. */
@@ -287,30 +286,29 @@ typedef enum
} re_token_type_t;
-#ifdef RE_ENABLE_I18N
typedef struct
{
/* Multibyte characters. */
wchar_t *mbchars;
+#ifdef _LIBC
/* Collating symbols. */
-# ifdef _LIBC
int32_t *coll_syms;
-# endif
+#endif
+#ifdef _LIBC
/* Equivalence classes. */
-# ifdef _LIBC
int32_t *equiv_classes;
-# endif
+#endif
/* Range expressions. */
-# ifdef _LIBC
+#ifdef _LIBC
uint32_t *range_starts;
uint32_t *range_ends;
-# else /* not _LIBC */
+#else
wchar_t *range_starts;
wchar_t *range_ends;
-# endif /* not _LIBC */
+#endif
/* Character classes. */
wctype_t *char_classes;
@@ -333,7 +331,6 @@ typedef struct
/* # of character classes. */
Idx nchar_classes;
} re_charset_t;
-#endif /* RE_ENABLE_I18N */
typedef struct
{
@@ -341,9 +338,7 @@ typedef struct
{
unsigned char c; /* for CHARACTER */
re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */
-#ifdef RE_ENABLE_I18N
re_charset_t *mbcset; /* for COMPLEX_BRACKET */
-#endif /* RE_ENABLE_I18N */
Idx idx; /* for BACK_REF */
re_context_type ctx_type; /* for ANCHOR */
} opr;
@@ -355,12 +350,10 @@ typedef struct
unsigned int constraint : 10; /* context constraint */
unsigned int duplicated : 1;
unsigned int opt_subexp : 1;
-#ifdef RE_ENABLE_I18N
unsigned int accept_mb : 1;
/* These 2 bits can be moved into the union if needed (e.g. if running out
of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */
unsigned int mb_partial : 1;
-#endif
unsigned int word_char : 1;
} re_token_t;
@@ -375,12 +368,10 @@ struct re_string_t
REG_ICASE, upper cases of the string are stored, otherwise MBS points
the same address that RAW_MBS points. */
unsigned char *mbs;
-#ifdef RE_ENABLE_I18N
/* Store the wide character string which is corresponding to MBS. */
wint_t *wcs;
Idx *offsets;
mbstate_t cur_state;
-#endif
/* Index in RAW_MBS. Each character mbs[i] corresponds to
raw_mbs[raw_mbs_idx + i]. */
Idx raw_mbs_idx;
@@ -779,7 +770,6 @@ bitset_mask (bitset_t dest, const bitset_t src)
dest[bitset_i] &= src[bitset_i];
}
-#ifdef RE_ENABLE_I18N
/* Functions for re_string. */
static int
__attribute__ ((pure, unused))
@@ -803,15 +793,15 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx)
return (wint_t) pstr->wcs[idx];
}
-# ifdef _LIBC
-# include <locale/weight.h>
-# endif
+#ifdef _LIBC
+# include <locale/weight.h>
+#endif
static int
__attribute__ ((pure, unused))
re_string_elem_size_at (const re_string_t *pstr, Idx idx)
{
-# ifdef _LIBC
+#ifdef _LIBC
const unsigned char *p, *extra;
const int32_t *table, *indirect;
uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
@@ -827,11 +817,10 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
findidx (table, indirect, extra, &p, pstr->len - idx);
return p - pstr->mbs - idx;
}
- else
-# endif /* _LIBC */
- return 1;
+#endif /* _LIBC */
+
+ return 1;
}
-#endif /* RE_ENABLE_I18N */
#ifdef _LIBC
# if __GNUC__ >= 7
diff --git a/lib/regexec.c b/lib/regexec.c
index 5e4eb497a..521cb0284 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -67,11 +67,9 @@ static reg_errcode_t set_regs (const regex_t *preg,
bool fl_backtrack);
static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs);
-#ifdef RE_ENABLE_I18N
static int sift_states_iter_mb (const re_match_context_t *mctx,
re_sift_context_t *sctx,
Idx node_idx, Idx str_idx, Idx max_str_idx);
-#endif /* RE_ENABLE_I18N */
static reg_errcode_t sift_states_backward (const re_match_context_t *mctx,
re_sift_context_t *sctx);
static reg_errcode_t build_sifted_states (const re_match_context_t *mctx,
@@ -123,10 +121,8 @@ static re_dfastate_t *transit_state_sb (reg_errcode_t *err,
re_match_context_t *mctx,
re_dfastate_t *pstate);
#endif
-#ifdef RE_ENABLE_I18N
static reg_errcode_t transit_state_mb (re_match_context_t *mctx,
re_dfastate_t *pstate);
-#endif /* RE_ENABLE_I18N */
static reg_errcode_t transit_state_bkref (re_match_context_t *mctx,
const re_node_set *nodes);
static reg_errcode_t get_subexp (re_match_context_t *mctx,
@@ -156,14 +152,12 @@ static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx,
re_node_set *cur_nodes, Idx cur_str,
Idx subexp_num, int type);
static bool build_trtable (const re_dfa_t *dfa, re_dfastate_t *state);
-#ifdef RE_ENABLE_I18N
static int check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
const re_string_t *input, Idx idx);
-# ifdef _LIBC
+#ifdef _LIBC
static unsigned int find_collation_sequence_value (const unsigned char *mbs,
size_t name_len);
-# endif /* _LIBC */
-#endif /* RE_ENABLE_I18N */
+#endif
static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa,
const re_dfastate_t *state,
re_node_set *states_node,
@@ -191,7 +185,7 @@ static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len);
int
regexec (const regex_t *__restrict preg, const char *__restrict string,
- size_t nmatch, regmatch_t pmatch[], int eflags)
+ size_t nmatch, regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags)
{
reg_errcode_t err;
Idx start, length;
@@ -235,7 +229,7 @@ int
attribute_compat_text_section
__compat_regexec (const regex_t *__restrict preg,
const char *__restrict string, size_t nmatch,
- regmatch_t pmatch[], int eflags)
+ regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags)
{
return regexec (preg, string, nmatch, pmatch,
eflags & (REG_NOTBOL | REG_NOTEOL));
@@ -758,10 +752,9 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
offset = match_first - mctx.input.raw_mbs_idx;
}
- /* If MATCH_FIRST is out of the buffer, leave it as '\0'.
- Note that MATCH_FIRST must not be smaller than 0. */
- ch = (match_first >= length
- ? 0 : re_string_byte_at (&mctx.input, offset));
+ /* Use buffer byte if OFFSET is in buffer, otherwise '\0'. */
+ ch = (offset < mctx.input.valid_len
+ ? re_string_byte_at (&mctx.input, offset) : 0);
if (fastmap[ch])
break;
match_first += incr;
@@ -780,12 +773,10 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
if (__glibc_unlikely (err != REG_NOERROR))
goto free_return;
-#ifdef RE_ENABLE_I18N
- /* Don't consider this char as a possible match start if it part,
- yet isn't the head, of a multibyte character. */
+ /* Don't consider this char as a possible match start if it part,
+ yet isn't the head, of a multibyte character. */
if (!sb && !re_string_first_byte (&mctx.input, 0))
continue;
-#endif
/* It seems to be appropriate one, then use the matcher. */
/* We assume that the matching starts from 0. */
@@ -859,7 +850,6 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
if (pmatch[reg_idx].rm_so != -1)
{
-#ifdef RE_ENABLE_I18N
if (__glibc_unlikely (mctx.input.offsets_needed != 0))
{
pmatch[reg_idx].rm_so =
@@ -871,9 +861,6 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
? mctx.input.valid_raw_len
: mctx.input.offsets[pmatch[reg_idx].rm_eo]);
}
-#else
- DEBUG_ASSERT (mctx.input.offsets_needed == 0);
-#endif
pmatch[reg_idx].rm_so += match_first;
pmatch[reg_idx].rm_eo += match_first;
}
@@ -997,8 +984,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
We must select appropriate initial state depending on the context,
since initial states may have constraints like "\<", "^", etc.. */
-static inline re_dfastate_t *
-__attribute__ ((always_inline))
+static __always_inline re_dfastate_t *
acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
Idx idx)
{
@@ -1262,12 +1248,9 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
Idx naccepted = 0;
re_token_type_t type = dfa->nodes[node].type;
-#ifdef RE_ENABLE_I18N
if (dfa->nodes[node].accept_mb)
naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx);
- else
-#endif /* RE_ENABLE_I18N */
- if (type == OP_BACK_REF)
+ else if (type == OP_BACK_REF)
{
Idx subexp_idx = dfa->nodes[node].opr.idx + 1;
if (subexp_idx < nregs)
@@ -1325,8 +1308,8 @@ push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
re_node_set *eps_via_nodes)
{
reg_errcode_t err;
- Idx num = fs->num++;
- if (fs->num == fs->alloc)
+ Idx num = fs->num;
+ if (num == fs->alloc)
{
struct re_fail_stack_ent_t *new_array;
new_array = re_realloc (fs->stack, struct re_fail_stack_ent_t,
@@ -1341,6 +1324,7 @@ push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
fs->stack[num].regs = re_malloc (regmatch_t, 2 * nregs);
if (fs->stack[num].regs == NULL)
return REG_ESPACE;
+ fs->num = num + 1;
memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs);
memcpy (fs->stack[num].regs + nregs, prevregs, sizeof (regmatch_t) * nregs);
err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes);
@@ -1635,12 +1619,10 @@ build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
bool ok;
DEBUG_ASSERT (!IS_EPSILON_NODE (dfa->nodes[prev_node].type));
-#ifdef RE_ENABLE_I18N
/* If the node may accept "multi byte". */
if (dfa->nodes[prev_node].accept_mb)
naccepted = sift_states_iter_mb (mctx, sctx, prev_node,
str_idx, sctx->last_str_idx);
-#endif /* RE_ENABLE_I18N */
/* We don't check backreferences here.
See update_cur_sifted_state(). */
@@ -1689,6 +1671,7 @@ clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
if (top < next_state_log_idx)
{
+ DEBUG_ASSERT (mctx->state_log != NULL);
memset (mctx->state_log + top + 1, '\0',
sizeof (re_dfastate_t *) * (next_state_log_idx - top));
mctx->state_log_top = next_state_log_idx;
@@ -2177,7 +2160,6 @@ sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
}
-#ifdef RE_ENABLE_I18N
static int
sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
Idx node_idx, Idx str_idx, Idx max_str_idx)
@@ -2197,8 +2179,6 @@ sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
'naccepted' bytes input. */
return naccepted;
}
-#endif /* RE_ENABLE_I18N */
-
/* Functions for state transition. */
@@ -2216,7 +2196,6 @@ transit_state (reg_errcode_t *err, re_match_context_t *mctx,
re_dfastate_t **trtable;
unsigned char ch;
-#ifdef RE_ENABLE_I18N
/* If the current state can accept multibyte. */
if (__glibc_unlikely (state->accept_mb))
{
@@ -2224,7 +2203,6 @@ transit_state (reg_errcode_t *err, re_match_context_t *mctx,
if (__glibc_unlikely (*err != REG_NOERROR))
return NULL;
}
-#endif /* RE_ENABLE_I18N */
/* Then decide the next state with the single byte. */
#if 0
@@ -2445,7 +2423,6 @@ transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
}
#endif
-#ifdef RE_ENABLE_I18N
static reg_errcode_t
transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
{
@@ -2513,7 +2490,6 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
}
return REG_NOERROR;
}
-#endif /* RE_ENABLE_I18N */
static reg_errcode_t
transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
@@ -3003,9 +2979,7 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
const re_dfa_t *const dfa = mctx->dfa;
bool ok;
Idx cur_idx;
-#ifdef RE_ENABLE_I18N
reg_errcode_t err = REG_NOERROR;
-#endif
re_node_set union_set;
re_node_set_init_empty (&union_set);
for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx)
@@ -3014,7 +2988,6 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
Idx cur_node = cur_nodes->elems[cur_idx];
DEBUG_ASSERT (!IS_EPSILON_NODE (dfa->nodes[cur_node].type));
-#ifdef RE_ENABLE_I18N
/* If the node may accept "multi byte". */
if (dfa->nodes[cur_node].accept_mb)
{
@@ -3052,7 +3025,7 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
}
}
}
-#endif /* RE_ENABLE_I18N */
+
if (naccepted
|| check_node_accept (mctx, dfa->nodes + cur_node, str_idx))
{
@@ -3476,18 +3449,15 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
}
else if (type == OP_PERIOD)
{
-#ifdef RE_ENABLE_I18N
if (dfa->mb_cur_max > 1)
bitset_merge (accepts, dfa->sb_char);
else
-#endif
bitset_set_all (accepts);
if (!(dfa->syntax & RE_DOT_NEWLINE))
bitset_clear (accepts, '\n');
if (dfa->syntax & RE_DOT_NOT_NULL)
bitset_clear (accepts, '\0');
}
-#ifdef RE_ENABLE_I18N
else if (type == OP_UTF8_PERIOD)
{
if (ASCII_CHARS % BITSET_WORD_BITS == 0)
@@ -3499,7 +3469,6 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
if (dfa->syntax & RE_DOT_NOT_NULL)
bitset_clear (accepts, '\0');
}
-#endif
else
continue;
@@ -3530,12 +3499,10 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
bitset_empty (accepts);
continue;
}
-#ifdef RE_ENABLE_I18N
if (dfa->mb_cur_max > 1)
for (j = 0; j < BITSET_WORDS; ++j)
any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j]));
else
-#endif
for (j = 0; j < BITSET_WORDS; ++j)
any_set |= (accepts[j] &= dfa->word_char[j]);
if (!any_set)
@@ -3549,12 +3516,10 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
bitset_empty (accepts);
continue;
}
-#ifdef RE_ENABLE_I18N
if (dfa->mb_cur_max > 1)
for (j = 0; j < BITSET_WORDS; ++j)
any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j]));
else
-#endif
for (j = 0; j < BITSET_WORDS; ++j)
any_set |= (accepts[j] &= ~dfa->word_char[j]);
if (!any_set)
@@ -3631,7 +3596,6 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
return -1;
}
-#ifdef RE_ENABLE_I18N
/* Check how many bytes the node 'dfa->nodes[node_idx]' accepts.
Return the number of the bytes the node accepts.
STR_IDX is the current index of the input string.
@@ -3640,9 +3604,9 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
one collating element like '.', '[a-z]', opposite to the other nodes
can only accept one byte. */
-# ifdef _LIBC
-# include <locale/weight.h>
-# endif
+#ifdef _LIBC
+# include <locale/weight.h>
+#endif
static int
check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
@@ -3726,12 +3690,12 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
if (node->type == COMPLEX_BRACKET)
{
const re_charset_t *cset = node->opr.mbcset;
-# ifdef _LIBC
+#ifdef _LIBC
const unsigned char *pin
= ((const unsigned char *) re_string_get_buffer (input) + str_idx);
Idx j;
uint32_t nrules;
-# endif /* _LIBC */
+#endif
int match_len = 0;
wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars)
? re_string_wchar_at (input, str_idx) : 0);
@@ -3754,7 +3718,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
}
}
-# ifdef _LIBC
+#ifdef _LIBC
nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
if (nrules != 0)
{
@@ -3843,7 +3807,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
}
}
else
-# endif /* _LIBC */
+#endif /* _LIBC */
{
/* match with range expression? */
for (i = 0; i < cset->nranges; ++i)
@@ -3869,7 +3833,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
return 0;
}
-# ifdef _LIBC
+#ifdef _LIBC
static unsigned int
find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
{
@@ -3927,8 +3891,7 @@ find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
return UINT_MAX;
}
}
-# endif /* _LIBC */
-#endif /* RE_ENABLE_I18N */
+#endif /* _LIBC */
/* Check whether the node accepts the byte which is IDX-th
byte of the INPUT. */
@@ -3951,12 +3914,10 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
return false;
break;
-#ifdef RE_ENABLE_I18N
case OP_UTF8_PERIOD:
if (ch >= ASCII_CHARS)
return false;
FALLTHROUGH;
-#endif
case OP_PERIOD:
if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE))
|| (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL)))
@@ -4017,7 +3978,6 @@ extend_buffers (re_match_context_t *mctx, int min_len)
/* Then reconstruct the buffers. */
if (pstr->icase)
{
-#ifdef RE_ENABLE_I18N
if (pstr->mb_cur_max > 1)
{
ret = build_wcs_upper_buffer (pstr);
@@ -4025,16 +3985,13 @@ extend_buffers (re_match_context_t *mctx, int min_len)
return ret;
}
else
-#endif /* RE_ENABLE_I18N */
build_upper_buffer (pstr);
}
else
{
-#ifdef RE_ENABLE_I18N
if (pstr->mb_cur_max > 1)
build_wcs_buffer (pstr);
else
-#endif /* RE_ENABLE_I18N */
{
if (pstr->trans != NULL)
re_string_translate_buffer (pstr);
diff --git a/lib/rename.c b/lib/rename.c
index a3b7dc641..119abe5c2 100644
--- a/lib/rename.c
+++ b/lib/rename.c
@@ -1,6 +1,6 @@
/* Work around rename bugs in some systems.
- Copyright (C) 2001-2003, 2005-2006, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2006, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -287,7 +287,7 @@ rpl_rename (char const *src, char const *dst)
char *dst_temp = (char *) dst;
bool src_slash;
bool dst_slash;
- bool dst_exists _GL_UNUSED;
+ _GL_UNUSED bool dst_exists;
int ret_val = -1;
int rename_errno = ENOTDIR;
struct stat src_st;
diff --git a/lib/rmdir.c b/lib/rmdir.c
index 6295e4125..8c8b75e04 100644
--- a/lib/rmdir.c
+++ b/lib/rmdir.c
@@ -1,6 +1,6 @@
/* Work around rmdir bugs.
- Copyright (C) 1988, 1990, 1999, 2003-2006, 2009-2021 Free Software
+ Copyright (C) 1988, 1990, 1999, 2003-2006, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/round.c b/lib/round.c
index 552505042..7e62feeb5 100644
--- a/lib/round.c
+++ b/lib/round.c
@@ -1,9 +1,9 @@
/* Round toward nearest, breaking ties away from zero.
- Copyright (C) 2007, 2010-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2010-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/safe-read.c b/lib/safe-read.c
index e187b1258..04ffa7b84 100644
--- a/lib/safe-read.c
+++ b/lib/safe-read.c
@@ -1,6 +1,6 @@
/* An interface to read and write that retries after interrupts.
- Copyright (C) 1993-1994, 1998, 2002-2006, 2009-2021 Free Software
+ Copyright (C) 1993-1994, 1998, 2002-2006, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/safe-read.h b/lib/safe-read.h
index 111aff5c4..a39bb984c 100644
--- a/lib/safe-read.h
+++ b/lib/safe-read.h
@@ -1,5 +1,5 @@
/* An interface to read() that retries after interrupts.
- Copyright (C) 2002, 2006, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/safe-write.c b/lib/safe-write.c
index 494de1495..b779b36e7 100644
--- a/lib/safe-write.c
+++ b/lib/safe-write.c
@@ -1,5 +1,5 @@
/* An interface to write that retries after interrupts.
- Copyright (C) 2002, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/safe-write.h b/lib/safe-write.h
index 25d8c710c..a5a6c90bc 100644
--- a/lib/safe-write.h
+++ b/lib/safe-write.h
@@ -1,5 +1,5 @@
/* An interface to write() that retries after interrupts.
- Copyright (C) 2002, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/same-inode.h b/lib/same-inode.h
index c7277779a..f65f3d039 100644
--- a/lib/same-inode.h
+++ b/lib/same-inode.h
@@ -1,6 +1,6 @@
/* Determine whether two stat buffers are known to refer to the same file.
- Copyright (C) 2006, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/sched.h b/lib/sched.h
new file mode 100644
index 000000000..223718750
--- /dev/null
+++ b/lib/sched.h
@@ -0,0 +1,580 @@
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+/* A GNU-like <sched.h>.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_SCHED_H
+
+#if __GNUC__ >= 3
+#pragma GCC system_header
+#endif
+
+
+/* The include_next requires a split double-inclusion guard. */
+#if 1
+# if 1
+# include <sys/cdefs.h>
+# endif
+# include_next <sched.h>
+#endif
+
+#ifndef _GL_SCHED_H
+#define _GL_SCHED_H
+
+/* Get pid_t.
+ This is needed on glibc 2.11 (see
+ glibc bug <https://sourceware.org/bugzilla/show_bug.cgi?id=13198>)
+ and Mac OS X 10.5. */
+#include <sys/types.h>
+
+#ifdef __KLIBC__
+/* On OS/2 kLIBC, struct sched_param is in spawn.h. */
+# include <spawn.h>
+#endif
+
+#ifdef __VMS
+/* On OpenVMS, struct sched_param is in <pthread.h>. */
+# include <pthread.h>
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+/* C++ compatible function declaration macros.
+ Copyright (C) 2010-2022 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_CXXDEFS_H
+#define _GL_CXXDEFS_H
+
+/* Begin/end the GNULIB_NAMESPACE namespace. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
+# define _GL_END_NAMESPACE }
+#else
+# define _GL_BEGIN_NAMESPACE
+# define _GL_END_NAMESPACE
+#endif
+
+/* The three most frequent use cases of these macros are:
+
+ * For providing a substitute for a function that is missing on some
+ platforms, but is declared and works fine on the platforms on which
+ it exists:
+
+ #if @GNULIB_FOO@
+ # if !@HAVE_FOO@
+ _GL_FUNCDECL_SYS (foo, ...);
+ # endif
+ _GL_CXXALIAS_SYS (foo, ...);
+ _GL_CXXALIASWARN (foo);
+ #elif defined GNULIB_POSIXCHECK
+ ...
+ #endif
+
+ * For providing a replacement for a function that exists on all platforms,
+ but is broken/insufficient and needs to be replaced on some platforms:
+
+ #if @GNULIB_FOO@
+ # if @REPLACE_FOO@
+ # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+ # undef foo
+ # define foo rpl_foo
+ # endif
+ _GL_FUNCDECL_RPL (foo, ...);
+ _GL_CXXALIAS_RPL (foo, ...);
+ # else
+ _GL_CXXALIAS_SYS (foo, ...);
+ # endif
+ _GL_CXXALIASWARN (foo);
+ #elif defined GNULIB_POSIXCHECK
+ ...
+ #endif
+
+ * For providing a replacement for a function that exists on some platforms
+ but is broken/insufficient and needs to be replaced on some of them and
+ is additionally either missing or undeclared on some other platforms:
+
+ #if @GNULIB_FOO@
+ # if @REPLACE_FOO@
+ # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+ # undef foo
+ # define foo rpl_foo
+ # endif
+ _GL_FUNCDECL_RPL (foo, ...);
+ _GL_CXXALIAS_RPL (foo, ...);
+ # else
+ # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
+ _GL_FUNCDECL_SYS (foo, ...);
+ # endif
+ _GL_CXXALIAS_SYS (foo, ...);
+ # endif
+ _GL_CXXALIASWARN (foo);
+ #elif defined GNULIB_POSIXCHECK
+ ...
+ #endif
+*/
+
+/* _GL_EXTERN_C declaration;
+ performs the declaration with C linkage. */
+#if defined __cplusplus
+# define _GL_EXTERN_C extern "C"
+#else
+# define _GL_EXTERN_C extern
+#endif
+
+/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
+ declares a replacement function, named rpl_func, with the given prototype,
+ consisting of return type, parameters, and attributes.
+ Example:
+ _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
+ _GL_ARG_NONNULL ((1)));
+ */
+#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
+ _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
+#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
+ _GL_EXTERN_C rettype rpl_func parameters_and_attributes
+
+/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
+ declares the system function, named func, with the given prototype,
+ consisting of return type, parameters, and attributes.
+ Example:
+ _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
+ _GL_ARG_NONNULL ((1)));
+ */
+#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
+ _GL_EXTERN_C rettype func parameters_and_attributes
+
+/* _GL_CXXALIAS_RPL (func, rettype, parameters);
+ declares a C++ alias called GNULIB_NAMESPACE::func
+ that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
+ Example:
+ _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
+
+ Wrapping rpl_func in an object with an inline conversion operator
+ avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
+ actually used in the program. */
+#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
+ _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return ::rpl_func; \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_MDA (func, rettype, parameters);
+ is to be used when func is a Microsoft deprecated alias, on native Windows.
+ It declares a C++ alias called GNULIB_NAMESPACE::func
+ that redirects to _func, if GNULIB_NAMESPACE is defined.
+ Example:
+ _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
+ */
+#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
+ _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
+
+/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
+ is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
+ except that the C function rpl_func may have a slightly different
+ declaration. A cast is used to silence the "invalid conversion" error
+ that would otherwise occur. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast<type>(::rpl_func); \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
+ is like _GL_CXXALIAS_MDA (func, rettype, parameters);
+ except that the C function func may have a slightly different declaration.
+ A cast is used to silence the "invalid conversion" error that would
+ otherwise occur. */
+#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
+ _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
+
+/* _GL_CXXALIAS_SYS (func, rettype, parameters);
+ declares a C++ alias called GNULIB_NAMESPACE::func
+ that redirects to the system provided function func, if GNULIB_NAMESPACE
+ is defined.
+ Example:
+ _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
+
+ Wrapping func in an object with an inline conversion operator
+ avoids a reference to func unless GNULIB_NAMESPACE::func is
+ actually used in the program. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return ::func; \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
+ is like _GL_CXXALIAS_SYS (func, rettype, parameters);
+ except that the C function func may have a slightly different declaration.
+ A cast is used to silence the "invalid conversion" error that would
+ otherwise occur. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast<type>(::func); \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
+ is like _GL_CXXALIAS_SYS (func, rettype, parameters);
+ except that the C function is picked among a set of overloaded functions,
+ namely the one with rettype2 and parameters2. Two consecutive casts
+ are used to silence the "cannot find a match" and "invalid conversion"
+ errors that would otherwise occur. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+ /* The outer cast must be a reinterpret_cast.
+ The inner cast: When the function is defined as a set of overloaded
+ functions, it works as a static_cast<>, choosing the designated variant.
+ When the function is defined as a single variant, it works as a
+ reinterpret_cast<>. The parenthesized cast syntax works both ways. */
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIASWARN (func);
+ causes a warning to be emitted when ::func is used but not when
+ GNULIB_NAMESPACE::func is used. func must be defined without overloaded
+ variants. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIASWARN(func) \
+ _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
+# define _GL_CXXALIASWARN_1(func,namespace) \
+ _GL_CXXALIASWARN_2 (func, namespace)
+/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+ we enable the warning only when not optimizing. */
+# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
+# define _GL_CXXALIASWARN_2(func,namespace) \
+ _GL_WARN_ON_USE (func, \
+ "The symbol ::" #func " refers to the system function. " \
+ "Use " #namespace "::" #func " instead.")
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+# define _GL_CXXALIASWARN_2(func,namespace) \
+ extern __typeof__ (func) func
+# else
+# define _GL_CXXALIASWARN_2(func,namespace) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+# endif
+#else
+# define _GL_CXXALIASWARN(func) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
+ causes a warning to be emitted when the given overloaded variant of ::func
+ is used but not when GNULIB_NAMESPACE::func is used. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
+ _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
+ GNULIB_NAMESPACE)
+# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
+ _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
+/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+ we enable the warning only when not optimizing. */
+# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+ _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
+ "The symbol ::" #func " refers to the system function. " \
+ "Use " #namespace "::" #func " instead.")
+# else
+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+# endif
+#else
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+#endif /* _GL_CXXDEFS_H */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+/* A C macro for emitting warnings if a function is used.
+ Copyright (C) 2010-2022 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
+ for FUNCTION which will then trigger a compiler warning containing
+ the text of "literal string" anywhere that function is called, if
+ supported by the compiler. If the compiler does not support this
+ feature, the macro expands to an unused extern declaration.
+
+ _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
+ attribute used in _GL_WARN_ON_USE. If the compiler does not support
+ this feature, it expands to empty.
+
+ These macros are useful for marking a function as a potential
+ portability trap, with the intent that "literal string" include
+ instructions on the replacement function that should be used
+ instead.
+ _GL_WARN_ON_USE is for functions with 'extern' linkage.
+ _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
+ linkage.
+
+ However, one of the reasons that a function is a portability trap is
+ if it has the wrong signature. Declaring FUNCTION with a different
+ signature in C is a compilation error, so this macro must use the
+ same type as any existing declaration so that programs that avoid
+ the problematic FUNCTION do not fail to compile merely because they
+ included a header that poisoned the function. But this implies that
+ _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
+ have a declaration. Use of this macro implies that there must not
+ be any other macro hiding the declaration of FUNCTION; but
+ undefining FUNCTION first is part of the poisoning process anyway
+ (although for symbols that are provided only via a macro, the result
+ is a compilation error rather than a warning containing
+ "literal string"). Also note that in C++, it is only safe to use if
+ FUNCTION has no overloads.
+
+ For an example, it is possible to poison 'getline' by:
+ - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
+ [getline]) in configure.ac, which potentially defines
+ HAVE_RAW_DECL_GETLINE
+ - adding this code to a header that wraps the system <stdio.h>:
+ #undef getline
+ #if HAVE_RAW_DECL_GETLINE
+ _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
+ "not universally present; use the gnulib module getline");
+ #endif
+
+ It is not possible to directly poison global variables. But it is
+ possible to write a wrapper accessor function, and poison that
+ (less common usage, like &environ, will cause a compilation error
+ rather than issue the nice warning, but the end result of informing
+ the developer about their portability problem is still achieved):
+ #if HAVE_RAW_DECL_ENVIRON
+ static char ***
+ rpl_environ (void) { return &environ; }
+ _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
+ # undef environ
+ # define environ (*rpl_environ ())
+ #endif
+ or better (avoiding contradictory use of 'static' and 'extern'):
+ #if HAVE_RAW_DECL_ENVIRON
+ static char ***
+ _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
+ rpl_environ (void) { return &environ; }
+ # undef environ
+ # define environ (*rpl_environ ())
+ #endif
+ */
+#ifndef _GL_WARN_ON_USE
+
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
+/* A compiler attribute is available in gcc versions 4.3.0 and later. */
+# define _GL_WARN_ON_USE(function, message) \
+_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
+# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
+ __attribute__ ((__warning__ (message)))
+# elif __clang_major__ >= 4
+/* Another compiler attribute is available in clang. */
+# define _GL_WARN_ON_USE(function, message) \
+_GL_WARN_EXTERN_C __typeof__ (function) function \
+ __attribute__ ((__diagnose_if__ (1, message, "warning")))
+# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
+ __attribute__ ((__diagnose_if__ (1, message, "warning")))
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+/* Verify the existence of the function. */
+# define _GL_WARN_ON_USE(function, message) \
+_GL_WARN_EXTERN_C __typeof__ (function) function
+# define _GL_WARN_ON_USE_ATTRIBUTE(message)
+# else /* Unsupported. */
+# define _GL_WARN_ON_USE(function, message) \
+_GL_WARN_EXTERN_C int _gl_warn_on_use
+# define _GL_WARN_ON_USE_ATTRIBUTE(message)
+# endif
+#endif
+
+/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
+ is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
+ function is declared with the given prototype, consisting of return type,
+ parameters, and attributes.
+ This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
+ not work in this case. */
+#ifndef _GL_WARN_ON_USE_CXX
+# if !defined __cplusplus
+# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+ _GL_WARN_ON_USE (function, msg)
+# else
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
+/* A compiler attribute is available in gcc versions 4.3.0 and later. */
+# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+extern rettype_gcc function parameters_and_attributes \
+ __attribute__ ((__warning__ (msg)))
+# elif __clang_major__ >= 4
+/* Another compiler attribute is available in clang. */
+# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+extern rettype_clang function parameters_and_attributes \
+ __attribute__ ((__diagnose_if__ (1, msg, "warning")))
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+/* Verify the existence of the function. */
+# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+extern rettype_gcc function parameters_and_attributes
+# else /* Unsupported. */
+# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+_GL_WARN_EXTERN_C int _gl_warn_on_use
+# endif
+# endif
+#endif
+
+/* _GL_WARN_EXTERN_C declaration;
+ performs the declaration with C linkage. */
+#ifndef _GL_WARN_EXTERN_C
+# if defined __cplusplus
+# define _GL_WARN_EXTERN_C extern "C"
+# else
+# define _GL_WARN_EXTERN_C extern
+# endif
+#endif
+
+#if !1
+
+# if !GNULIB_defined_struct_sched_param
+struct sched_param
+{
+ int sched_priority;
+};
+# define GNULIB_defined_struct_sched_param 1
+# endif
+
+#endif
+
+#if !(defined SCHED_FIFO && defined SCHED_RR && defined SCHED_OTHER)
+# define SCHED_FIFO 1
+# define SCHED_RR 2
+# define SCHED_OTHER 0
+#endif
+
+#if 0
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef sched_yield
+# define sched_yield rpl_sched_yield
+# endif
+_GL_FUNCDECL_RPL (sched_yield, int, (void));
+_GL_CXXALIAS_RPL (sched_yield, int, (void));
+# else
+# if !1
+_GL_FUNCDECL_SYS (sched_yield, int, (void));
+# endif
+_GL_CXXALIAS_SYS (sched_yield, int, (void));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (sched_yield);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef sched_yield
+# if HAVE_RAW_DECL_SCHED_YIELD
+_GL_WARN_ON_USE (sched_yield, "sched_yield is not portable - "
+ "use gnulib module sched_yield for portability");
+# endif
+#endif
+
+#endif /* _GL_SCHED_H */
+#endif /* _GL_SCHED_H */
diff --git a/lib/sched.in.h b/lib/sched.in.h
new file mode 100644
index 000000000..d19c5022a
--- /dev/null
+++ b/lib/sched.in.h
@@ -0,0 +1,99 @@
+/* A GNU-like <sched.h>.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _@GUARD_PREFIX@_SCHED_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_SCHED_H@
+# if @HAVE_SYS_CDEFS_H@
+# include <sys/cdefs.h>
+# endif
+# @INCLUDE_NEXT@ @NEXT_SCHED_H@
+#endif
+
+#ifndef _@GUARD_PREFIX@_SCHED_H
+#define _@GUARD_PREFIX@_SCHED_H
+
+/* Get pid_t.
+ This is needed on glibc 2.11 (see
+ glibc bug <https://sourceware.org/bugzilla/show_bug.cgi?id=13198>)
+ and Mac OS X 10.5. */
+#include <sys/types.h>
+
+#ifdef __KLIBC__
+/* On OS/2 kLIBC, struct sched_param is in spawn.h. */
+# include <spawn.h>
+#endif
+
+#ifdef __VMS
+/* On OpenVMS, struct sched_param is in <pthread.h>. */
+# include <pthread.h>
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+#if !@HAVE_STRUCT_SCHED_PARAM@
+
+# if !GNULIB_defined_struct_sched_param
+struct sched_param
+{
+ int sched_priority;
+};
+# define GNULIB_defined_struct_sched_param 1
+# endif
+
+#endif
+
+#if !(defined SCHED_FIFO && defined SCHED_RR && defined SCHED_OTHER)
+# define SCHED_FIFO 1
+# define SCHED_RR 2
+# define SCHED_OTHER 0
+#endif
+
+#if @GNULIB_SCHED_YIELD@
+# if @REPLACE_SCHED_YIELD@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef sched_yield
+# define sched_yield rpl_sched_yield
+# endif
+_GL_FUNCDECL_RPL (sched_yield, int, (void));
+_GL_CXXALIAS_RPL (sched_yield, int, (void));
+# else
+# if !@HAVE_SCHED_YIELD@
+_GL_FUNCDECL_SYS (sched_yield, int, (void));
+# endif
+_GL_CXXALIAS_SYS (sched_yield, int, (void));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (sched_yield);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef sched_yield
+# if HAVE_RAW_DECL_SCHED_YIELD
+_GL_WARN_ON_USE (sched_yield, "sched_yield is not portable - "
+ "use gnulib module sched_yield for portability");
+# endif
+#endif
+
+#endif /* _@GUARD_PREFIX@_SCHED_H */
+#endif /* _@GUARD_PREFIX@_SCHED_H */
diff --git a/lib/scratch_buffer.h b/lib/scratch_buffer.h
index 88735771d..f4fe5e8d3 100644
--- a/lib/scratch_buffer.h
+++ b/lib/scratch_buffer.h
@@ -1,5 +1,5 @@
/* Variable-sized buffer with on-stack default allocation.
- Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ Copyright (C) 2017-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/select.c b/lib/select.c
index eddac4b61..c24249822 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -1,7 +1,7 @@
/* Emulation for select(2)
Contributed by Paolo Bonzini.
- Copyright 2008-2021 Free Software Foundation, Inc.
+ Copyright 2008-2022 Free Software Foundation, Inc.
This file is part of gnulib.
diff --git a/lib/send.c b/lib/send.c
index 58cb70b56..5510c0c04 100644
--- a/lib/send.c
+++ b/lib/send.c
@@ -1,6 +1,6 @@
/* send.c --- wrappers for Windows send function
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/sendto.c b/lib/sendto.c
index 029ccd69f..01163a633 100644
--- a/lib/sendto.c
+++ b/lib/sendto.c
@@ -1,6 +1,6 @@
/* sendto.c --- wrappers for Windows sendto function
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/setenv.c b/lib/setenv.c
index 3ad3477e9..ebfd4e550 100644
--- a/lib/setenv.c
+++ b/lib/setenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1995-2003, 2005-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995-2003, 2005-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/setlocale-lock.c b/lib/setlocale-lock.c
index 53e231c6c..4e7540e1f 100644
--- a/lib/setlocale-lock.c
+++ b/lib/setlocale-lock.c
@@ -1,5 +1,5 @@
/* Return the internal lock used by setlocale_null_r.
- Copyright (C) 2019-2021 Free Software Foundation, Inc.
+ Copyright (C) 2019-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/setlocale_null.c b/lib/setlocale_null.c
index dbfda25c5..778429b94 100644
--- a/lib/setlocale_null.c
+++ b/lib/setlocale_null.c
@@ -1,5 +1,5 @@
/* Query the name of the current global locale.
- Copyright (C) 2019-2021 Free Software Foundation, Inc.
+ Copyright (C) 2019-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/setlocale_null.h b/lib/setlocale_null.h
index 00c42e2aa..d1921b09b 100644
--- a/lib/setlocale_null.h
+++ b/lib/setlocale_null.h
@@ -1,5 +1,5 @@
/* Query the name of the current global locale.
- Copyright (C) 2019-2021 Free Software Foundation, Inc.
+ Copyright (C) 2019-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/setsockopt.c b/lib/setsockopt.c
index 10b1e9061..2811c19af 100644
--- a/lib/setsockopt.c
+++ b/lib/setsockopt.c
@@ -1,6 +1,6 @@
/* setsockopt.c --- wrappers for Windows setsockopt function
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/shutdown.c b/lib/shutdown.c
index 70c927c6a..170d8710e 100644
--- a/lib/shutdown.c
+++ b/lib/shutdown.c
@@ -1,6 +1,6 @@
/* shutdown.c --- wrappers for Windows shutdown function
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/signal.in.h b/lib/signal.in.h
index 275da8c81..640b5022f 100644
--- a/lib/signal.in.h
+++ b/lib/signal.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <signal.h>.
- Copyright (C) 2006-2021 Free Software Foundation, Inc.
+ Copyright (C) 2006-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/signbitd.c b/lib/signbitd.c
index 22597719f..776dd732b 100644
--- a/lib/signbitd.c
+++ b/lib/signbitd.c
@@ -1,5 +1,5 @@
/* signbit() macro: Determine the sign bit of a floating-point number.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/signbitf.c b/lib/signbitf.c
index b196d9ab5..0adf0011a 100644
--- a/lib/signbitf.c
+++ b/lib/signbitf.c
@@ -1,5 +1,5 @@
/* signbit() macro: Determine the sign bit of a floating-point number.
- Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/signbitl.c b/lib/signbitl.c
index f73802d1a..865d27652 100644
--- a/lib/signbitl.c
+++ b/lib/signbitl.c
@@ -1,5 +1,5 @@
/* signbit() macro: Determine the sign bit of a floating-point number.
- Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/size_max.h b/lib/size_max.h
index 1186ba95d..dee2b8eea 100644
--- a/lib/size_max.h
+++ b/lib/size_max.h
@@ -1,5 +1,5 @@
/* size_max.h -- declare SIZE_MAX through system headers
- Copyright (C) 2005-2006, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2022 Free Software Foundation, Inc.
Written by Simon Josefsson.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/snprintf.c b/lib/snprintf.c
index a589cf1a6..3d87854e9 100644
--- a/lib/snprintf.c
+++ b/lib/snprintf.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 2004, 2006-2021 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006-2022 Free Software Foundation, Inc.
Written by Simon Josefsson and Paul Eggert.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/socket.c b/lib/socket.c
index 0f2e6ff91..49e013c7a 100644
--- a/lib/socket.c
+++ b/lib/socket.c
@@ -1,6 +1,6 @@
/* socket.c --- wrappers for Windows socket function
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/sockets.c b/lib/sockets.c
index 934da73d2..31b430296 100644
--- a/lib/sockets.c
+++ b/lib/sockets.c
@@ -1,6 +1,6 @@
/* sockets.c --- wrappers for Windows socket functions
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -113,7 +113,7 @@ static int initialized_sockets_version /* = 0 */;
#endif /* WINDOWS_SOCKETS */
int
-gl_sockets_startup (int version _GL_UNUSED)
+gl_sockets_startup (_GL_UNUSED int version)
{
#if WINDOWS_SOCKETS
if (version > initialized_sockets_version)
diff --git a/lib/sockets.h b/lib/sockets.h
index e70c2bbfd..75e49fce0 100644
--- a/lib/sockets.h
+++ b/lib/sockets.h
@@ -1,6 +1,6 @@
/* sockets.h - wrappers for Windows socket functions
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/spawn.c b/lib/spawn.c
new file mode 100644
index 000000000..bb2308dfc
--- /dev/null
+++ b/lib/spawn.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 2000, 2009-2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <spawn.h>
+
+#include "spawn_int.h"
+
+/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
+ Before running the process perform the actions described in FILE-ACTIONS. */
+int
+posix_spawn (pid_t *pid, const char *path,
+ const posix_spawn_file_actions_t *file_actions,
+ const posix_spawnattr_t *attrp, char *const argv[],
+ char *const envp[])
+{
+ return __spawni (pid, path, file_actions, attrp,
+ (const char * const *) argv, (const char * const *) envp, 0);
+}
diff --git a/lib/spawn.h b/lib/spawn.h
new file mode 100644
index 000000000..c0757d3e4
--- /dev/null
+++ b/lib/spawn.h
@@ -0,0 +1,1499 @@
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+/* Definitions for POSIX spawn interface.
+ Copyright (C) 2000, 2003-2004, 2008-2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#if __GNUC__ >= 3
+#pragma GCC system_header
+#endif
+
+
+#if defined _GL_ALREADY_INCLUDING_SPAWN_H
+/* Special invocation convention:
+ On OS/2 kLIBC, <spawn.h> includes <signal.h>. Then <signal.h> ->
+ <pthread.h> -> <sched.h> -> <spawn.h> are included by GNULIB.
+ In this situation, struct sched_param is not yet defined. */
+
+#include_next <spawn.h>
+
+#else
+
+#ifndef _GL_SPAWN_H
+/* Normal invocation convention. */
+
+/* The include_next requires a split double-inclusion guard. */
+#if 1
+
+# define _GL_ALREADY_INCLUDING_SPAWN_H
+
+# include_next <spawn.h>
+
+# define _GL_ALREADY_INCLUDING_SPAWN_H
+
+#endif
+
+#ifndef _GL_SPAWN_H
+#define _GL_SPAWN_H
+
+/* Get definitions of 'struct sched_param' and 'sigset_t'.
+ But avoid namespace pollution on glibc systems. */
+#if !(defined __GLIBC__ && !defined __UCLIBC__)
+# include <sched.h>
+# include <signal.h>
+#endif
+
+#include <sys/types.h>
+
+#ifndef __THROW
+# define __THROW
+#endif
+
+/* For plain 'restrict', use glibc's __restrict if defined.
+ Otherwise, GCC 2.95 and later have "__restrict"; C99 compilers have
+ "restrict", and "configure" may have defined "restrict".
+ Other compilers use __restrict, __restrict__, and _Restrict, and
+ 'configure' might #define 'restrict' to those words, so pick a
+ different name. */
+#ifndef _Restrict_
+# if defined __restrict \
+ || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \
+ || __clang_major__ >= 3
+# define _Restrict_ __restrict
+# elif 199901L <= __STDC_VERSION__ || defined restrict
+# define _Restrict_ restrict
+# else
+# define _Restrict_
+# endif
+#endif
+/* For the ISO C99 syntax
+ array_name[restrict]
+ use glibc's __restrict_arr if available.
+ Otherwise, GCC 3.1 and clang support this syntax (but not in C++ mode).
+ Other ISO C99 compilers support it as well. */
+#ifndef _Restrict_arr_
+# ifdef __restrict_arr
+# define _Restrict_arr_ __restrict_arr
+# elif ((199901L <= __STDC_VERSION__ \
+ || 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \
+ || __clang_major__ >= 3) \
+ && !defined __cplusplus)
+# define _Restrict_arr_ _Restrict_
+# else
+# define _Restrict_arr_
+# endif
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+/* C++ compatible function declaration macros.
+ Copyright (C) 2010-2022 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_CXXDEFS_H
+#define _GL_CXXDEFS_H
+
+/* Begin/end the GNULIB_NAMESPACE namespace. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
+# define _GL_END_NAMESPACE }
+#else
+# define _GL_BEGIN_NAMESPACE
+# define _GL_END_NAMESPACE
+#endif
+
+/* The three most frequent use cases of these macros are:
+
+ * For providing a substitute for a function that is missing on some
+ platforms, but is declared and works fine on the platforms on which
+ it exists:
+
+ #if @GNULIB_FOO@
+ # if !@HAVE_FOO@
+ _GL_FUNCDECL_SYS (foo, ...);
+ # endif
+ _GL_CXXALIAS_SYS (foo, ...);
+ _GL_CXXALIASWARN (foo);
+ #elif defined GNULIB_POSIXCHECK
+ ...
+ #endif
+
+ * For providing a replacement for a function that exists on all platforms,
+ but is broken/insufficient and needs to be replaced on some platforms:
+
+ #if @GNULIB_FOO@
+ # if @REPLACE_FOO@
+ # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+ # undef foo
+ # define foo rpl_foo
+ # endif
+ _GL_FUNCDECL_RPL (foo, ...);
+ _GL_CXXALIAS_RPL (foo, ...);
+ # else
+ _GL_CXXALIAS_SYS (foo, ...);
+ # endif
+ _GL_CXXALIASWARN (foo);
+ #elif defined GNULIB_POSIXCHECK
+ ...
+ #endif
+
+ * For providing a replacement for a function that exists on some platforms
+ but is broken/insufficient and needs to be replaced on some of them and
+ is additionally either missing or undeclared on some other platforms:
+
+ #if @GNULIB_FOO@
+ # if @REPLACE_FOO@
+ # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+ # undef foo
+ # define foo rpl_foo
+ # endif
+ _GL_FUNCDECL_RPL (foo, ...);
+ _GL_CXXALIAS_RPL (foo, ...);
+ # else
+ # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
+ _GL_FUNCDECL_SYS (foo, ...);
+ # endif
+ _GL_CXXALIAS_SYS (foo, ...);
+ # endif
+ _GL_CXXALIASWARN (foo);
+ #elif defined GNULIB_POSIXCHECK
+ ...
+ #endif
+*/
+
+/* _GL_EXTERN_C declaration;
+ performs the declaration with C linkage. */
+#if defined __cplusplus
+# define _GL_EXTERN_C extern "C"
+#else
+# define _GL_EXTERN_C extern
+#endif
+
+/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
+ declares a replacement function, named rpl_func, with the given prototype,
+ consisting of return type, parameters, and attributes.
+ Example:
+ _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
+ _GL_ARG_NONNULL ((1)));
+ */
+#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
+ _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
+#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
+ _GL_EXTERN_C rettype rpl_func parameters_and_attributes
+
+/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
+ declares the system function, named func, with the given prototype,
+ consisting of return type, parameters, and attributes.
+ Example:
+ _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
+ _GL_ARG_NONNULL ((1)));
+ */
+#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
+ _GL_EXTERN_C rettype func parameters_and_attributes
+
+/* _GL_CXXALIAS_RPL (func, rettype, parameters);
+ declares a C++ alias called GNULIB_NAMESPACE::func
+ that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
+ Example:
+ _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
+
+ Wrapping rpl_func in an object with an inline conversion operator
+ avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
+ actually used in the program. */
+#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
+ _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return ::rpl_func; \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_MDA (func, rettype, parameters);
+ is to be used when func is a Microsoft deprecated alias, on native Windows.
+ It declares a C++ alias called GNULIB_NAMESPACE::func
+ that redirects to _func, if GNULIB_NAMESPACE is defined.
+ Example:
+ _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
+ */
+#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
+ _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
+
+/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
+ is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
+ except that the C function rpl_func may have a slightly different
+ declaration. A cast is used to silence the "invalid conversion" error
+ that would otherwise occur. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast<type>(::rpl_func); \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
+ is like _GL_CXXALIAS_MDA (func, rettype, parameters);
+ except that the C function func may have a slightly different declaration.
+ A cast is used to silence the "invalid conversion" error that would
+ otherwise occur. */
+#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
+ _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
+
+/* _GL_CXXALIAS_SYS (func, rettype, parameters);
+ declares a C++ alias called GNULIB_NAMESPACE::func
+ that redirects to the system provided function func, if GNULIB_NAMESPACE
+ is defined.
+ Example:
+ _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
+
+ Wrapping func in an object with an inline conversion operator
+ avoids a reference to func unless GNULIB_NAMESPACE::func is
+ actually used in the program. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return ::func; \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
+ is like _GL_CXXALIAS_SYS (func, rettype, parameters);
+ except that the C function func may have a slightly different declaration.
+ A cast is used to silence the "invalid conversion" error that would
+ otherwise occur. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast<type>(::func); \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
+ is like _GL_CXXALIAS_SYS (func, rettype, parameters);
+ except that the C function is picked among a set of overloaded functions,
+ namely the one with rettype2 and parameters2. Two consecutive casts
+ are used to silence the "cannot find a match" and "invalid conversion"
+ errors that would otherwise occur. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+ /* The outer cast must be a reinterpret_cast.
+ The inner cast: When the function is defined as a set of overloaded
+ functions, it works as a static_cast<>, choosing the designated variant.
+ When the function is defined as a single variant, it works as a
+ reinterpret_cast<>. The parenthesized cast syntax works both ways. */
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIASWARN (func);
+ causes a warning to be emitted when ::func is used but not when
+ GNULIB_NAMESPACE::func is used. func must be defined without overloaded
+ variants. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIASWARN(func) \
+ _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
+# define _GL_CXXALIASWARN_1(func,namespace) \
+ _GL_CXXALIASWARN_2 (func, namespace)
+/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+ we enable the warning only when not optimizing. */
+# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
+# define _GL_CXXALIASWARN_2(func,namespace) \
+ _GL_WARN_ON_USE (func, \
+ "The symbol ::" #func " refers to the system function. " \
+ "Use " #namespace "::" #func " instead.")
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+# define _GL_CXXALIASWARN_2(func,namespace) \
+ extern __typeof__ (func) func
+# else
+# define _GL_CXXALIASWARN_2(func,namespace) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+# endif
+#else
+# define _GL_CXXALIASWARN(func) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
+ causes a warning to be emitted when the given overloaded variant of ::func
+ is used but not when GNULIB_NAMESPACE::func is used. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
+ _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
+ GNULIB_NAMESPACE)
+# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
+ _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
+/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+ we enable the warning only when not optimizing. */
+# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+ _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
+ "The symbol ::" #func " refers to the system function. " \
+ "Use " #namespace "::" #func " instead.")
+# else
+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+# endif
+#else
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+#endif /* _GL_CXXDEFS_H */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+/* A C macro for declaring that specific arguments must not be NULL.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
+ that the values passed as arguments n, ..., m must be non-NULL pointers.
+ n = 1 stands for the first argument, n = 2 for the second argument etc. */
+#ifndef _GL_ARG_NONNULL
+# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
+# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
+# else
+# define _GL_ARG_NONNULL(params)
+# endif
+#endif
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+/* A C macro for emitting warnings if a function is used.
+ Copyright (C) 2010-2022 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
+ for FUNCTION which will then trigger a compiler warning containing
+ the text of "literal string" anywhere that function is called, if
+ supported by the compiler. If the compiler does not support this
+ feature, the macro expands to an unused extern declaration.
+
+ _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
+ attribute used in _GL_WARN_ON_USE. If the compiler does not support
+ this feature, it expands to empty.
+
+ These macros are useful for marking a function as a potential
+ portability trap, with the intent that "literal string" include
+ instructions on the replacement function that should be used
+ instead.
+ _GL_WARN_ON_USE is for functions with 'extern' linkage.
+ _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
+ linkage.
+
+ However, one of the reasons that a function is a portability trap is
+ if it has the wrong signature. Declaring FUNCTION with a different
+ signature in C is a compilation error, so this macro must use the
+ same type as any existing declaration so that programs that avoid
+ the problematic FUNCTION do not fail to compile merely because they
+ included a header that poisoned the function. But this implies that
+ _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
+ have a declaration. Use of this macro implies that there must not
+ be any other macro hiding the declaration of FUNCTION; but
+ undefining FUNCTION first is part of the poisoning process anyway
+ (although for symbols that are provided only via a macro, the result
+ is a compilation error rather than a warning containing
+ "literal string"). Also note that in C++, it is only safe to use if
+ FUNCTION has no overloads.
+
+ For an example, it is possible to poison 'getline' by:
+ - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
+ [getline]) in configure.ac, which potentially defines
+ HAVE_RAW_DECL_GETLINE
+ - adding this code to a header that wraps the system <stdio.h>:
+ #undef getline
+ #if HAVE_RAW_DECL_GETLINE
+ _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
+ "not universally present; use the gnulib module getline");
+ #endif
+
+ It is not possible to directly poison global variables. But it is
+ possible to write a wrapper accessor function, and poison that
+ (less common usage, like &environ, will cause a compilation error
+ rather than issue the nice warning, but the end result of informing
+ the developer about their portability problem is still achieved):
+ #if HAVE_RAW_DECL_ENVIRON
+ static char ***
+ rpl_environ (void) { return &environ; }
+ _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
+ # undef environ
+ # define environ (*rpl_environ ())
+ #endif
+ or better (avoiding contradictory use of 'static' and 'extern'):
+ #if HAVE_RAW_DECL_ENVIRON
+ static char ***
+ _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
+ rpl_environ (void) { return &environ; }
+ # undef environ
+ # define environ (*rpl_environ ())
+ #endif
+ */
+#ifndef _GL_WARN_ON_USE
+
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
+/* A compiler attribute is available in gcc versions 4.3.0 and later. */
+# define _GL_WARN_ON_USE(function, message) \
+_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
+# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
+ __attribute__ ((__warning__ (message)))
+# elif __clang_major__ >= 4
+/* Another compiler attribute is available in clang. */
+# define _GL_WARN_ON_USE(function, message) \
+_GL_WARN_EXTERN_C __typeof__ (function) function \
+ __attribute__ ((__diagnose_if__ (1, message, "warning")))
+# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
+ __attribute__ ((__diagnose_if__ (1, message, "warning")))
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+/* Verify the existence of the function. */
+# define _GL_WARN_ON_USE(function, message) \
+_GL_WARN_EXTERN_C __typeof__ (function) function
+# define _GL_WARN_ON_USE_ATTRIBUTE(message)
+# else /* Unsupported. */
+# define _GL_WARN_ON_USE(function, message) \
+_GL_WARN_EXTERN_C int _gl_warn_on_use
+# define _GL_WARN_ON_USE_ATTRIBUTE(message)
+# endif
+#endif
+
+/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
+ is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
+ function is declared with the given prototype, consisting of return type,
+ parameters, and attributes.
+ This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
+ not work in this case. */
+#ifndef _GL_WARN_ON_USE_CXX
+# if !defined __cplusplus
+# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+ _GL_WARN_ON_USE (function, msg)
+# else
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
+/* A compiler attribute is available in gcc versions 4.3.0 and later. */
+# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+extern rettype_gcc function parameters_and_attributes \
+ __attribute__ ((__warning__ (msg)))
+# elif __clang_major__ >= 4
+/* Another compiler attribute is available in clang. */
+# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+extern rettype_clang function parameters_and_attributes \
+ __attribute__ ((__diagnose_if__ (1, msg, "warning")))
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+/* Verify the existence of the function. */
+# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+extern rettype_gcc function parameters_and_attributes
+# else /* Unsupported. */
+# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+_GL_WARN_EXTERN_C int _gl_warn_on_use
+# endif
+# endif
+#endif
+
+/* _GL_WARN_EXTERN_C declaration;
+ performs the declaration with C linkage. */
+#ifndef _GL_WARN_EXTERN_C
+# if defined __cplusplus
+# define _GL_WARN_EXTERN_C extern "C"
+# else
+# define _GL_WARN_EXTERN_C extern
+# endif
+#endif
+
+
+/* Data structure to contain attributes for thread creation. */
+#if 0 || (1 && !1)
+# define posix_spawnattr_t rpl_posix_spawnattr_t
+#endif
+#if 0 || !1 || !1
+# if !GNULIB_defined_posix_spawnattr_t
+typedef struct
+{
+ short int _flags;
+ pid_t _pgrp;
+ sigset_t _sd;
+ sigset_t _ss;
+ struct sched_param _sp;
+ int _policy;
+ int __pad[16];
+} posix_spawnattr_t;
+# define GNULIB_defined_posix_spawnattr_t 1
+# endif
+#endif
+
+
+/* Data structure to contain information about the actions to be
+ performed in the new process with respect to file descriptors. */
+#if 0 || (1 && !1)
+# define posix_spawn_file_actions_t rpl_posix_spawn_file_actions_t
+#endif
+#if 0 || !1 || !1
+# if !GNULIB_defined_posix_spawn_file_actions_t
+typedef struct
+{
+ int _allocated;
+ int _used;
+ struct __spawn_action *_actions;
+ int __pad[16];
+} posix_spawn_file_actions_t;
+# define GNULIB_defined_posix_spawn_file_actions_t 1
+# endif
+#endif
+
+
+/* Flags to be set in the 'posix_spawnattr_t'. */
+#if 1
+/* Use the values from the system, but provide the missing ones. */
+# ifndef POSIX_SPAWN_SETSCHEDPARAM
+# define POSIX_SPAWN_SETSCHEDPARAM 0
+# endif
+# ifndef POSIX_SPAWN_SETSCHEDULER
+# define POSIX_SPAWN_SETSCHEDULER 0
+# endif
+#else
+# if 0
+/* Use the values from the system, for better compatibility. */
+/* But this implementation does not support AIX extensions. */
+# undef POSIX_SPAWN_FORK_HANDLERS
+# else
+# define POSIX_SPAWN_RESETIDS 0x01
+# define POSIX_SPAWN_SETPGROUP 0x02
+# define POSIX_SPAWN_SETSIGDEF 0x04
+# define POSIX_SPAWN_SETSIGMASK 0x08
+# define POSIX_SPAWN_SETSCHEDPARAM 0x10
+# define POSIX_SPAWN_SETSCHEDULER 0x20
+# endif
+#endif
+/* A GNU extension. Use the next free bit position. */
+#ifndef POSIX_SPAWN_USEVFORK
+# define POSIX_SPAWN_USEVFORK \
+ ((POSIX_SPAWN_RESETIDS | (POSIX_SPAWN_RESETIDS - 1) \
+ | POSIX_SPAWN_SETPGROUP | (POSIX_SPAWN_SETPGROUP - 1) \
+ | POSIX_SPAWN_SETSIGDEF | (POSIX_SPAWN_SETSIGDEF - 1) \
+ | POSIX_SPAWN_SETSIGMASK | (POSIX_SPAWN_SETSIGMASK - 1) \
+ | POSIX_SPAWN_SETSCHEDPARAM \
+ | (POSIX_SPAWN_SETSCHEDPARAM > 0 ? POSIX_SPAWN_SETSCHEDPARAM - 1 : 0) \
+ | POSIX_SPAWN_SETSCHEDULER \
+ | (POSIX_SPAWN_SETSCHEDULER > 0 ? POSIX_SPAWN_SETSCHEDULER - 1 : 0)) \
+ + 1)
+#endif
+#if !GNULIB_defined_verify_POSIX_SPAWN_USEVFORK_no_overlap
+typedef int verify_POSIX_SPAWN_USEVFORK_no_overlap
+ [(((POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP
+ | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK
+ | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER)
+ & POSIX_SPAWN_USEVFORK)
+ == 0)
+ ? 1 : -1];
+# define GNULIB_defined_verify_POSIX_SPAWN_USEVFORK_no_overlap 1
+#endif
+
+
+#if 0
+/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
+ Before running the process perform the actions described in FILE-ACTIONS.
+
+ This function is a possible cancellation points and therefore not
+ marked with __THROW. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn rpl_posix_spawn
+# endif
+_GL_FUNCDECL_RPL (posix_spawn, int,
+ (pid_t *_Restrict_ __pid,
+ const char *_Restrict_ __path,
+ const posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const posix_spawnattr_t *_Restrict_ __attrp,
+ char *const argv[_Restrict_arr_],
+ char *const envp[_Restrict_arr_])
+ _GL_ARG_NONNULL ((2, 5, 6)));
+_GL_CXXALIAS_RPL (posix_spawn, int,
+ (pid_t *_Restrict_ __pid,
+ const char *_Restrict_ __path,
+ const posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const posix_spawnattr_t *_Restrict_ __attrp,
+ char *const argv[_Restrict_arr_],
+ char *const envp[_Restrict_arr_]));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawn, int,
+ (pid_t *_Restrict_ __pid,
+ const char *_Restrict_ __path,
+ const posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const posix_spawnattr_t *_Restrict_ __attrp,
+ char *const argv[_Restrict_arr_],
+ char *const envp[_Restrict_arr_])
+ _GL_ARG_NONNULL ((2, 5, 6)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn, int,
+ (pid_t *_Restrict_ __pid,
+ const char *_Restrict_ __path,
+ const posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const posix_spawnattr_t *_Restrict_ __attrp,
+ char *const argv[_Restrict_arr_],
+ char *const envp[_Restrict_arr_]));
+# endif
+_GL_CXXALIASWARN (posix_spawn);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn
+# if HAVE_RAW_DECL_POSIX_SPAWN
+_GL_WARN_ON_USE (posix_spawn, "posix_spawn is unportable - "
+ "use gnulib module posix_spawn for portability");
+# endif
+#endif
+
+#if 1
+/* Similar to 'posix_spawn' but search for FILE in the PATH.
+
+ This function is a possible cancellation points and therefore not
+ marked with __THROW. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnp rpl_posix_spawnp
+# endif
+_GL_FUNCDECL_RPL (posix_spawnp, int,
+ (pid_t *__pid, const char *__file,
+ const posix_spawn_file_actions_t *__file_actions,
+ const posix_spawnattr_t *__attrp,
+ char *const argv[], char *const envp[])
+ _GL_ARG_NONNULL ((2, 5, 6)));
+_GL_CXXALIAS_RPL (posix_spawnp, int,
+ (pid_t *__pid, const char *__file,
+ const posix_spawn_file_actions_t *__file_actions,
+ const posix_spawnattr_t *__attrp,
+ char *const argv[], char *const envp[]));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawnp, int,
+ (pid_t *__pid, const char *__file,
+ const posix_spawn_file_actions_t *__file_actions,
+ const posix_spawnattr_t *__attrp,
+ char *const argv[], char *const envp[])
+ _GL_ARG_NONNULL ((2, 5, 6)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnp, int,
+ (pid_t *__pid, const char *__file,
+ const posix_spawn_file_actions_t *__file_actions,
+ const posix_spawnattr_t *__attrp,
+ char *const argv[], char *const envp[]));
+# endif
+_GL_CXXALIASWARN (posix_spawnp);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnp
+# if HAVE_RAW_DECL_POSIX_SPAWNP
+_GL_WARN_ON_USE (posix_spawnp, "posix_spawnp is unportable - "
+ "use gnulib module posix_spawnp for portability");
+# endif
+#endif
+
+
+#if 0
+/* Initialize data structure with attributes for 'spawn' to default values. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_init rpl_posix_spawnattr_init
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_init, int, (posix_spawnattr_t *__attr)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawnattr_init, int, (posix_spawnattr_t *__attr));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawnattr_init, int, (posix_spawnattr_t *__attr)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_init, int, (posix_spawnattr_t *__attr));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_init);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_init
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_INIT
+_GL_WARN_ON_USE (posix_spawnattr_init, "posix_spawnattr_init is unportable - "
+ "use gnulib module posix_spawnattr_init for portability");
+# endif
+#endif
+
+#if 0
+/* Free resources associated with ATTR. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_destroy rpl_posix_spawnattr_destroy
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_destroy);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_destroy
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_DESTROY
+_GL_WARN_ON_USE (posix_spawnattr_destroy,
+ "posix_spawnattr_destroy is unportable - "
+ "use gnulib module posix_spawnattr_destroy for portability");
+# endif
+#endif
+
+#if 0
+/* Store signal mask for signals with default handling from ATTR in
+ SIGDEFAULT. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_getsigdefault rpl_posix_spawnattr_getsigdefault
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_getsigdefault, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigdefault)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_getsigdefault, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigdefault));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawnattr_getsigdefault, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigdefault)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_getsigdefault, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigdefault));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_getsigdefault);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_getsigdefault
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGDEFAULT
+_GL_WARN_ON_USE (posix_spawnattr_getsigdefault,
+ "posix_spawnattr_getsigdefault is unportable - "
+ "use gnulib module posix_spawnattr_getsigdefault for portability");
+# endif
+#endif
+
+#if 0
+/* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_setsigdefault rpl_posix_spawnattr_setsigdefault
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_setsigdefault, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigdefault)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_setsigdefault, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigdefault));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawnattr_setsigdefault, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigdefault)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_setsigdefault, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigdefault));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_setsigdefault);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_setsigdefault
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGDEFAULT
+_GL_WARN_ON_USE (posix_spawnattr_setsigdefault,
+ "posix_spawnattr_setsigdefault is unportable - "
+ "use gnulib module posix_spawnattr_setsigdefault for portability");
+# endif
+#endif
+
+#if 0
+/* Store signal mask for the new process from ATTR in SIGMASK. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_getsigmask rpl_posix_spawnattr_getsigmask
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_getsigmask, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigmask)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_getsigmask, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigmask));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawnattr_getsigmask, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigmask)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_getsigmask, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigmask));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_getsigmask);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_getsigmask
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGMASK
+_GL_WARN_ON_USE (posix_spawnattr_getsigmask,
+ "posix_spawnattr_getsigmask is unportable - "
+ "use gnulib module posix_spawnattr_getsigmask for portability");
+# endif
+#endif
+
+#if 0
+/* Set signal mask for the new process in ATTR to SIGMASK. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_setsigmask rpl_posix_spawnattr_setsigmask
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_setsigmask, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigmask)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_setsigmask, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigmask));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawnattr_setsigmask, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigmask)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_setsigmask, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigmask));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_setsigmask);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_setsigmask
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGMASK
+_GL_WARN_ON_USE (posix_spawnattr_setsigmask,
+ "posix_spawnattr_setsigmask is unportable - "
+ "use gnulib module posix_spawnattr_setsigmask for portability");
+# endif
+#endif
+
+#if 0
+/* Get flag word from the attribute structure. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_getflags rpl_posix_spawnattr_getflags
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_getflags, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ short int *_Restrict_ __flags)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_getflags, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ short int *_Restrict_ __flags));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawnattr_getflags, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ short int *_Restrict_ __flags)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_getflags, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ short int *_Restrict_ __flags));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_getflags);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_getflags
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETFLAGS
+_GL_WARN_ON_USE (posix_spawnattr_getflags,
+ "posix_spawnattr_getflags is unportable - "
+ "use gnulib module posix_spawnattr_getflags for portability");
+# endif
+#endif
+
+#if 0
+/* Store flags in the attribute structure. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_setflags rpl_posix_spawnattr_setflags
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_setflags, int,
+ (posix_spawnattr_t *__attr, short int __flags)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawnattr_setflags, int,
+ (posix_spawnattr_t *__attr, short int __flags));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawnattr_setflags, int,
+ (posix_spawnattr_t *__attr, short int __flags)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_setflags, int,
+ (posix_spawnattr_t *__attr, short int __flags));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_setflags);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_setflags
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETFLAGS
+_GL_WARN_ON_USE (posix_spawnattr_setflags,
+ "posix_spawnattr_setflags is unportable - "
+ "use gnulib module posix_spawnattr_setflags for portability");
+# endif
+#endif
+
+#if 0
+/* Get process group ID from the attribute structure. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_getpgroup rpl_posix_spawnattr_getpgroup
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_getpgroup, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ pid_t *_Restrict_ __pgroup)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_getpgroup, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ pid_t *_Restrict_ __pgroup));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawnattr_getpgroup, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ pid_t *_Restrict_ __pgroup)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_getpgroup, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ pid_t *_Restrict_ __pgroup));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_getpgroup);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_getpgroup
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETPGROUP
+_GL_WARN_ON_USE (posix_spawnattr_getpgroup,
+ "posix_spawnattr_getpgroup is unportable - "
+ "use gnulib module posix_spawnattr_getpgroup for portability");
+# endif
+#endif
+
+#if 0
+/* Store process group ID in the attribute structure. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_setpgroup rpl_posix_spawnattr_setpgroup
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_setpgroup, int,
+ (posix_spawnattr_t *__attr, pid_t __pgroup)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawnattr_setpgroup, int,
+ (posix_spawnattr_t *__attr, pid_t __pgroup));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawnattr_setpgroup, int,
+ (posix_spawnattr_t *__attr, pid_t __pgroup)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_setpgroup, int,
+ (posix_spawnattr_t *__attr, pid_t __pgroup));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_setpgroup);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_setpgroup
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETPGROUP
+_GL_WARN_ON_USE (posix_spawnattr_setpgroup,
+ "posix_spawnattr_setpgroup is unportable - "
+ "use gnulib module posix_spawnattr_setpgroup for portability");
+# endif
+#endif
+
+#if 0
+/* Get scheduling policy from the attribute structure. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_getschedpolicy rpl_posix_spawnattr_getschedpolicy
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_getschedpolicy, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ int *_Restrict_ __schedpolicy)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_getschedpolicy, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ int *_Restrict_ __schedpolicy));
+# else
+# if !1 || POSIX_SPAWN_SETSCHEDULER == 0
+_GL_FUNCDECL_SYS (posix_spawnattr_getschedpolicy, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ int *_Restrict_ __schedpolicy)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_getschedpolicy, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ int *_Restrict_ __schedpolicy));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (posix_spawnattr_getschedpolicy);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_getschedpolicy
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSCHEDPOLICY
+_GL_WARN_ON_USE (posix_spawnattr_getschedpolicy,
+ "posix_spawnattr_getschedpolicy is unportable - "
+ "use gnulib module posix_spawnattr_getschedpolicy for portability");
+# endif
+#endif
+
+#if 0
+/* Store scheduling policy in the attribute structure. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_setschedpolicy rpl_posix_spawnattr_setschedpolicy
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_setschedpolicy, int,
+ (posix_spawnattr_t *__attr, int __schedpolicy)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawnattr_setschedpolicy, int,
+ (posix_spawnattr_t *__attr, int __schedpolicy));
+# else
+# if !1 || POSIX_SPAWN_SETSCHEDULER == 0
+_GL_FUNCDECL_SYS (posix_spawnattr_setschedpolicy, int,
+ (posix_spawnattr_t *__attr, int __schedpolicy)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_setschedpolicy, int,
+ (posix_spawnattr_t *__attr, int __schedpolicy));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (posix_spawnattr_setschedpolicy);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_setschedpolicy
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSCHEDPOLICY
+_GL_WARN_ON_USE (posix_spawnattr_setschedpolicy,
+ "posix_spawnattr_setschedpolicy is unportable - "
+ "use gnulib module posix_spawnattr_setschedpolicy for portability");
+# endif
+#endif
+
+#if 0
+/* Get scheduling parameters from the attribute structure. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_getschedparam rpl_posix_spawnattr_getschedparam
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_getschedparam, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ struct sched_param *_Restrict_ __schedparam)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_getschedparam, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ struct sched_param *_Restrict_ __schedparam));
+# else
+# if !1 || POSIX_SPAWN_SETSCHEDPARAM == 0
+_GL_FUNCDECL_SYS (posix_spawnattr_getschedparam, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ struct sched_param *_Restrict_ __schedparam)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_getschedparam, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ struct sched_param *_Restrict_ __schedparam));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (posix_spawnattr_getschedparam);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_getschedparam
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSCHEDPARAM
+_GL_WARN_ON_USE (posix_spawnattr_getschedparam,
+ "posix_spawnattr_getschedparam is unportable - "
+ "use gnulib module posix_spawnattr_getschedparam for portability");
+# endif
+#endif
+
+#if 0
+/* Store scheduling parameters in the attribute structure. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_setschedparam rpl_posix_spawnattr_setschedparam
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_setschedparam, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const struct sched_param *_Restrict_ __schedparam)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_setschedparam, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const struct sched_param *_Restrict_ __schedparam));
+# else
+# if !1 || POSIX_SPAWN_SETSCHEDPARAM == 0
+_GL_FUNCDECL_SYS (posix_spawnattr_setschedparam, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const struct sched_param *_Restrict_ __schedparam)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_setschedparam, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const struct sched_param *_Restrict_ __schedparam));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (posix_spawnattr_setschedparam);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_setschedparam
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSCHEDPARAM
+_GL_WARN_ON_USE (posix_spawnattr_setschedparam,
+ "posix_spawnattr_setschedparam is unportable - "
+ "use gnulib module posix_spawnattr_setschedparam for portability");
+# endif
+#endif
+
+
+#if 0
+/* Initialize data structure for file attribute for 'spawn' call. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn_file_actions_init rpl_posix_spawn_file_actions_init
+# endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_init, int,
+ (posix_spawn_file_actions_t *__file_actions)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_init, int,
+ (posix_spawn_file_actions_t *__file_actions));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_init, int,
+ (posix_spawn_file_actions_t *__file_actions)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_init, int,
+ (posix_spawn_file_actions_t *__file_actions));
+# endif
+_GL_CXXALIASWARN (posix_spawn_file_actions_init);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_init
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_INIT
+_GL_WARN_ON_USE (posix_spawn_file_actions_init,
+ "posix_spawn_file_actions_init is unportable - "
+ "use gnulib module posix_spawn_file_actions_init for portability");
+# endif
+#endif
+
+#if 0
+/* Free resources associated with FILE-ACTIONS. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn_file_actions_destroy rpl_posix_spawn_file_actions_destroy
+# endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_destroy, int,
+ (posix_spawn_file_actions_t *__file_actions)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_destroy, int,
+ (posix_spawn_file_actions_t *__file_actions));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_destroy, int,
+ (posix_spawn_file_actions_t *__file_actions)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_destroy, int,
+ (posix_spawn_file_actions_t *__file_actions));
+# endif
+_GL_CXXALIASWARN (posix_spawn_file_actions_destroy);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_destroy
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_DESTROY
+_GL_WARN_ON_USE (posix_spawn_file_actions_destroy,
+ "posix_spawn_file_actions_destroy is unportable - "
+ "use gnulib module posix_spawn_file_actions_destroy for portability");
+# endif
+#endif
+
+#if 0
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ 'open' for the given file during the 'spawn' call. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn_file_actions_addopen rpl_posix_spawn_file_actions_addopen
+# endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_addopen, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd,
+ const char *_Restrict_ __path, int __oflag, mode_t __mode)
+ __THROW _GL_ARG_NONNULL ((1, 3)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_addopen, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd,
+ const char *_Restrict_ __path, int __oflag, mode_t __mode));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_addopen, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd,
+ const char *_Restrict_ __path, int __oflag, mode_t __mode)
+ __THROW _GL_ARG_NONNULL ((1, 3)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_addopen, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd,
+ const char *_Restrict_ __path, int __oflag, mode_t __mode));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (posix_spawn_file_actions_addopen);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_addopen
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN
+_GL_WARN_ON_USE (posix_spawn_file_actions_addopen,
+ "posix_spawn_file_actions_addopen is unportable - "
+ "use gnulib module posix_spawn_file_actions_addopen for portability");
+# endif
+#endif
+
+#if 0
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ 'close' for the given file descriptor during the 'spawn' call. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn_file_actions_addclose rpl_posix_spawn_file_actions_addclose
+# endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_addclose, int,
+ (posix_spawn_file_actions_t *__file_actions, int __fd)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_addclose, int,
+ (posix_spawn_file_actions_t *__file_actions, int __fd));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_addclose, int,
+ (posix_spawn_file_actions_t *__file_actions, int __fd)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_addclose, int,
+ (posix_spawn_file_actions_t *__file_actions, int __fd));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (posix_spawn_file_actions_addclose);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_addclose
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE
+_GL_WARN_ON_USE (posix_spawn_file_actions_addclose,
+ "posix_spawn_file_actions_addclose is unportable - "
+ "use gnulib module posix_spawn_file_actions_addclose for portability");
+# endif
+#endif
+
+#if 0
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ 'dup2' for the given file descriptors during the 'spawn' call. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn_file_actions_adddup2 rpl_posix_spawn_file_actions_adddup2
+# endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_adddup2, int,
+ (posix_spawn_file_actions_t *__file_actions,
+ int __fd, int __newfd)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_adddup2, int,
+ (posix_spawn_file_actions_t *__file_actions,
+ int __fd, int __newfd));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_adddup2, int,
+ (posix_spawn_file_actions_t *__file_actions,
+ int __fd, int __newfd)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_adddup2, int,
+ (posix_spawn_file_actions_t *__file_actions,
+ int __fd, int __newfd));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (posix_spawn_file_actions_adddup2);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_adddup2
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2
+_GL_WARN_ON_USE (posix_spawn_file_actions_adddup2,
+ "posix_spawn_file_actions_adddup2 is unportable - "
+ "use gnulib module posix_spawn_file_actions_adddup2 for portability");
+# endif
+#endif
+
+#if 0
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ 'chdir' to the given directory during the 'spawn' call. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn_file_actions_addchdir rpl_posix_spawn_file_actions_addchdir
+# endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_addchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const char *_Restrict_ __path)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_addchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const char *_Restrict_ __path));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_addchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const char *_Restrict_ __path)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_addchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const char *_Restrict_ __path));
+# endif
+_GL_CXXALIASWARN (posix_spawn_file_actions_addchdir);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_addchdir
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR
+_GL_WARN_ON_USE (posix_spawn_file_actions_addchdir,
+ "posix_spawn_file_actions_addchdir is unportable - "
+ "use gnulib module posix_spawn_file_actions_addchdir for portability");
+# endif
+#endif
+
+#if 0
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ 'fchdir' to the given directory during the 'spawn' call. */
+# if 0
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn_file_actions_addfchdir rpl_posix_spawn_file_actions_addfchdir
+# endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_addfchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_addfchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd));
+# else
+# if !1
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_addfchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_addfchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd));
+# endif
+_GL_CXXALIASWARN (posix_spawn_file_actions_addfchdir);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_addfchdir
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR
+_GL_WARN_ON_USE (posix_spawn_file_actions_addfchdir,
+ "posix_spawn_file_actions_addfchdir is unportable - "
+ "use gnulib module posix_spawn_file_actions_addfchdir for portability");
+# endif
+#endif
+
+
+#endif /* _GL_SPAWN_H */
+#endif /* _GL_SPAWN_H */
+#endif
diff --git a/lib/spawn.in.h b/lib/spawn.in.h
new file mode 100644
index 000000000..c1acf6043
--- /dev/null
+++ b/lib/spawn.in.h
@@ -0,0 +1,992 @@
+/* Definitions for POSIX spawn interface.
+ Copyright (C) 2000, 2003-2004, 2008-2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if defined _GL_ALREADY_INCLUDING_SPAWN_H
+/* Special invocation convention:
+ On OS/2 kLIBC, <spawn.h> includes <signal.h>. Then <signal.h> ->
+ <pthread.h> -> <sched.h> -> <spawn.h> are included by GNULIB.
+ In this situation, struct sched_param is not yet defined. */
+
+#@INCLUDE_NEXT@ @NEXT_SPAWN_H@
+
+#else
+
+#ifndef _@GUARD_PREFIX@_SPAWN_H
+/* Normal invocation convention. */
+
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_SPAWN_H@
+
+# define _GL_ALREADY_INCLUDING_SPAWN_H
+
+# @INCLUDE_NEXT@ @NEXT_SPAWN_H@
+
+# define _GL_ALREADY_INCLUDING_SPAWN_H
+
+#endif
+
+#ifndef _@GUARD_PREFIX@_SPAWN_H
+#define _@GUARD_PREFIX@_SPAWN_H
+
+/* Get definitions of 'struct sched_param' and 'sigset_t'.
+ But avoid namespace pollution on glibc systems. */
+#if !(defined __GLIBC__ && !defined __UCLIBC__)
+# include <sched.h>
+# include <signal.h>
+#endif
+
+#include <sys/types.h>
+
+#ifndef __THROW
+# define __THROW
+#endif
+
+/* For plain 'restrict', use glibc's __restrict if defined.
+ Otherwise, GCC 2.95 and later have "__restrict"; C99 compilers have
+ "restrict", and "configure" may have defined "restrict".
+ Other compilers use __restrict, __restrict__, and _Restrict, and
+ 'configure' might #define 'restrict' to those words, so pick a
+ different name. */
+#ifndef _Restrict_
+# if defined __restrict \
+ || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \
+ || __clang_major__ >= 3
+# define _Restrict_ __restrict
+# elif 199901L <= __STDC_VERSION__ || defined restrict
+# define _Restrict_ restrict
+# else
+# define _Restrict_
+# endif
+#endif
+/* For the ISO C99 syntax
+ array_name[restrict]
+ use glibc's __restrict_arr if available.
+ Otherwise, GCC 3.1 and clang support this syntax (but not in C++ mode).
+ Other ISO C99 compilers support it as well. */
+#ifndef _Restrict_arr_
+# ifdef __restrict_arr
+# define _Restrict_arr_ __restrict_arr
+# elif ((199901L <= __STDC_VERSION__ \
+ || 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \
+ || __clang_major__ >= 3) \
+ && !defined __cplusplus)
+# define _Restrict_arr_ _Restrict_
+# else
+# define _Restrict_arr_
+# endif
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+
+/* Data structure to contain attributes for thread creation. */
+#if @REPLACE_POSIX_SPAWN@ || (@HAVE_POSIX_SPAWNATTR_T@ && !@HAVE_POSIX_SPAWN@)
+# define posix_spawnattr_t rpl_posix_spawnattr_t
+#endif
+#if @REPLACE_POSIX_SPAWN@ || !@HAVE_POSIX_SPAWNATTR_T@ || !@HAVE_POSIX_SPAWN@
+# if !GNULIB_defined_posix_spawnattr_t
+typedef struct
+{
+ short int _flags;
+ pid_t _pgrp;
+ sigset_t _sd;
+ sigset_t _ss;
+ struct sched_param _sp;
+ int _policy;
+ int __pad[16];
+} posix_spawnattr_t;
+# define GNULIB_defined_posix_spawnattr_t 1
+# endif
+#endif
+
+
+/* Data structure to contain information about the actions to be
+ performed in the new process with respect to file descriptors. */
+#if @REPLACE_POSIX_SPAWN@ || (@HAVE_POSIX_SPAWN_FILE_ACTIONS_T@ && !@HAVE_POSIX_SPAWN@)
+# define posix_spawn_file_actions_t rpl_posix_spawn_file_actions_t
+#endif
+#if @REPLACE_POSIX_SPAWN@ || !@HAVE_POSIX_SPAWN_FILE_ACTIONS_T@ || !@HAVE_POSIX_SPAWN@
+# if !GNULIB_defined_posix_spawn_file_actions_t
+typedef struct
+{
+ int _allocated;
+ int _used;
+ struct __spawn_action *_actions;
+ int __pad[16];
+} posix_spawn_file_actions_t;
+# define GNULIB_defined_posix_spawn_file_actions_t 1
+# endif
+#endif
+
+
+/* Flags to be set in the 'posix_spawnattr_t'. */
+#if @HAVE_POSIX_SPAWN@
+/* Use the values from the system, but provide the missing ones. */
+# ifndef POSIX_SPAWN_SETSCHEDPARAM
+# define POSIX_SPAWN_SETSCHEDPARAM 0
+# endif
+# ifndef POSIX_SPAWN_SETSCHEDULER
+# define POSIX_SPAWN_SETSCHEDULER 0
+# endif
+#else
+# if @REPLACE_POSIX_SPAWN@
+/* Use the values from the system, for better compatibility. */
+/* But this implementation does not support AIX extensions. */
+# undef POSIX_SPAWN_FORK_HANDLERS
+# else
+# define POSIX_SPAWN_RESETIDS 0x01
+# define POSIX_SPAWN_SETPGROUP 0x02
+# define POSIX_SPAWN_SETSIGDEF 0x04
+# define POSIX_SPAWN_SETSIGMASK 0x08
+# define POSIX_SPAWN_SETSCHEDPARAM 0x10
+# define POSIX_SPAWN_SETSCHEDULER 0x20
+# endif
+#endif
+/* A GNU extension. Use the next free bit position. */
+#ifndef POSIX_SPAWN_USEVFORK
+# define POSIX_SPAWN_USEVFORK \
+ ((POSIX_SPAWN_RESETIDS | (POSIX_SPAWN_RESETIDS - 1) \
+ | POSIX_SPAWN_SETPGROUP | (POSIX_SPAWN_SETPGROUP - 1) \
+ | POSIX_SPAWN_SETSIGDEF | (POSIX_SPAWN_SETSIGDEF - 1) \
+ | POSIX_SPAWN_SETSIGMASK | (POSIX_SPAWN_SETSIGMASK - 1) \
+ | POSIX_SPAWN_SETSCHEDPARAM \
+ | (POSIX_SPAWN_SETSCHEDPARAM > 0 ? POSIX_SPAWN_SETSCHEDPARAM - 1 : 0) \
+ | POSIX_SPAWN_SETSCHEDULER \
+ | (POSIX_SPAWN_SETSCHEDULER > 0 ? POSIX_SPAWN_SETSCHEDULER - 1 : 0)) \
+ + 1)
+#endif
+#if !GNULIB_defined_verify_POSIX_SPAWN_USEVFORK_no_overlap
+typedef int verify_POSIX_SPAWN_USEVFORK_no_overlap
+ [(((POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP
+ | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK
+ | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER)
+ & POSIX_SPAWN_USEVFORK)
+ == 0)
+ ? 1 : -1];
+# define GNULIB_defined_verify_POSIX_SPAWN_USEVFORK_no_overlap 1
+#endif
+
+
+#if @GNULIB_POSIX_SPAWN@
+/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
+ Before running the process perform the actions described in FILE-ACTIONS.
+
+ This function is a possible cancellation points and therefore not
+ marked with __THROW. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn rpl_posix_spawn
+# endif
+_GL_FUNCDECL_RPL (posix_spawn, int,
+ (pid_t *_Restrict_ __pid,
+ const char *_Restrict_ __path,
+ const posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const posix_spawnattr_t *_Restrict_ __attrp,
+ char *const argv[_Restrict_arr_],
+ char *const envp[_Restrict_arr_])
+ _GL_ARG_NONNULL ((2, 5, 6)));
+_GL_CXXALIAS_RPL (posix_spawn, int,
+ (pid_t *_Restrict_ __pid,
+ const char *_Restrict_ __path,
+ const posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const posix_spawnattr_t *_Restrict_ __attrp,
+ char *const argv[_Restrict_arr_],
+ char *const envp[_Restrict_arr_]));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawn, int,
+ (pid_t *_Restrict_ __pid,
+ const char *_Restrict_ __path,
+ const posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const posix_spawnattr_t *_Restrict_ __attrp,
+ char *const argv[_Restrict_arr_],
+ char *const envp[_Restrict_arr_])
+ _GL_ARG_NONNULL ((2, 5, 6)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn, int,
+ (pid_t *_Restrict_ __pid,
+ const char *_Restrict_ __path,
+ const posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const posix_spawnattr_t *_Restrict_ __attrp,
+ char *const argv[_Restrict_arr_],
+ char *const envp[_Restrict_arr_]));
+# endif
+_GL_CXXALIASWARN (posix_spawn);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn
+# if HAVE_RAW_DECL_POSIX_SPAWN
+_GL_WARN_ON_USE (posix_spawn, "posix_spawn is unportable - "
+ "use gnulib module posix_spawn for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWNP@
+/* Similar to 'posix_spawn' but search for FILE in the PATH.
+
+ This function is a possible cancellation points and therefore not
+ marked with __THROW. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnp rpl_posix_spawnp
+# endif
+_GL_FUNCDECL_RPL (posix_spawnp, int,
+ (pid_t *__pid, const char *__file,
+ const posix_spawn_file_actions_t *__file_actions,
+ const posix_spawnattr_t *__attrp,
+ char *const argv[], char *const envp[])
+ _GL_ARG_NONNULL ((2, 5, 6)));
+_GL_CXXALIAS_RPL (posix_spawnp, int,
+ (pid_t *__pid, const char *__file,
+ const posix_spawn_file_actions_t *__file_actions,
+ const posix_spawnattr_t *__attrp,
+ char *const argv[], char *const envp[]));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawnp, int,
+ (pid_t *__pid, const char *__file,
+ const posix_spawn_file_actions_t *__file_actions,
+ const posix_spawnattr_t *__attrp,
+ char *const argv[], char *const envp[])
+ _GL_ARG_NONNULL ((2, 5, 6)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnp, int,
+ (pid_t *__pid, const char *__file,
+ const posix_spawn_file_actions_t *__file_actions,
+ const posix_spawnattr_t *__attrp,
+ char *const argv[], char *const envp[]));
+# endif
+_GL_CXXALIASWARN (posix_spawnp);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnp
+# if HAVE_RAW_DECL_POSIX_SPAWNP
+_GL_WARN_ON_USE (posix_spawnp, "posix_spawnp is unportable - "
+ "use gnulib module posix_spawnp for portability");
+# endif
+#endif
+
+
+#if @GNULIB_POSIX_SPAWNATTR_INIT@
+/* Initialize data structure with attributes for 'spawn' to default values. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_init rpl_posix_spawnattr_init
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_init, int, (posix_spawnattr_t *__attr)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawnattr_init, int, (posix_spawnattr_t *__attr));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawnattr_init, int, (posix_spawnattr_t *__attr)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_init, int, (posix_spawnattr_t *__attr));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_init);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_init
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_INIT
+_GL_WARN_ON_USE (posix_spawnattr_init, "posix_spawnattr_init is unportable - "
+ "use gnulib module posix_spawnattr_init for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWNATTR_DESTROY@
+/* Free resources associated with ATTR. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_destroy rpl_posix_spawnattr_destroy
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_destroy);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_destroy
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_DESTROY
+_GL_WARN_ON_USE (posix_spawnattr_destroy,
+ "posix_spawnattr_destroy is unportable - "
+ "use gnulib module posix_spawnattr_destroy for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT@
+/* Store signal mask for signals with default handling from ATTR in
+ SIGDEFAULT. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_getsigdefault rpl_posix_spawnattr_getsigdefault
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_getsigdefault, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigdefault)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_getsigdefault, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigdefault));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawnattr_getsigdefault, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigdefault)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_getsigdefault, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigdefault));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_getsigdefault);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_getsigdefault
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGDEFAULT
+_GL_WARN_ON_USE (posix_spawnattr_getsigdefault,
+ "posix_spawnattr_getsigdefault is unportable - "
+ "use gnulib module posix_spawnattr_getsigdefault for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT@
+/* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_setsigdefault rpl_posix_spawnattr_setsigdefault
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_setsigdefault, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigdefault)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_setsigdefault, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigdefault));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawnattr_setsigdefault, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigdefault)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_setsigdefault, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigdefault));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_setsigdefault);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_setsigdefault
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGDEFAULT
+_GL_WARN_ON_USE (posix_spawnattr_setsigdefault,
+ "posix_spawnattr_setsigdefault is unportable - "
+ "use gnulib module posix_spawnattr_setsigdefault for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWNATTR_GETSIGMASK@
+/* Store signal mask for the new process from ATTR in SIGMASK. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_getsigmask rpl_posix_spawnattr_getsigmask
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_getsigmask, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigmask)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_getsigmask, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigmask));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawnattr_getsigmask, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigmask)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_getsigmask, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ sigset_t *_Restrict_ __sigmask));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_getsigmask);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_getsigmask
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGMASK
+_GL_WARN_ON_USE (posix_spawnattr_getsigmask,
+ "posix_spawnattr_getsigmask is unportable - "
+ "use gnulib module posix_spawnattr_getsigmask for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWNATTR_SETSIGMASK@
+/* Set signal mask for the new process in ATTR to SIGMASK. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_setsigmask rpl_posix_spawnattr_setsigmask
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_setsigmask, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigmask)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_setsigmask, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigmask));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawnattr_setsigmask, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigmask)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_setsigmask, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const sigset_t *_Restrict_ __sigmask));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_setsigmask);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_setsigmask
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGMASK
+_GL_WARN_ON_USE (posix_spawnattr_setsigmask,
+ "posix_spawnattr_setsigmask is unportable - "
+ "use gnulib module posix_spawnattr_setsigmask for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWNATTR_GETFLAGS@
+/* Get flag word from the attribute structure. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_getflags rpl_posix_spawnattr_getflags
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_getflags, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ short int *_Restrict_ __flags)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_getflags, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ short int *_Restrict_ __flags));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawnattr_getflags, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ short int *_Restrict_ __flags)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_getflags, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ short int *_Restrict_ __flags));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_getflags);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_getflags
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETFLAGS
+_GL_WARN_ON_USE (posix_spawnattr_getflags,
+ "posix_spawnattr_getflags is unportable - "
+ "use gnulib module posix_spawnattr_getflags for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWNATTR_SETFLAGS@
+/* Store flags in the attribute structure. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_setflags rpl_posix_spawnattr_setflags
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_setflags, int,
+ (posix_spawnattr_t *__attr, short int __flags)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawnattr_setflags, int,
+ (posix_spawnattr_t *__attr, short int __flags));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawnattr_setflags, int,
+ (posix_spawnattr_t *__attr, short int __flags)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_setflags, int,
+ (posix_spawnattr_t *__attr, short int __flags));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_setflags);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_setflags
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETFLAGS
+_GL_WARN_ON_USE (posix_spawnattr_setflags,
+ "posix_spawnattr_setflags is unportable - "
+ "use gnulib module posix_spawnattr_setflags for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWNATTR_GETPGROUP@
+/* Get process group ID from the attribute structure. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_getpgroup rpl_posix_spawnattr_getpgroup
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_getpgroup, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ pid_t *_Restrict_ __pgroup)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_getpgroup, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ pid_t *_Restrict_ __pgroup));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawnattr_getpgroup, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ pid_t *_Restrict_ __pgroup)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_getpgroup, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ pid_t *_Restrict_ __pgroup));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_getpgroup);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_getpgroup
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETPGROUP
+_GL_WARN_ON_USE (posix_spawnattr_getpgroup,
+ "posix_spawnattr_getpgroup is unportable - "
+ "use gnulib module posix_spawnattr_getpgroup for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWNATTR_SETPGROUP@
+/* Store process group ID in the attribute structure. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_setpgroup rpl_posix_spawnattr_setpgroup
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_setpgroup, int,
+ (posix_spawnattr_t *__attr, pid_t __pgroup)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawnattr_setpgroup, int,
+ (posix_spawnattr_t *__attr, pid_t __pgroup));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawnattr_setpgroup, int,
+ (posix_spawnattr_t *__attr, pid_t __pgroup)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_setpgroup, int,
+ (posix_spawnattr_t *__attr, pid_t __pgroup));
+# endif
+_GL_CXXALIASWARN (posix_spawnattr_setpgroup);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_setpgroup
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETPGROUP
+_GL_WARN_ON_USE (posix_spawnattr_setpgroup,
+ "posix_spawnattr_setpgroup is unportable - "
+ "use gnulib module posix_spawnattr_setpgroup for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY@
+/* Get scheduling policy from the attribute structure. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_getschedpolicy rpl_posix_spawnattr_getschedpolicy
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_getschedpolicy, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ int *_Restrict_ __schedpolicy)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_getschedpolicy, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ int *_Restrict_ __schedpolicy));
+# else
+# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDULER == 0
+_GL_FUNCDECL_SYS (posix_spawnattr_getschedpolicy, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ int *_Restrict_ __schedpolicy)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_getschedpolicy, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ int *_Restrict_ __schedpolicy));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (posix_spawnattr_getschedpolicy);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_getschedpolicy
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSCHEDPOLICY
+_GL_WARN_ON_USE (posix_spawnattr_getschedpolicy,
+ "posix_spawnattr_getschedpolicy is unportable - "
+ "use gnulib module posix_spawnattr_getschedpolicy for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY@
+/* Store scheduling policy in the attribute structure. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_setschedpolicy rpl_posix_spawnattr_setschedpolicy
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_setschedpolicy, int,
+ (posix_spawnattr_t *__attr, int __schedpolicy)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawnattr_setschedpolicy, int,
+ (posix_spawnattr_t *__attr, int __schedpolicy));
+# else
+# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDULER == 0
+_GL_FUNCDECL_SYS (posix_spawnattr_setschedpolicy, int,
+ (posix_spawnattr_t *__attr, int __schedpolicy)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_setschedpolicy, int,
+ (posix_spawnattr_t *__attr, int __schedpolicy));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (posix_spawnattr_setschedpolicy);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_setschedpolicy
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSCHEDPOLICY
+_GL_WARN_ON_USE (posix_spawnattr_setschedpolicy,
+ "posix_spawnattr_setschedpolicy is unportable - "
+ "use gnulib module posix_spawnattr_setschedpolicy for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM@
+/* Get scheduling parameters from the attribute structure. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_getschedparam rpl_posix_spawnattr_getschedparam
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_getschedparam, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ struct sched_param *_Restrict_ __schedparam)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_getschedparam, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ struct sched_param *_Restrict_ __schedparam));
+# else
+# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDPARAM == 0
+_GL_FUNCDECL_SYS (posix_spawnattr_getschedparam, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ struct sched_param *_Restrict_ __schedparam)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_getschedparam, int,
+ (const posix_spawnattr_t *_Restrict_ __attr,
+ struct sched_param *_Restrict_ __schedparam));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (posix_spawnattr_getschedparam);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_getschedparam
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSCHEDPARAM
+_GL_WARN_ON_USE (posix_spawnattr_getschedparam,
+ "posix_spawnattr_getschedparam is unportable - "
+ "use gnulib module posix_spawnattr_getschedparam for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM@
+/* Store scheduling parameters in the attribute structure. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawnattr_setschedparam rpl_posix_spawnattr_setschedparam
+# endif
+_GL_FUNCDECL_RPL (posix_spawnattr_setschedparam, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const struct sched_param *_Restrict_ __schedparam)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawnattr_setschedparam, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const struct sched_param *_Restrict_ __schedparam));
+# else
+# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDPARAM == 0
+_GL_FUNCDECL_SYS (posix_spawnattr_setschedparam, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const struct sched_param *_Restrict_ __schedparam)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawnattr_setschedparam, int,
+ (posix_spawnattr_t *_Restrict_ __attr,
+ const struct sched_param *_Restrict_ __schedparam));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (posix_spawnattr_setschedparam);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawnattr_setschedparam
+# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSCHEDPARAM
+_GL_WARN_ON_USE (posix_spawnattr_setschedparam,
+ "posix_spawnattr_setschedparam is unportable - "
+ "use gnulib module posix_spawnattr_setschedparam for portability");
+# endif
+#endif
+
+
+#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT@
+/* Initialize data structure for file attribute for 'spawn' call. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn_file_actions_init rpl_posix_spawn_file_actions_init
+# endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_init, int,
+ (posix_spawn_file_actions_t *__file_actions)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_init, int,
+ (posix_spawn_file_actions_t *__file_actions));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_init, int,
+ (posix_spawn_file_actions_t *__file_actions)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_init, int,
+ (posix_spawn_file_actions_t *__file_actions));
+# endif
+_GL_CXXALIASWARN (posix_spawn_file_actions_init);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_init
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_INIT
+_GL_WARN_ON_USE (posix_spawn_file_actions_init,
+ "posix_spawn_file_actions_init is unportable - "
+ "use gnulib module posix_spawn_file_actions_init for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY@
+/* Free resources associated with FILE-ACTIONS. */
+# if @REPLACE_POSIX_SPAWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn_file_actions_destroy rpl_posix_spawn_file_actions_destroy
+# endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_destroy, int,
+ (posix_spawn_file_actions_t *__file_actions)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_destroy, int,
+ (posix_spawn_file_actions_t *__file_actions));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_destroy, int,
+ (posix_spawn_file_actions_t *__file_actions)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_destroy, int,
+ (posix_spawn_file_actions_t *__file_actions));
+# endif
+_GL_CXXALIASWARN (posix_spawn_file_actions_destroy);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_destroy
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_DESTROY
+_GL_WARN_ON_USE (posix_spawn_file_actions_destroy,
+ "posix_spawn_file_actions_destroy is unportable - "
+ "use gnulib module posix_spawn_file_actions_destroy for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ 'open' for the given file during the 'spawn' call. */
+# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn_file_actions_addopen rpl_posix_spawn_file_actions_addopen
+# endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_addopen, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd,
+ const char *_Restrict_ __path, int __oflag, mode_t __mode)
+ __THROW _GL_ARG_NONNULL ((1, 3)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_addopen, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd,
+ const char *_Restrict_ __path, int __oflag, mode_t __mode));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_addopen, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd,
+ const char *_Restrict_ __path, int __oflag, mode_t __mode)
+ __THROW _GL_ARG_NONNULL ((1, 3)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_addopen, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd,
+ const char *_Restrict_ __path, int __oflag, mode_t __mode));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (posix_spawn_file_actions_addopen);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_addopen
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN
+_GL_WARN_ON_USE (posix_spawn_file_actions_addopen,
+ "posix_spawn_file_actions_addopen is unportable - "
+ "use gnulib module posix_spawn_file_actions_addopen for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ 'close' for the given file descriptor during the 'spawn' call. */
+# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn_file_actions_addclose rpl_posix_spawn_file_actions_addclose
+# endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_addclose, int,
+ (posix_spawn_file_actions_t *__file_actions, int __fd)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_addclose, int,
+ (posix_spawn_file_actions_t *__file_actions, int __fd));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_addclose, int,
+ (posix_spawn_file_actions_t *__file_actions, int __fd)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_addclose, int,
+ (posix_spawn_file_actions_t *__file_actions, int __fd));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (posix_spawn_file_actions_addclose);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_addclose
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE
+_GL_WARN_ON_USE (posix_spawn_file_actions_addclose,
+ "posix_spawn_file_actions_addclose is unportable - "
+ "use gnulib module posix_spawn_file_actions_addclose for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ 'dup2' for the given file descriptors during the 'spawn' call. */
+# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn_file_actions_adddup2 rpl_posix_spawn_file_actions_adddup2
+# endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_adddup2, int,
+ (posix_spawn_file_actions_t *__file_actions,
+ int __fd, int __newfd)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_adddup2, int,
+ (posix_spawn_file_actions_t *__file_actions,
+ int __fd, int __newfd));
+# else
+# if !@HAVE_POSIX_SPAWN@
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_adddup2, int,
+ (posix_spawn_file_actions_t *__file_actions,
+ int __fd, int __newfd)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_adddup2, int,
+ (posix_spawn_file_actions_t *__file_actions,
+ int __fd, int __newfd));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (posix_spawn_file_actions_adddup2);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_adddup2
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2
+_GL_WARN_ON_USE (posix_spawn_file_actions_adddup2,
+ "posix_spawn_file_actions_adddup2 is unportable - "
+ "use gnulib module posix_spawn_file_actions_adddup2 for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ 'chdir' to the given directory during the 'spawn' call. */
+# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn_file_actions_addchdir rpl_posix_spawn_file_actions_addchdir
+# endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_addchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const char *_Restrict_ __path)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_addchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const char *_Restrict_ __path));
+# else
+# if !@HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_addchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const char *_Restrict_ __path)
+ __THROW _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_addchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ const char *_Restrict_ __path));
+# endif
+_GL_CXXALIASWARN (posix_spawn_file_actions_addchdir);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_addchdir
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR
+_GL_WARN_ON_USE (posix_spawn_file_actions_addchdir,
+ "posix_spawn_file_actions_addchdir is unportable - "
+ "use gnulib module posix_spawn_file_actions_addchdir for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ 'fchdir' to the given directory during the 'spawn' call. */
+# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn_file_actions_addfchdir rpl_posix_spawn_file_actions_addfchdir
+# endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_addfchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_addfchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd));
+# else
+# if !@HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_addfchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_addfchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd));
+# endif
+_GL_CXXALIASWARN (posix_spawn_file_actions_addfchdir);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_addfchdir
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR
+_GL_WARN_ON_USE (posix_spawn_file_actions_addfchdir,
+ "posix_spawn_file_actions_addfchdir is unportable - "
+ "use gnulib module posix_spawn_file_actions_addfchdir for portability");
+# endif
+#endif
+
+
+#endif /* _@GUARD_PREFIX@_SPAWN_H */
+#endif /* _@GUARD_PREFIX@_SPAWN_H */
+#endif
diff --git a/lib/spawn_int.h b/lib/spawn_int.h
new file mode 100644
index 000000000..93f2b751f
--- /dev/null
+++ b/lib/spawn_int.h
@@ -0,0 +1,72 @@
+/* Copyright (C) 2000, 2008-2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <sys/types.h>
+
+/* Data structure to contain the action information. */
+struct __spawn_action
+{
+ enum
+ {
+ spawn_do_close,
+ spawn_do_dup2,
+ spawn_do_open,
+ spawn_do_chdir,
+ spawn_do_fchdir
+ } tag;
+
+ union
+ {
+ struct
+ {
+ int fd;
+ } close_action;
+ struct
+ {
+ int fd;
+ int newfd;
+ } dup2_action;
+ struct
+ {
+ int fd;
+ char *path;
+ int oflag;
+ mode_t mode;
+ } open_action;
+ struct
+ {
+ char *path;
+ } chdir_action;
+ struct
+ {
+ int fd;
+ } fchdir_action;
+ } action;
+};
+
+#if !_LIBC
+# define __posix_spawn_file_actions_realloc gl_posix_spawn_file_actions_realloc
+#endif
+extern int __posix_spawn_file_actions_realloc (posix_spawn_file_actions_t *
+ file_actions);
+
+#if !_LIBC
+# define __spawni gl_posix_spawn_internal
+#endif
+extern int __spawni (pid_t *pid, const char *path,
+ const posix_spawn_file_actions_t *file_actions,
+ const posix_spawnattr_t *attrp, const char *const argv[],
+ const char *const envp[], int use_path);
diff --git a/lib/spawni.c b/lib/spawni.c
new file mode 100644
index 000000000..9bca2002b
--- /dev/null
+++ b/lib/spawni.c
@@ -0,0 +1,965 @@
+/* Guts of POSIX spawn interface. Generic POSIX.1 version.
+ Copyright (C) 2000-2006, 2008-2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <spawn.h>
+#include "spawn_int.h"
+
+#include <alloca.h>
+#include <errno.h>
+
+#include <fcntl.h>
+#ifndef O_LARGEFILE
+# define O_LARGEFILE 0
+#endif
+
+#if _LIBC || HAVE_PATHS_H
+# include <paths.h>
+#else
+# define _PATH_BSHELL BOURNE_SHELL
+#endif
+
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#if _LIBC
+# include <not-cancel.h>
+#else
+# define close_not_cancel close
+# define open_not_cancel open
+#endif
+
+#if _LIBC
+# include <local-setxid.h>
+#else
+# if !HAVE_SETEUID
+# define seteuid(id) setresuid (-1, id, -1)
+# endif
+# if !HAVE_SETEGID
+# define setegid(id) setresgid (-1, id, -1)
+# endif
+# define local_seteuid(id) seteuid (id)
+# define local_setegid(id) setegid (id)
+#endif
+
+#if _LIBC
+# define alloca __alloca
+# define execve __execve
+# define dup2 __dup2
+# define fork __fork
+# define getgid __getgid
+# define getuid __getuid
+# define sched_setparam __sched_setparam
+# define sched_setscheduler __sched_setscheduler
+# define setpgid __setpgid
+# define sigaction __sigaction
+# define sigismember __sigismember
+# define sigprocmask __sigprocmask
+# define strchrnul __strchrnul
+# define vfork __vfork
+#endif
+
+
+/* The Unix standard contains a long explanation of the way to signal
+ an error after the fork() was successful. Since no new wait status
+ was wanted there is no way to signal an error using one of the
+ available methods. The committee chose to signal an error by a
+ normal program exit with the exit code 127. */
+#define SPAWN_ERROR 127
+
+
+#if defined _WIN32 && ! defined __CYGWIN__
+/* Native Windows API. */
+
+/* Get declarations of the native Windows API functions. */
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+
+# include <stdbool.h>
+# include <stdio.h>
+
+# include "filename.h"
+# include "concat-filename.h"
+# include "findprog.h"
+# include "malloca.h"
+# include "windows-spawn.h"
+
+/* Don't assume that UNICODE is not defined. */
+# undef CreateFile
+# define CreateFile CreateFileA
+# undef STARTUPINFO
+# define STARTUPINFO STARTUPINFOA
+# undef CreateProcess
+# define CreateProcess CreateProcessA
+
+/* Grows inh_handles->count so that it becomes > newfd.
+ Returns 0 upon success. In case of failure, -1 is returned, with errno set.
+ */
+static int
+grow_inheritable_handles (struct inheritable_handles *inh_handles, int newfd)
+{
+ if (inh_handles->allocated <= newfd)
+ {
+ size_t new_allocated = 2 * inh_handles->allocated + 1;
+ if (new_allocated <= newfd)
+ new_allocated = newfd + 1;
+ HANDLE *new_handles_array =
+ (HANDLE *)
+ realloc (inh_handles->handles, new_allocated * sizeof (HANDLE));
+ if (new_handles_array == NULL)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+ unsigned char *new_flags_array =
+ (unsigned char *)
+ realloc (inh_handles->flags, new_allocated * sizeof (unsigned char));
+ if (new_flags_array == NULL)
+ {
+ free (new_handles_array);
+ errno = ENOMEM;
+ return -1;
+ }
+ inh_handles->allocated = new_allocated;
+ inh_handles->handles = new_handles_array;
+ inh_handles->flags = new_flags_array;
+ }
+
+ HANDLE *handles = inh_handles->handles;
+
+ for (; inh_handles->count <= newfd; inh_handles->count++)
+ handles[inh_handles->count] = INVALID_HANDLE_VALUE;
+
+ return 0;
+}
+
+/* Reduces inh_handles->count to the minimum needed. */
+static void
+shrink_inheritable_handles (struct inheritable_handles *inh_handles)
+{
+ HANDLE *handles = inh_handles->handles;
+
+ while (inh_handles->count > 3
+ && handles[inh_handles->count - 1] == INVALID_HANDLE_VALUE)
+ inh_handles->count--;
+}
+
+/* Closes all handles in inh_handles. */
+static void
+close_inheritable_handles (struct inheritable_handles *inh_handles)
+{
+ HANDLE *handles = inh_handles->handles;
+ size_t handles_count = inh_handles->count;
+ unsigned int fd;
+
+ for (fd = 0; fd < handles_count; fd++)
+ {
+ HANDLE handle = handles[fd];
+
+ if (handle != INVALID_HANDLE_VALUE)
+ CloseHandle (handle);
+ }
+}
+
+/* Tests whether a memory region, starting at P and N bytes long, contains only
+ zeroes. */
+static bool
+memiszero (const void *p, size_t n)
+{
+ const char *cp = p;
+ for (; n > 0; cp++, n--)
+ if (*cp != 0)
+ return 0;
+ return 1;
+}
+
+/* Tests whether *S contains no signals. */
+static bool
+sigisempty (const sigset_t *s)
+{
+ return memiszero (s, sizeof (sigset_t));
+}
+
+/* Opens a HANDLE to a file.
+ Upon failure, returns INVALID_HANDLE_VALUE with errno set. */
+static HANDLE
+open_handle (const char *name, int flags, mode_t mode)
+{
+ /* To ease portability. Like in open.c. */
+ if (strcmp (name, "/dev/null") == 0)
+ name = "NUL";
+
+ /* POSIX <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>
+ specifies: "More than two leading <slash> characters shall be treated as
+ a single <slash> character." */
+ if (ISSLASH (name[0]) && ISSLASH (name[1]) && ISSLASH (name[2]))
+ {
+ name += 2;
+ while (ISSLASH (name[1]))
+ name++;
+ }
+
+ size_t len = strlen (name);
+ size_t drive_prefix_len = (HAS_DEVICE (name) ? 2 : 0);
+
+ /* Remove trailing slashes (except the very first one, at position
+ drive_prefix_len), but remember their presence. */
+ size_t rlen;
+ bool check_dir = false;
+
+ rlen = len;
+ while (rlen > drive_prefix_len && ISSLASH (name[rlen-1]))
+ {
+ check_dir = true;
+ if (rlen == drive_prefix_len + 1)
+ break;
+ rlen--;
+ }
+
+ /* Handle '' and 'C:'. */
+ if (!check_dir && rlen == drive_prefix_len)
+ {
+ errno = ENOENT;
+ return INVALID_HANDLE_VALUE;
+ }
+
+ /* Handle '\\'. */
+ if (rlen == 1 && ISSLASH (name[0]) && len >= 2)
+ {
+ errno = ENOENT;
+ return INVALID_HANDLE_VALUE;
+ }
+
+ const char *rname;
+ char *malloca_rname;
+ if (rlen == len)
+ {
+ rname = name;
+ malloca_rname = NULL;
+ }
+ else
+ {
+ malloca_rname = malloca (rlen + 1);
+ if (malloca_rname == NULL)
+ {
+ errno = ENOMEM;
+ return INVALID_HANDLE_VALUE;
+ }
+ memcpy (malloca_rname, name, rlen);
+ malloca_rname[rlen] = '\0';
+ rname = malloca_rname;
+ }
+
+ /* For the meaning of the flags, see
+ <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/open-wopen> */
+ /* Open a handle to the file.
+ CreateFile
+ <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-createfilea>
+ <https://docs.microsoft.com/en-us/windows/desktop/FileIO/creating-and-opening-files> */
+ HANDLE handle =
+ CreateFile (rname,
+ ((flags & (O_WRONLY | O_RDWR)) != 0
+ ? GENERIC_READ | GENERIC_WRITE
+ : GENERIC_READ),
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ NULL,
+ ((flags & O_CREAT) != 0
+ ? ((flags & O_EXCL) != 0
+ ? CREATE_NEW
+ : ((flags & O_TRUNC) != 0 ? CREATE_ALWAYS : OPEN_ALWAYS))
+ : ((flags & O_TRUNC) != 0
+ ? TRUNCATE_EXISTING
+ : OPEN_EXISTING)),
+ /* FILE_FLAG_BACKUP_SEMANTICS is useful for opening directories,
+ which is out-of-scope here. */
+ /* FILE_FLAG_POSIX_SEMANTICS (treat file names that differ only
+ in case as different) makes sense only when applied to *all*
+ filesystem operations. */
+ /* FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_POSIX_SEMANTICS */
+ FILE_ATTRIBUTE_NORMAL
+ | ((flags & O_TEMPORARY) != 0 ? FILE_FLAG_DELETE_ON_CLOSE : 0)
+ | ((flags & O_SEQUENTIAL ) != 0 ? FILE_FLAG_SEQUENTIAL_SCAN : 0)
+ | ((flags & O_RANDOM) != 0 ? FILE_FLAG_RANDOM_ACCESS : 0),
+ NULL);
+ if (handle == INVALID_HANDLE_VALUE)
+ switch (GetLastError ())
+ {
+ /* Some of these errors probably cannot happen with the specific flags
+ that we pass to CreateFile. But who knows... */
+ case ERROR_FILE_NOT_FOUND: /* The last component of rname does not exist. */
+ case ERROR_PATH_NOT_FOUND: /* Some directory component in rname does not exist. */
+ case ERROR_BAD_PATHNAME: /* rname is such as '\\server'. */
+ case ERROR_BAD_NETPATH: /* rname is such as '\\nonexistentserver\share'. */
+ case ERROR_BAD_NET_NAME: /* rname is such as '\\server\nonexistentshare'. */
+ case ERROR_INVALID_NAME: /* rname contains wildcards, misplaced colon, etc. */
+ case ERROR_DIRECTORY:
+ errno = ENOENT;
+ break;
+
+ case ERROR_ACCESS_DENIED: /* rname is such as 'C:\System Volume Information\foo'. */
+ case ERROR_SHARING_VIOLATION: /* rname is such as 'C:\pagefile.sys'. */
+ /* XXX map to EACCES or EPERM? */
+ errno = EACCES;
+ break;
+
+ case ERROR_OUTOFMEMORY:
+ errno = ENOMEM;
+ break;
+
+ case ERROR_WRITE_PROTECT:
+ errno = EROFS;
+ break;
+
+ case ERROR_WRITE_FAULT:
+ case ERROR_READ_FAULT:
+ case ERROR_GEN_FAILURE:
+ errno = EIO;
+ break;
+
+ case ERROR_BUFFER_OVERFLOW:
+ case ERROR_FILENAME_EXCED_RANGE:
+ errno = ENAMETOOLONG;
+ break;
+
+ case ERROR_DELETE_PENDING: /* XXX map to EACCES or EPERM? */
+ errno = EPERM;
+ break;
+
+ default:
+ errno = EINVAL;
+ break;
+ }
+
+ if (malloca_rname != NULL)
+ {
+ int saved_errno = errno;
+ freea (malloca_rname);
+ errno = saved_errno;
+ }
+ return handle;
+}
+
+/* Executes an 'open' action.
+ Returns 0 upon success. In case of failure, -1 is returned, with errno set.
+ */
+static int
+do_open (struct inheritable_handles *inh_handles, int newfd,
+ const char *filename, const char *directory,
+ int flags, mode_t mode, HANDLE curr_process)
+{
+ if (!(newfd >= 0 && newfd < _getmaxstdio ()))
+ {
+ errno = EBADF;
+ return -1;
+ }
+ if (grow_inheritable_handles (inh_handles, newfd) < 0)
+ return -1;
+ if (inh_handles->handles[newfd] != INVALID_HANDLE_VALUE
+ && !CloseHandle (inh_handles->handles[newfd]))
+ {
+ errno = EIO;
+ return -1;
+ }
+ if (filename == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ char *filename_to_free = NULL;
+ if (directory != NULL && IS_RELATIVE_FILE_NAME (filename))
+ {
+ char *real_filename = concatenated_filename (directory, filename, NULL);
+ if (real_filename == NULL)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+ filename = real_filename;
+ filename_to_free = real_filename;
+ }
+ HANDLE handle = open_handle (filename, flags, mode);
+ if (handle == INVALID_HANDLE_VALUE)
+ {
+ free (filename_to_free);
+ return -1;
+ }
+ free (filename_to_free);
+ /* Duplicate the handle, so that it becomes inheritable. */
+ if (!DuplicateHandle (curr_process, handle,
+ curr_process, &inh_handles->handles[newfd],
+ 0, TRUE,
+ DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS))
+ {
+ errno = EBADF; /* arbitrary */
+ return -1;
+ }
+ inh_handles->flags[newfd] = ((flags & O_APPEND) != 0 ? 32 : 0);
+ return 0;
+}
+
+/* Executes a 'dup2' action.
+ Returns 0 upon success. In case of failure, -1 is returned, with errno set.
+ */
+static int
+do_dup2 (struct inheritable_handles *inh_handles, int oldfd, int newfd,
+ HANDLE curr_process)
+{
+ if (!(oldfd >= 0 && oldfd < inh_handles->count
+ && inh_handles->handles[oldfd] != INVALID_HANDLE_VALUE))
+ {
+ errno = EBADF;
+ return -1;
+ }
+ if (!(newfd >= 0 && newfd < _getmaxstdio ()))
+ {
+ errno = EBADF;
+ return -1;
+ }
+ if (newfd != oldfd)
+ {
+ if (grow_inheritable_handles (inh_handles, newfd) < 0)
+ return -1;
+ if (inh_handles->handles[newfd] != INVALID_HANDLE_VALUE
+ && !CloseHandle (inh_handles->handles[newfd]))
+ {
+ errno = EIO;
+ return -1;
+ }
+ /* Duplicate the handle, so that it a forthcoming do_close action on oldfd
+ has no effect on newfd. */
+ if (!DuplicateHandle (curr_process, inh_handles->handles[oldfd],
+ curr_process, &inh_handles->handles[newfd],
+ 0, TRUE, DUPLICATE_SAME_ACCESS))
+ {
+ errno = EBADF; /* arbitrary */
+ return -1;
+ }
+ inh_handles->flags[newfd] = 0;
+ }
+ return 0;
+}
+
+/* Executes a 'close' action.
+ Returns 0 upon success. In case of failure, -1 is returned, with errno set.
+ */
+static int
+do_close (struct inheritable_handles *inh_handles, int fd)
+{
+ if (!(fd >= 0 && fd < inh_handles->count
+ && inh_handles->handles[fd] != INVALID_HANDLE_VALUE))
+ {
+ errno = EBADF;
+ return -1;
+ }
+ if (!CloseHandle (inh_handles->handles[fd]))
+ {
+ errno = EIO;
+ return -1;
+ }
+ inh_handles->handles[fd] = INVALID_HANDLE_VALUE;
+ return 0;
+}
+
+int
+__spawni (pid_t *pid, const char *prog_filename,
+ const posix_spawn_file_actions_t *file_actions,
+ const posix_spawnattr_t *attrp, const char *const prog_argv[],
+ const char *const envp[], int use_path)
+{
+ /* Validate the arguments. */
+ if (prog_filename == NULL
+ || (attrp != NULL
+ && ((attrp->_flags & ~POSIX_SPAWN_SETPGROUP) != 0
+ || attrp->_pgrp != 0
+ || ! sigisempty (&attrp->_sd)
+ || ! sigisempty (&attrp->_ss)
+ || attrp->_sp.sched_priority != 0
+ || attrp->_policy != 0)))
+ return EINVAL;
+
+ /* Process group handling:
+ Native Windows does not have the concept of process group, but it has the
+ concept of a console attached to a process.
+ So, we interpret the three cases as follows:
+ - Flag POSIX_SPAWN_SETPGROUP not set: Means, the child process is in the
+ same process group as the parent process. We interpret this as a
+ request to reuse the same console.
+ - Flag POSIX_SPAWN_SETPGROUP set with attrp->_pgrp == 0: Means the child
+ process starts a process group of its own. See
+ <https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getpgroup.html>
+ <https://pubs.opengroup.org/onlinepubs/9699919799/functions/setpgrp.html>
+ We interpret this as a request to detach from the current console.
+ - Flag POSIX_SPAWN_SETPGROUP set with attrp->_pgrp != 0: Means the child
+ process joins another, existing process group. See
+ <https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getpgroup.html>
+ <https://pubs.opengroup.org/onlinepubs/9699919799/functions/setpgid.html>
+ We don't support this case; it produces error EINVAL above. */
+ /* <https://docs.microsoft.com/en-us/windows/win32/procthread/process-creation-flags> */
+ DWORD process_creation_flags =
+ (attrp != NULL && (attrp->_flags & POSIX_SPAWN_SETPGROUP) != 0 ? DETACHED_PROCESS : 0);
+
+ char *argv_mem_to_free;
+ const char **argv = prepare_spawn (prog_argv, &argv_mem_to_free);
+ if (argv == NULL)
+ return errno; /* errno is set here */
+ argv++;
+
+ /* Compose the command. */
+ char *command = compose_command (argv);
+ if (command == NULL)
+ {
+ free (argv_mem_to_free);
+ return ENOMEM;
+ }
+
+ /* Copy *ENVP into a contiguous block of memory. */
+ char *envblock;
+ if (envp == NULL)
+ envblock = NULL;
+ else
+ {
+ envblock = compose_envblock (envp);
+ if (envblock == NULL)
+ {
+ free (command);
+ free (argv_mem_to_free);
+ return ENOMEM;
+ }
+ }
+
+ /* Set up the array of handles to inherit.
+ Duplicate each handle, so that a spawn_do_close action (below) has no
+ effect on the file descriptors of the current process. Alternatively,
+ we could store, for each handle, a bit that tells whether it is shared
+ with the current process. But this is simpler. */
+ struct inheritable_handles inh_handles;
+ if (init_inheritable_handles (&inh_handles, true) < 0)
+ goto failed_1;
+
+ /* Directory in which to execute the new process. */
+ const char *directory = NULL;
+
+ /* Execute the file_actions, modifying the inh_handles instead of the
+ file descriptors of the current process. */
+ if (file_actions != NULL)
+ {
+ HANDLE curr_process = GetCurrentProcess ();
+ int cnt;
+
+ for (cnt = 0; cnt < file_actions->_used; ++cnt)
+ {
+ struct __spawn_action *action = &file_actions->_actions[cnt];
+
+ switch (action->tag)
+ {
+ case spawn_do_close:
+ {
+ int fd = action->action.close_action.fd;
+ if (do_close (&inh_handles, fd) < 0)
+ goto failed_2;
+ }
+ break;
+
+ case spawn_do_open:
+ {
+ int newfd = action->action.open_action.fd;
+ const char *filename = action->action.open_action.path;
+ int flags = action->action.open_action.oflag;
+ mode_t mode = action->action.open_action.mode;
+ if (do_open (&inh_handles, newfd, filename, directory,
+ flags, mode, curr_process)
+ < 0)
+ goto failed_2;
+ }
+ break;
+
+ case spawn_do_dup2:
+ {
+ int oldfd = action->action.dup2_action.fd;
+ int newfd = action->action.dup2_action.newfd;
+ if (do_dup2 (&inh_handles, oldfd, newfd, curr_process) < 0)
+ goto failed_2;
+ }
+ break;
+
+ case spawn_do_chdir:
+ {
+ char *newdir = action->action.chdir_action.path;
+ if (directory != NULL && IS_RELATIVE_FILE_NAME (newdir))
+ {
+ newdir = concatenated_filename (directory, newdir, NULL);
+ if (newdir == NULL)
+ {
+ errno = ENOMEM;
+ goto failed_2;
+ }
+ }
+ directory = newdir;
+ }
+ break;
+
+ case spawn_do_fchdir:
+ /* Not supported in this implementation. */
+ errno = EINVAL;
+ goto failed_2;
+ }
+ }
+ }
+
+ /* Reduce inh_handles.count to the minimum needed. */
+ shrink_inheritable_handles (&inh_handles);
+
+ /* CreateProcess
+ <https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa> */
+ /* STARTUPINFO
+ <https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfoa> */
+ STARTUPINFO sinfo;
+ sinfo.cb = sizeof (STARTUPINFO);
+ sinfo.lpReserved = NULL;
+ sinfo.lpDesktop = NULL;
+ sinfo.lpTitle = NULL;
+ if (compose_handles_block (&inh_handles, &sinfo) < 0)
+ goto failed_2;
+
+ /* Perform the PATH search now, considering the final DIRECTORY. */
+ char *resolved_prog_filename_to_free = NULL;
+ {
+ const char *resolved_prog_filename =
+ find_in_given_path (prog_filename, use_path ? getenv ("PATH") : "",
+ directory, false);
+ if (resolved_prog_filename == NULL)
+ goto failed_3;
+ if (resolved_prog_filename != prog_filename)
+ resolved_prog_filename_to_free = (char *) resolved_prog_filename;
+ prog_filename = resolved_prog_filename;
+ }
+
+ PROCESS_INFORMATION pinfo;
+ if (!CreateProcess (prog_filename, command, NULL, NULL, TRUE,
+ process_creation_flags, envblock, directory, &sinfo,
+ &pinfo))
+ {
+ DWORD error = GetLastError ();
+
+ free (resolved_prog_filename_to_free);
+ free (sinfo.lpReserved2);
+ close_inheritable_handles (&inh_handles);
+ free_inheritable_handles (&inh_handles);
+ free (envblock);
+ free (command);
+ free (argv_mem_to_free);
+
+ return convert_CreateProcess_error (error);
+ }
+
+ if (pinfo.hThread)
+ CloseHandle (pinfo.hThread);
+
+ free (resolved_prog_filename_to_free);
+ free (sinfo.lpReserved2);
+ close_inheritable_handles (&inh_handles);
+ free_inheritable_handles (&inh_handles);
+ free (envblock);
+ free (command);
+ free (argv_mem_to_free);
+
+ if (pid != NULL)
+ *pid = (intptr_t) pinfo.hProcess;
+ return 0;
+
+ failed_3:
+ {
+ int saved_errno = errno;
+ free (sinfo.lpReserved2);
+ close_inheritable_handles (&inh_handles);
+ free_inheritable_handles (&inh_handles);
+ free (envblock);
+ free (command);
+ free (argv_mem_to_free);
+ return saved_errno;
+ }
+
+ failed_2:
+ {
+ int saved_errno = errno;
+ close_inheritable_handles (&inh_handles);
+ free_inheritable_handles (&inh_handles);
+ free (envblock);
+ free (command);
+ free (argv_mem_to_free);
+ return saved_errno;
+ }
+
+ failed_1:
+ free (envblock);
+ free (command);
+ free (argv_mem_to_free);
+ return errno;
+}
+
+#else
+
+
+/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
+ Before running the process perform the actions described in FILE-ACTIONS. */
+int
+__spawni (pid_t *pid, const char *file,
+ const posix_spawn_file_actions_t *file_actions,
+ const posix_spawnattr_t *attrp, const char *const argv[],
+ const char *const envp[], int use_path)
+{
+ pid_t new_pid;
+ char *path, *p, *name;
+ size_t len;
+ size_t pathlen;
+
+ /* Do this once. */
+ short int flags = attrp == NULL ? 0 : attrp->_flags;
+
+ /* Avoid gcc warning
+ "variable 'flags' might be clobbered by 'longjmp' or 'vfork'" */
+ (void) &flags;
+
+ /* Generate the new process. */
+#if HAVE_VFORK
+ if ((flags & POSIX_SPAWN_USEVFORK) != 0
+ /* If no major work is done, allow using vfork. Note that we
+ might perform the path searching. But this would be done by
+ a call to execvp(), too, and such a call must be OK according
+ to POSIX. */
+ || ((flags & (POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSIGDEF
+ | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER
+ | POSIX_SPAWN_SETPGROUP | POSIX_SPAWN_RESETIDS)) == 0
+ && file_actions == NULL))
+ new_pid = vfork ();
+ else
+#endif
+ new_pid = fork ();
+
+ if (new_pid != 0)
+ {
+ if (new_pid < 0)
+ return errno;
+
+ /* The call was successful. Store the PID if necessary. */
+ if (pid != NULL)
+ *pid = new_pid;
+
+ return 0;
+ }
+
+ /* Set signal mask. */
+ if ((flags & POSIX_SPAWN_SETSIGMASK) != 0
+ && sigprocmask (SIG_SETMASK, &attrp->_ss, NULL) != 0)
+ _exit (SPAWN_ERROR);
+
+ /* Set signal default action. */
+ if ((flags & POSIX_SPAWN_SETSIGDEF) != 0)
+ {
+ /* We have to iterate over all signals. This could possibly be
+ done better but it requires system specific solutions since
+ the sigset_t data type can be very different on different
+ architectures. */
+ int sig;
+ struct sigaction sa;
+
+ memset (&sa, '\0', sizeof (sa));
+ sa.sa_handler = SIG_DFL;
+
+ for (sig = 1; sig <= NSIG; ++sig)
+ if (sigismember (&attrp->_sd, sig) != 0
+ && sigaction (sig, &sa, NULL) != 0)
+ _exit (SPAWN_ERROR);
+
+ }
+
+#if (_LIBC ? defined _POSIX_PRIORITY_SCHEDULING : HAVE_SCHED_SETPARAM && HAVE_SCHED_SETSCHEDULER)
+ /* Set the scheduling algorithm and parameters. */
+ if ((flags & (POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER))
+ == POSIX_SPAWN_SETSCHEDPARAM)
+ {
+ if (sched_setparam (0, &attrp->_sp) == -1)
+ _exit (SPAWN_ERROR);
+ }
+ else if ((flags & POSIX_SPAWN_SETSCHEDULER) != 0)
+ {
+ if (sched_setscheduler (0, attrp->_policy,
+ (flags & POSIX_SPAWN_SETSCHEDPARAM) != 0
+ ? &attrp->_sp : NULL) == -1)
+ _exit (SPAWN_ERROR);
+ }
+#endif
+
+ /* Set the process group ID. */
+ if ((flags & POSIX_SPAWN_SETPGROUP) != 0
+ && setpgid (0, attrp->_pgrp) != 0)
+ _exit (SPAWN_ERROR);
+
+ /* Set the effective user and group IDs. */
+ if ((flags & POSIX_SPAWN_RESETIDS) != 0
+ && (local_seteuid (getuid ()) != 0
+ || local_setegid (getgid ()) != 0))
+ _exit (SPAWN_ERROR);
+
+ /* Execute the file actions. */
+ if (file_actions != NULL)
+ {
+ int cnt;
+
+ for (cnt = 0; cnt < file_actions->_used; ++cnt)
+ {
+ struct __spawn_action *action = &file_actions->_actions[cnt];
+
+ switch (action->tag)
+ {
+ case spawn_do_close:
+ if (close_not_cancel (action->action.close_action.fd) != 0)
+ /* Signal the error. */
+ _exit (SPAWN_ERROR);
+ break;
+
+ case spawn_do_open:
+ {
+ int new_fd = open_not_cancel (action->action.open_action.path,
+ action->action.open_action.oflag
+ | O_LARGEFILE,
+ action->action.open_action.mode);
+
+ if (new_fd == -1)
+ /* The 'open' call failed. */
+ _exit (SPAWN_ERROR);
+
+ /* Make sure the desired file descriptor is used. */
+ if (new_fd != action->action.open_action.fd)
+ {
+ if (dup2 (new_fd, action->action.open_action.fd)
+ != action->action.open_action.fd)
+ /* The 'dup2' call failed. */
+ _exit (SPAWN_ERROR);
+
+ if (close_not_cancel (new_fd) != 0)
+ /* The 'close' call failed. */
+ _exit (SPAWN_ERROR);
+ }
+ }
+ break;
+
+ case spawn_do_dup2:
+ if (dup2 (action->action.dup2_action.fd,
+ action->action.dup2_action.newfd)
+ != action->action.dup2_action.newfd)
+ /* The 'dup2' call failed. */
+ _exit (SPAWN_ERROR);
+ break;
+
+ case spawn_do_chdir:
+ if (chdir (action->action.chdir_action.path) < 0)
+ /* The 'chdir' call failed. */
+ _exit (SPAWN_ERROR);
+ break;
+
+ case spawn_do_fchdir:
+ if (fchdir (action->action.fchdir_action.fd) < 0)
+ /* The 'fchdir' call failed. */
+ _exit (SPAWN_ERROR);
+ break;
+ }
+ }
+ }
+
+ if (! use_path || strchr (file, '/') != NULL)
+ {
+ /* The FILE parameter is actually a path. */
+ execve (file, (char * const *) argv, (char * const *) envp);
+
+ /* Oh, oh. 'execve' returns. This is bad. */
+ _exit (SPAWN_ERROR);
+ }
+
+ /* We have to search for FILE on the path. */
+ path = getenv ("PATH");
+ if (path == NULL)
+ {
+#if HAVE_CONFSTR
+ /* There is no 'PATH' in the environment.
+ The default search path is the current directory
+ followed by the path 'confstr' returns for '_CS_PATH'. */
+ len = confstr (_CS_PATH, (char *) NULL, 0);
+ path = (char *) alloca (1 + len);
+ path[0] = ':';
+ (void) confstr (_CS_PATH, path + 1, len);
+#else
+ /* Pretend that the PATH contains only the current directory. */
+ path = "";
+#endif
+ }
+
+ len = strlen (file) + 1;
+ pathlen = strlen (path);
+ name = alloca (pathlen + len + 1);
+ /* Copy the file name at the top. */
+ name = (char *) memcpy (name + pathlen + 1, file, len);
+ /* And add the slash. */
+ *--name = '/';
+
+ p = path;
+ do
+ {
+ char *startp;
+
+ path = p;
+ p = strchrnul (path, ':');
+
+ if (p == path)
+ /* Two adjacent colons, or a colon at the beginning or the end
+ of 'PATH' means to search the current directory. */
+ startp = name + 1;
+ else
+ startp = (char *) memcpy (name - (p - path), path, p - path);
+
+ /* Try to execute this name. If it works, execv will not return. */
+ execve (startp, (char * const *) argv, (char * const *) envp);
+
+ switch (errno)
+ {
+ case EACCES:
+ case ENOENT:
+ case ESTALE:
+ case ENOTDIR:
+ /* Those errors indicate the file is missing or not executable
+ by us, in which case we want to just try the next path
+ directory. */
+ break;
+
+ default:
+ /* Some other error means we found an executable file, but
+ something went wrong executing it; return the error to our
+ caller. */
+ _exit (SPAWN_ERROR);
+ }
+ }
+ while (*p++ != '\0');
+
+ /* Return with an error. */
+ _exit (SPAWN_ERROR);
+}
+
+#endif
diff --git a/lib/spawnp.c b/lib/spawnp.c
new file mode 100644
index 000000000..27d9e1692
--- /dev/null
+++ b/lib/spawnp.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 2000, 2009-2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <spawn.h>
+
+#include "spawn_int.h"
+
+/* Spawn a new process executing FILE with the attributes describes in *ATTRP.
+ Before running the process perform the actions described in FILE-ACTIONS. */
+int
+posix_spawnp (pid_t *pid, const char *file,
+ const posix_spawn_file_actions_t *file_actions,
+ const posix_spawnattr_t *attrp, char *const argv[],
+ char *const envp[])
+{
+ return __spawni (pid, file, file_actions, attrp,
+ (const char * const *) argv, (const char * const *) envp, 1);
+}
diff --git a/lib/stat-time.c b/lib/stat-time.c
index 7b9279269..3d48a2b5b 100644
--- a/lib/stat-time.c
+++ b/lib/stat-time.c
@@ -1,6 +1,6 @@
/* stat-related time functions.
- Copyright (C) 2012-2021 Free Software Foundation, Inc.
+ Copyright (C) 2012-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/stat-time.h b/lib/stat-time.h
index fe3483d63..6b0088e32 100644
--- a/lib/stat-time.h
+++ b/lib/stat-time.h
@@ -1,6 +1,6 @@
/* stat-related time functions.
- Copyright (C) 2005, 2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2007, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -102,7 +102,7 @@ get_stat_mtime_ns (struct stat const *st)
/* Return the nanosecond component of *ST's birth time. */
_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
-get_stat_birthtime_ns (struct stat const *st _GL_UNUSED)
+get_stat_birthtime_ns (_GL_UNUSED struct stat const *st)
{
# if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC
return STAT_TIMESPEC (st, st_birthtim).tv_nsec;
@@ -158,7 +158,7 @@ get_stat_mtime (struct stat const *st)
/* Return *ST's birth time, if available; otherwise return a value
with tv_sec and tv_nsec both equal to -1. */
_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
-get_stat_birthtime (struct stat const *st _GL_UNUSED)
+get_stat_birthtime (_GL_UNUSED struct stat const *st)
{
struct timespec t;
@@ -208,7 +208,7 @@ get_stat_birthtime (struct stat const *st _GL_UNUSED)
errno to EOVERFLOW if normalization overflowed. This function
is intended to be private to this .h file. */
_GL_STAT_TIME_INLINE int
-stat_time_normalize (int result, struct stat *st _GL_UNUSED)
+stat_time_normalize (int result, _GL_UNUSED struct stat *st)
{
#if defined __sun && defined STAT_TIMESPEC
if (result == 0)
diff --git a/lib/stat-w32.c b/lib/stat-w32.c
index 4164199b6..c1a292397 100644
--- a/lib/stat-w32.c
+++ b/lib/stat-w32.c
@@ -1,5 +1,5 @@
/* Core of implementation of fstat and stat for native Windows.
- Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ Copyright (C) 2017-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/stat-w32.h b/lib/stat-w32.h
index 5b56c09dd..0f79d6141 100644
--- a/lib/stat-w32.h
+++ b/lib/stat-w32.h
@@ -1,5 +1,5 @@
/* Core of implementation of fstat and stat for native Windows.
- Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ Copyright (C) 2017-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/stat.c b/lib/stat.c
index bc9a767d3..574489ac7 100644
--- a/lib/stat.c
+++ b/lib/stat.c
@@ -1,5 +1,5 @@
/* Work around platform bugs in stat.
- Copyright (C) 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h
index 592d58e37..3b117df11 100644
--- a/lib/stdalign.in.h
+++ b/lib/stdalign.in.h
@@ -1,6 +1,6 @@
/* A substitute for ISO C11 <stdalign.h>.
- Copyright 2011-2021 Free Software Foundation, Inc.
+ Copyright 2011-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/stdbool.h b/lib/stdbool.h
new file mode 100644
index 000000000..193e4a534
--- /dev/null
+++ b/lib/stdbool.h
@@ -0,0 +1,116 @@
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+/* Copyright (C) 2001-2003, 2006-2022 Free Software Foundation, Inc.
+ Written by Bruno Haible <haible@clisp.cons.org>, 2001.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_STDBOOL_H
+#define _GL_STDBOOL_H
+
+/* ISO C 99 <stdbool.h> for platforms that lack it. */
+
+/* Usage suggestions:
+
+ Programs that use <stdbool.h> should be aware of some limitations
+ and standards compliance issues.
+
+ Standards compliance:
+
+ - <stdbool.h> must be #included before 'bool', 'false', 'true'
+ can be used.
+
+ - You cannot assume that sizeof (bool) == 1.
+
+ - Programs should not undefine the macros bool, true, and false,
+ as C99 lists that as an "obsolescent feature".
+
+ Limitations of this substitute, when used in a C89 environment:
+
+ - <stdbool.h> must be #included before the '_Bool' type can be used.
+
+ - You cannot assume that _Bool is a typedef; it might be a macro.
+
+ - Bit-fields of type 'bool' are not supported. Portable code
+ should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'.
+
+ - In C99, casts and automatic conversions to '_Bool' or 'bool' are
+ performed in such a way that every nonzero value gets converted
+ to 'true', and zero gets converted to 'false'. This doesn't work
+ with this substitute. With this substitute, only the values 0 and 1
+ give the expected result when converted to _Bool' or 'bool'.
+
+ - C99 allows the use of (_Bool)0.0 in constant expressions, but
+ this substitute cannot always provide this property.
+
+ Also, it is suggested that programs use 'bool' rather than '_Bool';
+ this isn't required, but 'bool' is more common. */
+
+
+/* 7.16. Boolean type and values */
+
+#ifdef __cplusplus
+# define _Bool bool
+# define bool bool
+#else
+# if !defined __GNUC__
+ /* If 1:
+ Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
+ the built-in _Bool type is used. See
+ https://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+ https://lists.gnu.org/r/bug-coreutils/2005-11/msg00161.html
+ https://lists.gnu.org/r/bug-coreutils/2005-10/msg00086.html
+ Similar bugs are likely with other compilers as well; this file
+ wouldn't be used if <stdbool.h> was working.
+ So we override the _Bool type.
+ If !1:
+ Need to define _Bool ourselves. As 'signed char' or as an enum type?
+ Use of a typedef, with SunPRO C, leads to a stupid
+ "warning: _Bool is a keyword in ISO C99".
+ Use of an enum type, with IRIX cc, leads to a stupid
+ "warning(1185): enumerated type mixed with another type".
+ Even the existence of an enum type, without a typedef,
+ "Invalid enumerator. (badenum)" with HP-UX cc on Tru64.
+ The only benefit of the enum, debuggability, is not important
+ with these compilers. So use 'signed char' and no enum. */
+# define _Bool signed char
+# else
+ /* With this compiler, trust the _Bool type if the compiler has it. */
+# if !1
+ /* For the sake of symbolic names in gdb, define true and false as
+ enum constants, not only as macros.
+ It is tempting to write
+ typedef enum { false = 0, true = 1 } _Bool;
+ so that gdb prints values of type 'bool' symbolically. But then
+ values of type '_Bool' might promote to 'int' or 'unsigned int'
+ (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
+ (see ISO C 99 6.3.1.1.(2)). So add a negative value to the
+ enum; this ensures that '_Bool' promotes to 'int'. */
+typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
+# endif
+# endif
+# define bool _Bool
+#endif
+
+/* The other macros must be usable in preprocessor directives. */
+#ifdef __cplusplus
+# define false false
+# define true true
+#else
+# define false 0
+# define true 1
+#endif
+
+#define __bool_true_false_are_defined 1
+
+#endif /* _GL_STDBOOL_H */
diff --git a/lib/stdbool.in.h b/lib/stdbool.in.h
index 2a1992da8..2fa46724b 100644
--- a/lib/stdbool.in.h
+++ b/lib/stdbool.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2003, 2006-2021 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2003, 2006-2022 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
This file is free software: you can redistribute it and/or modify
@@ -58,27 +58,11 @@
/* 7.16. Boolean type and values */
-/* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same
- definitions below, but temporarily we have to #undef them. */
-#if defined __BEOS__ && !defined __HAIKU__
-# include <OS.h> /* defines bool but not _Bool */
-# undef false
-# undef true
-#endif
-
#ifdef __cplusplus
# define _Bool bool
# define bool bool
#else
-# if defined __BEOS__ && !defined __HAIKU__
- /* A compiler known to have 'bool'. */
- /* If the compiler already has both 'bool' and '_Bool', we can assume they
- are the same types. */
-# if !@HAVE__BOOL@
-typedef bool _Bool;
-# endif
-# else
-# if !defined __GNUC__
+# if !defined __GNUC__
/* If @HAVE__BOOL@:
Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
the built-in _Bool type is used. See
@@ -98,10 +82,10 @@ typedef bool _Bool;
"Invalid enumerator. (badenum)" with HP-UX cc on Tru64.
The only benefit of the enum, debuggability, is not important
with these compilers. So use 'signed char' and no enum. */
-# define _Bool signed char
-# else
+# define _Bool signed char
+# else
/* With this compiler, trust the _Bool type if the compiler has it. */
-# if !@HAVE__BOOL@
+# if !@HAVE__BOOL@
/* For the sake of symbolic names in gdb, define true and false as
enum constants, not only as macros.
It is tempting to write
@@ -112,7 +96,6 @@ typedef bool _Bool;
(see ISO C 99 6.3.1.1.(2)). So add a negative value to the
enum; this ensures that '_Bool' promotes to 'int'. */
typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
-# endif
# endif
# endif
# define bool _Bool
diff --git a/lib/stdckdint.h b/lib/stdckdint.h
new file mode 100644
index 000000000..8eeac9094
--- /dev/null
+++ b/lib/stdckdint.h
@@ -0,0 +1,38 @@
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+/* stdckdint.h -- checked integer arithmetic
+
+ Copyright 2022 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_STDCKDINT_H
+#define _GL_STDCKDINT_H
+
+#include "intprops-internal.h"
+
+#include <stdbool.h>
+
+/* Store into *R the low-order bits of A + B, A - B, A * B, respectively.
+ Return 1 if the result overflows, 0 otherwise.
+ A, B, and *R can have any integer type other than char, bool, a
+ bit-precise integer type, or an enumeration type.
+
+ These are like the standard macros introduced in C23, except that
+ arguments should not have side effects. */
+
+#define ckd_add(r, a, b) ((bool) _GL_INT_ADD_WRAPV (a, b, r))
+#define ckd_sub(r, a, b) ((bool) _GL_INT_SUBTRACT_WRAPV (a, b, r))
+#define ckd_mul(r, a, b) ((bool) _GL_INT_MULTIPLY_WRAPV (a, b, r))
+
+#endif /* _GL_STDCKDINT_H */
diff --git a/lib/stdckdint.in.h b/lib/stdckdint.in.h
new file mode 100644
index 000000000..90fa62e59
--- /dev/null
+++ b/lib/stdckdint.in.h
@@ -0,0 +1,37 @@
+/* stdckdint.h -- checked integer arithmetic
+
+ Copyright 2022 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_STDCKDINT_H
+#define _GL_STDCKDINT_H
+
+#include "intprops-internal.h"
+
+#include <stdbool.h>
+
+/* Store into *R the low-order bits of A + B, A - B, A * B, respectively.
+ Return 1 if the result overflows, 0 otherwise.
+ A, B, and *R can have any integer type other than char, bool, a
+ bit-precise integer type, or an enumeration type.
+
+ These are like the standard macros introduced in C23, except that
+ arguments should not have side effects. */
+
+#define ckd_add(r, a, b) ((bool) _GL_INT_ADD_WRAPV (a, b, r))
+#define ckd_sub(r, a, b) ((bool) _GL_INT_SUBTRACT_WRAPV (a, b, r))
+#define ckd_mul(r, a, b) ((bool) _GL_INT_MULTIPLY_WRAPV (a, b, r))
+
+#endif /* _GL_STDCKDINT_H */
diff --git a/lib/stddef.in.h b/lib/stddef.in.h
index 42290d448..5c9a747d7 100644
--- a/lib/stddef.in.h
+++ b/lib/stddef.in.h
@@ -1,6 +1,6 @@
/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
- Copyright (C) 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index 85c5418f1..eaa7874f5 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2002, 2004-2021 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2002, 2004-2022 Free Software Foundation, Inc.
Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
This file is part of gnulib.
diff --git a/lib/stdio-read.c b/lib/stdio-read.c
new file mode 100644
index 000000000..85efa0d44
--- /dev/null
+++ b/lib/stdio-read.c
@@ -0,0 +1,168 @@
+/* POSIX compatible FILE stream read function.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <stdio.h>
+
+/* Replace these functions only if module 'nonblocking' is requested. */
+#if GNULIB_NONBLOCKING
+
+/* On native Windows platforms, when read() is called on a non-blocking pipe
+ with an empty buffer, ReadFile() fails with error GetLastError() =
+ ERROR_NO_DATA, and read() in consequence fails with error EINVAL. This
+ read() function is at the basis of the function which fills the buffer of
+ a FILE stream. */
+
+# if defined _WIN32 && ! defined __CYGWIN__
+
+# include <errno.h>
+# include <io.h>
+
+# define WIN32_LEAN_AND_MEAN /* avoid including junk */
+# include <windows.h>
+
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
+
+/* Don't assume that UNICODE is not defined. */
+# undef GetNamedPipeHandleState
+# define GetNamedPipeHandleState GetNamedPipeHandleStateA
+
+# define CALL_WITH_ERRNO_FIX(RETTYPE, EXPRESSION, FAILED) \
+ if (ferror (stream)) \
+ return (EXPRESSION); \
+ else \
+ { \
+ RETTYPE ret; \
+ SetLastError (0); \
+ ret = (EXPRESSION); \
+ if (FAILED) \
+ { \
+ if (GetLastError () == ERROR_NO_DATA && ferror (stream)) \
+ { \
+ int fd = fileno (stream); \
+ if (fd >= 0) \
+ { \
+ HANDLE h = (HANDLE) _get_osfhandle (fd); \
+ if (GetFileType (h) == FILE_TYPE_PIPE) \
+ { \
+ /* h is a pipe or socket. */ \
+ DWORD state; \
+ if (GetNamedPipeHandleState (h, &state, NULL, NULL, \
+ NULL, NULL, 0) \
+ && (state & PIPE_NOWAIT) != 0) \
+ /* h is a pipe in non-blocking mode. \
+ Change errno from EINVAL to EAGAIN. */ \
+ errno = EAGAIN; \
+ } \
+ } \
+ } \
+ } \
+ return ret; \
+ }
+
+/* Enable this function definition only if gnulib's <stdio.h> has prepared it.
+ Otherwise we get a function definition conflict with mingw64's <stdio.h>. */
+# if GNULIB_SCANF
+int
+scanf (const char *format, ...)
+{
+ int retval;
+ va_list args;
+
+ va_start (args, format);
+ retval = vfscanf (stdin, format, args);
+ va_end (args);
+
+ return retval;
+}
+# endif
+
+/* Enable this function definition only if gnulib's <stdio.h> has prepared it.
+ Otherwise we get a function definition conflict with mingw64's <stdio.h>. */
+# if GNULIB_FSCANF
+int
+fscanf (FILE *stream, const char *format, ...)
+{
+ int retval;
+ va_list args;
+
+ va_start (args, format);
+ retval = vfscanf (stream, format, args);
+ va_end (args);
+
+ return retval;
+}
+# endif
+
+/* Enable this function definition only if gnulib's <stdio.h> has prepared it.
+ Otherwise we get a function definition conflict with mingw64's <stdio.h>. */
+# if GNULIB_VSCANF
+int
+vscanf (const char *format, va_list args)
+{
+ return vfscanf (stdin, format, args);
+}
+# endif
+
+/* Enable this function definition only if gnulib's <stdio.h> has prepared it.
+ Otherwise we get a function definition conflict with mingw64's <stdio.h>. */
+# if GNULIB_VFSCANF
+int
+vfscanf (FILE *stream, const char *format, va_list args)
+#undef vfscanf
+{
+ CALL_WITH_ERRNO_FIX (int, vfscanf (stream, format, args), ret == EOF)
+}
+# endif
+
+int
+getchar (void)
+{
+ return fgetc (stdin);
+}
+
+int
+fgetc (FILE *stream)
+#undef fgetc
+{
+ CALL_WITH_ERRNO_FIX (int, fgetc (stream), ret == EOF)
+}
+
+char *
+fgets (char *s, int n, FILE *stream)
+#undef fgets
+{
+ CALL_WITH_ERRNO_FIX (char *, fgets (s, n, stream), ret == NULL)
+}
+
+/* We intentionally don't bother to fix gets. */
+
+size_t
+fread (void *ptr, size_t s, size_t n, FILE *stream)
+#undef fread
+{
+ CALL_WITH_ERRNO_FIX (size_t, fread (ptr, s, n, stream), ret < n)
+}
+
+# endif
+#endif
diff --git a/lib/stdio-write.c b/lib/stdio-write.c
new file mode 100644
index 000000000..82facf545
--- /dev/null
+++ b/lib/stdio-write.c
@@ -0,0 +1,206 @@
+/* POSIX compatible FILE stream write function.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2008.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <stdio.h>
+
+/* Replace these functions only if module 'nonblocking' or module 'sigpipe' is
+ requested. */
+#if GNULIB_NONBLOCKING || GNULIB_SIGPIPE
+
+/* On native Windows platforms, SIGPIPE does not exist. When write() is
+ called on a pipe with no readers, WriteFile() fails with error
+ GetLastError() = ERROR_NO_DATA, and write() in consequence fails with
+ error EINVAL. This write() function is at the basis of the function
+ which flushes the buffer of a FILE stream. */
+
+# if defined _WIN32 && ! defined __CYGWIN__
+
+# include <errno.h>
+# include <signal.h>
+# include <io.h>
+
+# define WIN32_LEAN_AND_MEAN /* avoid including junk */
+# include <windows.h>
+
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
+
+/* Don't assume that UNICODE is not defined. */
+# undef GetNamedPipeHandleState
+# define GetNamedPipeHandleState GetNamedPipeHandleStateA
+
+# if GNULIB_NONBLOCKING
+# define CLEAR_ERRNO \
+ errno = 0;
+# define HANDLE_ENOSPC \
+ if (errno == ENOSPC && ferror (stream)) \
+ { \
+ int fd = fileno (stream); \
+ if (fd >= 0) \
+ { \
+ HANDLE h = (HANDLE) _get_osfhandle (fd); \
+ if (GetFileType (h) == FILE_TYPE_PIPE) \
+ { \
+ /* h is a pipe or socket. */ \
+ DWORD state; \
+ if (GetNamedPipeHandleState (h, &state, NULL, NULL, \
+ NULL, NULL, 0) \
+ && (state & PIPE_NOWAIT) != 0) \
+ /* h is a pipe in non-blocking mode. \
+ Change errno from ENOSPC to EAGAIN. */ \
+ errno = EAGAIN; \
+ } \
+ } \
+ } \
+ else
+# else
+# define CLEAR_ERRNO
+# define HANDLE_ENOSPC
+# endif
+
+# if GNULIB_SIGPIPE
+# define CLEAR_LastError \
+ SetLastError (0);
+# define HANDLE_ERROR_NO_DATA \
+ if (GetLastError () == ERROR_NO_DATA && ferror (stream)) \
+ { \
+ int fd = fileno (stream); \
+ if (fd >= 0 \
+ && GetFileType ((HANDLE) _get_osfhandle (fd)) \
+ == FILE_TYPE_PIPE) \
+ { \
+ /* Try to raise signal SIGPIPE. */ \
+ raise (SIGPIPE); \
+ /* If it is currently blocked or ignored, change errno from \
+ EINVAL to EPIPE. */ \
+ errno = EPIPE; \
+ } \
+ } \
+ else
+# else
+# define CLEAR_LastError
+# define HANDLE_ERROR_NO_DATA
+# endif
+
+# define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \
+ if (ferror (stream)) \
+ return (EXPRESSION); \
+ else \
+ { \
+ RETTYPE ret; \
+ CLEAR_ERRNO \
+ CLEAR_LastError \
+ ret = (EXPRESSION); \
+ if (FAILED) \
+ { \
+ HANDLE_ENOSPC \
+ HANDLE_ERROR_NO_DATA \
+ ; \
+ } \
+ return ret; \
+ }
+
+# if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */
+int
+printf (const char *format, ...)
+{
+ int retval;
+ va_list args;
+
+ va_start (args, format);
+ retval = vfprintf (stdout, format, args);
+ va_end (args);
+
+ return retval;
+}
+# endif
+
+# if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */
+int
+fprintf (FILE *stream, const char *format, ...)
+{
+ int retval;
+ va_list args;
+
+ va_start (args, format);
+ retval = vfprintf (stream, format, args);
+ va_end (args);
+
+ return retval;
+}
+# endif
+
+# if !REPLACE_VPRINTF_POSIX /* avoid collision with vprintf.c */
+int
+vprintf (const char *format, va_list args)
+{
+ return vfprintf (stdout, format, args);
+}
+# endif
+
+# if !REPLACE_VFPRINTF_POSIX /* avoid collision with vfprintf.c */
+int
+vfprintf (FILE *stream, const char *format, va_list args)
+#undef vfprintf
+{
+ CALL_WITH_SIGPIPE_EMULATION (int, vfprintf (stream, format, args), ret == EOF)
+}
+# endif
+
+int
+putchar (int c)
+{
+ return fputc (c, stdout);
+}
+
+int
+fputc (int c, FILE *stream)
+#undef fputc
+{
+ CALL_WITH_SIGPIPE_EMULATION (int, fputc (c, stream), ret == EOF)
+}
+
+int
+fputs (const char *string, FILE *stream)
+#undef fputs
+{
+ CALL_WITH_SIGPIPE_EMULATION (int, fputs (string, stream), ret == EOF)
+}
+
+int
+puts (const char *string)
+#undef puts
+{
+ FILE *stream = stdout;
+ CALL_WITH_SIGPIPE_EMULATION (int, puts (string), ret == EOF)
+}
+
+size_t
+fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
+#undef fwrite
+{
+ CALL_WITH_SIGPIPE_EMULATION (size_t, fwrite (ptr, s, n, stream), ret < n)
+}
+
+# endif
+#endif
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index f1bf81732..7b36dac2f 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <stdio.h>.
- Copyright (C) 2004, 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -56,6 +56,52 @@
May also define off_t to a 64-bit type on native Windows. */
#include <sys/types.h>
+/* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */
+/* But in any case avoid namespace pollution on glibc systems. */
+#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \
+ && ! defined __GLIBC__
+# include <unistd.h>
+#endif
+
+/* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>. */
+/* But in any case avoid namespace pollution on glibc systems. */
+#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
+ && ! defined __GLIBC__
+# include <sys/stat.h>
+#endif
+
+/* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>. We must include
+ it before we #define perror rpl_perror. */
+/* But in any case avoid namespace pollution on glibc systems. */
+#if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \
+ && (defined _WIN32 && ! defined __CYGWIN__) \
+ && ! defined __GLIBC__
+# include <stdlib.h>
+#endif
+
+/* MSVC declares 'remove' in <io.h>, not in <stdio.h>. We must include
+ it before we #define remove rpl_remove. */
+/* MSVC declares 'rename' in <io.h>, not in <stdio.h>. We must include
+ it before we #define rename rpl_rename. */
+/* But in any case avoid namespace pollution on glibc systems. */
+#if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \
+ && (defined _WIN32 && ! defined __CYGWIN__) \
+ && ! defined __GLIBC__
+# include <io.h>
+#endif
+
+
+/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
+ that can be freed by passing them as the Ith argument to the
+ function F. */
+#ifndef _GL_ATTRIBUTE_DEALLOC
+# if __GNUC__ >= 11
+# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
+# else
+# define _GL_ATTRIBUTE_DEALLOC(f, i)
+# endif
+#endif
+
/* The __attribute__ feature is available in gcc versions 2.5 and later.
The __-protected variants of the attributes 'format' and 'printf' are
accepted by gcc versions 2.6.4 (effectively 2.7) and later.
@@ -127,41 +173,6 @@
#define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
_GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
-/* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */
-/* But in any case avoid namespace pollution on glibc systems. */
-#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \
- && ! defined __GLIBC__
-# include <unistd.h>
-#endif
-
-/* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>. */
-/* But in any case avoid namespace pollution on glibc systems. */
-#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
- && ! defined __GLIBC__
-# include <sys/stat.h>
-#endif
-
-/* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>. We must include
- it before we #define perror rpl_perror. */
-/* But in any case avoid namespace pollution on glibc systems. */
-#if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \
- && (defined _WIN32 && ! defined __CYGWIN__) \
- && ! defined __GLIBC__
-# include <stdlib.h>
-#endif
-
-/* MSVC declares 'remove' in <io.h>, not in <stdio.h>. We must include
- it before we #define remove rpl_remove. */
-/* MSVC declares 'rename' in <io.h>, not in <stdio.h>. We must include
- it before we #define rename rpl_rename. */
-/* But in any case avoid namespace pollution on glibc systems. */
-#if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \
- && (defined _WIN32 && ! defined __CYGWIN__) \
- && ! defined __GLIBC__
-# include <io.h>
-#endif
-
-
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -388,7 +399,8 @@ _GL_CXXALIASWARN (fileno);
#endif
#if @GNULIB_FOPEN@
-# if @REPLACE_FOPEN@
+# if (@GNULIB_FOPEN@ && @REPLACE_FOPEN@) \
+ || (@GNULIB_FOPEN_GNU@ && @REPLACE_FOPEN_FOR_FOPEN_GNU@)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef fopen
# define fopen rpl_fopen
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index d86a88071..a86643c3c 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <stdlib.h>.
- Copyright (C) 1995, 2001-2004, 2006-2021 Free Software Foundation, Inc.
+ Copyright (C) 1995, 2001-2004, 2006-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -99,6 +99,35 @@ struct random_data
# include <unistd.h>
#endif
+/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
+ that can be freed by passing them as the Ith argument to the
+ function F. */
+#ifndef _GL_ATTRIBUTE_DEALLOC
+# if __GNUC__ >= 11
+# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
+# else
+# define _GL_ATTRIBUTE_DEALLOC(f, i)
+# endif
+#endif
+
+/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
+ can be freed via 'free'; it can be used only after declaring 'free'. */
+/* Applies to: functions. Cannot be used on inline functions. */
+#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
+# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
+#endif
+
+/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
+ allocated memory. */
+/* Applies to: functions. */
+#ifndef _GL_ATTRIBUTE_MALLOC
+# if __GNUC__ >= 3 || defined __clang__
+# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+# define _GL_ATTRIBUTE_MALLOC
+# endif
+#endif
+
/* The __attribute__ feature is available in gcc versions 2.5 and later.
The attribute __pure__ was added in gcc 2.96. */
#ifndef _GL_ATTRIBUTE_PURE
@@ -155,7 +184,11 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
# undef free
# define free rpl_free
# endif
+# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
+_GL_FUNCDECL_RPL (free, void, (void *ptr) throw ());
+# else
_GL_FUNCDECL_RPL (free, void, (void *ptr));
+# endif
_GL_CXXALIAS_RPL (free, void, (void *ptr));
# else
_GL_CXXALIAS_SYS (free, void, (void *ptr));
@@ -231,7 +264,8 @@ _GL_WARN_ON_USE (atoll, "atoll is unportable - "
#endif
#if @GNULIB_CALLOC_POSIX@
-# if @REPLACE_CALLOC@
+# if (@GNULIB_CALLOC_POSIX@ && @REPLACE_CALLOC_FOR_CALLOC_POSIX@) \
+ || (@GNULIB_CALLOC_GNU@ && @REPLACE_CALLOC_FOR_CALLOC_GNU@)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef calloc
# define calloc rpl_calloc
@@ -445,7 +479,8 @@ _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
by never specifying a zero size), so it does not need malloc or
realloc to be redefined. */
#if @GNULIB_MALLOC_POSIX@
-# if @REPLACE_MALLOC@
+# if (@GNULIB_MALLOC_POSIX@ && @REPLACE_MALLOC_FOR_MALLOC_POSIX@) \
+ || (@GNULIB_MALLOC_GNU@ && @REPLACE_MALLOC_FOR_MALLOC_GNU@)
# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
|| _GL_USE_STDLIB_ALLOC)
# undef malloc
@@ -799,29 +834,35 @@ _GL_CXXALIASWARN (putenv);
/* Sort an array of NMEMB elements, starting at address BASE, each element
occupying SIZE bytes, in ascending order according to the comparison
function COMPARE. */
+# ifdef __cplusplus
+extern "C" {
+# endif
+# if !GNULIB_defined_qsort_r_fn_types
+typedef int (*_gl_qsort_r_compar_fn) (void const *, void const *, void *);
+# define GNULIB_defined_qsort_r_fn_types 1
+# endif
+# ifdef __cplusplus
+}
+# endif
# if @REPLACE_QSORT_R@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef qsort_r
# define qsort_r rpl_qsort_r
# endif
_GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
- int (*compare) (void const *, void const *,
- void *),
+ _gl_qsort_r_compar_fn compare,
void *arg) _GL_ARG_NONNULL ((1, 4)));
_GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
- int (*compare) (void const *, void const *,
- void *),
+ _gl_qsort_r_compar_fn compare,
void *arg));
# else
# if !@HAVE_QSORT_R@
_GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
- int (*compare) (void const *, void const *,
- void *),
+ _gl_qsort_r_compar_fn compare,
void *arg) _GL_ARG_NONNULL ((1, 4)));
# endif
_GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
- int (*compare) (void const *, void const *,
- void *),
+ _gl_qsort_r_compar_fn compare,
void *arg));
# endif
_GL_CXXALIASWARN (qsort_r);
@@ -1072,7 +1113,8 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
#if @GNULIB_REALLOC_POSIX@
-# if @REPLACE_REALLOC@
+# if (@GNULIB_REALLOC_POSIX@ && @REPLACE_REALLOC_FOR_REALLOC_POSIX@) \
+ || (@GNULIB_REALLOC_GNU@ && @REPLACE_REALLOC_FOR_REALLOC_GNU@)
# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
|| _GL_USE_STDLIB_ALLOC)
# undef realloc
diff --git a/lib/stpcpy.c b/lib/stpcpy.c
new file mode 100644
index 000000000..434f84ae7
--- /dev/null
+++ b/lib/stpcpy.c
@@ -0,0 +1,49 @@
+/* stpcpy.c -- copy a string and return pointer to end of new string
+ Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2022 Free Software
+ Foundation, Inc.
+
+ NOTE: The canonical source of this file is maintained with the GNU C Library.
+ Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include <string.h>
+
+#undef __stpcpy
+#ifdef _LIBC
+# undef stpcpy
+#endif
+
+#ifndef weak_alias
+# define __stpcpy stpcpy
+#endif
+
+/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
+char *
+__stpcpy (char *dest, const char *src)
+{
+ register char *d = dest;
+ register const char *s = src;
+
+ do
+ *d++ = *s;
+ while (*s++ != '\0');
+
+ return d - 1;
+}
+#ifdef weak_alias
+weak_alias (__stpcpy, stpcpy)
+#endif
diff --git a/lib/strchrnul.c b/lib/strchrnul.c
new file mode 100644
index 000000000..2141b3e19
--- /dev/null
+++ b/lib/strchrnul.c
@@ -0,0 +1,142 @@
+/* Searching in a string.
+ Copyright (C) 2003, 2007-2022 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <string.h>
+
+/* Find the first occurrence of C in S or the final NUL byte. */
+char *
+strchrnul (const char *s, int c_in)
+{
+ /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
+ long instead of a 64-bit uintmax_t tends to give better
+ performance. On 64-bit hardware, unsigned long is generally 64
+ bits already. Change this typedef to experiment with
+ performance. */
+ typedef unsigned long int longword;
+
+ const unsigned char *char_ptr;
+ const longword *longword_ptr;
+ longword repeated_one;
+ longword repeated_c;
+ unsigned char c;
+
+ c = (unsigned char) c_in;
+ if (!c)
+ return rawmemchr (s, 0);
+
+ /* Handle the first few bytes by reading one byte at a time.
+ Do this until CHAR_PTR is aligned on a longword boundary. */
+ for (char_ptr = (const unsigned char *) s;
+ (size_t) char_ptr % sizeof (longword) != 0;
+ ++char_ptr)
+ if (!*char_ptr || *char_ptr == c)
+ return (char *) char_ptr;
+
+ longword_ptr = (const longword *) char_ptr;
+
+ /* All these elucidatory comments refer to 4-byte longwords,
+ but the theory applies equally well to any size longwords. */
+
+ /* Compute auxiliary longword values:
+ repeated_one is a value which has a 1 in every byte.
+ repeated_c has c in every byte. */
+ repeated_one = 0x01010101;
+ repeated_c = c | (c << 8);
+ repeated_c |= repeated_c << 16;
+ if (0xffffffffU < (longword) -1)
+ {
+ repeated_one |= repeated_one << 31 << 1;
+ repeated_c |= repeated_c << 31 << 1;
+ if (8 < sizeof (longword))
+ {
+ size_t i;
+
+ for (i = 64; i < sizeof (longword) * 8; i *= 2)
+ {
+ repeated_one |= repeated_one << i;
+ repeated_c |= repeated_c << i;
+ }
+ }
+ }
+
+ /* Instead of the traditional loop which tests each byte, we will
+ test a longword at a time. The tricky part is testing if *any of
+ the four* bytes in the longword in question are equal to NUL or
+ c. We first use an xor with repeated_c. This reduces the task
+ to testing whether *any of the four* bytes in longword1 or
+ longword2 is zero.
+
+ Let's consider longword1. We compute tmp =
+ ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
+ That is, we perform the following operations:
+ 1. Subtract repeated_one.
+ 2. & ~longword1.
+ 3. & a mask consisting of 0x80 in every byte.
+ Consider what happens in each byte:
+ - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
+ and step 3 transforms it into 0x80. A carry can also be propagated
+ to more significant bytes.
+ - If a byte of longword1 is nonzero, let its lowest 1 bit be at
+ position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
+ the byte ends in a single bit of value 0 and k bits of value 1.
+ After step 2, the result is just k bits of value 1: 2^k - 1. After
+ step 3, the result is 0. And no carry is produced.
+ So, if longword1 has only non-zero bytes, tmp is zero.
+ Whereas if longword1 has a zero byte, call j the position of the least
+ significant zero byte. Then the result has a zero at positions 0, ...,
+ j-1 and a 0x80 at position j. We cannot predict the result at the more
+ significant bytes (positions j+1..3), but it does not matter since we
+ already have a non-zero bit at position 8*j+7.
+
+ The test whether any byte in longword1 or longword2 is zero is equivalent
+ to testing whether tmp1 is nonzero or tmp2 is nonzero. We can combine
+ this into a single test, whether (tmp1 | tmp2) is nonzero.
+
+ This test can read more than one byte beyond the end of a string,
+ depending on where the terminating NUL is encountered. However,
+ this is considered safe since the initialization phase ensured
+ that the read will be aligned, therefore, the read will not cross
+ page boundaries and will not cause a fault. */
+
+ while (1)
+ {
+ longword longword1 = *longword_ptr ^ repeated_c;
+ longword longword2 = *longword_ptr;
+
+ if (((((longword1 - repeated_one) & ~longword1)
+ | ((longword2 - repeated_one) & ~longword2))
+ & (repeated_one << 7)) != 0)
+ break;
+ longword_ptr++;
+ }
+
+ char_ptr = (const unsigned char *) longword_ptr;
+
+ /* At this point, we know that one of the sizeof (longword) bytes
+ starting at char_ptr is == 0 or == c. On little-endian machines,
+ we could determine the first such byte without any further memory
+ accesses, just by looking at the tmp result from the last loop
+ iteration. But this does not work on big-endian machines.
+ Choose code that works in both cases. */
+
+ char_ptr = (unsigned char *) longword_ptr;
+ while (*char_ptr && (*char_ptr != c))
+ char_ptr++;
+ return (char *) char_ptr;
+}
diff --git a/lib/strchrnul.valgrind b/lib/strchrnul.valgrind
new file mode 100644
index 000000000..1cf50ec8d
--- /dev/null
+++ b/lib/strchrnul.valgrind
@@ -0,0 +1,28 @@
+# Suppress a valgrind message about use of uninitialized memory in strchrnul().
+
+# Copyright (C) 2008-2022 Free Software Foundation, Inc.
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of the
+# License, or (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+# This use is OK because it provides only a speedup.
+{
+ strchrnul-value4
+ Memcheck:Value4
+ fun:strchrnul
+}
+{
+ strchrnul-value8
+ Memcheck:Value8
+ fun:strchrnul
+}
diff --git a/lib/strdup.c b/lib/strdup.c
index e5d4d75c8..2a0df023c 100644
--- a/lib/strdup.c
+++ b/lib/strdup.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2021 Free Software
+/* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2022 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
diff --git a/lib/streq.h b/lib/streq.h
index adabd158e..49f73c1b9 100644
--- a/lib/streq.h
+++ b/lib/streq.h
@@ -1,5 +1,5 @@
/* Optimized string comparison.
- Copyright (C) 2001-2002, 2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2007, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/strftime.h b/lib/strftime.h
index 790a80ed8..a9847084f 100644
--- a/lib/strftime.h
+++ b/lib/strftime.h
@@ -1,10 +1,10 @@
/* declarations for strftime.c
- Copyright (C) 2002, 2004, 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/striconveh.c b/lib/striconveh.c
index 78a5e0296..5b60a7e0a 100644
--- a/lib/striconveh.c
+++ b/lib/striconveh.c
@@ -1,5 +1,5 @@
/* Character set conversion with error handling.
- Copyright (C) 2001-2021 Free Software Foundation, Inc.
+ Copyright (C) 2001-2022 Free Software Foundation, Inc.
Written by Bruno Haible and Simon Josefsson.
This file is free software: you can redistribute it and/or modify
@@ -457,13 +457,18 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
if (cd2 == (iconv_t)(-1))
{
/* TO_CODESET is UTF-8. */
- /* Error handling can produce up to 1 byte of output. */
- if (length + 1 + extra_alloc > allocated)
+ /* Error handling can produce up to 1 or 3 bytes of
+ output. */
+ size_t extra_need =
+ (handler == iconveh_replacement_character ? 3 : 1);
+ if (length + extra_need + extra_alloc > allocated)
{
char *memory;
allocated = 2 * allocated;
- if (length + 1 + extra_alloc > allocated)
+ if (length + extra_need + extra_alloc > allocated)
+ allocated = 2 * allocated;
+ if (length + extra_need + extra_alloc > allocated)
abort ();
if (result == initial_result)
memory = (char *) malloc (allocated);
@@ -482,7 +487,7 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
grow = false;
}
/* The input is invalid in FROM_CODESET. Eat up one byte
- and emit a question mark. */
+ and emit a replacement character or a question mark. */
if (!incremented)
{
if (insize == 0)
@@ -490,8 +495,19 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
inptr++;
insize--;
}
- result[length] = '?';
- length++;
+ if (handler == iconveh_replacement_character)
+ {
+ /* U+FFFD in UTF-8 encoding. */
+ result[length+0] = '\357';
+ result[length+1] = '\277';
+ result[length+2] = '\275';
+ length += 3;
+ }
+ else
+ {
+ result[length] = '?';
+ length++;
+ }
}
else
goto indirectly;
@@ -594,7 +610,7 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
{
const bool slowly = (offsets != NULL || handler == iconveh_error);
# define utf8bufsize 4096 /* may also be smaller or larger than tmpbufsize */
- char utf8buf[utf8bufsize + 1];
+ char utf8buf[utf8bufsize + 3];
size_t utf8len = 0;
const char *in1ptr = src;
size_t in1size = srclen;
@@ -682,8 +698,8 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
&& errno == EILSEQ && handler != iconveh_error)
{
/* The input is invalid in FROM_CODESET. Eat up one byte and
- emit a question mark. Room for the question mark was allocated
- at the end of utf8buf. */
+ emit a U+FFFD character or a question mark. Room for this
+ character was allocated at the end of utf8buf. */
if (!incremented1)
{
if (in1size == 0)
@@ -691,7 +707,16 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
in1ptr++;
in1size--;
}
- *out1ptr++ = '?';
+ if (handler == iconveh_replacement_character)
+ {
+ /* U+FFFD in UTF-8 encoding. */
+ out1ptr[0] = '\357';
+ out1ptr[1] = '\277';
+ out1ptr[2] = '\275';
+ out1ptr += 3;
+ }
+ else
+ *out1ptr++ = '?';
res1 = 0;
}
errno1 = errno;
@@ -756,7 +781,7 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
break;
else if (errno == EILSEQ && handler != iconveh_error)
{
- /* Error handling can produce up to 10 bytes of ASCII
+ /* Error handling can produce up to 10 bytes of UTF-8
output. But TO_CODESET may be UCS-2, UTF-16 or
UCS-4, so use CD2 here as well. */
char scratchbuf[10];
@@ -804,6 +829,14 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
scratchbuf[scratchlen++] = hex[(uc>>4) & 15];
scratchbuf[scratchlen++] = hex[uc & 15];
}
+ else if (handler == iconveh_replacement_character)
+ {
+ /* U+FFFD in UTF-8 encoding. */
+ scratchbuf[0] = '\357';
+ scratchbuf[1] = '\277';
+ scratchbuf[2] = '\275';
+ scratchlen = 3;
+ }
else
{
scratchbuf[0] = '?';
@@ -813,9 +846,45 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
inptr = scratchbuf;
insize = scratchlen;
if (cd2 != (iconv_t)(-1))
- res = iconv (cd2,
- (ICONV_CONST char **) &inptr, &insize,
- &out2ptr, &out2size);
+ {
+ char *out2ptr_try = out2ptr;
+ size_t out2size_try = out2size;
+ res = iconv (cd2,
+ (ICONV_CONST char **) &inptr, &insize,
+ &out2ptr_try, &out2size_try);
+ if (handler == iconveh_replacement_character
+ && (res == (size_t)(-1)
+ ? errno == EILSEQ
+ /* FreeBSD iconv(), NetBSD iconv(), and
+ Solaris 11 iconv() insert a '?' if they
+ cannot convert. This is what we want.
+ But IRIX iconv() inserts a NUL byte if it
+ cannot convert.
+ And musl libc iconv() inserts a '*' if it
+ cannot convert. */
+ : (res > 0
+ && !(out2ptr_try - out2ptr == 1
+ && *out2ptr == '?'))))
+ {
+ /* The iconv() call failed.
+ U+FFFD can't be converted to TO_CODESET.
+ Use '?' instead. */
+ scratchbuf[0] = '?';
+ scratchlen = 1;
+ inptr = scratchbuf;
+ insize = scratchlen;
+ res = iconv (cd2,
+ (ICONV_CONST char **) &inptr, &insize,
+ &out2ptr, &out2size);
+ }
+ else
+ {
+ /* Accept the results of the iconv() call. */
+ out2ptr = out2ptr_try;
+ out2size = out2size_try;
+ res = 0;
+ }
+ }
else
{
/* TO_CODESET is UTF-8. */
@@ -880,9 +949,10 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
length = out2ptr - result;
}
# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__)
- /* Irix iconv() inserts a NUL byte if it cannot convert.
- NetBSD iconv() inserts a question mark if it cannot
- convert.
+ /* IRIX iconv() inserts a NUL byte if it cannot convert.
+ FreeBSD iconv(), NetBSD iconv(), and Solaris 11
+ iconv() insert a '?' if they cannot convert.
+ musl libc iconv() inserts a '*' if it cannot convert.
Only GNU libiconv and GNU libc are known to prefer
to fail rather than doing a lossy conversion. */
if (res != (size_t)(-1) && res > 0)
diff --git a/lib/striconveh.h b/lib/striconveh.h
index 60c632928..e152a046f 100644
--- a/lib/striconveh.h
+++ b/lib/striconveh.h
@@ -1,5 +1,5 @@
/* Character set conversion with error handling.
- Copyright (C) 2001-2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2001-2007, 2009-2022 Free Software Foundation, Inc.
Written by Bruno Haible and Simon Josefsson.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/string.in.h b/lib/string.in.h
index b043c7522..3996da9fc 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <string.h>.
- Copyright (C) 1995-1996, 2001-2021 Free Software Foundation, Inc.
+ Copyright (C) 1995-1996, 2001-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -47,24 +47,11 @@
/* NetBSD 5.0 mis-defines NULL. */
#include <stddef.h>
-/* Get free(). */
-#include <stdlib.h>
-
/* MirBSD defines mbslen as a macro. */
#if @GNULIB_MBSLEN@ && defined __MirBSD__
# include <wchar.h>
#endif
-/* The __attribute__ feature is available in gcc versions 2.5 and later.
- The attribute __pure__ was added in gcc 2.96. */
-#ifndef _GL_ATTRIBUTE_PURE
-# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
-# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
-# else
-# define _GL_ATTRIBUTE_PURE /* empty */
-# endif
-#endif
-
/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */
/* But in any case avoid namespace pollution on glibc systems. */
#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
@@ -80,12 +67,90 @@
# include <strings.h>
#endif
+/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
+ that can be freed by passing them as the Ith argument to the
+ function F. */
+#ifndef _GL_ATTRIBUTE_DEALLOC
+# if __GNUC__ >= 11
+# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
+# else
+# define _GL_ATTRIBUTE_DEALLOC(f, i)
+# endif
+#endif
+
+/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
+ can be freed via 'free'; it can be used only after declaring 'free'. */
+/* Applies to: functions. Cannot be used on inline functions. */
+#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
+# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
+#endif
+
+/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
+ allocated memory. */
+/* Applies to: functions. */
+#ifndef _GL_ATTRIBUTE_MALLOC
+# if __GNUC__ >= 3 || defined __clang__
+# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+# define _GL_ATTRIBUTE_MALLOC
+# endif
+#endif
+
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+ The attribute __pure__ was added in gcc 2.96. */
+#ifndef _GL_ATTRIBUTE_PURE
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
+# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
+# else
+# define _GL_ATTRIBUTE_PURE /* empty */
+# endif
+#endif
+
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
/* The definition of _GL_WARN_ON_USE is copied here. */
+/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
+ been included yet. */
+#if @GNULIB_FREE_POSIX@
+# if (@REPLACE_FREE@ && !defined free \
+ && !(defined __cplusplus && defined GNULIB_NAMESPACE))
+/* We can't do '#define free rpl_free' here. */
+_GL_EXTERN_C void rpl_free (void *);
+# undef _GL_ATTRIBUTE_DEALLOC_FREE
+# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
+# else
+# if defined _MSC_VER && !defined free
+_GL_EXTERN_C
+# if defined _DLL
+ __declspec (dllimport)
+# endif
+ void __cdecl free (void *);
+# else
+# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
+_GL_EXTERN_C void free (void *) throw ();
+# else
+_GL_EXTERN_C void free (void *);
+# endif
+# endif
+# endif
+#else
+# if defined _MSC_VER && !defined free
+_GL_EXTERN_C
+# if defined _DLL
+ __declspec (dllimport)
+# endif
+ void __cdecl free (void *);
+# else
+# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
+_GL_EXTERN_C void free (void *) throw ();
+# else
+_GL_EXTERN_C void free (void *);
+# endif
+# endif
+#endif
/* Clear a block of memory. The compiler will not delete a call to
this function, even if the block is dead after the call. */
@@ -181,10 +246,11 @@ _GL_CXXALIAS_SYS_CAST2 (memchr,
void const *, (void const *__s, int __c, size_t __n));
# endif
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
- && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
-_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
+ || defined __clang__)
+_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n) throw ());
_GL_CXXALIASWARN1 (memchr, void const *,
- (void const *__s, int __c, size_t __n));
+ (void const *__s, int __c, size_t __n) throw ());
# elif __GLIBC__ >= 2
_GL_CXXALIASWARN (memchr);
# endif
@@ -266,9 +332,10 @@ _GL_CXXALIAS_SYS_CAST2 (memrchr,
void *, (void const *, int, size_t),
void const *, (void const *, int, size_t));
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
- && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
-_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
-_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
+ || defined __clang__)
+_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t) throw ());
+_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t) throw ());
# else
_GL_CXXALIASWARN (memrchr);
# endif
@@ -296,9 +363,11 @@ _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
void *, (void const *__s, int __c_in),
void const *, (void const *__s, int __c_in));
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
- && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
-_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
-_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
+ || defined __clang__)
+_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in) throw ());
+_GL_CXXALIASWARN1 (rawmemchr, void const *,
+ (void const *__s, int __c_in) throw ());
# else
_GL_CXXALIASWARN (rawmemchr);
# endif
@@ -400,9 +469,11 @@ _GL_CXXALIAS_SYS_CAST2 (strchrnul,
char const *, (char const *__s, int __c_in));
# endif
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
- && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
-_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
-_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
+ || defined __clang__)
+_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in) throw ());
+_GL_CXXALIASWARN1 (strchrnul, char const *,
+ (char const *__s, int __c_in) throw ());
# else
_GL_CXXALIASWARN (strchrnul);
# endif
@@ -514,22 +585,35 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - "
# undef strndup
# define strndup rpl_strndup
# endif
-_GL_FUNCDECL_RPL (strndup, char *, (char const *__s, size_t __n)
- _GL_ARG_NONNULL ((1)));
+_GL_FUNCDECL_RPL (strndup, char *,
+ (char const *__s, size_t __n)
+ _GL_ARG_NONNULL ((1))
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
# else
-# if ! @HAVE_DECL_STRNDUP@
-_GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n)
- _GL_ARG_NONNULL ((1)));
+# if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup)
+_GL_FUNCDECL_SYS (strndup, char *,
+ (char const *__s, size_t __n)
+ _GL_ARG_NONNULL ((1))
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
# endif
_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
# endif
_GL_CXXALIASWARN (strndup);
-#elif defined GNULIB_POSIXCHECK
-# undef strndup
-# if HAVE_RAW_DECL_STRNDUP
+#else
+# if __GNUC__ >= 11 && !defined strndup
+/* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */
+_GL_FUNCDECL_SYS (strndup, char *,
+ (char const *__s, size_t __n)
+ _GL_ARG_NONNULL ((1))
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
+# endif
+# if defined GNULIB_POSIXCHECK
+# undef strndup
+# if HAVE_RAW_DECL_STRNDUP
_GL_WARN_ON_USE (strndup, "strndup is unportable - "
"use gnulib module strndup for portability");
+# endif
# endif
#endif
@@ -589,10 +673,11 @@ _GL_CXXALIAS_SYS_CAST2 (strpbrk,
char *, (char const *__s, char const *__accept),
const char *, (char const *__s, char const *__accept));
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
- && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
-_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
+ || defined __clang__)
+_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept) throw ());
_GL_CXXALIASWARN1 (strpbrk, char const *,
- (char const *__s, char const *__accept));
+ (char const *__s, char const *__accept) throw ());
# elif __GLIBC__ >= 2
_GL_CXXALIASWARN (strpbrk);
# endif
@@ -697,10 +782,12 @@ _GL_CXXALIAS_SYS_CAST2 (strstr,
const char *, (const char *haystack, const char *needle));
# endif
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
- && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
-_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
+ || defined __clang__)
+_GL_CXXALIASWARN1 (strstr, char *,
+ (char *haystack, const char *needle) throw ());
_GL_CXXALIASWARN1 (strstr, const char *,
- (const char *haystack, const char *needle));
+ (const char *haystack, const char *needle) throw ());
# elif __GLIBC__ >= 2
_GL_CXXALIASWARN (strstr);
# endif
@@ -746,10 +833,12 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr,
const char *, (const char *haystack, const char *needle));
# endif
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
- && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
-_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
+ || defined __clang__)
+_GL_CXXALIASWARN1 (strcasestr, char *,
+ (char *haystack, const char *needle) throw ());
_GL_CXXALIASWARN1 (strcasestr, const char *,
- (const char *haystack, const char *needle));
+ (const char *haystack, const char *needle) throw ());
# else
_GL_CXXALIASWARN (strcasestr);
# endif
diff --git a/lib/stripslash.c b/lib/stripslash.c
index 99bfbe66b..aee89b78d 100644
--- a/lib/stripslash.c
+++ b/lib/stripslash.c
@@ -1,6 +1,6 @@
/* stripslash.c -- remove redundant trailing slashes from a file name
- Copyright (C) 1990, 2001, 2003-2006, 2009-2021 Free Software Foundation,
+ Copyright (C) 1990, 2001, 2003-2006, 2009-2022 Free Software Foundation,
Inc.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/sys-limits.h b/lib/sys-limits.h
index 2d9784d1b..d154f0b23 100644
--- a/lib/sys-limits.h
+++ b/lib/sys-limits.h
@@ -1,6 +1,6 @@
/* System call limits
- Copyright 2018-2021 Free Software Foundation, Inc.
+ Copyright 2018-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/sys_file.in.h b/lib/sys_file.in.h
index 41660822b..1ae54f85a 100644
--- a/lib/sys_file.in.h
+++ b/lib/sys_file.in.h
@@ -1,6 +1,6 @@
/* Provide a more complete sys/file.h.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/sys_random.in.h b/lib/sys_random.in.h
index 1abd6c544..e730e6139 100644
--- a/lib/sys_random.in.h
+++ b/lib/sys_random.in.h
@@ -1,5 +1,5 @@
/* Substitute for <sys/random.h>.
- Copyright (C) 2020-2021 Free Software Foundation, Inc.
+ Copyright (C) 2020-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -23,8 +23,10 @@
#if @HAVE_SYS_RANDOM_H@
-/* On uClibc, <sys/random.h> assumes prior inclusion of <stddef.h>. */
-# if defined __UCLIBC__
+/* On uClibc < 1.0.35, <sys/random.h> assumes prior inclusion of <stddef.h>.
+ Do not use __UCLIBC__ here, as it might not be defined yet.
+ But avoid namespace pollution on glibc systems. */
+# ifndef __GLIBC__
# include <stddef.h>
# endif
/* On Mac OS X 10.5, <sys/random.h> assumes prior inclusion of <sys/types.h>.
diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h
index f8ef648d4..2bd0e0f79 100644
--- a/lib/sys_select.in.h
+++ b/lib/sys_select.in.h
@@ -1,5 +1,5 @@
/* Substitute for <sys/select.h>.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -21,7 +21,7 @@
/* On OSF/1 and Solaris 2.6, <sys/types.h> and <sys/time.h>
both include <sys/select.h>.
- On Cygwin, <sys/time.h> includes <sys/select.h>.
+ On Cygwin and OpenBSD, <sys/time.h> includes <sys/select.h>.
Simply delegate to the system's header in this case. */
#if (@HAVE_SYS_SELECT_H@ \
&& !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H \
@@ -39,6 +39,7 @@
|| (!defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H \
&& ((defined __osf__ && defined _SYS_TIME_H_ \
&& defined _OSF_SOURCE) \
+ || (defined __OpenBSD__ && defined _SYS_TIME_H_) \
|| (defined __sun && defined _SYS_TIME_H \
&& (! (defined _XOPEN_SOURCE \
|| defined _POSIX_C_SOURCE) \
@@ -278,9 +279,13 @@ _GL_FUNCDECL_SYS (pselect, int,
(int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
struct timespec const *restrict, const sigset_t *restrict));
# endif
-_GL_CXXALIAS_SYS (pselect, int,
- (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
- struct timespec const *restrict, const sigset_t *restrict));
+/* Need to cast, because on AIX 7, the second, third, fourth argument may be
+ void *restrict, void *restrict, void *restrict. */
+_GL_CXXALIAS_SYS_CAST (pselect, int,
+ (int,
+ fd_set *restrict, fd_set *restrict, fd_set *restrict,
+ struct timespec const *restrict,
+ const sigset_t *restrict));
# endif
_GL_CXXALIASWARN (pselect);
#elif defined GNULIB_POSIXCHECK
diff --git a/lib/sys_socket.c b/lib/sys_socket.c
index d90b32c97..0bfd60f2f 100644
--- a/lib/sys_socket.c
+++ b/lib/sys_socket.c
@@ -1,6 +1,6 @@
/* Inline functions for <sys/socket.h>.
- Copyright (C) 2012-2021 Free Software Foundation, Inc.
+ Copyright (C) 2012-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/sys_socket.in.h b/lib/sys_socket.in.h
index 0a2c57db5..acdf7eee5 100644
--- a/lib/sys_socket.in.h
+++ b/lib/sys_socket.in.h
@@ -1,6 +1,6 @@
/* Provide a sys/socket header file for systems lacking it (read: MinGW)
and for systems where it is incomplete.
- Copyright (C) 2005-2021 Free Software Foundation, Inc.
+ Copyright (C) 2005-2022 Free Software Foundation, Inc.
Written by Simon Josefsson.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index babe3dba3..714c3cb18 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -1,5 +1,5 @@
/* Provide a more complete sys/stat.h header file.
- Copyright (C) 2005-2021 Free Software Foundation, Inc.
+ Copyright (C) 2005-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -391,7 +391,33 @@ struct stat
#endif
-#if @GNULIB_MDA_CHMOD@
+#if @GNULIB_CHMOD@
+# if @REPLACE_CHMOD@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef chmod
+# define chmod rpl_chmod
+# endif
+_GL_FUNCDECL_RPL (chmod, int, (const char *filename, mode_t mode)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (chmod, int, (const char *filename, mode_t mode));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef chmod
+# define chmod _chmod
+# endif
+/* Need to cast, because in mingw the last argument is 'int mode'. */
+_GL_CXXALIAS_MDA_CAST (chmod, int, (const char *filename, mode_t mode));
+# else
+_GL_CXXALIAS_SYS (chmod, int, (const char *filename, mode_t mode));
+# endif
+_GL_CXXALIASWARN (chmod);
+#elif defined GNULIB_POSIXCHECK
+# undef chmod
+# if HAVE_RAW_DECL_CHMOD
+_GL_WARN_ON_USE (chmod, "chmod has portability problems - "
+ "use gnulib module chmod for portability");
+# endif
+#elif @GNULIB_MDA_CHMOD@
/* On native Windows, map 'chmod' to '_chmod', so that -loldnames is not
required. In C++ with GNULIB_NAMESPACE, avoid differences between
platforms by defining GNULIB_NAMESPACE::chmod always. */
diff --git a/lib/sys_time.in.h b/lib/sys_time.in.h
index 8035fbe7e..87db1a887 100644
--- a/lib/sys_time.in.h
+++ b/lib/sys_time.in.h
@@ -1,6 +1,6 @@
/* Provide a more complete sys/time.h.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/sys_times.in.h b/lib/sys_times.in.h
index 85b728f00..01b58a4ac 100644
--- a/lib/sys_times.in.h
+++ b/lib/sys_times.in.h
@@ -1,5 +1,5 @@
/* Provide a sys/times.h header file.
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/sys_types.in.h b/lib/sys_types.in.h
index 2079d72ef..698e88d63 100644
--- a/lib/sys_types.in.h
+++ b/lib/sys_types.in.h
@@ -1,6 +1,6 @@
/* Provide a more complete sys/types.h.
- Copyright (C) 2011-2021 Free Software Foundation, Inc.
+ Copyright (C) 2011-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/sys_uio.in.h b/lib/sys_uio.in.h
index 507ab011b..788d461f1 100644
--- a/lib/sys_uio.in.h
+++ b/lib/sys_uio.in.h
@@ -1,5 +1,5 @@
/* Substitute for <sys/uio.h>.
- Copyright (C) 2011-2021 Free Software Foundation, Inc.
+ Copyright (C) 2011-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/tempname.c b/lib/tempname.c
index 5f804b38d..11b4796b3 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,16 +20,10 @@
# include "tempname.h"
#endif
-#include <sys/types.h>
-#include <assert.h>
#include <stdbool.h>
-
#include <errno.h>
#include <stdio.h>
-#ifndef P_tmpdir
-# define P_tmpdir "/tmp"
-#endif
#ifndef TMP_MAX
# define TMP_MAX 238328
#endif
@@ -43,27 +37,23 @@
# error report this to bug-gnulib@gnu.org
#endif
-#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
-#include <stdalign.h>
#include <stdint.h>
#include <sys/random.h>
#include <sys/stat.h>
#include <time.h>
#if _LIBC
-# define struct_stat64 struct stat64
-# define __secure_getenv __libc_secure_getenv
+# define struct_stat64 struct __stat64_t64
#else
# define struct_stat64 struct stat
# define __gen_tempname gen_tempname
# define __mkdir mkdir
# define __open open
-# define __lstat64(file, buf) lstat (file, buf)
-# define __stat64(file, buf) stat (file, buf)
+# define __lstat64_time64(file, buf) lstat (file, buf)
# define __getrandom getrandom
# define __clock_gettime64 clock_gettime
# define __timespec64 timespec
@@ -77,94 +67,56 @@ typedef uint_fast64_t random_value;
#define BASE_62_DIGITS 10 /* 62**10 < UINT_FAST64_MAX */
#define BASE_62_POWER (62LL * 62 * 62 * 62 * 62 * 62 * 62 * 62 * 62 * 62)
+/* Return the result of mixing the entropy from R and S.
+ Assume that R and S are not particularly random,
+ and that the result should look randomish to an untrained eye. */
+
static random_value
-random_bits (random_value var, bool use_getrandom)
+mix_random_values (random_value r, random_value s)
{
- random_value r;
- /* Without GRND_NONBLOCK it can be blocked for minutes on some systems. */
- if (use_getrandom && __getrandom (&r, sizeof r, GRND_NONBLOCK) == sizeof r)
- return r;
-#if _LIBC || (defined CLOCK_MONOTONIC && HAVE_CLOCK_GETTIME)
- /* Add entropy if getrandom did not work. */
- struct __timespec64 tv;
- __clock_gettime64 (CLOCK_MONOTONIC, &tv);
- var ^= tv.tv_nsec;
-#endif
- return 2862933555777941757 * var + 3037000493;
+ /* As this code is used only when high-quality randomness is neither
+ available nor necessary, there is no need for fancier polynomials
+ such as those in the Linux kernel's 'random' driver. */
+ return (2862933555777941757 * r + 3037000493) ^ s;
}
-#if _LIBC
-/* Return nonzero if DIR is an existent directory. */
-static int
-direxists (const char *dir)
-{
- struct_stat64 buf;
- return __stat64 (dir, &buf) == 0 && S_ISDIR (buf.st_mode);
-}
+/* Set *R to a random value.
+ Return true if *R is set to high-quality value taken from getrandom.
+ Otherwise return false, falling back to a low-quality *R that might
+ depend on S.
-/* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is
- non-null and exists, uses it; otherwise uses the first of $TMPDIR,
- P_tmpdir, /tmp that exists. Copies into TMPL a template suitable
- for use with mk[s]temp. Will fail (-1) if DIR is non-null and
- doesn't exist, none of the searched dirs exists, or there's not
- enough space in TMPL. */
-int
-__path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
- int try_tmpdir)
+ This function returns false only when getrandom fails.
+ On GNU systems this should happen only early in the boot process,
+ when the fallback should be good enough for programs using tempname
+ because any attacker likely has root privileges already. */
+
+static bool
+random_bits (random_value *r, random_value s)
{
- const char *d;
- size_t dlen, plen;
+ /* Without GRND_NONBLOCK it can be blocked for minutes on some systems. */
+ if (__getrandom (r, sizeof *r, GRND_NONBLOCK) == sizeof *r)
+ return true;
- if (!pfx || !pfx[0])
- {
- pfx = "file";
- plen = 4;
- }
- else
- {
- plen = strlen (pfx);
- if (plen > 5)
- plen = 5;
- }
+ /* If getrandom did not work, use ersatz entropy based on low-order
+ clock bits. On GNU systems getrandom should fail only
+ early in booting, when ersatz should be good enough.
+ Do not use ASLR-based entropy, as that would leak ASLR info into
+ the resulting file name which is typically public.
- if (try_tmpdir)
- {
- d = __secure_getenv ("TMPDIR");
- if (d != NULL && direxists (d))
- dir = d;
- else if (dir != NULL && direxists (dir))
- /* nothing */ ;
- else
- dir = NULL;
- }
- if (dir == NULL)
- {
- if (direxists (P_tmpdir))
- dir = P_tmpdir;
- else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))
- dir = "/tmp";
- else
- {
- __set_errno (ENOENT);
- return -1;
- }
- }
+ Of course we are in a state of sin here. */
- dlen = strlen (dir);
- while (dlen > 1 && dir[dlen - 1] == '/')
- dlen--; /* remove trailing slashes */
+ random_value v = s;
- /* check we have room for "${dir}/${pfx}XXXXXX\0" */
- if (tmpl_len < dlen + 1 + plen + 6 + 1)
- {
- __set_errno (EINVAL);
- return -1;
- }
+#if _LIBC || (defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME)
+ struct __timespec64 tv;
+ __clock_gettime64 (CLOCK_REALTIME, &tv);
+ v = mix_random_values (v, tv.tv_sec);
+ v = mix_random_values (v, tv.tv_nsec);
+#endif
- sprintf (tmpl, "%.*s/%.*sXXXXXX", (int) dlen, dir, (int) plen, pfx);
- return 0;
+ *r = mix_random_values (v, clock ());
+ return false;
}
-#endif /* _LIBC */
#if _LIBC
static int try_tempname_len (char *, int, void *, int (*) (char *, void *),
@@ -181,17 +133,17 @@ try_file (char *tmpl, void *flags)
}
static int
-try_dir (char *tmpl, void *flags _GL_UNUSED)
+try_dir (char *tmpl, _GL_UNUSED void *flags)
{
return __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR);
}
static int
-try_nocreate (char *tmpl, void *flags _GL_UNUSED)
+try_nocreate (char *tmpl, _GL_UNUSED void *flags)
{
struct_stat64 st;
- if (__lstat64 (tmpl, &st) == 0 || errno == EOVERFLOW)
+ if (__lstat64_time64 (tmpl, &st) == 0 || errno == EOVERFLOW)
__set_errno (EEXIST);
return errno == ENOENT ? 0 : -1;
}
@@ -213,7 +165,7 @@ static const char letters[] =
and return a read-write fd. The file is mode 0600.
__GT_DIR: create a directory, which will be mode 0700.
- We use a clever algorithm to get hard-to-predict names. */
+ */
#ifdef _LIBC
static
#endif
@@ -261,25 +213,17 @@ try_tempname_len (char *tmpl, int suffixlen, void *args,
unsigned int attempts = ATTEMPTS_MIN;
#endif
- /* A random variable. The initial value is used only the for fallback path
- on 'random_bits' on 'getrandom' failure. Its initial value tries to use
- some entropy from the ASLR and ignore possible bits from the stack
- alignment. */
- random_value v = ((uintptr_t) &v) / alignof (max_align_t);
+ /* A random variable. */
+ random_value v = 0;
- /* How many random base-62 digits can currently be extracted from V. */
+ /* A value derived from the random variable, and how many random
+ base-62 digits can currently be extracted from VDIGBUF. */
+ random_value vdigbuf;
int vdigits = 0;
- /* Whether to consume entropy when acquiring random bits. On the
- first try it's worth the entropy cost with __GT_NOCREATE, which
- is inherently insecure and can use the entropy to make it a bit
- less secure. On the (rare) second and later attempts it might
- help against DoS attacks. */
- bool use_getrandom = tryfunc == try_nocreate;
-
- /* Least unfair value for V. If V is less than this, V can generate
- BASE_62_DIGITS digits fairly. Otherwise it might be biased. */
- random_value const unfair_min
+ /* Least biased value for V. If V is less than this, V can generate
+ BASE_62_DIGITS unbiased digits. Otherwise the digits are biased. */
+ random_value const biased_min
= RANDOM_VALUE_MAX - RANDOM_VALUE_MAX % BASE_62_POWER;
len = strlen (tmpl);
@@ -299,18 +243,16 @@ try_tempname_len (char *tmpl, int suffixlen, void *args,
{
if (vdigits == 0)
{
- do
- {
- v = random_bits (v, use_getrandom);
- use_getrandom = true;
- }
- while (unfair_min <= v);
+ /* Worry about bias only if the bits are high quality. */
+ while (random_bits (&v, v) && biased_min <= v)
+ continue;
+ vdigbuf = v;
vdigits = BASE_62_DIGITS;
}
- XXXXXX[i] = letters[v % 62];
- v /= 62;
+ XXXXXX[i] = letters[vdigbuf % 62];
+ vdigbuf /= 62;
vdigits--;
}
diff --git a/lib/tempname.h b/lib/tempname.h
index 795bb4976..5e3c5e155 100644
--- a/lib/tempname.h
+++ b/lib/tempname.h
@@ -1,6 +1,6 @@
/* Create a temporary file or directory.
- Copyright (C) 2006, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -48,7 +48,7 @@ extern "C" {
and return a read-write fd. The file is mode 0600.
GT_DIR: create a directory, which will be mode 0700.
- We use a clever algorithm to get hard-to-predict names. */
+ */
extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
/* Similar, except X_SUFFIX_LEN gives the number of Xs. */
extern int gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind,
diff --git a/lib/time-internal.h b/lib/time-internal.h
index 6bbd0a727..c8a2a8ce6 100644
--- a/lib/time-internal.h
+++ b/lib/time-internal.h
@@ -1,10 +1,10 @@
/* Time internal interface
- Copyright 2015-2021 Free Software Foundation, Inc.
+ Copyright 2015-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/time.in.h b/lib/time.in.h
index a73fe59cb..6d4c77196 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -1,6 +1,6 @@
/* A more-standard <time.h>.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -120,6 +120,17 @@ _GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base));
_GL_CXXALIASWARN (timespec_get);
# endif
+/* Set *TS to the current time resolution, and return BASE.
+ Upon failure, return 0. */
+# if @GNULIB_TIMESPEC_GETRES@
+# if ! @HAVE_TIMESPEC_GETRES@
+_GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base));
+_GL_CXXALIASWARN (timespec_getres);
+# endif
+
/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
return -1 and store the remaining time into RMTP. See
<https://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html>. */
diff --git a/lib/time_r.c b/lib/time_r.c
index 88d3c1c76..d4b227554 100644
--- a/lib/time_r.c
+++ b/lib/time_r.c
@@ -1,6 +1,6 @@
/* Reentrant time functions like localtime_r.
- Copyright (C) 2003, 2006-2007, 2010-2021 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2006-2007, 2010-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/time_rz.c b/lib/time_rz.c
index e7722447c..1a91d3778 100644
--- a/lib/time_rz.c
+++ b/lib/time_rz.c
@@ -1,10 +1,10 @@
/* Time zone functions such as tzalloc and localtime_rz
- Copyright 2015-2021 Free Software Foundation, Inc.
+ Copyright 2015-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/timegm.c b/lib/timegm.c
index 7e723e1fb..a1b19efc3 100644
--- a/lib/timegm.c
+++ b/lib/timegm.c
@@ -1,6 +1,6 @@
/* Convert UTC calendar time to simple time. Like mktime but assumes UTC.
- Copyright (C) 1994-2021 Free Software Foundation, Inc.
+ Copyright (C) 1994-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/times.c b/lib/times.c
index 72b852e58..68bc8e3c4 100644
--- a/lib/times.c
+++ b/lib/times.c
@@ -1,6 +1,6 @@
/* Get process times
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/trunc.c b/lib/trunc.c
index 1c9c420af..be24c8780 100644
--- a/lib/trunc.c
+++ b/lib/trunc.c
@@ -1,9 +1,9 @@
/* Round towards zero.
- Copyright (C) 2007, 2010-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2010-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/tzset.c b/lib/tzset.c
index 7fd4936b2..845d34962 100644
--- a/lib/tzset.c
+++ b/lib/tzset.c
@@ -1,10 +1,10 @@
/* Provide tzset for systems that don't have it or for which it's broken.
- Copyright (C) 2001-2003, 2005-2007, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2007, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/unistd.c b/lib/unistd.c
index 076345602..95978e6ad 100644
--- a/lib/unistd.c
+++ b/lib/unistd.c
@@ -1,6 +1,6 @@
/* Inline functions for <unistd.h>.
- Copyright (C) 2012-2021 Free Software Foundation, Inc.
+ Copyright (C) 2012-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 73c882f97..57df09ecd 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -1,5 +1,5 @@
/* Substitute for and wrapper around <unistd.h>.
- Copyright (C) 2003-2021 Free Software Foundation, Inc.
+ Copyright (C) 2003-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -415,16 +415,30 @@ _GL_CXXALIASWARN (close);
#if @GNULIB_COPY_FILE_RANGE@
-# if !@HAVE_COPY_FILE_RANGE@
+# if @REPLACE_COPY_FILE_RANGE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef copy_file_range
+# define copy_file_range rpl_copy_file_range
+# endif
+_GL_FUNCDECL_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
+ int ofd, off_t *opos,
+ size_t len, unsigned flags));
+_GL_CXXALIAS_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
+ int ofd, off_t *opos,
+ size_t len, unsigned flags));
+# else
+# if !@HAVE_COPY_FILE_RANGE@
_GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
int ofd, off_t *opos,
size_t len, unsigned flags));
+# endif
_GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
int ofd, off_t *opos,
size_t len, unsigned flags));
# endif
_GL_CXXALIASWARN (copy_file_range);
#elif defined GNULIB_POSIXCHECK
+# undef copy_file_range
# if HAVE_RAW_DECL_COPY_FILE_RANGE
_GL_WARN_ON_USE (copy_file_range,
"copy_file_range is unportable - "
@@ -1409,7 +1423,8 @@ _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
Read a password from /dev/tty or stdin.
Function getpass() from module 'getpass-gnu':
Read a password of arbitrary length from /dev/tty or stdin. */
-# if @REPLACE_GETPASS@
+# if (@GNULIB_GETPASS@ && @REPLACE_GETPASS@) \
+ || (@GNULIB_GETPASS_GNU@ && @REPLACE_GETPASS_FOR_GETPASS_GNU@)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef getpass
# define getpass rpl_getpass
diff --git a/lib/unsetenv.c b/lib/unsetenv.c
index b2e910e39..07eac6fdd 100644
--- a/lib/unsetenv.c
+++ b/lib/unsetenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1995-2002, 2005-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995-2002, 2005-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index d9b669d15..285c674b9 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -1,5 +1,5 @@
/* vsprintf with automatic memory allocation.
- Copyright (C) 1999, 2002-2021 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -915,8 +915,7 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
q_ptr[q_len++] = 1;
}
keep_q:
- if (tmp_roomptr != NULL)
- free (tmp_roomptr);
+ free (tmp_roomptr);
q->limbs = q_ptr;
q->nlimbs = q_len;
return roomptr;
@@ -1873,11 +1872,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
free (a.arg);
if (PRINTF_FETCHARGS (args, &a) < 0)
- {
- CLEANUP ();
- errno = EINVAL;
- return NULL;
- }
+ goto fail_1_with_EINVAL;
{
size_t buf_neededlength;
@@ -1913,19 +1908,12 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
buf_malloced = buf;
}
- if (resultbuf != NULL)
- {
- result = resultbuf;
- allocated = *lengthp;
- }
- else
- {
- result = NULL;
- allocated = 0;
- }
+ result = resultbuf;
+ allocated = (resultbuf != NULL ? *lengthp : 0);
length = 0;
/* Invariants:
- result is either == resultbuf or == NULL or malloc-allocated.
+ result is either == resultbuf or malloc-allocated.
+ If result == NULL, resultbuf is == NULL as well.
If length > 0, then result != NULL. */
/* Ensures that allocated >= needed. Aborts through a jump to
@@ -1942,7 +1930,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
memory_size = xtimes (allocated, sizeof (DCHAR_T)); \
if (size_overflow_p (memory_size)) \
oom_statement \
- if (result == resultbuf || result == NULL) \
+ if (result == resultbuf) \
memory = (DCHAR_T *) malloc (memory_size); \
else \
memory = (DCHAR_T *) realloc (result, memory_size); \
@@ -2112,15 +2100,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
if (count == 0)
break;
if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
@@ -2137,15 +2117,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
if (count == 0)
break;
if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
@@ -2191,14 +2163,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
converted, &converted_len);
# endif
if (converted == NULL)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- return NULL;
- }
+ goto fail_with_errno;
if (converted != result + length)
{
ENSURE_ALLOCATION_ELSE (xsum (length, converted_len),
@@ -2237,15 +2202,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
if (count == 0)
break;
if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
@@ -2262,15 +2219,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
if (count == 0)
break;
if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
@@ -2316,14 +2265,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
converted, &converted_len);
# endif
if (converted == NULL)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- return NULL;
- }
+ goto fail_with_errno;
if (converted != result + length)
{
ENSURE_ALLOCATION_ELSE (xsum (length, converted_len),
@@ -2362,15 +2304,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
if (count == 0)
break;
if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
@@ -2387,15 +2321,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
if (count == 0)
break;
if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
@@ -2441,14 +2367,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
converted, &converted_len);
# endif
if (converted == NULL)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- return NULL;
- }
+ goto fail_with_errno;
if (converted != result + length)
{
ENSURE_ALLOCATION_ELSE (xsum (length, converted_len),
@@ -2590,16 +2509,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
/* Found the terminating NUL. */
break;
if (count < 0)
- {
- /* Invalid or incomplete multibyte character. */
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ /* Invalid or incomplete multibyte character. */
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
@@ -2626,16 +2537,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
/* Found the terminating NUL. */
break;
if (count < 0)
- {
- /* Invalid or incomplete multibyte character. */
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ /* Invalid or incomplete multibyte character. */
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
@@ -2752,16 +2655,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
break;
count = local_wcrtomb (cbuf, *arg_end, &state);
if (count < 0)
- {
- /* Cannot convert. */
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ /* Cannot convert. */
+ goto fail_with_EILSEQ;
if (precision < (unsigned int) count)
break;
arg_end++;
@@ -2793,16 +2688,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
break;
count = local_wcrtomb (cbuf, *arg_end, &state);
if (count < 0)
- {
- /* Cannot convert. */
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ /* Cannot convert. */
+ goto fail_with_EILSEQ;
arg_end++;
characters += count;
}
@@ -2859,12 +2746,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
if (tmpdst == NULL)
{
free (tmpsrc);
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- return NULL;
+ goto fail_with_errno;
}
free (tmpsrc);
# endif
@@ -2938,16 +2820,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
abort ();
count = local_wcrtomb (cbuf, *arg, &state);
if (count <= 0)
- {
- /* Cannot convert. */
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ /* Cannot convert. */
+ goto fail_with_EILSEQ;
ENSURE_ALLOCATION (xsum (length, count));
memcpy (result + length, cbuf, count);
length += count;
@@ -3083,14 +2957,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
NULL,
NULL, &tmpdst_len);
if (tmpdst == NULL)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- return NULL;
- }
+ goto fail_with_errno;
# endif
if (has_width)
@@ -5463,13 +5330,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
errno = EINVAL;
}
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
-
- return NULL;
+ goto fail_with_errno;
}
#if USE_SNPRINTF
@@ -5603,14 +5464,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
NULL,
NULL, &tmpdst_len);
if (tmpdst == NULL)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- return NULL;
- }
+ goto fail_with_errno;
ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len),
{ free (tmpdst); goto out_of_memory; });
DCHAR_CPY (result + length, tmpdst, tmpdst_len);
@@ -5835,25 +5689,40 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
#if USE_SNPRINTF
overflow:
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
errno = EOVERFLOW;
- return NULL;
+ goto fail_with_errno;
#endif
out_of_memory:
- if (!(result == resultbuf || result == NULL))
+ errno = ENOMEM;
+ goto fail_with_errno;
+
+#if ENABLE_UNISTDIO || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T)
+ fail_with_EILSEQ:
+ errno = EILSEQ;
+ goto fail_with_errno;
+#endif
+
+ fail_with_errno:
+ if (result != resultbuf)
free (result);
if (buf_malloced != NULL)
free (buf_malloced);
- out_of_memory_1:
CLEANUP ();
- errno = ENOMEM;
return NULL;
}
+
+ out_of_memory_1:
+ errno = ENOMEM;
+ goto fail_1_with_errno;
+
+ fail_1_with_EINVAL:
+ errno = EINVAL;
+ goto fail_1_with_errno;
+
+ fail_1_with_errno:
+ CLEANUP ();
+ return NULL;
}
#undef MAX_ROOM_NEEDED
diff --git a/lib/vasnprintf.h b/lib/vasnprintf.h
index 9b02cdf8a..27cf54c50 100644
--- a/lib/vasnprintf.h
+++ b/lib/vasnprintf.h
@@ -1,5 +1,5 @@
/* vsprintf with automatic memory allocation.
- Copyright (C) 2002-2004, 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002-2004, 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/verify.h b/lib/verify.h
index a8ca59b09..47b6ee661 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -1,6 +1,6 @@
/* Compile-time assert-like macros.
- Copyright (C) 2005-2006, 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -34,7 +34,7 @@
#ifndef __cplusplus
# if (201112L <= __STDC_VERSION__ \
|| (!defined __STRICT_ANSI__ \
- && (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || 4 <= __clang_major__)))
+ && (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || 5 <= __clang_major__)))
# define _GL_HAVE__STATIC_ASSERT 1
# endif
# if (202000L <= __STDC_VERSION__ \
@@ -215,6 +215,9 @@ template <int w>
# define _GL_VERIFY(R, DIAGNOSTIC, ...) \
extern int (*_GL_GENSYM (_gl_verify_function) (void)) \
[_GL_VERIFY_TRUE (R, DIAGNOSTIC)]
+# if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
+# pragma GCC diagnostic ignored "-Wnested-externs"
+# endif
#endif
/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */
@@ -300,13 +303,16 @@ template <int w>
# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
#elif 1200 <= _MSC_VER
# define assume(R) __assume (R)
+#elif 202311L <= __STDC_VERSION__
+# include <stddef.h>
+# define assume(R) ((R) ? (void) 0 : unreachable ())
#elif (defined GCC_LINT || defined lint) && _GL_HAS_BUILTIN_TRAP
/* Doing it this way helps various packages when configured with
--enable-gcc-warnings, which compiles with -Dlint. It's nicer
- when 'assume' silences warnings even with older GCCs. */
+ if 'assume' silences warnings with GCC 3.4 through GCC 4.4.7 (2012). */
# define assume(R) ((R) ? (void) 0 : __builtin_trap ())
#else
- /* Some tools grok NOTREACHED, e.g., Oracle Studio 12.6. */
+ /* Some older tools grok NOTREACHED, e.g., Oracle Studio 12.6 (2017). */
# define assume(R) ((R) ? (void) 0 : /*NOTREACHED*/ (void) 0)
#endif
diff --git a/lib/vsnprintf.c b/lib/vsnprintf.c
index 4a0a3dc6a..80999e9b4 100644
--- a/lib/vsnprintf.c
+++ b/lib/vsnprintf.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 2004, 2006-2021 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006-2022 Free Software Foundation, Inc.
Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/w32sock.h b/lib/w32sock.h
index 635a1b228..17db3f12a 100644
--- a/lib/w32sock.h
+++ b/lib/w32sock.h
@@ -1,6 +1,6 @@
/* w32sock.h --- internal auxiliary functions for Windows socket functions
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/warn-on-use.h b/lib/warn-on-use.h
index 612937abb..94f5b9201 100644
--- a/lib/warn-on-use.h
+++ b/lib/warn-on-use.h
@@ -1,5 +1,5 @@
/* A C macro for emitting warnings if a function is used.
- Copyright (C) 2010-2021 Free Software Foundation, Inc.
+ Copyright (C) 2010-2022 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
@@ -84,20 +84,20 @@
# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
/* A compiler attribute is available in gcc versions 4.3.0 and later. */
# define _GL_WARN_ON_USE(function, message) \
-extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
+_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
__attribute__ ((__warning__ (message)))
# elif __clang_major__ >= 4
/* Another compiler attribute is available in clang. */
# define _GL_WARN_ON_USE(function, message) \
-extern __typeof__ (function) function \
+_GL_WARN_EXTERN_C __typeof__ (function) function \
__attribute__ ((__diagnose_if__ (1, message, "warning")))
# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
__attribute__ ((__diagnose_if__ (1, message, "warning")))
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE(function, message) \
-extern __typeof__ (function) function
+_GL_WARN_EXTERN_C __typeof__ (function) function
# define _GL_WARN_ON_USE_ATTRIBUTE(message)
# else /* Unsupported. */
# define _GL_WARN_ON_USE(function, message) \
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index be5d36c8d..835ddbe65 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -1,6 +1,6 @@
/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
+ Copyright (C) 2007-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -72,9 +72,6 @@
# include <stddef.h>
#endif
-/* Get free(). */
-#include <stdlib.h>
-
/* Include the original <wchar.h> if it exists.
Some builds of uClibc lack it. */
/* The include_next requires a split double-inclusion guard. */
@@ -87,6 +84,35 @@
#ifndef _@GUARD_PREFIX@_WCHAR_H
#define _@GUARD_PREFIX@_WCHAR_H
+/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
+ that can be freed by passing them as the Ith argument to the
+ function F. */
+#ifndef _GL_ATTRIBUTE_DEALLOC
+# if __GNUC__ >= 11
+# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
+# else
+# define _GL_ATTRIBUTE_DEALLOC(f, i)
+# endif
+#endif
+
+/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
+ can be freed via 'free'; it can be used only after declaring 'free'. */
+/* Applies to: functions. Cannot be used on inline functions. */
+#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
+# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
+#endif
+
+/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
+ allocated memory. */
+/* Applies to: functions. */
+#ifndef _GL_ATTRIBUTE_MALLOC
+# if __GNUC__ >= 3 || defined __clang__
+# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+# define _GL_ATTRIBUTE_MALLOC
+# endif
+#endif
+
/* The __attribute__ feature is available in gcc versions 2.5 and later.
The attribute __pure__ was added in gcc 2.96. */
#ifndef _GL_ATTRIBUTE_PURE
@@ -149,6 +175,45 @@ typedef int rpl_mbstate_t;
# endif
#endif
+/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
+ been included yet. */
+#if @GNULIB_FREE_POSIX@
+# if (@REPLACE_FREE@ && !defined free \
+ && !(defined __cplusplus && defined GNULIB_NAMESPACE))
+/* We can't do '#define free rpl_free' here. */
+_GL_EXTERN_C void rpl_free (void *);
+# undef _GL_ATTRIBUTE_DEALLOC_FREE
+# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
+# else
+# if defined _MSC_VER && !defined free
+_GL_EXTERN_C
+# if defined _DLL
+ __declspec (dllimport)
+# endif
+ void __cdecl free (void *);
+# else
+# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
+_GL_EXTERN_C void free (void *) throw ();
+# else
+_GL_EXTERN_C void free (void *);
+# endif
+# endif
+# endif
+#else
+# if defined _MSC_VER && !defined free
+_GL_EXTERN_C
+# if defined _DLL
+ __declspec (dllimport)
+# endif
+ void __cdecl free (void *);
+# else
+# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
+_GL_EXTERN_C void free (void *) throw ();
+# else
+_GL_EXTERN_C void free (void *);
+# endif
+# endif
+#endif
/* Convert a single-byte character to a wide character. */
#if @GNULIB_BTOWC@
diff --git a/lib/wcrtomb.c b/lib/wcrtomb.c
index 5c9fd795b..e14d8022a 100644
--- a/lib/wcrtomb.c
+++ b/lib/wcrtomb.c
@@ -1,5 +1,5 @@
/* Convert wide character to multibyte character.
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/wctype-h.c b/lib/wctype-h.c
index 150221d6d..127814330 100644
--- a/lib/wctype-h.c
+++ b/lib/wctype-h.c
@@ -1,6 +1,6 @@
/* Inline functions for <wctype.h>.
- Copyright (C) 2012-2021 Free Software Foundation, Inc.
+ Copyright (C) 2012-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/wctype.in.h b/lib/wctype.in.h
index 652d811ea..98cafee77 100644
--- a/lib/wctype.in.h
+++ b/lib/wctype.in.h
@@ -1,6 +1,6 @@
/* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
- Copyright (C) 2006-2021 Free Software Foundation, Inc.
+ Copyright (C) 2006-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/windows-initguard.h b/lib/windows-initguard.h
index 7999b2339..a29d7e97b 100644
--- a/lib/windows-initguard.h
+++ b/lib/windows-initguard.h
@@ -1,5 +1,5 @@
/* Init guards, somewhat like spinlocks (native Windows implementation).
- Copyright (C) 2005-2021 Free Software Foundation, Inc.
+ Copyright (C) 2005-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/windows-spawn.c b/lib/windows-spawn.c
new file mode 100644
index 000000000..a9212d485
--- /dev/null
+++ b/lib/windows-spawn.c
@@ -0,0 +1,727 @@
+/* Auxiliary functions for the creation of subprocesses. Native Windows API.
+ Copyright (C) 2001, 2003-2022 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2003.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "windows-spawn.h"
+
+/* Get declarations of the native Windows API functions. */
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+/* Get _get_osfhandle(). */
+#if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+#else
+# include <io.h>
+#endif
+#include <process.h>
+
+#include "findprog.h"
+
+/* Don't assume that UNICODE is not defined. */
+#undef STARTUPINFO
+#define STARTUPINFO STARTUPINFOA
+#undef CreateProcess
+#define CreateProcess CreateProcessA
+
+#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037*?"
+#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
+
+/* Returns the length of a quoted argument string. */
+static size_t
+quoted_arg_length (const char *string)
+{
+ bool quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
+ size_t length;
+ unsigned int backslashes;
+ const char *s;
+
+ length = 0;
+ backslashes = 0;
+ if (quote_around)
+ length++;
+ for (s = string; *s != '\0'; s++)
+ {
+ char c = *s;
+ if (c == '"')
+ length += backslashes + 1;
+ length++;
+ if (c == '\\')
+ backslashes++;
+ else
+ backslashes = 0;
+ }
+ if (quote_around)
+ length += backslashes + 1;
+
+ return length;
+}
+
+/* Produces a quoted argument string.
+ Stores exactly quoted_arg_length (STRING) + 1 bytes, including the final
+ NUL byte, at MEM.
+ Returns a pointer past the stored quoted argument string. */
+static char *
+quoted_arg_string (const char *string, char *mem)
+{
+ bool quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
+ char *p;
+ unsigned int backslashes;
+ const char *s;
+
+ p = mem;
+ backslashes = 0;
+ if (quote_around)
+ *p++ = '"';
+ for (s = string; *s != '\0'; s++)
+ {
+ char c = *s;
+ if (c == '"')
+ {
+ unsigned int j;
+ for (j = backslashes + 1; j > 0; j--)
+ *p++ = '\\';
+ }
+ *p++ = c;
+ if (c == '\\')
+ backslashes++;
+ else
+ backslashes = 0;
+ }
+ if (quote_around)
+ {
+ unsigned int j;
+ for (j = backslashes; j > 0; j--)
+ *p++ = '\\';
+ *p++ = '"';
+ }
+ *p++ = '\0';
+
+ return p;
+}
+
+const char **
+prepare_spawn (const char * const *argv, char **mem_to_free)
+{
+ size_t argc;
+ const char **new_argv;
+ size_t i;
+
+ /* Count number of arguments. */
+ for (argc = 0; argv[argc] != NULL; argc++)
+ ;
+
+ /* Allocate new argument vector. */
+ new_argv = (const char **) malloc ((1 + argc + 1) * sizeof (const char *));
+
+ /* Add an element upfront that can be used when argv[0] turns out to be a
+ script, not a program.
+ On Unix, this would be "/bin/sh". On native Windows, "sh" is actually
+ "sh.exe". We have to omit the directory part and rely on the search in
+ PATH, because the mingw "mount points" are not visible inside Windows
+ CreateProcess(). */
+ new_argv[0] = "sh.exe";
+
+ /* Put quoted arguments into the new argument vector. */
+ size_t needed_size = 0;
+ for (i = 0; i < argc; i++)
+ {
+ const char *string = argv[i];
+ size_t length;
+
+ if (string[0] == '\0')
+ length = strlen ("\"\"");
+ else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
+ length = quoted_arg_length (string);
+ else
+ length = strlen (string);
+ needed_size += length + 1;
+ }
+
+ char *mem;
+ if (needed_size == 0)
+ mem = NULL;
+ else
+ {
+ mem = (char *) malloc (needed_size);
+ if (mem == NULL)
+ {
+ /* Memory allocation failure. */
+ free (new_argv);
+ errno = ENOMEM;
+ return NULL;
+ }
+ }
+ *mem_to_free = mem;
+
+ for (i = 0; i < argc; i++)
+ {
+ const char *string = argv[i];
+
+ new_argv[1 + i] = mem;
+ if (string[0] == '\0')
+ {
+ size_t length = strlen ("\"\"");
+ memcpy (mem, "\"\"", length + 1);
+ mem += length + 1;
+ }
+ else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
+ {
+ mem = quoted_arg_string (string, mem);
+ }
+ else
+ {
+ size_t length = strlen (string);
+ memcpy (mem, string, length + 1);
+ mem += length + 1;
+ }
+ }
+ new_argv[1 + argc] = NULL;
+
+ return new_argv;
+}
+
+char *
+compose_command (const char * const *argv)
+{
+ /* Just concatenate the argv[] strings, separated by spaces. */
+ char *command;
+
+ /* Determine the size of the needed block of memory. */
+ size_t total_size = 0;
+ const char * const *ap;
+ const char *p;
+ for (ap = argv; (p = *ap) != NULL; ap++)
+ total_size += strlen (p) + 1;
+ size_t command_size = (total_size > 0 ? total_size : 1);
+
+ /* Allocate the block of memory. */
+ command = (char *) malloc (command_size);
+ if (command == NULL)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ /* Fill it. */
+ if (total_size > 0)
+ {
+ char *cp = command;
+ for (ap = argv; (p = *ap) != NULL; ap++)
+ {
+ size_t size = strlen (p) + 1;
+ memcpy (cp, p, size - 1);
+ cp += size;
+ cp[-1] = ' ';
+ }
+ cp[-1] = '\0';
+ }
+ else
+ *command = '\0';
+
+ return command;
+}
+
+char *
+compose_envblock (const char * const *envp)
+{
+ /* This is a bit hairy, because we don't have a lock that would prevent other
+ threads from making modifications in ENVP. So, just make sure we don't
+ crash; but if other threads are making modifications, part of the result
+ may be wrong. */
+ retry:
+ {
+ /* Guess the size of the needed block of memory.
+ The guess will be exact if other threads don't make modifications. */
+ size_t total_size = 0;
+ const char * const *ep;
+ const char *p;
+ for (ep = envp; (p = *ep) != NULL; ep++)
+ total_size += strlen (p) + 1;
+ size_t envblock_size = total_size;
+
+ /* Allocate the block of memory. */
+ char *envblock = (char *) malloc (envblock_size + 1);
+ if (envblock == NULL)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+ size_t envblock_used = 0;
+ for (ep = envp; (p = *ep) != NULL; ep++)
+ {
+ size_t size = strlen (p) + 1;
+ if (envblock_used + size > envblock_size)
+ {
+ /* Other threads did modifications. Need more memory. */
+ envblock_size += envblock_size / 2;
+ if (envblock_used + size > envblock_size)
+ envblock_size = envblock_used + size;
+
+ char *new_envblock = (char *) realloc (envblock, envblock_size + 1);
+ if (new_envblock == NULL)
+ {
+ free (envblock);
+ errno = ENOMEM;
+ return NULL;
+ }
+ envblock = new_envblock;
+ }
+ memcpy (envblock + envblock_used, p, size);
+ envblock_used += size;
+ if (envblock[envblock_used - 1] != '\0')
+ {
+ /* Other threads did modifications. Restart. */
+ free (envblock);
+ goto retry;
+ }
+ }
+ envblock[envblock_used] = '\0';
+ return envblock;
+ }
+}
+
+int
+init_inheritable_handles (struct inheritable_handles *inh_handles,
+ bool duplicate)
+{
+ /* Determine the minimal count of handles we need to care about. */
+ size_t handles_count;
+ {
+ /* _getmaxstdio
+ <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/getmaxstdio>
+ Default value is 512. */
+ unsigned int fdmax = _getmaxstdio ();
+ if (fdmax < 3)
+ fdmax = 3;
+ for (; fdmax > 3; fdmax--)
+ {
+ unsigned int fd = fdmax - 1;
+ /* _get_osfhandle
+ <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/get-osfhandle> */
+ HANDLE handle = (HANDLE) _get_osfhandle (fd);
+ if (handle != INVALID_HANDLE_VALUE)
+ {
+ DWORD hflags;
+ /* GetHandleInformation
+ <https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-gethandleinformation> */
+ if (GetHandleInformation (handle, &hflags))
+ {
+ if ((hflags & HANDLE_FLAG_INHERIT) != 0)
+ /* fd denotes an inheritable descriptor. */
+ break;
+ }
+ }
+ }
+ handles_count = fdmax;
+ }
+ /* Note: handles_count >= 3. */
+
+ /* Allocate the arrays. */
+ size_t handles_allocated = handles_count;
+ HANDLE *handles_array =
+ (HANDLE *) malloc (handles_allocated * sizeof (HANDLE));
+ if (handles_array == NULL)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+ unsigned char *flags_array =
+ (unsigned char *) malloc (handles_allocated * sizeof (unsigned char));
+ if (flags_array == NULL)
+ {
+ free (handles_array);
+ errno = ENOMEM;
+ return -1;
+ }
+
+ /* Fill in the two arrays. */
+ {
+ HANDLE curr_process = (duplicate ? GetCurrentProcess () : INVALID_HANDLE_VALUE);
+ unsigned int fd;
+ for (fd = 0; fd < handles_count; fd++)
+ {
+ handles_array[fd] = INVALID_HANDLE_VALUE;
+ /* _get_osfhandle
+ <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/get-osfhandle> */
+ HANDLE handle = (HANDLE) _get_osfhandle (fd);
+ if (handle != INVALID_HANDLE_VALUE)
+ {
+ DWORD hflags;
+ /* GetHandleInformation
+ <https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-gethandleinformation> */
+ if (GetHandleInformation (handle, &hflags))
+ {
+ if ((hflags & HANDLE_FLAG_INHERIT) != 0)
+ {
+ /* fd denotes an inheritable descriptor. */
+ if (duplicate)
+ {
+ if (!DuplicateHandle (curr_process, handle,
+ curr_process, &handles_array[fd],
+ 0, TRUE, DUPLICATE_SAME_ACCESS))
+ {
+ unsigned int i;
+ for (i = 0; i < fd; i++)
+ if (handles_array[i] != INVALID_HANDLE_VALUE)
+ CloseHandle (handles_array[i]);
+ free (flags_array);
+ free (handles_array);
+ errno = EBADF; /* arbitrary */
+ return -1;
+ }
+ }
+ else
+ handles_array[fd] = handle;
+
+ flags_array[fd] = 0;
+ }
+ }
+ }
+ }
+ }
+
+ /* Return the result. */
+ inh_handles->count = handles_count;
+ inh_handles->allocated = handles_allocated;
+ inh_handles->handles = handles_array;
+ inh_handles->flags = flags_array;
+ return 0;
+}
+
+int
+compose_handles_block (const struct inheritable_handles *inh_handles,
+ STARTUPINFO *sinfo)
+{
+ /* STARTUPINFO
+ <https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfoa> */
+ sinfo->dwFlags = STARTF_USESTDHANDLES;
+ sinfo->hStdInput = inh_handles->handles[0];
+ sinfo->hStdOutput = inh_handles->handles[1];
+ sinfo->hStdError = inh_handles->handles[2];
+
+ /* On newer versions of Windows, more file descriptors / handles than the
+ first three can be passed.
+ The format is as follows: Let N be an exclusive upper bound for the file
+ descriptors to be passed. Two arrays are constructed in memory:
+ - flags[0..N-1], of element type 'unsigned char',
+ - handles[0..N-1], of element type 'HANDLE' or 'intptr_t'.
+ For used entries, handles[i] is the handle, and flags[i] is a set of flags,
+ a combination of:
+ 1 for open file descriptors,
+ 64 for handles of type FILE_TYPE_CHAR,
+ 8 for handles of type FILE_TYPE_PIPE,
+ 32 for O_APPEND.
+ For unused entries - this may include any of the first three, since they
+ are already passed above -, handles[i] is INVALID_HANDLE_VALUE and flags[i]
+ is zero.
+ lpReserved2 now is a pointer to the concatenation (without padding) of:
+ - an 'unsigned int' whose value is N,
+ - the contents of the flags[0..N-1] array,
+ - the contents of the handles[0..N-1] array.
+ cbReserved2 is the size (in bytes) of the object at lpReserved2. */
+
+ size_t handles_count = inh_handles->count;
+
+ sinfo->cbReserved2 =
+ sizeof (unsigned int)
+ + handles_count * sizeof (unsigned char)
+ + handles_count * sizeof (HANDLE);
+ /* Add some padding, so that we can work with a properly aligned HANDLE
+ array. */
+ char *hblock = (char *) malloc (sinfo->cbReserved2 + (sizeof (HANDLE) - 1));
+ if (hblock == NULL)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+ unsigned char *flags = (unsigned char *) (hblock + sizeof (unsigned int));
+ char *handles = (char *) (flags + handles_count);
+ HANDLE *handles_aligned =
+ (HANDLE *) (((uintptr_t) handles + (sizeof (HANDLE) - 1))
+ & - (uintptr_t) sizeof (HANDLE));
+
+ * (unsigned int *) hblock = handles_count;
+ {
+ unsigned int fd;
+ for (fd = 0; fd < handles_count; fd++)
+ {
+ handles_aligned[fd] = INVALID_HANDLE_VALUE;
+ flags[fd] = 0;
+
+ HANDLE handle = inh_handles->handles[fd];
+ if (handle != INVALID_HANDLE_VALUE
+ /* The first three are possibly already passed above.
+ But they need to passed here as well, if they have some flags. */
+ && (fd >= 3 || inh_handles->flags[fd] != 0))
+ {
+ DWORD hflags;
+ /* GetHandleInformation
+ <https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-gethandleinformation> */
+ if (GetHandleInformation (handle, &hflags))
+ {
+ if ((hflags & HANDLE_FLAG_INHERIT) != 0)
+ {
+ /* fd denotes an inheritable descriptor. */
+ handles_aligned[fd] = handle;
+ /* On Microsoft Windows, it would be sufficient to set
+ flags[fd] = 1. But on ReactOS or Wine, adding the bit
+ that indicates the handle type may be necessary. So,
+ just do it everywhere. */
+ flags[fd] = 1 | inh_handles->flags[fd];
+ switch (GetFileType (handle))
+ {
+ case FILE_TYPE_CHAR:
+ flags[fd] |= 64;
+ break;
+ case FILE_TYPE_PIPE:
+ flags[fd] |= 8;
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ /* We shouldn't have any non-inheritable handles in
+ inh_handles->handles. */
+ abort ();
+ }
+ }
+ }
+ }
+ if (handles != (char *) handles_aligned)
+ memmove (handles, (char *) handles_aligned, handles_count * sizeof (HANDLE));
+
+ sinfo->lpReserved2 = (BYTE *) hblock;
+
+ return 0;
+}
+
+void
+free_inheritable_handles (struct inheritable_handles *inh_handles)
+{
+ free (inh_handles->flags);
+ free (inh_handles->handles);
+}
+
+int
+convert_CreateProcess_error (DWORD error)
+{
+ /* Some of these errors probably cannot happen. But who knows... */
+ switch (error)
+ {
+ case ERROR_FILE_NOT_FOUND:
+ case ERROR_PATH_NOT_FOUND:
+ case ERROR_BAD_PATHNAME:
+ case ERROR_BAD_NET_NAME:
+ case ERROR_INVALID_NAME:
+ case ERROR_DIRECTORY:
+ return ENOENT;
+ break;
+
+ case ERROR_ACCESS_DENIED:
+ case ERROR_SHARING_VIOLATION:
+ return EACCES;
+ break;
+
+ case ERROR_OUTOFMEMORY:
+ return ENOMEM;
+ break;
+
+ case ERROR_BUFFER_OVERFLOW:
+ case ERROR_FILENAME_EXCED_RANGE:
+ return ENAMETOOLONG;
+ break;
+
+ case ERROR_BAD_FORMAT:
+ case ERROR_BAD_EXE_FORMAT:
+ return ENOEXEC;
+ break;
+
+ default:
+ return EINVAL;
+ break;
+ }
+}
+
+intptr_t
+spawnpvech (int mode,
+ const char *progname, const char * const *argv,
+ const char * const *envp,
+ const char *currdir,
+ HANDLE stdin_handle, HANDLE stdout_handle, HANDLE stderr_handle)
+{
+ /* Validate the arguments. */
+ if (!(mode == P_WAIT
+ || mode == P_NOWAIT
+ || mode == P_DETACH
+ || mode == P_OVERLAY)
+ || progname == NULL || argv == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* Implement the 'p' letter: search for PROGNAME in getenv ("PATH"). */
+ const char *resolved_progname =
+ find_in_given_path (progname, getenv ("PATH"), NULL, false);
+ if (resolved_progname == NULL)
+ return -1;
+
+ /* Compose the command. */
+ char *command = compose_command (argv);
+ if (command == NULL)
+ goto out_of_memory_1;
+
+ /* Copy *ENVP into a contiguous block of memory. */
+ char *envblock;
+ if (envp == NULL)
+ envblock = NULL;
+ else
+ {
+ envblock = compose_envblock (envp);
+ if (envblock == NULL)
+ goto out_of_memory_2;
+ }
+
+ /* Collect the inheritable handles. */
+ struct inheritable_handles inh_handles;
+ if (init_inheritable_handles (&inh_handles, false) < 0)
+ {
+ int saved_errno = errno;
+ if (envblock != NULL)
+ free (envblock);
+ free (command);
+ if (resolved_progname != progname)
+ free ((char *) resolved_progname);
+ errno = saved_errno;
+ return -1;
+ }
+ inh_handles.handles[0] = stdin_handle; inh_handles.flags[0] = 0;
+ inh_handles.handles[1] = stdout_handle; inh_handles.flags[1] = 0;
+ inh_handles.handles[2] = stderr_handle; inh_handles.flags[2] = 0;
+
+ /* CreateProcess
+ <https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa> */
+ /* <https://docs.microsoft.com/en-us/windows/win32/procthread/process-creation-flags> */
+ DWORD process_creation_flags = (mode == P_DETACH ? DETACHED_PROCESS : 0);
+ /* STARTUPINFO
+ <https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfoa> */
+ STARTUPINFO sinfo;
+ sinfo.cb = sizeof (STARTUPINFO);
+ sinfo.lpReserved = NULL;
+ sinfo.lpDesktop = NULL;
+ sinfo.lpTitle = NULL;
+ if (compose_handles_block (&inh_handles, &sinfo) < 0)
+ {
+ int saved_errno = errno;
+ free_inheritable_handles (&inh_handles);
+ if (envblock != NULL)
+ free (envblock);
+ free (command);
+ if (resolved_progname != progname)
+ free ((char *) resolved_progname);
+ errno = saved_errno;
+ return -1;
+ }
+
+ PROCESS_INFORMATION pinfo;
+ if (!CreateProcess (resolved_progname, command, NULL, NULL, TRUE,
+ process_creation_flags, envblock, currdir, &sinfo,
+ &pinfo))
+ {
+ DWORD error = GetLastError ();
+
+ free (sinfo.lpReserved2);
+ free_inheritable_handles (&inh_handles);
+ if (envblock != NULL)
+ free (envblock);
+ free (command);
+ if (resolved_progname != progname)
+ free ((char *) resolved_progname);
+
+ errno = convert_CreateProcess_error (error);
+ return -1;
+ }
+
+ if (pinfo.hThread)
+ CloseHandle (pinfo.hThread);
+ free (sinfo.lpReserved2);
+ free_inheritable_handles (&inh_handles);
+ if (envblock != NULL)
+ free (envblock);
+ free (command);
+ if (resolved_progname != progname)
+ free ((char *) resolved_progname);
+
+ switch (mode)
+ {
+ case P_WAIT:
+ {
+ /* Wait until it terminates. Then get its exit status code. */
+ switch (WaitForSingleObject (pinfo.hProcess, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ break;
+ case WAIT_FAILED:
+ errno = ECHILD;
+ return -1;
+ default:
+ abort ();
+ }
+
+ DWORD exit_code;
+ if (!GetExitCodeProcess (pinfo.hProcess, &exit_code))
+ {
+ errno = ECHILD;
+ return -1;
+ }
+ CloseHandle (pinfo.hProcess);
+ return exit_code;
+ }
+
+ case P_NOWAIT:
+ /* Return pinfo.hProcess, not pinfo.dwProcessId. */
+ return (intptr_t) pinfo.hProcess;
+
+ case P_DETACH:
+ case P_OVERLAY:
+ CloseHandle (pinfo.hProcess);
+ return 0;
+
+ default:
+ /* Already checked above. */
+ abort ();
+ }
+
+ /*NOTREACHED*/
+ out_of_memory_2:
+ free (command);
+ out_of_memory_1:
+ if (resolved_progname != progname)
+ free ((char *) resolved_progname);
+ errno = ENOMEM;
+ return -1;
+}
diff --git a/lib/windows-spawn.h b/lib/windows-spawn.h
new file mode 100644
index 000000000..0be407bf9
--- /dev/null
+++ b/lib/windows-spawn.h
@@ -0,0 +1,157 @@
+/* Auxiliary functions for the creation of subprocesses. Native Windows API.
+ Copyright (C) 2001, 2003-2022 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2003.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _WINDOWS_SPAWN_H
+#define _WINDOWS_SPAWN_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+/* Get declarations of the native Windows API functions. */
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+
+/* Prepares an argument vector before calling spawn().
+
+ Note that spawn() does not by itself call the command interpreter
+ (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
+ ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&v);
+ v.dwPlatformId == VER_PLATFORM_WIN32_NT;
+ }) ? "cmd.exe" : "command.com").
+ Instead it simply concatenates the arguments, separated by ' ', and calls
+ CreateProcess(). We must quote the arguments since Windows CreateProcess()
+ interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
+ special way:
+ - Space and tab are interpreted as delimiters. They are not treated as
+ delimiters if they are surrounded by double quotes: "...".
+ - Unescaped double quotes are removed from the input. Their only effect is
+ that within double quotes, space and tab are treated like normal
+ characters.
+ - Backslashes not followed by double quotes are not special.
+ - But 2*n+1 backslashes followed by a double quote become
+ n backslashes followed by a double quote (n >= 0):
+ \" -> "
+ \\\" -> \"
+ \\\\\" -> \\"
+ - '*', '?' characters may get expanded through wildcard expansion in the
+ callee: By default, in the callee, the initialization code before main()
+ takes the result of GetCommandLine(), wildcard-expands it, and passes it
+ to main(). The exceptions to this rule are:
+ - programs that inspect GetCommandLine() and ignore argv,
+ - mingw programs that have a global variable 'int _CRT_glob = 0;',
+ - Cygwin programs, when invoked from a Cygwin program.
+
+ prepare_spawn creates and returns a new argument vector, where the arguments
+ are appropriately quoted and an additional argument "sh.exe" has been added
+ at the beginning. The new argument vector is freshly allocated. The memory
+ for all its elements is allocated within *MEM_TO_FREE, which is freshly
+ allocated as well. In case of memory allocation failure, NULL is returned,
+ with errno set.
+ */
+extern const char ** prepare_spawn (const char * const *argv,
+ char **mem_to_free);
+
+/* Composes the command to be passed to CreateProcess().
+ ARGV must contain appropriately quoted arguments, as returned by
+ prepare_spawn.
+ Returns a freshly allocated string. In case of memory allocation failure,
+ NULL is returned, with errno set. */
+extern char * compose_command (const char * const *argv)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
+
+/* Composes the block of memory that contains the environment variables.
+ ENVP must contain an environment (a NULL-terminated array of string of the
+ form VARIABLE=VALUE).
+ Returns a freshly allocated block of memory. In case of memory allocation
+ failure, NULL is returned, with errno set. */
+extern char * compose_envblock (const char * const *envp)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
+
+
+/* This struct keeps track of which handles to pass to a subprocess, and with
+ which flags. All of the handles here are inheritable.
+ Regarding handle inheritance, see
+ <https://docs.microsoft.com/en-us/windows/win32/sysinfo/handle-inheritance> */
+struct inheritable_handles
+{
+ /* The number of occupied entries in the two arrays below.
+ 3 <= count <= allocated. */
+ size_t count;
+ /* The number of allocated entries in the two arrays below. */
+ size_t allocated;
+ /* handles[0..count-1] are the occupied entries.
+ handles[fd] is either INVALID_HANDLE_VALUE or an inheritable handle. */
+ HANDLE *handles;
+ /* flags[0..count-1] are the occupied entries.
+ flags[fd] is only relevant if handles[fd] != INVALID_HANDLE_VALUE.
+ It is a bit mask consisting of:
+ - 32 for O_APPEND.
+ */
+ unsigned char *flags;
+};
+
+/* Initializes a set of inheritable handles, filling in all inheritable handles
+ assigned to file descriptors.
+ If DUPLICATE is true, the handles stored in the set are duplicates.
+ Returns 0 upon success. In case of failure, -1 is returned, with errno set.
+ */
+extern int init_inheritable_handles (struct inheritable_handles *inh_handles,
+ bool duplicate);
+
+/* Fills a set of inheritable handles into a STARTUPINFO for CreateProcess().
+ Returns 0 upon success. In case of failure, -1 is returned, with errno set.
+ */
+extern int compose_handles_block (const struct inheritable_handles *inh_handles,
+ STARTUPINFOA *sinfo);
+
+/* Frees the memory held by a set of inheritable handles. */
+extern void free_inheritable_handles (struct inheritable_handles *inh_handles);
+
+
+/* Converts a CreateProcess() error code (retrieved through GetLastError()) to
+ an errno value. */
+extern int convert_CreateProcess_error (DWORD error);
+
+
+/* Creates a subprocess.
+ MODE is either P_WAIT or P_NOWAIT.
+ PROGNAME is the program to invoke.
+ ARGV is the NULL-terminated array of arguments, ARGV[0] being PROGNAME by
+ convention.
+ ENVP is the NULL-terminated set of environment variable assignments, or NULL
+ to inherit the initial environ variable assignments from the caller and
+ ignore all calls to putenv(), setenv(), unsetenv() done in the caller.
+ CURRDIR is the directory in which to start the program, or NULL to inherit
+ the working directory from the caller.
+ STDIN_HANDLE, STDOUT_HANDLE, STDERR_HANDLE are the handles to use for the
+ first three file descriptors in the callee process.
+ Returns
+ - 0 for success (if MODE is P_WAIT), or
+ - a handle that be passed to _cwait (on Windows) or waitpid (on OS/2), or
+ - -1 upon error, with errno set.
+ */
+extern intptr_t spawnpvech (int mode,
+ const char *progname, const char * const *argv,
+ const char * const *envp,
+ const char *currdir,
+ HANDLE stdin_handle, HANDLE stdout_handle,
+ HANDLE stderr_handle);
+
+#endif /* _WINDOWS_SPAWN_H */
diff --git a/lib/write.c b/lib/write.c
index 614cdc62f..bcbc97c63 100644
--- a/lib/write.c
+++ b/lib/write.c
@@ -1,5 +1,5 @@
/* POSIX compatible write() function.
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This file is free software: you can redistribute it and/or modify
diff --git a/lib/xalloc-oversized.h b/lib/xalloc-oversized.h
index 4184f3395..aefa6fd80 100644
--- a/lib/xalloc-oversized.h
+++ b/lib/xalloc-oversized.h
@@ -1,6 +1,6 @@
/* xalloc-oversized.h -- memory allocation size checking
- Copyright (C) 1990-2000, 2003-2004, 2006-2021 Free Software Foundation, Inc.
+ Copyright (C) 1990-2000, 2003-2004, 2006-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/xsize.c b/lib/xsize.c
index b3d73a2d8..761e3434d 100644
--- a/lib/xsize.c
+++ b/lib/xsize.c
@@ -1,6 +1,6 @@
/* Checked size_t computations.
- Copyright (C) 2012-2021 Free Software Foundation, Inc.
+ Copyright (C) 2012-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/xsize.h b/lib/xsize.h
index 91fa877ce..0bfa4c889 100644
--- a/lib/xsize.h
+++ b/lib/xsize.h
@@ -1,6 +1,6 @@
/* xsize.h -- Checked size_t computations.
- Copyright (C) 2003, 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as