aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVibhav Pant2023-06-06 19:30:27 +0530
committerVibhav Pant2023-06-06 19:30:27 +0530
commit49ffcbf86a32a8a217538d4df3736fe069ccf35d (patch)
treea5f16157cc20fb19a844473a6fbd2b434f4c8260 /lib
parentaf569fa3d90a717983b743eb97adbf869c6d1736 (diff)
parent7ca1d782f5910d0c3978c6798a45c6854ec668c7 (diff)
downloademacs-49ffcbf86a32a8a217538d4df3736fe069ccf35d.tar.gz
emacs-49ffcbf86a32a8a217538d4df3736fe069ccf35d.zip
Merge branch 'master' into scratch/comp-static-data
Diffstat (limited to 'lib')
-rw-r--r--lib/acl-internal.h8
-rw-r--r--lib/acl.h5
-rw-r--r--lib/attribute.h15
-rw-r--r--lib/binary-io.h8
-rw-r--r--lib/c++defs.h6
-rw-r--r--lib/c-ctype.h4
-rw-r--r--lib/c-strcase.h5
-rw-r--r--lib/careadlinkat.h5
-rw-r--r--lib/count-leading-zeros.h8
-rw-r--r--lib/count-one-bits.h8
-rw-r--r--lib/count-trailing-zeros.h8
-rw-r--r--lib/dirent-private.h67
-rw-r--r--lib/dirent.in.h49
-rw-r--r--lib/dirfd.c17
-rw-r--r--lib/eloop-threshold.h5
-rw-r--r--lib/execinfo.in.h4
-rw-r--r--lib/fcntl.in.h5
-rw-r--r--lib/fdopendir.c97
-rw-r--r--lib/file-has-acl.c111
-rw-r--r--lib/filemode.h6
-rw-r--r--lib/filevercmp.h5
-rw-r--r--lib/flexmember.h5
-rw-r--r--lib/fpending.h6
-rw-r--r--lib/gettime.c4
-rw-r--r--lib/gettimeofday.c14
-rw-r--r--lib/gnulib.mk.in35
-rw-r--r--lib/inttypes.in.h5
-rw-r--r--lib/limits.in.h5
-rw-r--r--lib/malloc/dynarray_emplace_enlarge.c4
-rw-r--r--lib/malloc/dynarray_resize.c4
-rw-r--r--lib/md5.h5
-rw-r--r--lib/minmax.h5
-rw-r--r--lib/mktime.c11
-rw-r--r--lib/nanosleep.c3
-rw-r--r--lib/nstrftime.c44
-rw-r--r--lib/openat.h9
-rw-r--r--lib/pathmax.h5
-rw-r--r--lib/pselect.c12
-rw-r--r--lib/regex_internal.h3
-rw-r--r--lib/regexec.c2
-rw-r--r--lib/sha1.h5
-rw-r--r--lib/sha256.h5
-rw-r--r--lib/sha512.h5
-rw-r--r--lib/signal.in.h5
-rw-r--r--lib/stat-time.h45
-rw-r--r--lib/stddef.in.h52
-rw-r--r--lib/stdio.in.h95
-rw-r--r--lib/stdlib.in.h63
-rw-r--r--lib/string.in.h6
-rw-r--r--lib/strtol.c14
-rw-r--r--lib/sys_random.in.h5
-rw-r--r--lib/sys_select.in.h12
-rw-r--r--lib/sys_stat.in.h12
-rw-r--r--lib/sys_time.in.h12
-rw-r--r--lib/sys_types.in.h7
-rw-r--r--lib/time.in.h31
-rw-r--r--lib/timespec-add.c5
-rw-r--r--lib/timespec-sub.c5
-rw-r--r--lib/timespec.h14
-rw-r--r--lib/u64.h8
-rw-r--r--lib/unistd.in.h9
-rw-r--r--lib/unlocked-io.h5
-rw-r--r--lib/utimens.c20
-rw-r--r--lib/utimens.h8
-rw-r--r--lib/verify.h34
65 files changed, 879 insertions, 230 deletions
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index c97e847cdc5..496e41d7b21 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -17,6 +17,11 @@
17 17
18 Written by Paul Eggert, Andreas Grünbacher, and Bruno Haible. */ 18 Written by Paul Eggert, Andreas Grünbacher, and Bruno Haible. */
19 19
20/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_ATTRIBUTE_PURE. */
21#if !_GL_CONFIG_H_INCLUDED
22 #error "Please include config.h first."
23#endif
24
20#include "acl.h" 25#include "acl.h"
21 26
22#include <stdlib.h> 27#include <stdlib.h>
@@ -60,9 +65,6 @@ extern int aclsort (int, int, struct acl *);
60# define fchmod(fd, mode) (-1) 65# define fchmod(fd, mode) (-1)
61#endif 66#endif
62 67
63#ifndef _GL_INLINE_HEADER_BEGIN
64 #error "Please include config.h first."
65#endif
66_GL_INLINE_HEADER_BEGIN 68_GL_INLINE_HEADER_BEGIN
67#ifndef ACL_INTERNAL_INLINE 69#ifndef ACL_INTERNAL_INLINE
68# define ACL_INTERNAL_INLINE _GL_INLINE 70# define ACL_INTERNAL_INLINE _GL_INLINE
diff --git a/lib/acl.h b/lib/acl.h
index 58e5797179e..0d021200556 100644
--- a/lib/acl.h
+++ b/lib/acl.h
@@ -20,6 +20,11 @@
20#ifndef _GL_ACL_H 20#ifndef _GL_ACL_H
21#define _GL_ACL_H 1 21#define _GL_ACL_H 1
22 22
23/* This file uses _GL_ATTRIBUTE_CONST. */
24#if !_GL_CONFIG_H_INCLUDED
25 #error "Please include config.h first."
26#endif
27
23#include <sys/types.h> 28#include <sys/types.h>
24#include <sys/stat.h> 29#include <sys/stat.h>
25 30
diff --git a/lib/attribute.h b/lib/attribute.h
index 130644d8798..9464fde0f30 100644
--- a/lib/attribute.h
+++ b/lib/attribute.h
@@ -41,6 +41,21 @@
41 These names begin with 'ATTRIBUTE_' to avoid name clashes. */ 41 These names begin with 'ATTRIBUTE_' to avoid name clashes. */
42 42
43 43
44/* This file uses _GL_ATTRIBUTE_ALLOC_SIZE, _GL_ATTRIBUTE_ALWAYS_INLINE,
45 _GL_ATTRIBUTE_ARTIFICIAL, _GL_ATTRIBUTE_COLD, _GL_ATTRIBUTE_CONST,
46 _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEPRECATED, _GL_ATTRIBUTE_ERROR,
47 _GL_ATTRIBUTE_WARNING, _GL_ATTRIBUTE_EXTERNALLY_VISIBLE,
48 _GL_ATTRIBUTE_FALLTHROUGH, _GL_ATTRIBUTE_FORMAT, _GL_ATTRIBUTE_LEAF,
49 _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_MAY_ALIAS, _GL_ATTRIBUTE_MAYBE_UNUSED,
50 _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOINLINE, _GL_ATTRIBUTE_NONNULL,
51 _GL_ATTRIBUTE_NONSTRING, _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PACKED,
52 _GL_ATTRIBUTE_PURE, _GL_ATTRIBUTE_RETURNS_NONNULL,
53 _GL_ATTRIBUTE_SENTINEL. */
54#if !_GL_CONFIG_H_INCLUDED
55 #error "Please include config.h first."
56#endif
57
58
44/* =============== Attributes for specific kinds of functions =============== */ 59/* =============== Attributes for specific kinds of functions =============== */
45 60
46/* Attributes for functions that should not be used. */ 61/* Attributes for functions that should not be used. */
diff --git a/lib/binary-io.h b/lib/binary-io.h
index 6f4db253354..855d6f819f0 100644
--- a/lib/binary-io.h
+++ b/lib/binary-io.h
@@ -17,6 +17,11 @@
17#ifndef _BINARY_H 17#ifndef _BINARY_H
18#define _BINARY_H 18#define _BINARY_H
19 19
20/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_UNUSED. */
21#if !_GL_CONFIG_H_INCLUDED
22 #error "Please include config.h first."
23#endif
24
20/* For systems that distinguish between text and binary I/O. 25/* For systems that distinguish between text and binary I/O.
21 O_BINARY is guaranteed by the gnulib <fcntl.h>. */ 26 O_BINARY is guaranteed by the gnulib <fcntl.h>. */
22#include <fcntl.h> 27#include <fcntl.h>
@@ -25,9 +30,6 @@
25 so we include it here first. */ 30 so we include it here first. */
26#include <stdio.h> 31#include <stdio.h>
27 32
28#ifndef _GL_INLINE_HEADER_BEGIN
29 #error "Please include config.h first."
30#endif
31_GL_INLINE_HEADER_BEGIN 33_GL_INLINE_HEADER_BEGIN
32#ifndef BINARY_IO_INLINE 34#ifndef BINARY_IO_INLINE
33# define BINARY_IO_INLINE _GL_INLINE 35# define BINARY_IO_INLINE _GL_INLINE
diff --git a/lib/c++defs.h b/lib/c++defs.h
index 8ad46951ad4..458c014de5c 100644
--- a/lib/c++defs.h
+++ b/lib/c++defs.h
@@ -99,6 +99,12 @@
99 Example: 99 Example:
100 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 100 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
101 _GL_ARG_NONNULL ((1))); 101 _GL_ARG_NONNULL ((1)));
102
103 Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front
104 of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's
105 because
106 [[...]] extern "C" <declaration>;
107 is invalid syntax in C++.)
102 */ 108 */
103#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ 109#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
104 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) 110 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
diff --git a/lib/c-ctype.h b/lib/c-ctype.h
index 35ca83d7d43..cb0f4f3ba1f 100644
--- a/lib/c-ctype.h
+++ b/lib/c-ctype.h
@@ -23,9 +23,11 @@
23#ifndef C_CTYPE_H 23#ifndef C_CTYPE_H
24#define C_CTYPE_H 24#define C_CTYPE_H
25 25
26#ifndef _GL_INLINE_HEADER_BEGIN 26/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */
27#if !_GL_CONFIG_H_INCLUDED
27 #error "Please include config.h first." 28 #error "Please include config.h first."
28#endif 29#endif
30
29_GL_INLINE_HEADER_BEGIN 31_GL_INLINE_HEADER_BEGIN
30#ifndef C_CTYPE_INLINE 32#ifndef C_CTYPE_INLINE
31# define C_CTYPE_INLINE _GL_INLINE 33# define C_CTYPE_INLINE _GL_INLINE
diff --git a/lib/c-strcase.h b/lib/c-strcase.h
index 9bcca01b27c..5dfa96c41f4 100644
--- a/lib/c-strcase.h
+++ b/lib/c-strcase.h
@@ -18,6 +18,11 @@
18#ifndef C_STRCASE_H 18#ifndef C_STRCASE_H
19#define C_STRCASE_H 19#define C_STRCASE_H
20 20
21/* This file uses _GL_ATTRIBUTE_PURE. */
22#if !_GL_CONFIG_H_INCLUDED
23 #error "Please include config.h first."
24#endif
25
21#include <stddef.h> 26#include <stddef.h>
22 27
23 28
diff --git a/lib/careadlinkat.h b/lib/careadlinkat.h
index 201d0415fff..562cf013b75 100644
--- a/lib/careadlinkat.h
+++ b/lib/careadlinkat.h
@@ -20,6 +20,11 @@
20#ifndef _GL_CAREADLINKAT_H 20#ifndef _GL_CAREADLINKAT_H
21#define _GL_CAREADLINKAT_H 21#define _GL_CAREADLINKAT_H
22 22
23/* This file uses HAVE_READLINKAT. */
24#if !_GL_CONFIG_H_INCLUDED
25 #error "Please include config.h first."
26#endif
27
23#include <fcntl.h> 28#include <fcntl.h>
24#include <unistd.h> 29#include <unistd.h>
25 30
diff --git a/lib/count-leading-zeros.h b/lib/count-leading-zeros.h
index 99151d695bf..9fe2a03ee09 100644
--- a/lib/count-leading-zeros.h
+++ b/lib/count-leading-zeros.h
@@ -19,12 +19,14 @@
19#ifndef COUNT_LEADING_ZEROS_H 19#ifndef COUNT_LEADING_ZEROS_H
20#define COUNT_LEADING_ZEROS_H 1 20#define COUNT_LEADING_ZEROS_H 1
21 21
22/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */
23#if !_GL_CONFIG_H_INCLUDED
24 #error "Please include config.h first."
25#endif
26
22#include <limits.h> 27#include <limits.h>
23#include <stdlib.h> 28#include <stdlib.h>
24 29
25#ifndef _GL_INLINE_HEADER_BEGIN
26 #error "Please include config.h first."
27#endif
28_GL_INLINE_HEADER_BEGIN 30_GL_INLINE_HEADER_BEGIN
29#ifndef COUNT_LEADING_ZEROS_INLINE 31#ifndef COUNT_LEADING_ZEROS_INLINE
30# define COUNT_LEADING_ZEROS_INLINE _GL_INLINE 32# define COUNT_LEADING_ZEROS_INLINE _GL_INLINE
diff --git a/lib/count-one-bits.h b/lib/count-one-bits.h
index 01a60b77b85..2821a1fb75e 100644
--- a/lib/count-one-bits.h
+++ b/lib/count-one-bits.h
@@ -19,12 +19,14 @@
19#ifndef COUNT_ONE_BITS_H 19#ifndef COUNT_ONE_BITS_H
20#define COUNT_ONE_BITS_H 1 20#define COUNT_ONE_BITS_H 1
21 21
22/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */
23#if !_GL_CONFIG_H_INCLUDED
24 #error "Please include config.h first."
25#endif
26
22#include <limits.h> 27#include <limits.h>
23#include <stdlib.h> 28#include <stdlib.h>
24 29
25#ifndef _GL_INLINE_HEADER_BEGIN
26 #error "Please include config.h first."
27#endif
28_GL_INLINE_HEADER_BEGIN 30_GL_INLINE_HEADER_BEGIN
29#ifndef COUNT_ONE_BITS_INLINE 31#ifndef COUNT_ONE_BITS_INLINE
30# define COUNT_ONE_BITS_INLINE _GL_INLINE 32# define COUNT_ONE_BITS_INLINE _GL_INLINE
diff --git a/lib/count-trailing-zeros.h b/lib/count-trailing-zeros.h
index ef8e164126a..9b33df76f6d 100644
--- a/lib/count-trailing-zeros.h
+++ b/lib/count-trailing-zeros.h
@@ -19,12 +19,14 @@
19#ifndef COUNT_TRAILING_ZEROS_H 19#ifndef COUNT_TRAILING_ZEROS_H
20#define COUNT_TRAILING_ZEROS_H 1 20#define COUNT_TRAILING_ZEROS_H 1
21 21
22/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */
23#if !_GL_CONFIG_H_INCLUDED
24 #error "Please include config.h first."
25#endif
26
22#include <limits.h> 27#include <limits.h>
23#include <stdlib.h> 28#include <stdlib.h>
24 29
25#ifndef _GL_INLINE_HEADER_BEGIN
26 #error "Please include config.h first."
27#endif
28_GL_INLINE_HEADER_BEGIN 30_GL_INLINE_HEADER_BEGIN
29#ifndef COUNT_TRAILING_ZEROS_INLINE 31#ifndef COUNT_TRAILING_ZEROS_INLINE
30# define COUNT_TRAILING_ZEROS_INLINE _GL_INLINE 32# define COUNT_TRAILING_ZEROS_INLINE _GL_INLINE
diff --git a/lib/dirent-private.h b/lib/dirent-private.h
new file mode 100644
index 00000000000..012b6837198
--- /dev/null
+++ b/lib/dirent-private.h
@@ -0,0 +1,67 @@
1/* Private details of the DIR type.
2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#ifndef _DIRENT_PRIVATE_H
18#define _DIRENT_PRIVATE_H 1
19
20#if HAVE_DIRENT_H /* mingw */
21
22# undef DIR
23
24struct gl_directory
25{
26 /* File descriptor to close during closedir().
27 Needed for implementing fdopendir(). */
28 int fd_to_close;
29 /* Pointer to the real DIR. */
30 DIR *real_dirp;
31};
32
33/* Restore definition from dirent.h. */
34# define DIR struct gl_directory
35
36#else /* MSVC */
37
38# define WIN32_LEAN_AND_MEAN
39# include <windows.h>
40
41/* Don't assume that UNICODE is not defined. */
42# undef WIN32_FIND_DATA
43# define WIN32_FIND_DATA WIN32_FIND_DATAA
44
45struct gl_directory
46{
47 /* File descriptor to close during closedir().
48 Needed for implementing fdopendir(). */
49 int fd_to_close;
50 /* Status, or error code to produce in next readdir() call.
51 -2 means the end of the directory is already reached,
52 -1 means the entry was already filled by FindFirstFile,
53 0 means the entry needs to be filled using FindNextFile.
54 A positive value is an error code. */
55 int status;
56 /* Handle, reading the directory, at current position. */
57 HANDLE current;
58 /* Found directory entry. */
59 WIN32_FIND_DATA entry;
60 /* Argument to pass to FindFirstFile. It consists of the absolutized
61 directory name, followed by a directory separator and the wildcards. */
62 char dir_name_mask[1];
63};
64
65#endif
66
67#endif /* _DIRENT_PRIVATE_H */
diff --git a/lib/dirent.in.h b/lib/dirent.in.h
index 2aaabd054a8..d409a031ec8 100644
--- a/lib/dirent.in.h
+++ b/lib/dirent.in.h
@@ -29,6 +29,12 @@
29#ifndef _@GUARD_PREFIX@_DIRENT_H 29#ifndef _@GUARD_PREFIX@_DIRENT_H
30#define _@GUARD_PREFIX@_DIRENT_H 30#define _@GUARD_PREFIX@_DIRENT_H
31 31
32/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
33 _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
34#if !_GL_CONFIG_H_INCLUDED
35 #error "Please include config.h first."
36#endif
37
32/* Get ino_t. Needed on some systems, including glibc 2.8. */ 38/* Get ino_t. Needed on some systems, including glibc 2.8. */
33#include <sys/types.h> 39#include <sys/types.h>
34 40
@@ -50,11 +56,24 @@ struct dirent
50# define DT_LNK 10 /* symbolic link */ 56# define DT_LNK 10 /* symbolic link */
51# define DT_SOCK 12 /* socket */ 57# define DT_SOCK 12 /* socket */
52# define DT_WHT 14 /* whiteout */ 58# define DT_WHT 14 /* whiteout */
53typedef struct gl_directory DIR;
54# define GNULIB_defined_struct_dirent 1 59# define GNULIB_defined_struct_dirent 1
55# endif 60# endif
56#endif 61#endif
57 62
63#if !@DIR_HAS_FD_MEMBER@
64# if !GNULIB_defined_DIR
65/* struct gl_directory is a type with a field 'int fd_to_close'.
66 It is needed for implementing fdopendir(). */
67struct gl_directory;
68# if @HAVE_DIRENT_H@
69# define DIR struct gl_directory
70# else
71typedef struct gl_directory DIR;
72# endif
73# define GNULIB_defined_DIR 1
74# endif
75#endif
76
58/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers 77/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
59 that can be freed by passing them as the Ith argument to the 78 that can be freed by passing them as the Ith argument to the
60 function F. */ 79 function F. */
@@ -143,7 +162,7 @@ _GL_CXXALIAS_SYS (opendir, DIR *, (const char *dir_name));
143# endif 162# endif
144_GL_CXXALIASWARN (opendir); 163_GL_CXXALIASWARN (opendir);
145#else 164#else
146# if @GNULIB_CLOSEDIR@ && __GNUC__ >= 11 && !defined opendir 165# if @GNULIB_CLOSEDIR@ && !GNULIB_defined_DIR && __GNUC__ >= 11 && !defined opendir
147/* For -Wmismatched-dealloc: Associate opendir with closedir or 166/* For -Wmismatched-dealloc: Associate opendir with closedir or
148 rpl_closedir. */ 167 rpl_closedir. */
149_GL_FUNCDECL_SYS (opendir, DIR *, 168_GL_FUNCDECL_SYS (opendir, DIR *,
@@ -161,10 +180,19 @@ _GL_WARN_ON_USE (opendir, "opendir is not portable - "
161#endif 180#endif
162 181
163#if @GNULIB_READDIR@ 182#if @GNULIB_READDIR@
164# if !@HAVE_READDIR@ 183# if @REPLACE_READDIR@
184# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
185# undef readdir
186# define readdir rpl_readdir
187# endif
188_GL_FUNCDECL_RPL (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1)));
189_GL_CXXALIAS_RPL (readdir, struct dirent *, (DIR *dirp));
190# else
191# if !@HAVE_READDIR@
165_GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1))); 192_GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1)));
166# endif 193# endif
167_GL_CXXALIAS_SYS (readdir, struct dirent *, (DIR *dirp)); 194_GL_CXXALIAS_SYS (readdir, struct dirent *, (DIR *dirp));
195# endif
168_GL_CXXALIASWARN (readdir); 196_GL_CXXALIASWARN (readdir);
169#elif defined GNULIB_POSIXCHECK 197#elif defined GNULIB_POSIXCHECK
170# undef readdir 198# undef readdir
@@ -175,10 +203,19 @@ _GL_WARN_ON_USE (readdir, "readdir is not portable - "
175#endif 203#endif
176 204
177#if @GNULIB_REWINDDIR@ 205#if @GNULIB_REWINDDIR@
178# if !@HAVE_REWINDDIR@ 206# if @REPLACE_REWINDDIR@
207# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
208# undef rewinddir
209# define rewinddir rpl_rewinddir
210# endif
211_GL_FUNCDECL_RPL (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1)));
212_GL_CXXALIAS_RPL (rewinddir, void, (DIR *dirp));
213# else
214# if !@HAVE_REWINDDIR@
179_GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1))); 215_GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1)));
180# endif 216# endif
181_GL_CXXALIAS_SYS (rewinddir, void, (DIR *dirp)); 217_GL_CXXALIAS_SYS (rewinddir, void, (DIR *dirp));
218# endif
182_GL_CXXALIASWARN (rewinddir); 219_GL_CXXALIASWARN (rewinddir);
183#elif defined GNULIB_POSIXCHECK 220#elif defined GNULIB_POSIXCHECK
184# undef rewinddir 221# undef rewinddir
diff --git a/lib/dirfd.c b/lib/dirfd.c
index b2b1d25cdbd..75b2163c353 100644
--- a/lib/dirfd.c
+++ b/lib/dirfd.c
@@ -22,6 +22,10 @@
22#include <dirent.h> 22#include <dirent.h>
23#include <errno.h> 23#include <errno.h>
24 24
25#if GNULIB_defined_DIR
26# include "dirent-private.h"
27#endif
28
25#ifdef __KLIBC__ 29#ifdef __KLIBC__
26# include <stdlib.h> 30# include <stdlib.h>
27# include <io.h> 31# include <io.h>
@@ -78,11 +82,17 @@ _gl_unregister_dirp_fd (int fd)
78int 82int
79dirfd (DIR *dir_p) 83dirfd (DIR *dir_p)
80{ 84{
85#if GNULIB_defined_DIR
86 int fd = dir_p->fd_to_close;
87 if (fd == -1)
88 errno = EINVAL;
89 return fd;
90#else
81 int fd = DIR_TO_FD (dir_p); 91 int fd = DIR_TO_FD (dir_p);
82 if (fd == -1) 92 if (fd == -1)
83#ifndef __KLIBC__ 93# ifndef __KLIBC__
84 errno = ENOTSUP; 94 errno = ENOTSUP;
85#else 95# else
86 { 96 {
87 struct dirp_fd_list *dirp_fd; 97 struct dirp_fd_list *dirp_fd;
88 98
@@ -92,7 +102,8 @@ dirfd (DIR *dir_p)
92 102
93 errno = EINVAL; 103 errno = EINVAL;
94 } 104 }
95#endif 105# endif
96 106
97 return fd; 107 return fd;
108#endif
98} 109}
diff --git a/lib/eloop-threshold.h b/lib/eloop-threshold.h
index 510f261795d..d9b154e4868 100644
--- a/lib/eloop-threshold.h
+++ b/lib/eloop-threshold.h
@@ -19,6 +19,11 @@
19#ifndef _ELOOP_THRESHOLD_H 19#ifndef _ELOOP_THRESHOLD_H
20#define _ELOOP_THRESHOLD_H 1 20#define _ELOOP_THRESHOLD_H 1
21 21
22/* This file uses _GL_ATTRIBUTE_CONST. */
23#if !_LIBC && !_GL_CONFIG_H_INCLUDED
24 #error "Please include config.h first."
25#endif
26
22#include <limits.h> 27#include <limits.h>
23#ifdef _LIBC 28#ifdef _LIBC
24# include <sys/param.h> 29# include <sys/param.h>
diff --git a/lib/execinfo.in.h b/lib/execinfo.in.h
index ff9293b6327..56b04d1d862 100644
--- a/lib/execinfo.in.h
+++ b/lib/execinfo.in.h
@@ -20,9 +20,11 @@
20#ifndef _GL_EXECINFO_H 20#ifndef _GL_EXECINFO_H
21#define _GL_EXECINFO_H 21#define _GL_EXECINFO_H
22 22
23#ifndef _GL_INLINE_HEADER_BEGIN 23/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */
24#if !_GL_CONFIG_H_INCLUDED
24 #error "Please include config.h first." 25 #error "Please include config.h first."
25#endif 26#endif
27
26_GL_INLINE_HEADER_BEGIN 28_GL_INLINE_HEADER_BEGIN
27#ifndef _GL_EXECINFO_INLINE 29#ifndef _GL_EXECINFO_INLINE
28# define _GL_EXECINFO_INLINE _GL_INLINE 30# define _GL_EXECINFO_INLINE _GL_INLINE
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index e034eaf9f5a..d0bb85f30b5 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -74,6 +74,11 @@
74#ifndef _@GUARD_PREFIX@_FCNTL_H 74#ifndef _@GUARD_PREFIX@_FCNTL_H
75#define _@GUARD_PREFIX@_FCNTL_H 75#define _@GUARD_PREFIX@_FCNTL_H
76 76
77/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
78#if !_GL_CONFIG_H_INCLUDED
79 #error "Please include config.h first."
80#endif
81
77#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ 82#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
78# include <unistd.h> 83# include <unistd.h>
79#endif 84#endif
diff --git a/lib/fdopendir.c b/lib/fdopendir.c
index aa841e3e819..0f43d6ff349 100644
--- a/lib/fdopendir.c
+++ b/lib/fdopendir.c
@@ -25,44 +25,27 @@
25 25
26#if !HAVE_FDOPENDIR 26#if !HAVE_FDOPENDIR
27 27
28# include "openat.h" 28# if GNULIB_defined_DIR
29# include "openat-priv.h" 29/* We are in control of the file descriptor of a DIR. */
30# include "save-cwd.h"
31 30
32# if GNULIB_DIRENT_SAFER 31# include "dirent-private.h"
33# include "dirent--.h"
34# endif
35
36# ifndef REPLACE_FCHDIR
37# define REPLACE_FCHDIR 0
38# endif
39
40static DIR *fdopendir_with_dup (int, int, struct saved_cwd const *);
41static DIR *fd_clone_opendir (int, struct saved_cwd const *);
42
43/* Replacement for POSIX fdopendir.
44 32
45 First, try to simulate it via opendir ("/proc/self/fd/..."). Failing 33# if !REPLACE_FCHDIR
46 that, simulate it by using fchdir metadata, or by doing 34# error "unexpected configuration: GNULIB_defined_DIR but fchdir not replaced"
47 save_cwd/fchdir/opendir(".")/restore_cwd. 35# endif
48 If either the save_cwd or the restore_cwd fails (relatively unlikely),
49 then give a diagnostic and exit nonzero.
50
51 If successful, the resulting stream is based on FD in
52 implementations where streams are based on file descriptors and in
53 applications where no other thread or signal handler allocates or
54 frees file descriptors. In other cases, consult dirfd on the result
55 to find out whether FD is still being used.
56 36
57 Otherwise, this function works just like POSIX fdopendir. 37DIR *
38fdopendir (int fd)
39{
40 char const *name = _gl_directory_name (fd);
41 DIR *dirp = name ? opendir (name) : NULL;
42 if (dirp != NULL)
43 dirp->fd_to_close = fd;
44 return dirp;
45}
58 46
59 W A R N I N G: 47# elif defined __KLIBC__
60 48
61 Unlike other fd-related functions, this one places constraints on FD.
62 If this function returns successfully, FD is under control of the
63 dirent.h system, and the caller should not close or modify the state of
64 FD other than by the dirent.h functions. */
65# ifdef __KLIBC__
66# include <InnoTekLIBC/backend.h> 49# include <InnoTekLIBC/backend.h>
67 50
68DIR * 51DIR *
@@ -96,7 +79,48 @@ fdopendir (int fd)
96 79
97 return dirp; 80 return dirp;
98} 81}
82
99# else 83# else
84/* We are not in control of the file descriptor of a DIR, and therefore have to
85 play tricks with file descriptors before and after a call to opendir(). */
86
87# include "openat.h"
88# include "openat-priv.h"
89# include "save-cwd.h"
90
91# if GNULIB_DIRENT_SAFER
92# include "dirent--.h"
93# endif
94
95# ifndef REPLACE_FCHDIR
96# define REPLACE_FCHDIR 0
97# endif
98
99static DIR *fdopendir_with_dup (int, int, struct saved_cwd const *);
100static DIR *fd_clone_opendir (int, struct saved_cwd const *);
101
102/* Replacement for POSIX fdopendir.
103
104 First, try to simulate it via opendir ("/proc/self/fd/..."). Failing
105 that, simulate it by using fchdir metadata, or by doing
106 save_cwd/fchdir/opendir(".")/restore_cwd.
107 If either the save_cwd or the restore_cwd fails (relatively unlikely),
108 then give a diagnostic and exit nonzero.
109
110 If successful, the resulting stream is based on FD in
111 implementations where streams are based on file descriptors and in
112 applications where no other thread or signal handler allocates or
113 frees file descriptors. In other cases, consult dirfd on the result
114 to find out whether FD is still being used.
115
116 Otherwise, this function works just like POSIX fdopendir.
117
118 W A R N I N G:
119
120 Unlike other fd-related functions, this one places constraints on FD.
121 If this function returns successfully, FD is under control of the
122 dirent.h system, and the caller should not close or modify the state of
123 FD other than by the dirent.h functions. */
100DIR * 124DIR *
101fdopendir (int fd) 125fdopendir (int fd)
102{ 126{
@@ -119,7 +143,6 @@ fdopendir (int fd)
119 143
120 return dir; 144 return dir;
121} 145}
122# endif
123 146
124/* Like fdopendir, except that if OLDER_DUPFD is not -1, it is known 147/* Like fdopendir, except that if OLDER_DUPFD is not -1, it is known
125 to be a dup of FD which is less than FD - 1 and which will be 148 to be a dup of FD which is less than FD - 1 and which will be
@@ -188,7 +211,7 @@ fd_clone_opendir (int fd, struct saved_cwd const *cwd)
188 if (proc_file != buf) 211 if (proc_file != buf)
189 free (proc_file); 212 free (proc_file);
190 } 213 }
191# if REPLACE_FCHDIR 214# if REPLACE_FCHDIR
192 if (! dir && EXPECTED_ERRNO (saved_errno)) 215 if (! dir && EXPECTED_ERRNO (saved_errno))
193 { 216 {
194 char const *name = _gl_directory_name (fd); 217 char const *name = _gl_directory_name (fd);
@@ -203,7 +226,7 @@ fd_clone_opendir (int fd, struct saved_cwd const *cwd)
203 226
204 return dp; 227 return dp;
205 } 228 }
206# endif 229# endif
207 errno = saved_errno; 230 errno = saved_errno;
208 return dir; 231 return dir;
209 } 232 }
@@ -223,6 +246,8 @@ fd_clone_opendir (int fd, struct saved_cwd const *cwd)
223 } 246 }
224} 247}
225 248
249# endif
250
226#else /* HAVE_FDOPENDIR */ 251#else /* HAVE_FDOPENDIR */
227 252
228# include <errno.h> 253# include <errno.h>
diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c
index b31a2ea2523..4cddc80bd13 100644
--- a/lib/file-has-acl.c
+++ b/lib/file-has-acl.c
@@ -29,7 +29,10 @@
29 29
30#include "acl-internal.h" 30#include "acl-internal.h"
31 31
32#if USE_ACL && GETXATTR_WITH_POSIX_ACLS 32#include "minmax.h"
33
34#if USE_ACL && HAVE_LINUX_XATTR_H && HAVE_LISTXATTR
35# include <stdckdint.h>
33# include <string.h> 36# include <string.h>
34# include <arpa/inet.h> 37# include <arpa/inet.h>
35# include <sys/xattr.h> 38# include <sys/xattr.h>
@@ -44,6 +47,20 @@ enum {
44 ACE4_IDENTIFIER_GROUP = 0x00000040 47 ACE4_IDENTIFIER_GROUP = 0x00000040
45}; 48};
46 49
50/* Return true if ATTR is in the set represented by the NUL-terminated
51 strings in LISTBUF, which is of size LISTSIZE. */
52
53static bool
54have_xattr (char const *attr, char const *listbuf, ssize_t listsize)
55{
56 char const *blim = listbuf + listsize;
57 for (char const *b = listbuf; b < blim; b += strlen (b) + 1)
58 for (char const *a = attr; *a == *b; a++, b++)
59 if (!*a)
60 return true;
61 return false;
62}
63
47/* Return 1 if given ACL in XDR format is non-trivial, 0 if it is trivial. 64/* Return 1 if given ACL in XDR format is non-trivial, 0 if it is trivial.
48 -1 upon failure to determine it. Possibly change errno. Assume that 65 -1 upon failure to determine it. Possibly change errno. Assume that
49 the ACL is valid, except avoid undefined behavior even if invalid. 66 the ACL is valid, except avoid undefined behavior even if invalid.
@@ -137,37 +154,77 @@ file_has_acl (char const *name, struct stat const *sb)
137 if (! S_ISLNK (sb->st_mode)) 154 if (! S_ISLNK (sb->st_mode))
138 { 155 {
139 156
140# if GETXATTR_WITH_POSIX_ACLS 157# if HAVE_LINUX_XATTR_H && HAVE_LISTXATTR
141
142 ssize_t ret;
143 int initial_errno = errno; 158 int initial_errno = errno;
144 159
145 ret = getxattr (name, XATTR_NAME_POSIX_ACL_ACCESS, NULL, 0); 160 /* The max length of a trivial NFSv4 ACL is 6 words for owner,
146 if (ret < 0 && errno == ENODATA) 161 6 for group, 7 for everyone, all times 2 because there are
147 ret = 0; 162 both allow and deny ACEs. There are 6 words for owner
148 else if (ret > 0) 163 because of type, flag, mask, wholen, "OWNER@"+pad and
149 return 1; 164 similarly for group; everyone is another word to hold
150 165 "EVERYONE@". */
151 if (ret == 0 && S_ISDIR (sb->st_mode)) 166 typedef uint32_t trivial_NFSv4_xattr_buf[2 * (6 + 6 + 7)];
167
168 /* A buffer large enough to hold any trivial NFSv4 ACL,
169 and also useful as a small array of char. */
170 union {
171 trivial_NFSv4_xattr_buf xattr;
172 char ch[sizeof (trivial_NFSv4_xattr_buf)];
173 } stackbuf;
174
175 char *listbuf = stackbuf.ch;
176 ssize_t listbufsize = sizeof stackbuf.ch;
177 char *heapbuf = NULL;
178 ssize_t listsize;
179
180 /* Use listxattr first, as this means just one syscall in the
181 typical case where the file lacks an ACL. Try stackbuf
182 first, falling back on malloc if stackbuf is too small. */
183 while ((listsize = listxattr (name, listbuf, listbufsize)) < 0
184 && errno == ERANGE)
152 { 185 {
153 ret = getxattr (name, XATTR_NAME_POSIX_ACL_DEFAULT, NULL, 0); 186 free (heapbuf);
154 if (ret < 0 && errno == ENODATA) 187 ssize_t newsize = listxattr (name, NULL, 0);
155 ret = 0; 188 if (newsize <= 0)
156 else if (ret > 0) 189 return newsize;
157 return 1; 190
191 /* Grow LISTBUFSIZE to at least NEWSIZE. Grow it by a
192 nontrivial amount too, to defend against denial of
193 service by an adversary that fiddles with ACLs. */
194 bool overflow = ckd_add (&listbufsize, listbufsize, listbufsize >> 1);
195 listbufsize = MAX (listbufsize, newsize);
196 if (overflow || SIZE_MAX < listbufsize)
197 {
198 errno = ENOMEM;
199 return -1;
200 }
201
202 listbuf = heapbuf = malloc (listbufsize);
203 if (!listbuf)
204 return -1;
158 } 205 }
159 206
160 if (ret < 0) 207 /* In Fedora 39, a file can have both NFSv4 and POSIX ACLs,
208 but if it has an NFSv4 ACL that's the one that matters.
209 In earlier Fedora the two types of ACLs were mutually exclusive.
210 Attempt to work correctly on both kinds of systems. */
211 bool nfsv4_acl
212 = 0 < listsize && have_xattr (XATTR_NAME_NFSV4_ACL, listbuf, listsize);
213 int ret
214 = (listsize <= 0 ? listsize
215 : (nfsv4_acl
216 || have_xattr (XATTR_NAME_POSIX_ACL_ACCESS, listbuf, listsize)
217 || (S_ISDIR (sb->st_mode)
218 && have_xattr (XATTR_NAME_POSIX_ACL_DEFAULT,
219 listbuf, listsize))));
220 free (heapbuf);
221
222 /* If there is an NFSv4 ACL, follow up with a getxattr syscall
223 to see whether the NFSv4 ACL is nontrivial. */
224 if (nfsv4_acl)
161 { 225 {
162 /* Check for NFSv4 ACLs. The max length of a trivial 226 ret = getxattr (name, XATTR_NAME_NFSV4_ACL,
163 ACL is 6 words for owner, 6 for group, 7 for everyone, 227 stackbuf.xattr, sizeof stackbuf.xattr);
164 all times 2 because there are both allow and deny ACEs.
165 There are 6 words for owner because of type, flag, mask,
166 wholen, "OWNER@"+pad and similarly for group; everyone is
167 another word to hold "EVERYONE@". */
168 uint32_t xattr[2 * (6 + 6 + 7)];
169
170 ret = getxattr (name, XATTR_NAME_NFSV4_ACL, xattr, sizeof xattr);
171 if (ret < 0) 228 if (ret < 0)
172 switch (errno) 229 switch (errno)
173 { 230 {
@@ -177,7 +234,7 @@ file_has_acl (char const *name, struct stat const *sb)
177 else 234 else
178 { 235 {
179 /* It looks like a trivial ACL, but investigate further. */ 236 /* It looks like a trivial ACL, but investigate further. */
180 ret = acl_nfs4_nontrivial (xattr, ret); 237 ret = acl_nfs4_nontrivial (stackbuf.xattr, ret);
181 if (ret < 0) 238 if (ret < 0)
182 { 239 {
183 errno = EINVAL; 240 errno = EINVAL;
diff --git a/lib/filemode.h b/lib/filemode.h
index 15a8dcc3760..3e1d9903eac 100644
--- a/lib/filemode.h
+++ b/lib/filemode.h
@@ -17,6 +17,12 @@
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#ifndef FILEMODE_H_ 19#ifndef FILEMODE_H_
20# define FILEMODE_H_
21
22/* This file uses HAVE_DECL_STRMODE. */
23# if !_GL_CONFIG_H_INCLUDED
24# error "Please include config.h first."
25# endif
20 26
21# include <sys/types.h> 27# include <sys/types.h>
22# include <sys/stat.h> 28# include <sys/stat.h>
diff --git a/lib/filevercmp.h b/lib/filevercmp.h
index 6b81ab32a7f..9e052bdd08c 100644
--- a/lib/filevercmp.h
+++ b/lib/filevercmp.h
@@ -20,6 +20,11 @@
20#ifndef FILEVERCMP_H 20#ifndef FILEVERCMP_H
21#define FILEVERCMP_H 21#define FILEVERCMP_H
22 22
23/* This file uses _GL_ATTRIBUTE_PURE. */
24#if !_GL_CONFIG_H_INCLUDED
25 #error "Please include config.h first."
26#endif
27
23#include <stddef.h> 28#include <stddef.h>
24 29
25/* Compare strings A and B as file names containing version numbers, 30/* Compare strings A and B as file names containing version numbers,
diff --git a/lib/flexmember.h b/lib/flexmember.h
index a6cc876a6d5..8c5915ecf9c 100644
--- a/lib/flexmember.h
+++ b/lib/flexmember.h
@@ -20,6 +20,11 @@
20 20
21 Written by Paul Eggert. */ 21 Written by Paul Eggert. */
22 22
23/* This file uses _Alignof. */
24#if !_GL_CONFIG_H_INCLUDED
25 #error "Please include config.h first."
26#endif
27
23#include <stddef.h> 28#include <stddef.h>
24 29
25/* Nonzero multiple of alignment of TYPE, suitable for FLEXSIZEOF below. 30/* Nonzero multiple of alignment of TYPE, suitable for FLEXSIZEOF below.
diff --git a/lib/fpending.h b/lib/fpending.h
index 5e860db6810..1604ca0b7af 100644
--- a/lib/fpending.h
+++ b/lib/fpending.h
@@ -18,6 +18,12 @@
18 18
19 Written by Jim Meyering. */ 19 Written by Jim Meyering. */
20 20
21/* This file uses _GL_ATTRIBUTE_PURE, HAVE_STDIO_EXT_H,
22 HAVE_DECL___FPENDING. */
23#if !_GL_CONFIG_H_INCLUDED
24 #error "Please include config.h first."
25#endif
26
21#include <stddef.h> 27#include <stddef.h>
22#include <stdio.h> 28#include <stdio.h>
23#if HAVE_STDIO_EXT_H 29#if HAVE_STDIO_EXT_H
diff --git a/lib/gettime.c b/lib/gettime.c
index f86cc4efbff..ec40ff903e1 100644
--- a/lib/gettime.c
+++ b/lib/gettime.c
@@ -35,8 +35,8 @@ gettime (struct timespec *ts)
35#else 35#else
36 struct timeval tv; 36 struct timeval tv;
37 gettimeofday (&tv, NULL); 37 gettimeofday (&tv, NULL);
38 ts->tv_sec = tv.tv_sec; 38 *ts = (struct timespec) { .tv_sec = tv.tv_sec,
39 ts->tv_nsec = tv.tv_usec * 1000; 39 .tv_nsec = tv.tv_usec * 1000 };
40#endif 40#endif
41} 41}
42 42
diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
index d896ec132b9..c71629cbc57 100644
--- a/lib/gettimeofday.c
+++ b/lib/gettimeofday.c
@@ -113,8 +113,10 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz)
113 ULONGLONG since_1970 = 113 ULONGLONG since_1970 =
114 since_1601 - (ULONGLONG) 134774 * (ULONGLONG) 86400 * (ULONGLONG) 10000000; 114 since_1601 - (ULONGLONG) 134774 * (ULONGLONG) 86400 * (ULONGLONG) 10000000;
115 ULONGLONG microseconds_since_1970 = since_1970 / (ULONGLONG) 10; 115 ULONGLONG microseconds_since_1970 = since_1970 / (ULONGLONG) 10;
116 tv->tv_sec = microseconds_since_1970 / (ULONGLONG) 1000000; 116 *tv = (struct timeval) {
117 tv->tv_usec = microseconds_since_1970 % (ULONGLONG) 1000000; 117 .tv_sec = microseconds_since_1970 / (ULONGLONG) 1000000,
118 .tv_usec = microseconds_since_1970 % (ULONGLONG) 1000000
119 };
118 120
119 return 0; 121 return 0;
120 122
@@ -127,10 +129,7 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz)
127 struct timeval otv; 129 struct timeval otv;
128 int result = gettimeofday (&otv, (struct timezone *) tz); 130 int result = gettimeofday (&otv, (struct timezone *) tz);
129 if (result == 0) 131 if (result == 0)
130 { 132 *tv = otv;
131 tv->tv_sec = otv.tv_sec;
132 tv->tv_usec = otv.tv_usec;
133 }
134# else 133# else
135 int result = gettimeofday (tv, (struct timezone *) tz); 134 int result = gettimeofday (tv, (struct timezone *) tz);
136# endif 135# endif
@@ -143,8 +142,7 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz)
143# error "Only 1-second nominal clock resolution found. Is that intended?" \ 142# error "Only 1-second nominal clock resolution found. Is that intended?" \
144 "If so, compile with the -DOK_TO_USE_1S_CLOCK option." 143 "If so, compile with the -DOK_TO_USE_1S_CLOCK option."
145# endif 144# endif
146 tv->tv_sec = time (NULL); 145 *tv = (struct timeval) { .tv_sec = time (NULL), .tv_usec = 0 };
147 tv->tv_usec = 0;
148 146
149 return 0; 147 return 0;
150 148
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 53a821b141e..a25bee25aae 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -147,6 +147,7 @@
147# stat-time \ 147# stat-time \
148# std-gnu11 \ 148# std-gnu11 \
149# stdbool \ 149# stdbool \
150# stdckdint \
150# stddef \ 151# stddef \
151# stdio \ 152# stdio \
152# stpcpy \ 153# stpcpy \
@@ -156,7 +157,7 @@
156# sys_stat \ 157# sys_stat \
157# sys_time \ 158# sys_time \
158# tempname \ 159# tempname \
159# time \ 160# time-h \
160# time_r \ 161# time_r \
161# time_rz \ 162# time_rz \
162# timegm \ 163# timegm \
@@ -167,7 +168,8 @@
167# update-copyright \ 168# update-copyright \
168# utimensat \ 169# utimensat \
169# vla \ 170# vla \
170# warnings 171# warnings \
172# year2038
171 173
172 174
173MOSTLYCLEANFILES += core *.stackdump 175MOSTLYCLEANFILES += core *.stackdump
@@ -221,6 +223,7 @@ DBUS_LIBS = @DBUS_LIBS@
221DBUS_OBJ = @DBUS_OBJ@ 223DBUS_OBJ = @DBUS_OBJ@
222DEFS = @DEFS@ 224DEFS = @DEFS@
223DESLIB = @DESLIB@ 225DESLIB = @DESLIB@
226DIR_HAS_FD_MEMBER = @DIR_HAS_FD_MEMBER@
224DOCMISC_W32 = @DOCMISC_W32@ 227DOCMISC_W32 = @DOCMISC_W32@
225DUMPING = @DUMPING@ 228DUMPING = @DUMPING@
226DYNAMIC_LIB_SECONDARY_SUFFIX = @DYNAMIC_LIB_SECONDARY_SUFFIX@ 229DYNAMIC_LIB_SECONDARY_SUFFIX = @DYNAMIC_LIB_SECONDARY_SUFFIX@
@@ -444,6 +447,7 @@ GL_GNULIB_MBSSEP = @GL_GNULIB_MBSSEP@
444GL_GNULIB_MBSSPN = @GL_GNULIB_MBSSPN@ 447GL_GNULIB_MBSSPN = @GL_GNULIB_MBSSPN@
445GL_GNULIB_MBSSTR = @GL_GNULIB_MBSSTR@ 448GL_GNULIB_MBSSTR = @GL_GNULIB_MBSSTR@
446GL_GNULIB_MBSTOK_R = @GL_GNULIB_MBSTOK_R@ 449GL_GNULIB_MBSTOK_R = @GL_GNULIB_MBSTOK_R@
450GL_GNULIB_MBSTOWCS = @GL_GNULIB_MBSTOWCS@
447GL_GNULIB_MBTOWC = @GL_GNULIB_MBTOWC@ 451GL_GNULIB_MBTOWC = @GL_GNULIB_MBTOWC@
448GL_GNULIB_MDA_ACCESS = @GL_GNULIB_MDA_ACCESS@ 452GL_GNULIB_MDA_ACCESS = @GL_GNULIB_MDA_ACCESS@
449GL_GNULIB_MDA_CHDIR = @GL_GNULIB_MDA_CHDIR@ 453GL_GNULIB_MDA_CHDIR = @GL_GNULIB_MDA_CHDIR@
@@ -595,6 +599,7 @@ GL_GNULIB_STRVERSCMP = @GL_GNULIB_STRVERSCMP@
595GL_GNULIB_SYMLINK = @GL_GNULIB_SYMLINK@ 599GL_GNULIB_SYMLINK = @GL_GNULIB_SYMLINK@
596GL_GNULIB_SYMLINKAT = @GL_GNULIB_SYMLINKAT@ 600GL_GNULIB_SYMLINKAT = @GL_GNULIB_SYMLINKAT@
597GL_GNULIB_SYSTEM_POSIX = @GL_GNULIB_SYSTEM_POSIX@ 601GL_GNULIB_SYSTEM_POSIX = @GL_GNULIB_SYSTEM_POSIX@
602GL_GNULIB_TIME = @GL_GNULIB_TIME@
598GL_GNULIB_TIMEGM = @GL_GNULIB_TIMEGM@ 603GL_GNULIB_TIMEGM = @GL_GNULIB_TIMEGM@
599GL_GNULIB_TIMESPEC_GET = @GL_GNULIB_TIMESPEC_GET@ 604GL_GNULIB_TIMESPEC_GET = @GL_GNULIB_TIMESPEC_GET@
600GL_GNULIB_TIMESPEC_GETRES = @GL_GNULIB_TIMESPEC_GETRES@ 605GL_GNULIB_TIMESPEC_GETRES = @GL_GNULIB_TIMESPEC_GETRES@
@@ -688,6 +693,7 @@ HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@
688HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@ 693HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@
689HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@ 694HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@
690HAVE_DECL_POSIX_SPAWN_SETSID = @HAVE_DECL_POSIX_SPAWN_SETSID@ 695HAVE_DECL_POSIX_SPAWN_SETSID = @HAVE_DECL_POSIX_SPAWN_SETSID@
696HAVE_DECL_PROGRAM_INVOCATION_NAME = @HAVE_DECL_PROGRAM_INVOCATION_NAME@
691HAVE_DECL_PUTW = @HAVE_DECL_PUTW@ 697HAVE_DECL_PUTW = @HAVE_DECL_PUTW@
692HAVE_DECL_SETENV = @HAVE_DECL_SETENV@ 698HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
693HAVE_DECL_SETHOSTNAME = @HAVE_DECL_SETHOSTNAME@ 699HAVE_DECL_SETHOSTNAME = @HAVE_DECL_SETHOSTNAME@
@@ -955,6 +961,7 @@ LIB_WSOCK32 = @LIB_WSOCK32@
955LIB_XATTR = @LIB_XATTR@ 961LIB_XATTR = @LIB_XATTR@
956LIMITS_H = @LIMITS_H@ 962LIMITS_H = @LIMITS_H@
957LN_S_FILEONLY = @LN_S_FILEONLY@ 963LN_S_FILEONLY = @LN_S_FILEONLY@
964LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
958LTLIBGMP = @LTLIBGMP@ 965LTLIBGMP = @LTLIBGMP@
959LTLIBINTL = @LTLIBINTL@ 966LTLIBINTL = @LTLIBINTL@
960LTLIBOBJS = @LTLIBOBJS@ 967LTLIBOBJS = @LTLIBOBJS@
@@ -1126,7 +1133,9 @@ REPLACE_LSEEK = @REPLACE_LSEEK@
1126REPLACE_LSTAT = @REPLACE_LSTAT@ 1133REPLACE_LSTAT = @REPLACE_LSTAT@
1127REPLACE_MALLOC_FOR_MALLOC_GNU = @REPLACE_MALLOC_FOR_MALLOC_GNU@ 1134REPLACE_MALLOC_FOR_MALLOC_GNU = @REPLACE_MALLOC_FOR_MALLOC_GNU@
1128REPLACE_MALLOC_FOR_MALLOC_POSIX = @REPLACE_MALLOC_FOR_MALLOC_POSIX@ 1135REPLACE_MALLOC_FOR_MALLOC_POSIX = @REPLACE_MALLOC_FOR_MALLOC_POSIX@
1136REPLACE_MBSTOWCS = @REPLACE_MBSTOWCS@
1129REPLACE_MBTOWC = @REPLACE_MBTOWC@ 1137REPLACE_MBTOWC = @REPLACE_MBTOWC@
1138REPLACE_MB_CUR_MAX = @REPLACE_MB_CUR_MAX@
1130REPLACE_MEMCHR = @REPLACE_MEMCHR@ 1139REPLACE_MEMCHR = @REPLACE_MEMCHR@
1131REPLACE_MEMMEM = @REPLACE_MEMMEM@ 1140REPLACE_MEMMEM = @REPLACE_MEMMEM@
1132REPLACE_MEMPCPY = @REPLACE_MEMPCPY@ 1141REPLACE_MEMPCPY = @REPLACE_MEMPCPY@
@@ -1163,6 +1172,7 @@ REPLACE_RAISE = @REPLACE_RAISE@
1163REPLACE_RANDOM = @REPLACE_RANDOM@ 1172REPLACE_RANDOM = @REPLACE_RANDOM@
1164REPLACE_RANDOM_R = @REPLACE_RANDOM_R@ 1173REPLACE_RANDOM_R = @REPLACE_RANDOM_R@
1165REPLACE_READ = @REPLACE_READ@ 1174REPLACE_READ = @REPLACE_READ@
1175REPLACE_READDIR = @REPLACE_READDIR@
1166REPLACE_READLINK = @REPLACE_READLINK@ 1176REPLACE_READLINK = @REPLACE_READLINK@
1167REPLACE_READLINKAT = @REPLACE_READLINKAT@ 1177REPLACE_READLINKAT = @REPLACE_READLINKAT@
1168REPLACE_REALLOCARRAY = @REPLACE_REALLOCARRAY@ 1178REPLACE_REALLOCARRAY = @REPLACE_REALLOCARRAY@
@@ -1172,6 +1182,7 @@ REPLACE_REALPATH = @REPLACE_REALPATH@
1172REPLACE_REMOVE = @REPLACE_REMOVE@ 1182REPLACE_REMOVE = @REPLACE_REMOVE@
1173REPLACE_RENAME = @REPLACE_RENAME@ 1183REPLACE_RENAME = @REPLACE_RENAME@
1174REPLACE_RENAMEAT = @REPLACE_RENAMEAT@ 1184REPLACE_RENAMEAT = @REPLACE_RENAMEAT@
1185REPLACE_REWINDDIR = @REPLACE_REWINDDIR@
1175REPLACE_RMDIR = @REPLACE_RMDIR@ 1186REPLACE_RMDIR = @REPLACE_RMDIR@
1176REPLACE_SELECT = @REPLACE_SELECT@ 1187REPLACE_SELECT = @REPLACE_SELECT@
1177REPLACE_SETENV = @REPLACE_SETENV@ 1188REPLACE_SETENV = @REPLACE_SETENV@
@@ -1209,6 +1220,7 @@ REPLACE_STRTOUMAX = @REPLACE_STRTOUMAX@
1209REPLACE_STRUCT_TIMEVAL = @REPLACE_STRUCT_TIMEVAL@ 1220REPLACE_STRUCT_TIMEVAL = @REPLACE_STRUCT_TIMEVAL@
1210REPLACE_SYMLINK = @REPLACE_SYMLINK@ 1221REPLACE_SYMLINK = @REPLACE_SYMLINK@
1211REPLACE_SYMLINKAT = @REPLACE_SYMLINKAT@ 1222REPLACE_SYMLINKAT = @REPLACE_SYMLINKAT@
1223REPLACE_TIME = @REPLACE_TIME@
1212REPLACE_TIMEGM = @REPLACE_TIMEGM@ 1224REPLACE_TIMEGM = @REPLACE_TIMEGM@
1213REPLACE_TIMESPEC_GET = @REPLACE_TIMESPEC_GET@ 1225REPLACE_TIMESPEC_GET = @REPLACE_TIMESPEC_GET@
1214REPLACE_TMPFILE = @REPLACE_TMPFILE@ 1226REPLACE_TMPFILE = @REPLACE_TMPFILE@
@@ -1730,6 +1742,7 @@ dirent.h: dirent.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
1730 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1742 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1731 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1743 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1732 -e 's|@''NEXT_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \ 1744 -e 's|@''NEXT_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \
1745 -e 's/@''DIR_HAS_FD_MEMBER''@/$(DIR_HAS_FD_MEMBER)/g' \
1733 -e 's/@''GNULIB_OPENDIR''@/$(GL_GNULIB_OPENDIR)/g' \ 1746 -e 's/@''GNULIB_OPENDIR''@/$(GL_GNULIB_OPENDIR)/g' \
1734 -e 's/@''GNULIB_READDIR''@/$(GL_GNULIB_READDIR)/g' \ 1747 -e 's/@''GNULIB_READDIR''@/$(GL_GNULIB_READDIR)/g' \
1735 -e 's/@''GNULIB_REWINDDIR''@/$(GL_GNULIB_REWINDDIR)/g' \ 1748 -e 's/@''GNULIB_REWINDDIR''@/$(GL_GNULIB_REWINDDIR)/g' \
@@ -1748,6 +1761,8 @@ dirent.h: dirent.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
1748 -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \ 1761 -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \
1749 -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \ 1762 -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \
1750 -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \ 1763 -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \
1764 -e 's|@''REPLACE_READDIR''@|$(REPLACE_READDIR)|g' \
1765 -e 's|@''REPLACE_REWINDDIR''@|$(REPLACE_REWINDDIR)|g' \
1751 -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \ 1766 -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \
1752 -e 's|@''REPLACE_DIRFD''@|$(REPLACE_DIRFD)|g' \ 1767 -e 's|@''REPLACE_DIRFD''@|$(REPLACE_DIRFD)|g' \
1753 -e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|g' \ 1768 -e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|g' \
@@ -1772,6 +1787,8 @@ libgnu_a_SOURCES += dirfd.c
1772endif 1787endif
1773 1788
1774endif 1789endif
1790EXTRA_DIST += dirent-private.h
1791
1775endif 1792endif
1776## end gnulib module dirfd 1793## end gnulib module dirfd
1777 1794
@@ -1972,6 +1989,8 @@ ifneq (,$(GL_COND_OBJ_FDOPENDIR_CONDITION))
1972libgnu_a_SOURCES += fdopendir.c 1989libgnu_a_SOURCES += fdopendir.c
1973endif 1990endif
1974 1991
1992EXTRA_DIST += dirent-private.h
1993
1975endif 1994endif
1976## end gnulib module fdopendir 1995## end gnulib module fdopendir
1977 1996
@@ -3207,6 +3226,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
3207 -e 's/@''GNULIB_GRANTPT''@/$(GL_GNULIB_GRANTPT)/g' \ 3226 -e 's/@''GNULIB_GRANTPT''@/$(GL_GNULIB_GRANTPT)/g' \
3208 -e 's/@''GNULIB_MALLOC_GNU''@/$(GL_GNULIB_MALLOC_GNU)/g' \ 3227 -e 's/@''GNULIB_MALLOC_GNU''@/$(GL_GNULIB_MALLOC_GNU)/g' \
3209 -e 's/@''GNULIB_MALLOC_POSIX''@/$(GL_GNULIB_MALLOC_POSIX)/g' \ 3228 -e 's/@''GNULIB_MALLOC_POSIX''@/$(GL_GNULIB_MALLOC_POSIX)/g' \
3229 -e 's/@''GNULIB_MBSTOWCS''@/$(GL_GNULIB_MBSTOWCS)/g' \
3210 -e 's/@''GNULIB_MBTOWC''@/$(GL_GNULIB_MBTOWC)/g' \ 3230 -e 's/@''GNULIB_MBTOWC''@/$(GL_GNULIB_MBTOWC)/g' \
3211 -e 's/@''GNULIB_MKDTEMP''@/$(GL_GNULIB_MKDTEMP)/g' \ 3231 -e 's/@''GNULIB_MKDTEMP''@/$(GL_GNULIB_MKDTEMP)/g' \
3212 -e 's/@''GNULIB_MKOSTEMP''@/$(GL_GNULIB_MKOSTEMP)/g' \ 3232 -e 's/@''GNULIB_MKOSTEMP''@/$(GL_GNULIB_MKOSTEMP)/g' \
@@ -3252,6 +3272,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
3252 -e 's|@''HAVE_DECL_FCVT''@|$(HAVE_DECL_FCVT)|g' \ 3272 -e 's|@''HAVE_DECL_FCVT''@|$(HAVE_DECL_FCVT)|g' \
3253 -e 's|@''HAVE_DECL_GCVT''@|$(HAVE_DECL_GCVT)|g' \ 3273 -e 's|@''HAVE_DECL_GCVT''@|$(HAVE_DECL_GCVT)|g' \
3254 -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ 3274 -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
3275 -e 's|@''HAVE_DECL_PROGRAM_INVOCATION_NAME''@|$(HAVE_DECL_PROGRAM_INVOCATION_NAME)|g' \
3255 -e 's|@''HAVE_GETPROGNAME''@|$(HAVE_GETPROGNAME)|g' \ 3276 -e 's|@''HAVE_GETPROGNAME''@|$(HAVE_GETPROGNAME)|g' \
3256 -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ 3277 -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
3257 -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \ 3278 -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
@@ -3300,6 +3321,8 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
3300 -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \ 3321 -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \
3301 -e 's|@''REPLACE_MALLOC_FOR_MALLOC_GNU''@|$(REPLACE_MALLOC_FOR_MALLOC_GNU)|g' \ 3322 -e 's|@''REPLACE_MALLOC_FOR_MALLOC_GNU''@|$(REPLACE_MALLOC_FOR_MALLOC_GNU)|g' \
3302 -e 's|@''REPLACE_MALLOC_FOR_MALLOC_POSIX''@|$(REPLACE_MALLOC_FOR_MALLOC_POSIX)|g' \ 3323 -e 's|@''REPLACE_MALLOC_FOR_MALLOC_POSIX''@|$(REPLACE_MALLOC_FOR_MALLOC_POSIX)|g' \
3324 -e 's|@''REPLACE_MB_CUR_MAX''@|$(REPLACE_MB_CUR_MAX)|g' \
3325 -e 's|@''REPLACE_MBSTOWCS''@|$(REPLACE_MBSTOWCS)|g' \
3303 -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \ 3326 -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
3304 -e 's|@''REPLACE_MKOSTEMP''@|$(REPLACE_MKOSTEMP)|g' \ 3327 -e 's|@''REPLACE_MKOSTEMP''@|$(REPLACE_MKOSTEMP)|g' \
3305 -e 's|@''REPLACE_MKOSTEMPS''@|$(REPLACE_MKOSTEMPS)|g' \ 3328 -e 's|@''REPLACE_MKOSTEMPS''@|$(REPLACE_MKOSTEMPS)|g' \
@@ -3723,8 +3746,8 @@ EXTRA_DIST += tempname.h
3723endif 3746endif
3724## end gnulib module tempname 3747## end gnulib module tempname
3725 3748
3726## begin gnulib module time 3749## begin gnulib module time-h
3727ifeq (,$(OMIT_GNULIB_MODULE_time)) 3750ifeq (,$(OMIT_GNULIB_MODULE_time-h))
3728 3751
3729BUILT_SOURCES += time.h 3752BUILT_SOURCES += time.h
3730 3753
@@ -3743,6 +3766,7 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
3743 -e 's/@''GNULIB_NANOSLEEP''@/$(GL_GNULIB_NANOSLEEP)/g' \ 3766 -e 's/@''GNULIB_NANOSLEEP''@/$(GL_GNULIB_NANOSLEEP)/g' \
3744 -e 's/@''GNULIB_STRFTIME''@/$(GL_GNULIB_STRFTIME)/g' \ 3767 -e 's/@''GNULIB_STRFTIME''@/$(GL_GNULIB_STRFTIME)/g' \
3745 -e 's/@''GNULIB_STRPTIME''@/$(GL_GNULIB_STRPTIME)/g' \ 3768 -e 's/@''GNULIB_STRPTIME''@/$(GL_GNULIB_STRPTIME)/g' \
3769 -e 's/@''GNULIB_TIME''@/$(GL_GNULIB_TIME)/g' \
3746 -e 's/@''GNULIB_TIMEGM''@/$(GL_GNULIB_TIMEGM)/g' \ 3770 -e 's/@''GNULIB_TIMEGM''@/$(GL_GNULIB_TIMEGM)/g' \
3747 -e 's/@''GNULIB_TIMESPEC_GET''@/$(GL_GNULIB_TIMESPEC_GET)/g' \ 3771 -e 's/@''GNULIB_TIMESPEC_GET''@/$(GL_GNULIB_TIMESPEC_GET)/g' \
3748 -e 's/@''GNULIB_TIMESPEC_GETRES''@/$(GL_GNULIB_TIMESPEC_GETRES)/g' \ 3772 -e 's/@''GNULIB_TIMESPEC_GETRES''@/$(GL_GNULIB_TIMESPEC_GETRES)/g' \
@@ -3764,6 +3788,7 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
3764 -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ 3788 -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
3765 -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ 3789 -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
3766 -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \ 3790 -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \
3791 -e 's|@''REPLACE_TIME''@|$(REPLACE_TIME)|g' \
3767 -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ 3792 -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
3768 -e 's|@''REPLACE_TIMESPEC_GET''@|$(REPLACE_TIMESPEC_GET)|g' \ 3793 -e 's|@''REPLACE_TIMESPEC_GET''@|$(REPLACE_TIMESPEC_GET)|g' \
3769 -e 's|@''REPLACE_TZSET''@|$(REPLACE_TZSET)|g' \ 3794 -e 's|@''REPLACE_TZSET''@|$(REPLACE_TZSET)|g' \
@@ -3782,7 +3807,7 @@ MOSTLYCLEANFILES += time.h time.h-t
3782EXTRA_DIST += time.in.h 3807EXTRA_DIST += time.in.h
3783 3808
3784endif 3809endif
3785## end gnulib module time 3810## end gnulib module time-h
3786 3811
3787## begin gnulib module time_r 3812## begin gnulib module time_r
3788ifeq (,$(OMIT_GNULIB_MODULE_time_r)) 3813ifeq (,$(OMIT_GNULIB_MODULE_time_r))
diff --git a/lib/inttypes.in.h b/lib/inttypes.in.h
index 5b7ef12dc7e..22643876ab3 100644
--- a/lib/inttypes.in.h
+++ b/lib/inttypes.in.h
@@ -46,6 +46,11 @@
46#if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H 46#if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
47#define INTTYPES_H 47#define INTTYPES_H
48 48
49/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
50#if !_GL_CONFIG_H_INCLUDED
51 #error "Please include config.h first."
52#endif
53
49/* Include <stdint.h> or the gnulib replacement. 54/* Include <stdint.h> or the gnulib replacement.
50 But avoid namespace pollution on glibc systems. */ 55 But avoid namespace pollution on glibc systems. */
51#ifndef __GLIBC__ 56#ifndef __GLIBC__
diff --git a/lib/limits.in.h b/lib/limits.in.h
index a01b4c6a280..45d46fd6897 100644
--- a/lib/limits.in.h
+++ b/lib/limits.in.h
@@ -99,6 +99,11 @@
99# endif 99# endif
100#endif 100#endif
101 101
102/* Assume no multibyte character is longer than 16 bytes. */
103#ifndef MB_LEN_MAX
104# define MB_LEN_MAX 16
105#endif
106
102/* Macros specified by C23 and by ISO/IEC TS 18661-1:2014. */ 107/* Macros specified by C23 and by ISO/IEC TS 18661-1:2014. */
103 108
104#if (! defined ULLONG_WIDTH \ 109#if (! defined ULLONG_WIDTH \
diff --git a/lib/malloc/dynarray_emplace_enlarge.c b/lib/malloc/dynarray_emplace_enlarge.c
index 7da539316c1..65aabb1e4a5 100644
--- a/lib/malloc/dynarray_emplace_enlarge.c
+++ b/lib/malloc/dynarray_emplace_enlarge.c
@@ -22,7 +22,7 @@
22 22
23#include <dynarray.h> 23#include <dynarray.h>
24#include <errno.h> 24#include <errno.h>
25#include <intprops.h> 25#include <stdckdint.h>
26#include <stdlib.h> 26#include <stdlib.h>
27#include <string.h> 27#include <string.h>
28 28
@@ -56,7 +56,7 @@ __libc_dynarray_emplace_enlarge (struct dynarray_header *list,
56 } 56 }
57 57
58 size_t new_size; 58 size_t new_size;
59 if (INT_MULTIPLY_WRAPV (new_allocated, element_size, &new_size)) 59 if (ckd_mul (&new_size, new_allocated, element_size))
60 return false; 60 return false;
61 void *new_array; 61 void *new_array;
62 if (list->array == scratch) 62 if (list->array == scratch)
diff --git a/lib/malloc/dynarray_resize.c b/lib/malloc/dynarray_resize.c
index 7ecd4de63b9..014f98c330e 100644
--- a/lib/malloc/dynarray_resize.c
+++ b/lib/malloc/dynarray_resize.c
@@ -22,7 +22,7 @@
22 22
23#include <dynarray.h> 23#include <dynarray.h>
24#include <errno.h> 24#include <errno.h>
25#include <intprops.h> 25#include <stdckdint.h>
26#include <stdlib.h> 26#include <stdlib.h>
27#include <string.h> 27#include <string.h>
28 28
@@ -42,7 +42,7 @@ __libc_dynarray_resize (struct dynarray_header *list, size_t size,
42 over-allocation here. */ 42 over-allocation here. */
43 43
44 size_t new_size_bytes; 44 size_t new_size_bytes;
45 if (INT_MULTIPLY_WRAPV (size, element_size, &new_size_bytes)) 45 if (ckd_mul (&new_size_bytes, size, element_size))
46 { 46 {
47 /* Overflow. */ 47 /* Overflow. */
48 __set_errno (ENOMEM); 48 __set_errno (ENOMEM);
diff --git a/lib/md5.h b/lib/md5.h
index f34e7cb8dfa..92dc6038988 100644
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -20,6 +20,11 @@
20#ifndef _MD5_H 20#ifndef _MD5_H
21#define _MD5_H 1 21#define _MD5_H 1
22 22
23/* This file uses HAVE_OPENSSL_MD5. */
24#if !_GL_CONFIG_H_INCLUDED
25 #error "Please include config.h first."
26#endif
27
23#include <stdio.h> 28#include <stdio.h>
24#include <stdint.h> 29#include <stdint.h>
25 30
diff --git a/lib/minmax.h b/lib/minmax.h
index 1fbfc6616cf..0ac40198e24 100644
--- a/lib/minmax.h
+++ b/lib/minmax.h
@@ -23,6 +23,11 @@
23 MIN, MAX macro redefinitions on some systems; the workaround is to 23 MIN, MAX macro redefinitions on some systems; the workaround is to
24 #include this file as the last one among the #include list. */ 24 #include this file as the last one among the #include list. */
25 25
26/* This file uses HAVE_MINMAX_IN_LIMITS_H, HAVE_MINMAX_IN_SYS_PARAM_H. */
27#if !_GL_CONFIG_H_INCLUDED
28 #error "Please include config.h first."
29#endif
30
26/* Before we define the following symbols we get the <limits.h> file 31/* Before we define the following symbols we get the <limits.h> file
27 since otherwise we get redefinitions on some systems if <limits.h> is 32 since otherwise we get redefinitions on some systems if <limits.h> is
28 included after this file. Likewise for <sys/param.h>. 33 included after this file. Likewise for <sys/param.h>.
diff --git a/lib/mktime.c b/lib/mktime.c
index 94a4320e6ca..8e80bcdbd16 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -46,6 +46,7 @@
46#include <errno.h> 46#include <errno.h>
47#include <limits.h> 47#include <limits.h>
48#include <stdbool.h> 48#include <stdbool.h>
49#include <stdckdint.h>
49#include <stdlib.h> 50#include <stdlib.h>
50#include <string.h> 51#include <string.h>
51 52
@@ -379,7 +380,7 @@ __mktime_internal (struct tm *tp,
379 /* Invert CONVERT by probing. First assume the same offset as last 380 /* Invert CONVERT by probing. First assume the same offset as last
380 time. */ 381 time. */
381 382
382 INT_SUBTRACT_WRAPV (0, off, &negative_offset_guess); 383 ckd_sub (&negative_offset_guess, 0, off);
383 long_int t0 = ydhms_diff (year, yday, hour, min, sec, 384 long_int t0 = ydhms_diff (year, yday, hour, min, sec,
384 EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, 385 EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0,
385 negative_offset_guess); 386 negative_offset_guess);
@@ -465,7 +466,7 @@ __mktime_internal (struct tm *tp,
465 for (direction = -1; direction <= 1; direction += 2) 466 for (direction = -1; direction <= 1; direction += 2)
466 { 467 {
467 long_int ot; 468 long_int ot;
468 if (! INT_ADD_WRAPV (t, delta * direction, &ot)) 469 if (! ckd_add (&ot, t, delta * direction))
469 { 470 {
470 struct tm otm; 471 struct tm otm;
471 if (! ranged_convert (convert, &ot, &otm)) 472 if (! ranged_convert (convert, &ot, &otm))
@@ -503,8 +504,8 @@ __mktime_internal (struct tm *tp,
503 /* Set *OFFSET to the low-order bits of T - T0 - NEGATIVE_OFFSET_GUESS. 504 /* Set *OFFSET to the low-order bits of T - T0 - NEGATIVE_OFFSET_GUESS.
504 This is just a heuristic to speed up the next mktime call, and 505 This is just a heuristic to speed up the next mktime call, and
505 correctness is unaffected if integer overflow occurs here. */ 506 correctness is unaffected if integer overflow occurs here. */
506 INT_SUBTRACT_WRAPV (t, t0, offset); 507 ckd_sub (offset, t, t0);
507 INT_SUBTRACT_WRAPV (*offset, negative_offset_guess, offset); 508 ckd_sub (offset, *offset, negative_offset_guess);
508 509
509 if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec) 510 if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec)
510 { 511 {
@@ -513,7 +514,7 @@ __mktime_internal (struct tm *tp,
513 long_int sec_adjustment = sec == 0 && tm.tm_sec == 60; 514 long_int sec_adjustment = sec == 0 && tm.tm_sec == 60;
514 sec_adjustment -= sec; 515 sec_adjustment -= sec;
515 sec_adjustment += sec_requested; 516 sec_adjustment += sec_requested;
516 if (INT_ADD_WRAPV (t, sec_adjustment, &t) 517 if (ckd_add (&t, t, sec_adjustment)
517 || ! (mktime_min <= t && t <= mktime_max)) 518 || ! (mktime_min <= t && t <= mktime_max))
518 { 519 {
519 __set_errno (EOVERFLOW); 520 __set_errno (EOVERFLOW);
diff --git a/lib/nanosleep.c b/lib/nanosleep.c
index 3f295f49b5d..10974df461e 100644
--- a/lib/nanosleep.c
+++ b/lib/nanosleep.c
@@ -60,8 +60,7 @@ nanosleep (const struct timespec *requested_delay,
60 static_assert (TYPE_MAXIMUM (time_t) / 24 / 24 / 60 / 60); 60 static_assert (TYPE_MAXIMUM (time_t) / 24 / 24 / 60 / 60);
61 const time_t limit = 24 * 24 * 60 * 60; 61 const time_t limit = 24 * 24 * 60 * 60;
62 time_t seconds = requested_delay->tv_sec; 62 time_t seconds = requested_delay->tv_sec;
63 struct timespec intermediate; 63 struct timespec intermediate = *requested_delay;
64 intermediate.tv_nsec = requested_delay->tv_nsec;
65 64
66 while (limit < seconds) 65 while (limit < seconds)
67 { 66 {
diff --git a/lib/nstrftime.c b/lib/nstrftime.c
index 68bb560910d..2a1dd8d88d7 100644
--- a/lib/nstrftime.c
+++ b/lib/nstrftime.c
@@ -62,6 +62,7 @@ extern char *tzname[];
62#endif 62#endif
63 63
64#include <limits.h> 64#include <limits.h>
65#include <stdckdint.h>
65#include <stddef.h> 66#include <stddef.h>
66#include <stdlib.h> 67#include <stdlib.h>
67#include <string.h> 68#include <string.h>
@@ -226,15 +227,6 @@ extern char *tzname[];
226# undef __mbsrtowcs_l 227# undef __mbsrtowcs_l
227# define __mbsrtowcs_l(d, s, l, st, loc) __mbsrtowcs (d, s, l, st) 228# define __mbsrtowcs_l(d, s, l, st, loc) __mbsrtowcs (d, s, l, st)
228# endif 229# endif
229# define widen(os, ws, l) \
230 { \
231 mbstate_t __st; \
232 const char *__s = os; \
233 memset (&__st, '\0', sizeof (__st)); \
234 l = __mbsrtowcs_l (NULL, &__s, 0, &__st, loc); \
235 ws = (wchar_t *) alloca ((l + 1) * sizeof (wchar_t)); \
236 (void) __mbsrtowcs_l (ws, &__s, l, &__st, loc); \
237 }
238#endif 230#endif
239 231
240 232
@@ -684,8 +676,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
684 width = 0; 676 width = 0;
685 do 677 do
686 { 678 {
687 if (INT_MULTIPLY_WRAPV (width, 10, &width) 679 if (ckd_mul (&width, width, 10)
688 || INT_ADD_WRAPV (width, *f - L_('0'), &width)) 680 || ckd_add (&width, width, *f - L_('0')))
689 width = INT_MAX; 681 width = INT_MAX;
690 ++f; 682 ++f;
691 } 683 }
@@ -1374,11 +1366,31 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
1374#ifdef COMPILE_WIDE 1366#ifdef COMPILE_WIDE
1375 { 1367 {
1376 /* The zone string is always given in multibyte form. We have 1368 /* The zone string is always given in multibyte form. We have
1377 to transform it first. */ 1369 to convert it to wide character. */
1378 wchar_t *wczone; 1370 size_t w = pad == L_('-') || width < 0 ? 0 : width;
1379 size_t len; 1371 char const *z = zone;
1380 widen (zone, wczone, len); 1372 mbstate_t st = {0};
1381 cpy (len, wczone); 1373 size_t len = __mbsrtowcs_l (p, &z, maxsize - i, &st, loc);
1374 if (len == (size_t) -1)
1375 return 0;
1376 size_t incr = len < w ? w : len;
1377 if (incr >= maxsize - i)
1378 {
1379 errno = ERANGE;
1380 return 0;
1381 }
1382 if (p)
1383 {
1384 if (len < w)
1385 {
1386 size_t delta = w - len;
1387 wmemmove (p + delta, p, len);
1388 wchar_t wc = pad == L_('0') || pad == L_('+') ? L'0' : L' ';
1389 wmemset (p, wc, delta);
1390 }
1391 p += incr;
1392 }
1393 i += incr;
1382 } 1394 }
1383#else 1395#else
1384 cpy (strlen (zone), zone); 1396 cpy (strlen (zone), zone);
diff --git a/lib/openat.h b/lib/openat.h
index 37d8eedbee4..97f066d10f8 100644
--- a/lib/openat.h
+++ b/lib/openat.h
@@ -19,15 +19,18 @@
19#ifndef _GL_HEADER_OPENAT 19#ifndef _GL_HEADER_OPENAT
20#define _GL_HEADER_OPENAT 20#define _GL_HEADER_OPENAT
21 21
22/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _Noreturn,
23 _GL_ATTRIBUTE_DEPRECATED, HAVE_OPENAT. */
24#if !_GL_CONFIG_H_INCLUDED
25 #error "Please include config.h first."
26#endif
27
22#include <fcntl.h> 28#include <fcntl.h>
23 29
24#include <sys/types.h> 30#include <sys/types.h>
25#include <sys/stat.h> 31#include <sys/stat.h>
26#include <unistd.h> 32#include <unistd.h>
27 33
28#ifndef _GL_INLINE_HEADER_BEGIN
29 #error "Please include config.h first."
30#endif
31_GL_INLINE_HEADER_BEGIN 34_GL_INLINE_HEADER_BEGIN
32 35
33#if !HAVE_OPENAT 36#if !HAVE_OPENAT
diff --git a/lib/pathmax.h b/lib/pathmax.h
index 0dd8f3bc5ce..6930283b82a 100644
--- a/lib/pathmax.h
+++ b/lib/pathmax.h
@@ -39,6 +39,11 @@
39 #endif 39 #endif
40 */ 40 */
41 41
42/* This file uses HAVE_SYS_PARAM_H. */
43# if !_GL_CONFIG_H_INCLUDED
44# error "Please include config.h first."
45# endif
46
42# include <unistd.h> 47# include <unistd.h>
43 48
44# include <limits.h> 49# include <limits.h>
diff --git a/lib/pselect.c b/lib/pselect.c
index f5d21e1048a..1b8c19130c2 100644
--- a/lib/pselect.c
+++ b/lib/pselect.c
@@ -45,6 +45,12 @@ pselect (int nfds, fd_set *restrict rfds,
45 sigset_t origmask; 45 sigset_t origmask;
46 struct timeval tv, *tvp; 46 struct timeval tv, *tvp;
47 47
48 if (nfds < 0 || nfds > FD_SETSIZE)
49 {
50 errno = EINVAL;
51 return -1;
52 }
53
48 if (timeout) 54 if (timeout)
49 { 55 {
50 if (! (0 <= timeout->tv_nsec && timeout->tv_nsec < 1000000000)) 56 if (! (0 <= timeout->tv_nsec && timeout->tv_nsec < 1000000000))
@@ -53,8 +59,10 @@ pselect (int nfds, fd_set *restrict rfds,
53 return -1; 59 return -1;
54 } 60 }
55 61
56 tv.tv_sec = timeout->tv_sec; 62 tv = (struct timeval) {
57 tv.tv_usec = (timeout->tv_nsec + 999) / 1000; 63 .tv_sec = timeout->tv_sec,
64 .tv_usec = (timeout->tv_nsec + 999) / 1000
65 };
58 tvp = &tv; 66 tvp = &tv;
59 } 67 }
60 else 68 else
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index 149ec2e868a..0270091df70 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -29,6 +29,7 @@
29#include <locale.h> 29#include <locale.h>
30#include <wchar.h> 30#include <wchar.h>
31#include <wctype.h> 31#include <wctype.h>
32#include <stdckdint.h>
32#include <stdint.h> 33#include <stdint.h>
33 34
34#ifndef _LIBC 35#ifndef _LIBC
@@ -822,7 +823,7 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
822} 823}
823 824
824#ifdef _LIBC 825#ifdef _LIBC
825# if __GNUC__ >= 7 826# if __glibc_has_attribute (__fallthrough__)
826# define FALLTHROUGH __attribute__ ((__fallthrough__)) 827# define FALLTHROUGH __attribute__ ((__fallthrough__))
827# else 828# else
828# define FALLTHROUGH ((void) 0) 829# define FALLTHROUGH ((void) 0)
diff --git a/lib/regexec.c b/lib/regexec.c
index 13e0349e727..f05f38ae0e0 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -324,7 +324,7 @@ re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1,
324 char *s = NULL; 324 char *s = NULL;
325 325
326 if (__glibc_unlikely ((length1 < 0 || length2 < 0 || stop < 0 326 if (__glibc_unlikely ((length1 < 0 || length2 < 0 || stop < 0
327 || INT_ADD_WRAPV (length1, length2, &len)))) 327 || ckd_add (&len, length1, length2))))
328 return -2; 328 return -2;
329 329
330 /* Concatenate the strings. */ 330 /* Concatenate the strings. */
diff --git a/lib/sha1.h b/lib/sha1.h
index 5a58b567ceb..854213a9211 100644
--- a/lib/sha1.h
+++ b/lib/sha1.h
@@ -19,6 +19,11 @@
19#ifndef SHA1_H 19#ifndef SHA1_H
20# define SHA1_H 1 20# define SHA1_H 1
21 21
22/* This file uses HAVE_OPENSSL_SHA1. */
23# if !_GL_CONFIG_H_INCLUDED
24# error "Please include config.h first."
25# endif
26
22# include <stdio.h> 27# include <stdio.h>
23# include <stdint.h> 28# include <stdint.h>
24 29
diff --git a/lib/sha256.h b/lib/sha256.h
index 2879477e89c..938b1067062 100644
--- a/lib/sha256.h
+++ b/lib/sha256.h
@@ -18,6 +18,11 @@
18#ifndef SHA256_H 18#ifndef SHA256_H
19# define SHA256_H 1 19# define SHA256_H 1
20 20
21/* This file uses HAVE_OPENSSL_SHA256. */
22# if !_GL_CONFIG_H_INCLUDED
23# error "Please include config.h first."
24# endif
25
21# include <stdio.h> 26# include <stdio.h>
22# include <stdint.h> 27# include <stdint.h>
23 28
diff --git a/lib/sha512.h b/lib/sha512.h
index e3a98a2644c..f3465bc8a68 100644
--- a/lib/sha512.h
+++ b/lib/sha512.h
@@ -18,6 +18,11 @@
18#ifndef SHA512_H 18#ifndef SHA512_H
19# define SHA512_H 1 19# define SHA512_H 1
20 20
21/* This file uses HAVE_OPENSSL_SHA512. */
22# if !_GL_CONFIG_H_INCLUDED
23# error "Please include config.h first."
24# endif
25
21# include <stdio.h> 26# include <stdio.h>
22# include "u64.h" 27# include "u64.h"
23 28
diff --git a/lib/signal.in.h b/lib/signal.in.h
index fea12e6572d..418d59c582d 100644
--- a/lib/signal.in.h
+++ b/lib/signal.in.h
@@ -55,6 +55,11 @@
55#ifndef _@GUARD_PREFIX@_SIGNAL_H 55#ifndef _@GUARD_PREFIX@_SIGNAL_H
56#define _@GUARD_PREFIX@_SIGNAL_H 56#define _@GUARD_PREFIX@_SIGNAL_H
57 57
58/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
59#if !_GL_CONFIG_H_INCLUDED
60 #error "Please include config.h first."
61#endif
62
58/* For testing the OpenBSD version. */ 63/* For testing the OpenBSD version. */
59#if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \ 64#if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \
60 && defined __OpenBSD__ 65 && defined __OpenBSD__
diff --git a/lib/stat-time.h b/lib/stat-time.h
index 92aa1e64e20..75eb27e549d 100644
--- a/lib/stat-time.h
+++ b/lib/stat-time.h
@@ -20,15 +20,18 @@
20#ifndef STAT_TIME_H 20#ifndef STAT_TIME_H
21#define STAT_TIME_H 1 21#define STAT_TIME_H 1
22 22
23/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_UNUSED,
24 _GL_ATTRIBUTE_PURE, HAVE_STRUCT_STAT_*. */
25#if !_GL_CONFIG_H_INCLUDED
26 #error "Please include config.h first."
27#endif
28
23#include <errno.h> 29#include <errno.h>
24#include <stdckdint.h> 30#include <stdckdint.h>
25#include <stddef.h> 31#include <stddef.h>
26#include <sys/stat.h> 32#include <sys/stat.h>
27#include <time.h> 33#include <time.h>
28 34
29#ifndef _GL_INLINE_HEADER_BEGIN
30 #error "Please include config.h first."
31#endif
32_GL_INLINE_HEADER_BEGIN 35_GL_INLINE_HEADER_BEGIN
33#ifndef _GL_STAT_TIME_INLINE 36#ifndef _GL_STAT_TIME_INLINE
34# define _GL_STAT_TIME_INLINE _GL_INLINE 37# define _GL_STAT_TIME_INLINE _GL_INLINE
@@ -119,10 +122,8 @@ get_stat_atime (struct stat const *st)
119#ifdef STAT_TIMESPEC 122#ifdef STAT_TIMESPEC
120 return STAT_TIMESPEC (st, st_atim); 123 return STAT_TIMESPEC (st, st_atim);
121#else 124#else
122 struct timespec t; 125 return (struct timespec) { .tv_sec = st->st_atime,
123 t.tv_sec = st->st_atime; 126 .tv_nsec = get_stat_atime_ns (st) };
124 t.tv_nsec = get_stat_atime_ns (st);
125 return t;
126#endif 127#endif
127} 128}
128 129
@@ -133,10 +134,8 @@ get_stat_ctime (struct stat const *st)
133#ifdef STAT_TIMESPEC 134#ifdef STAT_TIMESPEC
134 return STAT_TIMESPEC (st, st_ctim); 135 return STAT_TIMESPEC (st, st_ctim);
135#else 136#else
136 struct timespec t; 137 return (struct timespec) { .tv_sec = st->st_ctime,
137 t.tv_sec = st->st_ctime; 138 .tv_nsec = get_stat_ctime_ns (st) };
138 t.tv_nsec = get_stat_ctime_ns (st);
139 return t;
140#endif 139#endif
141} 140}
142 141
@@ -147,10 +146,8 @@ get_stat_mtime (struct stat const *st)
147#ifdef STAT_TIMESPEC 146#ifdef STAT_TIMESPEC
148 return STAT_TIMESPEC (st, st_mtim); 147 return STAT_TIMESPEC (st, st_mtim);
149#else 148#else
150 struct timespec t; 149 return (struct timespec) { .tv_sec = st->st_mtime,
151 t.tv_sec = st->st_mtime; 150 .tv_nsec = get_stat_mtime_ns (st) };
152 t.tv_nsec = get_stat_mtime_ns (st);
153 return t;
154#endif 151#endif
155} 152}
156 153
@@ -165,8 +162,8 @@ get_stat_birthtime (_GL_UNUSED struct stat const *st)
165 || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC) 162 || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC)
166 t = STAT_TIMESPEC (st, st_birthtim); 163 t = STAT_TIMESPEC (st, st_birthtim);
167#elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC 164#elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
168 t.tv_sec = st->st_birthtime; 165 t = (struct timespec) { .tv_sec = st->st_birthtime,
169 t.tv_nsec = st->st_birthtimensec; 166 .tv_nsec = st->st_birthtimensec };
170#elif defined _WIN32 && ! defined __CYGWIN__ 167#elif defined _WIN32 && ! defined __CYGWIN__
171 /* Native Windows platforms (but not Cygwin) put the "file creation 168 /* Native Windows platforms (but not Cygwin) put the "file creation
172 time" in st_ctime (!). See 169 time" in st_ctime (!). See
@@ -174,13 +171,11 @@ get_stat_birthtime (_GL_UNUSED struct stat const *st)
174# if _GL_WINDOWS_STAT_TIMESPEC 171# if _GL_WINDOWS_STAT_TIMESPEC
175 t = st->st_ctim; 172 t = st->st_ctim;
176# else 173# else
177 t.tv_sec = st->st_ctime; 174 t = (struct timespec) { .tv_sec = st->st_ctime };
178 t.tv_nsec = 0;
179# endif 175# endif
180#else 176#else
181 /* Birth time is not supported. */ 177 /* Birth time is not supported. */
182 t.tv_sec = -1; 178 t = (struct timespec) { .tv_sec = -1, .tv_nsec = -1 };
183 t.tv_nsec = -1;
184#endif 179#endif
185 180
186#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \ 181#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
@@ -192,10 +187,7 @@ get_stat_birthtime (_GL_UNUSED struct stat const *st)
192 sometimes returns junk in the birth time fields; work around this 187 sometimes returns junk in the birth time fields; work around this
193 bug if it is detected. */ 188 bug if it is detected. */
194 if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000)) 189 if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000))
195 { 190 t = (struct timespec) { .tv_sec = -1, .tv_nsec = -1 };
196 t.tv_sec = -1;
197 t.tv_nsec = -1;
198 }
199#endif 191#endif
200 192
201 return t; 193 return t;
@@ -229,8 +221,7 @@ stat_time_normalize (int result, _GL_UNUSED struct stat *st)
229 } 221 }
230 ts->tv_nsec = r; 222 ts->tv_nsec = r;
231 /* Overflow is possible, as Solaris 11 stat can yield 223 /* Overflow is possible, as Solaris 11 stat can yield
232 tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000. 224 tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000. */
233 INT_ADD_WRAPV is OK, since time_t is signed on Solaris. */
234 if (ckd_add (&ts->tv_sec, q, ts->tv_sec)) 225 if (ckd_add (&ts->tv_sec, q, ts->tv_sec))
235 { 226 {
236 errno = EOVERFLOW; 227 errno = EOVERFLOW;
diff --git a/lib/stddef.in.h b/lib/stddef.in.h
index 6eadcc3d5a4..431e819b8bf 100644
--- a/lib/stddef.in.h
+++ b/lib/stddef.in.h
@@ -18,7 +18,7 @@
18/* Written by Eric Blake. */ 18/* Written by Eric Blake. */
19 19
20/* 20/*
21 * POSIX 2008 <stddef.h> for platforms that have issues. 21 * POSIX 2008 and ISO C 23 <stddef.h> for platforms that have issues.
22 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html> 22 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html>
23 */ 23 */
24 24
@@ -37,9 +37,9 @@
37 remember if special invocation has ever been used to obtain wint_t, 37 remember if special invocation has ever been used to obtain wint_t,
38 in which case we need to clean up NULL yet again. */ 38 in which case we need to clean up NULL yet again. */
39 39
40# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T) 40# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _@GUARD_PREFIX@_STDDEF_WINT_T)
41# ifdef __need_wint_t 41# ifdef __need_wint_t
42# define _GL_STDDEF_WINT_T 42# define _@GUARD_PREFIX@_STDDEF_WINT_T
43# endif 43# endif
44# @INCLUDE_NEXT@ @NEXT_STDDEF_H@ 44# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
45 /* On TinyCC, make sure that the macros that indicate the special invocation 45 /* On TinyCC, make sure that the macros that indicate the special invocation
@@ -69,6 +69,7 @@ typedef long rpl_max_align_t;
69typedef long max_align_t; 69typedef long max_align_t;
70# define _MAX_ALIGN_T 70# define _MAX_ALIGN_T
71# endif 71# endif
72# define __CLANG_MAX_ALIGN_T_DEFINED
72# define GNULIB_defined_max_align_t 1 73# define GNULIB_defined_max_align_t 1
73# endif 74# endif
74# endif 75# endif
@@ -79,7 +80,7 @@ typedef long max_align_t;
79 80
80/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */ 81/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */
81# if (@REPLACE_NULL@ \ 82# if (@REPLACE_NULL@ \
82 && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _GL_STDDEF_WINT_T)) 83 && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _@GUARD_PREFIX@_STDDEF_WINT_T))
83# undef NULL 84# undef NULL
84# ifdef __cplusplus 85# ifdef __cplusplus
85 /* ISO C++ says that the macro NULL must expand to an integer constant 86 /* ISO C++ says that the macro NULL must expand to an integer constant
@@ -100,6 +101,11 @@ typedef long max_align_t;
100# ifndef _@GUARD_PREFIX@_STDDEF_H 101# ifndef _@GUARD_PREFIX@_STDDEF_H
101# define _@GUARD_PREFIX@_STDDEF_H 102# define _@GUARD_PREFIX@_STDDEF_H
102 103
104/* This file uses _Noreturn. */
105#if !_GL_CONFIG_H_INCLUDED
106 #error "Please include config.h first."
107#endif
108
103/* Some platforms lack wchar_t. */ 109/* Some platforms lack wchar_t. */
104#if !@HAVE_WCHAR_T@ 110#if !@HAVE_WCHAR_T@
105# define wchar_t int 111# define wchar_t int
@@ -137,11 +143,49 @@ typedef union
137 long int __i _GL_STDDEF_ALIGNAS (long int); 143 long int __i _GL_STDDEF_ALIGNAS (long int);
138} rpl_max_align_t; 144} rpl_max_align_t;
139# define max_align_t rpl_max_align_t 145# define max_align_t rpl_max_align_t
146# define __CLANG_MAX_ALIGN_T_DEFINED
140# define GNULIB_defined_max_align_t 1 147# define GNULIB_defined_max_align_t 1
141# endif 148# endif
142# endif 149# endif
143#endif 150#endif
144 151
152/* ISO C 23 § 7.21.1 The unreachable macro */
153#ifndef unreachable
154
155/* Code borrowed from verify.h. */
156# ifndef _GL_HAS_BUILTIN_UNREACHABLE
157# if defined __clang_major__ && __clang_major__ < 5
158# define _GL_HAS_BUILTIN_UNREACHABLE 0
159# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__)
160# define _GL_HAS_BUILTIN_UNREACHABLE 1
161# elif defined __has_builtin
162# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable)
163# else
164# define _GL_HAS_BUILTIN_UNREACHABLE 0
165# endif
166# endif
167
168# if _GL_HAS_BUILTIN_UNREACHABLE
169# define unreachable() __builtin_unreachable ()
170# elif 1200 <= _MSC_VER
171# define unreachable() __assume (0)
172# else
173/* Declare abort(), without including <stdlib.h>. */
174extern
175# if defined __cplusplus
176"C"
177# endif
178_Noreturn
179void abort (void)
180# if defined __cplusplus && (__GLIBC__ >= 2)
181throw ()
182# endif
183;
184# define unreachable() abort ()
185# endif
186
187#endif
188
145# endif /* _@GUARD_PREFIX@_STDDEF_H */ 189# endif /* _@GUARD_PREFIX@_STDDEF_H */
146# endif /* _@GUARD_PREFIX@_STDDEF_H */ 190# endif /* _@GUARD_PREFIX@_STDDEF_H */
147#endif /* __need_XXX */ 191#endif /* __need_XXX */
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 3f8ea985335..6be12c0525d 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -36,6 +36,12 @@
36 36
37#ifndef _@GUARD_PREFIX@_STDIO_H 37#ifndef _@GUARD_PREFIX@_STDIO_H
38 38
39/* Suppress macOS deprecation warnings for sprintf and vsprintf. */
40#if (defined __APPLE__ && defined __MACH__) && !defined _POSIX_C_SOURCE
41# define _POSIX_C_SOURCE 200809L
42# define _GL_DEFINED__POSIX_C_SOURCE
43#endif
44
39#define _GL_ALREADY_INCLUDING_STDIO_H 45#define _GL_ALREADY_INCLUDING_STDIO_H
40 46
41/* The include_next requires a split double-inclusion guard. */ 47/* The include_next requires a split double-inclusion guard. */
@@ -43,9 +49,20 @@
43 49
44#undef _GL_ALREADY_INCLUDING_STDIO_H 50#undef _GL_ALREADY_INCLUDING_STDIO_H
45 51
52#ifdef _GL_DEFINED__POSIX_C_SOURCE
53# undef _GL_DEFINED__POSIX_C_SOURCE
54# undef _POSIX_C_SOURCE
55#endif
56
46#ifndef _@GUARD_PREFIX@_STDIO_H 57#ifndef _@GUARD_PREFIX@_STDIO_H
47#define _@GUARD_PREFIX@_STDIO_H 58#define _@GUARD_PREFIX@_STDIO_H
48 59
60/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT,
61 _GL_ATTRIBUTE_MALLOC, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
62#if !_GL_CONFIG_H_INCLUDED
63 #error "Please include config.h first."
64#endif
65
49/* Get va_list. Needed on many systems, including glibc 2.8. */ 66/* Get va_list. Needed on many systems, including glibc 2.8. */
50#include <stdarg.h> 67#include <stdarg.h>
51 68
@@ -116,6 +133,16 @@
116# endif 133# endif
117#endif 134#endif
118 135
136/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
137 allocated memory. */
138#ifndef _GL_ATTRIBUTE_MALLOC
139# if __GNUC__ >= 3 || defined __clang__
140# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
141# else
142# define _GL_ATTRIBUTE_MALLOC
143# endif
144#endif
145
119/* An __attribute__ __format__ specifier for a function that takes a format 146/* An __attribute__ __format__ specifier for a function that takes a format
120 string and arguments, where the format string directives are the ones 147 string and arguments, where the format string directives are the ones
121 standardized by ISO C99 and POSIX. 148 standardized by ISO C99 and POSIX.
@@ -193,6 +220,36 @@
193# undef putc_unlocked 220# undef putc_unlocked
194#endif 221#endif
195 222
223
224/* Maximum number of characters produced by printing a NaN value. */
225#ifndef _PRINTF_NAN_LEN_MAX
226# if defined __FreeBSD__ || defined __DragonFly__ \
227 || defined __NetBSD__ \
228 || (defined __APPLE__ && defined __MACH__)
229/* On BSD systems, a NaN value prints as just "nan", without a sign. */
230# define _PRINTF_NAN_LEN_MAX 3
231# elif (__GLIBC__ >= 2) || MUSL_LIBC || defined __OpenBSD__ || defined __sun || defined __CYGWIN__
232/* glibc, musl libc, OpenBSD, Solaris libc, and Cygwin produce "[-]nan". */
233# define _PRINTF_NAN_LEN_MAX 4
234# elif defined _AIX
235/* AIX produces "[-]NaNQ". */
236# define _PRINTF_NAN_LEN_MAX 5
237# elif defined _WIN32 && !defined __CYGWIN__
238/* On native Windows, the output can be:
239 - with MSVC ucrt: "[-]nan" or "[-]nan(ind)" or "[-]nan(snan)",
240 - with mingw: "[-]1.#IND" or "[-]1.#QNAN". */
241# define _PRINTF_NAN_LEN_MAX 10
242# elif defined __sgi
243/* On IRIX, the output typically is "[-]nan0xNNNNNNNN" with 8 hexadecimal
244 digits. */
245# define _PRINTF_NAN_LEN_MAX 14
246# else
247/* We don't know, but 32 should be a safe maximum. */
248# define _PRINTF_NAN_LEN_MAX 32
249# endif
250#endif
251
252
196#if @GNULIB_DPRINTF@ 253#if @GNULIB_DPRINTF@
197# if @REPLACE_DPRINTF@ 254# if @REPLACE_DPRINTF@
198# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 255# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -275,7 +332,8 @@ _GL_CXXALIASWARN (fcloseall);
275# endif 332# endif
276_GL_FUNCDECL_RPL (fdopen, FILE *, 333_GL_FUNCDECL_RPL (fdopen, FILE *,
277 (int fd, const char *mode) 334 (int fd, const char *mode)
278 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 335 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
336 _GL_ATTRIBUTE_MALLOC);
279_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); 337_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
280# elif defined _WIN32 && !defined __CYGWIN__ 338# elif defined _WIN32 && !defined __CYGWIN__
281# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 339# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -288,7 +346,8 @@ _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
288/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ 346/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
289_GL_FUNCDECL_SYS (fdopen, FILE *, 347_GL_FUNCDECL_SYS (fdopen, FILE *,
290 (int fd, const char *mode) 348 (int fd, const char *mode)
291 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 349 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
350 _GL_ATTRIBUTE_MALLOC);
292# endif 351# endif
293_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); 352_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
294# endif 353# endif
@@ -298,7 +357,8 @@ _GL_CXXALIASWARN (fdopen);
298/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ 357/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
299_GL_FUNCDECL_SYS (fdopen, FILE *, 358_GL_FUNCDECL_SYS (fdopen, FILE *,
300 (int fd, const char *mode) 359 (int fd, const char *mode)
301 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 360 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
361 _GL_ATTRIBUTE_MALLOC);
302# endif 362# endif
303# if defined GNULIB_POSIXCHECK 363# if defined GNULIB_POSIXCHECK
304# undef fdopen 364# undef fdopen
@@ -409,7 +469,8 @@ _GL_CXXALIASWARN (fileno);
409# endif 469# endif
410_GL_FUNCDECL_RPL (fopen, FILE *, 470_GL_FUNCDECL_RPL (fopen, FILE *,
411 (const char *restrict filename, const char *restrict mode) 471 (const char *restrict filename, const char *restrict mode)
412 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 472 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
473 _GL_ATTRIBUTE_MALLOC);
413_GL_CXXALIAS_RPL (fopen, FILE *, 474_GL_CXXALIAS_RPL (fopen, FILE *,
414 (const char *restrict filename, const char *restrict mode)); 475 (const char *restrict filename, const char *restrict mode));
415# else 476# else
@@ -956,6 +1017,10 @@ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
956_GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream)); 1017_GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream));
957# else 1018# else
958# if @HAVE_DECL_GETW@ 1019# if @HAVE_DECL_GETW@
1020# if defined __APPLE__ && defined __MACH__
1021/* The presence of the declaration depends on _POSIX_C_SOURCE. */
1022_GL_FUNCDECL_SYS (getw, int, (FILE *restrict stream));
1023# endif
959_GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream)); 1024_GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream));
960# endif 1025# endif
961# endif 1026# endif
@@ -1060,13 +1125,15 @@ _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
1060# endif 1125# endif
1061_GL_FUNCDECL_RPL (popen, FILE *, 1126_GL_FUNCDECL_RPL (popen, FILE *,
1062 (const char *cmd, const char *mode) 1127 (const char *cmd, const char *mode)
1063 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)); 1128 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
1129 _GL_ATTRIBUTE_MALLOC);
1064_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); 1130_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
1065# else 1131# else
1066# if !@HAVE_POPEN@ || __GNUC__ >= 11 1132# if !@HAVE_POPEN@ || __GNUC__ >= 11
1067_GL_FUNCDECL_SYS (popen, FILE *, 1133_GL_FUNCDECL_SYS (popen, FILE *,
1068 (const char *cmd, const char *mode) 1134 (const char *cmd, const char *mode)
1069 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)); 1135 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
1136 _GL_ATTRIBUTE_MALLOC);
1070# endif 1137# endif
1071_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); 1138_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
1072# endif 1139# endif
@@ -1076,7 +1143,8 @@ _GL_CXXALIASWARN (popen);
1076/* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */ 1143/* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */
1077_GL_FUNCDECL_SYS (popen, FILE *, 1144_GL_FUNCDECL_SYS (popen, FILE *,
1078 (const char *cmd, const char *mode) 1145 (const char *cmd, const char *mode)
1079 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)); 1146 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
1147 _GL_ATTRIBUTE_MALLOC);
1080# endif 1148# endif
1081# if defined GNULIB_POSIXCHECK 1149# if defined GNULIB_POSIXCHECK
1082# undef popen 1150# undef popen
@@ -1199,6 +1267,10 @@ _GL_CXXALIASWARN (puts);
1199_GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream)); 1267_GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream));
1200# else 1268# else
1201# if @HAVE_DECL_PUTW@ 1269# if @HAVE_DECL_PUTW@
1270# if defined __APPLE__ && defined __MACH__
1271/* The presence of the declaration depends on _POSIX_C_SOURCE. */
1272_GL_FUNCDECL_SYS (putw, int, (int w, FILE *restrict stream));
1273# endif
1202_GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream)); 1274_GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream));
1203# endif 1275# endif
1204# endif 1276# endif
@@ -1410,13 +1482,15 @@ _GL_CXXALIASWARN (tempnam);
1410# define tmpfile rpl_tmpfile 1482# define tmpfile rpl_tmpfile
1411# endif 1483# endif
1412_GL_FUNCDECL_RPL (tmpfile, FILE *, (void) 1484_GL_FUNCDECL_RPL (tmpfile, FILE *, (void)
1413 _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 1485 _GL_ATTRIBUTE_DEALLOC (fclose, 1)
1486 _GL_ATTRIBUTE_MALLOC);
1414_GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); 1487_GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
1415# else 1488# else
1416# if __GNUC__ >= 11 1489# if __GNUC__ >= 11
1417/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ 1490/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
1418_GL_FUNCDECL_SYS (tmpfile, FILE *, (void) 1491_GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
1419 _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 1492 _GL_ATTRIBUTE_DEALLOC (fclose, 1)
1493 _GL_ATTRIBUTE_MALLOC);
1420# endif 1494# endif
1421_GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); 1495_GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
1422# endif 1496# endif
@@ -1427,7 +1501,8 @@ _GL_CXXALIASWARN (tmpfile);
1427# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile 1501# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile
1428/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ 1502/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
1429_GL_FUNCDECL_SYS (tmpfile, FILE *, (void) 1503_GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
1430 _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 1504 _GL_ATTRIBUTE_DEALLOC (fclose, 1)
1505 _GL_ATTRIBUTE_MALLOC);
1431# endif 1506# endif
1432# if defined GNULIB_POSIXCHECK 1507# if defined GNULIB_POSIXCHECK
1433# undef tmpfile 1508# undef tmpfile
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index a91f4e23d67..1479a2b2871 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -37,6 +37,12 @@
37#ifndef _@GUARD_PREFIX@_STDLIB_H 37#ifndef _@GUARD_PREFIX@_STDLIB_H
38#define _@GUARD_PREFIX@_STDLIB_H 38#define _@GUARD_PREFIX@_STDLIB_H
39 39
40/* This file uses _Noreturn, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
41 _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
42#if !_GL_CONFIG_H_INCLUDED
43 #error "Please include config.h first."
44#endif
45
40/* NetBSD 5.0 mis-defines NULL. */ 46/* NetBSD 5.0 mis-defines NULL. */
41#include <stddef.h> 47#include <stddef.h>
42 48
@@ -67,9 +73,7 @@
67# include <random.h> 73# include <random.h>
68# endif 74# endif
69 75
70# if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@ 76# include <stdint.h>
71# include <stdint.h>
72# endif
73 77
74# if !@HAVE_STRUCT_RANDOM_DATA@ 78# if !@HAVE_STRUCT_RANDOM_DATA@
75/* Define 'struct random_data'. 79/* Define 'struct random_data'.
@@ -461,7 +465,7 @@ _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
461# undef getprogname 465# undef getprogname
462# define getprogname rpl_getprogname 466# define getprogname rpl_getprogname
463# endif 467# endif
464# ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME 468# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@
465_GL_FUNCDECL_RPL (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE); 469_GL_FUNCDECL_RPL (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE);
466# else 470# else
467_GL_FUNCDECL_RPL (getprogname, const char *, (void)); 471_GL_FUNCDECL_RPL (getprogname, const char *, (void));
@@ -469,7 +473,7 @@ _GL_FUNCDECL_RPL (getprogname, const char *, (void));
469_GL_CXXALIAS_RPL (getprogname, const char *, (void)); 473_GL_CXXALIAS_RPL (getprogname, const char *, (void));
470# else 474# else
471# if !@HAVE_GETPROGNAME@ 475# if !@HAVE_GETPROGNAME@
472# ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME 476# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@
473_GL_FUNCDECL_SYS (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE); 477_GL_FUNCDECL_SYS (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE);
474# else 478# else
475_GL_FUNCDECL_SYS (getprogname, const char *, (void)); 479_GL_FUNCDECL_SYS (getprogname, const char *, (void));
@@ -589,6 +593,51 @@ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
589# endif 593# endif
590#endif 594#endif
591 595
596/* Return maximum number of bytes of a multibyte character. */
597#if @REPLACE_MB_CUR_MAX@
598# if !GNULIB_defined_MB_CUR_MAX
599static inline
600int gl_MB_CUR_MAX (void)
601{
602 /* Turn the value 3 to the value 4, as needed for the UTF-8 encoding. */
603 return MB_CUR_MAX + (MB_CUR_MAX == 3);
604}
605# undef MB_CUR_MAX
606# define MB_CUR_MAX gl_MB_CUR_MAX ()
607# define GNULIB_defined_MB_CUR_MAX 1
608# endif
609#endif
610
611/* Convert a string to a wide string. */
612#if @GNULIB_MBSTOWCS@
613# if @REPLACE_MBSTOWCS@
614# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
615# undef mbstowcs
616# define mbstowcs rpl_mbstowcs
617# endif
618_GL_FUNCDECL_RPL (mbstowcs, size_t,
619 (wchar_t *restrict dest, const char *restrict src,
620 size_t len)
621 _GL_ARG_NONNULL ((2)));
622_GL_CXXALIAS_RPL (mbstowcs, size_t,
623 (wchar_t *restrict dest, const char *restrict src,
624 size_t len));
625# else
626_GL_CXXALIAS_SYS (mbstowcs, size_t,
627 (wchar_t *restrict dest, const char *restrict src,
628 size_t len));
629# endif
630# if __GLIBC__ >= 2
631_GL_CXXALIASWARN (mbstowcs);
632# endif
633#elif defined GNULIB_POSIXCHECK
634# undef mbstowcs
635# if HAVE_RAW_DECL_MBSTOWCS
636_GL_WARN_ON_USE (mbstowcs, "mbstowcs is unportable - "
637 "use gnulib module mbstowcs for portability");
638# endif
639#endif
640
592/* Convert a multibyte character to a wide character. */ 641/* Convert a multibyte character to a wide character. */
593#if @GNULIB_MBTOWC@ 642#if @GNULIB_MBTOWC@
594# if @REPLACE_MBTOWC@ 643# if @REPLACE_MBTOWC@
@@ -1009,7 +1058,9 @@ _GL_FUNCDECL_SYS (random, long, (void));
1009 int. */ 1058 int. */
1010_GL_CXXALIAS_SYS_CAST (random, long, (void)); 1059_GL_CXXALIAS_SYS_CAST (random, long, (void));
1011# endif 1060# endif
1061# if __GLIBC__ >= 2
1012_GL_CXXALIASWARN (random); 1062_GL_CXXALIASWARN (random);
1063# endif
1013#elif defined GNULIB_POSIXCHECK 1064#elif defined GNULIB_POSIXCHECK
1014# undef random 1065# undef random
1015# if HAVE_RAW_DECL_RANDOM 1066# if HAVE_RAW_DECL_RANDOM
@@ -1034,7 +1085,9 @@ _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
1034 unsigned long seed. */ 1085 unsigned long seed. */
1035_GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed)); 1086_GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed));
1036# endif 1087# endif
1088# if __GLIBC__ >= 2
1037_GL_CXXALIASWARN (srandom); 1089_GL_CXXALIASWARN (srandom);
1090# endif
1038#elif defined GNULIB_POSIXCHECK 1091#elif defined GNULIB_POSIXCHECK
1039# undef srandom 1092# undef srandom
1040# if HAVE_RAW_DECL_SRANDOM 1093# if HAVE_RAW_DECL_SRANDOM
diff --git a/lib/string.in.h b/lib/string.in.h
index b6bf432e1f1..912d0f7a306 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -44,6 +44,12 @@
44#ifndef _@GUARD_PREFIX@_STRING_H 44#ifndef _@GUARD_PREFIX@_STRING_H
45#define _@GUARD_PREFIX@_STRING_H 45#define _@GUARD_PREFIX@_STRING_H
46 46
47/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
48 _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
49#if !_GL_CONFIG_H_INCLUDED
50 #error "Please include config.h first."
51#endif
52
47/* NetBSD 5.0 mis-defines NULL. */ 53/* NetBSD 5.0 mis-defines NULL. */
48#include <stddef.h> 54#include <stddef.h>
49 55
diff --git a/lib/strtol.c b/lib/strtol.c
index d11269b2622..b93483dca49 100644
--- a/lib/strtol.c
+++ b/lib/strtol.c
@@ -288,6 +288,11 @@ INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr,
288 s += 2; 288 s += 2;
289 base = 16; 289 base = 16;
290 } 290 }
291 else if ((base == 0 || base == 2) && TOUPPER (s[1]) == L_('B'))
292 {
293 s += 2;
294 base = 2;
295 }
291 else if (base == 0) 296 else if (base == 0)
292 base = 8; 297 base = 8;
293 } 298 }
@@ -378,11 +383,14 @@ INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr,
378noconv: 383noconv:
379 /* We must handle a special case here: the base is 0 or 16 and the 384 /* We must handle a special case here: the base is 0 or 16 and the
380 first two characters are '0' and 'x', but the rest are no 385 first two characters are '0' and 'x', but the rest are no
381 hexadecimal digits. This is no error case. We return 0 and 386 hexadecimal digits. Likewise when the base is 0 or 2 and the
382 ENDPTR points to the 'x'. */ 387 first two characters are '0' and 'b', but the rest are no binary
388 digits. This is no error case. We return 0 and ENDPTR points to
389 the 'x' or 'b'. */
383 if (endptr != NULL) 390 if (endptr != NULL)
384 { 391 {
385 if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X') 392 if (save - nptr >= 2
393 && (TOUPPER (save[-1]) == L_('X') || TOUPPER (save[-1]) == L_('B'))
386 && save[-2] == L_('0')) 394 && save[-2] == L_('0'))
387 *endptr = (STRING_TYPE *) &save[-1]; 395 *endptr = (STRING_TYPE *) &save[-1];
388 else 396 else
diff --git a/lib/sys_random.in.h b/lib/sys_random.in.h
index 8dca1326837..b240033bcbf 100644
--- a/lib/sys_random.in.h
+++ b/lib/sys_random.in.h
@@ -45,6 +45,11 @@
45#ifndef _@GUARD_PREFIX@_SYS_RANDOM_H 45#ifndef _@GUARD_PREFIX@_SYS_RANDOM_H
46#define _@GUARD_PREFIX@_SYS_RANDOM_H 46#define _@GUARD_PREFIX@_SYS_RANDOM_H
47 47
48/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
49#if !_GL_CONFIG_H_INCLUDED
50 #error "Please include config.h first."
51#endif
52
48#include <sys/types.h> 53#include <sys/types.h>
49 54
50/* Define the GRND_* constants. */ 55/* Define the GRND_* constants. */
diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h
index 13440fa6f0a..3abfc48af09 100644
--- a/lib/sys_select.in.h
+++ b/lib/sys_select.in.h
@@ -19,6 +19,13 @@
19# endif 19# endif
20@PRAGMA_COLUMNS@ 20@PRAGMA_COLUMNS@
21 21
22/* This file uses #include_next of a system file that defines time_t.
23 For the 'year2038' module to work right, <config.h> needs to have been
24 included before. */
25#if !_GL_CONFIG_H_INCLUDED
26 #error "Please include config.h first."
27#endif
28
22/* On OSF/1 and Solaris 2.6, <sys/types.h> and <sys/time.h> 29/* On OSF/1 and Solaris 2.6, <sys/types.h> and <sys/time.h>
23 both include <sys/select.h>. 30 both include <sys/select.h>.
24 On Cygwin and OpenBSD, <sys/time.h> includes <sys/select.h>. 31 On Cygwin and OpenBSD, <sys/time.h> includes <sys/select.h>.
@@ -71,6 +78,11 @@
71 78
72#ifndef _@GUARD_PREFIX@_SYS_SELECT_H 79#ifndef _@GUARD_PREFIX@_SYS_SELECT_H
73 80
81/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
82#if !_GL_CONFIG_H_INCLUDED
83 #error "Please include config.h first."
84#endif
85
74/* On many platforms, <sys/select.h> assumes prior inclusion of 86/* On many platforms, <sys/select.h> assumes prior inclusion of
75 <sys/types.h>. Also, mingw defines sigset_t there, instead of 87 <sys/types.h>. Also, mingw defines sigset_t there, instead of
76 in <signal.h> where it belongs. */ 88 in <signal.h> where it belongs. */
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 0c2f39c12bf..ad4da17fa46 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -25,6 +25,13 @@
25#endif 25#endif
26@PRAGMA_COLUMNS@ 26@PRAGMA_COLUMNS@
27 27
28/* This file uses #include_next of a system file that defines time_t.
29 For the 'year2038' module to work right, <config.h> needs to have been
30 included before. */
31#if !_GL_CONFIG_H_INCLUDED
32 #error "Please include config.h first."
33#endif
34
28#if defined __need_system_sys_stat_h 35#if defined __need_system_sys_stat_h
29/* Special invocation convention. */ 36/* Special invocation convention. */
30 37
@@ -48,6 +55,11 @@
48#ifndef _@GUARD_PREFIX@_SYS_STAT_H 55#ifndef _@GUARD_PREFIX@_SYS_STAT_H
49#define _@GUARD_PREFIX@_SYS_STAT_H 56#define _@GUARD_PREFIX@_SYS_STAT_H
50 57
58/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
59#if !_GL_CONFIG_H_INCLUDED
60 #error "Please include config.h first."
61#endif
62
51/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 63/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
52 64
53/* The definition of _GL_ARG_NONNULL is copied here. */ 65/* The definition of _GL_ARG_NONNULL is copied here. */
diff --git a/lib/sys_time.in.h b/lib/sys_time.in.h
index e833d551677..59cce1440da 100644
--- a/lib/sys_time.in.h
+++ b/lib/sys_time.in.h
@@ -24,6 +24,13 @@
24#endif 24#endif
25@PRAGMA_COLUMNS@ 25@PRAGMA_COLUMNS@
26 26
27/* This file uses #include_next of a system file that defines time_t.
28 For the 'year2038' module to work right, <config.h> needs to have been
29 included before. */
30#if !_GL_CONFIG_H_INCLUDED
31 #error "Please include config.h first."
32#endif
33
27/* On Cygwin and on many BSDish systems, <sys/time.h> includes itself 34/* On Cygwin and on many BSDish systems, <sys/time.h> includes itself
28 recursively via <sys/select.h>. 35 recursively via <sys/select.h>.
29 Simply delegate to the system's header in this case; it is a no-op. 36 Simply delegate to the system's header in this case; it is a no-op.
@@ -41,6 +48,11 @@
41#ifndef _@GUARD_PREFIX@_SYS_TIME_H 48#ifndef _@GUARD_PREFIX@_SYS_TIME_H
42#define _@GUARD_PREFIX@_SYS_TIME_H 49#define _@GUARD_PREFIX@_SYS_TIME_H
43 50
51/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
52#if !_GL_CONFIG_H_INCLUDED
53 #error "Please include config.h first."
54#endif
55
44#if ! @HAVE_SYS_TIME_H@ 56#if ! @HAVE_SYS_TIME_H@
45# include <time.h> 57# include <time.h>
46#endif 58#endif
diff --git a/lib/sys_types.in.h b/lib/sys_types.in.h
index 082a6c674de..ea77e140be9 100644
--- a/lib/sys_types.in.h
+++ b/lib/sys_types.in.h
@@ -20,6 +20,13 @@
20#endif 20#endif
21@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
22 22
23/* This file uses #include_next of a system file that defines time_t.
24 For the 'year2038' module to work right, <config.h> needs to have been
25 included before. */
26#if !_GL_CONFIG_H_INCLUDED
27 #error "Please include config.h first."
28#endif
29
23#if defined _WIN32 && !defined __CYGWIN__ \ 30#if defined _WIN32 && !defined __CYGWIN__ \
24 && (defined __need_off_t || defined __need___off64_t \ 31 && (defined __need_off_t || defined __need___off64_t \
25 || defined __need_ssize_t || defined __need_time_t) 32 || defined __need_ssize_t || defined __need_time_t)
diff --git a/lib/time.in.h b/lib/time.in.h
index 87cda21413b..06428adb1d0 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -20,6 +20,13 @@
20#endif 20#endif
21@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
22 22
23/* This file uses #include_next of a system file that defines time_t.
24 For the 'year2038' module to work right, <config.h> needs to have been
25 included before. */
26#if !_GL_CONFIG_H_INCLUDED
27 #error "Please include config.h first."
28#endif
29
23/* Don't get in the way of glibc when it includes time.h merely to 30/* Don't get in the way of glibc when it includes time.h merely to
24 declare a few standard symbols, rather than to declare all the 31 declare a few standard symbols, rather than to declare all the
25 symbols. (However, skip this for MinGW as it treats __need_time_t 32 symbols. (However, skip this for MinGW as it treats __need_time_t
@@ -45,6 +52,12 @@
45 52
46# @INCLUDE_NEXT@ @NEXT_TIME_H@ 53# @INCLUDE_NEXT@ @NEXT_TIME_H@
47 54
55/* This file uses _GL_ATTRIBUTE_DEPRECATED, GNULIB_POSIXCHECK,
56 HAVE_RAW_DECL_*. */
57# if !_GL_CONFIG_H_INCLUDED
58# error "Please include config.h first."
59# endif
60
48/* NetBSD 5.0 mis-defines NULL. */ 61/* NetBSD 5.0 mis-defines NULL. */
49# include <stddef.h> 62# include <stddef.h>
50 63
@@ -143,6 +156,22 @@ _GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base));
143_GL_CXXALIASWARN (timespec_getres); 156_GL_CXXALIASWARN (timespec_getres);
144# endif 157# endif
145 158
159/* Return the number of seconds that have elapsed since the Epoch. */
160# if @GNULIB_TIME@
161# if @REPLACE_TIME@
162# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
163# define time rpl_time
164# endif
165_GL_FUNCDECL_RPL (time, time_t, (time_t *__tp));
166_GL_CXXALIAS_RPL (time, time_t, (time_t *__tp));
167# else
168_GL_CXXALIAS_SYS (time, time_t, (time_t *__tp));
169# endif
170# if __GLIBC__ >= 2
171_GL_CXXALIASWARN (time);
172# endif
173# endif
174
146/* Sleep for at least RQTP seconds unless interrupted, If interrupted, 175/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
147 return -1 and store the remaining time into RMTP. See 176 return -1 and store the remaining time into RMTP. See
148 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html>. */ 177 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html>. */
@@ -327,7 +356,9 @@ _GL_CXXALIASWARN (strptime);
327# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 356# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
328# define ctime rpl_ctime 357# define ctime rpl_ctime
329# endif 358# endif
359# ifndef __cplusplus
330_GL_ATTRIBUTE_DEPRECATED 360_GL_ATTRIBUTE_DEPRECATED
361# endif
331_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp) 362_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp)
332 _GL_ARG_NONNULL ((1))); 363 _GL_ARG_NONNULL ((1)));
333_GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp)); 364_GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
diff --git a/lib/timespec-add.c b/lib/timespec-add.c
index cb3017803b4..38c4dfc24c2 100644
--- a/lib/timespec-add.c
+++ b/lib/timespec-add.c
@@ -23,6 +23,7 @@
23#include <config.h> 23#include <config.h>
24#include "timespec.h" 24#include "timespec.h"
25 25
26#include <stdckdint.h>
26#include "intprops.h" 27#include "intprops.h"
27 28
28struct timespec 29struct timespec
@@ -38,7 +39,7 @@ timespec_add (struct timespec a, struct timespec b)
38 { 39 {
39 rns = nsd; 40 rns = nsd;
40 time_t bs1; 41 time_t bs1;
41 if (!INT_ADD_WRAPV (bs, 1, &bs1)) 42 if (!ckd_add (&bs1, bs, 1))
42 bs = bs1; 43 bs = bs1;
43 else if (rs < 0) 44 else if (rs < 0)
44 rs++; 45 rs++;
@@ -46,7 +47,7 @@ timespec_add (struct timespec a, struct timespec b)
46 goto high_overflow; 47 goto high_overflow;
47 } 48 }
48 49
49 if (INT_ADD_WRAPV (rs, bs, &rs)) 50 if (ckd_add (&rs, rs, bs))
50 { 51 {
51 if (bs < 0) 52 if (bs < 0)
52 { 53 {
diff --git a/lib/timespec-sub.c b/lib/timespec-sub.c
index 822c2831089..f8052400410 100644
--- a/lib/timespec-sub.c
+++ b/lib/timespec-sub.c
@@ -24,6 +24,7 @@
24#include <config.h> 24#include <config.h>
25#include "timespec.h" 25#include "timespec.h"
26 26
27#include <stdckdint.h>
27#include "intprops.h" 28#include "intprops.h"
28 29
29struct timespec 30struct timespec
@@ -38,7 +39,7 @@ timespec_sub (struct timespec a, struct timespec b)
38 { 39 {
39 rns = ns + TIMESPEC_HZ; 40 rns = ns + TIMESPEC_HZ;
40 time_t bs1; 41 time_t bs1;
41 if (!INT_ADD_WRAPV (bs, 1, &bs1)) 42 if (!ckd_add (&bs1, bs, 1))
42 bs = bs1; 43 bs = bs1;
43 else if (- TYPE_SIGNED (time_t) < rs) 44 else if (- TYPE_SIGNED (time_t) < rs)
44 rs--; 45 rs--;
@@ -46,7 +47,7 @@ timespec_sub (struct timespec a, struct timespec b)
46 goto low_overflow; 47 goto low_overflow;
47 } 48 }
48 49
49 if (INT_SUBTRACT_WRAPV (rs, bs, &rs)) 50 if (ckd_sub (&rs, rs, bs))
50 { 51 {
51 if (0 < bs) 52 if (0 < bs)
52 { 53 {
diff --git a/lib/timespec.h b/lib/timespec.h
index ba78647f09a..e94da75defe 100644
--- a/lib/timespec.h
+++ b/lib/timespec.h
@@ -19,11 +19,14 @@
19#if ! defined TIMESPEC_H 19#if ! defined TIMESPEC_H
20#define TIMESPEC_H 20#define TIMESPEC_H
21 21
22#include <time.h> 22/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_ATTRIBUTE_CONST,
23 23 _GL_ATTRIBUTE_PURE, _GL_CMP. */
24#ifndef _GL_INLINE_HEADER_BEGIN 24#if !_GL_CONFIG_H_INCLUDED
25 #error "Please include config.h first." 25 #error "Please include config.h first."
26#endif 26#endif
27
28#include <time.h>
29
27_GL_INLINE_HEADER_BEGIN 30_GL_INLINE_HEADER_BEGIN
28#ifndef _GL_TIMESPEC_INLINE 31#ifndef _GL_TIMESPEC_INLINE
29# define _GL_TIMESPEC_INLINE _GL_INLINE 32# define _GL_TIMESPEC_INLINE _GL_INLINE
@@ -52,10 +55,7 @@ enum { LOG10_TIMESPEC_RESOLUTION = LOG10_TIMESPEC_HZ };
52_GL_TIMESPEC_INLINE struct timespec 55_GL_TIMESPEC_INLINE struct timespec
53make_timespec (time_t s, long int ns) 56make_timespec (time_t s, long int ns)
54{ 57{
55 struct timespec r; 58 return (struct timespec) { .tv_sec = s, .tv_nsec = ns };
56 r.tv_sec = s;
57 r.tv_nsec = ns;
58 return r;
59} 59}
60 60
61/* Return negative, zero, positive if A < B, A == B, A > B, respectively. */ 61/* Return negative, zero, positive if A < B, A == B, A > B, respectively. */
diff --git a/lib/u64.h b/lib/u64.h
index 0353ad4d9af..8a99335b6aa 100644
--- a/lib/u64.h
+++ b/lib/u64.h
@@ -17,11 +17,13 @@
17 17
18/* Written by Paul Eggert. */ 18/* Written by Paul Eggert. */
19 19
20#include <stdint.h> 20/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */
21 21#if !_GL_CONFIG_H_INCLUDED
22#ifndef _GL_INLINE_HEADER_BEGIN
23 #error "Please include config.h first." 22 #error "Please include config.h first."
24#endif 23#endif
24
25#include <stdint.h>
26
25_GL_INLINE_HEADER_BEGIN 27_GL_INLINE_HEADER_BEGIN
26#ifndef _GL_U64_INLINE 28#ifndef _GL_U64_INLINE
27# define _GL_U64_INLINE _GL_INLINE 29# define _GL_U64_INLINE _GL_INLINE
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 8ba9867894e..2ae040a76b3 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -69,6 +69,12 @@
69#if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H 69#if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
70#define _@GUARD_PREFIX@_UNISTD_H 70#define _@GUARD_PREFIX@_UNISTD_H
71 71
72/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, GNULIB_POSIXCHECK,
73 HAVE_RAW_DECL_*. */
74#if !_GL_CONFIG_H_INCLUDED
75 #error "Please include config.h first."
76#endif
77
72/* NetBSD 5.0 mis-defines NULL. Also get size_t. */ 78/* NetBSD 5.0 mis-defines NULL. Also get size_t. */
73/* But avoid namespace pollution on glibc systems. */ 79/* But avoid namespace pollution on glibc systems. */
74#ifndef __GLIBC__ 80#ifndef __GLIBC__
@@ -170,9 +176,6 @@
170# include <getopt-pfx-core.h> 176# include <getopt-pfx-core.h>
171#endif 177#endif
172 178
173#ifndef _GL_INLINE_HEADER_BEGIN
174 #error "Please include config.h first."
175#endif
176_GL_INLINE_HEADER_BEGIN 179_GL_INLINE_HEADER_BEGIN
177#ifndef _GL_UNISTD_INLINE 180#ifndef _GL_UNISTD_INLINE
178# define _GL_UNISTD_INLINE _GL_INLINE 181# define _GL_UNISTD_INLINE _GL_INLINE
diff --git a/lib/unlocked-io.h b/lib/unlocked-io.h
index fdef624ab9c..4830df4a747 100644
--- a/lib/unlocked-io.h
+++ b/lib/unlocked-io.h
@@ -31,6 +31,11 @@
31 the *_unlocked functions directly. On hosts that lack those 31 the *_unlocked functions directly. On hosts that lack those
32 functions, invoke the non-thread-safe versions instead. */ 32 functions, invoke the non-thread-safe versions instead. */
33 33
34/* This file uses HAVE_DECL_*_UNLOCKED. */
35# if !_GL_CONFIG_H_INCLUDED
36# error "Please include config.h first."
37# endif
38
34# include <stdio.h> 39# include <stdio.h>
35 40
36# if HAVE_DECL_CLEARERR_UNLOCKED || defined clearerr_unlocked 41# if HAVE_DECL_CLEARERR_UNLOCKED || defined clearerr_unlocked
diff --git a/lib/utimens.c b/lib/utimens.c
index 4c5377eca0f..faa197e6cb5 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -405,10 +405,10 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2])
405 struct timeval *t; 405 struct timeval *t;
406 if (ts) 406 if (ts)
407 { 407 {
408 timeval[0].tv_sec = ts[0].tv_sec; 408 timeval[0] = (struct timeval) { .tv_sec = ts[0].tv_sec,
409 timeval[0].tv_usec = ts[0].tv_nsec / 1000; 409 .tv_usec = ts[0].tv_nsec / 1000 };
410 timeval[1].tv_sec = ts[1].tv_sec; 410 timeval[1] = (struct timeval) { .tv_sec = ts[1].tv_sec,
411 timeval[1].tv_usec = ts[1].tv_nsec / 1000; 411 .tv_usec = ts[1].tv_nsec / 1000 };
412 t = timeval; 412 t = timeval;
413 } 413 }
414 else 414 else
@@ -502,8 +502,8 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2])
502 struct utimbuf *ut; 502 struct utimbuf *ut;
503 if (ts) 503 if (ts)
504 { 504 {
505 utimbuf.actime = ts[0].tv_sec; 505 utimbuf = (struct utimbuf) { .actime = ts[0].tv_sec,
506 utimbuf.modtime = ts[1].tv_sec; 506 .modtime = ts[1].tv_sec };
507 ut = &utimbuf; 507 ut = &utimbuf;
508 } 508 }
509 else 509 else
@@ -621,10 +621,10 @@ lutimens (char const *file, struct timespec const timespec[2])
621 int result; 621 int result;
622 if (ts) 622 if (ts)
623 { 623 {
624 timeval[0].tv_sec = ts[0].tv_sec; 624 timeval[0] = (struct timeval) { .tv_sec = ts[0].tv_sec,
625 timeval[0].tv_usec = ts[0].tv_nsec / 1000; 625 .tv_usec = ts[0].tv_nsec / 1000 };
626 timeval[1].tv_sec = ts[1].tv_sec; 626 timeval[1] = (struct timeval) { .tv_sec = ts[1].tv_sec,
627 timeval[1].tv_usec = ts[1].tv_nsec / 1000; 627 .tv_usec = ts[1].tv_nsec / 1000 };
628 t = timeval; 628 t = timeval;
629 } 629 }
630 else 630 else
diff --git a/lib/utimens.h b/lib/utimens.h
index a7056981f32..4a21792a7e4 100644
--- a/lib/utimens.h
+++ b/lib/utimens.h
@@ -17,6 +17,11 @@
17 17
18/* Written by Paul Eggert. */ 18/* Written by Paul Eggert. */
19 19
20/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */
21#if !_GL_CONFIG_H_INCLUDED
22 #error "Please include config.h first."
23#endif
24
20#include <time.h> 25#include <time.h>
21int fdutimens (int, char const *, struct timespec const [2]); 26int fdutimens (int, char const *, struct timespec const [2]);
22int utimens (char const *, struct timespec const [2]); 27int utimens (char const *, struct timespec const [2]);
@@ -26,9 +31,6 @@ int lutimens (char const *, struct timespec const [2]);
26# include <fcntl.h> 31# include <fcntl.h>
27# include <sys/stat.h> 32# include <sys/stat.h>
28 33
29#ifndef _GL_INLINE_HEADER_BEGIN
30 #error "Please include config.h first."
31#endif
32_GL_INLINE_HEADER_BEGIN 34_GL_INLINE_HEADER_BEGIN
33#ifndef _GL_UTIMENS_INLINE 35#ifndef _GL_UTIMENS_INLINE
34# define _GL_UTIMENS_INLINE _GL_INLINE 36# define _GL_UTIMENS_INLINE _GL_INLINE
diff --git a/lib/verify.h b/lib/verify.h
index f0b3fc5851b..e4af91517e6 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -241,10 +241,16 @@ template <int w>
241# define _Static_assert(...) \ 241# define _Static_assert(...) \
242 _GL_VERIFY (__VA_ARGS__, "static assertion failed", -) 242 _GL_VERIFY (__VA_ARGS__, "static assertion failed", -)
243# else 243# else
244 /* Work around MSVC preprocessor incompatibility with ISO C; see 244# if defined __cplusplus && _MSC_VER >= 1910
245 <https://stackoverflow.com/questions/5134523/>. */ 245 /* In MSVC 14.1 or newer, static_assert accepts one or two arguments,
246# define _Static_assert(R, ...) \ 246 but _Static_assert is not defined. */
247 _GL_VERIFY ((R), "static assertion failed", -) 247# define _Static_assert static_assert
248# else
249 /* Work around MSVC preprocessor incompatibility with ISO C; see
250 <https://stackoverflow.com/questions/5134523/>. */
251# define _Static_assert(R, ...) \
252 _GL_VERIFY ((R), "static assertion failed", -)
253# endif
248# endif 254# endif
249# endif 255# endif
250/* Define static_assert if needed. */ 256/* Define static_assert if needed. */
@@ -252,7 +258,7 @@ template <int w>
252 && __STDC_VERSION__ < 202311 \ 258 && __STDC_VERSION__ < 202311 \
253 && (!defined __cplusplus \ 259 && (!defined __cplusplus \
254 || (__cpp_static_assert < 201411 \ 260 || (__cpp_static_assert < 201411 \
255 && __GNUG__ < 6 && __clang_major__ < 6))) 261 && __GNUG__ < 6 && __clang_major__ < 6 && _MSC_VER < 1910)))
256# if defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__ 262# if defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__
257/* MSVC 14 in C++ mode supports the two-arguments static_assert but not 263/* MSVC 14 in C++ mode supports the two-arguments static_assert but not
258 the one-argument static_assert, and it does not support _Static_assert. 264 the one-argument static_assert, and it does not support _Static_assert.
@@ -285,14 +291,16 @@ template <int w>
285# define _GL_HAS_BUILTIN_TRAP 0 291# define _GL_HAS_BUILTIN_TRAP 0
286#endif 292#endif
287 293
288#if defined __clang_major__ && __clang_major__ < 5 294#ifndef _GL_HAS_BUILTIN_UNREACHABLE
289# define _GL_HAS_BUILTIN_UNREACHABLE 0 295# if defined __clang_major__ && __clang_major__ < 5
290#elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) 296# define _GL_HAS_BUILTIN_UNREACHABLE 0
291# define _GL_HAS_BUILTIN_UNREACHABLE 1 297# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__)
292#elif defined __has_builtin 298# define _GL_HAS_BUILTIN_UNREACHABLE 1
293# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) 299# elif defined __has_builtin
294#else 300# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable)
295# define _GL_HAS_BUILTIN_UNREACHABLE 0 301# else
302# define _GL_HAS_BUILTIN_UNREACHABLE 0
303# endif
296#endif 304#endif
297 305
298/* Each of these macros verifies that its argument R is nonzero. To 306/* Each of these macros verifies that its argument R is nonzero. To