Debian Codegraph @

lib/stdlib.in.h

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