Debian Codegraph @

lib/stdlib.in.h

raw
1 /* A GNU-like <stdlib.h>.
2
3 Copyright (C) 1995, 2001-2004, 2006-2026 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18 #if __GNUC__ >= 3
19 @PRAGMA_SYSTEM_HEADER@
20 #endif
21 @PRAGMA_COLUMNS@
22
23 #if ((defined __need_system_stdlib_h && !defined _GLIBCXX_STDLIB_H) \
24 || defined __need_malloc_and_calloc) \
25 && !defined __SUNPRO_CC
26 /* Special invocation conventions inside some gnulib header files,
27 and inside some glibc header files, respectively.
28 Do not recognize this special invocation convention when GCC's
29 c++/11/stdlib.h is being included or has been included. This is needed
30 to support the use of clang+llvm binaries on Ubuntu 22.04 with
31 CXX="$clangdir/bin/clang++ -I/usr/include/c++/11 \
32 -I/usr/include/x86_64-linux-gnu/c++/11
33 -L/usr/lib/gcc/x86_64-linux-gnu/11
34 -Wl,-rpath,$clangdir/lib"
35 because in this case /usr/include/c++/11/stdlib.h (which does not support
36 the convention) is seen before the gnulib-generated stdlib.h. */
37
38 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
39
40 /* Make sure that the macros that indicate the special invocation convention
41 get undefined. This is needed at least on CentOS 7. */
42 #undef __need_malloc_and_calloc
43
44 #else
45 /* Normal invocation convention. */
46
47 #ifndef _@GUARD_PREFIX@_STDLIB_H
48
49 /* The include_next requires a split double-inclusion guard. */
50 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
51
52 #ifndef _@GUARD_PREFIX@_STDLIB_H
53 #define _@GUARD_PREFIX@_STDLIB_H
54
55 /* This file uses _Noreturn, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
56 _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE,
57 _GL_INLINE_HEADER_BEGIN, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
58 #if !_GL_CONFIG_H_INCLUDED
59 #error "Please include config.h first."
60 #endif
61
62 /* NetBSD 5.0 mis-defines NULL. */
63 #include <stddef.h>
64
65 /* Solaris declares getloadavg() in <sys/loadavg.h>. */
66 #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
67 /* OpenIndiana has a bug: <sys/time.h> must be included before
68 <sys/loadavg.h>. */
69 # include <sys/time.h>
70 # include <sys/loadavg.h>
71 #endif
72
73 /* QNX declares getprogname() in <sys/process.h>. */
74 #if (@GNULIB_GETPROGNAME@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_PROCESS_H@
75 # include <sys/process.h>
76 #endif
77
78 /* Native Windows platforms declare _mktemp() in <io.h>. */
79 #if defined _WIN32 && !defined __CYGWIN__
80 # include <io.h>
81 #endif
82
83 #if @GNULIB_RANDOM_R@
84
85 # include <stdint.h>
86
87 # if !@HAVE_STRUCT_RANDOM_DATA@
88 /* Define 'struct random_data'.
89 But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
90 # if !GNULIB_defined_struct_random_data
91 struct random_data
92 {
93 int32_t *fptr; /* Front pointer. */
94 int32_t *rptr; /* Rear pointer. */
95 int32_t *state; /* Array of state values. */
96 int rand_type; /* Type of random number generator. */
97 int rand_deg; /* Degree of random number generator. */
98 int rand_sep; /* Distance between front and rear. */
99 int32_t *end_ptr; /* Pointer behind state table. */
100 };
101 # define GNULIB_defined_struct_random_data 1
102 # endif
103 # endif
104 #endif
105
106 #if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_MKOSTEMP@ || @GNULIB_MKOSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !(defined _WIN32 && ! defined __CYGWIN__)
107 /* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */
108 /* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */
109 /* On Mac OS X 10.13, only <unistd.h> declares mkostemp and mkostemps. */
110 /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
111 /* But avoid namespace pollution on glibc systems and native Windows. */
112 # include <unistd.h>
113 #endif
114
115 #if ((@GNULIB_STRTOL@ && @REPLACE_STRTOL@) || (@GNULIB_STRTOLL@ && @REPLACE_STRTOLL@) || (@GNULIB_STRTOUL@ && @REPLACE_STRTOUL@) || (@GNULIB_STRTOULL@ && @REPLACE_STRTOULL@)) && defined __cplusplus && !defined GNULIB_NAMESPACE && defined __GNUG__ && !defined __clang__ && (defined __sun || defined _AIX)
116 /* When strtol, strtoll, strtoul, or strtoull is going to be defined as a macro
117 below, this may cause compilation errors later in the libstdc++ header files
118 (that are part of GCC), such as:
119 error: 'rpl_strtol' is not a member of 'std'
120 To avoid this, include the relevant header files here, before these symbols
121 get defined as macros. But do so only on Solaris 11 and AIX (where it is
122 needed), not on mingw (where it would cause other compilation errors). */
123 # include <string>
124 #endif
125
126 _GL_INLINE_HEADER_BEGIN
127 #ifndef _GL_STDLIB_INLINE
128 # define _GL_STDLIB_INLINE _GL_INLINE
129 #endif
130 #ifndef _GL_REALLOC_INLINE
131 # define _GL_REALLOC_INLINE _GL_INLINE
132 #endif
133
134 /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
135 that can be freed by passing them as the Ith argument to the
136 function F. */
137 #ifndef _GL_ATTRIBUTE_DEALLOC
138 # if __GNUC__ >= 11 && !defined __clang__
139 # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
140 # else
141 # define _GL_ATTRIBUTE_DEALLOC(f, i)
142 # endif
143 #endif
144
145 /* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
146 can be freed via 'free'; it can be used only after declaring 'free'. */
147 /* Applies to: functions. Cannot be used on inline functions. */
148 #ifndef _GL_ATTRIBUTE_DEALLOC_FREE
149 # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
150 #endif
151
152 /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
153 allocated memory. */
154 /* Applies to: functions. */
155 #ifndef _GL_ATTRIBUTE_MALLOC
156 # if __GNUC__ >= 3 || defined __clang__
157 # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
158 # else
159 # define _GL_ATTRIBUTE_MALLOC
160 # endif
161 #endif
162
163 /* _GL_ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) declares that the argument NP
164 (a pointer) must not be NULL if the argument NI (an integer) is != 0. */
165 /* Applies to: functions. */
166 #ifndef _GL_ATTRIBUTE_NONNULL_IF_NONZERO
167 # if __GNUC__ >= 15 && !defined __clang__
168 # define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) \
169 __attribute__ ((__nonnull_if_nonzero__ (np, ni)))
170 # else
171 # define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni)
172 # endif
173 #endif
174
175 /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
176 */
177 #ifndef _GL_ATTRIBUTE_NOTHROW
178 # if defined __cplusplus
179 # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
180 # if __cplusplus >= 201103L
181 # define _GL_ATTRIBUTE_NOTHROW noexcept (true)
182 # else
183 # define _GL_ATTRIBUTE_NOTHROW throw ()
184 # endif
185 # else
186 # define _GL_ATTRIBUTE_NOTHROW
187 # endif
188 # else
189 # if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
190 # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
191 # else
192 # define _GL_ATTRIBUTE_NOTHROW
193 # endif
194 # endif
195 #endif
196
197 /* The __attribute__ feature is available in gcc versions 2.5 and later.
198 The attribute __pure__ was added in gcc 2.96. */
199 #ifndef _GL_ATTRIBUTE_PURE
200 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
201 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
202 # else
203 # define _GL_ATTRIBUTE_PURE /* empty */
204 # endif
205 #endif
206
207 /* The definition of _Noreturn is copied here. */
208
209 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
210
211 /* The definition of _GL_ARG_NONNULL is copied here. */
212
213 /* The definition of _GL_WARN_ON_USE is copied here. */
214
215
216 /* Some systems do not define EXIT_*, despite otherwise supporting C89. */
217 #ifndef EXIT_SUCCESS
218 # define EXIT_SUCCESS 0
219 #endif
220 /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
221 with proper operation of xargs. */
222 #ifndef EXIT_FAILURE
223 # define EXIT_FAILURE 1
224 #elif EXIT_FAILURE != 1
225 # undef EXIT_FAILURE
226 # define EXIT_FAILURE 1
227 #endif
228
229
230 /* Declarations for ISO C N3322. */
231 #if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__
232 _GL_EXTERN_C void *_GL_FUNCDECL_SYS_NAME (bsearch)
233 (const void *__key, const void *__base, size_t __nmemb, size_t __size,
234 int (*__compare) (const void *, const void *))
235 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3) _GL_ARG_NONNULL ((5));
236 _GL_EXTERN_C void qsort (void *__base, size_t __nmemb, size_t __size,
237 int (*__compare) (const void *, const void *))
238 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) _GL_ARG_NONNULL ((4));
239 #endif
240
241
242 #if @GNULIB__EXIT@
243 /* Terminate the current process with the given return code, without running
244 the 'atexit' handlers. */
245 # if @REPLACE__EXIT@
246 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
247 # undef _Exit
248 # define _Exit rpl__Exit
249 # endif
250 _GL_FUNCDECL_RPL (_Exit, _Noreturn void, (int status), );
251 _GL_CXXALIAS_RPL (_Exit, void, (int status));
252 # else
253 # if !@HAVE__EXIT@
254 _GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status), );
255 # endif
256 _GL_CXXALIAS_SYS (_Exit, void, (int status));
257 # endif
258 # if __GLIBC__ >= 2
259 _GL_CXXALIASWARN (_Exit);
260 # endif
261 #elif defined GNULIB_POSIXCHECK
262 # if HAVE_RAW_DECL__EXIT
263 _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
264 "use gnulib module _Exit for portability");
265 # endif
266 #endif
267
268
269 #if @GNULIB_ABORT_DEBUG@
270 /* Terminates the current process with signal SIGABRT.
271 Note: While the original abort() function is safe to call in signal handlers,
272 the overridden abort() function is not. */
273 # if @REPLACE_ABORT@
274 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
275 # undef abort
276 # define abort rpl_abort
277 # endif
278 _GL_FUNCDECL_RPL (abort, _Noreturn void, (void), );
279 _GL_CXXALIAS_RPL (abort, void, (void));
280 # else
281 _GL_CXXALIAS_SYS (abort, void, (void));
282 # endif
283 # if __GLIBC__ >= 2
284 _GL_CXXALIASWARN (abort);
285 # endif
286 #endif
287
288
289 #if @GNULIB_FREE_POSIX@
290 # if @REPLACE_FREE@
291 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
292 # undef free
293 # define free rpl_free
294 # endif
295 # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
296 _GL_FUNCDECL_RPL (free, void, (void *ptr), ) _GL_ATTRIBUTE_NOTHROW;
297 # else
298 _GL_FUNCDECL_RPL (free, void, (void *ptr), );
299 # endif
300 _GL_CXXALIAS_RPL (free, void, (void *ptr));
301 # else
302 _GL_CXXALIAS_SYS (free, void, (void *ptr));
303 # endif
304 # if __GLIBC__ >= 2
305 _GL_CXXALIASWARN (free);
306 # endif
307 #elif defined GNULIB_POSIXCHECK
308 /* Assume free is always declared. */
309 _GL_WARN_ON_USE (free, "free is not POSIX:2024 compliant everywhere - "
310 "use gnulib module free-posix for portability");
311 #endif
312
313
314 /* Allocate memory with indefinite extent and specified alignment. */
315 #if @GNULIB_ALIGNED_ALLOC@
316 # if @REPLACE_ALIGNED_ALLOC@
317 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
318 # undef aligned_alloc
319 # define aligned_alloc rpl_aligned_alloc
320 # endif
321 _GL_FUNCDECL_RPL (aligned_alloc, void *,
322 (size_t alignment, size_t size),
323 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
324 _GL_ATTRIBUTE_NODISCARD);
325 _GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size));
326 # else
327 # if @HAVE_ALIGNED_ALLOC@
328 # if __GNUC__ >= 11 && !defined __clang__
329 /* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
330 # if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
331 _GL_FUNCDECL_SYS (aligned_alloc, void *,
332 (size_t alignment, size_t size),
333 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
334 _GL_ATTRIBUTE_NODISCARD)
335 _GL_ATTRIBUTE_NOTHROW;
336 # else
337 _GL_FUNCDECL_SYS (aligned_alloc, void *,
338 (size_t alignment, size_t size),
339 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
340 _GL_ATTRIBUTE_NODISCARD);
341 # endif
342 # endif
343 _GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size));
344 # endif
345 # endif
346 # if (__GLIBC__ >= 2) && @HAVE_ALIGNED_ALLOC@
347 _GL_CXXALIASWARN (aligned_alloc);
348 # endif
349 #else
350 # if @GNULIB_FREE_POSIX@ \
351 && (__GNUC__ >= 11 && !defined __clang__) && !defined aligned_alloc
352 /* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
353 # if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
354 _GL_FUNCDECL_SYS (aligned_alloc, void *,
355 (size_t alignment, size_t size),
356 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
357 _GL_ATTRIBUTE_NOTHROW;
358 # else
359 _GL_FUNCDECL_SYS (aligned_alloc, void *,
360 (size_t alignment, size_t size),
361 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
362 # endif
363 # endif
364 # if defined GNULIB_POSIXCHECK
365 # if HAVE_RAW_DECL_ALIGNED_ALLOC
366 _GL_WARN_ON_USE (aligned_alloc, "aligned_alloc is not portable - "
367 "use gnulib module aligned_alloc for portability");
368 # endif
369 # endif
370 #endif
371
372 #if @GNULIB_ATOLL@
373 /* Parse a signed decimal integer.
374 Returns the value of the integer. Errors are not detected. */
375 # if !@HAVE_ATOLL@
376 _GL_FUNCDECL_SYS (atoll, long long,
377 (const char *string),
378 _GL_ATTRIBUTE_PURE
379 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
380 # endif
381 _GL_CXXALIAS_SYS (atoll, long long, (const char *string));
382 _GL_CXXALIASWARN (atoll);
383 #elif defined GNULIB_POSIXCHECK
384 # if HAVE_RAW_DECL_ATOLL
385 _GL_WARN_ON_USE (atoll, "atoll is unportable - "
386 "use gnulib module atoll for portability");
387 # endif
388 #endif
389
390 #if @GNULIB_CALLOC_POSIX@
391 # if @REPLACE_CALLOC_FOR_CALLOC_POSIX@ \
392 || (@GNULIB_CALLOC_GNU@ && @REPLACE_CALLOC_FOR_CALLOC_GNU@)
393 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
394 || _GL_USE_STDLIB_ALLOC)
395 # undef calloc
396 # define calloc rpl_calloc
397 # endif
398 _GL_FUNCDECL_RPL (calloc, void *,
399 (size_t nmemb, size_t size),
400 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
401 _GL_ATTRIBUTE_NODISCARD);
402 _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
403 # else
404 # if __GNUC__ >= 11 && !defined __clang__
405 /* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
406 # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
407 _GL_FUNCDECL_SYS (calloc, void *,
408 (size_t nmemb, size_t size),
409 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
410 _GL_ATTRIBUTE_NODISCARD)
411 _GL_ATTRIBUTE_NOTHROW;
412 # else
413 _GL_FUNCDECL_SYS (calloc, void *,
414 (size_t nmemb, size_t size),
415 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
416 _GL_ATTRIBUTE_NODISCARD);
417 # endif
418 # endif
419 _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
420 # endif
421 # if __GLIBC__ >= 2
422 _GL_CXXALIASWARN (calloc);
423 # endif
424 #else
425 # if @GNULIB_FREE_POSIX@ \
426 && (__GNUC__ >= 11 && !defined __clang__) && !defined calloc
427 /* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
428 # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
429 _GL_FUNCDECL_SYS (calloc, void *,
430 (size_t nmemb, size_t size),
431 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
432 _GL_ATTRIBUTE_NOTHROW;
433 # else
434 _GL_FUNCDECL_SYS (calloc, void *,
435 (size_t nmemb, size_t size),
436 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
437 # endif
438 # endif
439 # if defined GNULIB_POSIXCHECK
440 /* Assume calloc is always declared. */
441 _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
442 "use gnulib module calloc-posix for portability");
443 # endif
444 #endif
445
446 #if @GNULIB_CANONICALIZE_FILE_NAME@
447 # if @REPLACE_CANONICALIZE_FILE_NAME@
448 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
449 # define canonicalize_file_name rpl_canonicalize_file_name
450 # endif
451 _GL_FUNCDECL_RPL (canonicalize_file_name, char *,
452 (const char *name),
453 _GL_ARG_NONNULL ((1))
454 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
455 _GL_ATTRIBUTE_NODISCARD);
456 _GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
457 # else
458 # if !@HAVE_CANONICALIZE_FILE_NAME@ || (__GNUC__ >= 11 && !defined __clang__)
459 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
460 _GL_FUNCDECL_SYS (canonicalize_file_name, char *,
461 (const char *name),
462 _GL_ARG_NONNULL ((1))
463 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
464 _GL_ATTRIBUTE_NODISCARD)
465 _GL_ATTRIBUTE_NOTHROW;
466 # else
467 _GL_FUNCDECL_SYS (canonicalize_file_name, char *,
468 (const char *name),
469 _GL_ARG_NONNULL ((1))
470 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
471 _GL_ATTRIBUTE_NODISCARD);
472 # endif
473 # endif
474 _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
475 # endif
476 # ifndef GNULIB_defined_canonicalize_file_name
477 # define GNULIB_defined_canonicalize_file_name \
478 (!@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@)
479 # endif
480 _GL_CXXALIASWARN (canonicalize_file_name);
481 #else
482 # if @GNULIB_FREE_POSIX@ \
483 && (__GNUC__ >= 11 && !defined __clang__) && !defined canonicalize_file_name
484 /* For -Wmismatched-dealloc: Associate canonicalize_file_name with free or
485 rpl_free. */
486 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
487 _GL_FUNCDECL_SYS (canonicalize_file_name, char *,
488 (const char *name),
489 _GL_ARG_NONNULL ((1))
490 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
491 _GL_ATTRIBUTE_NOTHROW;
492 # else
493 _GL_FUNCDECL_SYS (canonicalize_file_name, char *,
494 (const char *name),
495 _GL_ARG_NONNULL ((1))
496 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
497 # endif
498 # endif
499 # if defined GNULIB_POSIXCHECK
500 # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
501 _GL_WARN_ON_USE (canonicalize_file_name,
502 "canonicalize_file_name is unportable - "
503 "use gnulib module canonicalize-lgpl for portability");
504 # endif
505 # endif
506 #endif
507
508 #if @GNULIB_MDA_ECVT@
509 /* On native Windows, map 'ecvt' to '_ecvt', so that -loldnames is not
510 required. In C++ with GNULIB_NAMESPACE, avoid differences between
511 platforms by defining GNULIB_NAMESPACE::ecvt on all platforms that have
512 it. */
513 # if defined _WIN32 && !defined __CYGWIN__
514 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
515 # undef ecvt
516 # define ecvt _ecvt
517 # endif
518 _GL_CXXALIAS_MDA (ecvt, char *,
519 (double number, int ndigits, int *decptp, int *signp));
520 # else
521 # if @HAVE_DECL_ECVT@
522 _GL_CXXALIAS_SYS (ecvt, char *,
523 (double number, int ndigits, int *decptp, int *signp));
524 # endif
525 # endif
526 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_ECVT@
527 _GL_CXXALIASWARN (ecvt);
528 # endif
529 #endif
530
531 #if @GNULIB_MDA_FCVT@
532 /* On native Windows, map 'fcvt' to '_fcvt', so that -loldnames is not
533 required. In C++ with GNULIB_NAMESPACE, avoid differences between
534 platforms by defining GNULIB_NAMESPACE::fcvt on all platforms that have
535 it. */
536 # if defined _WIN32 && !defined __CYGWIN__
537 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
538 # undef fcvt
539 # define fcvt _fcvt
540 # endif
541 _GL_CXXALIAS_MDA (fcvt, char *,
542 (double number, int ndigits, int *decptp, int *signp));
543 # else
544 # if @HAVE_DECL_FCVT@
545 _GL_CXXALIAS_SYS (fcvt, char *,
546 (double number, int ndigits, int *decptp, int *signp));
547 # endif
548 # endif
549 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_FCVT@
550 _GL_CXXALIASWARN (fcvt);
551 # endif
552 #endif
553
554 #if @GNULIB_MDA_GCVT@
555 /* On native Windows, map 'gcvt' to '_gcvt', so that -loldnames is not
556 required. In C++ with GNULIB_NAMESPACE, avoid differences between
557 platforms by defining GNULIB_NAMESPACE::gcvt on all platforms that have
558 it. */
559 # if defined _WIN32 && !defined __CYGWIN__
560 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
561 # undef gcvt
562 # define gcvt _gcvt
563 # endif
564 _GL_CXXALIAS_MDA (gcvt, char *, (double number, int ndigits, char *buf));
565 # else
566 # if @HAVE_DECL_GCVT@
567 _GL_CXXALIAS_SYS (gcvt, char *, (double number, int ndigits, char *buf));
568 # endif
569 # endif
570 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_GCVT@
571 _GL_CXXALIASWARN (gcvt);
572 # endif
573 #endif
574
575 #if @GNULIB_GETLOADAVG@
576 /* Store max(NELEM,3) load average numbers in LOADAVG[].
577 The three numbers are the load average of the last 1 minute, the last 5
578 minutes, and the last 15 minutes, respectively.
579 LOADAVG is an array of NELEM numbers. */
580 # if @REPLACE_GETLOADAVG@
581 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
582 # undef getloadavg
583 # define getloadavg rpl_getloadavg
584 # endif
585 _GL_FUNCDECL_RPL (getloadavg, int, (double loadavg[], int nelem),
586 _GL_ARG_NONNULL ((1)));
587 _GL_CXXALIAS_RPL (getloadavg, int, (double loadavg[], int nelem));
588 # else
589 # if !@HAVE_DECL_GETLOADAVG@
590 _GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem),
591 _GL_ARG_NONNULL ((1)));
592 # endif
593 _GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
594 # endif
595 # if __GLIBC__ >= 2
596 _GL_CXXALIASWARN (getloadavg);
597 # endif
598 #elif defined GNULIB_POSIXCHECK
599 # if HAVE_RAW_DECL_GETLOADAVG
600 _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
601 "use gnulib module getloadavg for portability");
602 # endif
603 #endif
604
605 #if @GNULIB_GETPROGNAME@
606 /* Return the base name of the executing program.
607 On native Windows this will usually end in ".exe" or ".EXE". */
608 # if @REPLACE_GETPROGNAME@
609 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
610 # undef getprogname
611 # define getprogname rpl_getprogname
612 # endif
613 # if @HAVE_DECL_PROGRAM_INVOCATION_NAME@
614 _GL_FUNCDECL_RPL (getprogname, const char *, (void), _GL_ATTRIBUTE_PURE);
615 # else
616 _GL_FUNCDECL_RPL (getprogname, const char *, (void), );
617 # endif
618 _GL_CXXALIAS_RPL (getprogname, const char *, (void));
619 # else
620 # if !@HAVE_GETPROGNAME@
621 # if @HAVE_DECL_PROGRAM_INVOCATION_NAME@
622 _GL_FUNCDECL_SYS (getprogname, const char *, (void), _GL_ATTRIBUTE_PURE);
623 # else
624 _GL_FUNCDECL_SYS (getprogname, const char *, (void), );
625 # endif
626 # endif
627 _GL_CXXALIAS_SYS (getprogname, const char *, (void));
628 # endif
629 # if __GLIBC__ >= 2
630 _GL_CXXALIASWARN (getprogname);
631 # endif
632 #elif defined GNULIB_POSIXCHECK
633 # if HAVE_RAW_DECL_GETPROGNAME
634 _GL_WARN_ON_USE (getprogname, "getprogname is unportable - "
635 "use gnulib module getprogname for portability");
636 # endif
637 #endif
638
639 #if @GNULIB_GETSUBOPT@
640 /* Assuming *OPTIONP is a comma separated list of elements of the form
641 "token" or "token=value", getsubopt parses the first of these elements.
642 If the first element refers to a "token" that is member of the given
643 NULL-terminated array of tokens:
644 - It replaces the comma with a NUL byte, updates *OPTIONP to point past
645 the first option and the comma, sets *VALUEP to the value of the
646 element (or NULL if it doesn't contain an "=" sign),
647 - It returns the index of the "token" in the given array of tokens.
648 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
649 For more details see the POSIX specification.
650 https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html */
651 # if @REPLACE_GETSUBOPT@
652 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
653 # undef getsubopt
654 # define getsubopt rpl_getsubopt
655 # endif
656 _GL_FUNCDECL_RPL (getsubopt, int,
657 (char **optionp, char *const *tokens, char **valuep),
658 _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD);
659 _GL_CXXALIAS_RPL (getsubopt, int,
660 (char **optionp, char *const *tokens, char **valuep));
661 # else
662 # if !@HAVE_GETSUBOPT@
663 _GL_FUNCDECL_SYS (getsubopt, int,
664 (char **optionp, char *const *tokens, char **valuep),
665 _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD);
666 # endif
667 _GL_CXXALIAS_SYS (getsubopt, int,
668 (char **optionp, char *const *tokens, char **valuep));
669 # endif
670 # if __GLIBC__ >= 2
671 _GL_CXXALIASWARN (getsubopt);
672 # endif
673 #elif defined GNULIB_POSIXCHECK
674 # if HAVE_RAW_DECL_GETSUBOPT
675 _GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
676 "use gnulib module getsubopt for portability");
677 # endif
678 #endif
679
680 #if @GNULIB_GRANTPT@
681 /* Change the ownership and access permission of the slave side of the
682 pseudo-terminal whose master side is specified by FD. */
683 # if !@HAVE_GRANTPT@
684 _GL_FUNCDECL_SYS (grantpt, int, (int fd), );
685 # endif
686 _GL_CXXALIAS_SYS (grantpt, int, (int fd));
687 _GL_CXXALIASWARN (grantpt);
688 #elif defined GNULIB_POSIXCHECK
689 # if HAVE_RAW_DECL_GRANTPT
690 _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
691 "use gnulib module grantpt for portability");
692 # endif
693 #endif
694
695 /* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
696 rely on GNU or POSIX semantics for malloc and realloc (for example,
697 by never specifying a zero size), so it does not need malloc or
698 realloc to be redefined. */
699 #if @GNULIB_MALLOC_POSIX@
700 # if @REPLACE_MALLOC_FOR_MALLOC_POSIX@ \
701 || (@GNULIB_MALLOC_GNU@ && @REPLACE_MALLOC_FOR_MALLOC_GNU@)
702 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
703 || _GL_USE_STDLIB_ALLOC)
704 # undef malloc
705 # define malloc rpl_malloc
706 # endif
707 _GL_FUNCDECL_RPL (malloc, void *,
708 (size_t size),
709 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
710 _GL_ATTRIBUTE_NODISCARD);
711 _GL_CXXALIAS_RPL (malloc, void *, (size_t size));
712 # else
713 # if __GNUC__ >= 11 && !defined __clang__
714 /* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
715 # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
716 _GL_FUNCDECL_SYS (malloc, void *,
717 (size_t size),
718 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
719 _GL_ATTRIBUTE_NODISCARD)
720 _GL_ATTRIBUTE_NOTHROW;
721 # else
722 _GL_FUNCDECL_SYS (malloc, void *,
723 (size_t size),
724 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
725 _GL_ATTRIBUTE_NODISCARD);
726 # endif
727 # endif
728 _GL_CXXALIAS_SYS (malloc, void *, (size_t size));
729 # endif
730 # if __GLIBC__ >= 2
731 _GL_CXXALIASWARN (malloc);
732 # endif
733 #else
734 # if @GNULIB_FREE_POSIX@ \
735 && (__GNUC__ >= 11 && !defined __clang__) && !defined malloc
736 /* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
737 # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
738 _GL_FUNCDECL_SYS (malloc, void *,
739 (size_t size),
740 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
741 _GL_ATTRIBUTE_NOTHROW;
742 # else
743 _GL_FUNCDECL_SYS (malloc, void *,
744 (size_t size),
745 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
746 # endif
747 # endif
748 # if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
749 /* Assume malloc is always declared. */
750 _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
751 "use gnulib module malloc-posix for portability");
752 # endif
753 #endif
754
755 /* Return maximum number of bytes in a multibyte character in the
756 current locale. */
757 #if @REPLACE_MB_CUR_MAX@
758 # if !GNULIB_defined_MB_CUR_MAX
759 _GL_STDLIB_INLINE size_t
760 gl_MB_CUR_MAX (void)
761 {
762 # if 0 < @REPLACE_MB_CUR_MAX@
763 return @REPLACE_MB_CUR_MAX@;
764 # else
765 /* Turn the value 3 to the value 4, as needed for the UTF-8 encoding. */
766 int gl_mb_cur_max = MB_CUR_MAX;
767 return gl_mb_cur_max == 3 ? 4 : gl_mb_cur_max;
768 # endif
769 }
770 # undef MB_CUR_MAX
771 # define MB_CUR_MAX gl_MB_CUR_MAX ()
772 # define GNULIB_defined_MB_CUR_MAX 1
773 # endif
774 #endif
775
776 /* Convert a string to a wide string. */
777 #if @GNULIB_MBSTOWCS@
778 # if @REPLACE_MBSTOWCS@
779 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
780 # undef mbstowcs
781 # define mbstowcs rpl_mbstowcs
782 # endif
783 _GL_FUNCDECL_RPL (mbstowcs, size_t,
784 (wchar_t *restrict dest, const char *restrict src,
785 size_t len),
786 _GL_ARG_NONNULL ((2)));
787 _GL_CXXALIAS_RPL (mbstowcs, size_t,
788 (wchar_t *restrict dest, const char *restrict src,
789 size_t len));
790 # else
791 _GL_CXXALIAS_SYS (mbstowcs, size_t,
792 (wchar_t *restrict dest, const char *restrict src,
793 size_t len));
794 # endif
795 # if __GLIBC__ >= 2
796 _GL_CXXALIASWARN (mbstowcs);
797 # endif
798 #elif defined GNULIB_POSIXCHECK
799 # if HAVE_RAW_DECL_MBSTOWCS
800 _GL_WARN_ON_USE (mbstowcs, "mbstowcs is unportable - "
801 "use gnulib module mbstowcs for portability");
802 # endif
803 #endif
804
805 /* Convert a multibyte character to a wide character. */
806 #if @GNULIB_MBTOWC@
807 # if @REPLACE_MBTOWC@
808 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
809 # undef mbtowc
810 # define mbtowc rpl_mbtowc
811 # endif
812 _GL_FUNCDECL_RPL (mbtowc, int,
813 (wchar_t *restrict pwc, const char *restrict s, size_t n), );
814 _GL_CXXALIAS_RPL (mbtowc, int,
815 (wchar_t *restrict pwc, const char *restrict s, size_t n));
816 # else
817 # if !@HAVE_MBTOWC@
818 _GL_FUNCDECL_SYS (mbtowc, int,
819 (wchar_t *restrict pwc, const char *restrict s, size_t n), );
820 # endif
821 _GL_CXXALIAS_SYS (mbtowc, int,
822 (wchar_t *restrict pwc, const char *restrict s, size_t n));
823 # endif
824 # if __GLIBC__ >= 2
825 _GL_CXXALIASWARN (mbtowc);
826 # endif
827 #elif defined GNULIB_POSIXCHECK
828 # if HAVE_RAW_DECL_MBTOWC
829 _GL_WARN_ON_USE (mbtowc, "mbtowc is not portable - "
830 "use gnulib module mbtowc for portability");
831 # endif
832 #endif
833
834 #if @GNULIB_MKDTEMP@
835 /* Create a unique temporary directory from TEMPLATE.
836 The last six characters of TEMPLATE must be "XXXXXX";
837 they are replaced with a string that makes the directory name unique.
838 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
839 The directory is created mode 700. */
840 # if !@HAVE_MKDTEMP@
841 _GL_FUNCDECL_SYS (mkdtemp, char *,
842 (char * /*template*/),
843 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
844 # endif
845 _GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
846 _GL_CXXALIASWARN (mkdtemp);
847 #elif defined GNULIB_POSIXCHECK
848 # if HAVE_RAW_DECL_MKDTEMP
849 _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
850 "use gnulib module mkdtemp for portability");
851 # endif
852 #endif
853
854 #if @GNULIB_MKOSTEMP@
855 /* Create a unique temporary file from TEMPLATE.
856 The last six characters of TEMPLATE must be "XXXXXX";
857 they are replaced with a string that makes the file name unique.
858 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
859 and O_TEXT, O_BINARY (defined in "binary-io.h").
860 The file is then created, with the specified flags, ensuring it didn't exist
861 before.
862 The file is created read-write (mask at least 0600 & ~umask), but it may be
863 world-readable and world-writable (mask 0666 & ~umask), depending on the
864 implementation.
865 Returns the open file descriptor if successful, otherwise -1 and errno
866 set. */
867 # if @REPLACE_MKOSTEMP@
868 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
869 # undef mkostemp
870 # define mkostemp rpl_mkostemp
871 # endif
872 _GL_FUNCDECL_RPL (mkostemp, int, (char * /*template*/, int /*flags*/),
873 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
874 _GL_CXXALIAS_RPL (mkostemp, int, (char * /*template*/, int /*flags*/));
875 # else
876 # if !@HAVE_MKOSTEMP@
877 _GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/),
878 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
879 # endif
880 _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
881 # endif
882 # if __GLIBC__ >= 2
883 _GL_CXXALIASWARN (mkostemp);
884 # endif
885 #elif defined GNULIB_POSIXCHECK
886 # if HAVE_RAW_DECL_MKOSTEMP
887 _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
888 "use gnulib module mkostemp for portability");
889 # endif
890 #endif
891
892 #if @GNULIB_MKOSTEMPS@
893 /* Create a unique temporary file from TEMPLATE.
894 The last six characters of TEMPLATE before a suffix of length
895 SUFFIXLEN must be "XXXXXX";
896 they are replaced with a string that makes the file name unique.
897 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
898 and O_TEXT, O_BINARY (defined in "binary-io.h").
899 The file is then created, with the specified flags, ensuring it didn't exist
900 before.
901 The file is created read-write (mask at least 0600 & ~umask), but it may be
902 world-readable and world-writable (mask 0666 & ~umask), depending on the
903 implementation.
904 Returns the open file descriptor if successful, otherwise -1 and errno
905 set. */
906 # if @REPLACE_MKOSTEMPS@
907 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
908 # undef mkostemps
909 # define mkostemps rpl_mkostemps
910 # endif
911 _GL_FUNCDECL_RPL (mkostemps, int,
912 (char * /*template*/, int /*suffixlen*/, int /*flags*/),
913 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
914 _GL_CXXALIAS_RPL (mkostemps, int,
915 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
916 # else
917 # if !@HAVE_MKOSTEMPS@
918 _GL_FUNCDECL_SYS (mkostemps, int,
919 (char * /*template*/, int /*suffixlen*/, int /*flags*/),
920 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
921 # endif
922 _GL_CXXALIAS_SYS (mkostemps, int,
923 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
924 # endif
925 # if __GLIBC__ >= 2
926 _GL_CXXALIASWARN (mkostemps);
927 # endif
928 #elif defined GNULIB_POSIXCHECK
929 # if HAVE_RAW_DECL_MKOSTEMPS
930 _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
931 "use gnulib module mkostemps for portability");
932 # endif
933 #endif
934
935 #if @GNULIB_MKSTEMP@
936 /* Create a unique temporary file from TEMPLATE.
937 The last six characters of TEMPLATE must be "XXXXXX";
938 they are replaced with a string that makes the file name unique.
939 The file is then created, ensuring it didn't exist before.
940 The file is created read-write (mask at least 0600 & ~umask), but it may be
941 world-readable and world-writable (mask 0666 & ~umask), depending on the
942 implementation.
943 Returns the open file descriptor if successful, otherwise -1 and errno
944 set. */
945 # if @REPLACE_MKSTEMP@
946 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
947 # define mkstemp rpl_mkstemp
948 # endif
949 _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/),
950 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
951 _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
952 # else
953 # if ! @HAVE_MKSTEMP@
954 _GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/),
955 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
956 # endif
957 _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
958 # endif
959 _GL_CXXALIASWARN (mkstemp);
960 #elif defined GNULIB_POSIXCHECK
961 # if HAVE_RAW_DECL_MKSTEMP
962 _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
963 "use gnulib module mkstemp for portability");
964 # endif
965 #endif
966
967 #if @GNULIB_MKSTEMPS@
968 /* Create a unique temporary file from TEMPLATE.
969 The last six characters of TEMPLATE prior to a suffix of length
970 SUFFIXLEN must be "XXXXXX";
971 they are replaced with a string that makes the file name unique.
972 The file is then created, ensuring it didn't exist before.
973 The file is created read-write (mask at least 0600 & ~umask), but it may be
974 world-readable and world-writable (mask 0666 & ~umask), depending on the
975 implementation.
976 Returns the open file descriptor if successful, otherwise -1 and errno
977 set. */
978 # if !@HAVE_MKSTEMPS@
979 _GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/),
980 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
981 # endif
982 _GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
983 _GL_CXXALIASWARN (mkstemps);
984 #elif defined GNULIB_POSIXCHECK
985 # if HAVE_RAW_DECL_MKSTEMPS
986 _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
987 "use gnulib module mkstemps for portability");
988 # endif
989 #endif
990
991 #if @GNULIB_MDA_MKTEMP@
992 /* On native Windows, map 'mktemp' to '_mktemp', so that -loldnames is not
993 required. In C++ with GNULIB_NAMESPACE, avoid differences between
994 platforms by defining GNULIB_NAMESPACE::mktemp always. */
995 # if defined _WIN32 && !defined __CYGWIN__
996 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
997 # undef mktemp
998 # define mktemp _mktemp
999 # endif
1000 _GL_CXXALIAS_MDA (mktemp, char *, (char * /*template*/));
1001 # else
1002 _GL_CXXALIAS_SYS (mktemp, char *, (char * /*template*/));
1003 # endif
1004 _GL_CXXALIASWARN (mktemp);
1005 #endif
1006
1007 /* Allocate memory with indefinite extent and specified alignment. */
1008 #if @GNULIB_POSIX_MEMALIGN@
1009 # if @REPLACE_POSIX_MEMALIGN@
1010 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1011 # undef posix_memalign
1012 # define posix_memalign rpl_posix_memalign
1013 # endif
1014 _GL_FUNCDECL_RPL (posix_memalign, int,
1015 (void **memptr, size_t alignment, size_t size),
1016 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1017 _GL_CXXALIAS_RPL (posix_memalign, int,
1018 (void **memptr, size_t alignment, size_t size));
1019 # else
1020 # if @HAVE_POSIX_MEMALIGN@
1021 _GL_CXXALIAS_SYS (posix_memalign, int,
1022 (void **memptr, size_t alignment, size_t size));
1023 # endif
1024 # endif
1025 # if __GLIBC__ >= 2 && @HAVE_POSIX_MEMALIGN@
1026 _GL_CXXALIASWARN (posix_memalign);
1027 # endif
1028 #elif defined GNULIB_POSIXCHECK
1029 # if HAVE_RAW_DECL_POSIX_MEMALIGN
1030 _GL_WARN_ON_USE (posix_memalign, "posix_memalign is not portable - "
1031 "use gnulib module posix_memalign for portability");
1032 # endif
1033 #endif
1034
1035 #if @GNULIB_POSIX_OPENPT@
1036 /* Return an FD open to the master side of a pseudo-terminal. Flags should
1037 include O_RDWR, and may also include O_NOCTTY. */
1038 # if @REPLACE_POSIX_OPENPT@
1039 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1040 # undef posix_openpt
1041 # define posix_openpt rpl_posix_openpt
1042 # endif
1043 _GL_FUNCDECL_RPL (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
1044 _GL_CXXALIAS_RPL (posix_openpt, int, (int flags));
1045 # else
1046 # if !@HAVE_POSIX_OPENPT@
1047 _GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
1048 # endif
1049 _GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
1050 # endif
1051 # if __GLIBC__ >= 2
1052 _GL_CXXALIASWARN (posix_openpt);
1053 # endif
1054 #elif defined GNULIB_POSIXCHECK
1055 # if HAVE_RAW_DECL_POSIX_OPENPT
1056 _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
1057 "use gnulib module posix_openpt for portability");
1058 # endif
1059 #endif
1060
1061 #if @GNULIB_PTSNAME@
1062 /* Return the pathname of the pseudo-terminal slave associated with
1063 the master FD is open on, or NULL on errors. */
1064 # if @REPLACE_PTSNAME@
1065 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1066 # undef ptsname
1067 # define ptsname rpl_ptsname
1068 # endif
1069 _GL_FUNCDECL_RPL (ptsname, char *, (int fd), _GL_ATTRIBUTE_NODISCARD);
1070 _GL_CXXALIAS_RPL (ptsname, char *, (int fd));
1071 # else
1072 # if !@HAVE_PTSNAME@
1073 _GL_FUNCDECL_SYS (ptsname, char *, (int fd), _GL_ATTRIBUTE_NODISCARD);
1074 # endif
1075 _GL_CXXALIAS_SYS (ptsname, char *, (int fd));
1076 # endif
1077 _GL_CXXALIASWARN (ptsname);
1078 #elif defined GNULIB_POSIXCHECK
1079 # if HAVE_RAW_DECL_PTSNAME
1080 _GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
1081 "use gnulib module ptsname for portability");
1082 # endif
1083 #endif
1084
1085 #if @GNULIB_PTSNAME_R@
1086 /* Set the pathname of the pseudo-terminal slave associated with
1087 the master FD is open on and return 0, or set errno and return
1088 non-zero on errors. */
1089 # if @REPLACE_PTSNAME_R@
1090 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1091 # undef ptsname_r
1092 # define ptsname_r rpl_ptsname_r
1093 # endif
1094 _GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len), );
1095 _GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
1096 # else
1097 # if !@HAVE_PTSNAME_R@
1098 _GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len), );
1099 # endif
1100 _GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
1101 # endif
1102 # ifndef GNULIB_defined_ptsname_r
1103 # define GNULIB_defined_ptsname_r (!@HAVE_PTSNAME_R@ || @REPLACE_PTSNAME_R@)
1104 # endif
1105 _GL_CXXALIASWARN (ptsname_r);
1106 #elif defined GNULIB_POSIXCHECK
1107 # if HAVE_RAW_DECL_PTSNAME_R
1108 _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
1109 "use gnulib module ptsname_r for portability");
1110 # endif
1111 #endif
1112
1113 #if @GNULIB_PUTENV@
1114 # if @REPLACE_PUTENV@
1115 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1116 # undef putenv
1117 # define putenv rpl_putenv
1118 # endif
1119 _GL_FUNCDECL_RPL (putenv, int, (char *string), _GL_ARG_NONNULL ((1)));
1120 _GL_CXXALIAS_RPL (putenv, int, (char *string));
1121 # elif defined _WIN32 && !defined __CYGWIN__
1122 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1123 # undef putenv
1124 # define putenv _putenv
1125 # endif
1126 _GL_CXXALIAS_MDA (putenv, int, (char *string));
1127 # elif defined __KLIBC__
1128 /* Need to cast, because on OS/2 kLIBC, the first parameter is
1129 const char *string. */
1130 _GL_CXXALIAS_SYS_CAST (putenv, int, (char *string));
1131 # else
1132 _GL_CXXALIAS_SYS (putenv, int, (char *string));
1133 # endif
1134 _GL_CXXALIASWARN (putenv);
1135 #elif @GNULIB_MDA_PUTENV@
1136 /* On native Windows, map 'putenv' to '_putenv', so that -loldnames is not
1137 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1138 platforms by defining GNULIB_NAMESPACE::putenv always. */
1139 # if defined _WIN32 && !defined __CYGWIN__
1140 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1141 # undef putenv
1142 # define putenv _putenv
1143 # endif
1144 /* Need to cast, because on mingw, the parameter is either
1145 'const char *string' or 'char *string'. */
1146 _GL_CXXALIAS_MDA_CAST (putenv, int, (char *string));
1147 # elif defined __KLIBC__
1148 /* Need to cast, because on OS/2 kLIBC, the first parameter is
1149 const char *string. */
1150 _GL_CXXALIAS_SYS_CAST (putenv, int, (char *string));
1151 # else
1152 _GL_CXXALIAS_SYS (putenv, int, (char *string));
1153 # endif
1154 _GL_CXXALIASWARN (putenv);
1155 #endif
1156
1157 #if @GNULIB_QSORT_R@
1158 /* Sort an array of NMEMB elements, starting at address BASE, each element
1159 occupying SIZE bytes, in ascending order according to the comparison
1160 function COMPARE. */
1161 # ifdef __cplusplus
1162 extern "C" {
1163 # endif
1164 # if !GNULIB_defined_qsort_r_fn_types
1165 typedef int (*_gl_qsort_r_compar_fn) (void const *, void const *, void *);
1166 # define GNULIB_defined_qsort_r_fn_types 1
1167 # endif
1168 # ifdef __cplusplus
1169 }
1170 # endif
1171 # if @REPLACE_QSORT_R@
1172 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1173 # undef qsort_r
1174 # define qsort_r rpl_qsort_r
1175 # endif
1176 _GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
1177 _gl_qsort_r_compar_fn compare,
1178 void *arg),
1179 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
1180 _GL_ARG_NONNULL ((4)));
1181 _GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
1182 _gl_qsort_r_compar_fn compare,
1183 void *arg));
1184 # else
1185 # if !@HAVE_QSORT_R@
1186 _GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
1187 _gl_qsort_r_compar_fn compare,
1188 void *arg),
1189 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
1190 _GL_ARG_NONNULL ((4)));
1191 # endif
1192 _GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
1193 _gl_qsort_r_compar_fn compare,
1194 void *arg));
1195 # endif
1196 # if __GLIBC__ >= 2
1197 _GL_CXXALIASWARN (qsort_r);
1198 # endif
1199 #elif defined GNULIB_POSIXCHECK
1200 # if HAVE_RAW_DECL_QSORT_R
1201 _GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
1202 "use gnulib module qsort_r for portability");
1203 # endif
1204 #endif
1205
1206
1207 #if @GNULIB_RAND@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@)
1208 # ifndef RAND_MAX
1209 # define RAND_MAX 2147483647
1210 # endif
1211 #endif
1212
1213
1214 #if @GNULIB_RAND@
1215 # if @REPLACE_RAND@
1216 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1217 # undef rand
1218 # define rand rpl_rand
1219 # endif
1220 _GL_FUNCDECL_RPL (rand, int, (void), );
1221 _GL_CXXALIAS_RPL (rand, int, (void));
1222 # else
1223 _GL_CXXALIAS_SYS (rand, int, (void));
1224 # endif
1225 # if __GLIBC__ >= 2
1226 _GL_CXXALIASWARN (rand);
1227 # endif
1228 #endif
1229
1230
1231 #if @GNULIB_RANDOM@
1232 # if @REPLACE_RANDOM@
1233 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1234 # undef random
1235 # define random rpl_random
1236 # endif
1237 _GL_FUNCDECL_RPL (random, long, (void), );
1238 _GL_CXXALIAS_RPL (random, long, (void));
1239 # else
1240 # if !@HAVE_RANDOM@
1241 _GL_FUNCDECL_SYS (random, long, (void), );
1242 # endif
1243 /* Need to cast, because on Haiku, the return type is
1244 int. */
1245 _GL_CXXALIAS_SYS_CAST (random, long, (void));
1246 # endif
1247 # if __GLIBC__ >= 2
1248 _GL_CXXALIASWARN (random);
1249 # endif
1250 #elif defined GNULIB_POSIXCHECK
1251 # if HAVE_RAW_DECL_RANDOM
1252 _GL_WARN_ON_USE (random, "random is unportable - "
1253 "use gnulib module random for portability");
1254 # endif
1255 #endif
1256
1257 #if @GNULIB_RANDOM@
1258 # if @REPLACE_RANDOM@
1259 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1260 # undef srandom
1261 # define srandom rpl_srandom
1262 # endif
1263 _GL_FUNCDECL_RPL (srandom, void, (unsigned int seed), );
1264 _GL_CXXALIAS_RPL (srandom, void, (unsigned int seed));
1265 # else
1266 # if !@HAVE_RANDOM@
1267 _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed), );
1268 # endif
1269 /* Need to cast, because on FreeBSD, the first parameter is
1270 unsigned long seed. */
1271 _GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed));
1272 # endif
1273 # if __GLIBC__ >= 2
1274 _GL_CXXALIASWARN (srandom);
1275 # endif
1276 #elif defined GNULIB_POSIXCHECK
1277 # if HAVE_RAW_DECL_SRANDOM
1278 _GL_WARN_ON_USE (srandom, "srandom is unportable - "
1279 "use gnulib module random for portability");
1280 # endif
1281 #endif
1282
1283 #if @GNULIB_RANDOM@
1284 # if @REPLACE_INITSTATE@
1285 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1286 # undef initstate
1287 # define initstate rpl_initstate
1288 # endif
1289 _GL_FUNCDECL_RPL (initstate, char *,
1290 (unsigned int seed, char *buf, size_t buf_size),
1291 _GL_ARG_NONNULL ((2)));
1292 _GL_CXXALIAS_RPL (initstate, char *,
1293 (unsigned int seed, char *buf, size_t buf_size));
1294 # else
1295 # if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@
1296 _GL_FUNCDECL_SYS (initstate, char *,
1297 (unsigned int seed, char *buf, size_t buf_size),
1298 _GL_ARG_NONNULL ((2)));
1299 # endif
1300 /* Need to cast, because on FreeBSD, the first parameter is
1301 unsigned long seed. */
1302 _GL_CXXALIAS_SYS_CAST (initstate, char *,
1303 (unsigned int seed, char *buf, size_t buf_size));
1304 # endif
1305 # if __GLIBC__ >= 2
1306 _GL_CXXALIASWARN (initstate);
1307 # endif
1308 #elif defined GNULIB_POSIXCHECK
1309 # if HAVE_RAW_DECL_INITSTATE
1310 _GL_WARN_ON_USE (initstate, "initstate is unportable - "
1311 "use gnulib module random for portability");
1312 # endif
1313 #endif
1314
1315 #if @GNULIB_RANDOM@
1316 # if @REPLACE_SETSTATE@
1317 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1318 # undef setstate
1319 # define setstate rpl_setstate
1320 # endif
1321 _GL_FUNCDECL_RPL (setstate, char *, (char *arg_state), _GL_ARG_NONNULL ((1)));
1322 _GL_CXXALIAS_RPL (setstate, char *, (char *arg_state));
1323 # else
1324 # if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@
1325 _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state), _GL_ARG_NONNULL ((1)));
1326 # endif
1327 /* Need to cast, because on Mac OS X 10.13, HP-UX, Solaris the first parameter
1328 is const char *arg_state. */
1329 _GL_CXXALIAS_SYS_CAST (setstate, char *, (char *arg_state));
1330 # endif
1331 # if __GLIBC__ >= 2
1332 _GL_CXXALIASWARN (setstate);
1333 # endif
1334 #elif defined GNULIB_POSIXCHECK
1335 # if HAVE_RAW_DECL_SETSTATE
1336 _GL_WARN_ON_USE (setstate, "setstate is unportable - "
1337 "use gnulib module random for portability");
1338 # endif
1339 #endif
1340
1341
1342 #if @GNULIB_RANDOM_R@
1343 # if @REPLACE_RANDOM_R@
1344 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1345 # undef random_r
1346 # define random_r rpl_random_r
1347 # endif
1348 _GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result),
1349 _GL_ARG_NONNULL ((1, 2)));
1350 _GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
1351 # else
1352 # if !@HAVE_RANDOM_R@
1353 _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result),
1354 _GL_ARG_NONNULL ((1, 2)));
1355 # endif
1356 _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
1357 # endif
1358 _GL_CXXALIASWARN (random_r);
1359 #elif defined GNULIB_POSIXCHECK
1360 # if HAVE_RAW_DECL_RANDOM_R
1361 _GL_WARN_ON_USE (random_r, "random_r is unportable - "
1362 "use gnulib module random_r for portability");
1363 # endif
1364 #endif
1365
1366 #if @GNULIB_RANDOM_R@
1367 # if @REPLACE_RANDOM_R@
1368 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1369 # undef srandom_r
1370 # define srandom_r rpl_srandom_r
1371 # endif
1372 _GL_FUNCDECL_RPL (srandom_r, int,
1373 (unsigned int seed, struct random_data *rand_state),
1374 _GL_ARG_NONNULL ((2)));
1375 _GL_CXXALIAS_RPL (srandom_r, int,
1376 (unsigned int seed, struct random_data *rand_state));
1377 # else
1378 # if !@HAVE_RANDOM_R@
1379 _GL_FUNCDECL_SYS (srandom_r, int,
1380 (unsigned int seed, struct random_data *rand_state),
1381 _GL_ARG_NONNULL ((2)));
1382 # endif
1383 _GL_CXXALIAS_SYS (srandom_r, int,
1384 (unsigned int seed, struct random_data *rand_state));
1385 # endif
1386 _GL_CXXALIASWARN (srandom_r);
1387 #elif defined GNULIB_POSIXCHECK
1388 # if HAVE_RAW_DECL_SRANDOM_R
1389 _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
1390 "use gnulib module random_r for portability");
1391 # endif
1392 #endif
1393
1394 #if @GNULIB_RANDOM_R@
1395 # if @REPLACE_RANDOM_R@
1396 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1397 # undef initstate_r
1398 # define initstate_r rpl_initstate_r
1399 # endif
1400 _GL_FUNCDECL_RPL (initstate_r, int,
1401 (unsigned int seed, char *buf, size_t buf_size,
1402 struct random_data *rand_state),
1403 _GL_ARG_NONNULL ((2, 4)));
1404 _GL_CXXALIAS_RPL (initstate_r, int,
1405 (unsigned int seed, char *buf, size_t buf_size,
1406 struct random_data *rand_state));
1407 # else
1408 # if !@HAVE_RANDOM_R@
1409 _GL_FUNCDECL_SYS (initstate_r, int,
1410 (unsigned int seed, char *buf, size_t buf_size,
1411 struct random_data *rand_state),
1412 _GL_ARG_NONNULL ((2, 4)));
1413 # endif
1414 /* Need to cast, because on Haiku, the third parameter is
1415 unsigned long buf_size. */
1416 _GL_CXXALIAS_SYS_CAST (initstate_r, int,
1417 (unsigned int seed, char *buf, size_t buf_size,
1418 struct random_data *rand_state));
1419 # endif
1420 _GL_CXXALIASWARN (initstate_r);
1421 #elif defined GNULIB_POSIXCHECK
1422 # if HAVE_RAW_DECL_INITSTATE_R
1423 _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
1424 "use gnulib module random_r for portability");
1425 # endif
1426 #endif
1427
1428 #if @GNULIB_RANDOM_R@
1429 # if @REPLACE_RANDOM_R@
1430 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1431 # undef setstate_r
1432 # define setstate_r rpl_setstate_r
1433 # endif
1434 _GL_FUNCDECL_RPL (setstate_r, int,
1435 (char *arg_state, struct random_data *rand_state),
1436 _GL_ARG_NONNULL ((1, 2)));
1437 _GL_CXXALIAS_RPL (setstate_r, int,
1438 (char *arg_state, struct random_data *rand_state));
1439 # else
1440 # if !@HAVE_RANDOM_R@
1441 _GL_FUNCDECL_SYS (setstate_r, int,
1442 (char *arg_state, struct random_data *rand_state),
1443 _GL_ARG_NONNULL ((1, 2)));
1444 # endif
1445 /* Need to cast, because on Haiku, the first parameter is
1446 void *arg_state. */
1447 _GL_CXXALIAS_SYS_CAST (setstate_r, int,
1448 (char *arg_state, struct random_data *rand_state));
1449 # endif
1450 _GL_CXXALIASWARN (setstate_r);
1451 #elif defined GNULIB_POSIXCHECK
1452 # if HAVE_RAW_DECL_SETSTATE_R
1453 _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
1454 "use gnulib module random_r for portability");
1455 # endif
1456 #endif
1457
1458
1459 #if @GNULIB_REALLOC_POSIX@
1460 # if @REPLACE_REALLOC_FOR_REALLOC_POSIX@
1461 # if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ == 2
1462 # define _GL_INLINE_RPL_REALLOC 1
1463 # ifdef __cplusplus
1464 extern "C" {
1465 # endif
1466 _GL_REALLOC_INLINE void *
1467 rpl_realloc (void *ptr, size_t size)
1468 {
1469 return realloc (ptr, size ? size : 1);
1470 }
1471 # ifdef __cplusplus
1472 }
1473 # endif
1474 # endif
1475 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
1476 || _GL_USE_STDLIB_ALLOC)
1477 # undef realloc
1478 # define realloc rpl_realloc
1479 # endif
1480 # if !defined _GL_INLINE_RPL_REALLOC
1481 _GL_FUNCDECL_RPL (realloc, void *,
1482 (void *ptr, size_t size),
1483 _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD);
1484 # endif
1485 _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
1486 # else
1487 # if __GNUC__ >= 11 && !defined __clang__
1488 /* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1489 # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
1490 _GL_FUNCDECL_SYS (realloc, void *,
1491 (void *ptr, size_t size),
1492 _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD)
1493 _GL_ATTRIBUTE_NOTHROW;
1494 # else
1495 _GL_FUNCDECL_SYS (realloc, void *,
1496 (void *ptr, size_t size),
1497 _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD);
1498 # endif
1499 # endif
1500 _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
1501 # endif
1502 # if __GLIBC__ >= 2
1503 _GL_CXXALIASWARN (realloc);
1504 # endif
1505 #else
1506 # if @GNULIB_FREE_POSIX@ \
1507 && (__GNUC__ >= 11 && !defined __clang__) && !defined realloc
1508 /* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1509 # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
1510 _GL_FUNCDECL_SYS (realloc, void *,
1511 (void *ptr, size_t size),
1512 _GL_ATTRIBUTE_DEALLOC_FREE)
1513 _GL_ATTRIBUTE_NOTHROW;
1514 # else
1515 _GL_FUNCDECL_SYS (realloc, void *,
1516 (void *ptr, size_t size),
1517 _GL_ATTRIBUTE_DEALLOC_FREE);
1518 # endif
1519 # endif
1520 # if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
1521 /* Assume realloc is always declared. */
1522 _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
1523 "use gnulib module realloc-posix for portability");
1524 # endif
1525 #endif
1526
1527
1528 #if @GNULIB_REALLOCARRAY@
1529 # if @REPLACE_REALLOCARRAY@
1530 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1531 # undef reallocarray
1532 # define reallocarray rpl_reallocarray
1533 # endif
1534 _GL_FUNCDECL_RPL (reallocarray, void *,
1535 (void *ptr, size_t nmemb, size_t size),
1536 _GL_ATTRIBUTE_NODISCARD);
1537 _GL_CXXALIAS_RPL (reallocarray, void *,
1538 (void *ptr, size_t nmemb, size_t size));
1539 # else
1540 # if ! @HAVE_REALLOCARRAY@
1541 _GL_FUNCDECL_SYS (reallocarray, void *,
1542 (void *ptr, size_t nmemb, size_t size),
1543 _GL_ATTRIBUTE_NODISCARD);
1544 # endif
1545 _GL_CXXALIAS_SYS (reallocarray, void *,
1546 (void *ptr, size_t nmemb, size_t size));
1547 # endif
1548 # if __GLIBC__ >= 2
1549 _GL_CXXALIASWARN (reallocarray);
1550 # endif
1551 #elif defined GNULIB_POSIXCHECK
1552 # if HAVE_RAW_DECL_REALLOCARRAY
1553 _GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - "
1554 "use gnulib module reallocarray for portability");
1555 # endif
1556 #endif
1557
1558 #if @GNULIB_REALPATH@
1559 # if @REPLACE_REALPATH@
1560 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1561 # define realpath rpl_realpath
1562 # endif
1563 _GL_FUNCDECL_RPL (realpath, char *,
1564 (const char *restrict name, char *restrict resolved),
1565 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1566 _GL_CXXALIAS_RPL (realpath, char *,
1567 (const char *restrict name, char *restrict resolved));
1568 # else
1569 # if !@HAVE_REALPATH@
1570 _GL_FUNCDECL_SYS (realpath, char *,
1571 (const char *restrict name, char *restrict resolved),
1572 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1573 # endif
1574 _GL_CXXALIAS_SYS (realpath, char *,
1575 (const char *restrict name, char *restrict resolved));
1576 # endif
1577 _GL_CXXALIASWARN (realpath);
1578 #elif defined GNULIB_POSIXCHECK
1579 # if HAVE_RAW_DECL_REALPATH
1580 _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
1581 "canonicalize or canonicalize-lgpl for portability");
1582 # endif
1583 #endif
1584
1585 #if @GNULIB_RPMATCH@
1586 /* Test a user response to a question.
1587 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
1588 # if !@HAVE_RPMATCH@
1589 _GL_FUNCDECL_SYS (rpmatch, int, (const char *response),
1590 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1591 # endif
1592 _GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
1593 _GL_CXXALIASWARN (rpmatch);
1594 #elif defined GNULIB_POSIXCHECK
1595 # if HAVE_RAW_DECL_RPMATCH
1596 _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
1597 "use gnulib module rpmatch for portability");
1598 # endif
1599 #endif
1600
1601 #if @GNULIB_SECURE_GETENV@
1602 /* Look up NAME in the environment, returning 0 in insecure situations. */
1603 # if !@HAVE_SECURE_GETENV@
1604 _GL_FUNCDECL_SYS (secure_getenv, char *,
1605 (char const *name),
1606 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1607 # endif
1608 _GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
1609 _GL_CXXALIASWARN (secure_getenv);
1610 #elif defined GNULIB_POSIXCHECK
1611 # if HAVE_RAW_DECL_SECURE_GETENV
1612 _GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
1613 "use gnulib module secure_getenv for portability");
1614 # endif
1615 #endif
1616
1617 #if @GNULIB_SETENV@
1618 /* Set NAME to VALUE in the environment.
1619 If REPLACE is nonzero, overwrite an existing value. */
1620 # if @REPLACE_SETENV@
1621 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1622 # undef setenv
1623 # define setenv rpl_setenv
1624 # endif
1625 _GL_FUNCDECL_RPL (setenv, int,
1626 (const char *name, const char *value, int replace),
1627 _GL_ARG_NONNULL ((1)));
1628 _GL_CXXALIAS_RPL (setenv, int,
1629 (const char *name, const char *value, int replace));
1630 # else
1631 # if !@HAVE_DECL_SETENV@
1632 _GL_FUNCDECL_SYS (setenv, int,
1633 (const char *name, const char *value, int replace),
1634 _GL_ARG_NONNULL ((1)));
1635 # endif
1636 _GL_CXXALIAS_SYS (setenv, int,
1637 (const char *name, const char *value, int replace));
1638 # endif
1639 # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
1640 _GL_CXXALIASWARN (setenv);
1641 # endif
1642 #elif defined GNULIB_POSIXCHECK
1643 # if HAVE_RAW_DECL_SETENV
1644 _GL_WARN_ON_USE (setenv, "setenv is unportable - "
1645 "use gnulib module setenv for portability");
1646 # endif
1647 #endif
1648
1649 #if @GNULIB_STACK_TRACE@
1650 /* Prints a stack trace of the current thread to standard error,
1651 if possible. */
1652 # if @CAN_PRINT_STACK_TRACE@
1653 _GL_EXTERN_C void print_stack_trace (void);
1654 # else
1655 # if !GNULIB_defined_print_stack_trace
1656 # define print_stack_trace() /* nothing */
1657 # define GNULIB_defined_print_stack_trace 1
1658 # endif
1659 # endif
1660 #endif
1661
1662 #if @GNULIB_STRTOD@
1663 /* Parse a double from STRING, updating ENDP if appropriate. */
1664 # if @REPLACE_STRTOD@
1665 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1666 # define strtod rpl_strtod
1667 # endif
1668 # define GNULIB_defined_strtod_function 1
1669 _GL_FUNCDECL_RPL (strtod, double,
1670 (const char *restrict str, char **restrict endp),
1671 _GL_ARG_NONNULL ((1)));
1672 _GL_CXXALIAS_RPL (strtod, double,
1673 (const char *restrict str, char **restrict endp));
1674 # else
1675 # if !@HAVE_STRTOD@
1676 _GL_FUNCDECL_SYS (strtod, double,
1677 (const char *restrict str, char **restrict endp),
1678 _GL_ARG_NONNULL ((1)));
1679 # endif
1680 _GL_CXXALIAS_SYS (strtod, double,
1681 (const char *restrict str, char **restrict endp));
1682 # endif
1683 # if __GLIBC__ >= 2
1684 _GL_CXXALIASWARN (strtod);
1685 # endif
1686 #elif defined GNULIB_POSIXCHECK
1687 # if HAVE_RAW_DECL_STRTOD
1688 _GL_WARN_ON_USE (strtod, "strtod is unportable - "
1689 "use gnulib module strtod for portability");
1690 # endif
1691 #endif
1692
1693 #if @GNULIB_STRTOF@
1694 /* Parse a float from STRING, updating ENDP if appropriate. */
1695 # if @REPLACE_STRTOF@
1696 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1697 # define strtof rpl_strtof
1698 # endif
1699 # define GNULIB_defined_strtof_function 1
1700 _GL_FUNCDECL_RPL (strtof, float,
1701 (const char *restrict str, char **restrict endp),
1702 _GL_ARG_NONNULL ((1)));
1703 _GL_CXXALIAS_RPL (strtof, float,
1704 (const char *restrict str, char **restrict endp));
1705 # else
1706 # if !@HAVE_STRTOF@
1707 _GL_FUNCDECL_SYS (strtof, float,
1708 (const char *restrict str, char **restrict endp),
1709 _GL_ARG_NONNULL ((1)));
1710 # endif
1711 _GL_CXXALIAS_SYS (strtof, float,
1712 (const char *restrict str, char **restrict endp));
1713 # endif
1714 # if __GLIBC__ >= 2
1715 _GL_CXXALIASWARN (strtof);
1716 # endif
1717 #elif defined GNULIB_POSIXCHECK
1718 # if HAVE_RAW_DECL_STRTOF
1719 _GL_WARN_ON_USE (strtof, "strtof is unportable - "
1720 "use gnulib module strtof for portability");
1721 # endif
1722 #endif
1723
1724 #if @GNULIB_STRTOLD@
1725 /* Parse a 'long double' from STRING, updating ENDP if appropriate. */
1726 # if @REPLACE_STRTOLD@
1727 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1728 # define strtold rpl_strtold
1729 # endif
1730 # define GNULIB_defined_strtold_function 1
1731 _GL_FUNCDECL_RPL (strtold, long double,
1732 (const char *restrict str, char **restrict endp),
1733 _GL_ARG_NONNULL ((1)));
1734 _GL_CXXALIAS_RPL (strtold, long double,
1735 (const char *restrict str, char **restrict endp));
1736 # else
1737 # if !@HAVE_STRTOLD@
1738 _GL_FUNCDECL_SYS (strtold, long double,
1739 (const char *restrict str, char **restrict endp),
1740 _GL_ARG_NONNULL ((1)));
1741 # endif
1742 _GL_CXXALIAS_SYS (strtold, long double,
1743 (const char *restrict str, char **restrict endp));
1744 # endif
1745 _GL_CXXALIASWARN (strtold);
1746 #elif defined GNULIB_POSIXCHECK
1747 # if HAVE_RAW_DECL_STRTOLD
1748 _GL_WARN_ON_USE (strtold, "strtold is unportable - "
1749 "use gnulib module strtold for portability");
1750 # endif
1751 #endif
1752
1753 #if @GNULIB_STRTOL@
1754 /* Parse a signed integer whose textual representation starts at STRING.
1755 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1756 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1757 "0x").
1758 If ENDPTR is not NULL, the address of the first byte after the integer is
1759 stored in *ENDPTR.
1760 Upon overflow, the return value is LONG_MAX or LONG_MIN, and errno is set
1761 to ERANGE. */
1762 # if @REPLACE_STRTOL@
1763 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1764 # define strtol rpl_strtol
1765 # endif
1766 # define GNULIB_defined_strtol_function 1
1767 _GL_FUNCDECL_RPL (strtol, long,
1768 (const char *restrict string, char **restrict endptr,
1769 int base),
1770 _GL_ARG_NONNULL ((1)));
1771 _GL_CXXALIAS_RPL (strtol, long,
1772 (const char *restrict string, char **restrict endptr,
1773 int base));
1774 # else
1775 # if !@HAVE_STRTOL@
1776 _GL_FUNCDECL_SYS (strtol, long,
1777 (const char *restrict string, char **restrict endptr,
1778 int base),
1779 _GL_ARG_NONNULL ((1)));
1780 # endif
1781 _GL_CXXALIAS_SYS (strtol, long,
1782 (const char *restrict string, char **restrict endptr,
1783 int base));
1784 # endif
1785 # if __GLIBC__ >= 2
1786 _GL_CXXALIASWARN (strtol);
1787 # endif
1788 #elif defined GNULIB_POSIXCHECK
1789 # if HAVE_RAW_DECL_STRTOL
1790 _GL_WARN_ON_USE (strtol, "strtol is unportable - "
1791 "use gnulib module strtol for portability");
1792 # endif
1793 #endif
1794
1795 #if @GNULIB_STRTOLL@
1796 /* Parse a signed integer whose textual representation starts at STRING.
1797 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1798 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1799 "0x").
1800 If ENDPTR is not NULL, the address of the first byte after the integer is
1801 stored in *ENDPTR.
1802 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
1803 to ERANGE. */
1804 # if @REPLACE_STRTOLL@
1805 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1806 # define strtoll rpl_strtoll
1807 # endif
1808 # define GNULIB_defined_strtoll_function 1
1809 _GL_FUNCDECL_RPL (strtoll, long long,
1810 (const char *restrict string, char **restrict endptr,
1811 int base),
1812 _GL_ARG_NONNULL ((1)));
1813 _GL_CXXALIAS_RPL (strtoll, long long,
1814 (const char *restrict string, char **restrict endptr,
1815 int base));
1816 # else
1817 # if !@HAVE_STRTOLL@
1818 _GL_FUNCDECL_SYS (strtoll, long long,
1819 (const char *restrict string, char **restrict endptr,
1820 int base),
1821 _GL_ARG_NONNULL ((1)));
1822 # endif
1823 _GL_CXXALIAS_SYS (strtoll, long long,
1824 (const char *restrict string, char **restrict endptr,
1825 int base));
1826 # endif
1827 _GL_CXXALIASWARN (strtoll);
1828 #elif defined GNULIB_POSIXCHECK
1829 # if HAVE_RAW_DECL_STRTOLL
1830 _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
1831 "use gnulib module strtoll for portability");
1832 # endif
1833 #endif
1834
1835 #if @GNULIB_STRTOUL@
1836 /* Parse an unsigned integer whose textual representation starts at STRING.
1837 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1838 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1839 "0x").
1840 If ENDPTR is not NULL, the address of the first byte after the integer is
1841 stored in *ENDPTR.
1842 Upon overflow, the return value is ULONG_MAX, and errno is set to ERANGE. */
1843 # if @REPLACE_STRTOUL@
1844 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1845 # define strtoul rpl_strtoul
1846 # endif
1847 # define GNULIB_defined_strtoul_function 1
1848 _GL_FUNCDECL_RPL (strtoul, unsigned long,
1849 (const char *restrict string, char **restrict endptr,
1850 int base),
1851 _GL_ARG_NONNULL ((1)));
1852 _GL_CXXALIAS_RPL (strtoul, unsigned long,
1853 (const char *restrict string, char **restrict endptr,
1854 int base));
1855 # else
1856 # if !@HAVE_STRTOUL@
1857 _GL_FUNCDECL_SYS (strtoul, unsigned long,
1858 (const char *restrict string, char **restrict endptr,
1859 int base),
1860 _GL_ARG_NONNULL ((1)));
1861 # endif
1862 _GL_CXXALIAS_SYS (strtoul, unsigned long,
1863 (const char *restrict string, char **restrict endptr,
1864 int base));
1865 # endif
1866 # if __GLIBC__ >= 2
1867 _GL_CXXALIASWARN (strtoul);
1868 # endif
1869 #elif defined GNULIB_POSIXCHECK
1870 # if HAVE_RAW_DECL_STRTOUL
1871 _GL_WARN_ON_USE (strtoul, "strtoul is unportable - "
1872 "use gnulib module strtoul for portability");
1873 # endif
1874 #endif
1875
1876 #if @GNULIB_STRTOULL@
1877 /* Parse an unsigned integer whose textual representation starts at STRING.
1878 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1879 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1880 "0x").
1881 If ENDPTR is not NULL, the address of the first byte after the integer is
1882 stored in *ENDPTR.
1883 Upon overflow, the return value is ULLONG_MAX, and errno is set to
1884 ERANGE. */
1885 # if @REPLACE_STRTOULL@
1886 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1887 # define strtoull rpl_strtoull
1888 # endif
1889 # define GNULIB_defined_strtoull_function 1
1890 _GL_FUNCDECL_RPL (strtoull, unsigned long long,
1891 (const char *restrict string, char **restrict endptr,
1892 int base),
1893 _GL_ARG_NONNULL ((1)));
1894 _GL_CXXALIAS_RPL (strtoull, unsigned long long,
1895 (const char *restrict string, char **restrict endptr,
1896 int base));
1897 # else
1898 # if !@HAVE_STRTOULL@
1899 _GL_FUNCDECL_SYS (strtoull, unsigned long long,
1900 (const char *restrict string, char **restrict endptr,
1901 int base),
1902 _GL_ARG_NONNULL ((1)));
1903 # endif
1904 _GL_CXXALIAS_SYS (strtoull, unsigned long long,
1905 (const char *restrict string, char **restrict endptr,
1906 int base));
1907 # endif
1908 _GL_CXXALIASWARN (strtoull);
1909 #elif defined GNULIB_POSIXCHECK
1910 # if HAVE_RAW_DECL_STRTOULL
1911 _GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
1912 "use gnulib module strtoull for portability");
1913 # endif
1914 #endif
1915
1916 #if @GNULIB_UNLOCKPT@
1917 /* Unlock the slave side of the pseudo-terminal whose master side is specified
1918 by FD, so that it can be opened. */
1919 # if !@HAVE_UNLOCKPT@
1920 _GL_FUNCDECL_SYS (unlockpt, int, (int fd), );
1921 # endif
1922 _GL_CXXALIAS_SYS (unlockpt, int, (int fd));
1923 _GL_CXXALIASWARN (unlockpt);
1924 #elif defined GNULIB_POSIXCHECK
1925 # if HAVE_RAW_DECL_UNLOCKPT
1926 _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
1927 "use gnulib module unlockpt for portability");
1928 # endif
1929 #endif
1930
1931 #if @GNULIB_UNSETENV@
1932 /* Remove the variable NAME from the environment. */
1933 # if @REPLACE_UNSETENV@
1934 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1935 # undef unsetenv
1936 # define unsetenv rpl_unsetenv
1937 # endif
1938 _GL_FUNCDECL_RPL (unsetenv, int, (const char *name), _GL_ARG_NONNULL ((1)));
1939 _GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
1940 # else
1941 # if !@HAVE_DECL_UNSETENV@
1942 _GL_FUNCDECL_SYS (unsetenv, int, (const char *name), _GL_ARG_NONNULL ((1)));
1943 # endif
1944 _GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
1945 # endif
1946 # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
1947 _GL_CXXALIASWARN (unsetenv);
1948 # endif
1949 #elif defined GNULIB_POSIXCHECK
1950 # if HAVE_RAW_DECL_UNSETENV
1951 _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
1952 "use gnulib module unsetenv for portability");
1953 # endif
1954 #endif
1955
1956 /* Convert a wide character to a multibyte character. */
1957 #if @GNULIB_WCTOMB@
1958 # if @REPLACE_WCTOMB@
1959 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1960 # undef wctomb
1961 # define wctomb rpl_wctomb
1962 # endif
1963 _GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc), );
1964 _GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
1965 # else
1966 _GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
1967 # endif
1968 # if __GLIBC__ >= 2
1969 _GL_CXXALIASWARN (wctomb);
1970 # endif
1971 #endif
1972
1973
1974 _GL_INLINE_HEADER_END
1975
1976
1977 /* Includes that provide only macros that don't need to be overridden.
1978 (Includes that are needed for type definitions and function declarations
1979 have their place above, before the function overrides.) */
1980
1981 /* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>.
1982 glibc 2.41 defines WCOREDUMP in <sys/wait.h>, not in <stdlib.h>. */
1983 #if @GNULIB_SYSTEM_POSIX@ && !(defined WEXITSTATUS && defined WCOREDUMP)
1984 # include <sys/wait.h>
1985 #endif
1986
1987
1988 #endif /* _@GUARD_PREFIX@_STDLIB_H */
1989 #endif /* _@GUARD_PREFIX@_STDLIB_H */
1990 #endif