summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2022-09-17 00:56:19 (GMT)
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2022-09-17 00:56:19 (GMT)
commit62af1d0b2a31185dc8acaf3fe8fc3149414277bd (patch)
tree8aded0ff4acf5bcc582c61c3da9ab098656da6b4
parent1909de2e843f1dfd5e031d3d4aa6901a5b9a139d (diff)
downloadmonitoring-plugins-62af1d0.tar.gz
gnulib changes
-rw-r--r--gl/Makefile.am115
-rw-r--r--gl/af_alg.c213
-rw-r--r--gl/af_alg.h115
-rw-r--r--gl/byteswap.in.h44
-rw-r--r--gl/fflush.c233
-rw-r--r--gl/fpurge.c150
-rw-r--r--gl/freading.c76
-rw-r--r--gl/freading.h55
-rw-r--r--gl/fseek.c30
-rw-r--r--gl/fseeko.c164
-rw-r--r--gl/ftell.c37
-rw-r--r--gl/ftello.c157
-rw-r--r--gl/gl_openssl.h116
-rw-r--r--gl/inttypes.h1509
-rw-r--r--gl/limits.h132
-rw-r--r--gl/lseek.c89
-rw-r--r--gl/m4/af_alg.m457
-rw-r--r--gl/m4/byteswap.m417
-rw-r--r--gl/m4/fflush.m4100
-rw-r--r--gl/m4/fpurge.m473
-rw-r--r--gl/m4/freading.m411
-rw-r--r--gl/m4/fseek.m415
-rw-r--r--gl/m4/fseeko.m477
-rw-r--r--gl/m4/ftell.m415
-rw-r--r--gl/m4/ftello.m4151
-rw-r--r--gl/m4/gl-openssl.m476
-rw-r--r--gl/m4/gnulib-cache.m42
-rw-r--r--gl/m4/gnulib-comp.m487
-rw-r--r--gl/m4/lseek.m478
-rw-r--r--gl/m4/sha256.m414
-rw-r--r--gl/m4/ungetc.m473
-rw-r--r--gl/malloc/.deps/.dirstamp0
-rw-r--r--gl/malloc/.deps/libgnu_a-dynarray-skeleton.Po1
-rw-r--r--gl/malloc/.deps/libgnu_a-dynarray_at_failure.Po138
-rw-r--r--gl/malloc/.deps/libgnu_a-dynarray_emplace_enlarge.Po138
-rw-r--r--gl/malloc/.deps/libgnu_a-dynarray_finalize.Po116
-rw-r--r--gl/malloc/.deps/libgnu_a-dynarray_resize.Po138
-rw-r--r--gl/malloc/.deps/libgnu_a-dynarray_resize_clear.Po51
-rw-r--r--gl/malloc/.dirstamp0
-rw-r--r--gl/malloc/dynarray-skeleton.gl.h529
-rw-r--r--gl/malloc/dynarray.gl.h174
-rw-r--r--gl/sha256-stream.c145
-rw-r--r--gl/sha256.c433
-rw-r--r--gl/sha256.h121
-rw-r--r--gl/stdckdint.h38
-rw-r--r--gl/stdio-impl.h212
-rw-r--r--gl/sys-limits.h42
47 files changed, 2964 insertions, 3393 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am
index d0acf41..8578de5 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -34,7 +34,6 @@
34# --macro-prefix=gl \ 34# --macro-prefix=gl \
35# --no-vc-files \ 35# --no-vc-files \
36# base64 \ 36# base64 \
37# crypto/sha256 \
38# dirname \ 37# dirname \
39# environ \ 38# environ \
40# floorf \ 39# floorf \
@@ -179,26 +178,6 @@ endif
179 178
180## end gnulib module btowc 179## end gnulib module btowc
181 180
182## begin gnulib module byteswap
183
184BUILT_SOURCES += $(BYTESWAP_H)
185
186# We need the following in order to create <byteswap.h> when the system
187# doesn't have one.
188if GL_GENERATE_BYTESWAP_H
189byteswap.h: byteswap.in.h $(top_builddir)/config.status
190 $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/byteswap.in.h
191 $(AM_V_at)mv $@-t $@
192else
193byteswap.h: $(top_builddir)/config.status
194 rm -f $@
195endif
196MOSTLYCLEANFILES += byteswap.h byteswap.h-t
197
198EXTRA_DIST += byteswap.in.h
199
200## end gnulib module byteswap
201
202## begin gnulib module calloc-gnu 181## begin gnulib module calloc-gnu
203 182
204 183
@@ -233,28 +212,6 @@ endif
233 212
234## end gnulib module close 213## end gnulib module close
235 214
236## begin gnulib module crypto/af_alg
237
238libgnu_a_SOURCES += af_alg.c
239
240EXTRA_DIST += af_alg.h sys-limits.h
241
242## end gnulib module crypto/af_alg
243
244## begin gnulib module crypto/sha256
245
246libgnu_a_SOURCES += sha256-stream.c
247
248## end gnulib module crypto/sha256
249
250## begin gnulib module crypto/sha256-buffer
251
252libgnu_a_SOURCES += sha256.c
253
254EXTRA_DIST += gl_openssl.h sha256.h
255
256## end gnulib module crypto/sha256-buffer
257
258## begin gnulib module dirname 215## begin gnulib module dirname
259 216
260libgnu_a_SOURCES += dirname.c basename.c 217libgnu_a_SOURCES += dirname.c basename.c
@@ -417,16 +374,6 @@ EXTRA_DIST += fd-hook.h
417 374
418## end gnulib module fd-hook 375## end gnulib module fd-hook
419 376
420## begin gnulib module fflush
421
422if GL_COND_OBJ_FFLUSH
423libgnu_a_SOURCES += fflush.c
424endif
425
426EXTRA_DIST += stdio-impl.h
427
428## end gnulib module fflush
429
430## begin gnulib module filename 377## begin gnulib module filename
431 378
432 379
@@ -498,24 +445,6 @@ EXTRA_libgnu_a_SOURCES += fopen.c
498 445
499## end gnulib module fopen-gnu 446## end gnulib module fopen-gnu
500 447
501## begin gnulib module fpurge
502
503if GL_COND_OBJ_FPURGE
504libgnu_a_SOURCES += fpurge.c
505endif
506
507EXTRA_DIST += stdio-impl.h
508
509## end gnulib module fpurge
510
511## begin gnulib module freading
512
513libgnu_a_SOURCES += freading.c
514
515EXTRA_DIST += freading.h stdio-impl.h
516
517## end gnulib module freading
518
519## begin gnulib module free-posix 448## begin gnulib module free-posix
520 449
521if GL_COND_OBJ_FREE 450if GL_COND_OBJ_FREE
@@ -524,24 +453,6 @@ endif
524 453
525## end gnulib module free-posix 454## end gnulib module free-posix
526 455
527## begin gnulib module fseek
528
529if GL_COND_OBJ_FSEEK
530libgnu_a_SOURCES += fseek.c
531endif
532
533## end gnulib module fseek
534
535## begin gnulib module fseeko
536
537if GL_COND_OBJ_FSEEKO
538libgnu_a_SOURCES += fseeko.c
539endif
540
541EXTRA_DIST += stdio-impl.h
542
543## end gnulib module fseeko
544
545## begin gnulib module fstat 456## begin gnulib module fstat
546 457
547if GL_COND_OBJ_FSTAT 458if GL_COND_OBJ_FSTAT
@@ -564,24 +475,6 @@ EXTRA_DIST += fsusage.h
564 475
565## end gnulib module fsusage 476## end gnulib module fsusage
566 477
567## begin gnulib module ftell
568
569if GL_COND_OBJ_FTELL
570libgnu_a_SOURCES += ftell.c
571endif
572
573## end gnulib module ftell
574
575## begin gnulib module ftello
576
577if GL_COND_OBJ_FTELLO
578libgnu_a_SOURCES += ftello.c
579endif
580
581EXTRA_DIST += stdio-impl.h
582
583## end gnulib module ftello
584
585## begin gnulib module gen-header 478## begin gnulib module gen-header
586 479
587# In 'sed', replace the pattern space with a "DO NOT EDIT" comment. 480# In 'sed', replace the pattern space with a "DO NOT EDIT" comment.
@@ -947,14 +840,6 @@ libgnu_a_SOURCES += glthread/lock.h glthread/lock.c
947 840
948## end gnulib module lock 841## end gnulib module lock
949 842
950## begin gnulib module lseek
951
952if GL_COND_OBJ_LSEEK
953libgnu_a_SOURCES += lseek.c
954endif
955
956## end gnulib module lseek
957
958## begin gnulib module malloc-gnu 843## begin gnulib module malloc-gnu
959 844
960 845
diff --git a/gl/af_alg.c b/gl/af_alg.c
deleted file mode 100644
index 084bff6..0000000
--- a/gl/af_alg.c
+++ /dev/null
@@ -1,213 +0,0 @@
1/* af_alg.c - Compute message digests from file streams and buffers.
2 Copyright (C) 2018-2022 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/* Written by Matteo Croce <mcroce@redhat.com>, 2018. */
18
19#include <config.h>
20
21#include "af_alg.h"
22
23#if USE_LINUX_CRYPTO_API
24
25#include <unistd.h>
26#include <string.h>
27#include <stdio.h>
28#include <errno.h>
29#include <linux/if_alg.h>
30#include <sys/stat.h>
31#include <sys/sendfile.h>
32#include <sys/socket.h>
33
34#include "sys-limits.h"
35
36#define BLOCKSIZE 32768
37
38/* Return a newly created socket for ALG.
39 On error, return a negative error number. */
40static int
41alg_socket (char const *alg)
42{
43 struct sockaddr_alg salg = {
44 .salg_family = AF_ALG,
45 .salg_type = "hash",
46 };
47 /* Copy alg into salg.salg_name, without calling strcpy nor strlen. */
48 for (size_t i = 0; (salg.salg_name[i] = alg[i]) != '\0'; i++)
49 if (i == sizeof salg.salg_name - 1)
50 /* alg is too long. */
51 return -EINVAL;
52
53 int cfd = socket (AF_ALG, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
54 if (cfd < 0)
55 return -EAFNOSUPPORT;
56 int ofd = (bind (cfd, (struct sockaddr *) &salg, sizeof salg) == 0
57 ? accept4 (cfd, NULL, 0, SOCK_CLOEXEC)
58 : -1);
59 close (cfd);
60 return ofd < 0 ? -EAFNOSUPPORT : ofd;
61}
62
63int
64afalg_buffer (const char *buffer, size_t len, const char *alg,
65 void *resblock, ssize_t hashlen)
66{
67 /* On Linux < 4.9, the value for an empty stream is wrong (all zeroes).
68 See <https://patchwork.kernel.org/patch/9308641/>.
69 This was not fixed properly until November 2016,
70 see <https://patchwork.kernel.org/patch/9434741/>. */
71 if (len == 0)
72 return -EAFNOSUPPORT;
73
74 int ofd = alg_socket (alg);
75 if (ofd < 0)
76 return ofd;
77
78 int result;
79
80 for (;;)
81 {
82 ssize_t size = (len > BLOCKSIZE ? BLOCKSIZE : len);
83 if (send (ofd, buffer, size, MSG_MORE) != size)
84 {
85 result = -EAFNOSUPPORT;
86 break;
87 }
88 buffer += size;
89 len -= size;
90 if (len == 0)
91 {
92 result = read (ofd, resblock, hashlen) == hashlen ? 0 : -EAFNOSUPPORT;
93 break;
94 }
95 }
96
97 close (ofd);
98 return result;
99}
100
101int
102afalg_stream (FILE *stream, const char *alg,
103 void *resblock, ssize_t hashlen)
104{
105 int ofd = alg_socket (alg);
106 if (ofd < 0)
107 return ofd;
108
109 /* If STREAM's size is known and nonzero and not too large, attempt
110 sendfile to pipe the data. The nonzero restriction avoids issues
111 with /proc files that pretend to be empty, and lets the classic
112 read-write loop work around an empty-input bug noted below. */
113 int fd = fileno (stream);
114 int result;
115 struct stat st;
116 off_t off = ftello (stream);
117 if (0 <= off && fstat (fd, &st) == 0
118 && (S_ISREG (st.st_mode) || S_TYPEISSHM (&st) || S_TYPEISTMO (&st))
119 && off < st.st_size && st.st_size - off < SYS_BUFSIZE_MAX)
120 {
121 /* Make sure the offset of fileno (stream) reflects how many bytes
122 have been read from stream before this function got invoked.
123 Note: fflush on an input stream after ungetc does not work as expected
124 on some platforms. Therefore this situation is not supported here. */
125 if (fflush (stream))
126 result = -EIO;
127 else
128 {
129 off_t nbytes = st.st_size - off;
130 if (sendfile (ofd, fd, &off, nbytes) == nbytes)
131 {
132 if (read (ofd, resblock, hashlen) == hashlen)
133 {
134 /* The input buffers of stream are no longer valid. */
135 if (lseek (fd, off, SEEK_SET) != (off_t)-1)
136 result = 0;
137 else
138 /* The file position of fd has not changed. */
139 result = -EAFNOSUPPORT;
140 }
141 else
142 /* The file position of fd has not changed. */
143 result = -EAFNOSUPPORT;
144 }
145 else
146 /* The file position of fd has not changed. */
147 result = -EAFNOSUPPORT;
148 }
149 }
150 else
151 {
152 /* sendfile not possible, do a classic read-write loop. */
153
154 /* Number of bytes to seek (backwards) in case of error. */
155 off_t nseek = 0;
156
157 for (;;)
158 {
159 char buf[BLOCKSIZE];
160 /* When the stream is not seekable, start with a single-byte block,
161 so that we can use ungetc() in the case that send() fails. */
162 size_t blocksize = (nseek == 0 && off < 0 ? 1 : BLOCKSIZE);
163 ssize_t size = fread (buf, 1, blocksize, stream);
164 if (size == 0)
165 {
166 /* On Linux < 4.9, the value for an empty stream is wrong (all 0).
167 See <https://patchwork.kernel.org/patch/9308641/>.
168 This was not fixed properly until November 2016,
169 see <https://patchwork.kernel.org/patch/9434741/>. */
170 result = ferror (stream) ? -EIO : nseek == 0 ? -EAFNOSUPPORT : 0;
171 break;
172 }
173 nseek -= size;
174 if (send (ofd, buf, size, MSG_MORE) != size)
175 {
176 if (nseek == -1)
177 {
178 /* 1 byte of pushback buffer is guaranteed on stream, even
179 if stream is not seekable. */
180 ungetc ((unsigned char) buf[0], stream);
181 result = -EAFNOSUPPORT;
182 }
183 else if (fseeko (stream, nseek, SEEK_CUR) == 0)
184 /* The position of stream has been restored. */
185 result = -EAFNOSUPPORT;
186 else
187 result = -EIO;
188 break;
189 }
190
191 /* Don't assume that EOF is sticky. See:
192 <https://sourceware.org/bugzilla/show_bug.cgi?id=19476>. */
193 if (feof (stream))
194 {
195 result = 0;
196 break;
197 }
198 }
199
200 if (result == 0 && read (ofd, resblock, hashlen) != hashlen)
201 {
202 if (nseek == 0 || fseeko (stream, nseek, SEEK_CUR) == 0)
203 /* The position of stream has been restored. */
204 result = -EAFNOSUPPORT;
205 else
206 result = -EIO;
207 }
208 }
209 close (ofd);
210 return result;
211}
212
213#endif
diff --git a/gl/af_alg.h b/gl/af_alg.h
deleted file mode 100644
index ddd6568..0000000
--- a/gl/af_alg.h
+++ /dev/null
@@ -1,115 +0,0 @@
1/* af_alg.h - Compute message digests from file streams and buffers.
2 Copyright (C) 2018-2022 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/* Written by Matteo Croce <mcroce@redhat.com>, 2018.
18 Documentation by Bruno Haible <bruno@clisp.org>, 2018. */
19
20/* Declare specific functions for computing message digests
21 using the Linux kernel crypto API, if available. This kernel API gives
22 access to specialized crypto instructions (that would also be available
23 in user space) or to crypto devices (not directly available in user space).
24
25 For a more complete set of facilities that use the Linux kernel crypto API,
26 look at libkcapi. */
27
28#ifndef AF_ALG_H
29# define AF_ALG_H 1
30
31# include <stdio.h>
32# include <errno.h>
33
34# ifdef __cplusplus
35extern "C" {
36# endif
37
38# if USE_LINUX_CRYPTO_API
39
40/* Compute a message digest of a memory region.
41
42 The memory region starts at BUFFER and is LEN bytes long.
43
44 ALG is the message digest algorithm; see the file /proc/crypto.
45
46 RESBLOCK points to a block of HASHLEN bytes, for the result.
47 HASHLEN must be the length of the message digest, in bytes, in particular:
48
49 alg | hashlen
50 -------+--------
51 md5 | 16
52 sha1 | 20
53 sha224 | 28
54 sha256 | 32
55 sha384 | 48
56 sha512 | 64
57
58 If successful, fill RESBLOCK and return 0.
59 Upon failure, return a negated error number. */
60int
61afalg_buffer (const char *buffer, size_t len, const char *alg,
62 void *resblock, ssize_t hashlen);
63
64/* Compute a message digest of data read from STREAM.
65
66 STREAM is an open file stream. The last operation on STREAM should
67 not be 'ungetc', and if STREAM is also open for writing it should
68 have been fflushed since its last write. Read from the current
69 position to the end of STREAM. Handle regular files efficiently.
70
71 ALG is the message digest algorithm; see the file /proc/crypto.
72
73 RESBLOCK points to a block of HASHLEN bytes, for the result.
74 HASHLEN must be the length of the message digest, in bytes, in particular:
75
76 alg | hashlen
77 -------+--------
78 md5 | 16
79 sha1 | 20
80 sha224 | 28
81 sha256 | 32
82 sha384 | 48
83 sha512 | 64
84
85 If successful, fill RESBLOCK and return 0.
86 Upon failure, return a negated error number.
87 Unless returning 0 or -EIO, restore STREAM's file position so that
88 the caller can fall back on some other method. */
89int
90afalg_stream (FILE *stream, const char *alg,
91 void *resblock, ssize_t hashlen);
92
93# else
94
95static inline int
96afalg_buffer (const char *buffer, size_t len, const char *alg,
97 void *resblock, ssize_t hashlen)
98{
99 return -EAFNOSUPPORT;
100}
101
102static inline int
103afalg_stream (FILE *stream, const char *alg,
104 void *resblock, ssize_t hashlen)
105{
106 return -EAFNOSUPPORT;
107}
108
109# endif
110
111# ifdef __cplusplus
112}
113# endif
114
115#endif /* AF_ALG_H */
diff --git a/gl/byteswap.in.h b/gl/byteswap.in.h
deleted file mode 100644
index f4746d3..0000000
--- a/gl/byteswap.in.h
+++ /dev/null
@@ -1,44 +0,0 @@
1/* byteswap.h - Byte swapping
2 Copyright (C) 2005, 2007, 2009-2022 Free Software Foundation, Inc.
3 Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _GL_BYTESWAP_H
19#define _GL_BYTESWAP_H
20
21/* Given an unsigned 16-bit argument X, return the value corresponding to
22 X with reversed byte order. */
23#define bswap_16(x) ((((x) & 0x00FF) << 8) | \
24 (((x) & 0xFF00) >> 8))
25
26/* Given an unsigned 32-bit argument X, return the value corresponding to
27 X with reversed byte order. */
28#define bswap_32(x) ((((x) & 0x000000FF) << 24) | \
29 (((x) & 0x0000FF00) << 8) | \
30 (((x) & 0x00FF0000) >> 8) | \
31 (((x) & 0xFF000000) >> 24))
32
33/* Given an unsigned 64-bit argument X, return the value corresponding to
34 X with reversed byte order. */
35#define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \
36 (((x) & 0x000000000000FF00ULL) << 40) | \
37 (((x) & 0x0000000000FF0000ULL) << 24) | \
38 (((x) & 0x00000000FF000000ULL) << 8) | \
39 (((x) & 0x000000FF00000000ULL) >> 8) | \
40 (((x) & 0x0000FF0000000000ULL) >> 24) | \
41 (((x) & 0x00FF000000000000ULL) >> 40) | \
42 (((x) & 0xFF00000000000000ULL) >> 56))
43
44#endif /* _GL_BYTESWAP_H */
diff --git a/gl/fflush.c b/gl/fflush.c
deleted file mode 100644
index 69511cd..0000000
--- a/gl/fflush.c
+++ /dev/null
@@ -1,233 +0,0 @@
1/* fflush.c -- allow flushing input streams
2 Copyright (C) 2007-2022 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/* Written by Eric Blake. */
18
19#include <config.h>
20
21/* Specification. */
22#include <stdio.h>
23
24#include <errno.h>
25#include <unistd.h>
26
27#include "freading.h"
28
29#include "stdio-impl.h"
30
31#undef fflush
32
33
34#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
35/* GNU libc, BeOS, Haiku, Linux libc5 */
36
37/* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */
38static void
39clear_ungetc_buffer_preserving_position (FILE *fp)
40{
41 if (fp->_flags & _IO_IN_BACKUP)
42 /* _IO_free_backup_area is a bit complicated. Simply call fseek. */
43 fseeko (fp, 0, SEEK_CUR);
44}
45
46#else
47
48/* Clear the stream's ungetc buffer. May modify the value of ftello (fp). */
49static void
50clear_ungetc_buffer (FILE *fp)
51{
52# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
53 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
54 if (HASUB (fp))
55 {
56 fp_->_p += fp_->_r;
57 fp_->_r = 0;
58 }
59# elif defined __EMX__ /* emx+gcc */
60 if (fp->_ungetc_count > 0)
61 {
62 fp->_ungetc_count = 0;
63 fp->_rcount = - fp->_rcount;
64 }
65# elif defined _IOERR /* Minix, AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
66 /* Nothing to do. */
67# else /* other implementations */
68 fseeko (fp, 0, SEEK_CUR);
69# endif
70}
71
72#endif
73
74#if ! (defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1)
75/* GNU libc, BeOS, Haiku, Linux libc5 */
76
77# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
78/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
79
80static int
81disable_seek_optimization (FILE *fp)
82{
83 int saved_flags = fp_->_flags & (__SOPT | __SNPT);
84 fp_->_flags = (fp_->_flags & ~__SOPT) | __SNPT;
85 return saved_flags;
86}
87
88static void
89restore_seek_optimization (FILE *fp, int saved_flags)
90{
91 fp_->_flags = (fp_->_flags & ~(__SOPT | __SNPT)) | saved_flags;
92}
93
94# else
95
96static void
97update_fpos_cache (_GL_ATTRIBUTE_MAYBE_UNUSED FILE *fp,
98 _GL_ATTRIBUTE_MAYBE_UNUSED off_t pos)
99{
100# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
101 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
102# if defined __CYGWIN__
103 /* fp_->_offset is typed as an integer. */
104 fp_->_offset = pos;
105# else
106 /* fp_->_offset is an fpos_t. */
107 /* Use a union, since on NetBSD, the compilation flags determine
108 whether fpos_t is typedef'd to off_t or a struct containing a
109 single off_t member. */
110 union
111 {
112 fpos_t f;
113 off_t o;
114 } u;
115 u.o = pos;
116 fp_->_offset = u.f;
117# endif
118 fp_->_flags |= __SOFF;
119# endif
120}
121# endif
122#endif
123
124/* Flush all pending data on STREAM according to POSIX rules. Both
125 output and seekable input streams are supported. */
126int
127rpl_fflush (FILE *stream)
128{
129 /* When stream is NULL, POSIX and C99 only require flushing of "output
130 streams and update streams in which the most recent operation was not
131 input", and all implementations do this.
132
133 When stream is "an output stream or an update stream in which the most
134 recent operation was not input", POSIX and C99 requires that fflush
135 writes out any buffered data, and all implementations do this.
136
137 When stream is, however, an input stream or an update stream in
138 which the most recent operation was input, C99 specifies nothing,
139 and POSIX only specifies behavior if the stream is seekable.
140 mingw, in particular, drops the input buffer, leaving the file
141 descriptor positioned at the end of the input buffer. I.e. ftell
142 (stream) is lost. We don't want to call the implementation's
143 fflush in this case.
144
145 We test ! freading (stream) here, rather than fwriting (stream), because
146 what we need to know is whether the stream holds a "read buffer", and on
147 mingw this is indicated by _IOREAD, regardless of _IOWRT. */
148 if (stream == NULL || ! freading (stream))
149 return fflush (stream);
150
151#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
152 /* GNU libc, BeOS, Haiku, Linux libc5 */
153
154 clear_ungetc_buffer_preserving_position (stream);
155
156 return fflush (stream);
157
158#else
159 {
160 /* What POSIX says:
161 1) About the file-position indicator (-> fseeko, ftello):
162 The file position indicator is incremented by fgetc() and decremented
163 by ungetc():
164 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fgetc.html>
165 "... the fgetc() function shall ... advance the associated file
166 position indicator for the stream ..."
167 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ungetc.html>
168 "The file-position indicator is decremented by each successful
169 call to ungetc()..."
170 2) fflush discards bytes pushed back by ungetc:
171 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fflush.html>
172 "...any characters pushed back onto the stream by ungetc()
173 or ungetwc() that have not subsequently been read from the
174 stream shall be discarded..."
175 This implies implicitly: fflush does not change the file position
176 indicator.
177 3) Effects on the file descriptor, if the file descriptor is capable of
178 seeking:
179 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fflush.html>
180 "...the file offset of the underlying open file description shall
181 be set to the file position of the stream..." */
182
183 /* POSIX does not specify fflush behavior for non-seekable input
184 streams. Some implementations purge unread data, some return
185 EBADF, some do nothing. */
186 off_t pos = ftello (stream);
187 if (pos == -1)
188 {
189 errno = EBADF;
190 return EOF;
191 }
192
193 /* Clear the ungetc buffer. */
194 clear_ungetc_buffer (stream);
195
196 /* To get here, we must be flushing a seekable input stream, so the
197 semantics of fpurge are now appropriate to clear the buffer. To
198 avoid losing data, the lseek is also necessary. */
199 {
200 int result = fpurge (stream);
201 if (result != 0)
202 return result;
203 }
204
205# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
206 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
207
208 {
209 /* Disable seek optimization for the next fseeko call. This tells the
210 following fseeko call to seek to the desired position directly, rather
211 than to seek to a block-aligned boundary. */
212 int saved_flags = disable_seek_optimization (stream);
213 int result = fseeko (stream, pos, SEEK_SET);
214
215 restore_seek_optimization (stream, saved_flags);
216 return result;
217 }
218
219# else
220
221 pos = lseek (fileno (stream), pos, SEEK_SET);
222 if (pos == -1)
223 return EOF;
224 /* After a successful lseek, update the file descriptor's position cache
225 in the stream. */
226 update_fpos_cache (stream, pos);
227
228 return 0;
229
230# endif
231 }
232#endif
233}
diff --git a/gl/fpurge.c b/gl/fpurge.c
deleted file mode 100644
index 21e3b86..0000000
--- a/gl/fpurge.c
+++ /dev/null
@@ -1,150 +0,0 @@
1/* Flushing buffers of a FILE stream.
2 Copyright (C) 2007-2022 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#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.10, Android API >= 23, musl libc */
23# if HAVE_STDIO_EXT_H
24# include <stdio_ext.h>
25# endif
26#endif
27#include <stdlib.h>
28
29#include "stdio-impl.h"
30
31int
32fpurge (FILE *fp)
33{
34#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.10, Android API >= 23, musl libc */
35
36 __fpurge (fp);
37 /* The __fpurge function does not have a return value. */
38 return 0;
39
40#elif HAVE_FPURGE /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin >= 1.7 */
41
42 /* Call the system's fpurge function. */
43# undef fpurge
44# if !HAVE_DECL_FPURGE
45 extern int fpurge (FILE *);
46# endif
47 int result = fpurge (fp);
48# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
49 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
50 if (result == 0)
51 /* Correct the invariants that fpurge broke.
52 <stdio.h> on BSD systems says:
53 "The following always hold: if _flags & __SRD, _w is 0."
54 If this invariant is not fulfilled and the stream is read-write but
55 currently reading, subsequent putc or fputc calls will write directly
56 into the buffer, although they shouldn't be allowed to. */
57 if ((fp_->_flags & __SRD) != 0)
58 fp_->_w = 0;
59# endif
60 return result;
61
62#else
63
64 /* Most systems provide FILE as a struct and the necessary bitmask in
65 <stdio.h>, because they need it for implementing getc() and putc() as
66 fast macros. */
67# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
68 /* GNU libc, BeOS, Haiku, Linux libc5 */
69 fp->_IO_read_end = fp->_IO_read_ptr;
70 fp->_IO_write_ptr = fp->_IO_write_base;
71 /* Avoid memory leak when there is an active ungetc buffer. */
72 if (fp->_IO_save_base != NULL)
73 {
74 free (fp->_IO_save_base);
75 fp->_IO_save_base = NULL;
76 }
77 return 0;
78# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
79 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
80 fp_->_p = fp_->_bf._base;
81 fp_->_r = 0;
82 fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
83 ? fp_->_bf._size
84 : 0);
85 /* Avoid memory leak when there is an active ungetc buffer. */
86 if (fp_ub._base != NULL)
87 {
88 if (fp_ub._base != fp_->_ubuf)
89 free (fp_ub._base);
90 fp_ub._base = NULL;
91 }
92 return 0;
93# elif defined __EMX__ /* emx+gcc */
94 fp->_ptr = fp->_buffer;
95 fp->_rcount = 0;
96 fp->_wcount = 0;
97 fp->_ungetc_count = 0;
98 return 0;
99# elif defined __minix /* Minix */
100 fp->_ptr = fp->_buf;
101 if (fp->_ptr != NULL)
102 fp->_count = 0;
103 return 0;
104# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
105 fp_->_ptr = fp_->_base;
106 if (fp_->_ptr != NULL)
107 fp_->_cnt = 0;
108 return 0;
109# elif defined __UCLIBC__ /* uClibc */
110# ifdef __STDIO_BUFFERS
111 if (fp->__modeflags & __FLAG_WRITING)
112 fp->__bufpos = fp->__bufstart;
113 else if (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING))
114 fp->__bufpos = fp->__bufread;
115# endif
116 return 0;
117# elif defined __QNX__ /* QNX */
118 fp->_Rback = fp->_Back + sizeof (fp->_Back);
119 fp->_Rsave = NULL;
120 if (fp->_Mode & 0x2000 /* _MWRITE */)
121 /* fp->_Buf <= fp->_Next <= fp->_Wend */
122 fp->_Next = fp->_Buf;
123 else
124 /* fp->_Buf <= fp->_Next <= fp->_Rend */
125 fp->_Rend = fp->_Next;
126 return 0;
127# elif defined __MINT__ /* Atari FreeMiNT */
128 if (fp->__pushed_back)
129 {
130 fp->__bufp = fp->__pushback_bufp;
131 fp->__pushed_back = 0;
132 }
133 /* Preserve the current file position. */
134 if (fp->__target != -1)
135 fp->__target += fp->__bufp - fp->__buffer;
136 fp->__bufp = fp->__buffer;
137 /* Nothing in the buffer, next getc is nontrivial. */
138 fp->__get_limit = fp->__bufp;
139 /* Nothing in the buffer, next putc is nontrivial. */
140 fp->__put_limit = fp->__buffer;
141 return 0;
142# elif defined EPLAN9 /* Plan9 */
143 fp->rp = fp->wp = fp->lp = fp->buf;
144 return 0;
145# else
146# error "Please port gnulib fpurge.c to your platform! Look at the definitions of fflush, setvbuf and ungetc on your system, then report this to bug-gnulib."
147# endif
148
149#endif
150}
diff --git a/gl/freading.c b/gl/freading.c
deleted file mode 100644
index 93e96e0..0000000
--- a/gl/freading.c
+++ /dev/null
@@ -1,76 +0,0 @@
1/* Retrieve information about a FILE stream.
2 Copyright (C) 2007-2022 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#include <config.h>
18
19/* Specification. */
20#include "freading.h"
21
22#include "stdio-impl.h"
23
24/* Don't use glibc's __freading function in glibc < 2.7, see
25 <https://sourceware.org/bugzilla/show_bug.cgi?id=4359> */
26#if !(HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)))
27
28bool
29freading (FILE *fp)
30{
31 /* Most systems provide FILE as a struct and the necessary bitmask in
32 <stdio.h>, because they need it for implementing getc() and putc() as
33 fast macros. */
34# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
35 /* GNU libc, BeOS, Haiku, Linux libc5 */
36 return ((fp->_flags & _IO_NO_WRITES) != 0
37 || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
38 && fp->_IO_read_base != NULL));
39# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
40 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin < 1.7.34, Minix 3, Android */
41 return (fp_->_flags & __SRD) != 0;
42# elif defined __EMX__ /* emx+gcc */
43 return (fp->_flags & _IOREAD) != 0;
44# elif defined __minix /* Minix */
45 return (fp->_flags & _IOREADING) != 0;
46# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
47# if defined __sun /* Solaris */
48 return (fp_->_flag & _IOREAD) != 0 && (fp_->_flag & _IOWRT) == 0;
49# else
50 return (fp_->_flag & _IOREAD) != 0;
51# endif
52# elif defined __UCLIBC__ /* uClibc */
53 return (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) != 0;
54# elif defined __QNX__ /* QNX */
55 return ((fp->_Mode & 0x2 /* _MOPENW */) == 0
56 || (fp->_Mode & 0x1000 /* _MREAD */) != 0);
57# elif defined __MINT__ /* Atari FreeMiNT */
58 if (!fp->__mode.__write)
59 return 1;
60 if (!fp->__mode.__read)
61 return 0;
62# ifdef _IO_CURRENTLY_GETTING /* Flag added on 2009-02-28 */
63 return (fp->__flags & _IO_CURRENTLY_GETTING) != 0;
64# else
65 return (fp->__buffer < fp->__get_limit /*|| fp->__bufp == fp->__put_limit ??*/);
66# endif
67# elif defined EPLAN9 /* Plan9 */
68 if (fp->state == 0 /* CLOSED */ || fp->state == 4 /* WR */)
69 return 0;
70 return (fp->state == 3 /* RD */ && (fp->bufl == 0 || fp->rp < fp->wp));
71# else
72# error "Please port gnulib freading.c to your platform!"
73# endif
74}
75
76#endif
diff --git a/gl/freading.h b/gl/freading.h
deleted file mode 100644
index 74fed22..0000000
--- a/gl/freading.h
+++ /dev/null
@@ -1,55 +0,0 @@
1/* Retrieve information about a FILE stream.
2 Copyright (C) 2007-2022 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#include <stdbool.h>
18#include <stdio.h>
19
20/* Return true if the stream STREAM is opened read-only, or if the
21 last operation on the stream was a read operation. Return false if
22 the stream is opened write-only or append-only, or if it supports
23 writing and there is no current read operation (such as fgetc).
24
25 freading and fwriting will never both be true. If STREAM supports
26 both reads and writes, then:
27 - both freading and fwriting might be false when the stream is first
28 opened, after read encounters EOF, or after fflush,
29 - freading might be false or true and fwriting might be false
30 after repositioning (such as fseek, fsetpos, or rewind),
31 depending on the underlying implementation.
32
33 STREAM must not be wide-character oriented. */
34
35#if HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7))
36/* Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.34, Android API >= 29, not glibc >= 2.2, but glibc >= 2.7, or musl libc */
37
38# if HAVE_STDIO_EXT_H
39# include <stdio_ext.h>
40# endif
41# define freading(stream) (__freading (stream) != 0)
42
43#else
44
45# ifdef __cplusplus
46extern "C" {
47# endif
48
49extern bool freading (FILE *stream) _GL_ATTRIBUTE_PURE;
50
51# ifdef __cplusplus
52}
53# endif
54
55#endif
diff --git a/gl/fseek.c b/gl/fseek.c
deleted file mode 100644
index e9f9314..0000000
--- a/gl/fseek.c
+++ /dev/null
@@ -1,30 +0,0 @@
1/* An fseek() function that, together with fflush(), is POSIX compliant.
2 Copyright (C) 2007, 2009-2022 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#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22/* Get off_t. */
23#include <unistd.h>
24
25int
26fseek (FILE *fp, long offset, int whence)
27{
28 /* Use the replacement fseeko function with all its workarounds. */
29 return fseeko (fp, (off_t)offset, whence);
30}
diff --git a/gl/fseeko.c b/gl/fseeko.c
deleted file mode 100644
index 2ca2db8..0000000
--- a/gl/fseeko.c
+++ /dev/null
@@ -1,164 +0,0 @@
1/* An fseeko() function that, together with fflush(), is POSIX compliant.
2 Copyright (C) 2007-2022 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#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22/* Get off_t, lseek, _POSIX_VERSION. */
23#include <unistd.h>
24
25#include "stdio-impl.h"
26
27int
28fseeko (FILE *fp, off_t offset, int whence)
29#undef fseeko
30#if !HAVE_FSEEKO
31# undef fseek
32# define fseeko fseek
33#endif
34#if _GL_WINDOWS_64_BIT_OFF_T
35# undef fseeko
36# if HAVE__FSEEKI64 && HAVE_DECL__FSEEKI64 /* msvc, mingw since msvcrt8.0, mingw64 */
37# define fseeko _fseeki64
38# else /* mingw before msvcrt8.0 */
39# define fseeko fseeko64
40# endif
41#endif
42{
43#if LSEEK_PIPE_BROKEN
44 /* mingw gives bogus answers rather than failure on non-seekable files. */
45 if (lseek (fileno (fp), 0, SEEK_CUR) == -1)
46 return EOF;
47#endif
48
49 /* These tests are based on fpurge.c. */
50#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
51 /* GNU libc, BeOS, Haiku, Linux libc5 */
52 if (fp->_IO_read_end == fp->_IO_read_ptr
53 && fp->_IO_write_ptr == fp->_IO_write_base
54 && fp->_IO_save_base == NULL)
55#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
56 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
57# if defined __SL64 && defined __SCLE /* Cygwin */
58 if ((fp->_flags & __SL64) == 0)
59 {
60 /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit
61 mode; but has an fseeko that requires 64-bit mode. */
62 FILE *tmp = fopen ("/dev/null", "r");
63 if (!tmp)
64 return -1;
65 fp->_flags |= __SL64;
66 fp->_seek64 = tmp->_seek64;
67 fclose (tmp);
68 }
69# endif
70 if (fp_->_p == fp_->_bf._base
71 && fp_->_r == 0
72 && fp_->_w == ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
73 ? fp_->_bf._size
74 : 0)
75 && fp_ub._base == NULL)
76#elif defined __EMX__ /* emx+gcc */
77 if (fp->_ptr == fp->_buffer
78 && fp->_rcount == 0
79 && fp->_wcount == 0
80 && fp->_ungetc_count == 0)
81#elif defined __minix /* Minix */
82 if (fp_->_ptr == fp_->_buf
83 && (fp_->_ptr == NULL || fp_->_count == 0))
84#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
85 if (fp_->_ptr == fp_->_base
86 && (fp_->_ptr == NULL || fp_->_cnt == 0))
87#elif defined __UCLIBC__ /* uClibc */
88 if (((fp->__modeflags & __FLAG_WRITING) == 0
89 || fp->__bufpos == fp->__bufstart)
90 && ((fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) == 0
91 || fp->__bufpos == fp->__bufread))
92#elif defined __QNX__ /* QNX */
93 if ((fp->_Mode & 0x2000 /* _MWRITE */ ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend)
94 && fp->_Rback == fp->_Back + sizeof (fp->_Back)
95 && fp->_Rsave == NULL)
96#elif defined __MINT__ /* Atari FreeMiNT */
97 if (fp->__bufp == fp->__buffer
98 && fp->__get_limit == fp->__bufp
99 && fp->__put_limit == fp->__bufp
100 && !fp->__pushed_back)
101#elif defined EPLAN9 /* Plan9 */
102 if (fp->rp == fp->buf
103 && fp->wp == fp->buf)
104#elif FUNC_FFLUSH_STDIN < 0 && 200809 <= _POSIX_VERSION
105 /* Cross-compiling to some other system advertising conformance to
106 POSIX.1-2008 or later. Assume fseeko and fflush work as advertised.
107 If this assumption is incorrect, please report the bug to
108 bug-gnulib. */
109 if (0)
110#else
111 #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
112#endif
113 {
114 /* We get here when an fflush() call immediately preceded this one (or
115 if ftell() has created buffers but no I/O has occurred on a
116 newly-opened stream). We know there are no buffers. */
117 off_t pos = lseek (fileno (fp), offset, whence);
118 if (pos == -1)
119 {
120#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
121 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
122 fp_->_flags &= ~__SOFF;
123#endif
124 return -1;
125 }
126
127#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
128 /* GNU libc, BeOS, Haiku, Linux libc5 */
129 fp->_flags &= ~_IO_EOF_SEEN;
130 fp->_offset = pos;
131#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
132 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
133# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix
134 /* fp_->_offset is typed as an integer. */
135 fp_->_offset = pos;
136# else
137 /* fp_->_offset is an fpos_t. */
138 {
139 /* Use a union, since on NetBSD, the compilation flags
140 determine whether fpos_t is typedef'd to off_t or a struct
141 containing a single off_t member. */
142 union
143 {
144 fpos_t f;
145 off_t o;
146 } u;
147 u.o = pos;
148 fp_->_offset = u.f;
149 }
150# endif
151 fp_->_flags |= __SOFF;
152 fp_->_flags &= ~__SEOF;
153#elif defined __EMX__ /* emx+gcc */
154 fp->_flags &= ~_IOEOF;
155#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
156 fp_->_flag &= ~_IOEOF;
157#elif defined __MINT__ /* Atari FreeMiNT */
158 fp->__offset = pos;
159 fp->__eof = 0;
160#endif
161 return 0;
162 }
163 return fseeko (fp, offset, whence);
164}
diff --git a/gl/ftell.c b/gl/ftell.c
deleted file mode 100644
index 3fbd9e9..0000000
--- a/gl/ftell.c
+++ /dev/null
@@ -1,37 +0,0 @@
1/* An ftell() function that works around platform bugs.
2 Copyright (C) 2007-2022 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#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22#include <errno.h>
23#include <limits.h>
24
25long
26ftell (FILE *fp)
27{
28 /* Use the replacement ftello function with all its workarounds. */
29 off_t offset = ftello (fp);
30 if (LONG_MIN <= offset && offset <= LONG_MAX)
31 return /* (long) */ offset;
32 else
33 {
34 errno = EOVERFLOW;
35 return -1;
36 }
37}
diff --git a/gl/ftello.c b/gl/ftello.c
deleted file mode 100644
index 989614a..0000000
--- a/gl/ftello.c
+++ /dev/null
@@ -1,157 +0,0 @@
1/* An ftello() function that works around platform bugs.
2 Copyright (C) 2007, 2009-2022 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#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22#include <errno.h>
23#include "intprops.h"
24
25/* Get lseek. */
26#include <unistd.h>
27
28#include "stdio-impl.h"
29
30off_t
31ftello (FILE *fp)
32#undef ftello
33#if !HAVE_FTELLO
34# undef ftell
35# define ftello ftell
36#endif
37#if _GL_WINDOWS_64_BIT_OFF_T
38# undef ftello
39# if HAVE__FTELLI64 /* msvc, mingw64 */
40# define ftello _ftelli64
41# else /* mingw */
42# define ftello ftello64
43# endif
44#endif
45{
46#if FTELLO_BROKEN_AFTER_UNGETC /* macOS >= 10.15 */
47 /* The system's ftello() is completely broken, because it calls __sflush,
48 which makes side effects on the stream. */
49
50 /* Handle non-seekable files first. */
51 if (fp->_file < 0 || fp->_seek == NULL)
52 {
53 errno = ESPIPE;
54 return -1;
55 }
56
57 /* Determine the current offset, ignoring buffered and pushed-back bytes. */
58 off_t pos;
59
60 if (fp->_flags & __SOFF)
61 pos = fp->_offset;
62 else
63 {
64 pos = fp->_seek (fp->_cookie, 0, SEEK_CUR);
65 if (pos < 0)
66 return -1;
67 if (fp->_flags & __SOPT)
68 {
69 fp->_offset = pos;
70 fp->_flags |= __SOFF;
71 }
72 }
73
74 if (fp->_flags & __SRD)
75 {
76 /* Now consider buffered and pushed-back bytes from ungetc. */
77 if (fp->_ub._base != NULL)
78 /* Considering the buffered bytes, we are at position
79 pos - fp->_ur.
80 Considering also the pushed-back bytes, we are at position
81 pos - fp->_ur - fp->_r. */
82 pos = pos - fp->_ur - fp->_r;
83 else
84 /* Considering the buffered bytes, we are at position
85 pos - fp->_r. */
86 pos = pos - fp->_r;
87 if (pos < 0)
88 {
89 errno = EIO;
90 return -1;
91 }
92 }
93 else if ((fp->_flags & __SWR) && fp->_p != NULL)
94 {
95 /* Consider the buffered bytes. */
96 off_t buffered = fp->_p - fp->_bf._base;
97
98 /* Compute pos + buffered, with overflow check. */
99 off_t sum;
100 if (! INT_ADD_OK (pos, buffered, &sum))
101 {
102 errno = EOVERFLOW;
103 return -1;
104 }
105 pos = sum;
106 }
107
108 return pos;
109
110#else
111
112# if LSEEK_PIPE_BROKEN
113 /* mingw gives bogus answers rather than failure on non-seekable files. */
114 if (lseek (fileno (fp), 0, SEEK_CUR) == -1)
115 return -1;
116# endif
117
118# if FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE /* Solaris */
119 /* The Solaris stdio leaves the _IOREAD flag set after reading from a file
120 reaches EOF and the program then starts writing to the file. ftello
121 gets confused by this. */
122 if (fp_->_flag & _IOWRT)
123 {
124 off_t pos;
125
126 /* Call ftello nevertheless, for the side effects that it does on fp. */
127 ftello (fp);
128
129 /* Compute the file position ourselves. */
130 pos = lseek (fileno (fp), (off_t) 0, SEEK_CUR);
131 if (pos >= 0)
132 {
133 if ((fp_->_flag & _IONBF) == 0 && fp_->_base != NULL)
134 pos += fp_->_ptr - fp_->_base;
135 }
136 return pos;
137 }
138# endif
139
140# if defined __SL64 && defined __SCLE /* Cygwin */
141 if ((fp->_flags & __SL64) == 0)
142 {
143 /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit
144 mode; but has an ftello that requires 64-bit mode. */
145 FILE *tmp = fopen ("/dev/null", "r");
146 if (!tmp)
147 return -1;
148 fp->_flags |= __SL64;
149 fp->_seek64 = tmp->_seek64;
150 fclose (tmp);
151 }
152# endif
153
154 return ftello (fp);
155
156#endif
157}
diff --git a/gl/gl_openssl.h b/gl/gl_openssl.h
deleted file mode 100644
index 4c42ac8..0000000
--- a/gl/gl_openssl.h
+++ /dev/null
@@ -1,116 +0,0 @@
1/* Wrap openssl crypto hash routines in gnulib interface. -*- coding: utf-8 -*-
2
3 Copyright (C) 2013-2022 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Pádraig Brady */
19
20#ifndef GL_OPENSSL_NAME
21# error "Please define GL_OPENSSL_NAME to 1,5,256 etc."
22#endif
23
24#ifndef _GL_INLINE_HEADER_BEGIN
25# error "Please include config.h first."
26#endif
27_GL_INLINE_HEADER_BEGIN
28#ifndef GL_OPENSSL_INLINE
29# define GL_OPENSSL_INLINE _GL_INLINE
30#endif
31
32/* Concatenate two preprocessor tokens. */
33#define _GLCRYPTO_CONCAT_(prefix, suffix) prefix##suffix
34#define _GLCRYPTO_CONCAT(prefix, suffix) _GLCRYPTO_CONCAT_ (prefix, suffix)
35
36#if GL_OPENSSL_NAME == 5
37# define OPENSSL_ALG md5
38#else
39# define OPENSSL_ALG _GLCRYPTO_CONCAT (sha, GL_OPENSSL_NAME)
40#endif
41
42/* Context type mappings. */
43#if BASE_OPENSSL_TYPE != GL_OPENSSL_NAME
44# undef BASE_OPENSSL_TYPE
45# if GL_OPENSSL_NAME == 224
46# define BASE_OPENSSL_TYPE 256
47# elif GL_OPENSSL_NAME == 384
48# define BASE_OPENSSL_TYPE 512
49# endif
50# define md5_CTX MD5_CTX
51# define sha1_CTX SHA_CTX
52# define sha224_CTX SHA256_CTX
53# define sha224_ctx sha256_ctx
54# define sha256_CTX SHA256_CTX
55# define sha384_CTX SHA512_CTX
56# define sha384_ctx sha512_ctx
57# define sha512_CTX SHA512_CTX
58# undef _gl_CTX
59# undef _gl_ctx
60# define _gl_CTX _GLCRYPTO_CONCAT (OPENSSL_ALG, _CTX) /* openssl type. */
61# define _gl_ctx _GLCRYPTO_CONCAT (OPENSSL_ALG, _ctx) /* gnulib type. */
62
63struct _gl_ctx { _gl_CTX CTX; };
64#endif
65
66/* Function name mappings. */
67#define md5_prefix MD5
68#define sha1_prefix SHA1
69#define sha224_prefix SHA224
70#define sha256_prefix SHA256
71#define sha384_prefix SHA384
72#define sha512_prefix SHA512
73#define _GLCRYPTO_PREFIX _GLCRYPTO_CONCAT (OPENSSL_ALG, _prefix)
74#define OPENSSL_FN(suffix) _GLCRYPTO_CONCAT (_GLCRYPTO_PREFIX, suffix)
75#define GL_CRYPTO_FN(suffix) _GLCRYPTO_CONCAT (OPENSSL_ALG, suffix)
76
77GL_OPENSSL_INLINE void
78GL_CRYPTO_FN (_init_ctx) (struct _gl_ctx *ctx)
79{ (void) OPENSSL_FN (_Init) ((_gl_CTX *) ctx); }
80
81/* These were never exposed by gnulib. */
82#if ! (GL_OPENSSL_NAME == 224 || GL_OPENSSL_NAME == 384)
83GL_OPENSSL_INLINE void
84GL_CRYPTO_FN (_process_bytes) (const void *buf, size_t len, struct _gl_ctx *ctx)
85{ OPENSSL_FN (_Update) ((_gl_CTX *) ctx, buf, len); }
86
87GL_OPENSSL_INLINE void
88GL_CRYPTO_FN (_process_block) (const void *buf, size_t len, struct _gl_ctx *ctx)
89{ GL_CRYPTO_FN (_process_bytes) (buf, len, ctx); }
90#endif
91
92GL_OPENSSL_INLINE void *
93GL_CRYPTO_FN (_finish_ctx) (struct _gl_ctx *ctx, void *restrict res)
94{ OPENSSL_FN (_Final) ((unsigned char *) res, (_gl_CTX *) ctx); return res; }
95
96GL_OPENSSL_INLINE void *
97GL_CRYPTO_FN (_buffer) (const char *buf, size_t len, void *restrict res)
98{ return OPENSSL_FN () ((const unsigned char *) buf, len, (unsigned char *) res); }
99
100GL_OPENSSL_INLINE void *
101GL_CRYPTO_FN (_read_ctx) (const struct _gl_ctx *ctx, void *restrict res)
102{
103 /* Assume any unprocessed bytes in ctx are not to be ignored. */
104 _gl_CTX tmp_ctx = *(_gl_CTX *) ctx;
105 OPENSSL_FN (_Final) ((unsigned char *) res, &tmp_ctx);
106 return res;
107}
108
109/* Undef so we can include multiple times. */
110#undef GL_CRYPTO_FN
111#undef OPENSSL_FN
112#undef _GLCRYPTO_PREFIX
113#undef OPENSSL_ALG
114#undef GL_OPENSSL_NAME
115
116_GL_INLINE_HEADER_END
diff --git a/gl/inttypes.h b/gl/inttypes.h
new file mode 100644
index 0000000..445a599
--- /dev/null
+++ b/gl/inttypes.h
@@ -0,0 +1,1509 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* Copyright (C) 2006-2022 Free Software Foundation, Inc.
3 Written by Paul Eggert, Bruno Haible, Derek Price.
4 This file is part of gnulib.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19/*
20 * ISO C 99 <inttypes.h> for platforms that lack it.
21 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/inttypes.h.html>
22 */
23
24#if __GNUC__ >= 3
25#pragma GCC system_header
26#endif
27
28
29/* Include the original <inttypes.h> if it exists, and if this file
30 has not been included yet or if this file includes gnulib stdint.h
31 which in turn includes this file.
32 The include_next requires a split double-inclusion guard. */
33#if ! defined INTTYPES_H || defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
34# if 1
35
36 /* Some pre-C++11 <stdint.h> implementations need this. */
37# if defined __cplusplus && ! defined __STDC_FORMAT_MACROS
38# define __STDC_FORMAT_MACROS 1
39# endif
40
41# include_next <inttypes.h>
42
43# define _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H
44# endif
45#endif
46
47#if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
48#define INTTYPES_H
49
50/* Include <stdint.h> or the gnulib replacement.
51 But avoid namespace pollution on glibc systems. */
52#ifndef __GLIBC__
53# include <stdint.h>
54#endif
55/* Get CHAR_BIT, INT_MAX, LONG_MAX, etc. */
56#include <limits.h>
57/* On mingw, __USE_MINGW_ANSI_STDIO only works if <stdio.h> is also included */
58#if defined _WIN32 && ! defined __CYGWIN__
59# include <stdio.h>
60#endif
61
62#if !(INT_MAX == 0x7fffffff && INT_MIN + INT_MAX == -1)
63# error "This file assumes that 'int' is 32-bit two's complement. Please report your platform and compiler to <bug-gnulib@gnu.org>."
64#endif
65
66/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
67/* C++ compatible function declaration macros.
68 Copyright (C) 2010-2022 Free Software Foundation, Inc.
69
70 This program is free software: you can redistribute it and/or modify it
71 under the terms of the GNU Lesser General Public License as published
72 by the Free Software Foundation; either version 2 of the License, or
73 (at your option) any later version.
74
75 This program is distributed in the hope that it will be useful,
76 but WITHOUT ANY WARRANTY; without even the implied warranty of
77 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
78 Lesser General Public License for more details.
79
80 You should have received a copy of the GNU Lesser General Public License
81 along with this program. If not, see <https://www.gnu.org/licenses/>. */
82
83#ifndef _GL_CXXDEFS_H
84#define _GL_CXXDEFS_H
85
86/* Begin/end the GNULIB_NAMESPACE namespace. */
87#if defined __cplusplus && defined GNULIB_NAMESPACE
88# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
89# define _GL_END_NAMESPACE }
90#else
91# define _GL_BEGIN_NAMESPACE
92# define _GL_END_NAMESPACE
93#endif
94
95/* The three most frequent use cases of these macros are:
96
97 * For providing a substitute for a function that is missing on some
98 platforms, but is declared and works fine on the platforms on which
99 it exists:
100
101 #if @GNULIB_FOO@
102 # if !@HAVE_FOO@
103 _GL_FUNCDECL_SYS (foo, ...);
104 # endif
105 _GL_CXXALIAS_SYS (foo, ...);
106 _GL_CXXALIASWARN (foo);
107 #elif defined GNULIB_POSIXCHECK
108 ...
109 #endif
110
111 * For providing a replacement for a function that exists on all platforms,
112 but is broken/insufficient and needs to be replaced on some platforms:
113
114 #if @GNULIB_FOO@
115 # if @REPLACE_FOO@
116 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
117 # undef foo
118 # define foo rpl_foo
119 # endif
120 _GL_FUNCDECL_RPL (foo, ...);
121 _GL_CXXALIAS_RPL (foo, ...);
122 # else
123 _GL_CXXALIAS_SYS (foo, ...);
124 # endif
125 _GL_CXXALIASWARN (foo);
126 #elif defined GNULIB_POSIXCHECK
127 ...
128 #endif
129
130 * For providing a replacement for a function that exists on some platforms
131 but is broken/insufficient and needs to be replaced on some of them and
132 is additionally either missing or undeclared on some other platforms:
133
134 #if @GNULIB_FOO@
135 # if @REPLACE_FOO@
136 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
137 # undef foo
138 # define foo rpl_foo
139 # endif
140 _GL_FUNCDECL_RPL (foo, ...);
141 _GL_CXXALIAS_RPL (foo, ...);
142 # else
143 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
144 _GL_FUNCDECL_SYS (foo, ...);
145 # endif
146 _GL_CXXALIAS_SYS (foo, ...);
147 # endif
148 _GL_CXXALIASWARN (foo);
149 #elif defined GNULIB_POSIXCHECK
150 ...
151 #endif
152*/
153
154/* _GL_EXTERN_C declaration;
155 performs the declaration with C linkage. */
156#if defined __cplusplus
157# define _GL_EXTERN_C extern "C"
158#else
159# define _GL_EXTERN_C extern
160#endif
161
162/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
163 declares a replacement function, named rpl_func, with the given prototype,
164 consisting of return type, parameters, and attributes.
165 Example:
166 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
167 _GL_ARG_NONNULL ((1)));
168 */
169#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
170 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
171#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
172 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
173
174/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
175 declares the system function, named func, with the given prototype,
176 consisting of return type, parameters, and attributes.
177 Example:
178 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
179 _GL_ARG_NONNULL ((1)));
180 */
181#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
182 _GL_EXTERN_C rettype func parameters_and_attributes
183
184/* _GL_CXXALIAS_RPL (func, rettype, parameters);
185 declares a C++ alias called GNULIB_NAMESPACE::func
186 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
187 Example:
188 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
189
190 Wrapping rpl_func in an object with an inline conversion operator
191 avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
192 actually used in the program. */
193#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
194 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
195#if defined __cplusplus && defined GNULIB_NAMESPACE
196# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
197 namespace GNULIB_NAMESPACE \
198 { \
199 static const struct _gl_ ## func ## _wrapper \
200 { \
201 typedef rettype (*type) parameters; \
202 \
203 inline operator type () const \
204 { \
205 return ::rpl_func; \
206 } \
207 } func = {}; \
208 } \
209 _GL_EXTERN_C int _gl_cxxalias_dummy
210#else
211# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
212 _GL_EXTERN_C int _gl_cxxalias_dummy
213#endif
214
215/* _GL_CXXALIAS_MDA (func, rettype, parameters);
216 is to be used when func is a Microsoft deprecated alias, on native Windows.
217 It declares a C++ alias called GNULIB_NAMESPACE::func
218 that redirects to _func, if GNULIB_NAMESPACE is defined.
219 Example:
220 _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
221 */
222#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
223 _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
224
225/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
226 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
227 except that the C function rpl_func may have a slightly different
228 declaration. A cast is used to silence the "invalid conversion" error
229 that would otherwise occur. */
230#if defined __cplusplus && defined GNULIB_NAMESPACE
231# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
232 namespace GNULIB_NAMESPACE \
233 { \
234 static const struct _gl_ ## func ## _wrapper \
235 { \
236 typedef rettype (*type) parameters; \
237 \
238 inline operator type () const \
239 { \
240 return reinterpret_cast<type>(::rpl_func); \
241 } \
242 } func = {}; \
243 } \
244 _GL_EXTERN_C int _gl_cxxalias_dummy
245#else
246# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
247 _GL_EXTERN_C int _gl_cxxalias_dummy
248#endif
249
250/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
251 is like _GL_CXXALIAS_MDA (func, rettype, parameters);
252 except that the C function func may have a slightly different declaration.
253 A cast is used to silence the "invalid conversion" error that would
254 otherwise occur. */
255#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
256 _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
257
258/* _GL_CXXALIAS_SYS (func, rettype, parameters);
259 declares a C++ alias called GNULIB_NAMESPACE::func
260 that redirects to the system provided function func, if GNULIB_NAMESPACE
261 is defined.
262 Example:
263 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
264
265 Wrapping func in an object with an inline conversion operator
266 avoids a reference to func unless GNULIB_NAMESPACE::func is
267 actually used in the program. */
268#if defined __cplusplus && defined GNULIB_NAMESPACE
269# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
270 namespace GNULIB_NAMESPACE \
271 { \
272 static const struct _gl_ ## func ## _wrapper \
273 { \
274 typedef rettype (*type) parameters; \
275 \
276 inline operator type () const \
277 { \
278 return ::func; \
279 } \
280 } func = {}; \
281 } \
282 _GL_EXTERN_C int _gl_cxxalias_dummy
283#else
284# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
285 _GL_EXTERN_C int _gl_cxxalias_dummy
286#endif
287
288/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
289 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
290 except that the C function func may have a slightly different declaration.
291 A cast is used to silence the "invalid conversion" error that would
292 otherwise occur. */
293#if defined __cplusplus && defined GNULIB_NAMESPACE
294# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
295 namespace GNULIB_NAMESPACE \
296 { \
297 static const struct _gl_ ## func ## _wrapper \
298 { \
299 typedef rettype (*type) parameters; \
300 \
301 inline operator type () const \
302 { \
303 return reinterpret_cast<type>(::func); \
304 } \
305 } func = {}; \
306 } \
307 _GL_EXTERN_C int _gl_cxxalias_dummy
308#else
309# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
310 _GL_EXTERN_C int _gl_cxxalias_dummy
311#endif
312
313/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
314 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
315 except that the C function is picked among a set of overloaded functions,
316 namely the one with rettype2 and parameters2. Two consecutive casts
317 are used to silence the "cannot find a match" and "invalid conversion"
318 errors that would otherwise occur. */
319#if defined __cplusplus && defined GNULIB_NAMESPACE
320 /* The outer cast must be a reinterpret_cast.
321 The inner cast: When the function is defined as a set of overloaded
322 functions, it works as a static_cast<>, choosing the designated variant.
323 When the function is defined as a single variant, it works as a
324 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
325# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
326 namespace GNULIB_NAMESPACE \
327 { \
328 static const struct _gl_ ## func ## _wrapper \
329 { \
330 typedef rettype (*type) parameters; \
331 \
332 inline operator type () const \
333 { \
334 return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
335 } \
336 } func = {}; \
337 } \
338 _GL_EXTERN_C int _gl_cxxalias_dummy
339#else
340# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
341 _GL_EXTERN_C int _gl_cxxalias_dummy
342#endif
343
344/* _GL_CXXALIASWARN (func);
345 causes a warning to be emitted when ::func is used but not when
346 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
347 variants. */
348#if defined __cplusplus && defined GNULIB_NAMESPACE
349# define _GL_CXXALIASWARN(func) \
350 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
351# define _GL_CXXALIASWARN_1(func,namespace) \
352 _GL_CXXALIASWARN_2 (func, namespace)
353/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
354 we enable the warning only when not optimizing. */
355# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
356# define _GL_CXXALIASWARN_2(func,namespace) \
357 _GL_WARN_ON_USE (func, \
358 "The symbol ::" #func " refers to the system function. " \
359 "Use " #namespace "::" #func " instead.")
360# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
361# define _GL_CXXALIASWARN_2(func,namespace) \
362 extern __typeof__ (func) func
363# else
364# define _GL_CXXALIASWARN_2(func,namespace) \
365 _GL_EXTERN_C int _gl_cxxalias_dummy
366# endif
367#else
368# define _GL_CXXALIASWARN(func) \
369 _GL_EXTERN_C int _gl_cxxalias_dummy
370#endif
371
372/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
373 causes a warning to be emitted when the given overloaded variant of ::func
374 is used but not when GNULIB_NAMESPACE::func is used. */
375#if defined __cplusplus && defined GNULIB_NAMESPACE
376# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
377 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
378 GNULIB_NAMESPACE)
379# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
380 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
381/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
382 we enable the warning only when not optimizing. */
383# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
384# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
385 _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
386 "The symbol ::" #func " refers to the system function. " \
387 "Use " #namespace "::" #func " instead.")
388# else
389# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
390 _GL_EXTERN_C int _gl_cxxalias_dummy
391# endif
392#else
393# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
394 _GL_EXTERN_C int _gl_cxxalias_dummy
395#endif
396
397#endif /* _GL_CXXDEFS_H */
398
399/* The definition of _GL_ARG_NONNULL is copied here. */
400/* A C macro for declaring that specific arguments must not be NULL.
401 Copyright (C) 2009-2022 Free Software Foundation, Inc.
402
403 This program is free software: you can redistribute it and/or modify it
404 under the terms of the GNU Lesser General Public License as published
405 by the Free Software Foundation; either version 2 of the License, or
406 (at your option) any later version.
407
408 This program is distributed in the hope that it will be useful,
409 but WITHOUT ANY WARRANTY; without even the implied warranty of
410 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
411 Lesser General Public License for more details.
412
413 You should have received a copy of the GNU Lesser General Public License
414 along with this program. If not, see <https://www.gnu.org/licenses/>. */
415
416/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
417 that the values passed as arguments n, ..., m must be non-NULL pointers.
418 n = 1 stands for the first argument, n = 2 for the second argument etc. */
419#ifndef _GL_ARG_NONNULL
420# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
421# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
422# else
423# define _GL_ARG_NONNULL(params)
424# endif
425#endif
426
427/* The definition of _GL_WARN_ON_USE is copied here. */
428/* A C macro for emitting warnings if a function is used.
429 Copyright (C) 2010-2022 Free Software Foundation, Inc.
430
431 This program is free software: you can redistribute it and/or modify it
432 under the terms of the GNU Lesser General Public License as published
433 by the Free Software Foundation; either version 2 of the License, or
434 (at your option) any later version.
435
436 This program is distributed in the hope that it will be useful,
437 but WITHOUT ANY WARRANTY; without even the implied warranty of
438 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
439 Lesser General Public License for more details.
440
441 You should have received a copy of the GNU Lesser General Public License
442 along with this program. If not, see <https://www.gnu.org/licenses/>. */
443
444/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
445 for FUNCTION which will then trigger a compiler warning containing
446 the text of "literal string" anywhere that function is called, if
447 supported by the compiler. If the compiler does not support this
448 feature, the macro expands to an unused extern declaration.
449
450 _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
451 attribute used in _GL_WARN_ON_USE. If the compiler does not support
452 this feature, it expands to empty.
453
454 These macros are useful for marking a function as a potential
455 portability trap, with the intent that "literal string" include
456 instructions on the replacement function that should be used
457 instead.
458 _GL_WARN_ON_USE is for functions with 'extern' linkage.
459 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
460 linkage.
461
462 However, one of the reasons that a function is a portability trap is
463 if it has the wrong signature. Declaring FUNCTION with a different
464 signature in C is a compilation error, so this macro must use the
465 same type as any existing declaration so that programs that avoid
466 the problematic FUNCTION do not fail to compile merely because they
467 included a header that poisoned the function. But this implies that
468 _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
469 have a declaration. Use of this macro implies that there must not
470 be any other macro hiding the declaration of FUNCTION; but
471 undefining FUNCTION first is part of the poisoning process anyway
472 (although for symbols that are provided only via a macro, the result
473 is a compilation error rather than a warning containing
474 "literal string"). Also note that in C++, it is only safe to use if
475 FUNCTION has no overloads.
476
477 For an example, it is possible to poison 'getline' by:
478 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
479 [getline]) in configure.ac, which potentially defines
480 HAVE_RAW_DECL_GETLINE
481 - adding this code to a header that wraps the system <stdio.h>:
482 #undef getline
483 #if HAVE_RAW_DECL_GETLINE
484 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
485 "not universally present; use the gnulib module getline");
486 #endif
487
488 It is not possible to directly poison global variables. But it is
489 possible to write a wrapper accessor function, and poison that
490 (less common usage, like &environ, will cause a compilation error
491 rather than issue the nice warning, but the end result of informing
492 the developer about their portability problem is still achieved):
493 #if HAVE_RAW_DECL_ENVIRON
494 static char ***
495 rpl_environ (void) { return &environ; }
496 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
497 # undef environ
498 # define environ (*rpl_environ ())
499 #endif
500 or better (avoiding contradictory use of 'static' and 'extern'):
501 #if HAVE_RAW_DECL_ENVIRON
502 static char ***
503 _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
504 rpl_environ (void) { return &environ; }
505 # undef environ
506 # define environ (*rpl_environ ())
507 #endif
508 */
509#ifndef _GL_WARN_ON_USE
510
511# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
512/* A compiler attribute is available in gcc versions 4.3.0 and later. */
513# define _GL_WARN_ON_USE(function, message) \
514_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
515# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
516 __attribute__ ((__warning__ (message)))
517# elif __clang_major__ >= 4
518/* Another compiler attribute is available in clang. */
519# define _GL_WARN_ON_USE(function, message) \
520_GL_WARN_EXTERN_C __typeof__ (function) function \
521 __attribute__ ((__diagnose_if__ (1, message, "warning")))
522# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
523 __attribute__ ((__diagnose_if__ (1, message, "warning")))
524# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
525/* Verify the existence of the function. */
526# define _GL_WARN_ON_USE(function, message) \
527_GL_WARN_EXTERN_C __typeof__ (function) function
528# define _GL_WARN_ON_USE_ATTRIBUTE(message)
529# else /* Unsupported. */
530# define _GL_WARN_ON_USE(function, message) \
531_GL_WARN_EXTERN_C int _gl_warn_on_use
532# define _GL_WARN_ON_USE_ATTRIBUTE(message)
533# endif
534#endif
535
536/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
537 is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
538 function is declared with the given prototype, consisting of return type,
539 parameters, and attributes.
540 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
541 not work in this case. */
542#ifndef _GL_WARN_ON_USE_CXX
543# if !defined __cplusplus
544# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
545 _GL_WARN_ON_USE (function, msg)
546# else
547# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
548/* A compiler attribute is available in gcc versions 4.3.0 and later. */
549# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
550extern rettype_gcc function parameters_and_attributes \
551 __attribute__ ((__warning__ (msg)))
552# elif __clang_major__ >= 4
553/* Another compiler attribute is available in clang. */
554# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
555extern rettype_clang function parameters_and_attributes \
556 __attribute__ ((__diagnose_if__ (1, msg, "warning")))
557# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
558/* Verify the existence of the function. */
559# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
560extern rettype_gcc function parameters_and_attributes
561# else /* Unsupported. */
562# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
563_GL_WARN_EXTERN_C int _gl_warn_on_use
564# endif
565# endif
566#endif
567
568/* _GL_WARN_EXTERN_C declaration;
569 performs the declaration with C linkage. */
570#ifndef _GL_WARN_EXTERN_C
571# if defined __cplusplus
572# define _GL_WARN_EXTERN_C extern "C"
573# else
574# define _GL_WARN_EXTERN_C extern
575# endif
576#endif
577
578/* 7.8.1 Macros for format specifiers */
579
580#if defined _TNS_R_TARGET
581 /* Tandem NonStop R series and compatible platforms released before
582 July 2005 support %Ld but not %lld. */
583# define _LONG_LONG_FORMAT_PREFIX "L"
584#else
585# define _LONG_LONG_FORMAT_PREFIX "ll"
586#endif
587
588#if !defined PRId8
589# ifdef INT8_MAX
590# define PRId8 "d"
591# endif
592#endif
593#if !defined PRIi8
594# ifdef INT8_MAX
595# define PRIi8 "i"
596# endif
597#endif
598#if !defined PRIo8
599# ifdef UINT8_MAX
600# define PRIo8 "o"
601# endif
602#endif
603#if !defined PRIu8
604# ifdef UINT8_MAX
605# define PRIu8 "u"
606# endif
607#endif
608#if !defined PRIx8
609# ifdef UINT8_MAX
610# define PRIx8 "x"
611# endif
612#endif
613#if !defined PRIX8
614# ifdef UINT8_MAX
615# define PRIX8 "X"
616# endif
617#endif
618#if !defined PRId16
619# ifdef INT16_MAX
620# define PRId16 "d"
621# endif
622#endif
623#if !defined PRIi16
624# ifdef INT16_MAX
625# define PRIi16 "i"
626# endif
627#endif
628#if !defined PRIo16
629# ifdef UINT16_MAX
630# define PRIo16 "o"
631# endif
632#endif
633#if !defined PRIu16
634# ifdef UINT16_MAX
635# define PRIu16 "u"
636# endif
637#endif
638#if !defined PRIx16
639# ifdef UINT16_MAX
640# define PRIx16 "x"
641# endif
642#endif
643#if !defined PRIX16
644# ifdef UINT16_MAX
645# define PRIX16 "X"
646# endif
647#endif
648#if !defined PRId32
649# ifdef INT32_MAX
650# define PRId32 "d"
651# endif
652#endif
653#if !defined PRIi32
654# ifdef INT32_MAX
655# define PRIi32 "i"
656# endif
657#endif
658#if !defined PRIo32
659# ifdef UINT32_MAX
660# define PRIo32 "o"
661# endif
662#endif
663#if !defined PRIu32
664# ifdef UINT32_MAX
665# define PRIu32 "u"
666# endif
667#endif
668#if !defined PRIx32
669# ifdef UINT32_MAX
670# define PRIx32 "x"
671# endif
672#endif
673#if !defined PRIX32
674# ifdef UINT32_MAX
675# define PRIX32 "X"
676# endif
677#endif
678#ifdef INT64_MAX
679# if (0 ? defined _LP64 : defined _LP64)
680# define _PRI64_PREFIX "l"
681# elif defined _MSC_VER || defined __MINGW32__
682# define _PRI64_PREFIX "I64"
683# elif LONG_MAX >> 30 == 1
684# define _PRI64_PREFIX _LONG_LONG_FORMAT_PREFIX
685# endif
686# if !defined PRId64
687# define PRId64 _PRI64_PREFIX "d"
688# endif
689# if !defined PRIi64
690# define PRIi64 _PRI64_PREFIX "i"
691# endif
692#endif
693#ifdef UINT64_MAX
694# if (0 ? defined _LP64 : defined _LP64)
695# define _PRIu64_PREFIX "l"
696# elif defined _MSC_VER || defined __MINGW32__
697# define _PRIu64_PREFIX "I64"
698# elif ULONG_MAX >> 31 == 1
699# define _PRIu64_PREFIX _LONG_LONG_FORMAT_PREFIX
700# endif
701# if !defined PRIo64
702# define PRIo64 _PRIu64_PREFIX "o"
703# endif
704# if !defined PRIu64
705# define PRIu64 _PRIu64_PREFIX "u"
706# endif
707# if !defined PRIx64
708# define PRIx64 _PRIu64_PREFIX "x"
709# endif
710# if !defined PRIX64
711# define PRIX64 _PRIu64_PREFIX "X"
712# endif
713#endif
714
715#if !defined PRIdLEAST8
716# define PRIdLEAST8 "d"
717#endif
718#if !defined PRIiLEAST8
719# define PRIiLEAST8 "i"
720#endif
721#if !defined PRIoLEAST8
722# define PRIoLEAST8 "o"
723#endif
724#if !defined PRIuLEAST8
725# define PRIuLEAST8 "u"
726#endif
727#if !defined PRIxLEAST8
728# define PRIxLEAST8 "x"
729#endif
730#if !defined PRIXLEAST8
731# define PRIXLEAST8 "X"
732#endif
733#if !defined PRIdLEAST16
734# define PRIdLEAST16 "d"
735#endif
736#if !defined PRIiLEAST16
737# define PRIiLEAST16 "i"
738#endif
739#if !defined PRIoLEAST16
740# define PRIoLEAST16 "o"
741#endif
742#if !defined PRIuLEAST16
743# define PRIuLEAST16 "u"
744#endif
745#if !defined PRIxLEAST16
746# define PRIxLEAST16 "x"
747#endif
748#if !defined PRIXLEAST16
749# define PRIXLEAST16 "X"
750#endif
751#if !defined PRIdLEAST32
752# define PRIdLEAST32 "d"
753#endif
754#if !defined PRIiLEAST32
755# define PRIiLEAST32 "i"
756#endif
757#if !defined PRIoLEAST32
758# define PRIoLEAST32 "o"
759#endif
760#if !defined PRIuLEAST32
761# define PRIuLEAST32 "u"
762#endif
763#if !defined PRIxLEAST32
764# define PRIxLEAST32 "x"
765#endif
766#if !defined PRIXLEAST32
767# define PRIXLEAST32 "X"
768#endif
769#ifdef INT64_MAX
770# if !defined PRIdLEAST64
771# define PRIdLEAST64 PRId64
772# endif
773# if !defined PRIiLEAST64
774# define PRIiLEAST64 PRIi64
775# endif
776#endif
777#ifdef UINT64_MAX
778# if !defined PRIoLEAST64
779# define PRIoLEAST64 PRIo64
780# endif
781# if !defined PRIuLEAST64
782# define PRIuLEAST64 PRIu64
783# endif
784# if !defined PRIxLEAST64
785# define PRIxLEAST64 PRIx64
786# endif
787# if !defined PRIXLEAST64
788# define PRIXLEAST64 PRIX64
789# endif
790#endif
791
792#if !defined PRIdFAST8
793# if INT_FAST8_MAX > INT32_MAX
794# define PRIdFAST8 PRId64
795# else
796# define PRIdFAST8 "d"
797# endif
798#endif
799#if !defined PRIiFAST8
800# if INT_FAST8_MAX > INT32_MAX
801# define PRIiFAST8 PRIi64
802# else
803# define PRIiFAST8 "i"
804# endif
805#endif
806#if !defined PRIoFAST8
807# if UINT_FAST8_MAX > UINT32_MAX
808# define PRIoFAST8 PRIo64
809# else
810# define PRIoFAST8 "o"
811# endif
812#endif
813#if !defined PRIuFAST8
814# if UINT_FAST8_MAX > UINT32_MAX
815# define PRIuFAST8 PRIu64
816# else
817# define PRIuFAST8 "u"
818# endif
819#endif
820#if !defined PRIxFAST8
821# if UINT_FAST8_MAX > UINT32_MAX
822# define PRIxFAST8 PRIx64
823# else
824# define PRIxFAST8 "x"
825# endif
826#endif
827#if !defined PRIXFAST8
828# if UINT_FAST8_MAX > UINT32_MAX
829# define PRIXFAST8 PRIX64
830# else
831# define PRIXFAST8 "X"
832# endif
833#endif
834#if !defined PRIdFAST16
835# if INT_FAST16_MAX > INT32_MAX
836# define PRIdFAST16 PRId64
837# else
838# define PRIdFAST16 "d"
839# endif
840#endif
841#if !defined PRIiFAST16
842# if INT_FAST16_MAX > INT32_MAX
843# define PRIiFAST16 PRIi64
844# else
845# define PRIiFAST16 "i"
846# endif
847#endif
848#if !defined PRIoFAST16
849# if UINT_FAST16_MAX > UINT32_MAX
850# define PRIoFAST16 PRIo64
851# else
852# define PRIoFAST16 "o"
853# endif
854#endif
855#if !defined PRIuFAST16
856# if UINT_FAST16_MAX > UINT32_MAX
857# define PRIuFAST16 PRIu64
858# else
859# define PRIuFAST16 "u"
860# endif
861#endif
862#if !defined PRIxFAST16
863# if UINT_FAST16_MAX > UINT32_MAX
864# define PRIxFAST16 PRIx64
865# else
866# define PRIxFAST16 "x"
867# endif
868#endif
869#if !defined PRIXFAST16
870# if UINT_FAST16_MAX > UINT32_MAX
871# define PRIXFAST16 PRIX64
872# else
873# define PRIXFAST16 "X"
874# endif
875#endif
876#if !defined PRIdFAST32
877# if INT_FAST32_MAX > INT32_MAX
878# define PRIdFAST32 PRId64
879# else
880# define PRIdFAST32 "d"
881# endif
882#endif
883#if !defined PRIiFAST32
884# if INT_FAST32_MAX > INT32_MAX
885# define PRIiFAST32 PRIi64
886# else
887# define PRIiFAST32 "i"
888# endif
889#endif
890#if !defined PRIoFAST32
891# if UINT_FAST32_MAX > UINT32_MAX
892# define PRIoFAST32 PRIo64
893# else
894# define PRIoFAST32 "o"
895# endif
896#endif
897#if !defined PRIuFAST32
898# if UINT_FAST32_MAX > UINT32_MAX
899# define PRIuFAST32 PRIu64
900# else
901# define PRIuFAST32 "u"
902# endif
903#endif
904#if !defined PRIxFAST32
905# if UINT_FAST32_MAX > UINT32_MAX
906# define PRIxFAST32 PRIx64
907# else
908# define PRIxFAST32 "x"
909# endif
910#endif
911#if !defined PRIXFAST32
912# if UINT_FAST32_MAX > UINT32_MAX
913# define PRIXFAST32 PRIX64
914# else
915# define PRIXFAST32 "X"
916# endif
917#endif
918#ifdef INT64_MAX
919# if !defined PRIdFAST64
920# define PRIdFAST64 PRId64
921# endif
922# if !defined PRIiFAST64
923# define PRIiFAST64 PRIi64
924# endif
925#endif
926#ifdef UINT64_MAX
927# if !defined PRIoFAST64
928# define PRIoFAST64 PRIo64
929# endif
930# if !defined PRIuFAST64
931# define PRIuFAST64 PRIu64
932# endif
933# if !defined PRIxFAST64
934# define PRIxFAST64 PRIx64
935# endif
936# if !defined PRIXFAST64
937# define PRIXFAST64 PRIX64
938# endif
939#endif
940
941#if !defined PRIdMAX
942# if 1
943# define PRIdMAX PRId64
944# else
945# define PRIdMAX "ld"
946# endif
947#endif
948#if !defined PRIiMAX
949# if 1
950# define PRIiMAX PRIi64
951# else
952# define PRIiMAX "li"
953# endif
954#endif
955#if !defined PRIoMAX
956# if 1
957# define PRIoMAX PRIo64
958# else
959# define PRIoMAX "lo"
960# endif
961#endif
962#if !defined PRIuMAX
963# if 1
964# define PRIuMAX PRIu64
965# else
966# define PRIuMAX "lu"
967# endif
968#endif
969#if !defined PRIxMAX
970# if 1
971# define PRIxMAX PRIx64
972# else
973# define PRIxMAX "lx"
974# endif
975#endif
976#if !defined PRIXMAX
977# if 1
978# define PRIXMAX PRIX64
979# else
980# define PRIXMAX "lX"
981# endif
982#endif
983
984#if !defined PRIdPTR
985# ifdef INTPTR_MAX
986# define PRIdPTR __PRIPTR_PREFIX "d"
987# endif
988#endif
989#if !defined PRIiPTR
990# ifdef INTPTR_MAX
991# define PRIiPTR __PRIPTR_PREFIX "i"
992# endif
993#endif
994#if !defined PRIoPTR
995# ifdef UINTPTR_MAX
996# define PRIoPTR __PRIPTR_PREFIX "o"
997# endif
998#endif
999#if !defined PRIuPTR
1000# ifdef UINTPTR_MAX
1001# define PRIuPTR __PRIPTR_PREFIX "u"
1002# endif
1003#endif
1004#if !defined PRIxPTR
1005# ifdef UINTPTR_MAX
1006# define PRIxPTR __PRIPTR_PREFIX "x"
1007# endif
1008#endif
1009#if !defined PRIXPTR
1010# ifdef UINTPTR_MAX
1011# define PRIXPTR __PRIPTR_PREFIX "X"
1012# endif
1013#endif
1014
1015#if !defined SCNd8
1016# ifdef INT8_MAX
1017# define SCNd8 "hhd"
1018# endif
1019#endif
1020#if !defined SCNi8
1021# ifdef INT8_MAX
1022# define SCNi8 "hhi"
1023# endif
1024#endif
1025#if !defined SCNo8
1026# ifdef UINT8_MAX
1027# define SCNo8 "hho"
1028# endif
1029#endif
1030#if !defined SCNu8
1031# ifdef UINT8_MAX
1032# define SCNu8 "hhu"
1033# endif
1034#endif
1035#if !defined SCNx8
1036# ifdef UINT8_MAX
1037# define SCNx8 "hhx"
1038# endif
1039#endif
1040#if !defined SCNd16
1041# ifdef INT16_MAX
1042# define SCNd16 "hd"
1043# endif
1044#endif
1045#if !defined SCNi16
1046# ifdef INT16_MAX
1047# define SCNi16 "hi"
1048# endif
1049#endif
1050#if !defined SCNo16
1051# ifdef UINT16_MAX
1052# define SCNo16 "ho"
1053# endif
1054#endif
1055#if !defined SCNu16
1056# ifdef UINT16_MAX
1057# define SCNu16 "hu"
1058# endif
1059#endif
1060#if !defined SCNx16
1061# ifdef UINT16_MAX
1062# define SCNx16 "hx"
1063# endif
1064#endif
1065#if !defined SCNd32
1066# ifdef INT32_MAX
1067# define SCNd32 "d"
1068# endif
1069#endif
1070#if !defined SCNi32
1071# ifdef INT32_MAX
1072# define SCNi32 "i"
1073# endif
1074#endif
1075#if !defined SCNo32
1076# ifdef UINT32_MAX
1077# define SCNo32 "o"
1078# endif
1079#endif
1080#if !defined SCNu32
1081# ifdef UINT32_MAX
1082# define SCNu32 "u"
1083# endif
1084#endif
1085#if !defined SCNx32
1086# ifdef UINT32_MAX
1087# define SCNx32 "x"
1088# endif
1089#endif
1090#ifdef INT64_MAX
1091# if (0 ? defined _LP64 : defined _LP64)
1092# define _SCN64_PREFIX "l"
1093# elif defined _MSC_VER || defined __MINGW32__
1094# define _SCN64_PREFIX "I64"
1095# elif LONG_MAX >> 30 == 1
1096# define _SCN64_PREFIX _LONG_LONG_FORMAT_PREFIX
1097# endif
1098# if !defined SCNd64
1099# define SCNd64 _SCN64_PREFIX "d"
1100# endif
1101# if !defined SCNi64
1102# define SCNi64 _SCN64_PREFIX "i"
1103# endif
1104#endif
1105#ifdef UINT64_MAX
1106# if (0 ? defined _LP64 : defined _LP64)
1107# define _SCNu64_PREFIX "l"
1108# elif defined _MSC_VER || defined __MINGW32__
1109# define _SCNu64_PREFIX "I64"
1110# elif ULONG_MAX >> 31 == 1
1111# define _SCNu64_PREFIX _LONG_LONG_FORMAT_PREFIX
1112# endif
1113# if !defined SCNo64
1114# define SCNo64 _SCNu64_PREFIX "o"
1115# endif
1116# if !defined SCNu64
1117# define SCNu64 _SCNu64_PREFIX "u"
1118# endif
1119# if !defined SCNx64
1120# define SCNx64 _SCNu64_PREFIX "x"
1121# endif
1122#endif
1123
1124#if !defined SCNdLEAST8
1125# define SCNdLEAST8 "hhd"
1126#endif
1127#if !defined SCNiLEAST8
1128# define SCNiLEAST8 "hhi"
1129#endif
1130#if !defined SCNoLEAST8
1131# define SCNoLEAST8 "hho"
1132#endif
1133#if !defined SCNuLEAST8
1134# define SCNuLEAST8 "hhu"
1135#endif
1136#if !defined SCNxLEAST8
1137# define SCNxLEAST8 "hhx"
1138#endif
1139#if !defined SCNdLEAST16
1140# define SCNdLEAST16 "hd"
1141#endif
1142#if !defined SCNiLEAST16
1143# define SCNiLEAST16 "hi"
1144#endif
1145#if !defined SCNoLEAST16
1146# define SCNoLEAST16 "ho"
1147#endif
1148#if !defined SCNuLEAST16
1149# define SCNuLEAST16 "hu"
1150#endif
1151#if !defined SCNxLEAST16
1152# define SCNxLEAST16 "hx"
1153#endif
1154#if !defined SCNdLEAST32
1155# define SCNdLEAST32 "d"
1156#endif
1157#if !defined SCNiLEAST32
1158# define SCNiLEAST32 "i"
1159#endif
1160#if !defined SCNoLEAST32
1161# define SCNoLEAST32 "o"
1162#endif
1163#if !defined SCNuLEAST32
1164# define SCNuLEAST32 "u"
1165#endif
1166#if !defined SCNxLEAST32
1167# define SCNxLEAST32 "x"
1168#endif
1169#ifdef INT64_MAX
1170# if !defined SCNdLEAST64
1171# define SCNdLEAST64 SCNd64
1172# endif
1173# if !defined SCNiLEAST64
1174# define SCNiLEAST64 SCNi64
1175# endif
1176#endif
1177#ifdef UINT64_MAX
1178# if !defined SCNoLEAST64
1179# define SCNoLEAST64 SCNo64
1180# endif
1181# if !defined SCNuLEAST64
1182# define SCNuLEAST64 SCNu64
1183# endif
1184# if !defined SCNxLEAST64
1185# define SCNxLEAST64 SCNx64
1186# endif
1187#endif
1188
1189#if !defined SCNdFAST8
1190# if INT_FAST8_MAX > INT32_MAX
1191# define SCNdFAST8 SCNd64
1192# elif INT_FAST8_MAX == 0x7fff
1193# define SCNdFAST8 "hd"
1194# elif INT_FAST8_MAX == 0x7f
1195# define SCNdFAST8 "hhd"
1196# else
1197# define SCNdFAST8 "d"
1198# endif
1199#endif
1200#if !defined SCNiFAST8
1201# if INT_FAST8_MAX > INT32_MAX
1202# define SCNiFAST8 SCNi64
1203# elif INT_FAST8_MAX == 0x7fff
1204# define SCNiFAST8 "hi"
1205# elif INT_FAST8_MAX == 0x7f
1206# define SCNiFAST8 "hhi"
1207# else
1208# define SCNiFAST8 "i"
1209# endif
1210#endif
1211#if !defined SCNoFAST8
1212# if UINT_FAST8_MAX > UINT32_MAX
1213# define SCNoFAST8 SCNo64
1214# elif UINT_FAST8_MAX == 0xffff
1215# define SCNoFAST8 "ho"
1216# elif UINT_FAST8_MAX == 0xff
1217# define SCNoFAST8 "hho"
1218# else
1219# define SCNoFAST8 "o"
1220# endif
1221#endif
1222#if !defined SCNuFAST8
1223# if UINT_FAST8_MAX > UINT32_MAX
1224# define SCNuFAST8 SCNu64
1225# elif UINT_FAST8_MAX == 0xffff
1226# define SCNuFAST8 "hu"
1227# elif UINT_FAST8_MAX == 0xff
1228# define SCNuFAST8 "hhu"
1229# else
1230# define SCNuFAST8 "u"
1231# endif
1232#endif
1233#if !defined SCNxFAST8
1234# if UINT_FAST8_MAX > UINT32_MAX
1235# define SCNxFAST8 SCNx64
1236# elif UINT_FAST8_MAX == 0xffff
1237# define SCNxFAST8 "hx"
1238# elif UINT_FAST8_MAX == 0xff
1239# define SCNxFAST8 "hhx"
1240# else
1241# define SCNxFAST8 "x"
1242# endif
1243#endif
1244#if !defined SCNdFAST16
1245# if INT_FAST16_MAX > INT32_MAX
1246# define SCNdFAST16 SCNd64
1247# elif INT_FAST16_MAX == 0x7fff
1248# define SCNdFAST16 "hd"
1249# else
1250# define SCNdFAST16 "d"
1251# endif
1252#endif
1253#if !defined SCNiFAST16
1254# if INT_FAST16_MAX > INT32_MAX
1255# define SCNiFAST16 SCNi64
1256# elif INT_FAST16_MAX == 0x7fff
1257# define SCNiFAST16 "hi"
1258# else
1259# define SCNiFAST16 "i"
1260# endif
1261#endif
1262#if !defined SCNoFAST16
1263# if UINT_FAST16_MAX > UINT32_MAX
1264# define SCNoFAST16 SCNo64
1265# elif UINT_FAST16_MAX == 0xffff
1266# define SCNoFAST16 "ho"
1267# else
1268# define SCNoFAST16 "o"
1269# endif
1270#endif
1271#if !defined SCNuFAST16
1272# if UINT_FAST16_MAX > UINT32_MAX
1273# define SCNuFAST16 SCNu64
1274# elif UINT_FAST16_MAX == 0xffff
1275# define SCNuFAST16 "hu"
1276# else
1277# define SCNuFAST16 "u"
1278# endif
1279#endif
1280#if !defined SCNxFAST16
1281# if UINT_FAST16_MAX > UINT32_MAX
1282# define SCNxFAST16 SCNx64
1283# elif UINT_FAST16_MAX == 0xffff
1284# define SCNxFAST16 "hx"
1285# else
1286# define SCNxFAST16 "x"
1287# endif
1288#endif
1289#if !defined SCNdFAST32
1290# if INT_FAST32_MAX > INT32_MAX
1291# define SCNdFAST32 SCNd64
1292# else
1293# define SCNdFAST32 "d"
1294# endif
1295#endif
1296#if !defined SCNiFAST32
1297# if INT_FAST32_MAX > INT32_MAX
1298# define SCNiFAST32 SCNi64
1299# else
1300# define SCNiFAST32 "i"
1301# endif
1302#endif
1303#if !defined SCNoFAST32
1304# if UINT_FAST32_MAX > UINT32_MAX
1305# define SCNoFAST32 SCNo64
1306# else
1307# define SCNoFAST32 "o"
1308# endif
1309#endif
1310#if !defined SCNuFAST32
1311# if UINT_FAST32_MAX > UINT32_MAX
1312# define SCNuFAST32 SCNu64
1313# else
1314# define SCNuFAST32 "u"
1315# endif
1316#endif
1317#if !defined SCNxFAST32
1318# if UINT_FAST32_MAX > UINT32_MAX
1319# define SCNxFAST32 SCNx64
1320# else
1321# define SCNxFAST32 "x"
1322# endif
1323#endif
1324#ifdef INT64_MAX
1325# if !defined SCNdFAST64
1326# define SCNdFAST64 SCNd64
1327# endif
1328# if !defined SCNiFAST64
1329# define SCNiFAST64 SCNi64
1330# endif
1331#endif
1332#ifdef UINT64_MAX
1333# if !defined SCNoFAST64
1334# define SCNoFAST64 SCNo64
1335# endif
1336# if !defined SCNuFAST64
1337# define SCNuFAST64 SCNu64
1338# endif
1339# if !defined SCNxFAST64
1340# define SCNxFAST64 SCNx64
1341# endif
1342#endif
1343
1344#if !defined SCNdMAX
1345# if 1
1346# define SCNdMAX SCNd64
1347# else
1348# define SCNdMAX "ld"
1349# endif
1350#endif
1351#if !defined SCNiMAX
1352# if 1
1353# define SCNiMAX SCNi64
1354# else
1355# define SCNiMAX "li"
1356# endif
1357#endif
1358#if !defined SCNoMAX
1359# if 1
1360# define SCNoMAX SCNo64
1361# else
1362# define SCNoMAX "lo"
1363# endif
1364#endif
1365#if !defined SCNuMAX
1366# if 1
1367# define SCNuMAX SCNu64
1368# else
1369# define SCNuMAX "lu"
1370# endif
1371#endif
1372#if !defined SCNxMAX
1373# if 1
1374# define SCNxMAX SCNx64
1375# else
1376# define SCNxMAX "lx"
1377# endif
1378#endif
1379
1380#if !defined SCNdPTR
1381# ifdef INTPTR_MAX
1382# define SCNdPTR __PRIPTR_PREFIX "d"
1383# endif
1384#endif
1385#if !defined SCNiPTR
1386# ifdef INTPTR_MAX
1387# define SCNiPTR __PRIPTR_PREFIX "i"
1388# endif
1389#endif
1390#if !defined SCNoPTR
1391# ifdef UINTPTR_MAX
1392# define SCNoPTR __PRIPTR_PREFIX "o"
1393# endif
1394#endif
1395#if !defined SCNuPTR
1396# ifdef UINTPTR_MAX
1397# define SCNuPTR __PRIPTR_PREFIX "u"
1398# endif
1399#endif
1400#if !defined SCNxPTR
1401# ifdef UINTPTR_MAX
1402# define SCNxPTR __PRIPTR_PREFIX "x"
1403# endif
1404#endif
1405
1406/* 7.8.2 Functions for greatest-width integer types */
1407
1408#ifdef __cplusplus
1409extern "C" {
1410#endif
1411
1412#if 0
1413# if !1
1414extern intmax_t imaxabs (intmax_t);
1415# endif
1416#elif defined GNULIB_POSIXCHECK
1417# undef imaxabs
1418# if HAVE_RAW_DECL_IMAXABS
1419_GL_WARN_ON_USE (imaxabs, "imaxabs is unportable - "
1420 "use gnulib module imaxabs for portability");
1421# endif
1422#endif
1423
1424#if 0
1425# if !1
1426# if !GNULIB_defined_imaxdiv_t
1427typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t;
1428# define GNULIB_defined_imaxdiv_t 1
1429# endif
1430# endif
1431# if !1
1432extern imaxdiv_t imaxdiv (intmax_t, intmax_t);
1433# endif
1434#elif defined GNULIB_POSIXCHECK
1435# undef imaxdiv
1436# if HAVE_RAW_DECL_IMAXDIV
1437_GL_WARN_ON_USE (imaxdiv, "imaxdiv is unportable - "
1438 "use gnulib module imaxdiv for portability");
1439# endif
1440#endif
1441
1442#if 0
1443# if 0
1444# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1445# undef strtoimax
1446# define strtoimax rpl_strtoimax
1447# endif
1448_GL_FUNCDECL_RPL (strtoimax, intmax_t,
1449 (const char *restrict, char **restrict, int)
1450 _GL_ARG_NONNULL ((1)));
1451_GL_CXXALIAS_RPL (strtoimax, intmax_t,
1452 (const char *restrict, char **restrict, int));
1453# else
1454# if !1
1455# undef strtoimax
1456_GL_FUNCDECL_SYS (strtoimax, intmax_t,
1457 (const char *restrict, char **restrict, int)
1458 _GL_ARG_NONNULL ((1)));
1459# endif
1460_GL_CXXALIAS_SYS (strtoimax, intmax_t,
1461 (const char *restrict, char **restrict, int));
1462# endif
1463_GL_CXXALIASWARN (strtoimax);
1464#elif defined GNULIB_POSIXCHECK
1465# undef strtoimax
1466# if HAVE_RAW_DECL_STRTOIMAX
1467_GL_WARN_ON_USE (strtoimax, "strtoimax is unportable - "
1468 "use gnulib module strtoimax for portability");
1469# endif
1470#endif
1471
1472#if 0
1473# if 0
1474# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1475# undef strtoumax
1476# define strtoumax rpl_strtoumax
1477# endif
1478_GL_FUNCDECL_RPL (strtoumax, uintmax_t,
1479 (const char *restrict, char **restrict, int)
1480 _GL_ARG_NONNULL ((1)));
1481_GL_CXXALIAS_RPL (strtoumax, uintmax_t,
1482 (const char *restrict, char **restrict, int));
1483# else
1484# if !1
1485# undef strtoumax
1486_GL_FUNCDECL_SYS (strtoumax, uintmax_t,
1487 (const char *restrict, char **restrict, int)
1488 _GL_ARG_NONNULL ((1)));
1489# endif
1490_GL_CXXALIAS_SYS (strtoumax, uintmax_t,
1491 (const char *restrict, char **restrict, int));
1492# endif
1493_GL_CXXALIASWARN (strtoumax);
1494#elif defined GNULIB_POSIXCHECK
1495# undef strtoumax
1496# if HAVE_RAW_DECL_STRTOUMAX
1497_GL_WARN_ON_USE (strtoumax, "strtoumax is unportable - "
1498 "use gnulib module strtoumax for portability");
1499# endif
1500#endif
1501
1502/* Don't bother defining or declaring wcstoimax and wcstoumax, since
1503 wide-character functions like this are hardly ever useful. */
1504
1505#ifdef __cplusplus
1506}
1507#endif
1508
1509#endif /* !defined INTTYPES_H && !defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H */
diff --git a/gl/limits.h b/gl/limits.h
new file mode 100644
index 0000000..4f37f3c
--- /dev/null
+++ b/gl/limits.h
@@ -0,0 +1,132 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* A GNU-like <limits.h>.
3
4 Copyright 2016-2022 Free Software Foundation, Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19#if __GNUC__ >= 3
20#pragma GCC system_header
21#endif
22
23
24#if defined _GL_ALREADY_INCLUDING_LIMITS_H
25/* Special invocation convention:
26 On Haiku/x86_64, we have a sequence of nested includes
27 <limits.h> -> <syslimits.h> -> <limits.h>.
28 In this situation, LONG_MAX and INT_MAX are not yet defined,
29 therefore we should not attempt to define LONG_BIT. */
30
31#include_next <limits.h>
32
33#else
34/* Normal invocation convention. */
35
36#ifndef _GL_LIMITS_H
37
38# define _GL_ALREADY_INCLUDING_LIMITS_H
39
40/* The include_next requires a split double-inclusion guard. */
41# include_next <limits.h>
42
43# undef _GL_ALREADY_INCLUDING_LIMITS_H
44
45#ifndef _GL_LIMITS_H
46#define _GL_LIMITS_H
47
48#ifndef LLONG_MIN
49# if defined LONG_LONG_MIN /* HP-UX 11.31 */
50# define LLONG_MIN LONG_LONG_MIN
51# elif defined LONGLONG_MIN /* IRIX 6.5 */
52# define LLONG_MIN LONGLONG_MIN
53# elif defined __GNUC__
54# define LLONG_MIN (- __LONG_LONG_MAX__ - 1LL)
55# endif
56#endif
57#ifndef LLONG_MAX
58# if defined LONG_LONG_MAX /* HP-UX 11.31 */
59# define LLONG_MAX LONG_LONG_MAX
60# elif defined LONGLONG_MAX /* IRIX 6.5 */
61# define LLONG_MAX LONGLONG_MAX
62# elif defined __GNUC__
63# define LLONG_MAX __LONG_LONG_MAX__
64# endif
65#endif
66#ifndef ULLONG_MAX
67# if defined ULONG_LONG_MAX /* HP-UX 11.31 */
68# define ULLONG_MAX ULONG_LONG_MAX
69# elif defined ULONGLONG_MAX /* IRIX 6.5 */
70# define ULLONG_MAX ULONGLONG_MAX
71# elif defined __GNUC__
72# define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL)
73# endif
74#endif
75
76/* The number of usable bits in an unsigned or signed integer type
77 with minimum value MIN and maximum value MAX, as an int expression
78 suitable in #if. Cover all known practical hosts. This
79 implementation exploits the fact that MAX is 1 less than a power of
80 2, and merely counts the number of 1 bits in MAX; "COBn" means
81 "count the number of 1 bits in the low-order n bits"). */
82#define _GL_INTEGER_WIDTH(min, max) (((min) < 0) + _GL_COB128 (max))
83#define _GL_COB128(n) (_GL_COB64 ((n) >> 31 >> 31 >> 2) + _GL_COB64 (n))
84#define _GL_COB64(n) (_GL_COB32 ((n) >> 31 >> 1) + _GL_COB32 (n))
85#define _GL_COB32(n) (_GL_COB16 ((n) >> 16) + _GL_COB16 (n))
86#define _GL_COB16(n) (_GL_COB8 ((n) >> 8) + _GL_COB8 (n))
87#define _GL_COB8(n) (_GL_COB4 ((n) >> 4) + _GL_COB4 (n))
88#define _GL_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + !!((n) & 1))
89
90#ifndef WORD_BIT
91/* Assume 'int' is 32 bits wide. */
92# define WORD_BIT 32
93#endif
94#ifndef LONG_BIT
95/* Assume 'long' is 32 or 64 bits wide. */
96# if LONG_MAX == INT_MAX
97# define LONG_BIT 32
98# else
99# define LONG_BIT 64
100# endif
101#endif
102
103/* Macros specified by C2x and by ISO/IEC TS 18661-1:2014. */
104
105#if (! defined ULLONG_WIDTH \
106 && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__ \
107 || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)))
108# define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX)
109# define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX)
110# define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX)
111# define SHRT_WIDTH _GL_INTEGER_WIDTH (SHRT_MIN, SHRT_MAX)
112# define USHRT_WIDTH _GL_INTEGER_WIDTH (0, USHRT_MAX)
113# define INT_WIDTH _GL_INTEGER_WIDTH (INT_MIN, INT_MAX)
114# define UINT_WIDTH _GL_INTEGER_WIDTH (0, UINT_MAX)
115# define LONG_WIDTH _GL_INTEGER_WIDTH (LONG_MIN, LONG_MAX)
116# define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX)
117# define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX)
118# define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX)
119#endif
120
121/* Macros specified by C2x. */
122
123#if (! defined BOOL_WIDTH \
124 && (defined _GNU_SOURCE \
125 || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)))
126# define BOOL_MAX 1
127# define BOOL_WIDTH 1
128#endif
129
130#endif /* _GL_LIMITS_H */
131#endif /* _GL_LIMITS_H */
132#endif
diff --git a/gl/lseek.c b/gl/lseek.c
deleted file mode 100644
index 1a9c49b..0000000
--- a/gl/lseek.c
+++ /dev/null
@@ -1,89 +0,0 @@
1/* An lseek() function that detects pipes.
2 Copyright (C) 2007, 2009-2022 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#include <config.h>
18
19/* Specification. */
20#include <unistd.h>
21
22#if defined _WIN32 && ! defined __CYGWIN__
23/* Windows platforms. */
24/* Get GetFileType. */
25# include <windows.h>
26/* Get _get_osfhandle. */
27# if GNULIB_MSVC_NOTHROW
28# include "msvc-nothrow.h"
29# else
30# include <io.h>
31# endif
32#else
33# include <sys/stat.h>
34#endif
35#include <errno.h>
36
37#undef lseek
38
39off_t
40rpl_lseek (int fd, off_t offset, int whence)
41{
42#if defined _WIN32 && ! defined __CYGWIN__
43 /* mingw lseek mistakenly succeeds on pipes, sockets, and terminals. */
44 HANDLE h = (HANDLE) _get_osfhandle (fd);
45 if (h == INVALID_HANDLE_VALUE)
46 {
47 errno = EBADF;
48 return -1;
49 }
50 if (GetFileType (h) != FILE_TYPE_DISK)
51 {
52 errno = ESPIPE;
53 return -1;
54 }
55#elif defined __APPLE__ && defined __MACH__ && defined SEEK_DATA
56 if (whence == SEEK_DATA)
57 {
58 /* If OFFSET points to data, macOS lseek+SEEK_DATA returns the
59 start S of the first data region that begins *after* OFFSET,
60 where the region from OFFSET to S consists of possibly-empty
61 data followed by a possibly-empty hole. To work around this
62 portability glitch, check whether OFFSET is within data by
63 using lseek+SEEK_HOLE, and if so return to OFFSET by using
64 lseek+SEEK_SET. Also, contrary to the macOS documentation,
65 lseek+SEEK_HOLE can fail with ENXIO if there are no holes on
66 or after OFFSET. What a mess! */
67 off_t next_hole = lseek (fd, offset, SEEK_HOLE);
68 if (next_hole < 0)
69 return errno == ENXIO ? offset : next_hole;
70 if (next_hole != offset)
71 whence = SEEK_SET;
72 }
73#else
74 /* BeOS lseek mistakenly succeeds on pipes... */
75 struct stat statbuf;
76 if (fstat (fd, &statbuf) < 0)
77 return -1;
78 if (!S_ISREG (statbuf.st_mode))
79 {
80 errno = ESPIPE;
81 return -1;
82 }
83#endif
84#if _GL_WINDOWS_64_BIT_OFF_T || (defined __MINGW32__ && defined _FILE_OFFSET_BITS && (_FILE_OFFSET_BITS == 64))
85 return _lseeki64 (fd, offset, whence);
86#else
87 return lseek (fd, offset, whence);
88#endif
89}
diff --git a/gl/m4/af_alg.m4 b/gl/m4/af_alg.m4
deleted file mode 100644
index 9c7edf0..0000000
--- a/gl/m4/af_alg.m4
+++ /dev/null
@@ -1,57 +0,0 @@
1# af_alg.m4 serial 6
2dnl Copyright 2018-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Matteo Croce.
8
9AC_DEFUN_ONCE([gl_AF_ALG],
10[
11 AC_REQUIRE([gl_SYS_SOCKET_H])
12 AC_REQUIRE([AC_C_INLINE])
13
14 dnl Check whether linux/if_alg.h has needed features.
15 AC_CACHE_CHECK([whether linux/if_alg.h has struct sockaddr_alg.],
16 [gl_cv_header_linux_if_alg_salg],
17 [AC_COMPILE_IFELSE(
18 [AC_LANG_PROGRAM([[#include <sys/socket.h>
19 #include <linux/if_alg.h>
20 struct sockaddr_alg salg = {
21 .salg_family = AF_ALG,
22 .salg_type = "hash",
23 .salg_name = "sha1",
24 };]])],
25 [gl_cv_header_linux_if_alg_salg=yes],
26 [gl_cv_header_linux_if_alg_salg=no])])
27 if test "$gl_cv_header_linux_if_alg_salg" = yes; then
28 AC_DEFINE([HAVE_LINUX_IF_ALG_H], [1],
29 [Define to 1 if you have 'struct sockaddr_alg' defined.])
30 fi
31
32 dnl The default is to not use AF_ALG if available,
33 dnl as it's system dependent as to whether the kernel
34 dnl routines are faster than libcrypto for example.
35 use_af_alg=no
36 AC_ARG_WITH([linux-crypto],
37 [AS_HELP_STRING([[--with-linux-crypto]],
38 [use Linux kernel cryptographic API (if available) for the hash functions
39 MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512 on files])],
40 [use_af_alg=$withval],
41 [use_af_alg=no])
42 dnl We cannot use it if it is not available.
43 if test "$gl_cv_header_linux_if_alg_salg" != yes; then
44 if test "$use_af_alg" != no; then
45 AC_MSG_WARN([Linux kernel cryptographic API not found])
46 fi
47 use_af_alg=no
48 fi
49
50 if test "$use_af_alg" != no; then
51 USE_AF_ALG=1
52 else
53 USE_AF_ALG=0
54 fi
55 AC_DEFINE_UNQUOTED([USE_LINUX_CRYPTO_API], [$USE_AF_ALG],
56 [Define to 1 if you want to use the Linux kernel cryptographic API.])
57])
diff --git a/gl/m4/byteswap.m4 b/gl/m4/byteswap.m4
deleted file mode 100644
index 99aeb68..0000000
--- a/gl/m4/byteswap.m4
+++ /dev/null
@@ -1,17 +0,0 @@
1# byteswap.m4 serial 5
2dnl Copyright (C) 2005, 2007, 2009-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Written by Oskar Liljeblad.
8
9AC_DEFUN([gl_BYTESWAP],
10[
11 dnl Prerequisites of lib/byteswap.in.h.
12 AC_CHECK_HEADERS([byteswap.h], [
13 GL_GENERATE_BYTESWAP_H=false
14 ], [
15 GL_GENERATE_BYTESWAP_H=true
16 ])
17])
diff --git a/gl/m4/fflush.m4 b/gl/m4/fflush.m4
deleted file mode 100644
index e36f90e..0000000
--- a/gl/m4/fflush.m4
+++ /dev/null
@@ -1,100 +0,0 @@
1# fflush.m4 serial 18
2
3# Copyright (C) 2007-2022 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved.
7
8dnl From Eric Blake
9
10dnl Find out how to obey POSIX semantics of fflush(stdin) discarding
11dnl unread input on seekable streams, rather than C99 undefined semantics.
12
13AC_DEFUN([gl_FUNC_FFLUSH],
14[
15 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
16 gl_FUNC_FFLUSH_STDIN
17 case "$gl_cv_func_fflush_stdin" in
18 *yes) ;;
19 *) REPLACE_FFLUSH=1 ;;
20 esac
21])
22
23dnl Determine whether fflush works on input streams.
24dnl Sets gl_cv_func_fflush_stdin.
25
26AC_DEFUN([gl_FUNC_FFLUSH_STDIN],
27[
28 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
29 AC_CHECK_HEADERS_ONCE([unistd.h])
30 AC_CACHE_CHECK([whether fflush works on input streams],
31 [gl_cv_func_fflush_stdin],
32 [echo hello world > conftest.txt
33 AC_RUN_IFELSE([AC_LANG_PROGRAM(
34 [[
35#include <stdio.h>
36#if HAVE_UNISTD_H
37# include <unistd.h>
38#else /* on Windows with MSVC */
39# include <io.h>
40#endif
41 ]GL_MDA_DEFINES],
42 [[FILE *f = fopen ("conftest.txt", "r");
43 char buffer[10];
44 int fd;
45 int c;
46 if (f == NULL)
47 return 1;
48 fd = fileno (f);
49 if (fd < 0 || fread (buffer, 1, 5, f) != 5)
50 { fclose (f); return 2; }
51 /* For deterministic results, ensure f read a bigger buffer. */
52 if (lseek (fd, 0, SEEK_CUR) == 5)
53 { fclose (f); return 3; }
54 /* POSIX requires fflush-fseek to set file offset of fd. This fails
55 on BSD systems and on mingw. */
56 if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
57 { fclose (f); return 4; }
58 if (lseek (fd, 0, SEEK_CUR) != 5)
59 { fclose (f); return 5; }
60 /* Verify behaviour of fflush after ungetc. See
61 <https://www.opengroup.org/austin/aardvark/latest/xshbug3.txt> */
62 /* Verify behaviour of fflush after a backup ungetc. This fails on
63 mingw. */
64 c = fgetc (f);
65 ungetc (c, f);
66 fflush (f);
67 if (fgetc (f) != c)
68 { fclose (f); return 6; }
69 /* Verify behaviour of fflush after a non-backup ungetc. This fails
70 on glibc 2.8 and on BSD systems. */
71 c = fgetc (f);
72 ungetc ('@', f);
73 fflush (f);
74 if (fgetc (f) != c)
75 { fclose (f); return 7; }
76 fclose (f);
77 return 0;
78 ]])],
79 [gl_cv_func_fflush_stdin=yes],
80 [gl_cv_func_fflush_stdin=no],
81 [case "$host_os" in
82 # Guess no on native Windows.
83 mingw*) gl_cv_func_fflush_stdin="guessing no" ;;
84 *) gl_cv_func_fflush_stdin=cross ;;
85 esac
86 ])
87 rm conftest.txt
88 ])
89 case "$gl_cv_func_fflush_stdin" in
90 *yes) gl_func_fflush_stdin=1 ;;
91 *no) gl_func_fflush_stdin=0 ;;
92 *) gl_func_fflush_stdin='(-1)' ;;
93 esac
94 AC_DEFINE_UNQUOTED([FUNC_FFLUSH_STDIN], [$gl_func_fflush_stdin],
95 [Define to 1 if fflush is known to work on stdin as per POSIX.1-2008,
96 0 if fflush is known to not work, -1 if unknown.])
97])
98
99# Prerequisites of lib/fflush.c.
100AC_DEFUN([gl_PREREQ_FFLUSH], [:])
diff --git a/gl/m4/fpurge.m4 b/gl/m4/fpurge.m4
deleted file mode 100644
index 1a15454..0000000
--- a/gl/m4/fpurge.m4
+++ /dev/null
@@ -1,73 +0,0 @@
1# fpurge.m4 serial 12
2dnl Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FPURGE],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
11 AC_CHECK_HEADERS_ONCE([stdio_ext.h])
12 AC_CHECK_FUNCS_ONCE([fpurge])
13 AC_CHECK_FUNCS_ONCE([__fpurge])
14 AC_CHECK_DECLS([fpurge], , , [[#include <stdio.h>]])
15 if test "x$ac_cv_func_fpurge" = xyes; then
16 HAVE_FPURGE=1
17 # Detect BSD bug. Only cygwin 1.7 and musl are known to be immune.
18 AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works],
19 [AC_RUN_IFELSE(
20 [AC_LANG_PROGRAM(
21 [[#include <stdio.h>
22]],
23 [[FILE *f = fopen ("conftest.txt", "w+");
24 if (!f)
25 return 1;
26 if (fputc ('a', f) != 'a')
27 { fclose (f); return 2; }
28 rewind (f);
29 if (fgetc (f) != 'a')
30 { fclose (f); return 3; }
31 if (fgetc (f) != EOF)
32 { fclose (f); return 4; }
33 if (fpurge (f) != 0)
34 { fclose (f); return 5; }
35 if (putc ('b', f) != 'b')
36 { fclose (f); return 6; }
37 if (fclose (f) != 0)
38 return 7;
39 if ((f = fopen ("conftest.txt", "r")) == NULL)
40 return 8;
41 if (fgetc (f) != 'a')
42 { fclose (f); return 9; }
43 if (fgetc (f) != 'b')
44 { fclose (f); return 10; }
45 if (fgetc (f) != EOF)
46 { fclose (f); return 11; }
47 if (fclose (f) != 0)
48 return 12;
49 if (remove ("conftest.txt") != 0)
50 return 13;
51 return 0;
52 ]])],
53 [gl_cv_func_fpurge_works=yes],
54 [gl_cv_func_fpurge_works=no],
55 [case "$host_os" in
56 # Guess yes on musl systems.
57 *-musl*) gl_cv_func_fpurge_works="guessing yes" ;;
58 # Otherwise obey --enable-cross-guesses.
59 *) gl_cv_func_fpurge_works="$gl_cross_guess_normal" ;;
60 esac
61 ])
62 ])
63 case "$gl_cv_func_fpurge_works" in
64 *yes) ;;
65 *) REPLACE_FPURGE=1 ;;
66 esac
67 else
68 HAVE_FPURGE=0
69 fi
70 if test "x$ac_cv_have_decl_fpurge" = xno; then
71 HAVE_DECL_FPURGE=0
72 fi
73])
diff --git a/gl/m4/freading.m4 b/gl/m4/freading.m4
deleted file mode 100644
index 81b17a6..0000000
--- a/gl/m4/freading.m4
+++ /dev/null
@@ -1,11 +0,0 @@
1# freading.m4 serial 2
2dnl Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FREADING],
8[
9 AC_CHECK_HEADERS_ONCE([stdio_ext.h])
10 AC_CHECK_FUNCS_ONCE([__freading])
11])
diff --git a/gl/m4/fseek.m4 b/gl/m4/fseek.m4
deleted file mode 100644
index bd4a55b..0000000
--- a/gl/m4/fseek.m4
+++ /dev/null
@@ -1,15 +0,0 @@
1# fseek.m4 serial 4
2dnl Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FSEEK],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_FSEEKO])
11 dnl When fseeko needs fixes, fseek needs them too.
12 if test $HAVE_FSEEKO = 0 || test $REPLACE_FSEEKO = 1; then
13 REPLACE_FSEEK=1
14 fi
15])
diff --git a/gl/m4/fseeko.m4 b/gl/m4/fseeko.m4
deleted file mode 100644
index e50fe39..0000000
--- a/gl/m4/fseeko.m4
+++ /dev/null
@@ -1,77 +0,0 @@
1# fseeko.m4 serial 20
2dnl Copyright (C) 2007-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FSEEKO],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
11 AC_REQUIRE([gl_SYS_TYPES_H])
12 AC_REQUIRE([AC_PROG_CC])
13
14 dnl Persuade glibc <stdio.h> to declare fseeko().
15 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
16
17 AC_CACHE_CHECK([for fseeko], [gl_cv_func_fseeko],
18 [
19 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
20]], [[fseeko (stdin, 0, 0);]])],
21 [gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
22 ])
23
24 AC_CHECK_DECLS_ONCE([fseeko])
25 if test $ac_cv_have_decl_fseeko = no; then
26 HAVE_DECL_FSEEKO=0
27 fi
28
29 if test $gl_cv_func_fseeko = no; then
30 HAVE_FSEEKO=0
31 else
32 if test $WINDOWS_64_BIT_OFF_T = 1; then
33 REPLACE_FSEEKO=1
34 fi
35 if test $gl_cv_var_stdin_large_offset = no; then
36 REPLACE_FSEEKO=1
37 fi
38 m4_ifdef([gl_FUNC_FFLUSH_STDIN], [
39 gl_FUNC_FFLUSH_STDIN
40 case "$gl_cv_func_fflush_stdin" in
41 *yes) ;;
42 *) REPLACE_FSEEKO=1 ;;
43 esac
44 ])
45 fi
46])
47
48dnl Code shared by fseeko and ftello. Determine if large files are supported,
49dnl but stdin does not start as a large file by default.
50AC_DEFUN([gl_STDIN_LARGE_OFFSET],
51 [
52 AC_CACHE_CHECK([whether stdin defaults to large file offsets],
53 [gl_cv_var_stdin_large_offset],
54 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
55[[#if defined __SL64 && defined __SCLE /* cygwin */
56 /* Cygwin 1.5.24 and earlier fail to put stdin in 64-bit mode, making
57 fseeko/ftello needlessly fail. This bug was fixed in 1.5.25, and
58 it is easier to do a version check than building a runtime test. */
59# include <cygwin/version.h>
60# if CYGWIN_VERSION_DLL_COMBINED < CYGWIN_VERSION_DLL_MAKE_COMBINED (1005, 25)
61 choke me
62# endif
63#endif]])],
64 [gl_cv_var_stdin_large_offset=yes],
65 [gl_cv_var_stdin_large_offset=no])])
66])
67
68# Prerequisites of lib/fseeko.c.
69AC_DEFUN([gl_PREREQ_FSEEKO],
70[
71 dnl Native Windows has the function _fseeki64. mingw hides it in some
72 dnl circumstances, but mingw64 makes it usable again.
73 AC_CHECK_FUNCS([_fseeki64])
74 if test $ac_cv_func__fseeki64 = yes; then
75 AC_CHECK_DECLS([_fseeki64])
76 fi
77])
diff --git a/gl/m4/ftell.m4 b/gl/m4/ftell.m4
deleted file mode 100644
index 89f2d1b..0000000
--- a/gl/m4/ftell.m4
+++ /dev/null
@@ -1,15 +0,0 @@
1# ftell.m4 serial 3
2dnl Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FTELL],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_FTELLO])
11 dnl When ftello needs fixes, ftell needs them too.
12 if test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1; then
13 REPLACE_FTELL=1
14 fi
15])
diff --git a/gl/m4/ftello.m4 b/gl/m4/ftello.m4
deleted file mode 100644
index 919f39d..0000000
--- a/gl/m4/ftello.m4
+++ /dev/null
@@ -1,151 +0,0 @@
1# ftello.m4 serial 14
2dnl Copyright (C) 2007-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FTELLO],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_PROG_CC])
11 AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
12 AC_REQUIRE([gl_SYS_TYPES_H])
13
14 dnl Persuade glibc <stdio.h> to declare ftello().
15 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
16
17 AC_CHECK_DECLS_ONCE([ftello])
18 if test $ac_cv_have_decl_ftello = no; then
19 HAVE_DECL_FTELLO=0
20 fi
21
22 AC_CACHE_CHECK([for ftello], [gl_cv_func_ftello],
23 [
24 AC_LINK_IFELSE(
25 [AC_LANG_PROGRAM(
26 [[#include <stdio.h>]],
27 [[ftello (stdin);]])],
28 [gl_cv_func_ftello=yes],
29 [gl_cv_func_ftello=no])
30 ])
31 if test $gl_cv_func_ftello = no; then
32 HAVE_FTELLO=0
33 else
34 if test $WINDOWS_64_BIT_OFF_T = 1; then
35 REPLACE_FTELLO=1
36 fi
37 if test $gl_cv_var_stdin_large_offset = no; then
38 REPLACE_FTELLO=1
39 fi
40 if test $REPLACE_FTELLO = 0; then
41 dnl Detect bug on Solaris.
42 dnl ftell and ftello produce incorrect results after putc that followed a
43 dnl getc call that reached EOF on Solaris. This is because the _IOREAD
44 dnl flag does not get cleared in this case, even though _IOWRT gets set,
45 dnl and ftell and ftello look whether the _IOREAD flag is set.
46 AC_REQUIRE([AC_CANONICAL_HOST])
47 AC_CACHE_CHECK([whether ftello works],
48 [gl_cv_func_ftello_works],
49 [
50 dnl Initial guess, used when cross-compiling or when /dev/tty cannot
51 dnl be opened.
52changequote(,)dnl
53 case "$host_os" in
54 # Guess no on Solaris.
55 solaris*) gl_cv_func_ftello_works="guessing no" ;;
56 # Guess yes on native Windows.
57 mingw*) gl_cv_func_ftello_works="guessing yes" ;;
58 # Guess yes otherwise.
59 *) gl_cv_func_ftello_works="guessing yes" ;;
60 esac
61changequote([,])dnl
62 AC_RUN_IFELSE(
63 [AC_LANG_SOURCE([[
64#include <stdio.h>
65#include <stdlib.h>
66#include <string.h>
67#define TESTFILE "conftest.tmp"
68int
69main (void)
70{
71 FILE *fp;
72
73 /* Create a file with some contents. */
74 fp = fopen (TESTFILE, "w");
75 if (fp == NULL)
76 return 70;
77 if (fwrite ("foogarsh", 1, 8, fp) < 8)
78 { fclose (fp); return 71; }
79 if (fclose (fp))
80 return 72;
81
82 /* The file's contents is now "foogarsh". */
83
84 /* Try writing after reading to EOF. */
85 fp = fopen (TESTFILE, "r+");
86 if (fp == NULL)
87 return 73;
88 if (fseek (fp, -1, SEEK_END))
89 { fclose (fp); return 74; }
90 if (!(getc (fp) == 'h'))
91 { fclose (fp); return 1; }
92 if (!(getc (fp) == EOF))
93 { fclose (fp); return 2; }
94 if (!(ftell (fp) == 8))
95 { fclose (fp); return 3; }
96 if (!(ftell (fp) == 8))
97 { fclose (fp); return 4; }
98 if (!(putc ('!', fp) == '!'))
99 { fclose (fp); return 5; }
100 if (!(ftell (fp) == 9))
101 { fclose (fp); return 6; }
102 if (!(fclose (fp) == 0))
103 return 7;
104 fp = fopen (TESTFILE, "r");
105 if (fp == NULL)
106 return 75;
107 {
108 char buf[10];
109 if (!(fread (buf, 1, 10, fp) == 9))
110 { fclose (fp); return 10; }
111 if (!(memcmp (buf, "foogarsh!", 9) == 0))
112 { fclose (fp); return 11; }
113 }
114 if (!(fclose (fp) == 0))
115 return 12;
116
117 /* The file's contents is now "foogarsh!". */
118
119 return 0;
120}]])],
121 [gl_cv_func_ftello_works=yes],
122 [gl_cv_func_ftello_works=no], [:])
123 ])
124 case "$gl_cv_func_ftello_works" in
125 *yes) ;;
126 *)
127 REPLACE_FTELLO=1
128 AC_DEFINE([FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE], [1],
129 [Define to 1 if the system's ftello function has the Solaris bug.])
130 ;;
131 esac
132 fi
133 if test $REPLACE_FTELLO = 0; then
134 dnl Detect bug on macOS >= 10.15.
135 gl_FUNC_UNGETC_WORKS
136 if test $gl_ftello_broken_after_ungetc = yes; then
137 REPLACE_FTELLO=1
138 AC_DEFINE([FTELLO_BROKEN_AFTER_UNGETC], [1],
139 [Define to 1 if the system's ftello function has the macOS bug.])
140 fi
141 fi
142 fi
143])
144
145# Prerequisites of lib/ftello.c.
146AC_DEFUN([gl_PREREQ_FTELLO],
147[
148 dnl Native Windows has the function _ftelli64. mingw hides it, but mingw64
149 dnl makes it usable again.
150 AC_CHECK_FUNCS([_ftelli64])
151])
diff --git a/gl/m4/gl-openssl.m4 b/gl/m4/gl-openssl.m4
deleted file mode 100644
index d076f84..0000000
--- a/gl/m4/gl-openssl.m4
+++ /dev/null
@@ -1,76 +0,0 @@
1# gl-openssl.m4 serial 6
2dnl Copyright (C) 2013-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_SET_CRYPTO_CHECK_DEFAULT],
8[
9 m4_define([gl_CRYPTO_CHECK_DEFAULT], [$1])
10])
11gl_SET_CRYPTO_CHECK_DEFAULT([no])
12
13AC_DEFUN([gl_CRYPTO_CHECK],
14[
15 dnl gnulib users set this before gl_INIT with gl_SET_CRYPTO_CHECK_DEFAULT()
16 m4_divert_once([DEFAULTS], [with_openssl_default='gl_CRYPTO_CHECK_DEFAULT'])
17
18 dnl Only clear once, so crypto routines can be checked for individually
19 m4_divert_once([DEFAULTS], [LIB_CRYPTO=])
20
21 AC_ARG_WITH([openssl],
22 [[ --with-openssl[=ARG] use libcrypto hash routines for the hash functions
23 MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512.
24 Valid ARGs are:
25 'yes',
26 'no',
27 'auto' => use if any version available,
28 'auto-gpl-compat' => use if GPL compatible version
29 available,
30 'optional' => use if available
31 and warn if not available;
32 Default is ']gl_CRYPTO_CHECK_DEFAULT['.]m4_ifdef([gl_AF_ALG], [
33 Note also --with-linux-crypto, which will enable the
34 use of Linux kernel crypto routines (if available),
35 which has precedence for files.])],
36 [],
37 [with_openssl=$with_openssl_default])
38
39 AC_SUBST([LIB_CRYPTO])
40 if test "x$with_openssl" != xno; then
41 if test "x$with_openssl" = xauto-gpl-compat; then
42 AC_CACHE_CHECK([whether openssl is GPL compatible],
43 [gl_cv_openssl_gpl_compat],
44 [AC_COMPILE_IFELSE(
45 [AC_LANG_PROGRAM([[
46 #include <openssl/opensslv.h>
47 #if OPENSSL_VERSION_MAJOR < 3
48 #error "openssl >= version 3 not found"
49 #endif
50 ]])],
51 [gl_cv_openssl_gpl_compat=yes],
52 [gl_cv_openssl_gpl_compat=no])])
53 fi
54 if test "x$with_openssl" != xauto-gpl-compat ||
55 test "x$gl_cv_openssl_gpl_compat" = xyes; then
56 AC_CHECK_LIB([crypto], [$1],
57 [AC_CHECK_HEADERS(
58 m4_if([$1], [MD5], [openssl/md5.h], [openssl/sha.h]),
59 [LIB_CRYPTO=-lcrypto
60 AC_DEFINE([HAVE_OPENSSL_$1], [1],
61 [Define to 1 if libcrypto is used for $1.])])])
62 fi
63 if test "x$LIB_CRYPTO" = x; then
64 message='openssl development library not found for $1.
65 If you want to install it, first find the pre-built package name:
66 - On Debian and Debian-based systems: libssl-dev,
67 - On Red Hat distributions: openssl-devel.
68 - Other: https://repology.org/project/openssl/versions'
69 if test "x$with_openssl" = xyes; then
70 AC_MSG_ERROR([$message])
71 elif test "x$with_openssl" = xoptional; then
72 AC_MSG_WARN([$message])
73 fi
74 fi
75 fi
76])
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4
index 06fed91..7551d09 100644
--- a/gl/m4/gnulib-cache.m4
+++ b/gl/m4/gnulib-cache.m4
@@ -39,7 +39,6 @@
39# --macro-prefix=gl \ 39# --macro-prefix=gl \
40# --no-vc-files \ 40# --no-vc-files \
41# base64 \ 41# base64 \
42# crypto/sha256 \
43# dirname \ 42# dirname \
44# environ \ 43# environ \
45# floorf \ 44# floorf \
@@ -65,7 +64,6 @@
65gl_LOCAL_DIR([]) 64gl_LOCAL_DIR([])
66gl_MODULES([ 65gl_MODULES([
67 base64 66 base64
68 crypto/sha256
69 dirname 67 dirname
70 environ 68 environ
71 floorf 69 floorf
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 93b7884..563b9ae 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -50,15 +50,11 @@ AC_DEFUN([gl_EARLY],
50 # Code from module basename-lgpl: 50 # Code from module basename-lgpl:
51 # Code from module btowc: 51 # Code from module btowc:
52 # Code from module builtin-expect: 52 # Code from module builtin-expect:
53 # Code from module byteswap:
54 # Code from module c99: 53 # Code from module c99:
55 # Code from module calloc-gnu: 54 # Code from module calloc-gnu:
56 # Code from module calloc-posix: 55 # Code from module calloc-posix:
57 # Code from module cloexec: 56 # Code from module cloexec:
58 # Code from module close: 57 # Code from module close:
59 # Code from module crypto/af_alg:
60 # Code from module crypto/sha256:
61 # Code from module crypto/sha256-buffer:
62 # Code from module dirname: 58 # Code from module dirname:
63 # Code from module dirname-lgpl: 59 # Code from module dirname-lgpl:
64 # Code from module double-slash-root: 60 # Code from module double-slash-root:
@@ -73,24 +69,14 @@ AC_DEFUN([gl_EARLY],
73 # Code from module fcntl: 69 # Code from module fcntl:
74 # Code from module fcntl-h: 70 # Code from module fcntl-h:
75 # Code from module fd-hook: 71 # Code from module fd-hook:
76 # Code from module fflush:
77 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
78 # Code from module filename: 72 # Code from module filename:
79 # Code from module float: 73 # Code from module float:
80 # Code from module floorf: 74 # Code from module floorf:
81 # Code from module fopen: 75 # Code from module fopen:
82 # Code from module fopen-gnu: 76 # Code from module fopen-gnu:
83 # Code from module fpurge:
84 # Code from module freading:
85 # Code from module free-posix: 77 # Code from module free-posix:
86 # Code from module fseek:
87 # Code from module fseeko:
88 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
89 # Code from module fstat: 78 # Code from module fstat:
90 # Code from module fsusage: 79 # Code from module fsusage:
91 # Code from module ftell:
92 # Code from module ftello:
93 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
94 # Code from module gen-header: 80 # Code from module gen-header:
95 # Code from module getaddrinfo: 81 # Code from module getaddrinfo:
96 # Code from module getdelim: 82 # Code from module getdelim:
@@ -123,7 +109,6 @@ AC_DEFUN([gl_EARLY],
123 # Code from module locale: 109 # Code from module locale:
124 # Code from module localeconv: 110 # Code from module localeconv:
125 # Code from module lock: 111 # Code from module lock:
126 # Code from module lseek:
127 # Code from module malloc-gnu: 112 # Code from module malloc-gnu:
128 # Code from module malloc-posix: 113 # Code from module malloc-posix:
129 # Code from module malloca: 114 # Code from module malloca:
@@ -246,9 +231,6 @@ AC_DEFUN([gl_INIT],
246 ]) 231 ])
247 gl_WCHAR_MODULE_INDICATOR([btowc]) 232 gl_WCHAR_MODULE_INDICATOR([btowc])
248 gl___BUILTIN_EXPECT 233 gl___BUILTIN_EXPECT
249 gl_BYTESWAP
250 gl_CONDITIONAL_HEADER([byteswap.h])
251 AC_PROG_MKDIR_P
252 gl_FUNC_CALLOC_GNU 234 gl_FUNC_CALLOC_GNU
253 if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 1; then 235 if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 1; then
254 AC_LIBOBJ([calloc]) 236 AC_LIBOBJ([calloc])
@@ -263,9 +245,6 @@ AC_DEFUN([gl_INIT],
263 gl_FUNC_CLOSE 245 gl_FUNC_CLOSE
264 gl_CONDITIONAL([GL_COND_OBJ_CLOSE], [test $REPLACE_CLOSE = 1]) 246 gl_CONDITIONAL([GL_COND_OBJ_CLOSE], [test $REPLACE_CLOSE = 1])
265 gl_UNISTD_MODULE_INDICATOR([close]) 247 gl_UNISTD_MODULE_INDICATOR([close])
266 gl_AF_ALG
267 AC_REQUIRE([AC_C_RESTRICT])
268 gl_SHA256
269 gl_MODULE_INDICATOR([dirname]) 248 gl_MODULE_INDICATOR([dirname])
270 gl_DOUBLE_SLASH_ROOT 249 gl_DOUBLE_SLASH_ROOT
271 gl_FUNC_DUP2 250 gl_FUNC_DUP2
@@ -296,13 +275,6 @@ AC_DEFUN([gl_INIT],
296 gl_FCNTL_H 275 gl_FCNTL_H
297 gl_FCNTL_H_REQUIRE_DEFAULTS 276 gl_FCNTL_H_REQUIRE_DEFAULTS
298 AC_PROG_MKDIR_P 277 AC_PROG_MKDIR_P
299 gl_FUNC_FFLUSH
300 gl_CONDITIONAL([GL_COND_OBJ_FFLUSH], [test $REPLACE_FFLUSH = 1])
301 AM_COND_IF([GL_COND_OBJ_FFLUSH], [
302 gl_PREREQ_FFLUSH
303 ])
304 gl_MODULE_INDICATOR([fflush])
305 gl_STDIO_MODULE_INDICATOR([fflush])
306 gl_FLOAT_H 278 gl_FLOAT_H
307 gl_CONDITIONAL_HEADER([float.h]) 279 gl_CONDITIONAL_HEADER([float.h])
308 AC_PROG_MKDIR_P 280 AC_PROG_MKDIR_P
@@ -325,27 +297,12 @@ AC_DEFUN([gl_INIT],
325 fi 297 fi
326 gl_MODULE_INDICATOR([fopen-gnu]) 298 gl_MODULE_INDICATOR([fopen-gnu])
327 gl_STDIO_MODULE_INDICATOR([fopen-gnu]) 299 gl_STDIO_MODULE_INDICATOR([fopen-gnu])
328 gl_FUNC_FPURGE
329 gl_CONDITIONAL([GL_COND_OBJ_FPURGE],
330 [test $HAVE_FPURGE = 0 || test $REPLACE_FPURGE = 1])
331 gl_STDIO_MODULE_INDICATOR([fpurge])
332 gl_FUNC_FREADING
333 gl_FUNC_FREE 300 gl_FUNC_FREE
334 gl_CONDITIONAL([GL_COND_OBJ_FREE], [test $REPLACE_FREE = 1]) 301 gl_CONDITIONAL([GL_COND_OBJ_FREE], [test $REPLACE_FREE = 1])
335 AM_COND_IF([GL_COND_OBJ_FREE], [ 302 AM_COND_IF([GL_COND_OBJ_FREE], [
336 gl_PREREQ_FREE 303 gl_PREREQ_FREE
337 ]) 304 ])
338 gl_STDLIB_MODULE_INDICATOR([free-posix]) 305 gl_STDLIB_MODULE_INDICATOR([free-posix])
339 gl_FUNC_FSEEK
340 gl_CONDITIONAL([GL_COND_OBJ_FSEEK], [test $REPLACE_FSEEK = 1])
341 gl_STDIO_MODULE_INDICATOR([fseek])
342 gl_FUNC_FSEEKO
343 gl_CONDITIONAL([GL_COND_OBJ_FSEEKO],
344 [test $HAVE_FSEEKO = 0 || test $REPLACE_FSEEKO = 1])
345 AM_COND_IF([GL_COND_OBJ_FSEEKO], [
346 gl_PREREQ_FSEEKO
347 ])
348 gl_STDIO_MODULE_INDICATOR([fseeko])
349 gl_FUNC_FSTAT 306 gl_FUNC_FSTAT
350 gl_CONDITIONAL([GL_COND_OBJ_FSTAT], [test $REPLACE_FSTAT = 1]) 307 gl_CONDITIONAL([GL_COND_OBJ_FSTAT], [test $REPLACE_FSTAT = 1])
351 AM_COND_IF([GL_COND_OBJ_FSTAT], [ 308 AM_COND_IF([GL_COND_OBJ_FSTAT], [
@@ -362,16 +319,6 @@ AC_DEFUN([gl_INIT],
362 AM_COND_IF([GL_COND_OBJ_FSUSAGE], [ 319 AM_COND_IF([GL_COND_OBJ_FSUSAGE], [
363 gl_PREREQ_FSUSAGE_EXTRA 320 gl_PREREQ_FSUSAGE_EXTRA
364 ]) 321 ])
365 gl_FUNC_FTELL
366 gl_CONDITIONAL([GL_COND_OBJ_FTELL], [test $REPLACE_FTELL = 1])
367 gl_STDIO_MODULE_INDICATOR([ftell])
368 gl_FUNC_FTELLO
369 gl_CONDITIONAL([GL_COND_OBJ_FTELLO],
370 [test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1])
371 AM_COND_IF([GL_COND_OBJ_FTELLO], [
372 gl_PREREQ_FTELLO
373 ])
374 gl_STDIO_MODULE_INDICATOR([ftello])
375 gl_GETADDRINFO 322 gl_GETADDRINFO
376 gl_CONDITIONAL([GL_COND_OBJ_GETADDRINFO], 323 gl_CONDITIONAL([GL_COND_OBJ_GETADDRINFO],
377 [test $HAVE_GETADDRINFO = 0 || test $REPLACE_GETADDRINFO = 1]) 324 [test $HAVE_GETADDRINFO = 0 || test $REPLACE_GETADDRINFO = 1])
@@ -470,9 +417,6 @@ AC_DEFUN([gl_INIT],
470 gl_LOCALE_MODULE_INDICATOR([localeconv]) 417 gl_LOCALE_MODULE_INDICATOR([localeconv])
471 gl_LOCK 418 gl_LOCK
472 gl_MODULE_INDICATOR([lock]) 419 gl_MODULE_INDICATOR([lock])
473 gl_FUNC_LSEEK
474 gl_CONDITIONAL([GL_COND_OBJ_LSEEK], [test $REPLACE_LSEEK = 1])
475 gl_UNISTD_MODULE_INDICATOR([lseek])
476 gl_FUNC_MALLOC_GNU 420 gl_FUNC_MALLOC_GNU
477 if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1; then 421 if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1; then
478 AC_LIBOBJ([malloc]) 422 AC_LIBOBJ([malloc])
@@ -978,8 +922,6 @@ AC_DEFUN([gltests_LIBSOURCES], [
978AC_DEFUN([gl_FILE_LIST], [ 922AC_DEFUN([gl_FILE_LIST], [
979 build-aux/config.rpath 923 build-aux/config.rpath
980 lib/_Noreturn.h 924 lib/_Noreturn.h
981 lib/af_alg.c
982 lib/af_alg.h
983 lib/alloca.in.h 925 lib/alloca.in.h
984 lib/arg-nonnull.h 926 lib/arg-nonnull.h
985 lib/arpa_inet.in.h 927 lib/arpa_inet.in.h
@@ -992,7 +934,6 @@ AC_DEFUN([gl_FILE_LIST], [
992 lib/basename-lgpl.h 934 lib/basename-lgpl.h
993 lib/basename.c 935 lib/basename.c
994 lib/btowc.c 936 lib/btowc.c
995 lib/byteswap.in.h
996 lib/c++defs.h 937 lib/c++defs.h
997 lib/calloc.c 938 lib/calloc.c
998 lib/cdefs.h 939 lib/cdefs.h
@@ -1013,7 +954,6 @@ AC_DEFUN([gl_FILE_LIST], [
1013 lib/fcntl.in.h 954 lib/fcntl.in.h
1014 lib/fd-hook.c 955 lib/fd-hook.c
1015 lib/fd-hook.h 956 lib/fd-hook.h
1016 lib/fflush.c
1017 lib/filename.h 957 lib/filename.h
1018 lib/float+.h 958 lib/float+.h
1019 lib/float.c 959 lib/float.c
@@ -1021,17 +961,10 @@ AC_DEFUN([gl_FILE_LIST], [
1021 lib/floor.c 961 lib/floor.c
1022 lib/floorf.c 962 lib/floorf.c
1023 lib/fopen.c 963 lib/fopen.c
1024 lib/fpurge.c
1025 lib/freading.c
1026 lib/freading.h
1027 lib/free.c 964 lib/free.c
1028 lib/fseek.c
1029 lib/fseeko.c
1030 lib/fstat.c 965 lib/fstat.c
1031 lib/fsusage.c 966 lib/fsusage.c
1032 lib/fsusage.h 967 lib/fsusage.h
1033 lib/ftell.c
1034 lib/ftello.c
1035 lib/gai_strerror.c 968 lib/gai_strerror.c
1036 lib/getaddrinfo.c 969 lib/getaddrinfo.c
1037 lib/getdelim.c 970 lib/getdelim.c
@@ -1051,7 +984,6 @@ AC_DEFUN([gl_FILE_LIST], [
1051 lib/getprogname.c 984 lib/getprogname.c
1052 lib/getprogname.h 985 lib/getprogname.h
1053 lib/gettext.h 986 lib/gettext.h
1054 lib/gl_openssl.h
1055 lib/glthread/lock.c 987 lib/glthread/lock.c
1056 lib/glthread/lock.h 988 lib/glthread/lock.h
1057 lib/glthread/threadlib.c 989 lib/glthread/threadlib.c
@@ -1076,7 +1008,6 @@ AC_DEFUN([gl_FILE_LIST], [
1076 lib/localcharset.h 1008 lib/localcharset.h
1077 lib/locale.in.h 1009 lib/locale.in.h
1078 lib/localeconv.c 1010 lib/localeconv.c
1079 lib/lseek.c
1080 lib/malloc.c 1011 lib/malloc.c
1081 lib/malloc/dynarray-skeleton.c 1012 lib/malloc/dynarray-skeleton.c
1082 lib/malloc/dynarray.h 1013 lib/malloc/dynarray.h
@@ -1130,9 +1061,6 @@ AC_DEFUN([gl_FILE_LIST], [
1130 lib/setlocale-lock.c 1061 lib/setlocale-lock.c
1131 lib/setlocale_null.c 1062 lib/setlocale_null.c
1132 lib/setlocale_null.h 1063 lib/setlocale_null.h
1133 lib/sha256-stream.c
1134 lib/sha256.c
1135 lib/sha256.h
1136 lib/size_max.h 1064 lib/size_max.h
1137 lib/snprintf.c 1065 lib/snprintf.c
1138 lib/sockets.c 1066 lib/sockets.c
@@ -1147,7 +1075,6 @@ AC_DEFUN([gl_FILE_LIST], [
1147 lib/stdckdint.in.h 1075 lib/stdckdint.in.h
1148 lib/stddef.in.h 1076 lib/stddef.in.h
1149 lib/stdint.in.h 1077 lib/stdint.in.h
1150 lib/stdio-impl.h
1151 lib/stdio-read.c 1078 lib/stdio-read.c
1152 lib/stdio-write.c 1079 lib/stdio-write.c
1153 lib/stdio.in.h 1080 lib/stdio.in.h
@@ -1165,7 +1092,6 @@ AC_DEFUN([gl_FILE_LIST], [
1165 lib/strncasecmp.c 1092 lib/strncasecmp.c
1166 lib/strsep.c 1093 lib/strsep.c
1167 lib/strstr.c 1094 lib/strstr.c
1168 lib/sys-limits.h
1169 lib/sys_socket.c 1095 lib/sys_socket.c
1170 lib/sys_socket.in.h 1096 lib/sys_socket.in.h
1171 lib/sys_stat.in.h 1097 lib/sys_stat.in.h
@@ -1207,13 +1133,11 @@ AC_DEFUN([gl_FILE_LIST], [
1207 m4/00gnulib.m4 1133 m4/00gnulib.m4
1208 m4/__inline.m4 1134 m4/__inline.m4
1209 m4/absolute-header.m4 1135 m4/absolute-header.m4
1210 m4/af_alg.m4
1211 m4/alloca.m4 1136 m4/alloca.m4
1212 m4/arpa_inet_h.m4 1137 m4/arpa_inet_h.m4
1213 m4/base64.m4 1138 m4/base64.m4
1214 m4/btowc.m4 1139 m4/btowc.m4
1215 m4/builtin-expect.m4 1140 m4/builtin-expect.m4
1216 m4/byteswap.m4
1217 m4/calloc.m4 1141 m4/calloc.m4
1218 m4/close.m4 1142 m4/close.m4
1219 m4/codeset.m4 1143 m4/codeset.m4
@@ -1229,20 +1153,13 @@ AC_DEFUN([gl_FILE_LIST], [
1229 m4/fcntl-o.m4 1153 m4/fcntl-o.m4
1230 m4/fcntl.m4 1154 m4/fcntl.m4
1231 m4/fcntl_h.m4 1155 m4/fcntl_h.m4
1232 m4/fflush.m4
1233 m4/float_h.m4 1156 m4/float_h.m4
1234 m4/floorf.m4 1157 m4/floorf.m4
1235 m4/fopen.m4 1158 m4/fopen.m4
1236 m4/fpurge.m4
1237 m4/freading.m4
1238 m4/free.m4 1159 m4/free.m4
1239 m4/fseek.m4
1240 m4/fseeko.m4
1241 m4/fstat.m4 1160 m4/fstat.m4
1242 m4/fstypename.m4 1161 m4/fstypename.m4
1243 m4/fsusage.m4 1162 m4/fsusage.m4
1244 m4/ftell.m4
1245 m4/ftello.m4
1246 m4/getaddrinfo.m4 1163 m4/getaddrinfo.m4
1247 m4/getdelim.m4 1164 m4/getdelim.m4
1248 m4/getdtablesize.m4 1165 m4/getdtablesize.m4
@@ -1252,7 +1169,6 @@ AC_DEFUN([gl_FILE_LIST], [
1252 m4/getopt.m4 1169 m4/getopt.m4
1253 m4/getprogname.m4 1170 m4/getprogname.m4
1254 m4/gettext.m4 1171 m4/gettext.m4
1255 m4/gl-openssl.m4
1256 m4/gnulib-common.m4 1172 m4/gnulib-common.m4
1257 m4/host-cpu-c-abi.m4 1173 m4/host-cpu-c-abi.m4
1258 m4/hostent.m4 1174 m4/hostent.m4
@@ -1278,7 +1194,6 @@ AC_DEFUN([gl_FILE_LIST], [
1278 m4/locale_h.m4 1194 m4/locale_h.m4
1279 m4/localeconv.m4 1195 m4/localeconv.m4
1280 m4/lock.m4 1196 m4/lock.m4
1281 m4/lseek.m4
1282 m4/malloc.m4 1197 m4/malloc.m4
1283 m4/malloca.m4 1198 m4/malloca.m4
1284 m4/math_h.m4 1199 m4/math_h.m4
@@ -1316,7 +1231,6 @@ AC_DEFUN([gl_FILE_LIST], [
1316 m4/servent.m4 1231 m4/servent.m4
1317 m4/setenv.m4 1232 m4/setenv.m4
1318 m4/setlocale_null.m4 1233 m4/setlocale_null.m4
1319 m4/sha256.m4
1320 m4/size_max.m4 1234 m4/size_max.m4
1321 m4/snprintf.m4 1235 m4/snprintf.m4
1322 m4/socketlib.m4 1236 m4/socketlib.m4
@@ -1349,7 +1263,6 @@ AC_DEFUN([gl_FILE_LIST], [
1349 m4/time_h.m4 1263 m4/time_h.m4
1350 m4/time_r.m4 1264 m4/time_r.m4
1351 m4/timegm.m4 1265 m4/timegm.m4
1352 m4/ungetc.m4
1353 m4/unistd_h.m4 1266 m4/unistd_h.m4
1354 m4/unlocked-io.m4 1267 m4/unlocked-io.m4
1355 m4/vararrays.m4 1268 m4/vararrays.m4
diff --git a/gl/m4/lseek.m4 b/gl/m4/lseek.m4
deleted file mode 100644
index 0583511..0000000
--- a/gl/m4/lseek.m4
+++ /dev/null
@@ -1,78 +0,0 @@
1# lseek.m4 serial 12
2dnl Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_LSEEK],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10
11 AC_REQUIRE([AC_CANONICAL_HOST])
12 AC_REQUIRE([AC_PROG_CC])
13 AC_CHECK_HEADERS_ONCE([unistd.h])
14 AC_CACHE_CHECK([whether lseek detects pipes], [gl_cv_func_lseek_pipe],
15 [case "$host_os" in
16 mingw*)
17 dnl Native Windows.
18 dnl The result of lseek (fd, (off_t)0, SEEK_CUR) or
19 dnl SetFilePointer(handle, 0, NULL, FILE_CURRENT)
20 dnl for a pipe depends on the environment: In a Cygwin 1.5
21 dnl environment it succeeds (wrong); in a Cygwin 1.7 environment
22 dnl it fails with a wrong errno value.
23 gl_cv_func_lseek_pipe=no
24 ;;
25 *)
26 if test $cross_compiling = no; then
27 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
28#include <sys/types.h> /* for off_t */
29#include <stdio.h> /* for SEEK_CUR */
30#if HAVE_UNISTD_H
31# include <unistd.h>
32#else /* on Windows with MSVC */
33# include <io.h>
34#endif
35]GL_MDA_DEFINES],
36[[
37 /* Exit with success only if stdin is seekable. */
38 return lseek (0, (off_t)0, SEEK_CUR) < 0;
39]])],
40 [if test -s conftest$ac_exeext \
41 && ./conftest$ac_exeext < conftest.$ac_ext \
42 && test 1 = "`echo hi \
43 | { ./conftest$ac_exeext; echo $?; cat >/dev/null; }`"; then
44 gl_cv_func_lseek_pipe=yes
45 else
46 gl_cv_func_lseek_pipe=no
47 fi
48 ],
49 [gl_cv_func_lseek_pipe=no])
50 else
51 AC_COMPILE_IFELSE(
52 [AC_LANG_SOURCE([[
53#if defined __BEOS__
54/* BeOS mistakenly return 0 when trying to seek on pipes. */
55 Choke me.
56#endif]])],
57 [gl_cv_func_lseek_pipe=yes], [gl_cv_func_lseek_pipe=no])
58 fi
59 ;;
60 esac
61 ])
62 if test "$gl_cv_func_lseek_pipe" = no; then
63 REPLACE_LSEEK=1
64 AC_DEFINE([LSEEK_PIPE_BROKEN], [1],
65 [Define to 1 if lseek does not detect pipes.])
66 fi
67
68 AC_REQUIRE([gl_SYS_TYPES_H])
69 if test $WINDOWS_64_BIT_OFF_T = 1; then
70 REPLACE_LSEEK=1
71 fi
72
73 dnl macOS SEEK_DATA is incompatible with other platforms.
74 case $host_os in
75 darwin*)
76 REPLACE_LSEEK=1;;
77 esac
78])
diff --git a/gl/m4/sha256.m4 b/gl/m4/sha256.m4
deleted file mode 100644
index b3d8f92..0000000
--- a/gl/m4/sha256.m4
+++ /dev/null
@@ -1,14 +0,0 @@
1# sha256.m4 serial 8
2dnl Copyright (C) 2005, 2008-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_SHA256],
8[
9 dnl Prerequisites of lib/sha256.c.
10 AC_REQUIRE([gl_BIGENDIAN])
11
12 dnl Determine HAVE_OPENSSL_SHA256 and LIB_CRYPTO
13 gl_CRYPTO_CHECK([SHA256])
14])
diff --git a/gl/m4/ungetc.m4 b/gl/m4/ungetc.m4
deleted file mode 100644
index 12a1099..0000000
--- a/gl/m4/ungetc.m4
+++ /dev/null
@@ -1,73 +0,0 @@
1# ungetc.m4 serial 10
2dnl Copyright (C) 2009-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS],
8[
9 AC_REQUIRE([AC_PROG_CC])
10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
11
12 AC_CACHE_CHECK([whether ungetc works on arbitrary bytes],
13 [gl_cv_func_ungetc_works],
14 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
15#include <stdio.h>
16 ]], [[FILE *f;
17 if (!(f = fopen ("conftest.tmp", "w+")))
18 return 1;
19 if (fputs ("abc", f) < 0)
20 { fclose (f); return 2; }
21 rewind (f);
22 if (fgetc (f) != 'a')
23 { fclose (f); return 3; }
24 if (fgetc (f) != 'b')
25 { fclose (f); return 4; }
26 if (ungetc ('d', f) != 'd')
27 { fclose (f); return 5; }
28 if (ftell (f) != 1)
29 { fclose (f); return 6; }
30 if (fgetc (f) != 'd')
31 { fclose (f); return 7; }
32 if (ftell (f) != 2)
33 { fclose (f); return 8; }
34 if (fseek (f, 0, SEEK_CUR) != 0)
35 { fclose (f); return 9; }
36 if (ftell (f) != 2)
37 { fclose (f); return 10; }
38 if (fgetc (f) != 'c')
39 { fclose (f); return 11; }
40 fclose (f);
41 remove ("conftest.tmp");
42 ]])],
43 [gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no],
44 [case "$host_os" in
45 # Guess yes on glibc systems.
46 *-gnu* | gnu*) gl_cv_func_ungetc_works="guessing yes" ;;
47 # Guess yes on musl systems.
48 *-musl*) gl_cv_func_ungetc_works="guessing yes" ;;
49 # Guess yes on bionic systems.
50 *-android*) gl_cv_func_ungetc_works="guessing yes" ;;
51 # Guess yes on native Windows.
52 mingw*) gl_cv_func_ungetc_works="guessing yes" ;;
53 # If we don't know, obey --enable-cross-guesses.
54 *) gl_cv_func_ungetc_works="$gl_cross_guess_normal" ;;
55 esac
56 ])
57 ])
58 gl_ftello_broken_after_ungetc=no
59 case "$gl_cv_func_ungetc_works" in
60 *yes) ;;
61 *)
62 dnl On macOS >= 10.15, where the above program fails with exit code 6,
63 dnl we fix it through an ftello override.
64 case "$host_os" in
65 darwin*) gl_ftello_broken_after_ungetc=yes ;;
66 *)
67 AC_DEFINE([FUNC_UNGETC_BROKEN], [1],
68 [Define to 1 if ungetc is broken when used on arbitrary bytes.])
69 ;;
70 esac
71 ;;
72 esac
73])
diff --git a/gl/malloc/.deps/.dirstamp b/gl/malloc/.deps/.dirstamp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/gl/malloc/.deps/.dirstamp
diff --git a/gl/malloc/.deps/libgnu_a-dynarray-skeleton.Po b/gl/malloc/.deps/libgnu_a-dynarray-skeleton.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/gl/malloc/.deps/libgnu_a-dynarray-skeleton.Po
@@ -0,0 +1 @@
# dummy
diff --git a/gl/malloc/.deps/libgnu_a-dynarray_at_failure.Po b/gl/malloc/.deps/libgnu_a-dynarray_at_failure.Po
new file mode 100644
index 0000000..82befdb
--- /dev/null
+++ b/gl/malloc/.deps/libgnu_a-dynarray_at_failure.Po
@@ -0,0 +1,138 @@
1malloc/libgnu_a-dynarray_at_failure.o: malloc/dynarray_at_failure.c \
2 /usr/include/stdc-predef.h libc-config.h ../config.h \
3 /usr/include/errno.h /usr/include/features.h \
4 /usr/include/features-time64.h \
5 /usr/include/x86_64-linux-gnu/bits/wordsize.h \
6 /usr/include/x86_64-linux-gnu/bits/timesize.h \
7 /usr/include/x86_64-linux-gnu/sys/cdefs.h \
8 /usr/include/x86_64-linux-gnu/bits/long-double.h \
9 /usr/include/x86_64-linux-gnu/gnu/stubs.h \
10 /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
11 /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
12 /usr/include/x86_64-linux-gnu/asm/errno.h \
13 /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
14 /usr/include/x86_64-linux-gnu/bits/types/error_t.h cdefs.h stdlib.h \
15 /usr/include/stdlib.h \
16 /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
17 /usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h \
18 /usr/include/x86_64-linux-gnu/bits/waitflags.h \
19 /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
20 /usr/include/x86_64-linux-gnu/bits/floatn.h \
21 /usr/include/x86_64-linux-gnu/bits/floatn-common.h \
22 /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
23 /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h sys/types.h \
24 /usr/include/x86_64-linux-gnu/sys/types.h \
25 /usr/include/x86_64-linux-gnu/bits/types.h \
26 /usr/include/x86_64-linux-gnu/bits/typesizes.h \
27 /usr/include/x86_64-linux-gnu/bits/time64.h \
28 /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
29 /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
30 /usr/include/x86_64-linux-gnu/bits/types/time_t.h \
31 /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
32 /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \
33 /usr/include/x86_64-linux-gnu/bits/endian.h \
34 /usr/include/x86_64-linux-gnu/bits/endianness.h \
35 /usr/include/x86_64-linux-gnu/bits/byteswap.h \
36 /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
37 /usr/include/x86_64-linux-gnu/sys/select.h \
38 /usr/include/x86_64-linux-gnu/bits/select.h \
39 /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
40 /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
41 /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
42 /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
43 /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
44 /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
45 /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
46 /usr/include/x86_64-linux-gnu/bits/struct_mutex.h \
47 /usr/include/x86_64-linux-gnu/bits/struct_rwlock.h alloca.h \
48 /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
49 /usr/include/x86_64-linux-gnu/bits/stdlib-float.h dynarray.h \
50 malloc/dynarray.h stdbool.h string.h /usr/include/string.h strings.h \
51 /usr/include/strings.h stdio.h /usr/include/stdio.h \
52 /usr/lib/gcc/x86_64-linux-gnu/12/include/stdarg.h \
53 /usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h \
54 /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
55 /usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h \
56 /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
57 /usr/include/x86_64-linux-gnu/bits/types/FILE.h \
58 /usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h \
59 /usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h \
60 /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
61 /usr/include/x86_64-linux-gnu/bits/stdio.h
62/usr/include/stdc-predef.h:
63libc-config.h:
64../config.h:
65/usr/include/errno.h:
66/usr/include/features.h:
67/usr/include/features-time64.h:
68/usr/include/x86_64-linux-gnu/bits/wordsize.h:
69/usr/include/x86_64-linux-gnu/bits/timesize.h:
70/usr/include/x86_64-linux-gnu/sys/cdefs.h:
71/usr/include/x86_64-linux-gnu/bits/long-double.h:
72/usr/include/x86_64-linux-gnu/gnu/stubs.h:
73/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
74/usr/include/x86_64-linux-gnu/bits/errno.h:
75/usr/include/linux/errno.h:
76/usr/include/x86_64-linux-gnu/asm/errno.h:
77/usr/include/asm-generic/errno.h:
78/usr/include/asm-generic/errno-base.h:
79/usr/include/x86_64-linux-gnu/bits/types/error_t.h:
80cdefs.h:
81stdlib.h:
82/usr/include/stdlib.h:
83/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:
84/usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h:
85/usr/include/x86_64-linux-gnu/bits/waitflags.h:
86/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
87/usr/include/x86_64-linux-gnu/bits/floatn.h:
88/usr/include/x86_64-linux-gnu/bits/floatn-common.h:
89/usr/include/x86_64-linux-gnu/bits/types/locale_t.h:
90/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:
91sys/types.h:
92/usr/include/x86_64-linux-gnu/sys/types.h:
93/usr/include/x86_64-linux-gnu/bits/types.h:
94/usr/include/x86_64-linux-gnu/bits/typesizes.h:
95/usr/include/x86_64-linux-gnu/bits/time64.h:
96/usr/include/x86_64-linux-gnu/bits/types/clock_t.h:
97/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h:
98/usr/include/x86_64-linux-gnu/bits/types/time_t.h:
99/usr/include/x86_64-linux-gnu/bits/types/timer_t.h:
100/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:
101/usr/include/endian.h:
102/usr/include/x86_64-linux-gnu/bits/endian.h:
103/usr/include/x86_64-linux-gnu/bits/endianness.h:
104/usr/include/x86_64-linux-gnu/bits/byteswap.h:
105/usr/include/x86_64-linux-gnu/bits/uintn-identity.h:
106/usr/include/x86_64-linux-gnu/sys/select.h:
107/usr/include/x86_64-linux-gnu/bits/select.h:
108/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h:
109/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h:
110/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h:
111/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h:
112/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
113/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h:
114/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h:
115/usr/include/x86_64-linux-gnu/bits/struct_mutex.h:
116/usr/include/x86_64-linux-gnu/bits/struct_rwlock.h:
117alloca.h:
118/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
119/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
120dynarray.h:
121malloc/dynarray.h:
122stdbool.h:
123string.h:
124/usr/include/string.h:
125strings.h:
126/usr/include/strings.h:
127stdio.h:
128/usr/include/stdio.h:
129/usr/lib/gcc/x86_64-linux-gnu/12/include/stdarg.h:
130/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h:
131/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h:
132/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h:
133/usr/include/x86_64-linux-gnu/bits/types/__FILE.h:
134/usr/include/x86_64-linux-gnu/bits/types/FILE.h:
135/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h:
136/usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h:
137/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
138/usr/include/x86_64-linux-gnu/bits/stdio.h:
diff --git a/gl/malloc/.deps/libgnu_a-dynarray_emplace_enlarge.Po b/gl/malloc/.deps/libgnu_a-dynarray_emplace_enlarge.Po
new file mode 100644
index 0000000..d75417a
--- /dev/null
+++ b/gl/malloc/.deps/libgnu_a-dynarray_emplace_enlarge.Po
@@ -0,0 +1,138 @@
1malloc/libgnu_a-dynarray_emplace_enlarge.o: \
2 malloc/dynarray_emplace_enlarge.c /usr/include/stdc-predef.h \
3 libc-config.h ../config.h /usr/include/errno.h /usr/include/features.h \
4 /usr/include/features-time64.h \
5 /usr/include/x86_64-linux-gnu/bits/wordsize.h \
6 /usr/include/x86_64-linux-gnu/bits/timesize.h \
7 /usr/include/x86_64-linux-gnu/sys/cdefs.h \
8 /usr/include/x86_64-linux-gnu/bits/long-double.h \
9 /usr/include/x86_64-linux-gnu/gnu/stubs.h \
10 /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
11 /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
12 /usr/include/x86_64-linux-gnu/asm/errno.h \
13 /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
14 /usr/include/x86_64-linux-gnu/bits/types/error_t.h cdefs.h dynarray.h \
15 malloc/dynarray.h stdbool.h \
16 /usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h string.h \
17 /usr/include/string.h \
18 /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
19 /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
20 /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h strings.h \
21 /usr/include/strings.h intprops.h intprops-internal.h limits.h \
22 /usr/lib/gcc/x86_64-linux-gnu/12/include/limits.h \
23 /usr/lib/gcc/x86_64-linux-gnu/12/include/syslimits.h \
24 /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \
25 /usr/include/x86_64-linux-gnu/bits/local_lim.h \
26 /usr/include/linux/limits.h \
27 /usr/include/x86_64-linux-gnu/bits/pthread_stack_min-dynamic.h \
28 /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \
29 /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \
30 /usr/include/x86_64-linux-gnu/bits/uio_lim.h stdlib.h \
31 /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \
32 /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
33 /usr/include/x86_64-linux-gnu/bits/floatn.h \
34 /usr/include/x86_64-linux-gnu/bits/floatn-common.h sys/types.h \
35 /usr/include/x86_64-linux-gnu/sys/types.h \
36 /usr/include/x86_64-linux-gnu/bits/types.h \
37 /usr/include/x86_64-linux-gnu/bits/typesizes.h \
38 /usr/include/x86_64-linux-gnu/bits/time64.h \
39 /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
40 /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
41 /usr/include/x86_64-linux-gnu/bits/types/time_t.h \
42 /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
43 /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \
44 /usr/include/x86_64-linux-gnu/bits/endian.h \
45 /usr/include/x86_64-linux-gnu/bits/endianness.h \
46 /usr/include/x86_64-linux-gnu/bits/byteswap.h \
47 /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
48 /usr/include/x86_64-linux-gnu/sys/select.h \
49 /usr/include/x86_64-linux-gnu/bits/select.h \
50 /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
51 /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
52 /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
53 /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
54 /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
55 /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
56 /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
57 /usr/include/x86_64-linux-gnu/bits/struct_mutex.h \
58 /usr/include/x86_64-linux-gnu/bits/struct_rwlock.h alloca.h \
59 /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
60 /usr/include/x86_64-linux-gnu/bits/stdlib-float.h
61/usr/include/stdc-predef.h:
62libc-config.h:
63../config.h:
64/usr/include/errno.h:
65/usr/include/features.h:
66/usr/include/features-time64.h:
67/usr/include/x86_64-linux-gnu/bits/wordsize.h:
68/usr/include/x86_64-linux-gnu/bits/timesize.h:
69/usr/include/x86_64-linux-gnu/sys/cdefs.h:
70/usr/include/x86_64-linux-gnu/bits/long-double.h:
71/usr/include/x86_64-linux-gnu/gnu/stubs.h:
72/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
73/usr/include/x86_64-linux-gnu/bits/errno.h:
74/usr/include/linux/errno.h:
75/usr/include/x86_64-linux-gnu/asm/errno.h:
76/usr/include/asm-generic/errno.h:
77/usr/include/asm-generic/errno-base.h:
78/usr/include/x86_64-linux-gnu/bits/types/error_t.h:
79cdefs.h:
80dynarray.h:
81malloc/dynarray.h:
82stdbool.h:
83/usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h:
84string.h:
85/usr/include/string.h:
86/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:
87/usr/include/x86_64-linux-gnu/bits/types/locale_t.h:
88/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:
89strings.h:
90/usr/include/strings.h:
91intprops.h:
92intprops-internal.h:
93limits.h:
94/usr/lib/gcc/x86_64-linux-gnu/12/include/limits.h:
95/usr/lib/gcc/x86_64-linux-gnu/12/include/syslimits.h:
96/usr/include/limits.h:
97/usr/include/x86_64-linux-gnu/bits/posix1_lim.h:
98/usr/include/x86_64-linux-gnu/bits/local_lim.h:
99/usr/include/linux/limits.h:
100/usr/include/x86_64-linux-gnu/bits/pthread_stack_min-dynamic.h:
101/usr/include/x86_64-linux-gnu/bits/posix2_lim.h:
102/usr/include/x86_64-linux-gnu/bits/xopen_lim.h:
103/usr/include/x86_64-linux-gnu/bits/uio_lim.h:
104stdlib.h:
105/usr/include/stdlib.h:
106/usr/include/x86_64-linux-gnu/bits/waitflags.h:
107/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
108/usr/include/x86_64-linux-gnu/bits/floatn.h:
109/usr/include/x86_64-linux-gnu/bits/floatn-common.h:
110sys/types.h:
111/usr/include/x86_64-linux-gnu/sys/types.h:
112/usr/include/x86_64-linux-gnu/bits/types.h:
113/usr/include/x86_64-linux-gnu/bits/typesizes.h:
114/usr/include/x86_64-linux-gnu/bits/time64.h:
115/usr/include/x86_64-linux-gnu/bits/types/clock_t.h:
116/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h:
117/usr/include/x86_64-linux-gnu/bits/types/time_t.h:
118/usr/include/x86_64-linux-gnu/bits/types/timer_t.h:
119/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:
120/usr/include/endian.h:
121/usr/include/x86_64-linux-gnu/bits/endian.h:
122/usr/include/x86_64-linux-gnu/bits/endianness.h:
123/usr/include/x86_64-linux-gnu/bits/byteswap.h:
124/usr/include/x86_64-linux-gnu/bits/uintn-identity.h:
125/usr/include/x86_64-linux-gnu/sys/select.h:
126/usr/include/x86_64-linux-gnu/bits/select.h:
127/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h:
128/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h:
129/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h:
130/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h:
131/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
132/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h:
133/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h:
134/usr/include/x86_64-linux-gnu/bits/struct_mutex.h:
135/usr/include/x86_64-linux-gnu/bits/struct_rwlock.h:
136alloca.h:
137/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
138/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
diff --git a/gl/malloc/.deps/libgnu_a-dynarray_finalize.Po b/gl/malloc/.deps/libgnu_a-dynarray_finalize.Po
new file mode 100644
index 0000000..5acee05
--- /dev/null
+++ b/gl/malloc/.deps/libgnu_a-dynarray_finalize.Po
@@ -0,0 +1,116 @@
1malloc/libgnu_a-dynarray_finalize.o: malloc/dynarray_finalize.c \
2 /usr/include/stdc-predef.h libc-config.h ../config.h \
3 /usr/include/errno.h /usr/include/features.h \
4 /usr/include/features-time64.h \
5 /usr/include/x86_64-linux-gnu/bits/wordsize.h \
6 /usr/include/x86_64-linux-gnu/bits/timesize.h \
7 /usr/include/x86_64-linux-gnu/sys/cdefs.h \
8 /usr/include/x86_64-linux-gnu/bits/long-double.h \
9 /usr/include/x86_64-linux-gnu/gnu/stubs.h \
10 /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
11 /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
12 /usr/include/x86_64-linux-gnu/asm/errno.h \
13 /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
14 /usr/include/x86_64-linux-gnu/bits/types/error_t.h cdefs.h dynarray.h \
15 malloc/dynarray.h stdbool.h \
16 /usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h string.h \
17 /usr/include/string.h \
18 /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
19 /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
20 /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h strings.h \
21 /usr/include/strings.h stdlib.h /usr/include/stdlib.h \
22 /usr/include/x86_64-linux-gnu/bits/waitflags.h \
23 /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
24 /usr/include/x86_64-linux-gnu/bits/floatn.h \
25 /usr/include/x86_64-linux-gnu/bits/floatn-common.h sys/types.h \
26 /usr/include/x86_64-linux-gnu/sys/types.h \
27 /usr/include/x86_64-linux-gnu/bits/types.h \
28 /usr/include/x86_64-linux-gnu/bits/typesizes.h \
29 /usr/include/x86_64-linux-gnu/bits/time64.h \
30 /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
31 /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
32 /usr/include/x86_64-linux-gnu/bits/types/time_t.h \
33 /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
34 /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \
35 /usr/include/x86_64-linux-gnu/bits/endian.h \
36 /usr/include/x86_64-linux-gnu/bits/endianness.h \
37 /usr/include/x86_64-linux-gnu/bits/byteswap.h \
38 /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
39 /usr/include/x86_64-linux-gnu/sys/select.h \
40 /usr/include/x86_64-linux-gnu/bits/select.h \
41 /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
42 /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
43 /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
44 /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
45 /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
46 /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
47 /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
48 /usr/include/x86_64-linux-gnu/bits/struct_mutex.h \
49 /usr/include/x86_64-linux-gnu/bits/struct_rwlock.h alloca.h \
50 /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
51 /usr/include/x86_64-linux-gnu/bits/stdlib-float.h
52/usr/include/stdc-predef.h:
53libc-config.h:
54../config.h:
55/usr/include/errno.h:
56/usr/include/features.h:
57/usr/include/features-time64.h:
58/usr/include/x86_64-linux-gnu/bits/wordsize.h:
59/usr/include/x86_64-linux-gnu/bits/timesize.h:
60/usr/include/x86_64-linux-gnu/sys/cdefs.h:
61/usr/include/x86_64-linux-gnu/bits/long-double.h:
62/usr/include/x86_64-linux-gnu/gnu/stubs.h:
63/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
64/usr/include/x86_64-linux-gnu/bits/errno.h:
65/usr/include/linux/errno.h:
66/usr/include/x86_64-linux-gnu/asm/errno.h:
67/usr/include/asm-generic/errno.h:
68/usr/include/asm-generic/errno-base.h:
69/usr/include/x86_64-linux-gnu/bits/types/error_t.h:
70cdefs.h:
71dynarray.h:
72malloc/dynarray.h:
73stdbool.h:
74/usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h:
75string.h:
76/usr/include/string.h:
77/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:
78/usr/include/x86_64-linux-gnu/bits/types/locale_t.h:
79/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:
80strings.h:
81/usr/include/strings.h:
82stdlib.h:
83/usr/include/stdlib.h:
84/usr/include/x86_64-linux-gnu/bits/waitflags.h:
85/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
86/usr/include/x86_64-linux-gnu/bits/floatn.h:
87/usr/include/x86_64-linux-gnu/bits/floatn-common.h:
88sys/types.h:
89/usr/include/x86_64-linux-gnu/sys/types.h:
90/usr/include/x86_64-linux-gnu/bits/types.h:
91/usr/include/x86_64-linux-gnu/bits/typesizes.h:
92/usr/include/x86_64-linux-gnu/bits/time64.h:
93/usr/include/x86_64-linux-gnu/bits/types/clock_t.h:
94/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h:
95/usr/include/x86_64-linux-gnu/bits/types/time_t.h:
96/usr/include/x86_64-linux-gnu/bits/types/timer_t.h:
97/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:
98/usr/include/endian.h:
99/usr/include/x86_64-linux-gnu/bits/endian.h:
100/usr/include/x86_64-linux-gnu/bits/endianness.h:
101/usr/include/x86_64-linux-gnu/bits/byteswap.h:
102/usr/include/x86_64-linux-gnu/bits/uintn-identity.h:
103/usr/include/x86_64-linux-gnu/sys/select.h:
104/usr/include/x86_64-linux-gnu/bits/select.h:
105/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h:
106/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h:
107/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h:
108/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h:
109/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
110/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h:
111/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h:
112/usr/include/x86_64-linux-gnu/bits/struct_mutex.h:
113/usr/include/x86_64-linux-gnu/bits/struct_rwlock.h:
114alloca.h:
115/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
116/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
diff --git a/gl/malloc/.deps/libgnu_a-dynarray_resize.Po b/gl/malloc/.deps/libgnu_a-dynarray_resize.Po
new file mode 100644
index 0000000..2ab00d0
--- /dev/null
+++ b/gl/malloc/.deps/libgnu_a-dynarray_resize.Po
@@ -0,0 +1,138 @@
1malloc/libgnu_a-dynarray_resize.o: malloc/dynarray_resize.c \
2 /usr/include/stdc-predef.h libc-config.h ../config.h \
3 /usr/include/errno.h /usr/include/features.h \
4 /usr/include/features-time64.h \
5 /usr/include/x86_64-linux-gnu/bits/wordsize.h \
6 /usr/include/x86_64-linux-gnu/bits/timesize.h \
7 /usr/include/x86_64-linux-gnu/sys/cdefs.h \
8 /usr/include/x86_64-linux-gnu/bits/long-double.h \
9 /usr/include/x86_64-linux-gnu/gnu/stubs.h \
10 /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
11 /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
12 /usr/include/x86_64-linux-gnu/asm/errno.h \
13 /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
14 /usr/include/x86_64-linux-gnu/bits/types/error_t.h cdefs.h dynarray.h \
15 malloc/dynarray.h stdbool.h \
16 /usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h string.h \
17 /usr/include/string.h \
18 /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
19 /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
20 /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h strings.h \
21 /usr/include/strings.h intprops.h intprops-internal.h limits.h \
22 /usr/lib/gcc/x86_64-linux-gnu/12/include/limits.h \
23 /usr/lib/gcc/x86_64-linux-gnu/12/include/syslimits.h \
24 /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \
25 /usr/include/x86_64-linux-gnu/bits/local_lim.h \
26 /usr/include/linux/limits.h \
27 /usr/include/x86_64-linux-gnu/bits/pthread_stack_min-dynamic.h \
28 /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \
29 /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \
30 /usr/include/x86_64-linux-gnu/bits/uio_lim.h stdlib.h \
31 /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \
32 /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
33 /usr/include/x86_64-linux-gnu/bits/floatn.h \
34 /usr/include/x86_64-linux-gnu/bits/floatn-common.h sys/types.h \
35 /usr/include/x86_64-linux-gnu/sys/types.h \
36 /usr/include/x86_64-linux-gnu/bits/types.h \
37 /usr/include/x86_64-linux-gnu/bits/typesizes.h \
38 /usr/include/x86_64-linux-gnu/bits/time64.h \
39 /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
40 /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
41 /usr/include/x86_64-linux-gnu/bits/types/time_t.h \
42 /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
43 /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \
44 /usr/include/x86_64-linux-gnu/bits/endian.h \
45 /usr/include/x86_64-linux-gnu/bits/endianness.h \
46 /usr/include/x86_64-linux-gnu/bits/byteswap.h \
47 /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
48 /usr/include/x86_64-linux-gnu/sys/select.h \
49 /usr/include/x86_64-linux-gnu/bits/select.h \
50 /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
51 /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
52 /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
53 /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
54 /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
55 /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
56 /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
57 /usr/include/x86_64-linux-gnu/bits/struct_mutex.h \
58 /usr/include/x86_64-linux-gnu/bits/struct_rwlock.h alloca.h \
59 /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
60 /usr/include/x86_64-linux-gnu/bits/stdlib-float.h
61/usr/include/stdc-predef.h:
62libc-config.h:
63../config.h:
64/usr/include/errno.h:
65/usr/include/features.h:
66/usr/include/features-time64.h:
67/usr/include/x86_64-linux-gnu/bits/wordsize.h:
68/usr/include/x86_64-linux-gnu/bits/timesize.h:
69/usr/include/x86_64-linux-gnu/sys/cdefs.h:
70/usr/include/x86_64-linux-gnu/bits/long-double.h:
71/usr/include/x86_64-linux-gnu/gnu/stubs.h:
72/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
73/usr/include/x86_64-linux-gnu/bits/errno.h:
74/usr/include/linux/errno.h:
75/usr/include/x86_64-linux-gnu/asm/errno.h:
76/usr/include/asm-generic/errno.h:
77/usr/include/asm-generic/errno-base.h:
78/usr/include/x86_64-linux-gnu/bits/types/error_t.h:
79cdefs.h:
80dynarray.h:
81malloc/dynarray.h:
82stdbool.h:
83/usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h:
84string.h:
85/usr/include/string.h:
86/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:
87/usr/include/x86_64-linux-gnu/bits/types/locale_t.h:
88/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:
89strings.h:
90/usr/include/strings.h:
91intprops.h:
92intprops-internal.h:
93limits.h:
94/usr/lib/gcc/x86_64-linux-gnu/12/include/limits.h:
95/usr/lib/gcc/x86_64-linux-gnu/12/include/syslimits.h:
96/usr/include/limits.h:
97/usr/include/x86_64-linux-gnu/bits/posix1_lim.h:
98/usr/include/x86_64-linux-gnu/bits/local_lim.h:
99/usr/include/linux/limits.h:
100/usr/include/x86_64-linux-gnu/bits/pthread_stack_min-dynamic.h:
101/usr/include/x86_64-linux-gnu/bits/posix2_lim.h:
102/usr/include/x86_64-linux-gnu/bits/xopen_lim.h:
103/usr/include/x86_64-linux-gnu/bits/uio_lim.h:
104stdlib.h:
105/usr/include/stdlib.h:
106/usr/include/x86_64-linux-gnu/bits/waitflags.h:
107/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
108/usr/include/x86_64-linux-gnu/bits/floatn.h:
109/usr/include/x86_64-linux-gnu/bits/floatn-common.h:
110sys/types.h:
111/usr/include/x86_64-linux-gnu/sys/types.h:
112/usr/include/x86_64-linux-gnu/bits/types.h:
113/usr/include/x86_64-linux-gnu/bits/typesizes.h:
114/usr/include/x86_64-linux-gnu/bits/time64.h:
115/usr/include/x86_64-linux-gnu/bits/types/clock_t.h:
116/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h:
117/usr/include/x86_64-linux-gnu/bits/types/time_t.h:
118/usr/include/x86_64-linux-gnu/bits/types/timer_t.h:
119/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:
120/usr/include/endian.h:
121/usr/include/x86_64-linux-gnu/bits/endian.h:
122/usr/include/x86_64-linux-gnu/bits/endianness.h:
123/usr/include/x86_64-linux-gnu/bits/byteswap.h:
124/usr/include/x86_64-linux-gnu/bits/uintn-identity.h:
125/usr/include/x86_64-linux-gnu/sys/select.h:
126/usr/include/x86_64-linux-gnu/bits/select.h:
127/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h:
128/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h:
129/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h:
130/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h:
131/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
132/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h:
133/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h:
134/usr/include/x86_64-linux-gnu/bits/struct_mutex.h:
135/usr/include/x86_64-linux-gnu/bits/struct_rwlock.h:
136alloca.h:
137/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
138/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
diff --git a/gl/malloc/.deps/libgnu_a-dynarray_resize_clear.Po b/gl/malloc/.deps/libgnu_a-dynarray_resize_clear.Po
new file mode 100644
index 0000000..5af37ac
--- /dev/null
+++ b/gl/malloc/.deps/libgnu_a-dynarray_resize_clear.Po
@@ -0,0 +1,51 @@
1malloc/libgnu_a-dynarray_resize_clear.o: malloc/dynarray_resize_clear.c \
2 /usr/include/stdc-predef.h libc-config.h ../config.h \
3 /usr/include/errno.h /usr/include/features.h \
4 /usr/include/features-time64.h \
5 /usr/include/x86_64-linux-gnu/bits/wordsize.h \
6 /usr/include/x86_64-linux-gnu/bits/timesize.h \
7 /usr/include/x86_64-linux-gnu/sys/cdefs.h \
8 /usr/include/x86_64-linux-gnu/bits/long-double.h \
9 /usr/include/x86_64-linux-gnu/gnu/stubs.h \
10 /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
11 /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
12 /usr/include/x86_64-linux-gnu/asm/errno.h \
13 /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
14 /usr/include/x86_64-linux-gnu/bits/types/error_t.h cdefs.h dynarray.h \
15 malloc/dynarray.h stdbool.h \
16 /usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h string.h \
17 /usr/include/string.h \
18 /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
19 /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
20 /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h strings.h \
21 /usr/include/strings.h
22/usr/include/stdc-predef.h:
23libc-config.h:
24../config.h:
25/usr/include/errno.h:
26/usr/include/features.h:
27/usr/include/features-time64.h:
28/usr/include/x86_64-linux-gnu/bits/wordsize.h:
29/usr/include/x86_64-linux-gnu/bits/timesize.h:
30/usr/include/x86_64-linux-gnu/sys/cdefs.h:
31/usr/include/x86_64-linux-gnu/bits/long-double.h:
32/usr/include/x86_64-linux-gnu/gnu/stubs.h:
33/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
34/usr/include/x86_64-linux-gnu/bits/errno.h:
35/usr/include/linux/errno.h:
36/usr/include/x86_64-linux-gnu/asm/errno.h:
37/usr/include/asm-generic/errno.h:
38/usr/include/asm-generic/errno-base.h:
39/usr/include/x86_64-linux-gnu/bits/types/error_t.h:
40cdefs.h:
41dynarray.h:
42malloc/dynarray.h:
43stdbool.h:
44/usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h:
45string.h:
46/usr/include/string.h:
47/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:
48/usr/include/x86_64-linux-gnu/bits/types/locale_t.h:
49/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:
50strings.h:
51/usr/include/strings.h:
diff --git a/gl/malloc/.dirstamp b/gl/malloc/.dirstamp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/gl/malloc/.dirstamp
diff --git a/gl/malloc/dynarray-skeleton.gl.h b/gl/malloc/dynarray-skeleton.gl.h
new file mode 100644
index 0000000..6eb7690
--- /dev/null
+++ b/gl/malloc/dynarray-skeleton.gl.h
@@ -0,0 +1,529 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* Type-safe arrays which grow dynamically.
3 Copyright (C) 2017-2022 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
19
20/* Pre-processor macros which act as parameters:
21
22 DYNARRAY_STRUCT
23 The struct tag of dynamic array to be defined.
24 DYNARRAY_ELEMENT
25 The type name of the element type. Elements are copied
26 as if by memcpy, and can change address as the dynamic
27 array grows.
28 DYNARRAY_PREFIX
29 The prefix of the functions which are defined.
30
31 The following parameters are optional:
32
33 DYNARRAY_ELEMENT_FREE
34 DYNARRAY_ELEMENT_FREE (E) is evaluated to deallocate the
35 contents of elements. E is of type DYNARRAY_ELEMENT *.
36 DYNARRAY_ELEMENT_INIT
37 DYNARRAY_ELEMENT_INIT (E) is evaluated to initialize a new
38 element. E is of type DYNARRAY_ELEMENT *.
39 If DYNARRAY_ELEMENT_FREE but not DYNARRAY_ELEMENT_INIT is
40 defined, new elements are automatically zero-initialized.
41 Otherwise, new elements have undefined contents.
42 DYNARRAY_INITIAL_SIZE
43 The size of the statically allocated array (default:
44 at least 2, more elements if they fit into 128 bytes).
45 Must be a preprocessor constant. If DYNARRAY_INITIAL_SIZE is 0,
46 there is no statically allocated array at, and all non-empty
47 arrays are heap-allocated.
48 DYNARRAY_FINAL_TYPE
49 The name of the type which holds the final array. If not
50 defined, is PREFIX##finalize not provided. DYNARRAY_FINAL_TYPE
51 must be a struct type, with members of type DYNARRAY_ELEMENT and
52 size_t at the start (in this order).
53
54 These macros are undefined after this header file has been
55 included.
56
57 The following types are provided (their members are private to the
58 dynarray implementation):
59
60 struct DYNARRAY_STRUCT
61
62 The following functions are provided:
63
64 void DYNARRAY_PREFIX##init (struct DYNARRAY_STRUCT *);
65 void DYNARRAY_PREFIX##free (struct DYNARRAY_STRUCT *);
66 bool DYNARRAY_PREFIX##has_failed (const struct DYNARRAY_STRUCT *);
67 void DYNARRAY_PREFIX##mark_failed (struct DYNARRAY_STRUCT *);
68 size_t DYNARRAY_PREFIX##size (const struct DYNARRAY_STRUCT *);
69 DYNARRAY_ELEMENT *DYNARRAY_PREFIX##begin (const struct DYNARRAY_STRUCT *);
70 DYNARRAY_ELEMENT *DYNARRAY_PREFIX##end (const struct DYNARRAY_STRUCT *);
71 DYNARRAY_ELEMENT *DYNARRAY_PREFIX##at (struct DYNARRAY_STRUCT *, size_t);
72 void DYNARRAY_PREFIX##add (struct DYNARRAY_STRUCT *, DYNARRAY_ELEMENT);
73 DYNARRAY_ELEMENT *DYNARRAY_PREFIX##emplace (struct DYNARRAY_STRUCT *);
74 bool DYNARRAY_PREFIX##resize (struct DYNARRAY_STRUCT *, size_t);
75 void DYNARRAY_PREFIX##remove_last (struct DYNARRAY_STRUCT *);
76 void DYNARRAY_PREFIX##clear (struct DYNARRAY_STRUCT *);
77
78 The following functions are provided are provided if the
79 prerequisites are met:
80
81 bool DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *,
82 DYNARRAY_FINAL_TYPE *);
83 (if DYNARRAY_FINAL_TYPE is defined)
84 DYNARRAY_ELEMENT *DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *,
85 size_t *);
86 (if DYNARRAY_FINAL_TYPE is not defined)
87*/
88
89#include <malloc/dynarray.gl.h>
90
91#include <errno.h>
92#include <stdlib.h>
93#include <string.h>
94
95#ifndef DYNARRAY_STRUCT
96# error "DYNARRAY_STRUCT must be defined"
97#endif
98
99#ifndef DYNARRAY_ELEMENT
100# error "DYNARRAY_ELEMENT must be defined"
101#endif
102
103#ifndef DYNARRAY_PREFIX
104# error "DYNARRAY_PREFIX must be defined"
105#endif
106
107#ifdef DYNARRAY_INITIAL_SIZE
108# if DYNARRAY_INITIAL_SIZE < 0
109# error "DYNARRAY_INITIAL_SIZE must be non-negative"
110# endif
111# if DYNARRAY_INITIAL_SIZE > 0
112# define DYNARRAY_HAVE_SCRATCH 1
113# else
114# define DYNARRAY_HAVE_SCRATCH 0
115# endif
116#else
117/* Provide a reasonable default which limits the size of
118 DYNARRAY_STRUCT. */
119# define DYNARRAY_INITIAL_SIZE \
120 (sizeof (DYNARRAY_ELEMENT) > 64 ? 2 : 128 / sizeof (DYNARRAY_ELEMENT))
121# define DYNARRAY_HAVE_SCRATCH 1
122#endif
123
124/* Public type definitions. */
125
126/* All fields of this struct are private to the implementation. */
127struct DYNARRAY_STRUCT
128{
129 union
130 {
131 struct dynarray_header dynarray_abstract;
132 struct
133 {
134 /* These fields must match struct dynarray_header. */
135 size_t used;
136 size_t allocated;
137 DYNARRAY_ELEMENT *array;
138 } dynarray_header;
139 } u;
140
141#if DYNARRAY_HAVE_SCRATCH
142 /* Initial inline allocation. */
143 DYNARRAY_ELEMENT scratch[DYNARRAY_INITIAL_SIZE];
144#endif
145};
146
147/* Internal use only: Helper macros. */
148
149/* Ensure macro-expansion of DYNARRAY_PREFIX. */
150#define DYNARRAY_CONCAT0(prefix, name) prefix##name
151#define DYNARRAY_CONCAT1(prefix, name) DYNARRAY_CONCAT0(prefix, name)
152#define DYNARRAY_NAME(name) DYNARRAY_CONCAT1(DYNARRAY_PREFIX, name)
153
154/* Use DYNARRAY_FREE instead of DYNARRAY_NAME (free),
155 so that Gnulib does not change 'free' to 'rpl_free'. */
156#define DYNARRAY_FREE DYNARRAY_CONCAT1 (DYNARRAY_NAME (f), ree)
157
158/* Address of the scratch buffer if any. */
159#if DYNARRAY_HAVE_SCRATCH
160# define DYNARRAY_SCRATCH(list) (list)->scratch
161#else
162# define DYNARRAY_SCRATCH(list) NULL
163#endif
164
165/* Internal use only: Helper functions. */
166
167/* Internal function. Call DYNARRAY_ELEMENT_FREE with the array
168 elements. Name mangling needed due to the DYNARRAY_ELEMENT_FREE
169 macro expansion. */
170static inline void
171DYNARRAY_NAME (free__elements__) (DYNARRAY_ELEMENT *__dynarray_array,
172 size_t __dynarray_used)
173{
174#ifdef DYNARRAY_ELEMENT_FREE
175 for (size_t __dynarray_i = 0; __dynarray_i < __dynarray_used; ++__dynarray_i)
176 DYNARRAY_ELEMENT_FREE (&__dynarray_array[__dynarray_i]);
177#endif /* DYNARRAY_ELEMENT_FREE */
178}
179
180/* Internal function. Free the non-scratch array allocation. */
181static inline void
182DYNARRAY_NAME (free__array__) (struct DYNARRAY_STRUCT *list)
183{
184#if DYNARRAY_HAVE_SCRATCH
185 if (list->u.dynarray_header.array != list->scratch)
186 free (list->u.dynarray_header.array);
187#else
188 free (list->u.dynarray_header.array);
189#endif
190}
191
192/* Public functions. */
193
194/* Initialize a dynamic array object. This must be called before any
195 use of the object. */
196_GL_ATTRIBUTE_NONNULL ((1))
197static void
198DYNARRAY_NAME (init) (struct DYNARRAY_STRUCT *list)
199{
200 list->u.dynarray_header.used = 0;
201 list->u.dynarray_header.allocated = DYNARRAY_INITIAL_SIZE;
202 list->u.dynarray_header.array = DYNARRAY_SCRATCH (list);
203}
204
205/* Deallocate the dynamic array and its elements. */
206_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NONNULL ((1))
207static void
208DYNARRAY_FREE (struct DYNARRAY_STRUCT *list)
209{
210 DYNARRAY_NAME (free__elements__)
211 (list->u.dynarray_header.array, list->u.dynarray_header.used);
212 DYNARRAY_NAME (free__array__) (list);
213 DYNARRAY_NAME (init) (list);
214}
215
216/* Return true if the dynamic array is in an error state. */
217_GL_ATTRIBUTE_NONNULL ((1))
218static inline bool
219DYNARRAY_NAME (has_failed) (const struct DYNARRAY_STRUCT *list)
220{
221 return list->u.dynarray_header.allocated == __dynarray_error_marker ();
222}
223
224/* Mark the dynamic array as failed. All elements are deallocated as
225 a side effect. */
226_GL_ATTRIBUTE_NONNULL ((1))
227static void
228DYNARRAY_NAME (mark_failed) (struct DYNARRAY_STRUCT *list)
229{
230 DYNARRAY_NAME (free__elements__)
231 (list->u.dynarray_header.array, list->u.dynarray_header.used);
232 DYNARRAY_NAME (free__array__) (list);
233 list->u.dynarray_header.array = DYNARRAY_SCRATCH (list);
234 list->u.dynarray_header.used = 0;
235 list->u.dynarray_header.allocated = __dynarray_error_marker ();
236}
237
238/* Return the number of elements which have been added to the dynamic
239 array. */
240_GL_ATTRIBUTE_NONNULL ((1))
241static inline size_t
242DYNARRAY_NAME (size) (const struct DYNARRAY_STRUCT *list)
243{
244 return list->u.dynarray_header.used;
245}
246
247/* Return a pointer to the array element at INDEX. Terminate the
248 process if INDEX is out of bounds. */
249_GL_ATTRIBUTE_NONNULL ((1))
250static inline DYNARRAY_ELEMENT *
251DYNARRAY_NAME (at) (struct DYNARRAY_STRUCT *list, size_t index)
252{
253 if (_GL_UNLIKELY (index >= DYNARRAY_NAME (size) (list)))
254 __libc_dynarray_at_failure (DYNARRAY_NAME (size) (list), index);
255 return list->u.dynarray_header.array + index;
256}
257
258/* Return a pointer to the first array element, if any. For a
259 zero-length array, the pointer can be NULL even though the dynamic
260 array has not entered the failure state. */
261_GL_ATTRIBUTE_NONNULL ((1))
262static inline DYNARRAY_ELEMENT *
263DYNARRAY_NAME (begin) (struct DYNARRAY_STRUCT *list)
264{
265 return list->u.dynarray_header.array;
266}
267
268/* Return a pointer one element past the last array element. For a
269 zero-length array, the pointer can be NULL even though the dynamic
270 array has not entered the failure state. */
271_GL_ATTRIBUTE_NONNULL ((1))
272static inline DYNARRAY_ELEMENT *
273DYNARRAY_NAME (end) (struct DYNARRAY_STRUCT *list)
274{
275 return list->u.dynarray_header.array + list->u.dynarray_header.used;
276}
277
278/* Internal function. Slow path for the add function below. */
279static void
280DYNARRAY_NAME (add__) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
281{
282 if (_GL_UNLIKELY
283 (!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract,
284 DYNARRAY_SCRATCH (list),
285 sizeof (DYNARRAY_ELEMENT))))
286 {
287 DYNARRAY_NAME (mark_failed) (list);
288 return;
289 }
290
291 /* Copy the new element and increase the array length. */
292 list->u.dynarray_header.array[list->u.dynarray_header.used++] = item;
293}
294
295/* Add ITEM at the end of the array, enlarging it by one element.
296 Mark *LIST as failed if the dynamic array allocation size cannot be
297 increased. */
298_GL_ATTRIBUTE_NONNULL ((1))
299static inline void
300DYNARRAY_NAME (add) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
301{
302 /* Do nothing in case of previous error. */
303 if (DYNARRAY_NAME (has_failed) (list))
304 return;
305
306 /* Enlarge the array if necessary. */
307 if (_GL_UNLIKELY (list->u.dynarray_header.used
308 == list->u.dynarray_header.allocated))
309 {
310 DYNARRAY_NAME (add__) (list, item);
311 return;
312 }
313
314 /* Copy the new element and increase the array length. */
315 list->u.dynarray_header.array[list->u.dynarray_header.used++] = item;
316}
317
318/* Internal function. Building block for the emplace functions below.
319 Assumes space for one more element in *LIST. */
320static inline DYNARRAY_ELEMENT *
321DYNARRAY_NAME (emplace__tail__) (struct DYNARRAY_STRUCT *list)
322{
323 DYNARRAY_ELEMENT *result
324 = &list->u.dynarray_header.array[list->u.dynarray_header.used];
325 ++list->u.dynarray_header.used;
326#if defined (DYNARRAY_ELEMENT_INIT)
327 DYNARRAY_ELEMENT_INIT (result);
328#elif defined (DYNARRAY_ELEMENT_FREE)
329 memset (result, 0, sizeof (*result));
330#endif
331 return result;
332}
333
334/* Internal function. Slow path for the emplace function below. */
335static DYNARRAY_ELEMENT *
336DYNARRAY_NAME (emplace__) (struct DYNARRAY_STRUCT *list)
337{
338 if (_GL_UNLIKELY
339 (!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract,
340 DYNARRAY_SCRATCH (list),
341 sizeof (DYNARRAY_ELEMENT))))
342 {
343 DYNARRAY_NAME (mark_failed) (list);
344 return NULL;
345 }
346 return DYNARRAY_NAME (emplace__tail__) (list);
347}
348
349/* Allocate a place for a new element in *LIST and return a pointer to
350 it. The pointer can be NULL if the dynamic array cannot be
351 enlarged due to a memory allocation failure. */
352_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NODISCARD
353_GL_ATTRIBUTE_NONNULL ((1))
354static
355/* Avoid inlining with the larger initialization code. */
356#if !(defined (DYNARRAY_ELEMENT_INIT) || defined (DYNARRAY_ELEMENT_FREE))
357inline
358#endif
359DYNARRAY_ELEMENT *
360DYNARRAY_NAME (emplace) (struct DYNARRAY_STRUCT *list)
361{
362 /* Do nothing in case of previous error. */
363 if (DYNARRAY_NAME (has_failed) (list))
364 return NULL;
365
366 /* Enlarge the array if necessary. */
367 if (_GL_UNLIKELY (list->u.dynarray_header.used
368 == list->u.dynarray_header.allocated))
369 return (DYNARRAY_NAME (emplace__) (list));
370 return DYNARRAY_NAME (emplace__tail__) (list);
371}
372
373/* Change the size of *LIST to SIZE. If SIZE is larger than the
374 existing size, new elements are added (which can be initialized).
375 Otherwise, the list is truncated, and elements are freed. Return
376 false on memory allocation failure (and mark *LIST as failed). */
377_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NONNULL ((1))
378static bool
379DYNARRAY_NAME (resize) (struct DYNARRAY_STRUCT *list, size_t size)
380{
381 if (size > list->u.dynarray_header.used)
382 {
383 bool ok;
384#if defined (DYNARRAY_ELEMENT_INIT)
385 /* The new elements have to be initialized. */
386 size_t old_size = list->u.dynarray_header.used;
387 ok = __libc_dynarray_resize (&list->u.dynarray_abstract,
388 size, DYNARRAY_SCRATCH (list),
389 sizeof (DYNARRAY_ELEMENT));
390 if (ok)
391 for (size_t i = old_size; i < size; ++i)
392 {
393 DYNARRAY_ELEMENT_INIT (&list->u.dynarray_header.array[i]);
394 }
395#elif defined (DYNARRAY_ELEMENT_FREE)
396 /* Zero initialization is needed so that the elements can be
397 safely freed. */
398 ok = __libc_dynarray_resize_clear
399 (&list->u.dynarray_abstract, size,
400 DYNARRAY_SCRATCH (list), sizeof (DYNARRAY_ELEMENT));
401#else
402 ok = __libc_dynarray_resize (&list->u.dynarray_abstract,
403 size, DYNARRAY_SCRATCH (list),
404 sizeof (DYNARRAY_ELEMENT));
405#endif
406 if (_GL_UNLIKELY (!ok))
407 DYNARRAY_NAME (mark_failed) (list);
408 return ok;
409 }
410 else
411 {
412 /* The list has shrunk in size. Free the removed elements. */
413 DYNARRAY_NAME (free__elements__)
414 (list->u.dynarray_header.array + size,
415 list->u.dynarray_header.used - size);
416 list->u.dynarray_header.used = size;
417 return true;
418 }
419}
420
421/* Remove the last element of LIST if it is present. */
422_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NONNULL ((1))
423static void
424DYNARRAY_NAME (remove_last) (struct DYNARRAY_STRUCT *list)
425{
426 /* used > 0 implies that the array is the non-failed state. */
427 if (list->u.dynarray_header.used > 0)
428 {
429 size_t new_length = list->u.dynarray_header.used - 1;
430#ifdef DYNARRAY_ELEMENT_FREE
431 DYNARRAY_ELEMENT_FREE (&list->u.dynarray_header.array[new_length]);
432#endif
433 list->u.dynarray_header.used = new_length;
434 }
435}
436
437/* Remove all elements from the list. The elements are freed, but the
438 list itself is not. */
439_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NONNULL ((1))
440static void
441DYNARRAY_NAME (clear) (struct DYNARRAY_STRUCT *list)
442{
443 /* free__elements__ does nothing if the list is in the failed
444 state. */
445 DYNARRAY_NAME (free__elements__)
446 (list->u.dynarray_header.array, list->u.dynarray_header.used);
447 list->u.dynarray_header.used = 0;
448}
449
450#ifdef DYNARRAY_FINAL_TYPE
451/* Transfer the dynamic array to a permanent location at *RESULT.
452 Returns true on success on false on allocation failure. In either
453 case, *LIST is re-initialized and can be reused. A NULL pointer is
454 stored in *RESULT if LIST refers to an empty list. On success, the
455 pointer in *RESULT is heap-allocated and must be deallocated using
456 free. */
457_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NODISCARD
458_GL_ATTRIBUTE_NONNULL ((1, 2))
459static bool
460DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list,
461 DYNARRAY_FINAL_TYPE *result)
462{
463 struct dynarray_finalize_result res;
464 if (__libc_dynarray_finalize (&list->u.dynarray_abstract,
465 DYNARRAY_SCRATCH (list),
466 sizeof (DYNARRAY_ELEMENT), &res))
467 {
468 /* On success, the result owns all the data. */
469 DYNARRAY_NAME (init) (list);
470 *result = (DYNARRAY_FINAL_TYPE) { res.array, res.length };
471 return true;
472 }
473 else
474 {
475 /* On error, we need to free all data. */
476 DYNARRAY_FREE (list);
477 errno = ENOMEM;
478 return false;
479 }
480}
481#else /* !DYNARRAY_FINAL_TYPE */
482/* Transfer the dynamic array to a heap-allocated array and return a
483 pointer to it. The pointer is NULL if memory allocation fails, or
484 if the array is empty, so this function should be used only for
485 arrays which are known not be empty (usually because they always
486 have a sentinel at the end). If LENGTHP is not NULL, the array
487 length is written to *LENGTHP. *LIST is re-initialized and can be
488 reused. */
489_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NODISCARD
490_GL_ATTRIBUTE_NONNULL ((1))
491static DYNARRAY_ELEMENT *
492DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, size_t *lengthp)
493{
494 struct dynarray_finalize_result res;
495 if (__libc_dynarray_finalize (&list->u.dynarray_abstract,
496 DYNARRAY_SCRATCH (list),
497 sizeof (DYNARRAY_ELEMENT), &res))
498 {
499 /* On success, the result owns all the data. */
500 DYNARRAY_NAME (init) (list);
501 if (lengthp != NULL)
502 *lengthp = res.length;
503 return res.array;
504 }
505 else
506 {
507 /* On error, we need to free all data. */
508 DYNARRAY_FREE (list);
509 errno = ENOMEM;
510 return NULL;
511 }
512}
513#endif /* !DYNARRAY_FINAL_TYPE */
514
515/* Undo macro definitions. */
516
517#undef DYNARRAY_CONCAT0
518#undef DYNARRAY_CONCAT1
519#undef DYNARRAY_NAME
520#undef DYNARRAY_SCRATCH
521#undef DYNARRAY_HAVE_SCRATCH
522
523#undef DYNARRAY_STRUCT
524#undef DYNARRAY_ELEMENT
525#undef DYNARRAY_PREFIX
526#undef DYNARRAY_ELEMENT_FREE
527#undef DYNARRAY_ELEMENT_INIT
528#undef DYNARRAY_INITIAL_SIZE
529#undef DYNARRAY_FINAL_TYPE
diff --git a/gl/malloc/dynarray.gl.h b/gl/malloc/dynarray.gl.h
new file mode 100644
index 0000000..24897b2
--- /dev/null
+++ b/gl/malloc/dynarray.gl.h
@@ -0,0 +1,174 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* Type-safe arrays which grow dynamically. Shared definitions.
3 Copyright (C) 2017-2022 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
19
20/* To use the dynarray facility, you need to include
21 <malloc/dynarray-skeleton.c> and define the parameter macros
22 documented in that file.
23
24 A minimal example which provides a growing list of integers can be
25 defined like this:
26
27 struct int_array
28 {
29 // Pointer to result array followed by its length,
30 // as required by DYNARRAY_FINAL_TYPE.
31 int *array;
32 size_t length;
33 };
34
35 #define DYNARRAY_STRUCT dynarray_int
36 #define DYNARRAY_ELEMENT int
37 #define DYNARRAY_PREFIX dynarray_int_
38 #define DYNARRAY_FINAL_TYPE struct int_array
39 #include <malloc/dynarray-skeleton.c>
40
41 To create a three-element array with elements 1, 2, 3, use this
42 code:
43
44 struct dynarray_int dyn;
45 dynarray_int_init (&dyn);
46 for (int i = 1; i <= 3; ++i)
47 {
48 int *place = dynarray_int_emplace (&dyn);
49 assert (place != NULL);
50 *place = i;
51 }
52 struct int_array result;
53 bool ok = dynarray_int_finalize (&dyn, &result);
54 assert (ok);
55 assert (result.length == 3);
56 assert (result.array[0] == 1);
57 assert (result.array[1] == 2);
58 assert (result.array[2] == 3);
59 free (result.array);
60
61 If the elements contain resources which must be freed, define
62 DYNARRAY_ELEMENT_FREE appropriately, like this:
63
64 struct str_array
65 {
66 char **array;
67 size_t length;
68 };
69
70 #define DYNARRAY_STRUCT dynarray_str
71 #define DYNARRAY_ELEMENT char *
72 #define DYNARRAY_ELEMENT_FREE(ptr) free (*ptr)
73 #define DYNARRAY_PREFIX dynarray_str_
74 #define DYNARRAY_FINAL_TYPE struct str_array
75 #include <malloc/dynarray-skeleton.c>
76
77 Compared to scratch buffers, dynamic arrays have the following
78 features:
79
80 - They have an element type, and are not just an untyped buffer of
81 bytes.
82
83 - When growing, previously stored elements are preserved. (It is
84 expected that scratch_buffer_grow_preserve and
85 scratch_buffer_set_array_size eventually go away because all
86 current users are moved to dynamic arrays.)
87
88 - Scratch buffers have a more aggressive growth policy because
89 growing them typically means a retry of an operation (across an
90 NSS service module boundary), which is expensive.
91
92 - For the same reason, scratch buffers have a much larger initial
93 stack allocation. */
94
95#ifndef _DYNARRAY_H
96#define _DYNARRAY_H
97
98#include <stdbool.h>
99#include <stddef.h>
100#include <string.h>
101
102struct dynarray_header
103{
104 size_t used;
105 size_t allocated;
106 void *array;
107};
108
109/* Marker used in the allocated member to indicate that an error was
110 encountered. */
111static inline size_t
112__dynarray_error_marker (void)
113{
114 return -1;
115}
116
117/* Internal function. See the has_failed function in
118 dynarray-skeleton.c. */
119static inline bool
120__dynarray_error (struct dynarray_header *list)
121{
122 return list->allocated == __dynarray_error_marker ();
123}
124
125/* Internal function. Enlarge the dynamically allocated area of the
126 array to make room for one more element. SCRATCH is a pointer to
127 the scratch area (which is not heap-allocated and must not be
128 freed). ELEMENT_SIZE is the size, in bytes, of one element.
129 Return false on failure, true on success. */
130bool __libc_dynarray_emplace_enlarge (struct dynarray_header *,
131 void *scratch, size_t element_size);
132
133/* Internal function. Enlarge the dynamically allocated area of the
134 array to make room for at least SIZE elements (which must be larger
135 than the existing used part of the dynamic array). SCRATCH is a
136 pointer to the scratch area (which is not heap-allocated and must
137 not be freed). ELEMENT_SIZE is the size, in bytes, of one element.
138 Return false on failure, true on success. */
139bool __libc_dynarray_resize (struct dynarray_header *, size_t size,
140 void *scratch, size_t element_size);
141
142/* Internal function. Like __libc_dynarray_resize, but clear the new
143 part of the dynamic array. */
144bool __libc_dynarray_resize_clear (struct dynarray_header *, size_t size,
145 void *scratch, size_t element_size);
146
147/* Internal type. */
148struct dynarray_finalize_result
149{
150 void *array;
151 size_t length;
152};
153
154/* Internal function. Copy the dynamically-allocated area to an
155 explicitly-sized heap allocation. SCRATCH is a pointer to the
156 embedded scratch space. ELEMENT_SIZE is the size, in bytes, of the
157 element type. On success, true is returned, and pointer and length
158 are written to *RESULT. On failure, false is returned. The caller
159 has to take care of some of the memory management; this function is
160 expected to be called from dynarray-skeleton.c. */
161bool __libc_dynarray_finalize (struct dynarray_header *list, void *scratch,
162 size_t element_size,
163 struct dynarray_finalize_result *result);
164
165
166/* Internal function. Terminate the process after an index error.
167 SIZE is the number of elements of the dynamic array. INDEX is the
168 lookup index which triggered the failure. */
169_Noreturn void __libc_dynarray_at_failure (size_t size, size_t index);
170
171#ifndef _ISOMAC
172#endif
173
174#endif /* _DYNARRAY_H */
diff --git a/gl/sha256-stream.c b/gl/sha256-stream.c
deleted file mode 100644
index c2e6398..0000000
--- a/gl/sha256-stream.c
+++ /dev/null
@@ -1,145 +0,0 @@
1/* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-2.
3
4 Copyright (C) 2005-2006, 2008-2022 Free Software Foundation, Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19/* Written by David Madore, considerably copypasting from
20 Scott G. Miller's sha1.c
21*/
22
23#include <config.h>
24
25/* Specification. */
26#if HAVE_OPENSSL_SHA256
27# define GL_OPENSSL_INLINE _GL_EXTERN_INLINE
28#endif
29#include "sha256.h"
30
31#include <stdlib.h>
32
33#if USE_UNLOCKED_IO
34# include "unlocked-io.h"
35#endif
36
37#include "af_alg.h"
38
39#define BLOCKSIZE 32768
40#if BLOCKSIZE % 64 != 0
41# error "invalid BLOCKSIZE"
42#endif
43
44/* Compute message digest for bytes read from STREAM using algorithm ALG.
45 Write the message digest into RESBLOCK, which contains HASHLEN bytes.
46 The initial and finishing operations are INIT_CTX and FINISH_CTX.
47 Return zero if and only if successful. */
48static int
49shaxxx_stream (FILE *stream, char const *alg, void *resblock,
50 ssize_t hashlen, void (*init_ctx) (struct sha256_ctx *),
51 void *(*finish_ctx) (struct sha256_ctx *, void *))
52{
53 switch (afalg_stream (stream, alg, resblock, hashlen))
54 {
55 case 0: return 0;
56 case -EIO: return 1;
57 }
58
59 char *buffer = malloc (BLOCKSIZE + 72);
60 if (!buffer)
61 return 1;
62
63 struct sha256_ctx ctx;
64 init_ctx (&ctx);
65 size_t sum;
66
67 /* Iterate over full file contents. */
68 while (1)
69 {
70 /* We read the file in blocks of BLOCKSIZE bytes. One call of the
71 computation function processes the whole buffer so that with the
72 next round of the loop another block can be read. */
73 size_t n;
74 sum = 0;
75
76 /* Read block. Take care for partial reads. */
77 while (1)
78 {
79 /* Either process a partial fread() from this loop,
80 or the fread() in afalg_stream may have gotten EOF.
81 We need to avoid a subsequent fread() as EOF may
82 not be sticky. For details of such systems, see:
83 https://sourceware.org/bugzilla/show_bug.cgi?id=1190 */
84 if (feof (stream))
85 goto process_partial_block;
86
87 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
88
89 sum += n;
90
91 if (sum == BLOCKSIZE)
92 break;
93
94 if (n == 0)
95 {
96 /* Check for the error flag IFF N == 0, so that we don't
97 exit the loop after a partial read due to e.g., EAGAIN
98 or EWOULDBLOCK. */
99 if (ferror (stream))
100 {
101 free (buffer);
102 return 1;
103 }
104 goto process_partial_block;
105 }
106 }
107
108 /* Process buffer with BLOCKSIZE bytes. Note that
109 BLOCKSIZE % 64 == 0
110 */
111 sha256_process_block (buffer, BLOCKSIZE, &ctx);
112 }
113
114 process_partial_block:;
115
116 /* Process any remaining bytes. */
117 if (sum > 0)
118 sha256_process_bytes (buffer, sum, &ctx);
119
120 /* Construct result in desired memory. */
121 finish_ctx (&ctx, resblock);
122 free (buffer);
123 return 0;
124}
125
126int
127sha256_stream (FILE *stream, void *resblock)
128{
129 return shaxxx_stream (stream, "sha256", resblock, SHA256_DIGEST_SIZE,
130 sha256_init_ctx, sha256_finish_ctx);
131}
132
133int
134sha224_stream (FILE *stream, void *resblock)
135{
136 return shaxxx_stream (stream, "sha224", resblock, SHA224_DIGEST_SIZE,
137 sha224_init_ctx, sha224_finish_ctx);
138}
139
140/*
141 * Hey Emacs!
142 * Local Variables:
143 * coding: utf-8
144 * End:
145 */
diff --git a/gl/sha256.c b/gl/sha256.c
deleted file mode 100644
index c9ca618..0000000
--- a/gl/sha256.c
+++ /dev/null
@@ -1,433 +0,0 @@
1/* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-2.
3
4 Copyright (C) 2005-2006, 2008-2022 Free Software Foundation, Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19/* Written by David Madore, considerably copypasting from
20 Scott G. Miller's sha1.c
21*/
22
23#include <config.h>
24
25/* Specification. */
26#if HAVE_OPENSSL_SHA256
27# define GL_OPENSSL_INLINE _GL_EXTERN_INLINE
28#endif
29#include "sha256.h"
30
31#include <stdalign.h>
32#include <stdint.h>
33#include <string.h>
34
35#include <byteswap.h>
36#ifdef WORDS_BIGENDIAN
37# define SWAP(n) (n)
38#else
39# define SWAP(n) bswap_32 (n)
40#endif
41
42#if ! HAVE_OPENSSL_SHA256
43
44/* This array contains the bytes used to pad the buffer to the next
45 64-byte boundary. */
46static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
47
48
49/*
50 Takes a pointer to a 256 bit block of data (eight 32 bit ints) and
51 initializes it to the start constants of the SHA256 algorithm. This
52 must be called before using hash in the call to sha256_hash
53*/
54void
55sha256_init_ctx (struct sha256_ctx *ctx)
56{
57 ctx->state[0] = 0x6a09e667UL;
58 ctx->state[1] = 0xbb67ae85UL;
59 ctx->state[2] = 0x3c6ef372UL;
60 ctx->state[3] = 0xa54ff53aUL;
61 ctx->state[4] = 0x510e527fUL;
62 ctx->state[5] = 0x9b05688cUL;
63 ctx->state[6] = 0x1f83d9abUL;
64 ctx->state[7] = 0x5be0cd19UL;
65
66 ctx->total[0] = ctx->total[1] = 0;
67 ctx->buflen = 0;
68}
69
70void
71sha224_init_ctx (struct sha256_ctx *ctx)
72{
73 ctx->state[0] = 0xc1059ed8UL;
74 ctx->state[1] = 0x367cd507UL;
75 ctx->state[2] = 0x3070dd17UL;
76 ctx->state[3] = 0xf70e5939UL;
77 ctx->state[4] = 0xffc00b31UL;
78 ctx->state[5] = 0x68581511UL;
79 ctx->state[6] = 0x64f98fa7UL;
80 ctx->state[7] = 0xbefa4fa4UL;
81
82 ctx->total[0] = ctx->total[1] = 0;
83 ctx->buflen = 0;
84}
85
86/* Copy the value from v into the memory location pointed to by *CP,
87 If your architecture allows unaligned access, this is equivalent to
88 * (__typeof__ (v) *) cp = v */
89static void
90set_uint32 (char *cp, uint32_t v)
91{
92 memcpy (cp, &v, sizeof v);
93}
94
95/* Put result from CTX in first 32 bytes following RESBUF.
96 The result must be in little endian byte order. */
97void *
98sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
99{
100 int i;
101 char *r = resbuf;
102
103 for (i = 0; i < 8; i++)
104 set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
105
106 return resbuf;
107}
108
109void *
110sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
111{
112 int i;
113 char *r = resbuf;
114
115 for (i = 0; i < 7; i++)
116 set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
117
118 return resbuf;
119}
120
121/* Process the remaining bytes in the internal buffer and the usual
122 prolog according to the standard and write the result to RESBUF. */
123static void
124sha256_conclude_ctx (struct sha256_ctx *ctx)
125{
126 /* Take yet unprocessed bytes into account. */
127 size_t bytes = ctx->buflen;
128 size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
129
130 /* Now count remaining bytes. */
131 ctx->total[0] += bytes;
132 if (ctx->total[0] < bytes)
133 ++ctx->total[1];
134
135 /* Put the 64-bit file length in *bits* at the end of the buffer.
136 Use set_uint32 rather than a simple assignment, to avoid risk of
137 unaligned access. */
138 set_uint32 ((char *) &ctx->buffer[size - 2],
139 SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)));
140 set_uint32 ((char *) &ctx->buffer[size - 1],
141 SWAP (ctx->total[0] << 3));
142
143 memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
144
145 /* Process last bytes. */
146 sha256_process_block (ctx->buffer, size * 4, ctx);
147}
148
149void *
150sha256_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
151{
152 sha256_conclude_ctx (ctx);
153 return sha256_read_ctx (ctx, resbuf);
154}
155
156void *
157sha224_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
158{
159 sha256_conclude_ctx (ctx);
160 return sha224_read_ctx (ctx, resbuf);
161}
162
163/* Compute SHA256 message digest for LEN bytes beginning at BUFFER. The
164 result is always in little endian byte order, so that a byte-wise
165 output yields to the wanted ASCII representation of the message
166 digest. */
167void *
168sha256_buffer (const char *buffer, size_t len, void *resblock)
169{
170 struct sha256_ctx ctx;
171
172 /* Initialize the computation context. */
173 sha256_init_ctx (&ctx);
174
175 /* Process whole buffer but last len % 64 bytes. */
176 sha256_process_bytes (buffer, len, &ctx);
177
178 /* Put result in desired memory area. */
179 return sha256_finish_ctx (&ctx, resblock);
180}
181
182void *
183sha224_buffer (const char *buffer, size_t len, void *resblock)
184{
185 struct sha256_ctx ctx;
186
187 /* Initialize the computation context. */
188 sha224_init_ctx (&ctx);
189
190 /* Process whole buffer but last len % 64 bytes. */
191 sha256_process_bytes (buffer, len, &ctx);
192
193 /* Put result in desired memory area. */
194 return sha224_finish_ctx (&ctx, resblock);
195}
196
197void
198sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx)
199{
200 /* When we already have some bits in our internal buffer concatenate
201 both inputs first. */
202 if (ctx->buflen != 0)
203 {
204 size_t left_over = ctx->buflen;
205 size_t add = 128 - left_over > len ? len : 128 - left_over;
206
207 memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
208 ctx->buflen += add;
209
210 if (ctx->buflen > 64)
211 {
212 sha256_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
213
214 ctx->buflen &= 63;
215 /* The regions in the following copy operation cannot overlap,
216 because ctx->buflen < 64 ≤ (left_over + add) & ~63. */
217 memcpy (ctx->buffer,
218 &((char *) ctx->buffer)[(left_over + add) & ~63],
219 ctx->buflen);
220 }
221
222 buffer = (const char *) buffer + add;
223 len -= add;
224 }
225
226 /* Process available complete blocks. */
227 if (len >= 64)
228 {
229#if !(_STRING_ARCH_unaligned || _STRING_INLINE_unaligned)
230# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
231 if (UNALIGNED_P (buffer))
232 while (len > 64)
233 {
234 sha256_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
235 buffer = (const char *) buffer + 64;
236 len -= 64;
237 }
238 else
239#endif
240 {
241 sha256_process_block (buffer, len & ~63, ctx);
242 buffer = (const char *) buffer + (len & ~63);
243 len &= 63;
244 }
245 }
246
247 /* Move remaining bytes in internal buffer. */
248 if (len > 0)
249 {
250 size_t left_over = ctx->buflen;
251
252 memcpy (&((char *) ctx->buffer)[left_over], buffer, len);
253 left_over += len;
254 if (left_over >= 64)
255 {
256 sha256_process_block (ctx->buffer, 64, ctx);
257 left_over -= 64;
258 /* The regions in the following copy operation cannot overlap,
259 because left_over ≤ 64. */
260 memcpy (ctx->buffer, &ctx->buffer[16], left_over);
261 }
262 ctx->buflen = left_over;
263 }
264}
265
266/* --- Code below is the primary difference between sha1.c and sha256.c --- */
267
268/* SHA256 round constants */
269#define K(I) sha256_round_constants[I]
270static const uint32_t sha256_round_constants[64] = {
271 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
272 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
273 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,
274 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL,
275 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
276 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL,
277 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL,
278 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL,
279 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL,
280 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
281 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL,
282 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL,
283 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL,
284 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL,
285 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
286 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL,
287};
288
289/* Round functions. */
290#define F2(A,B,C) ( ( A & B ) | ( C & ( A | B ) ) )
291#define F1(E,F,G) ( G ^ ( E & ( F ^ G ) ) )
292
293/* Process LEN bytes of BUFFER, accumulating context into CTX.
294 It is assumed that LEN % 64 == 0.
295 Most of this code comes from GnuPG's cipher/sha1.c. */
296
297void
298sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx)
299{
300 const uint32_t *words = buffer;
301 size_t nwords = len / sizeof (uint32_t);
302 const uint32_t *endp = words + nwords;
303 uint32_t x[16];
304 uint32_t a = ctx->state[0];
305 uint32_t b = ctx->state[1];
306 uint32_t c = ctx->state[2];
307 uint32_t d = ctx->state[3];
308 uint32_t e = ctx->state[4];
309 uint32_t f = ctx->state[5];
310 uint32_t g = ctx->state[6];
311 uint32_t h = ctx->state[7];
312 uint32_t lolen = len;
313
314 /* First increment the byte count. FIPS PUB 180-2 specifies the possible
315 length of the file up to 2^64 bits. Here we only compute the
316 number of bytes. Do a double word increment. */
317 ctx->total[0] += lolen;
318 ctx->total[1] += (len >> 31 >> 1) + (ctx->total[0] < lolen);
319
320#define rol(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
321#define S0(x) (rol(x,25)^rol(x,14)^(x>>3))
322#define S1(x) (rol(x,15)^rol(x,13)^(x>>10))
323#define SS0(x) (rol(x,30)^rol(x,19)^rol(x,10))
324#define SS1(x) (rol(x,26)^rol(x,21)^rol(x,7))
325
326#define M(I) ( tm = S1(x[(I-2)&0x0f]) + x[(I-7)&0x0f] \
327 + S0(x[(I-15)&0x0f]) + x[I&0x0f] \
328 , x[I&0x0f] = tm )
329
330#define R(A,B,C,D,E,F,G,H,K,M) do { t0 = SS0(A) + F2(A,B,C); \
331 t1 = H + SS1(E) \
332 + F1(E,F,G) \
333 + K \
334 + M; \
335 D += t1; H = t0 + t1; \
336 } while(0)
337
338 while (words < endp)
339 {
340 uint32_t tm;
341 uint32_t t0, t1;
342 int t;
343 /* FIXME: see sha1.c for a better implementation. */
344 for (t = 0; t < 16; t++)
345 {
346 x[t] = SWAP (*words);
347 words++;
348 }
349
350 R( a, b, c, d, e, f, g, h, K( 0), x[ 0] );
351 R( h, a, b, c, d, e, f, g, K( 1), x[ 1] );
352 R( g, h, a, b, c, d, e, f, K( 2), x[ 2] );
353 R( f, g, h, a, b, c, d, e, K( 3), x[ 3] );
354 R( e, f, g, h, a, b, c, d, K( 4), x[ 4] );
355 R( d, e, f, g, h, a, b, c, K( 5), x[ 5] );
356 R( c, d, e, f, g, h, a, b, K( 6), x[ 6] );
357 R( b, c, d, e, f, g, h, a, K( 7), x[ 7] );
358 R( a, b, c, d, e, f, g, h, K( 8), x[ 8] );
359 R( h, a, b, c, d, e, f, g, K( 9), x[ 9] );
360 R( g, h, a, b, c, d, e, f, K(10), x[10] );
361 R( f, g, h, a, b, c, d, e, K(11), x[11] );
362 R( e, f, g, h, a, b, c, d, K(12), x[12] );
363 R( d, e, f, g, h, a, b, c, K(13), x[13] );
364 R( c, d, e, f, g, h, a, b, K(14), x[14] );
365 R( b, c, d, e, f, g, h, a, K(15), x[15] );
366 R( a, b, c, d, e, f, g, h, K(16), M(16) );
367 R( h, a, b, c, d, e, f, g, K(17), M(17) );
368 R( g, h, a, b, c, d, e, f, K(18), M(18) );
369 R( f, g, h, a, b, c, d, e, K(19), M(19) );
370 R( e, f, g, h, a, b, c, d, K(20), M(20) );
371 R( d, e, f, g, h, a, b, c, K(21), M(21) );
372 R( c, d, e, f, g, h, a, b, K(22), M(22) );
373 R( b, c, d, e, f, g, h, a, K(23), M(23) );
374 R( a, b, c, d, e, f, g, h, K(24), M(24) );
375 R( h, a, b, c, d, e, f, g, K(25), M(25) );
376 R( g, h, a, b, c, d, e, f, K(26), M(26) );
377 R( f, g, h, a, b, c, d, e, K(27), M(27) );
378 R( e, f, g, h, a, b, c, d, K(28), M(28) );
379 R( d, e, f, g, h, a, b, c, K(29), M(29) );
380 R( c, d, e, f, g, h, a, b, K(30), M(30) );
381 R( b, c, d, e, f, g, h, a, K(31), M(31) );
382 R( a, b, c, d, e, f, g, h, K(32), M(32) );
383 R( h, a, b, c, d, e, f, g, K(33), M(33) );
384 R( g, h, a, b, c, d, e, f, K(34), M(34) );
385 R( f, g, h, a, b, c, d, e, K(35), M(35) );
386 R( e, f, g, h, a, b, c, d, K(36), M(36) );
387 R( d, e, f, g, h, a, b, c, K(37), M(37) );
388 R( c, d, e, f, g, h, a, b, K(38), M(38) );
389 R( b, c, d, e, f, g, h, a, K(39), M(39) );
390 R( a, b, c, d, e, f, g, h, K(40), M(40) );
391 R( h, a, b, c, d, e, f, g, K(41), M(41) );
392 R( g, h, a, b, c, d, e, f, K(42), M(42) );
393 R( f, g, h, a, b, c, d, e, K(43), M(43) );
394 R( e, f, g, h, a, b, c, d, K(44), M(44) );
395 R( d, e, f, g, h, a, b, c, K(45), M(45) );
396 R( c, d, e, f, g, h, a, b, K(46), M(46) );
397 R( b, c, d, e, f, g, h, a, K(47), M(47) );
398 R( a, b, c, d, e, f, g, h, K(48), M(48) );
399 R( h, a, b, c, d, e, f, g, K(49), M(49) );
400 R( g, h, a, b, c, d, e, f, K(50), M(50) );
401 R( f, g, h, a, b, c, d, e, K(51), M(51) );
402 R( e, f, g, h, a, b, c, d, K(52), M(52) );
403 R( d, e, f, g, h, a, b, c, K(53), M(53) );
404 R( c, d, e, f, g, h, a, b, K(54), M(54) );
405 R( b, c, d, e, f, g, h, a, K(55), M(55) );
406 R( a, b, c, d, e, f, g, h, K(56), M(56) );
407 R( h, a, b, c, d, e, f, g, K(57), M(57) );
408 R( g, h, a, b, c, d, e, f, K(58), M(58) );
409 R( f, g, h, a, b, c, d, e, K(59), M(59) );
410 R( e, f, g, h, a, b, c, d, K(60), M(60) );
411 R( d, e, f, g, h, a, b, c, K(61), M(61) );
412 R( c, d, e, f, g, h, a, b, K(62), M(62) );
413 R( b, c, d, e, f, g, h, a, K(63), M(63) );
414
415 a = ctx->state[0] += a;
416 b = ctx->state[1] += b;
417 c = ctx->state[2] += c;
418 d = ctx->state[3] += d;
419 e = ctx->state[4] += e;
420 f = ctx->state[5] += f;
421 g = ctx->state[6] += g;
422 h = ctx->state[7] += h;
423 }
424}
425
426#endif
427
428/*
429 * Hey Emacs!
430 * Local Variables:
431 * coding: utf-8
432 * End:
433 */
diff --git a/gl/sha256.h b/gl/sha256.h
deleted file mode 100644
index 533173a..0000000
--- a/gl/sha256.h
+++ /dev/null
@@ -1,121 +0,0 @@
1/* Declarations of functions and data types used for SHA256 and SHA224 sum
2 library functions.
3 Copyright (C) 2005-2006, 2008-2022 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef SHA256_H
19# define SHA256_H 1
20
21# include <stdio.h>
22# include <stdint.h>
23
24# if HAVE_OPENSSL_SHA256
25# ifndef OPENSSL_API_COMPAT
26# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */
27# endif
28# include <openssl/sha.h>
29# endif
30
31# ifdef __cplusplus
32extern "C" {
33# endif
34
35enum { SHA224_DIGEST_SIZE = 224 / 8 };
36enum { SHA256_DIGEST_SIZE = 256 / 8 };
37
38# if HAVE_OPENSSL_SHA256
39# define GL_OPENSSL_NAME 224
40# include "gl_openssl.h"
41# define GL_OPENSSL_NAME 256
42# include "gl_openssl.h"
43# else
44/* Structure to save state of computation between the single steps. */
45struct sha256_ctx
46{
47 uint32_t state[8];
48
49 uint32_t total[2];
50 size_t buflen; /* ≥ 0, ≤ 128 */
51 uint32_t buffer[32]; /* 128 bytes; the first buflen bytes are in use */
52};
53
54/* Initialize structure containing state of computation. */
55extern void sha256_init_ctx (struct sha256_ctx *ctx);
56extern void sha224_init_ctx (struct sha256_ctx *ctx);
57
58/* Starting with the result of former calls of this function (or the
59 initialization function update the context for the next LEN bytes
60 starting at BUFFER.
61 It is necessary that LEN is a multiple of 64!!! */
62extern void sha256_process_block (const void *buffer, size_t len,
63 struct sha256_ctx *ctx);
64
65/* Starting with the result of former calls of this function (or the
66 initialization function update the context for the next LEN bytes
67 starting at BUFFER.
68 It is NOT required that LEN is a multiple of 64. */
69extern void sha256_process_bytes (const void *buffer, size_t len,
70 struct sha256_ctx *ctx);
71
72/* Process the remaining bytes in the buffer and put result from CTX
73 in first 32 (28) bytes following RESBUF. The result is always in little
74 endian byte order, so that a byte-wise output yields to the wanted
75 ASCII representation of the message digest. */
76extern void *sha256_finish_ctx (struct sha256_ctx *ctx, void *restrict resbuf);
77extern void *sha224_finish_ctx (struct sha256_ctx *ctx, void *restrict resbuf);
78
79
80/* Put result from CTX in first 32 (28) bytes following RESBUF. The result is
81 always in little endian byte order, so that a byte-wise output yields
82 to the wanted ASCII representation of the message digest. */
83extern void *sha256_read_ctx (const struct sha256_ctx *ctx,
84 void *restrict resbuf);
85extern void *sha224_read_ctx (const struct sha256_ctx *ctx,
86 void *restrict resbuf);
87
88
89/* Compute SHA256 (SHA224) message digest for LEN bytes beginning at BUFFER.
90 The result is always in little endian byte order, so that a byte-wise
91 output yields to the wanted ASCII representation of the message
92 digest. */
93extern void *sha256_buffer (const char *buffer, size_t len,
94 void *restrict resblock);
95extern void *sha224_buffer (const char *buffer, size_t len,
96 void *restrict resblock);
97
98# endif
99
100/* Compute SHA256 (SHA224) message digest for bytes read from STREAM.
101 STREAM is an open file stream. Regular files are handled more efficiently.
102 The contents of STREAM from its current position to its end will be read.
103 The case that the last operation on STREAM was an 'ungetc' is not supported.
104 The resulting message digest number will be written into the 32 (28) bytes
105 beginning at RESBLOCK. */
106extern int sha256_stream (FILE *stream, void *resblock);
107extern int sha224_stream (FILE *stream, void *resblock);
108
109
110# ifdef __cplusplus
111}
112# endif
113
114#endif
115
116/*
117 * Hey Emacs!
118 * Local Variables:
119 * coding: utf-8
120 * End:
121 */
diff --git a/gl/stdckdint.h b/gl/stdckdint.h
new file mode 100644
index 0000000..8eeac90
--- /dev/null
+++ b/gl/stdckdint.h
@@ -0,0 +1,38 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* stdckdint.h -- checked integer arithmetic
3
4 Copyright 2022 Free Software Foundation, Inc.
5
6 This program is free software: you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19#ifndef _GL_STDCKDINT_H
20#define _GL_STDCKDINT_H
21
22#include "intprops-internal.h"
23
24#include <stdbool.h>
25
26/* Store into *R the low-order bits of A + B, A - B, A * B, respectively.
27 Return 1 if the result overflows, 0 otherwise.
28 A, B, and *R can have any integer type other than char, bool, a
29 bit-precise integer type, or an enumeration type.
30
31 These are like the standard macros introduced in C23, except that
32 arguments should not have side effects. */
33
34#define ckd_add(r, a, b) ((bool) _GL_INT_ADD_WRAPV (a, b, r))
35#define ckd_sub(r, a, b) ((bool) _GL_INT_SUBTRACT_WRAPV (a, b, r))
36#define ckd_mul(r, a, b) ((bool) _GL_INT_MULTIPLY_WRAPV (a, b, r))
37
38#endif /* _GL_STDCKDINT_H */
diff --git a/gl/stdio-impl.h b/gl/stdio-impl.h
deleted file mode 100644
index ed32e69..0000000
--- a/gl/stdio-impl.h
+++ /dev/null
@@ -1,212 +0,0 @@
1/* Implementation details of FILE streams.
2 Copyright (C) 2007-2008, 2010-2022 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/* Many stdio implementations have the same logic and therefore can share
18 the same implementation of stdio extension API, except that some fields
19 have different naming conventions, or their access requires some casts. */
20
21/* Glibc 2.28 made _IO_UNBUFFERED and _IO_IN_BACKUP private. For now, work
22 around this problem by defining them ourselves. FIXME: Do not rely on glibc
23 internals. */
24#if defined _IO_EOF_SEEN
25# if !defined _IO_UNBUFFERED
26# define _IO_UNBUFFERED 0x2
27# endif
28# if !defined _IO_IN_BACKUP
29# define _IO_IN_BACKUP 0x100
30# endif
31#endif
32
33/* BSD stdio derived implementations. */
34
35#if defined __NetBSD__ /* NetBSD */
36/* Get __NetBSD_Version__. */
37# include <sys/param.h>
38#endif
39
40#include <errno.h> /* For detecting Plan9. */
41
42#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
43 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
44
45# if defined __DragonFly__ /* DragonFly */
46 /* See <https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/lib/libc/stdio/priv_stdio.h>. */
47# define fp_ ((struct { struct __FILE_public pub; \
48 struct { unsigned char *_base; int _size; } _bf; \
49 void *cookie; \
50 void *_close; \
51 void *_read; \
52 void *_seek; \
53 void *_write; \
54 struct { unsigned char *_base; int _size; } _ub; \
55 int _ur; \
56 unsigned char _ubuf[3]; \
57 unsigned char _nbuf[1]; \
58 struct { unsigned char *_base; int _size; } _lb; \
59 int _blksize; \
60 fpos_t _offset; \
61 /* More fields, not relevant here. */ \
62 } *) fp)
63 /* See <https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/include/stdio.h>. */
64# define _p pub._p
65# define _flags pub._flags
66# define _r pub._r
67# define _w pub._w
68# elif defined __ANDROID__ /* Android */
69# ifdef __LP64__
70# define _gl_flags_file_t int
71# else
72# define _gl_flags_file_t short
73# endif
74 /* Up to this commit from 2015-10-12
75 <https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a>
76 the innards of FILE were public, and fp_ub could be defined like for OpenBSD,
77 see <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/fileext.h>
78 and <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/local.h>.
79 After this commit, the innards of FILE are hidden. */
80# define fp_ ((struct { unsigned char *_p; \
81 int _r; \
82 int _w; \
83 _gl_flags_file_t _flags; \
84 _gl_flags_file_t _file; \
85 struct { unsigned char *_base; size_t _size; } _bf; \
86 int _lbfsize; \
87 void *_cookie; \
88 void *_close; \
89 void *_read; \
90 void *_seek; \
91 void *_write; \
92 struct { unsigned char *_base; size_t _size; } _ext; \
93 unsigned char *_up; \
94 int _ur; \
95 unsigned char _ubuf[3]; \
96 unsigned char _nbuf[1]; \
97 struct { unsigned char *_base; size_t _size; } _lb; \
98 int _blksize; \
99 fpos_t _offset; \
100 /* More fields, not relevant here. */ \
101 } *) fp)
102# else
103# define fp_ fp
104# endif
105
106# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */
107 /* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
108 and <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
109 and <https://github.com/Stichting-MINIX-Research-Foundation/minix/blob/master/lib/libc/stdio/fileext.h> */
110 struct __sfileext
111 {
112 struct __sbuf _ub; /* ungetc buffer */
113 /* More fields, not relevant here. */
114 };
115# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
116# elif defined __ANDROID__ /* Android */
117 struct __sfileext
118 {
119 struct { unsigned char *_base; size_t _size; } _ub; /* ungetc buffer */
120 /* More fields, not relevant here. */
121 };
122# define fp_ub ((struct __sfileext *) fp_->_ext._base)->_ub
123# else /* FreeBSD, NetBSD <= 1.5Z, DragonFly, Mac OS X, Cygwin */
124# define fp_ub fp_->_ub
125# endif
126
127# define HASUB(fp) (fp_ub._base != NULL)
128
129# if defined __ANDROID__ /* Android */
130 /* Needed after this commit from 2016-01-25
131 <https://android.googlesource.com/platform/bionic.git/+/e70e0e9267d069bf56a5078c99307e08a7280de7> */
132# ifndef __SEOF
133# define __SLBF 1
134# define __SNBF 2
135# define __SRD 4
136# define __SWR 8
137# define __SRW 0x10
138# define __SEOF 0x20
139# define __SERR 0x40
140# endif
141# ifndef __SOFF
142# define __SOFF 0x1000
143# endif
144# endif
145
146#endif
147
148
149/* SystemV derived implementations. */
150
151#ifdef __TANDEM /* NonStop Kernel */
152# ifndef _IOERR
153/* These values were determined by the program 'stdioext-flags' at
154 <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>. */
155# define _IOERR 0x40
156# define _IOREAD 0x80
157# define _IOWRT 0x4
158# define _IORW 0x100
159# endif
160#endif
161
162#if defined _IOERR
163
164# if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */
165# define fp_ ((struct { unsigned char *_ptr; \
166 unsigned char *_base; \
167 unsigned char *_end; \
168 long _cnt; \
169 int _file; \
170 unsigned int _flag; \
171 } *) fp)
172# elif defined __VMS /* OpenVMS */
173# define fp_ ((struct _iobuf *) fp)
174# else
175# define fp_ fp
176# endif
177
178# if defined _SCO_DS || (defined __SCO_VERSION__ || defined __sysv5__) /* OpenServer 5, OpenServer 6, UnixWare 7 */
179# define _cnt __cnt
180# define _ptr __ptr
181# define _base __base
182# define _flag __flag
183# endif
184
185#elif defined _WIN32 && ! defined __CYGWIN__ /* newer Windows with MSVC */
186
187/* <stdio.h> does not define the innards of FILE any more. */
188# define WINDOWS_OPAQUE_FILE
189
190struct _gl_real_FILE
191{
192 /* Note: Compared to older Windows and to mingw, it has the fields
193 _base and _cnt swapped. */
194 unsigned char *_ptr;
195 unsigned char *_base;
196 int _cnt;
197 int _flag;
198 int _file;
199 int _charbuf;
200 int _bufsiz;
201};
202# define fp_ ((struct _gl_real_FILE *) fp)
203
204/* These values were determined by a program similar to the one at
205 <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>. */
206# define _IOREAD 0x1
207# define _IOWRT 0x2
208# define _IORW 0x4
209# define _IOEOF 0x8
210# define _IOERR 0x10
211
212#endif
diff --git a/gl/sys-limits.h b/gl/sys-limits.h
deleted file mode 100644
index d154f0b..0000000
--- a/gl/sys-limits.h
+++ /dev/null
@@ -1,42 +0,0 @@
1/* System call limits
2
3 Copyright 2018-2022 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _GL_SYS_LIMITS_H
19#define _GL_SYS_LIMITS_H
20
21#include <limits.h>
22
23/* Maximum number of bytes to read or write in a single system call.
24 This can be useful for system calls like sendfile on GNU/Linux,
25 which do not handle more than MAX_RW_COUNT bytes correctly.
26 The Linux kernel MAX_RW_COUNT is at least INT_MAX >> 20 << 20,
27 where the 20 comes from the Hexagon port with 1 MiB pages; use that
28 as an approximation, as the exact value may not be available to us.
29
30 Using this also works around a serious Linux bug before 2.6.16; see
31 <https://bugzilla.redhat.com/show_bug.cgi?id=612839>.
32
33 Using this also works around a Tru64 5.1 bug, where attempting
34 to read INT_MAX bytes fails with errno == EINVAL. See
35 <https://lists.gnu.org/r/bug-gnu-utils/2002-04/msg00010.html>.
36
37 Using this is likely to work around similar bugs in other operating
38 systems. */
39
40enum { SYS_BUFSIZE_MAX = INT_MAX >> 20 << 20 };
41
42#endif