Debian Codegraph @

lib/stdlib.in.h

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