summaryrefslogtreecommitdiffstats
path: root/gl
diff options
context:
space:
mode:
Diffstat (limited to 'gl')
-rw-r--r--gl/Makefile.am17
-rw-r--r--gl/inttypes.h1509
-rw-r--r--gl/limits.h132
-rw-r--r--gl/m4/gnulib-cache.m46
-rw-r--r--gl/m4/gnulib-comp.m414
-rw-r--r--gl/m4/sha256.m4 (renamed from gl/m4/sha1.m4)12
-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.Po142
-rw-r--r--gl/malloc/.deps/libgnu_a-dynarray_emplace_enlarge.Po142
-rw-r--r--gl/malloc/.deps/libgnu_a-dynarray_finalize.Po119
-rw-r--r--gl/malloc/.deps/libgnu_a-dynarray_resize.Po141
-rw-r--r--gl/malloc/.deps/libgnu_a-dynarray_resize_clear.Po52
-rw-r--r--gl/malloc/.dirstamp0
-rw-r--r--gl/malloc/dynarray-skeleton.gl.h529
-rw-r--r--gl/malloc/dynarray.gl.h173
-rw-r--r--gl/sha1.c360
-rw-r--r--gl/sha256-stream.c (renamed from gl/sha1-stream.c)54
-rw-r--r--gl/sha256.c432
-rw-r--r--gl/sha256.h (renamed from gl/sha1.h)70
-rw-r--r--gl/stdckdint.h36
21 files changed, 3507 insertions, 434 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am
index db12446..3865bf7 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -33,8 +33,9 @@
33# --no-libtool \ 33# --no-libtool \
34# --macro-prefix=gl \ 34# --macro-prefix=gl \
35# --no-vc-files \ 35# --no-vc-files \
36# --no-vc-files \
36# base64 \ 37# base64 \
37# crypto/sha1 \ 38# crypto/sha256 \
38# dirname \ 39# dirname \
39# environ \ 40# environ \
40# floorf \ 41# floorf \
@@ -272,19 +273,19 @@ EXTRA_DIST += af_alg.h sys-limits.h
272 273
273## end gnulib module crypto/af_alg 274## end gnulib module crypto/af_alg
274 275
275## begin gnulib module crypto/sha1 276## begin gnulib module crypto/sha256
276 277
277libgnu_a_SOURCES += sha1-stream.c 278libgnu_a_SOURCES += sha256-stream.c
278 279
279## end gnulib module crypto/sha1 280## end gnulib module crypto/sha256
280 281
281## begin gnulib module crypto/sha1-buffer 282## begin gnulib module crypto/sha256-buffer
282 283
283libgnu_a_SOURCES += sha1.c 284libgnu_a_SOURCES += sha256.c
284 285
285EXTRA_DIST += gl_openssl.h sha1.h 286EXTRA_DIST += gl_openssl.h sha256.h
286 287
287## end gnulib module crypto/sha1-buffer 288## end gnulib module crypto/sha256-buffer
288 289
289## begin gnulib module dirname 290## begin gnulib module dirname
290 291
diff --git a/gl/inttypes.h b/gl/inttypes.h
new file mode 100644
index 0000000..697e00e
--- /dev/null
+++ b/gl/inttypes.h
@@ -0,0 +1,1509 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* Copyright (C) 2006-2023 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-2023 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-2023 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-2023 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..1da08b8
--- /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-2023 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 C23 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 C23. */
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/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4
index ee4756e..4e5055e 100644
--- a/gl/m4/gnulib-cache.m4
+++ b/gl/m4/gnulib-cache.m4
@@ -38,8 +38,9 @@
38# --no-libtool \ 38# --no-libtool \
39# --macro-prefix=gl \ 39# --macro-prefix=gl \
40# --no-vc-files \ 40# --no-vc-files \
41# --no-vc-files \
41# base64 \ 42# base64 \
42# crypto/sha1 \ 43# crypto/sha256 \
43# dirname \ 44# dirname \
44# environ \ 45# environ \
45# floorf \ 46# floorf \
@@ -64,8 +65,9 @@
64# Specification in the form of a few gnulib-tool.m4 macro invocations: 65# Specification in the form of a few gnulib-tool.m4 macro invocations:
65gl_LOCAL_DIR([]) 66gl_LOCAL_DIR([])
66gl_MODULES([ 67gl_MODULES([
68 --no-vc-files
67 base64 69 base64
68 crypto/sha1 70 crypto/sha256
69 dirname 71 dirname
70 environ 72 environ
71 floorf 73 floorf
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 644b916..e6501b9 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -58,8 +58,8 @@ AC_DEFUN([gl_EARLY],
58 # Code from module cloexec: 58 # Code from module cloexec:
59 # Code from module close: 59 # Code from module close:
60 # Code from module crypto/af_alg: 60 # Code from module crypto/af_alg:
61 # Code from module crypto/sha1: 61 # Code from module crypto/sha256:
62 # Code from module crypto/sha1-buffer: 62 # Code from module crypto/sha256-buffer:
63 # Code from module dirname: 63 # Code from module dirname:
64 # Code from module dirname-lgpl: 64 # Code from module dirname-lgpl:
65 # Code from module double-slash-root: 65 # Code from module double-slash-root:
@@ -268,7 +268,7 @@ AC_DEFUN([gl_INIT],
268 gl_UNISTD_MODULE_INDICATOR([close]) 268 gl_UNISTD_MODULE_INDICATOR([close])
269 gl_AF_ALG 269 gl_AF_ALG
270 AC_REQUIRE([AC_C_RESTRICT]) 270 AC_REQUIRE([AC_C_RESTRICT])
271 gl_SHA1 271 gl_SHA256
272 gl_MODULE_INDICATOR([dirname]) 272 gl_MODULE_INDICATOR([dirname])
273 gl_DOUBLE_SLASH_ROOT 273 gl_DOUBLE_SLASH_ROOT
274 gl_FUNC_DUP2 274 gl_FUNC_DUP2
@@ -1132,9 +1132,9 @@ AC_DEFUN([gl_FILE_LIST], [
1132 lib/setlocale-lock.c 1132 lib/setlocale-lock.c
1133 lib/setlocale_null.c 1133 lib/setlocale_null.c
1134 lib/setlocale_null.h 1134 lib/setlocale_null.h
1135 lib/sha1-stream.c 1135 lib/sha256-stream.c
1136 lib/sha1.c 1136 lib/sha256.c
1137 lib/sha1.h 1137 lib/sha256.h
1138 lib/size_max.h 1138 lib/size_max.h
1139 lib/snprintf.c 1139 lib/snprintf.c
1140 lib/sockets.c 1140 lib/sockets.c
@@ -1319,7 +1319,7 @@ AC_DEFUN([gl_FILE_LIST], [
1319 m4/servent.m4 1319 m4/servent.m4
1320 m4/setenv.m4 1320 m4/setenv.m4
1321 m4/setlocale_null.m4 1321 m4/setlocale_null.m4
1322 m4/sha1.m4 1322 m4/sha256.m4
1323 m4/size_max.m4 1323 m4/size_max.m4
1324 m4/snprintf.m4 1324 m4/snprintf.m4
1325 m4/socketlib.m4 1325 m4/socketlib.m4
diff --git a/gl/m4/sha1.m4 b/gl/m4/sha256.m4
index 16b79c0..4d1d1dd 100644
--- a/gl/m4/sha1.m4
+++ b/gl/m4/sha256.m4
@@ -1,14 +1,14 @@
1# sha1.m4 serial 12 1# sha256.m4 serial 8
2dnl Copyright (C) 2002-2006, 2008-2023 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_SHA1], 7AC_DEFUN([gl_SHA256],
8[ 8[
9 dnl Prerequisites of lib/sha1.c. 9 dnl Prerequisites of lib/sha256.c.
10 AC_REQUIRE([gl_BIGENDIAN]) 10 AC_REQUIRE([gl_BIGENDIAN])
11 11
12 dnl Determine HAVE_OPENSSL_SHA1 and LIB_CRYPTO 12 dnl Determine HAVE_OPENSSL_SHA256 and LIB_CRYPTO
13 gl_CRYPTO_CHECK([SHA1]) 13 gl_CRYPTO_CHECK([SHA256])
14]) 14])
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..4902a8d
--- /dev/null
+++ b/gl/malloc/.deps/libgnu_a-dynarray_at_failure.Po
@@ -0,0 +1,142 @@
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/lib/gcc/x86_64-linux-gnu/12/include/stdalign.h \
4 /usr/lib/gcc/x86_64-linux-gnu/12/include/stdbool.h /usr/include/assert.h \
5 /usr/include/features.h /usr/include/features-time64.h \
6 /usr/include/x86_64-linux-gnu/bits/wordsize.h \
7 /usr/include/x86_64-linux-gnu/bits/timesize.h \
8 /usr/include/x86_64-linux-gnu/sys/cdefs.h \
9 /usr/include/x86_64-linux-gnu/bits/long-double.h \
10 /usr/include/x86_64-linux-gnu/gnu/stubs.h \
11 /usr/include/x86_64-linux-gnu/gnu/stubs-64.h /usr/include/errno.h \
12 /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
13 /usr/include/x86_64-linux-gnu/asm/errno.h \
14 /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
15 /usr/include/x86_64-linux-gnu/bits/types/error_t.h stdlib.h \
16 /usr/include/stdlib.h \
17 /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
18 /usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h \
19 /usr/include/x86_64-linux-gnu/bits/waitflags.h \
20 /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
21 /usr/include/x86_64-linux-gnu/bits/floatn.h \
22 /usr/include/x86_64-linux-gnu/bits/floatn-common.h \
23 /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
24 /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h sys/types.h \
25 /usr/include/x86_64-linux-gnu/sys/types.h \
26 /usr/include/x86_64-linux-gnu/bits/types.h \
27 /usr/include/x86_64-linux-gnu/bits/typesizes.h \
28 /usr/include/x86_64-linux-gnu/bits/time64.h \
29 /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
30 /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
31 /usr/include/x86_64-linux-gnu/bits/types/time_t.h \
32 /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
33 /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \
34 /usr/include/x86_64-linux-gnu/bits/endian.h \
35 /usr/include/x86_64-linux-gnu/bits/endianness.h \
36 /usr/include/x86_64-linux-gnu/bits/byteswap.h \
37 /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
38 /usr/include/x86_64-linux-gnu/sys/select.h \
39 /usr/include/x86_64-linux-gnu/bits/select.h \
40 /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
41 /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
42 /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
43 /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
44 /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
45 /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
46 /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
47 /usr/include/x86_64-linux-gnu/bits/atomic_wide_counter.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 dynarray.h \
52 malloc/dynarray.h string.h /usr/include/string.h strings.h \
53 /usr/include/strings.h stdio.h /usr/include/stdio.h \
54 /usr/lib/gcc/x86_64-linux-gnu/12/include/stdarg.h \
55 /usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h \
56 /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
57 /usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h \
58 /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
59 /usr/include/x86_64-linux-gnu/bits/types/FILE.h \
60 /usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h \
61 /usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h \
62 /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
63 /usr/include/x86_64-linux-gnu/bits/stdio.h
64/usr/include/stdc-predef.h:
65libc-config.h:
66../config.h:
67/usr/lib/gcc/x86_64-linux-gnu/12/include/stdalign.h:
68/usr/lib/gcc/x86_64-linux-gnu/12/include/stdbool.h:
69/usr/include/assert.h:
70/usr/include/features.h:
71/usr/include/features-time64.h:
72/usr/include/x86_64-linux-gnu/bits/wordsize.h:
73/usr/include/x86_64-linux-gnu/bits/timesize.h:
74/usr/include/x86_64-linux-gnu/sys/cdefs.h:
75/usr/include/x86_64-linux-gnu/bits/long-double.h:
76/usr/include/x86_64-linux-gnu/gnu/stubs.h:
77/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
78/usr/include/errno.h:
79/usr/include/x86_64-linux-gnu/bits/errno.h:
80/usr/include/linux/errno.h:
81/usr/include/x86_64-linux-gnu/asm/errno.h:
82/usr/include/asm-generic/errno.h:
83/usr/include/asm-generic/errno-base.h:
84/usr/include/x86_64-linux-gnu/bits/types/error_t.h:
85stdlib.h:
86/usr/include/stdlib.h:
87/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:
88/usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h:
89/usr/include/x86_64-linux-gnu/bits/waitflags.h:
90/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
91/usr/include/x86_64-linux-gnu/bits/floatn.h:
92/usr/include/x86_64-linux-gnu/bits/floatn-common.h:
93/usr/include/x86_64-linux-gnu/bits/types/locale_t.h:
94/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:
95sys/types.h:
96/usr/include/x86_64-linux-gnu/sys/types.h:
97/usr/include/x86_64-linux-gnu/bits/types.h:
98/usr/include/x86_64-linux-gnu/bits/typesizes.h:
99/usr/include/x86_64-linux-gnu/bits/time64.h:
100/usr/include/x86_64-linux-gnu/bits/types/clock_t.h:
101/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h:
102/usr/include/x86_64-linux-gnu/bits/types/time_t.h:
103/usr/include/x86_64-linux-gnu/bits/types/timer_t.h:
104/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:
105/usr/include/endian.h:
106/usr/include/x86_64-linux-gnu/bits/endian.h:
107/usr/include/x86_64-linux-gnu/bits/endianness.h:
108/usr/include/x86_64-linux-gnu/bits/byteswap.h:
109/usr/include/x86_64-linux-gnu/bits/uintn-identity.h:
110/usr/include/x86_64-linux-gnu/sys/select.h:
111/usr/include/x86_64-linux-gnu/bits/select.h:
112/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h:
113/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h:
114/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h:
115/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h:
116/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
117/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h:
118/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h:
119/usr/include/x86_64-linux-gnu/bits/atomic_wide_counter.h:
120/usr/include/x86_64-linux-gnu/bits/struct_mutex.h:
121/usr/include/x86_64-linux-gnu/bits/struct_rwlock.h:
122alloca.h:
123/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
124/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
125dynarray.h:
126malloc/dynarray.h:
127string.h:
128/usr/include/string.h:
129strings.h:
130/usr/include/strings.h:
131stdio.h:
132/usr/include/stdio.h:
133/usr/lib/gcc/x86_64-linux-gnu/12/include/stdarg.h:
134/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h:
135/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h:
136/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h:
137/usr/include/x86_64-linux-gnu/bits/types/__FILE.h:
138/usr/include/x86_64-linux-gnu/bits/types/FILE.h:
139/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h:
140/usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h:
141/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
142/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..be7a9eb
--- /dev/null
+++ b/gl/malloc/.deps/libgnu_a-dynarray_emplace_enlarge.Po
@@ -0,0 +1,142 @@
1malloc/libgnu_a-dynarray_emplace_enlarge.o: \
2 malloc/dynarray_emplace_enlarge.c /usr/include/stdc-predef.h \
3 libc-config.h ../config.h \
4 /usr/lib/gcc/x86_64-linux-gnu/12/include/stdalign.h \
5 /usr/lib/gcc/x86_64-linux-gnu/12/include/stdbool.h /usr/include/assert.h \
6 /usr/include/features.h /usr/include/features-time64.h \
7 /usr/include/x86_64-linux-gnu/bits/wordsize.h \
8 /usr/include/x86_64-linux-gnu/bits/timesize.h \
9 /usr/include/x86_64-linux-gnu/sys/cdefs.h \
10 /usr/include/x86_64-linux-gnu/bits/long-double.h \
11 /usr/include/x86_64-linux-gnu/gnu/stubs.h \
12 /usr/include/x86_64-linux-gnu/gnu/stubs-64.h /usr/include/errno.h \
13 /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
14 /usr/include/x86_64-linux-gnu/asm/errno.h \
15 /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
16 /usr/include/x86_64-linux-gnu/bits/types/error_t.h dynarray.h \
17 malloc/dynarray.h /usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h \
18 string.h /usr/include/string.h \
19 /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
20 /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
21 /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h strings.h \
22 /usr/include/strings.h intprops.h intprops-internal.h limits.h \
23 /usr/lib/gcc/x86_64-linux-gnu/12/include/limits.h \
24 /usr/lib/gcc/x86_64-linux-gnu/12/include/syslimits.h \
25 /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \
26 /usr/include/x86_64-linux-gnu/bits/local_lim.h \
27 /usr/include/linux/limits.h \
28 /usr/include/x86_64-linux-gnu/bits/pthread_stack_min-dynamic.h \
29 /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \
30 /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \
31 /usr/include/x86_64-linux-gnu/bits/uio_lim.h stdlib.h \
32 /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \
33 /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
34 /usr/include/x86_64-linux-gnu/bits/floatn.h \
35 /usr/include/x86_64-linux-gnu/bits/floatn-common.h sys/types.h \
36 /usr/include/x86_64-linux-gnu/sys/types.h \
37 /usr/include/x86_64-linux-gnu/bits/types.h \
38 /usr/include/x86_64-linux-gnu/bits/typesizes.h \
39 /usr/include/x86_64-linux-gnu/bits/time64.h \
40 /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
41 /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
42 /usr/include/x86_64-linux-gnu/bits/types/time_t.h \
43 /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
44 /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \
45 /usr/include/x86_64-linux-gnu/bits/endian.h \
46 /usr/include/x86_64-linux-gnu/bits/endianness.h \
47 /usr/include/x86_64-linux-gnu/bits/byteswap.h \
48 /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
49 /usr/include/x86_64-linux-gnu/sys/select.h \
50 /usr/include/x86_64-linux-gnu/bits/select.h \
51 /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
52 /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
53 /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
54 /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
55 /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
56 /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
57 /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
58 /usr/include/x86_64-linux-gnu/bits/atomic_wide_counter.h \
59 /usr/include/x86_64-linux-gnu/bits/struct_mutex.h \
60 /usr/include/x86_64-linux-gnu/bits/struct_rwlock.h alloca.h \
61 /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
62 /usr/include/x86_64-linux-gnu/bits/stdlib-float.h
63/usr/include/stdc-predef.h:
64libc-config.h:
65../config.h:
66/usr/lib/gcc/x86_64-linux-gnu/12/include/stdalign.h:
67/usr/lib/gcc/x86_64-linux-gnu/12/include/stdbool.h:
68/usr/include/assert.h:
69/usr/include/features.h:
70/usr/include/features-time64.h:
71/usr/include/x86_64-linux-gnu/bits/wordsize.h:
72/usr/include/x86_64-linux-gnu/bits/timesize.h:
73/usr/include/x86_64-linux-gnu/sys/cdefs.h:
74/usr/include/x86_64-linux-gnu/bits/long-double.h:
75/usr/include/x86_64-linux-gnu/gnu/stubs.h:
76/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
77/usr/include/errno.h:
78/usr/include/x86_64-linux-gnu/bits/errno.h:
79/usr/include/linux/errno.h:
80/usr/include/x86_64-linux-gnu/asm/errno.h:
81/usr/include/asm-generic/errno.h:
82/usr/include/asm-generic/errno-base.h:
83/usr/include/x86_64-linux-gnu/bits/types/error_t.h:
84dynarray.h:
85malloc/dynarray.h:
86/usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h:
87string.h:
88/usr/include/string.h:
89/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:
90/usr/include/x86_64-linux-gnu/bits/types/locale_t.h:
91/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:
92strings.h:
93/usr/include/strings.h:
94intprops.h:
95intprops-internal.h:
96limits.h:
97/usr/lib/gcc/x86_64-linux-gnu/12/include/limits.h:
98/usr/lib/gcc/x86_64-linux-gnu/12/include/syslimits.h:
99/usr/include/limits.h:
100/usr/include/x86_64-linux-gnu/bits/posix1_lim.h:
101/usr/include/x86_64-linux-gnu/bits/local_lim.h:
102/usr/include/linux/limits.h:
103/usr/include/x86_64-linux-gnu/bits/pthread_stack_min-dynamic.h:
104/usr/include/x86_64-linux-gnu/bits/posix2_lim.h:
105/usr/include/x86_64-linux-gnu/bits/xopen_lim.h:
106/usr/include/x86_64-linux-gnu/bits/uio_lim.h:
107stdlib.h:
108/usr/include/stdlib.h:
109/usr/include/x86_64-linux-gnu/bits/waitflags.h:
110/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
111/usr/include/x86_64-linux-gnu/bits/floatn.h:
112/usr/include/x86_64-linux-gnu/bits/floatn-common.h:
113sys/types.h:
114/usr/include/x86_64-linux-gnu/sys/types.h:
115/usr/include/x86_64-linux-gnu/bits/types.h:
116/usr/include/x86_64-linux-gnu/bits/typesizes.h:
117/usr/include/x86_64-linux-gnu/bits/time64.h:
118/usr/include/x86_64-linux-gnu/bits/types/clock_t.h:
119/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h:
120/usr/include/x86_64-linux-gnu/bits/types/time_t.h:
121/usr/include/x86_64-linux-gnu/bits/types/timer_t.h:
122/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:
123/usr/include/endian.h:
124/usr/include/x86_64-linux-gnu/bits/endian.h:
125/usr/include/x86_64-linux-gnu/bits/endianness.h:
126/usr/include/x86_64-linux-gnu/bits/byteswap.h:
127/usr/include/x86_64-linux-gnu/bits/uintn-identity.h:
128/usr/include/x86_64-linux-gnu/sys/select.h:
129/usr/include/x86_64-linux-gnu/bits/select.h:
130/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h:
131/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h:
132/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h:
133/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h:
134/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
135/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h:
136/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h:
137/usr/include/x86_64-linux-gnu/bits/atomic_wide_counter.h:
138/usr/include/x86_64-linux-gnu/bits/struct_mutex.h:
139/usr/include/x86_64-linux-gnu/bits/struct_rwlock.h:
140alloca.h:
141/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
142/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..0c9dc34
--- /dev/null
+++ b/gl/malloc/.deps/libgnu_a-dynarray_finalize.Po
@@ -0,0 +1,119 @@
1malloc/libgnu_a-dynarray_finalize.o: malloc/dynarray_finalize.c \
2 /usr/include/stdc-predef.h libc-config.h ../config.h \
3 /usr/lib/gcc/x86_64-linux-gnu/12/include/stdalign.h \
4 /usr/lib/gcc/x86_64-linux-gnu/12/include/stdbool.h /usr/include/assert.h \
5 /usr/include/features.h /usr/include/features-time64.h \
6 /usr/include/x86_64-linux-gnu/bits/wordsize.h \
7 /usr/include/x86_64-linux-gnu/bits/timesize.h \
8 /usr/include/x86_64-linux-gnu/sys/cdefs.h \
9 /usr/include/x86_64-linux-gnu/bits/long-double.h \
10 /usr/include/x86_64-linux-gnu/gnu/stubs.h \
11 /usr/include/x86_64-linux-gnu/gnu/stubs-64.h /usr/include/errno.h \
12 /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
13 /usr/include/x86_64-linux-gnu/asm/errno.h \
14 /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
15 /usr/include/x86_64-linux-gnu/bits/types/error_t.h dynarray.h \
16 malloc/dynarray.h /usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h \
17 string.h /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/atomic_wide_counter.h \
49 /usr/include/x86_64-linux-gnu/bits/struct_mutex.h \
50 /usr/include/x86_64-linux-gnu/bits/struct_rwlock.h alloca.h \
51 /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
52 /usr/include/x86_64-linux-gnu/bits/stdlib-float.h
53/usr/include/stdc-predef.h:
54libc-config.h:
55../config.h:
56/usr/lib/gcc/x86_64-linux-gnu/12/include/stdalign.h:
57/usr/lib/gcc/x86_64-linux-gnu/12/include/stdbool.h:
58/usr/include/assert.h:
59/usr/include/features.h:
60/usr/include/features-time64.h:
61/usr/include/x86_64-linux-gnu/bits/wordsize.h:
62/usr/include/x86_64-linux-gnu/bits/timesize.h:
63/usr/include/x86_64-linux-gnu/sys/cdefs.h:
64/usr/include/x86_64-linux-gnu/bits/long-double.h:
65/usr/include/x86_64-linux-gnu/gnu/stubs.h:
66/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
67/usr/include/errno.h:
68/usr/include/x86_64-linux-gnu/bits/errno.h:
69/usr/include/linux/errno.h:
70/usr/include/x86_64-linux-gnu/asm/errno.h:
71/usr/include/asm-generic/errno.h:
72/usr/include/asm-generic/errno-base.h:
73/usr/include/x86_64-linux-gnu/bits/types/error_t.h:
74dynarray.h:
75malloc/dynarray.h:
76/usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h:
77string.h:
78/usr/include/string.h:
79/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:
80/usr/include/x86_64-linux-gnu/bits/types/locale_t.h:
81/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:
82strings.h:
83/usr/include/strings.h:
84stdlib.h:
85/usr/include/stdlib.h:
86/usr/include/x86_64-linux-gnu/bits/waitflags.h:
87/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
88/usr/include/x86_64-linux-gnu/bits/floatn.h:
89/usr/include/x86_64-linux-gnu/bits/floatn-common.h:
90sys/types.h:
91/usr/include/x86_64-linux-gnu/sys/types.h:
92/usr/include/x86_64-linux-gnu/bits/types.h:
93/usr/include/x86_64-linux-gnu/bits/typesizes.h:
94/usr/include/x86_64-linux-gnu/bits/time64.h:
95/usr/include/x86_64-linux-gnu/bits/types/clock_t.h:
96/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h:
97/usr/include/x86_64-linux-gnu/bits/types/time_t.h:
98/usr/include/x86_64-linux-gnu/bits/types/timer_t.h:
99/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:
100/usr/include/endian.h:
101/usr/include/x86_64-linux-gnu/bits/endian.h:
102/usr/include/x86_64-linux-gnu/bits/endianness.h:
103/usr/include/x86_64-linux-gnu/bits/byteswap.h:
104/usr/include/x86_64-linux-gnu/bits/uintn-identity.h:
105/usr/include/x86_64-linux-gnu/sys/select.h:
106/usr/include/x86_64-linux-gnu/bits/select.h:
107/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h:
108/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h:
109/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h:
110/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h:
111/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
112/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h:
113/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h:
114/usr/include/x86_64-linux-gnu/bits/atomic_wide_counter.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:
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..e738d85
--- /dev/null
+++ b/gl/malloc/.deps/libgnu_a-dynarray_resize.Po
@@ -0,0 +1,141 @@
1malloc/libgnu_a-dynarray_resize.o: malloc/dynarray_resize.c \
2 /usr/include/stdc-predef.h libc-config.h ../config.h \
3 /usr/lib/gcc/x86_64-linux-gnu/12/include/stdalign.h \
4 /usr/lib/gcc/x86_64-linux-gnu/12/include/stdbool.h /usr/include/assert.h \
5 /usr/include/features.h /usr/include/features-time64.h \
6 /usr/include/x86_64-linux-gnu/bits/wordsize.h \
7 /usr/include/x86_64-linux-gnu/bits/timesize.h \
8 /usr/include/x86_64-linux-gnu/sys/cdefs.h \
9 /usr/include/x86_64-linux-gnu/bits/long-double.h \
10 /usr/include/x86_64-linux-gnu/gnu/stubs.h \
11 /usr/include/x86_64-linux-gnu/gnu/stubs-64.h /usr/include/errno.h \
12 /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
13 /usr/include/x86_64-linux-gnu/asm/errno.h \
14 /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
15 /usr/include/x86_64-linux-gnu/bits/types/error_t.h dynarray.h \
16 malloc/dynarray.h /usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h \
17 string.h /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/atomic_wide_counter.h \
58 /usr/include/x86_64-linux-gnu/bits/struct_mutex.h \
59 /usr/include/x86_64-linux-gnu/bits/struct_rwlock.h alloca.h \
60 /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
61 /usr/include/x86_64-linux-gnu/bits/stdlib-float.h
62/usr/include/stdc-predef.h:
63libc-config.h:
64../config.h:
65/usr/lib/gcc/x86_64-linux-gnu/12/include/stdalign.h:
66/usr/lib/gcc/x86_64-linux-gnu/12/include/stdbool.h:
67/usr/include/assert.h:
68/usr/include/features.h:
69/usr/include/features-time64.h:
70/usr/include/x86_64-linux-gnu/bits/wordsize.h:
71/usr/include/x86_64-linux-gnu/bits/timesize.h:
72/usr/include/x86_64-linux-gnu/sys/cdefs.h:
73/usr/include/x86_64-linux-gnu/bits/long-double.h:
74/usr/include/x86_64-linux-gnu/gnu/stubs.h:
75/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
76/usr/include/errno.h:
77/usr/include/x86_64-linux-gnu/bits/errno.h:
78/usr/include/linux/errno.h:
79/usr/include/x86_64-linux-gnu/asm/errno.h:
80/usr/include/asm-generic/errno.h:
81/usr/include/asm-generic/errno-base.h:
82/usr/include/x86_64-linux-gnu/bits/types/error_t.h:
83dynarray.h:
84malloc/dynarray.h:
85/usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h:
86string.h:
87/usr/include/string.h:
88/usr/include/x86_64-linux-gnu/bits/libc-header-start.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:
91strings.h:
92/usr/include/strings.h:
93intprops.h:
94intprops-internal.h:
95limits.h:
96/usr/lib/gcc/x86_64-linux-gnu/12/include/limits.h:
97/usr/lib/gcc/x86_64-linux-gnu/12/include/syslimits.h:
98/usr/include/limits.h:
99/usr/include/x86_64-linux-gnu/bits/posix1_lim.h:
100/usr/include/x86_64-linux-gnu/bits/local_lim.h:
101/usr/include/linux/limits.h:
102/usr/include/x86_64-linux-gnu/bits/pthread_stack_min-dynamic.h:
103/usr/include/x86_64-linux-gnu/bits/posix2_lim.h:
104/usr/include/x86_64-linux-gnu/bits/xopen_lim.h:
105/usr/include/x86_64-linux-gnu/bits/uio_lim.h:
106stdlib.h:
107/usr/include/stdlib.h:
108/usr/include/x86_64-linux-gnu/bits/waitflags.h:
109/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
110/usr/include/x86_64-linux-gnu/bits/floatn.h:
111/usr/include/x86_64-linux-gnu/bits/floatn-common.h:
112sys/types.h:
113/usr/include/x86_64-linux-gnu/sys/types.h:
114/usr/include/x86_64-linux-gnu/bits/types.h:
115/usr/include/x86_64-linux-gnu/bits/typesizes.h:
116/usr/include/x86_64-linux-gnu/bits/time64.h:
117/usr/include/x86_64-linux-gnu/bits/types/clock_t.h:
118/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h:
119/usr/include/x86_64-linux-gnu/bits/types/time_t.h:
120/usr/include/x86_64-linux-gnu/bits/types/timer_t.h:
121/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:
122/usr/include/endian.h:
123/usr/include/x86_64-linux-gnu/bits/endian.h:
124/usr/include/x86_64-linux-gnu/bits/endianness.h:
125/usr/include/x86_64-linux-gnu/bits/byteswap.h:
126/usr/include/x86_64-linux-gnu/bits/uintn-identity.h:
127/usr/include/x86_64-linux-gnu/sys/select.h:
128/usr/include/x86_64-linux-gnu/bits/select.h:
129/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h:
130/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h:
131/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h:
132/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h:
133/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
134/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h:
135/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h:
136/usr/include/x86_64-linux-gnu/bits/atomic_wide_counter.h:
137/usr/include/x86_64-linux-gnu/bits/struct_mutex.h:
138/usr/include/x86_64-linux-gnu/bits/struct_rwlock.h:
139alloca.h:
140/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
141/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..9585a04
--- /dev/null
+++ b/gl/malloc/.deps/libgnu_a-dynarray_resize_clear.Po
@@ -0,0 +1,52 @@
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/lib/gcc/x86_64-linux-gnu/12/include/stdalign.h \
4 /usr/lib/gcc/x86_64-linux-gnu/12/include/stdbool.h /usr/include/assert.h \
5 /usr/include/features.h /usr/include/features-time64.h \
6 /usr/include/x86_64-linux-gnu/bits/wordsize.h \
7 /usr/include/x86_64-linux-gnu/bits/timesize.h \
8 /usr/include/x86_64-linux-gnu/sys/cdefs.h \
9 /usr/include/x86_64-linux-gnu/bits/long-double.h \
10 /usr/include/x86_64-linux-gnu/gnu/stubs.h \
11 /usr/include/x86_64-linux-gnu/gnu/stubs-64.h /usr/include/errno.h \
12 /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
13 /usr/include/x86_64-linux-gnu/asm/errno.h \
14 /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
15 /usr/include/x86_64-linux-gnu/bits/types/error_t.h dynarray.h \
16 malloc/dynarray.h /usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h \
17 string.h /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/lib/gcc/x86_64-linux-gnu/12/include/stdalign.h:
26/usr/lib/gcc/x86_64-linux-gnu/12/include/stdbool.h:
27/usr/include/assert.h:
28/usr/include/features.h:
29/usr/include/features-time64.h:
30/usr/include/x86_64-linux-gnu/bits/wordsize.h:
31/usr/include/x86_64-linux-gnu/bits/timesize.h:
32/usr/include/x86_64-linux-gnu/sys/cdefs.h:
33/usr/include/x86_64-linux-gnu/bits/long-double.h:
34/usr/include/x86_64-linux-gnu/gnu/stubs.h:
35/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
36/usr/include/errno.h:
37/usr/include/x86_64-linux-gnu/bits/errno.h:
38/usr/include/linux/errno.h:
39/usr/include/x86_64-linux-gnu/asm/errno.h:
40/usr/include/asm-generic/errno.h:
41/usr/include/asm-generic/errno-base.h:
42/usr/include/x86_64-linux-gnu/bits/types/error_t.h:
43dynarray.h:
44malloc/dynarray.h:
45/usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h:
46string.h:
47/usr/include/string.h:
48/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:
49/usr/include/x86_64-linux-gnu/bits/types/locale_t.h:
50/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:
51strings.h:
52/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..af95414
--- /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-2023 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..34987e7
--- /dev/null
+++ b/gl/malloc/dynarray.gl.h
@@ -0,0 +1,173 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* Type-safe arrays which grow dynamically. Shared definitions.
3 Copyright (C) 2017-2023 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 <stddef.h>
99#include <string.h>
100
101struct dynarray_header
102{
103 size_t used;
104 size_t allocated;
105 void *array;
106};
107
108/* Marker used in the allocated member to indicate that an error was
109 encountered. */
110static inline size_t
111__dynarray_error_marker (void)
112{
113 return -1;
114}
115
116/* Internal function. See the has_failed function in
117 dynarray-skeleton.c. */
118static inline bool
119__dynarray_error (struct dynarray_header *list)
120{
121 return list->allocated == __dynarray_error_marker ();
122}
123
124/* Internal function. Enlarge the dynamically allocated area of the
125 array to make room for one more element. SCRATCH is a pointer to
126 the scratch area (which is not heap-allocated and must not be
127 freed). ELEMENT_SIZE is the size, in bytes, of one element.
128 Return false on failure, true on success. */
129bool __libc_dynarray_emplace_enlarge (struct dynarray_header *,
130 void *scratch, size_t element_size);
131
132/* Internal function. Enlarge the dynamically allocated area of the
133 array to make room for at least SIZE elements (which must be larger
134 than the existing used part of the dynamic array). SCRATCH is a
135 pointer to the scratch area (which is not heap-allocated and must
136 not be freed). ELEMENT_SIZE is the size, in bytes, of one element.
137 Return false on failure, true on success. */
138bool __libc_dynarray_resize (struct dynarray_header *, size_t size,
139 void *scratch, size_t element_size);
140
141/* Internal function. Like __libc_dynarray_resize, but clear the new
142 part of the dynamic array. */
143bool __libc_dynarray_resize_clear (struct dynarray_header *, size_t size,
144 void *scratch, size_t element_size);
145
146/* Internal type. */
147struct dynarray_finalize_result
148{
149 void *array;
150 size_t length;
151};
152
153/* Internal function. Copy the dynamically-allocated area to an
154 explicitly-sized heap allocation. SCRATCH is a pointer to the
155 embedded scratch space. ELEMENT_SIZE is the size, in bytes, of the
156 element type. On success, true is returned, and pointer and length
157 are written to *RESULT. On failure, false is returned. The caller
158 has to take care of some of the memory management; this function is
159 expected to be called from dynarray-skeleton.c. */
160bool __libc_dynarray_finalize (struct dynarray_header *list, void *scratch,
161 size_t element_size,
162 struct dynarray_finalize_result *result);
163
164
165/* Internal function. Terminate the process after an index error.
166 SIZE is the number of elements of the dynamic array. INDEX is the
167 lookup index which triggered the failure. */
168_Noreturn void __libc_dynarray_at_failure (size_t size, size_t index);
169
170#ifndef _ISOMAC
171#endif
172
173#endif /* _DYNARRAY_H */
diff --git a/gl/sha1.c b/gl/sha1.c
deleted file mode 100644
index 80f0b7a..0000000
--- a/gl/sha1.c
+++ /dev/null
@@ -1,360 +0,0 @@
1/* sha1.c - Functions to compute SHA1 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-1.
3
4 Copyright (C) 2000-2001, 2003-2006, 2008-2023 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 Scott G. Miller
20 Credits:
21 Robert Klep <robert@ilse.nl> -- Expansion function fix
22*/
23
24#include <config.h>
25
26/* Specification. */
27#if HAVE_OPENSSL_SHA1
28# define GL_OPENSSL_INLINE _GL_EXTERN_INLINE
29#endif
30#include "sha1.h"
31
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_SHA1
43
44/* This array contains the bytes used to pad the buffer to the next
45 64-byte boundary. (RFC 1321, 3.1: Step 1) */
46static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
47
48
49/* Take a pointer to a 160 bit block of data (five 32 bit ints) and
50 initialize it to the start constants of the SHA1 algorithm. This
51 must be called before using hash in the call to sha1_hash. */
52void
53sha1_init_ctx (struct sha1_ctx *ctx)
54{
55 ctx->A = 0x67452301;
56 ctx->B = 0xefcdab89;
57 ctx->C = 0x98badcfe;
58 ctx->D = 0x10325476;
59 ctx->E = 0xc3d2e1f0;
60
61 ctx->total[0] = ctx->total[1] = 0;
62 ctx->buflen = 0;
63}
64
65/* Copy the 4 byte value from v into the memory location pointed to by *cp,
66 If your architecture allows unaligned access this is equivalent to
67 * (uint32_t *) cp = v */
68static void
69set_uint32 (char *cp, uint32_t v)
70{
71 memcpy (cp, &v, sizeof v);
72}
73
74/* Put result from CTX in first 20 bytes following RESBUF. The result
75 must be in little endian byte order. */
76void *
77sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
78{
79 char *r = resbuf;
80 set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A));
81 set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B));
82 set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C));
83 set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D));
84 set_uint32 (r + 4 * sizeof ctx->E, SWAP (ctx->E));
85
86 return resbuf;
87}
88
89/* Process the remaining bytes in the internal buffer and the usual
90 prolog according to the standard and write the result to RESBUF. */
91void *
92sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
93{
94 /* Take yet unprocessed bytes into account. */
95 uint32_t bytes = ctx->buflen;
96 size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
97
98 /* Now count remaining bytes. */
99 ctx->total[0] += bytes;
100 if (ctx->total[0] < bytes)
101 ++ctx->total[1];
102
103 /* Put the 64-bit file length in *bits* at the end of the buffer. */
104 ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
105 ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3);
106
107 memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
108
109 /* Process last bytes. */
110 sha1_process_block (ctx->buffer, size * 4, ctx);
111
112 return sha1_read_ctx (ctx, resbuf);
113}
114
115/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The
116 result is always in little endian byte order, so that a byte-wise
117 output yields to the wanted ASCII representation of the message
118 digest. */
119void *
120sha1_buffer (const char *buffer, size_t len, void *resblock)
121{
122 struct sha1_ctx ctx;
123
124 /* Initialize the computation context. */
125 sha1_init_ctx (&ctx);
126
127 /* Process whole buffer but last len % 64 bytes. */
128 sha1_process_bytes (buffer, len, &ctx);
129
130 /* Put result in desired memory area. */
131 return sha1_finish_ctx (&ctx, resblock);
132}
133
134void
135sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
136{
137 /* When we already have some bits in our internal buffer concatenate
138 both inputs first. */
139 if (ctx->buflen != 0)
140 {
141 size_t left_over = ctx->buflen;
142 size_t add = 128 - left_over > len ? len : 128 - left_over;
143
144 memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
145 ctx->buflen += add;
146
147 if (ctx->buflen > 64)
148 {
149 sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
150
151 ctx->buflen &= 63;
152 /* The regions in the following copy operation cannot overlap,
153 because ctx->buflen < 64 ≤ (left_over + add) & ~63. */
154 memcpy (ctx->buffer,
155 &((char *) ctx->buffer)[(left_over + add) & ~63],
156 ctx->buflen);
157 }
158
159 buffer = (const char *) buffer + add;
160 len -= add;
161 }
162
163 /* Process available complete blocks. */
164 if (len >= 64)
165 {
166#if !(_STRING_ARCH_unaligned || _STRING_INLINE_unaligned)
167# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
168 if (UNALIGNED_P (buffer))
169 while (len > 64)
170 {
171 sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
172 buffer = (const char *) buffer + 64;
173 len -= 64;
174 }
175 else
176#endif
177 {
178 sha1_process_block (buffer, len & ~63, ctx);
179 buffer = (const char *) buffer + (len & ~63);
180 len &= 63;
181 }
182 }
183
184 /* Move remaining bytes in internal buffer. */
185 if (len > 0)
186 {
187 size_t left_over = ctx->buflen;
188
189 memcpy (&((char *) ctx->buffer)[left_over], buffer, len);
190 left_over += len;
191 if (left_over >= 64)
192 {
193 sha1_process_block (ctx->buffer, 64, ctx);
194 left_over -= 64;
195 /* The regions in the following copy operation cannot overlap,
196 because left_over ≤ 64. */
197 memcpy (ctx->buffer, &ctx->buffer[16], left_over);
198 }
199 ctx->buflen = left_over;
200 }
201}
202
203/* --- Code below is the primary difference between md5.c and sha1.c --- */
204
205/* SHA1 round constants */
206#define K1 0x5a827999
207#define K2 0x6ed9eba1
208#define K3 0x8f1bbcdc
209#define K4 0xca62c1d6
210
211/* Round functions. Note that F2 is the same as F4. */
212#define F1(B,C,D) ( D ^ ( B & ( C ^ D ) ) )
213#define F2(B,C,D) (B ^ C ^ D)
214#define F3(B,C,D) ( ( B & C ) | ( D & ( B | C ) ) )
215#define F4(B,C,D) (B ^ C ^ D)
216
217/* Process LEN bytes of BUFFER, accumulating context into CTX.
218 It is assumed that LEN % 64 == 0.
219 Most of this code comes from GnuPG's cipher/sha1.c. */
220
221void
222sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx)
223{
224 const uint32_t *words = buffer;
225 size_t nwords = len / sizeof (uint32_t);
226 const uint32_t *endp = words + nwords;
227 uint32_t x[16];
228 uint32_t a = ctx->A;
229 uint32_t b = ctx->B;
230 uint32_t c = ctx->C;
231 uint32_t d = ctx->D;
232 uint32_t e = ctx->E;
233 uint32_t lolen = len;
234
235 /* First increment the byte count. RFC 1321 specifies the possible
236 length of the file up to 2^64 bits. Here we only compute the
237 number of bytes. Do a double word increment. */
238 ctx->total[0] += lolen;
239 ctx->total[1] += (len >> 31 >> 1) + (ctx->total[0] < lolen);
240
241#define rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n))))
242
243#define M(I) ( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \
244 ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \
245 , (x[I&0x0f] = rol(tm, 1)) )
246
247#define R(A,B,C,D,E,F,K,M) do { E += rol( A, 5 ) \
248 + F( B, C, D ) \
249 + K \
250 + M; \
251 B = rol( B, 30 ); \
252 } while(0)
253
254 while (words < endp)
255 {
256 uint32_t tm;
257 int t;
258 for (t = 0; t < 16; t++)
259 {
260 x[t] = SWAP (*words);
261 words++;
262 }
263
264 R( a, b, c, d, e, F1, K1, x[ 0] );
265 R( e, a, b, c, d, F1, K1, x[ 1] );
266 R( d, e, a, b, c, F1, K1, x[ 2] );
267 R( c, d, e, a, b, F1, K1, x[ 3] );
268 R( b, c, d, e, a, F1, K1, x[ 4] );
269 R( a, b, c, d, e, F1, K1, x[ 5] );
270 R( e, a, b, c, d, F1, K1, x[ 6] );
271 R( d, e, a, b, c, F1, K1, x[ 7] );
272 R( c, d, e, a, b, F1, K1, x[ 8] );
273 R( b, c, d, e, a, F1, K1, x[ 9] );
274 R( a, b, c, d, e, F1, K1, x[10] );
275 R( e, a, b, c, d, F1, K1, x[11] );
276 R( d, e, a, b, c, F1, K1, x[12] );
277 R( c, d, e, a, b, F1, K1, x[13] );
278 R( b, c, d, e, a, F1, K1, x[14] );
279 R( a, b, c, d, e, F1, K1, x[15] );
280 R( e, a, b, c, d, F1, K1, M(16) );
281 R( d, e, a, b, c, F1, K1, M(17) );
282 R( c, d, e, a, b, F1, K1, M(18) );
283 R( b, c, d, e, a, F1, K1, M(19) );
284 R( a, b, c, d, e, F2, K2, M(20) );
285 R( e, a, b, c, d, F2, K2, M(21) );
286 R( d, e, a, b, c, F2, K2, M(22) );
287 R( c, d, e, a, b, F2, K2, M(23) );
288 R( b, c, d, e, a, F2, K2, M(24) );
289 R( a, b, c, d, e, F2, K2, M(25) );
290 R( e, a, b, c, d, F2, K2, M(26) );
291 R( d, e, a, b, c, F2, K2, M(27) );
292 R( c, d, e, a, b, F2, K2, M(28) );
293 R( b, c, d, e, a, F2, K2, M(29) );
294 R( a, b, c, d, e, F2, K2, M(30) );
295 R( e, a, b, c, d, F2, K2, M(31) );
296 R( d, e, a, b, c, F2, K2, M(32) );
297 R( c, d, e, a, b, F2, K2, M(33) );
298 R( b, c, d, e, a, F2, K2, M(34) );
299 R( a, b, c, d, e, F2, K2, M(35) );
300 R( e, a, b, c, d, F2, K2, M(36) );
301 R( d, e, a, b, c, F2, K2, M(37) );
302 R( c, d, e, a, b, F2, K2, M(38) );
303 R( b, c, d, e, a, F2, K2, M(39) );
304 R( a, b, c, d, e, F3, K3, M(40) );
305 R( e, a, b, c, d, F3, K3, M(41) );
306 R( d, e, a, b, c, F3, K3, M(42) );
307 R( c, d, e, a, b, F3, K3, M(43) );
308 R( b, c, d, e, a, F3, K3, M(44) );
309 R( a, b, c, d, e, F3, K3, M(45) );
310 R( e, a, b, c, d, F3, K3, M(46) );
311 R( d, e, a, b, c, F3, K3, M(47) );
312 R( c, d, e, a, b, F3, K3, M(48) );
313 R( b, c, d, e, a, F3, K3, M(49) );
314 R( a, b, c, d, e, F3, K3, M(50) );
315 R( e, a, b, c, d, F3, K3, M(51) );
316 R( d, e, a, b, c, F3, K3, M(52) );
317 R( c, d, e, a, b, F3, K3, M(53) );
318 R( b, c, d, e, a, F3, K3, M(54) );
319 R( a, b, c, d, e, F3, K3, M(55) );
320 R( e, a, b, c, d, F3, K3, M(56) );
321 R( d, e, a, b, c, F3, K3, M(57) );
322 R( c, d, e, a, b, F3, K3, M(58) );
323 R( b, c, d, e, a, F3, K3, M(59) );
324 R( a, b, c, d, e, F4, K4, M(60) );
325 R( e, a, b, c, d, F4, K4, M(61) );
326 R( d, e, a, b, c, F4, K4, M(62) );
327 R( c, d, e, a, b, F4, K4, M(63) );
328 R( b, c, d, e, a, F4, K4, M(64) );
329 R( a, b, c, d, e, F4, K4, M(65) );
330 R( e, a, b, c, d, F4, K4, M(66) );
331 R( d, e, a, b, c, F4, K4, M(67) );
332 R( c, d, e, a, b, F4, K4, M(68) );
333 R( b, c, d, e, a, F4, K4, M(69) );
334 R( a, b, c, d, e, F4, K4, M(70) );
335 R( e, a, b, c, d, F4, K4, M(71) );
336 R( d, e, a, b, c, F4, K4, M(72) );
337 R( c, d, e, a, b, F4, K4, M(73) );
338 R( b, c, d, e, a, F4, K4, M(74) );
339 R( a, b, c, d, e, F4, K4, M(75) );
340 R( e, a, b, c, d, F4, K4, M(76) );
341 R( d, e, a, b, c, F4, K4, M(77) );
342 R( c, d, e, a, b, F4, K4, M(78) );
343 R( b, c, d, e, a, F4, K4, M(79) );
344
345 a = ctx->A += a;
346 b = ctx->B += b;
347 c = ctx->C += c;
348 d = ctx->D += d;
349 e = ctx->E += e;
350 }
351}
352
353#endif
354
355/*
356 * Hey Emacs!
357 * Local Variables:
358 * coding: utf-8
359 * End:
360 */
diff --git a/gl/sha1-stream.c b/gl/sha256-stream.c
index 393d9ae..0e83380 100644
--- a/gl/sha1-stream.c
+++ b/gl/sha256-stream.c
@@ -1,7 +1,7 @@
1/* sha1.c - Functions to compute SHA1 message digest of files or 1/* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-1. 2 memory blocks according to the NIST specification FIPS-180-2.
3 3
4 Copyright (C) 2000-2001, 2003-2006, 2008-2023 Free Software Foundation, Inc. 4 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
5 5
6 This file is free software: you can redistribute it and/or modify 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 7 it under the terms of the GNU Lesser General Public License as
@@ -16,18 +16,17 @@
16 You should have received a copy of the GNU Lesser General Public License 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/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19/* Written by Scott G. Miller 19/* Written by David Madore, considerably copypasting from
20 Credits: 20 Scott G. Miller's sha1.c
21 Robert Klep <robert@ilse.nl> -- Expansion function fix
22*/ 21*/
23 22
24#include <config.h> 23#include <config.h>
25 24
26/* Specification. */ 25/* Specification. */
27#if HAVE_OPENSSL_SHA1 26#if HAVE_OPENSSL_SHA256
28# define GL_OPENSSL_INLINE _GL_EXTERN_INLINE 27# define GL_OPENSSL_INLINE _GL_EXTERN_INLINE
29#endif 28#endif
30#include "sha1.h" 29#include "sha256.h"
31 30
32#include <stdlib.h> 31#include <stdlib.h>
33 32
@@ -42,13 +41,16 @@
42# error "invalid BLOCKSIZE" 41# error "invalid BLOCKSIZE"
43#endif 42#endif
44 43
45/* Compute SHA1 message digest for bytes read from STREAM. The 44/* Compute message digest for bytes read from STREAM using algorithm ALG.
46 resulting message digest number will be written into the 20 bytes 45 Write the message digest into RESBLOCK, which contains HASHLEN bytes.
47 beginning at RESBLOCK. */ 46 The initial and finishing operations are INIT_CTX and FINISH_CTX.
48int 47 Return zero if and only if successful. */
49sha1_stream (FILE *stream, void *resblock) 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 *))
50{ 52{
51 switch (afalg_stream (stream, "sha1", resblock, SHA1_DIGEST_SIZE)) 53 switch (afalg_stream (stream, alg, resblock, hashlen))
52 { 54 {
53 case 0: return 0; 55 case 0: return 0;
54 case -EIO: return 1; 56 case -EIO: return 1;
@@ -58,8 +60,8 @@ sha1_stream (FILE *stream, void *resblock)
58 if (!buffer) 60 if (!buffer)
59 return 1; 61 return 1;
60 62
61 struct sha1_ctx ctx; 63 struct sha256_ctx ctx;
62 sha1_init_ctx (&ctx); 64 init_ctx (&ctx);
63 size_t sum; 65 size_t sum;
64 66
65 /* Iterate over full file contents. */ 67 /* Iterate over full file contents. */
@@ -106,21 +108,35 @@ sha1_stream (FILE *stream, void *resblock)
106 /* Process buffer with BLOCKSIZE bytes. Note that 108 /* Process buffer with BLOCKSIZE bytes. Note that
107 BLOCKSIZE % 64 == 0 109 BLOCKSIZE % 64 == 0
108 */ 110 */
109 sha1_process_block (buffer, BLOCKSIZE, &ctx); 111 sha256_process_block (buffer, BLOCKSIZE, &ctx);
110 } 112 }
111 113
112 process_partial_block:; 114 process_partial_block:;
113 115
114 /* Process any remaining bytes. */ 116 /* Process any remaining bytes. */
115 if (sum > 0) 117 if (sum > 0)
116 sha1_process_bytes (buffer, sum, &ctx); 118 sha256_process_bytes (buffer, sum, &ctx);
117 119
118 /* Construct result in desired memory. */ 120 /* Construct result in desired memory. */
119 sha1_finish_ctx (&ctx, resblock); 121 finish_ctx (&ctx, resblock);
120 free (buffer); 122 free (buffer);
121 return 0; 123 return 0;
122} 124}
123 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
124/* 140/*
125 * Hey Emacs! 141 * Hey Emacs!
126 * Local Variables: 142 * Local Variables:
diff --git a/gl/sha256.c b/gl/sha256.c
new file mode 100644
index 0000000..e5fea02
--- /dev/null
+++ b/gl/sha256.c
@@ -0,0 +1,432 @@
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-2023 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 <stdint.h>
32#include <string.h>
33
34#include <byteswap.h>
35#ifdef WORDS_BIGENDIAN
36# define SWAP(n) (n)
37#else
38# define SWAP(n) bswap_32 (n)
39#endif
40
41#if ! HAVE_OPENSSL_SHA256
42
43/* This array contains the bytes used to pad the buffer to the next
44 64-byte boundary. */
45static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
46
47
48/*
49 Takes a pointer to a 256 bit block of data (eight 32 bit ints) and
50 initializes it to the start constants of the SHA256 algorithm. This
51 must be called before using hash in the call to sha256_hash
52*/
53void
54sha256_init_ctx (struct sha256_ctx *ctx)
55{
56 ctx->state[0] = 0x6a09e667UL;
57 ctx->state[1] = 0xbb67ae85UL;
58 ctx->state[2] = 0x3c6ef372UL;
59 ctx->state[3] = 0xa54ff53aUL;
60 ctx->state[4] = 0x510e527fUL;
61 ctx->state[5] = 0x9b05688cUL;
62 ctx->state[6] = 0x1f83d9abUL;
63 ctx->state[7] = 0x5be0cd19UL;
64
65 ctx->total[0] = ctx->total[1] = 0;
66 ctx->buflen = 0;
67}
68
69void
70sha224_init_ctx (struct sha256_ctx *ctx)
71{
72 ctx->state[0] = 0xc1059ed8UL;
73 ctx->state[1] = 0x367cd507UL;
74 ctx->state[2] = 0x3070dd17UL;
75 ctx->state[3] = 0xf70e5939UL;
76 ctx->state[4] = 0xffc00b31UL;
77 ctx->state[5] = 0x68581511UL;
78 ctx->state[6] = 0x64f98fa7UL;
79 ctx->state[7] = 0xbefa4fa4UL;
80
81 ctx->total[0] = ctx->total[1] = 0;
82 ctx->buflen = 0;
83}
84
85/* Copy the value from v into the memory location pointed to by *CP,
86 If your architecture allows unaligned access, this is equivalent to
87 * (__typeof__ (v) *) cp = v */
88static void
89set_uint32 (char *cp, uint32_t v)
90{
91 memcpy (cp, &v, sizeof v);
92}
93
94/* Put result from CTX in first 32 bytes following RESBUF.
95 The result must be in little endian byte order. */
96void *
97sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
98{
99 int i;
100 char *r = resbuf;
101
102 for (i = 0; i < 8; i++)
103 set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
104
105 return resbuf;
106}
107
108void *
109sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
110{
111 int i;
112 char *r = resbuf;
113
114 for (i = 0; i < 7; i++)
115 set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
116
117 return resbuf;
118}
119
120/* Process the remaining bytes in the internal buffer and the usual
121 prolog according to the standard and write the result to RESBUF. */
122static void
123sha256_conclude_ctx (struct sha256_ctx *ctx)
124{
125 /* Take yet unprocessed bytes into account. */
126 size_t bytes = ctx->buflen;
127 size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
128
129 /* Now count remaining bytes. */
130 ctx->total[0] += bytes;
131 if (ctx->total[0] < bytes)
132 ++ctx->total[1];
133
134 /* Put the 64-bit file length in *bits* at the end of the buffer.
135 Use set_uint32 rather than a simple assignment, to avoid risk of
136 unaligned access. */
137 set_uint32 ((char *) &ctx->buffer[size - 2],
138 SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)));
139 set_uint32 ((char *) &ctx->buffer[size - 1],
140 SWAP (ctx->total[0] << 3));
141
142 memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
143
144 /* Process last bytes. */
145 sha256_process_block (ctx->buffer, size * 4, ctx);
146}
147
148void *
149sha256_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
150{
151 sha256_conclude_ctx (ctx);
152 return sha256_read_ctx (ctx, resbuf);
153}
154
155void *
156sha224_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
157{
158 sha256_conclude_ctx (ctx);
159 return sha224_read_ctx (ctx, resbuf);
160}
161
162/* Compute SHA256 message digest for LEN bytes beginning at BUFFER. The
163 result is always in little endian byte order, so that a byte-wise
164 output yields to the wanted ASCII representation of the message
165 digest. */
166void *
167sha256_buffer (const char *buffer, size_t len, void *resblock)
168{
169 struct sha256_ctx ctx;
170
171 /* Initialize the computation context. */
172 sha256_init_ctx (&ctx);
173
174 /* Process whole buffer but last len % 64 bytes. */
175 sha256_process_bytes (buffer, len, &ctx);
176
177 /* Put result in desired memory area. */
178 return sha256_finish_ctx (&ctx, resblock);
179}
180
181void *
182sha224_buffer (const char *buffer, size_t len, void *resblock)
183{
184 struct sha256_ctx ctx;
185
186 /* Initialize the computation context. */
187 sha224_init_ctx (&ctx);
188
189 /* Process whole buffer but last len % 64 bytes. */
190 sha256_process_bytes (buffer, len, &ctx);
191
192 /* Put result in desired memory area. */
193 return sha224_finish_ctx (&ctx, resblock);
194}
195
196void
197sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx)
198{
199 /* When we already have some bits in our internal buffer concatenate
200 both inputs first. */
201 if (ctx->buflen != 0)
202 {
203 size_t left_over = ctx->buflen;
204 size_t add = 128 - left_over > len ? len : 128 - left_over;
205
206 memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
207 ctx->buflen += add;
208
209 if (ctx->buflen > 64)
210 {
211 sha256_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
212
213 ctx->buflen &= 63;
214 /* The regions in the following copy operation cannot overlap,
215 because ctx->buflen < 64 ≤ (left_over + add) & ~63. */
216 memcpy (ctx->buffer,
217 &((char *) ctx->buffer)[(left_over + add) & ~63],
218 ctx->buflen);
219 }
220
221 buffer = (const char *) buffer + add;
222 len -= add;
223 }
224
225 /* Process available complete blocks. */
226 if (len >= 64)
227 {
228#if !(_STRING_ARCH_unaligned || _STRING_INLINE_unaligned)
229# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
230 if (UNALIGNED_P (buffer))
231 while (len > 64)
232 {
233 sha256_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
234 buffer = (const char *) buffer + 64;
235 len -= 64;
236 }
237 else
238#endif
239 {
240 sha256_process_block (buffer, len & ~63, ctx);
241 buffer = (const char *) buffer + (len & ~63);
242 len &= 63;
243 }
244 }
245
246 /* Move remaining bytes in internal buffer. */
247 if (len > 0)
248 {
249 size_t left_over = ctx->buflen;
250
251 memcpy (&((char *) ctx->buffer)[left_over], buffer, len);
252 left_over += len;
253 if (left_over >= 64)
254 {
255 sha256_process_block (ctx->buffer, 64, ctx);
256 left_over -= 64;
257 /* The regions in the following copy operation cannot overlap,
258 because left_over ≤ 64. */
259 memcpy (ctx->buffer, &ctx->buffer[16], left_over);
260 }
261 ctx->buflen = left_over;
262 }
263}
264
265/* --- Code below is the primary difference between sha1.c and sha256.c --- */
266
267/* SHA256 round constants */
268#define K(I) sha256_round_constants[I]
269static const uint32_t sha256_round_constants[64] = {
270 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
271 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
272 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,
273 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL,
274 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
275 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL,
276 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL,
277 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL,
278 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL,
279 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
280 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL,
281 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL,
282 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL,
283 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL,
284 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
285 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL,
286};
287
288/* Round functions. */
289#define F2(A,B,C) ( ( A & B ) | ( C & ( A | B ) ) )
290#define F1(E,F,G) ( G ^ ( E & ( F ^ G ) ) )
291
292/* Process LEN bytes of BUFFER, accumulating context into CTX.
293 It is assumed that LEN % 64 == 0.
294 Most of this code comes from GnuPG's cipher/sha1.c. */
295
296void
297sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx)
298{
299 const uint32_t *words = buffer;
300 size_t nwords = len / sizeof (uint32_t);
301 const uint32_t *endp = words + nwords;
302 uint32_t x[16];
303 uint32_t a = ctx->state[0];
304 uint32_t b = ctx->state[1];
305 uint32_t c = ctx->state[2];
306 uint32_t d = ctx->state[3];
307 uint32_t e = ctx->state[4];
308 uint32_t f = ctx->state[5];
309 uint32_t g = ctx->state[6];
310 uint32_t h = ctx->state[7];
311 uint32_t lolen = len;
312
313 /* First increment the byte count. FIPS PUB 180-2 specifies the possible
314 length of the file up to 2^64 bits. Here we only compute the
315 number of bytes. Do a double word increment. */
316 ctx->total[0] += lolen;
317 ctx->total[1] += (len >> 31 >> 1) + (ctx->total[0] < lolen);
318
319#define rol(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
320#define S0(x) (rol(x,25)^rol(x,14)^(x>>3))
321#define S1(x) (rol(x,15)^rol(x,13)^(x>>10))
322#define SS0(x) (rol(x,30)^rol(x,19)^rol(x,10))
323#define SS1(x) (rol(x,26)^rol(x,21)^rol(x,7))
324
325#define M(I) ( tm = S1(x[(I-2)&0x0f]) + x[(I-7)&0x0f] \
326 + S0(x[(I-15)&0x0f]) + x[I&0x0f] \
327 , x[I&0x0f] = tm )
328
329#define R(A,B,C,D,E,F,G,H,K,M) do { t0 = SS0(A) + F2(A,B,C); \
330 t1 = H + SS1(E) \
331 + F1(E,F,G) \
332 + K \
333 + M; \
334 D += t1; H = t0 + t1; \
335 } while(0)
336
337 while (words < endp)
338 {
339 uint32_t tm;
340 uint32_t t0, t1;
341 int t;
342 /* FIXME: see sha1.c for a better implementation. */
343 for (t = 0; t < 16; t++)
344 {
345 x[t] = SWAP (*words);
346 words++;
347 }
348
349 R( a, b, c, d, e, f, g, h, K( 0), x[ 0] );
350 R( h, a, b, c, d, e, f, g, K( 1), x[ 1] );
351 R( g, h, a, b, c, d, e, f, K( 2), x[ 2] );
352 R( f, g, h, a, b, c, d, e, K( 3), x[ 3] );
353 R( e, f, g, h, a, b, c, d, K( 4), x[ 4] );
354 R( d, e, f, g, h, a, b, c, K( 5), x[ 5] );
355 R( c, d, e, f, g, h, a, b, K( 6), x[ 6] );
356 R( b, c, d, e, f, g, h, a, K( 7), x[ 7] );
357 R( a, b, c, d, e, f, g, h, K( 8), x[ 8] );
358 R( h, a, b, c, d, e, f, g, K( 9), x[ 9] );
359 R( g, h, a, b, c, d, e, f, K(10), x[10] );
360 R( f, g, h, a, b, c, d, e, K(11), x[11] );
361 R( e, f, g, h, a, b, c, d, K(12), x[12] );
362 R( d, e, f, g, h, a, b, c, K(13), x[13] );
363 R( c, d, e, f, g, h, a, b, K(14), x[14] );
364 R( b, c, d, e, f, g, h, a, K(15), x[15] );
365 R( a, b, c, d, e, f, g, h, K(16), M(16) );
366 R( h, a, b, c, d, e, f, g, K(17), M(17) );
367 R( g, h, a, b, c, d, e, f, K(18), M(18) );
368 R( f, g, h, a, b, c, d, e, K(19), M(19) );
369 R( e, f, g, h, a, b, c, d, K(20), M(20) );
370 R( d, e, f, g, h, a, b, c, K(21), M(21) );
371 R( c, d, e, f, g, h, a, b, K(22), M(22) );
372 R( b, c, d, e, f, g, h, a, K(23), M(23) );
373 R( a, b, c, d, e, f, g, h, K(24), M(24) );
374 R( h, a, b, c, d, e, f, g, K(25), M(25) );
375 R( g, h, a, b, c, d, e, f, K(26), M(26) );
376 R( f, g, h, a, b, c, d, e, K(27), M(27) );
377 R( e, f, g, h, a, b, c, d, K(28), M(28) );
378 R( d, e, f, g, h, a, b, c, K(29), M(29) );
379 R( c, d, e, f, g, h, a, b, K(30), M(30) );
380 R( b, c, d, e, f, g, h, a, K(31), M(31) );
381 R( a, b, c, d, e, f, g, h, K(32), M(32) );
382 R( h, a, b, c, d, e, f, g, K(33), M(33) );
383 R( g, h, a, b, c, d, e, f, K(34), M(34) );
384 R( f, g, h, a, b, c, d, e, K(35), M(35) );
385 R( e, f, g, h, a, b, c, d, K(36), M(36) );
386 R( d, e, f, g, h, a, b, c, K(37), M(37) );
387 R( c, d, e, f, g, h, a, b, K(38), M(38) );
388 R( b, c, d, e, f, g, h, a, K(39), M(39) );
389 R( a, b, c, d, e, f, g, h, K(40), M(40) );
390 R( h, a, b, c, d, e, f, g, K(41), M(41) );
391 R( g, h, a, b, c, d, e, f, K(42), M(42) );
392 R( f, g, h, a, b, c, d, e, K(43), M(43) );
393 R( e, f, g, h, a, b, c, d, K(44), M(44) );
394 R( d, e, f, g, h, a, b, c, K(45), M(45) );
395 R( c, d, e, f, g, h, a, b, K(46), M(46) );
396 R( b, c, d, e, f, g, h, a, K(47), M(47) );
397 R( a, b, c, d, e, f, g, h, K(48), M(48) );
398 R( h, a, b, c, d, e, f, g, K(49), M(49) );
399 R( g, h, a, b, c, d, e, f, K(50), M(50) );
400 R( f, g, h, a, b, c, d, e, K(51), M(51) );
401 R( e, f, g, h, a, b, c, d, K(52), M(52) );
402 R( d, e, f, g, h, a, b, c, K(53), M(53) );
403 R( c, d, e, f, g, h, a, b, K(54), M(54) );
404 R( b, c, d, e, f, g, h, a, K(55), M(55) );
405 R( a, b, c, d, e, f, g, h, K(56), M(56) );
406 R( h, a, b, c, d, e, f, g, K(57), M(57) );
407 R( g, h, a, b, c, d, e, f, K(58), M(58) );
408 R( f, g, h, a, b, c, d, e, K(59), M(59) );
409 R( e, f, g, h, a, b, c, d, K(60), M(60) );
410 R( d, e, f, g, h, a, b, c, K(61), M(61) );
411 R( c, d, e, f, g, h, a, b, K(62), M(62) );
412 R( b, c, d, e, f, g, h, a, K(63), M(63) );
413
414 a = ctx->state[0] += a;
415 b = ctx->state[1] += b;
416 c = ctx->state[2] += c;
417 d = ctx->state[3] += d;
418 e = ctx->state[4] += e;
419 f = ctx->state[5] += f;
420 g = ctx->state[6] += g;
421 h = ctx->state[7] += h;
422 }
423}
424
425#endif
426
427/*
428 * Hey Emacs!
429 * Local Variables:
430 * coding: utf-8
431 * End:
432 */
diff --git a/gl/sha1.h b/gl/sha256.h
index 5a58b56..2879477 100644
--- a/gl/sha1.h
+++ b/gl/sha256.h
@@ -1,7 +1,6 @@
1/* Declarations of functions and data types used for SHA1 sum 1/* Declarations of functions and data types used for SHA256 and SHA224 sum
2 library functions. 2 library functions.
3 Copyright (C) 2000-2001, 2003, 2005-2006, 2008-2023 Free Software 3 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
4 Foundation, Inc.
5 4
6 This file is free software: you can redistribute it and/or modify 5 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 6 it under the terms of the GNU Lesser General Public License as
@@ -16,13 +15,13 @@
16 You should have received a copy of the GNU Lesser General Public License 15 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/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 17
19#ifndef SHA1_H 18#ifndef SHA256_H
20# define SHA1_H 1 19# define SHA256_H 1
21 20
22# include <stdio.h> 21# include <stdio.h>
23# include <stdint.h> 22# include <stdint.h>
24 23
25# if HAVE_OPENSSL_SHA1 24# if HAVE_OPENSSL_SHA256
26# ifndef OPENSSL_API_COMPAT 25# ifndef OPENSSL_API_COMPAT
27# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */ 26# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */
28# endif 27# endif
@@ -33,72 +32,79 @@
33extern "C" { 32extern "C" {
34# endif 33# endif
35 34
36# define SHA1_DIGEST_SIZE 20 35enum { SHA224_DIGEST_SIZE = 224 / 8 };
36enum { SHA256_DIGEST_SIZE = 256 / 8 };
37 37
38# if HAVE_OPENSSL_SHA1 38# if HAVE_OPENSSL_SHA256
39# define GL_OPENSSL_NAME 1 39# define GL_OPENSSL_NAME 224
40# include "gl_openssl.h"
41# define GL_OPENSSL_NAME 256
40# include "gl_openssl.h" 42# include "gl_openssl.h"
41# else 43# else
42/* Structure to save state of computation between the single steps. */ 44/* Structure to save state of computation between the single steps. */
43struct sha1_ctx 45struct sha256_ctx
44{ 46{
45 uint32_t A; 47 uint32_t state[8];
46 uint32_t B;
47 uint32_t C;
48 uint32_t D;
49 uint32_t E;
50 48
51 uint32_t total[2]; 49 uint32_t total[2];
52 uint32_t buflen; /* ≥ 0, ≤ 128 */ 50 size_t buflen; /* ≥ 0, ≤ 128 */
53 uint32_t buffer[32]; /* 128 bytes; the first buflen bytes are in use */ 51 uint32_t buffer[32]; /* 128 bytes; the first buflen bytes are in use */
54}; 52};
55 53
56/* Initialize structure containing state of computation. */ 54/* Initialize structure containing state of computation. */
57extern void sha1_init_ctx (struct sha1_ctx *ctx); 55extern void sha256_init_ctx (struct sha256_ctx *ctx);
56extern void sha224_init_ctx (struct sha256_ctx *ctx);
58 57
59/* Starting with the result of former calls of this function (or the 58/* Starting with the result of former calls of this function (or the
60 initialization function update the context for the next LEN bytes 59 initialization function update the context for the next LEN bytes
61 starting at BUFFER. 60 starting at BUFFER.
62 It is necessary that LEN is a multiple of 64!!! */ 61 It is necessary that LEN is a multiple of 64!!! */
63extern void sha1_process_block (const void *buffer, size_t len, 62extern void sha256_process_block (const void *buffer, size_t len,
64 struct sha1_ctx *ctx); 63 struct sha256_ctx *ctx);
65 64
66/* Starting with the result of former calls of this function (or the 65/* Starting with the result of former calls of this function (or the
67 initialization function update the context for the next LEN bytes 66 initialization function update the context for the next LEN bytes
68 starting at BUFFER. 67 starting at BUFFER.
69 It is NOT required that LEN is a multiple of 64. */ 68 It is NOT required that LEN is a multiple of 64. */
70extern void sha1_process_bytes (const void *buffer, size_t len, 69extern void sha256_process_bytes (const void *buffer, size_t len,
71 struct sha1_ctx *ctx); 70 struct sha256_ctx *ctx);
72 71
73/* Process the remaining bytes in the buffer and put result from CTX 72/* Process the remaining bytes in the buffer and put result from CTX
74 in first 20 bytes following RESBUF. The result is always in little 73 in first 32 (28) bytes following RESBUF. The result is always in little
75 endian byte order, so that a byte-wise output yields to the wanted 74 endian byte order, so that a byte-wise output yields to the wanted
76 ASCII representation of the message digest. */ 75 ASCII representation of the message digest. */
77extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *restrict resbuf); 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 78
79 79
80/* Put result from CTX in first 20 bytes following RESBUF. The result is 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 81 always in little endian byte order, so that a byte-wise output yields
82 to the wanted ASCII representation of the message digest. */ 82 to the wanted ASCII representation of the message digest. */
83extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *restrict resbuf); 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);
84 87
85 88
86/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The 89/* Compute SHA256 (SHA224) message digest for LEN bytes beginning at BUFFER.
87 result is always in little endian byte order, so that a byte-wise 90 The result is always in little endian byte order, so that a byte-wise
88 output yields to the wanted ASCII representation of the message 91 output yields to the wanted ASCII representation of the message
89 digest. */ 92 digest. */
90extern void *sha1_buffer (const char *buffer, size_t len, 93extern void *sha256_buffer (const char *buffer, size_t len,
91 void *restrict resblock); 94 void *restrict resblock);
95extern void *sha224_buffer (const char *buffer, size_t len,
96 void *restrict resblock);
92 97
93# endif 98# endif
94 99
95/* Compute SHA1 message digest for bytes read from STREAM. 100/* Compute SHA256 (SHA224) message digest for bytes read from STREAM.
96 STREAM is an open file stream. Regular files are handled more efficiently. 101 STREAM is an open file stream. Regular files are handled more efficiently.
97 The contents of STREAM from its current position to its end will be read. 102 The contents of STREAM from its current position to its end will be read.
98 The case that the last operation on STREAM was an 'ungetc' is not supported. 103 The case that the last operation on STREAM was an 'ungetc' is not supported.
99 The resulting message digest number will be written into the 20 bytes 104 The resulting message digest number will be written into the 32 (28) bytes
100 beginning at RESBLOCK. */ 105 beginning at RESBLOCK. */
101extern int sha1_stream (FILE *stream, void *resblock); 106extern int sha256_stream (FILE *stream, void *resblock);
107extern int sha224_stream (FILE *stream, void *resblock);
102 108
103 109
104# ifdef __cplusplus 110# ifdef __cplusplus
diff --git a/gl/stdckdint.h b/gl/stdckdint.h
new file mode 100644
index 0000000..edcda29
--- /dev/null
+++ b/gl/stdckdint.h
@@ -0,0 +1,36 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* stdckdint.h -- checked integer arithmetic
3
4 Copyright 2022-2023 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/* Store into *R the low-order bits of A + B, A - B, A * B, respectively.
25 Return 1 if the result overflows, 0 otherwise.
26 A, B, and *R can have any integer type other than char, bool, a
27 bit-precise integer type, or an enumeration type.
28
29 These are like the standard macros introduced in C23, except that
30 arguments should not have side effects. */
31
32#define ckd_add(r, a, b) ((bool) _GL_INT_ADD_WRAPV (a, b, r))
33#define ckd_sub(r, a, b) ((bool) _GL_INT_SUBTRACT_WRAPV (a, b, r))
34#define ckd_mul(r, a, b) ((bool) _GL_INT_MULTIPLY_WRAPV (a, b, r))
35
36#endif /* _GL_STDCKDINT_H */