1 /* A GNU-like <stdlib.h>.
2
3 Copyright (C) 1995, 2001-2004, 2006-2021 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 __need_malloc_and_calloc
24 /* Special invocation conventions inside some gnulib header files,
25 and inside some glibc header files, respectively. */
26
27 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
28
29 #else
30 /* Normal invocation convention. */
31
32 #ifndef _@GUARD_PREFIX@_STDLIB_H
33
34 /* The include_next requires a split double-inclusion guard. */
35 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
36
37 #ifndef _@GUARD_PREFIX@_STDLIB_H
38 #define _@GUARD_PREFIX@_STDLIB_H
39
40 /* NetBSD 5.0 mis-defines NULL. */
41 #include <stddef.h>
42
43 /* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */
44 #if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS
45 # include <sys/wait.h>
46 #endif
47
48 /* Solaris declares getloadavg() in <sys/loadavg.h>. */
49 #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
50 /* OpenIndiana has a bug: <sys/time.h> must be included before
51 <sys/loadavg.h>. */
52 # include <sys/time.h>
53 # include <sys/loadavg.h>
54 #endif
55
56 /* Native Windows platforms declare _mktemp() in <io.h>. */
57 #if defined _WIN32 && !defined __CYGWIN__
58 # include <io.h>
59 #endif
60
61 #if @GNULIB_RANDOM_R@
62
63 /* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
64 from <stdlib.h> if _REENTRANT is defined. Include it whenever we need
65 'struct random_data'. */
66 # if @HAVE_RANDOM_H@
67 # include <random.h>
68 # endif
69
70 # if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
71 # include <stdint.h>
72 # endif
73
74 # if !@HAVE_STRUCT_RANDOM_DATA@
75 /* Define 'struct random_data'.
76 But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
77 # if !GNULIB_defined_struct_random_data
78 struct random_data
79 {
80 int32_t *fptr; /* Front pointer. */
81 int32_t *rptr; /* Rear pointer. */
82 int32_t *state; /* Array of state values. */
83 int rand_type; /* Type of random number generator. */
84 int rand_deg; /* Degree of random number generator. */
85 int rand_sep; /* Distance between front and rear. */
86 int32_t *end_ptr; /* Pointer behind state table. */
87 };
88 # define GNULIB_defined_struct_random_data 1
89 # endif
90 # endif
91 #endif
92
93 #if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_MKOSTEMP@ || @GNULIB_MKOSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !(defined _WIN32 && ! defined __CYGWIN__)
94 /* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */
95 /* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */
96 /* On Mac OS X 10.13, only <unistd.h> declares mkostemp and mkostemps. */
97 /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
98 /* But avoid namespace pollution on glibc systems and native Windows. */
99 # include <unistd.h>
100 #endif
101
102 /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
103 that can be freed by passing them as the Ith argument to the
104 function F. */
105 #ifndef _GL_ATTRIBUTE_DEALLOC
106 # if __GNUC__ >= 11
107 # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
108 # else
109 # define _GL_ATTRIBUTE_DEALLOC(f, i)
110 # endif
111 #endif
112
113 /* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
114 can be freed via 'free'; it can be used only after declaring 'free'. */
115 /* Applies to: functions. Cannot be used on inline functions. */
116 #ifndef _GL_ATTRIBUTE_DEALLOC_FREE
117 # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
118 #endif
119
120 /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
121 allocated memory. */
122 /* Applies to: functions. */
123 #ifndef _GL_ATTRIBUTE_MALLOC
124 # if __GNUC__ >= 3 || defined __clang__
125 # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
126 # else
127 # define _GL_ATTRIBUTE_MALLOC
128 # endif
129 #endif
130
131 /* The __attribute__ feature is available in gcc versions 2.5 and later.
132 The attribute __pure__ was added in gcc 2.96. */
133 #ifndef _GL_ATTRIBUTE_PURE
134 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
135 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
136 # else
137 # define _GL_ATTRIBUTE_PURE /* empty */
138 # endif
139 #endif
140
141 /* The definition of _Noreturn is copied here. */
142
143 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
144
145 /* The definition of _GL_ARG_NONNULL is copied here. */
146
147 /* The definition of _GL_WARN_ON_USE is copied here. */
148
149
150 /* Some systems do not define EXIT_*, despite otherwise supporting C89. */
151 #ifndef EXIT_SUCCESS
152 # define EXIT_SUCCESS 0
153 #endif
154 /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
155 with proper operation of xargs. */
156 #ifndef EXIT_FAILURE
157 # define EXIT_FAILURE 1
158 #elif EXIT_FAILURE != 1
159 # undef EXIT_FAILURE
160 # define EXIT_FAILURE 1
161 #endif
162
163
164 #if @GNULIB__EXIT@
165 /* Terminate the current process with the given return code, without running
166 the 'atexit' handlers. */
167 # if !@HAVE__EXIT@
168 _GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status));
169 # endif
170 _GL_CXXALIAS_SYS (_Exit, void, (int status));
171 _GL_CXXALIASWARN (_Exit);
172 #elif defined GNULIB_POSIXCHECK
173 # undef _Exit
174 # if HAVE_RAW_DECL__EXIT
175 _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
176 "use gnulib module _Exit for portability");
177 # endif
178 #endif
179
180
181 #if @GNULIB_FREE_POSIX@
182 # if @REPLACE_FREE@
183 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
184 # undef free
185 # define free rpl_free
186 # endif
187 _GL_FUNCDECL_RPL (free, void, (void *ptr));
188 _GL_CXXALIAS_RPL (free, void, (void *ptr));
189 # else
190 _GL_CXXALIAS_SYS (free, void, (void *ptr));
191 # endif
192 # if __GLIBC__ >= 2
193 _GL_CXXALIASWARN (free);
194 # endif
195 #elif defined GNULIB_POSIXCHECK
196 # undef free
197 /* Assume free is always declared. */
198 _GL_WARN_ON_USE (free, "free is not future POSIX compliant everywhere - "
199 "use gnulib module free for portability");
200 #endif
201
202
203 /* Allocate memory with indefinite extent and specified alignment. */
204 #if @GNULIB_ALIGNED_ALLOC@
205 # if @REPLACE_ALIGNED_ALLOC@
206 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
207 # undef aligned_alloc
208 # define aligned_alloc rpl_aligned_alloc
209 # endif
210 _GL_FUNCDECL_RPL (aligned_alloc, void *,
211 (size_t alignment, size_t size)
212 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
213 _GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size));
214 # else
215 # if @HAVE_ALIGNED_ALLOC@
216 # if __GNUC__ >= 11
217 /* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
218 _GL_FUNCDECL_SYS (aligned_alloc, void *,
219 (size_t alignment, size_t size)
220 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
221 # endif
222 _GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size));
223 # endif
224 # endif
225 # if @HAVE_ALIGNED_ALLOC@
226 _GL_CXXALIASWARN (aligned_alloc);
227 # endif
228 #else
229 # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined aligned_alloc
230 /* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
231 _GL_FUNCDECL_SYS (aligned_alloc, void *,
232 (size_t alignment, size_t size)
233 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
234 # endif
235 # if defined GNULIB_POSIXCHECK
236 # undef aligned_alloc
237 # if HAVE_RAW_DECL_ALIGNED_ALLOC
238 _GL_WARN_ON_USE (aligned_alloc, "aligned_alloc is not portable - "
239 "use gnulib module aligned_alloc for portability");
240 # endif
241 # endif
242 #endif
243
244 #if @GNULIB_ATOLL@
245 /* Parse a signed decimal integer.
246 Returns the value of the integer. Errors are not detected. */
247 # if !@HAVE_ATOLL@
248 _GL_FUNCDECL_SYS (atoll, long long, (const char *string)
249 _GL_ATTRIBUTE_PURE
250 _GL_ARG_NONNULL ((1)));
251 # endif
252 _GL_CXXALIAS_SYS (atoll, long long, (const char *string));
253 _GL_CXXALIASWARN (atoll);
254 #elif defined GNULIB_POSIXCHECK
255 # undef atoll
256 # if HAVE_RAW_DECL_ATOLL
257 _GL_WARN_ON_USE (atoll, "atoll is unportable - "
258 "use gnulib module atoll for portability");
259 # endif
260 #endif
261
262 #if @GNULIB_CALLOC_POSIX@
263 # if @REPLACE_CALLOC@
264 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
265 # undef calloc
266 # define calloc rpl_calloc
267 # endif
268 _GL_FUNCDECL_RPL (calloc, void *,
269 (size_t nmemb, size_t size)
270 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
271 _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
272 # else
273 # if __GNUC__ >= 11
274 /* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
275 _GL_FUNCDECL_SYS (calloc, void *,
276 (size_t nmemb, size_t size)
277 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
278 # endif
279 _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
280 # endif
281 # if __GLIBC__ >= 2
282 _GL_CXXALIASWARN (calloc);
283 # endif
284 #else
285 # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined calloc
286 /* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
287 _GL_FUNCDECL_SYS (calloc, void *,
288 (size_t nmemb, size_t size)
289 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
290 # endif
291 # if defined GNULIB_POSIXCHECK
292 # undef calloc
293 /* Assume calloc is always declared. */
294 _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
295 "use gnulib module calloc-posix for portability");
296 # endif
297 #endif
298
299 #if @GNULIB_CANONICALIZE_FILE_NAME@
300 # if @REPLACE_CANONICALIZE_FILE_NAME@
301 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
302 # define canonicalize_file_name rpl_canonicalize_file_name
303 # endif
304 _GL_FUNCDECL_RPL (canonicalize_file_name, char *,
305 (const char *name)
306 _GL_ARG_NONNULL ((1))
307 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
308 _GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
309 # else
310 # if !@HAVE_CANONICALIZE_FILE_NAME@ || __GNUC__ >= 11
311 _GL_FUNCDECL_SYS (canonicalize_file_name, char *,
312 (const char *name)
313 _GL_ARG_NONNULL ((1))
314 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
315 # endif
316 _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
317 # endif
318 # ifndef GNULIB_defined_canonicalize_file_name
319 # define GNULIB_defined_canonicalize_file_name \
320 (!@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@)
321 # endif
322 _GL_CXXALIASWARN (canonicalize_file_name);
323 #else
324 # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined canonicalize_file_name
325 /* For -Wmismatched-dealloc: Associate canonicalize_file_name with free or
326 rpl_free. */
327 _GL_FUNCDECL_SYS (canonicalize_file_name, char *,
328 (const char *name)
329 _GL_ARG_NONNULL ((1))
330 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
331 # endif
332 # if defined GNULIB_POSIXCHECK
333 # undef canonicalize_file_name
334 # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
335 _GL_WARN_ON_USE (canonicalize_file_name,
336 "canonicalize_file_name is unportable - "
337 "use gnulib module canonicalize-lgpl for portability");
338 # endif
339 # endif
340 #endif
341
342 #if @GNULIB_MDA_ECVT@
343 /* On native Windows, map 'ecvt' to '_ecvt', so that -loldnames is not
344 required. In C++ with GNULIB_NAMESPACE, avoid differences between
345 platforms by defining GNULIB_NAMESPACE::ecvt on all platforms that have
346 it. */
347 # if defined _WIN32 && !defined __CYGWIN__
348 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
349 # undef ecvt
350 # define ecvt _ecvt
351 # endif
352 _GL_CXXALIAS_MDA (ecvt, char *,
353 (double number, int ndigits, int *decptp, int *signp));
354 # else
355 # if @HAVE_DECL_ECVT@
356 _GL_CXXALIAS_SYS (ecvt, char *,
357 (double number, int ndigits, int *decptp, int *signp));
358 # endif
359 # endif
360 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_ECVT@
361 _GL_CXXALIASWARN (ecvt);
362 # endif
363 #endif
364
365 #if @GNULIB_MDA_FCVT@
366 /* On native Windows, map 'fcvt' to '_fcvt', so that -loldnames is not
367 required. In C++ with GNULIB_NAMESPACE, avoid differences between
368 platforms by defining GNULIB_NAMESPACE::fcvt on all platforms that have
369 it. */
370 # if defined _WIN32 && !defined __CYGWIN__
371 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
372 # undef fcvt
373 # define fcvt _fcvt
374 # endif
375 _GL_CXXALIAS_MDA (fcvt, char *,
376 (double number, int ndigits, int *decptp, int *signp));
377 # else
378 # if @HAVE_DECL_FCVT@
379 _GL_CXXALIAS_SYS (fcvt, char *,
380 (double number, int ndigits, int *decptp, int *signp));
381 # endif
382 # endif
383 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_FCVT@
384 _GL_CXXALIASWARN (fcvt);
385 # endif
386 #endif
387
388 #if @GNULIB_MDA_GCVT@
389 /* On native Windows, map 'gcvt' to '_gcvt', so that -loldnames is not
390 required. In C++ with GNULIB_NAMESPACE, avoid differences between
391 platforms by defining GNULIB_NAMESPACE::gcvt on all platforms that have
392 it. */
393 # if defined _WIN32 && !defined __CYGWIN__
394 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
395 # undef gcvt
396 # define gcvt _gcvt
397 # endif
398 _GL_CXXALIAS_MDA (gcvt, char *, (double number, int ndigits, char *buf));
399 # else
400 # if @HAVE_DECL_GCVT@
401 _GL_CXXALIAS_SYS (gcvt, char *, (double number, int ndigits, char *buf));
402 # endif
403 # endif
404 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_GCVT@
405 _GL_CXXALIASWARN (gcvt);
406 # endif
407 #endif
408
409 #if @GNULIB_GETLOADAVG@
410 /* Store max(NELEM,3) load average numbers in LOADAVG[].
411 The three numbers are the load average of the last 1 minute, the last 5
412 minutes, and the last 15 minutes, respectively.
413 LOADAVG is an array of NELEM numbers. */
414 # if !@HAVE_DECL_GETLOADAVG@
415 _GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem)
416 _GL_ARG_NONNULL ((1)));
417 # endif
418 _GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
419 _GL_CXXALIASWARN (getloadavg);
420 #elif defined GNULIB_POSIXCHECK
421 # undef getloadavg
422 # if HAVE_RAW_DECL_GETLOADAVG
423 _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
424 "use gnulib module getloadavg for portability");
425 # endif
426 #endif
427
428 #if @GNULIB_GETSUBOPT@
429 /* Assuming *OPTIONP is a comma separated list of elements of the form
430 "token" or "token=value", getsubopt parses the first of these elements.
431 If the first element refers to a "token" that is member of the given
432 NULL-terminated array of tokens:
433 - It replaces the comma with a NUL byte, updates *OPTIONP to point past
434 the first option and the comma, sets *VALUEP to the value of the
435 element (or NULL if it doesn't contain an "=" sign),
436 - It returns the index of the "token" in the given array of tokens.
437 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
438 For more details see the POSIX specification.
439 https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html */
440 # if !@HAVE_GETSUBOPT@
441 _GL_FUNCDECL_SYS (getsubopt, int,
442 (char **optionp, char *const *tokens, char **valuep)
443 _GL_ARG_NONNULL ((1, 2, 3)));
444 # endif
445 _GL_CXXALIAS_SYS (getsubopt, int,
446 (char **optionp, char *const *tokens, char **valuep));
447 _GL_CXXALIASWARN (getsubopt);
448 #elif defined GNULIB_POSIXCHECK
449 # undef getsubopt
450 # if HAVE_RAW_DECL_GETSUBOPT
451 _GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
452 "use gnulib module getsubopt for portability");
453 # endif
454 #endif
455
456 #if @GNULIB_GRANTPT@
457 /* Change the ownership and access permission of the slave side of the
458 pseudo-terminal whose master side is specified by FD. */
459 # if !@HAVE_GRANTPT@
460 _GL_FUNCDECL_SYS (grantpt, int, (int fd));
461 # endif
462 _GL_CXXALIAS_SYS (grantpt, int, (int fd));
463 _GL_CXXALIASWARN (grantpt);
464 #elif defined GNULIB_POSIXCHECK
465 # undef grantpt
466 # if HAVE_RAW_DECL_GRANTPT
467 _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
468 "use gnulib module grantpt for portability");
469 # endif
470 #endif
471
472 /* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
473 rely on GNU or POSIX semantics for malloc and realloc (for example,
474 by never specifying a zero size), so it does not need malloc or
475 realloc to be redefined. */
476 #if @GNULIB_MALLOC_POSIX@
477 # if @REPLACE_MALLOC@
478 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
479 || _GL_USE_STDLIB_ALLOC)
480 # undef malloc
481 # define malloc rpl_malloc
482 # endif
483 _GL_FUNCDECL_RPL (malloc, void *,
484 (size_t size)
485 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
486 _GL_CXXALIAS_RPL (malloc, void *, (size_t size));
487 # else
488 # if __GNUC__ >= 11
489 /* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
490 _GL_FUNCDECL_SYS (malloc, void *,
491 (size_t size)
492 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
493 # endif
494 _GL_CXXALIAS_SYS (malloc, void *, (size_t size));
495 # endif
496 # if __GLIBC__ >= 2
497 _GL_CXXALIASWARN (malloc);
498 # endif
499 #else
500 # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined malloc
501 /* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
502 _GL_FUNCDECL_SYS (malloc, void *,
503 (size_t size)
504 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
505 # endif
506 # if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
507 # undef malloc
508 /* Assume malloc is always declared. */
509 _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
510 "use gnulib module malloc-posix for portability");
511 # endif
512 #endif
513
514 /* Convert a multibyte character to a wide character. */
515 #if @GNULIB_MBTOWC@
516 # if @REPLACE_MBTOWC@
517 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
518 # undef mbtowc
519 # define mbtowc rpl_mbtowc
520 # endif
521 _GL_FUNCDECL_RPL (mbtowc, int,
522 (wchar_t *restrict pwc, const char *restrict s, size_t n));
523 _GL_CXXALIAS_RPL (mbtowc, int,
524 (wchar_t *restrict pwc, const char *restrict s, size_t n));
525 # else
526 # if !@HAVE_MBTOWC@
527 _GL_FUNCDECL_SYS (mbtowc, int,
528 (wchar_t *restrict pwc, const char *restrict s, size_t n));
529 # endif
530 _GL_CXXALIAS_SYS (mbtowc, int,
531 (wchar_t *restrict pwc, const char *restrict s, size_t n));
532 # endif
533 # if __GLIBC__ >= 2
534 _GL_CXXALIASWARN (mbtowc);
535 # endif
536 #elif defined GNULIB_POSIXCHECK
537 # undef mbtowc
538 # if HAVE_RAW_DECL_MBTOWC
539 _GL_WARN_ON_USE (mbtowc, "mbtowc is not portable - "
540 "use gnulib module mbtowc for portability");
541 # endif
542 #endif
543
544 #if @GNULIB_MKDTEMP@
545 /* Create a unique temporary directory from TEMPLATE.
546 The last six characters of TEMPLATE must be "XXXXXX";
547 they are replaced with a string that makes the directory name unique.
548 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
549 The directory is created mode 700. */
550 # if !@HAVE_MKDTEMP@
551 _GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
552 # endif
553 _GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
554 _GL_CXXALIASWARN (mkdtemp);
555 #elif defined GNULIB_POSIXCHECK
556 # undef mkdtemp
557 # if HAVE_RAW_DECL_MKDTEMP
558 _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
559 "use gnulib module mkdtemp for portability");
560 # endif
561 #endif
562
563 #if @GNULIB_MKOSTEMP@
564 /* Create a unique temporary file from TEMPLATE.
565 The last six characters of TEMPLATE must be "XXXXXX";
566 they are replaced with a string that makes the file name unique.
567 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
568 and O_TEXT, O_BINARY (defined in "binary-io.h").
569 The file is then created, with the specified flags, ensuring it didn't exist
570 before.
571 The file is created read-write (mask at least 0600 & ~umask), but it may be
572 world-readable and world-writable (mask 0666 & ~umask), depending on the
573 implementation.
574 Returns the open file descriptor if successful, otherwise -1 and errno
575 set. */
576 # if !@HAVE_MKOSTEMP@
577 _GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)
578 _GL_ARG_NONNULL ((1)));
579 # endif
580 _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
581 _GL_CXXALIASWARN (mkostemp);
582 #elif defined GNULIB_POSIXCHECK
583 # undef mkostemp
584 # if HAVE_RAW_DECL_MKOSTEMP
585 _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
586 "use gnulib module mkostemp for portability");
587 # endif
588 #endif
589
590 #if @GNULIB_MKOSTEMPS@
591 /* Create a unique temporary file from TEMPLATE.
592 The last six characters of TEMPLATE before a suffix of length
593 SUFFIXLEN must be "XXXXXX";
594 they are replaced with a string that makes the file name unique.
595 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
596 and O_TEXT, O_BINARY (defined in "binary-io.h").
597 The file is then created, with the specified flags, ensuring it didn't exist
598 before.
599 The file is created read-write (mask at least 0600 & ~umask), but it may be
600 world-readable and world-writable (mask 0666 & ~umask), depending on the
601 implementation.
602 Returns the open file descriptor if successful, otherwise -1 and errno
603 set. */
604 # if !@HAVE_MKOSTEMPS@
605 _GL_FUNCDECL_SYS (mkostemps, int,
606 (char * /*template*/, int /*suffixlen*/, int /*flags*/)
607 _GL_ARG_NONNULL ((1)));
608 # endif
609 _GL_CXXALIAS_SYS (mkostemps, int,
610 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
611 _GL_CXXALIASWARN (mkostemps);
612 #elif defined GNULIB_POSIXCHECK
613 # undef mkostemps
614 # if HAVE_RAW_DECL_MKOSTEMPS
615 _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
616 "use gnulib module mkostemps for portability");
617 # endif
618 #endif
619
620 #if @GNULIB_MKSTEMP@
621 /* Create a unique temporary file from TEMPLATE.
622 The last six characters of TEMPLATE must be "XXXXXX";
623 they are replaced with a string that makes the file name unique.
624 The file is then created, ensuring it didn't exist before.
625 The file is created read-write (mask at least 0600 & ~umask), but it may be
626 world-readable and world-writable (mask 0666 & ~umask), depending on the
627 implementation.
628 Returns the open file descriptor if successful, otherwise -1 and errno
629 set. */
630 # if @REPLACE_MKSTEMP@
631 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
632 # define mkstemp rpl_mkstemp
633 # endif
634 _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
635 _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
636 # else
637 # if ! @HAVE_MKSTEMP@
638 _GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
639 # endif
640 _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
641 # endif
642 _GL_CXXALIASWARN (mkstemp);
643 #elif defined GNULIB_POSIXCHECK
644 # undef mkstemp
645 # if HAVE_RAW_DECL_MKSTEMP
646 _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
647 "use gnulib module mkstemp for portability");
648 # endif
649 #endif
650
651 #if @GNULIB_MKSTEMPS@
652 /* Create a unique temporary file from TEMPLATE.
653 The last six characters of TEMPLATE prior to a suffix of length
654 SUFFIXLEN must be "XXXXXX";
655 they are replaced with a string that makes the file name unique.
656 The file is then created, ensuring it didn't exist before.
657 The file is created read-write (mask at least 0600 & ~umask), but it may be
658 world-readable and world-writable (mask 0666 & ~umask), depending on the
659 implementation.
660 Returns the open file descriptor if successful, otherwise -1 and errno
661 set. */
662 # if !@HAVE_MKSTEMPS@
663 _GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)
664 _GL_ARG_NONNULL ((1)));
665 # endif
666 _GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
667 _GL_CXXALIASWARN (mkstemps);
668 #elif defined GNULIB_POSIXCHECK
669 # undef mkstemps
670 # if HAVE_RAW_DECL_MKSTEMPS
671 _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
672 "use gnulib module mkstemps for portability");
673 # endif
674 #endif
675
676 #if @GNULIB_MDA_MKTEMP@
677 /* On native Windows, map 'mktemp' to '_mktemp', so that -loldnames is not
678 required. In C++ with GNULIB_NAMESPACE, avoid differences between
679 platforms by defining GNULIB_NAMESPACE::mktemp always. */
680 # if defined _WIN32 && !defined __CYGWIN__
681 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
682 # undef mktemp
683 # define mktemp _mktemp
684 # endif
685 _GL_CXXALIAS_MDA (mktemp, char *, (char * /*template*/));
686 # else
687 _GL_CXXALIAS_SYS (mktemp, char *, (char * /*template*/));
688 # endif
689 _GL_CXXALIASWARN (mktemp);
690 #endif
691
692 /* Allocate memory with indefinite extent and specified alignment. */
693 #if @GNULIB_POSIX_MEMALIGN@
694 # if @REPLACE_POSIX_MEMALIGN@
695 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
696 # undef posix_memalign
697 # define posix_memalign rpl_posix_memalign
698 # endif
699 _GL_FUNCDECL_RPL (posix_memalign, int,
700 (void **memptr, size_t alignment, size_t size)
701 _GL_ARG_NONNULL ((1)));
702 _GL_CXXALIAS_RPL (posix_memalign, int,
703 (void **memptr, size_t alignment, size_t size));
704 # else
705 # if @HAVE_POSIX_MEMALIGN@
706 _GL_CXXALIAS_SYS (posix_memalign, int,
707 (void **memptr, size_t alignment, size_t size));
708 # endif
709 # endif
710 # if @HAVE_POSIX_MEMALIGN@
711 _GL_CXXALIASWARN (posix_memalign);
712 # endif
713 #elif defined GNULIB_POSIXCHECK
714 # undef posix_memalign
715 # if HAVE_RAW_DECL_POSIX_MEMALIGN
716 _GL_WARN_ON_USE (posix_memalign, "posix_memalign is not portable - "
717 "use gnulib module posix_memalign for portability");
718 # endif
719 #endif
720
721 #if @GNULIB_POSIX_OPENPT@
722 /* Return an FD open to the master side of a pseudo-terminal. Flags should
723 include O_RDWR, and may also include O_NOCTTY. */
724 # if !@HAVE_POSIX_OPENPT@
725 _GL_FUNCDECL_SYS (posix_openpt, int, (int flags));
726 # endif
727 _GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
728 _GL_CXXALIASWARN (posix_openpt);
729 #elif defined GNULIB_POSIXCHECK
730 # undef posix_openpt
731 # if HAVE_RAW_DECL_POSIX_OPENPT
732 _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
733 "use gnulib module posix_openpt for portability");
734 # endif
735 #endif
736
737 #if @GNULIB_PTSNAME@
738 /* Return the pathname of the pseudo-terminal slave associated with
739 the master FD is open on, or NULL on errors. */
740 # if @REPLACE_PTSNAME@
741 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
742 # undef ptsname
743 # define ptsname rpl_ptsname
744 # endif
745 _GL_FUNCDECL_RPL (ptsname, char *, (int fd));
746 _GL_CXXALIAS_RPL (ptsname, char *, (int fd));
747 # else
748 # if !@HAVE_PTSNAME@
749 _GL_FUNCDECL_SYS (ptsname, char *, (int fd));
750 # endif
751 _GL_CXXALIAS_SYS (ptsname, char *, (int fd));
752 # endif
753 _GL_CXXALIASWARN (ptsname);
754 #elif defined GNULIB_POSIXCHECK
755 # undef ptsname
756 # if HAVE_RAW_DECL_PTSNAME
757 _GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
758 "use gnulib module ptsname for portability");
759 # endif
760 #endif
761
762 #if @GNULIB_PTSNAME_R@
763 /* Set the pathname of the pseudo-terminal slave associated with
764 the master FD is open on and return 0, or set errno and return
765 non-zero on errors. */
766 # if @REPLACE_PTSNAME_R@
767 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
768 # undef ptsname_r
769 # define ptsname_r rpl_ptsname_r
770 # endif
771 _GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
772 _GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
773 # else
774 # if !@HAVE_PTSNAME_R@
775 _GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
776 # endif
777 _GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
778 # endif
779 # ifndef GNULIB_defined_ptsname_r
780 # define GNULIB_defined_ptsname_r (!@HAVE_PTSNAME_R@ || @REPLACE_PTSNAME_R@)
781 # endif
782 _GL_CXXALIASWARN (ptsname_r);
783 #elif defined GNULIB_POSIXCHECK
784 # undef ptsname_r
785 # if HAVE_RAW_DECL_PTSNAME_R
786 _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
787 "use gnulib module ptsname_r for portability");
788 # endif
789 #endif
790
791 #if @GNULIB_PUTENV@
792 # if @REPLACE_PUTENV@
793 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
794 # undef putenv
795 # define putenv rpl_putenv
796 # endif
797 _GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
798 _GL_CXXALIAS_RPL (putenv, int, (char *string));
799 # elif defined _WIN32 && !defined __CYGWIN__
800 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
801 # undef putenv
802 # define putenv _putenv
803 # endif
804 _GL_CXXALIAS_MDA (putenv, int, (char *string));
805 # else
806 _GL_CXXALIAS_SYS (putenv, int, (char *string));
807 # endif
808 _GL_CXXALIASWARN (putenv);
809 #elif @GNULIB_MDA_PUTENV@
810 /* On native Windows, map 'putenv' to '_putenv', so that -loldnames is not
811 required. In C++ with GNULIB_NAMESPACE, avoid differences between
812 platforms by defining GNULIB_NAMESPACE::putenv always. */
813 # if defined _WIN32 && !defined __CYGWIN__
814 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
815 # undef putenv
816 # define putenv _putenv
817 # endif
818 /* Need to cast, because on mingw, the parameter is either
819 'const char *string' or 'char *string'. */
820 _GL_CXXALIAS_MDA_CAST (putenv, int, (char *string));
821 # else
822 _GL_CXXALIAS_SYS (putenv, int, (char *string));
823 # endif
824 _GL_CXXALIASWARN (putenv);
825 #endif
826
827 #if @GNULIB_QSORT_R@
828 /* Sort an array of NMEMB elements, starting at address BASE, each element
829 occupying SIZE bytes, in ascending order according to the comparison
830 function COMPARE. */
831 # if @REPLACE_QSORT_R@
832 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
833 # undef qsort_r
834 # define qsort_r rpl_qsort_r
835 # endif
836 _GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
837 int (*compare) (void const *, void const *,
838 void *),
839 void *arg) _GL_ARG_NONNULL ((1, 4)));
840 _GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
841 int (*compare) (void const *, void const *,
842 void *),
843 void *arg));
844 # else
845 # if !@HAVE_QSORT_R@
846 _GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
847 int (*compare) (void const *, void const *,
848 void *),
849 void *arg) _GL_ARG_NONNULL ((1, 4)));
850 # endif
851 _GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
852 int (*compare) (void const *, void const *,
853 void *),
854 void *arg));
855 # endif
856 _GL_CXXALIASWARN (qsort_r);
857 #elif defined GNULIB_POSIXCHECK
858 # undef qsort_r
859 # if HAVE_RAW_DECL_QSORT_R
860 _GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
861 "use gnulib module qsort_r for portability");
862 # endif
863 #endif
864
865
866 #if @GNULIB_RANDOM_R@
867 # if !@HAVE_RANDOM_R@
868 # ifndef RAND_MAX
869 # define RAND_MAX 2147483647
870 # endif
871 # endif
872 #endif
873
874
875 #if @GNULIB_RANDOM@
876 # if @REPLACE_RANDOM@
877 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
878 # undef random
879 # define random rpl_random
880 # endif
881 _GL_FUNCDECL_RPL (random, long, (void));
882 _GL_CXXALIAS_RPL (random, long, (void));
883 # else
884 # if !@HAVE_RANDOM@
885 _GL_FUNCDECL_SYS (random, long, (void));
886 # endif
887 /* Need to cast, because on Haiku, the return type is
888 int. */
889 _GL_CXXALIAS_SYS_CAST (random, long, (void));
890 # endif
891 _GL_CXXALIASWARN (random);
892 #elif defined GNULIB_POSIXCHECK
893 # undef random
894 # if HAVE_RAW_DECL_RANDOM
895 _GL_WARN_ON_USE (random, "random is unportable - "
896 "use gnulib module random for portability");
897 # endif
898 #endif
899
900 #if @GNULIB_RANDOM@
901 # if @REPLACE_RANDOM@
902 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
903 # undef srandom
904 # define srandom rpl_srandom
905 # endif
906 _GL_FUNCDECL_RPL (srandom, void, (unsigned int seed));
907 _GL_CXXALIAS_RPL (srandom, void, (unsigned int seed));
908 # else
909 # if !@HAVE_RANDOM@
910 _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
911 # endif
912 /* Need to cast, because on FreeBSD, the first parameter is
913 unsigned long seed. */
914 _GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed));
915 # endif
916 _GL_CXXALIASWARN (srandom);
917 #elif defined GNULIB_POSIXCHECK
918 # undef srandom
919 # if HAVE_RAW_DECL_SRANDOM
920 _GL_WARN_ON_USE (srandom, "srandom is unportable - "
921 "use gnulib module random for portability");
922 # endif
923 #endif
924
925 #if @GNULIB_RANDOM@
926 # if @REPLACE_INITSTATE@
927 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
928 # undef initstate
929 # define initstate rpl_initstate
930 # endif
931 _GL_FUNCDECL_RPL (initstate, char *,
932 (unsigned int seed, char *buf, size_t buf_size)
933 _GL_ARG_NONNULL ((2)));
934 _GL_CXXALIAS_RPL (initstate, char *,
935 (unsigned int seed, char *buf, size_t buf_size));
936 # else
937 # if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@
938 _GL_FUNCDECL_SYS (initstate, char *,
939 (unsigned int seed, char *buf, size_t buf_size)
940 _GL_ARG_NONNULL ((2)));
941 # endif
942 /* Need to cast, because on FreeBSD, the first parameter is
943 unsigned long seed. */
944 _GL_CXXALIAS_SYS_CAST (initstate, char *,
945 (unsigned int seed, char *buf, size_t buf_size));
946 # endif
947 _GL_CXXALIASWARN (initstate);
948 #elif defined GNULIB_POSIXCHECK
949 # undef initstate
950 # if HAVE_RAW_DECL_INITSTATE
951 _GL_WARN_ON_USE (initstate, "initstate is unportable - "
952 "use gnulib module random for portability");
953 # endif
954 #endif
955
956 #if @GNULIB_RANDOM@
957 # if @REPLACE_SETSTATE@
958 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
959 # undef setstate
960 # define setstate rpl_setstate
961 # endif
962 _GL_FUNCDECL_RPL (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
963 _GL_CXXALIAS_RPL (setstate, char *, (char *arg_state));
964 # else
965 # if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@
966 _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
967 # endif
968 /* Need to cast, because on Mac OS X 10.13, HP-UX, Solaris the first parameter
969 is const char *arg_state. */
970 _GL_CXXALIAS_SYS_CAST (setstate, char *, (char *arg_state));
971 # endif
972 _GL_CXXALIASWARN (setstate);
973 #elif defined GNULIB_POSIXCHECK
974 # undef setstate
975 # if HAVE_RAW_DECL_SETSTATE
976 _GL_WARN_ON_USE (setstate, "setstate is unportable - "
977 "use gnulib module random for portability");
978 # endif
979 #endif
980
981
982 #if @GNULIB_RANDOM_R@
983 # if @REPLACE_RANDOM_R@
984 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
985 # undef random_r
986 # define random_r rpl_random_r
987 # endif
988 _GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
989 _GL_ARG_NONNULL ((1, 2)));
990 _GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
991 # else
992 # if !@HAVE_RANDOM_R@
993 _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
994 _GL_ARG_NONNULL ((1, 2)));
995 # endif
996 _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
997 # endif
998 _GL_CXXALIASWARN (random_r);
999 #elif defined GNULIB_POSIXCHECK
1000 # undef random_r
1001 # if HAVE_RAW_DECL_RANDOM_R
1002 _GL_WARN_ON_USE (random_r, "random_r is unportable - "
1003 "use gnulib module random_r for portability");
1004 # endif
1005 #endif
1006
1007 #if @GNULIB_RANDOM_R@
1008 # if @REPLACE_RANDOM_R@
1009 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1010 # undef srandom_r
1011 # define srandom_r rpl_srandom_r
1012 # endif
1013 _GL_FUNCDECL_RPL (srandom_r, int,
1014 (unsigned int seed, struct random_data *rand_state)
1015 _GL_ARG_NONNULL ((2)));
1016 _GL_CXXALIAS_RPL (srandom_r, int,
1017 (unsigned int seed, struct random_data *rand_state));
1018 # else
1019 # if !@HAVE_RANDOM_R@
1020 _GL_FUNCDECL_SYS (srandom_r, int,
1021 (unsigned int seed, struct random_data *rand_state)
1022 _GL_ARG_NONNULL ((2)));
1023 # endif
1024 _GL_CXXALIAS_SYS (srandom_r, int,
1025 (unsigned int seed, struct random_data *rand_state));
1026 # endif
1027 _GL_CXXALIASWARN (srandom_r);
1028 #elif defined GNULIB_POSIXCHECK
1029 # undef srandom_r
1030 # if HAVE_RAW_DECL_SRANDOM_R
1031 _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
1032 "use gnulib module random_r for portability");
1033 # endif
1034 #endif
1035
1036 #if @GNULIB_RANDOM_R@
1037 # if @REPLACE_RANDOM_R@
1038 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1039 # undef initstate_r
1040 # define initstate_r rpl_initstate_r
1041 # endif
1042 _GL_FUNCDECL_RPL (initstate_r, int,
1043 (unsigned int seed, char *buf, size_t buf_size,
1044 struct random_data *rand_state)
1045 _GL_ARG_NONNULL ((2, 4)));
1046 _GL_CXXALIAS_RPL (initstate_r, int,
1047 (unsigned int seed, char *buf, size_t buf_size,
1048 struct random_data *rand_state));
1049 # else
1050 # if !@HAVE_RANDOM_R@
1051 _GL_FUNCDECL_SYS (initstate_r, int,
1052 (unsigned int seed, char *buf, size_t buf_size,
1053 struct random_data *rand_state)
1054 _GL_ARG_NONNULL ((2, 4)));
1055 # endif
1056 /* Need to cast, because on Haiku, the third parameter is
1057 unsigned long buf_size. */
1058 _GL_CXXALIAS_SYS_CAST (initstate_r, int,
1059 (unsigned int seed, char *buf, size_t buf_size,
1060 struct random_data *rand_state));
1061 # endif
1062 _GL_CXXALIASWARN (initstate_r);
1063 #elif defined GNULIB_POSIXCHECK
1064 # undef initstate_r
1065 # if HAVE_RAW_DECL_INITSTATE_R
1066 _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
1067 "use gnulib module random_r for portability");
1068 # endif
1069 #endif
1070
1071 #if @GNULIB_RANDOM_R@
1072 # if @REPLACE_RANDOM_R@
1073 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1074 # undef setstate_r
1075 # define setstate_r rpl_setstate_r
1076 # endif
1077 _GL_FUNCDECL_RPL (setstate_r, int,
1078 (char *arg_state, struct random_data *rand_state)
1079 _GL_ARG_NONNULL ((1, 2)));
1080 _GL_CXXALIAS_RPL (setstate_r, int,
1081 (char *arg_state, struct random_data *rand_state));
1082 # else
1083 # if !@HAVE_RANDOM_R@
1084 _GL_FUNCDECL_SYS (setstate_r, int,
1085 (char *arg_state, struct random_data *rand_state)
1086 _GL_ARG_NONNULL ((1, 2)));
1087 # endif
1088 /* Need to cast, because on Haiku, the first parameter is
1089 void *arg_state. */
1090 _GL_CXXALIAS_SYS_CAST (setstate_r, int,
1091 (char *arg_state, struct random_data *rand_state));
1092 # endif
1093 _GL_CXXALIASWARN (setstate_r);
1094 #elif defined GNULIB_POSIXCHECK
1095 # undef setstate_r
1096 # if HAVE_RAW_DECL_SETSTATE_R
1097 _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
1098 "use gnulib module random_r for portability");
1099 # endif
1100 #endif
1101
1102
1103 #if @GNULIB_REALLOC_POSIX@
1104 # if @REPLACE_REALLOC@
1105 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
1106 || _GL_USE_STDLIB_ALLOC)
1107 # undef realloc
1108 # define realloc rpl_realloc
1109 # endif
1110 _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size)
1111 _GL_ATTRIBUTE_DEALLOC_FREE);
1112 _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
1113 # else
1114 # if __GNUC__ >= 11
1115 /* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1116 _GL_FUNCDECL_SYS (realloc, void *, (void *ptr, size_t size)
1117 _GL_ATTRIBUTE_DEALLOC_FREE);
1118 # endif
1119 _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
1120 # endif
1121 # if __GLIBC__ >= 2
1122 _GL_CXXALIASWARN (realloc);
1123 # endif
1124 #else
1125 # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined realloc
1126 /* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1127 _GL_FUNCDECL_SYS (realloc, void *, (void *ptr, size_t size)
1128 _GL_ATTRIBUTE_DEALLOC_FREE);
1129 # endif
1130 # if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
1131 # undef realloc
1132 /* Assume realloc is always declared. */
1133 _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
1134 "use gnulib module realloc-posix for portability");
1135 # endif
1136 #endif
1137
1138
1139 #if @GNULIB_REALLOCARRAY@
1140 # if @REPLACE_REALLOCARRAY@
1141 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1142 # undef reallocarray
1143 # define reallocarray rpl_reallocarray
1144 # endif
1145 _GL_FUNCDECL_RPL (reallocarray, void *,
1146 (void *ptr, size_t nmemb, size_t size));
1147 _GL_CXXALIAS_RPL (reallocarray, void *,
1148 (void *ptr, size_t nmemb, size_t size));
1149 # else
1150 # if ! @HAVE_REALLOCARRAY@
1151 _GL_FUNCDECL_SYS (reallocarray, void *,
1152 (void *ptr, size_t nmemb, size_t size));
1153 # endif
1154 _GL_CXXALIAS_SYS (reallocarray, void *,
1155 (void *ptr, size_t nmemb, size_t size));
1156 # endif
1157 _GL_CXXALIASWARN (reallocarray);
1158 #elif defined GNULIB_POSIXCHECK
1159 # undef reallocarray
1160 # if HAVE_RAW_DECL_REALLOCARRAY
1161 _GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - "
1162 "use gnulib module reallocarray for portability");
1163 # endif
1164 #endif
1165
1166 #if @GNULIB_REALPATH@
1167 # if @REPLACE_REALPATH@
1168 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1169 # define realpath rpl_realpath
1170 # endif
1171 _GL_FUNCDECL_RPL (realpath, char *,
1172 (const char *restrict name, char *restrict resolved)
1173 _GL_ARG_NONNULL ((1)));
1174 _GL_CXXALIAS_RPL (realpath, char *,
1175 (const char *restrict name, char *restrict resolved));
1176 # else
1177 # if !@HAVE_REALPATH@
1178 _GL_FUNCDECL_SYS (realpath, char *,
1179 (const char *restrict name, char *restrict resolved)
1180 _GL_ARG_NONNULL ((1)));
1181 # endif
1182 _GL_CXXALIAS_SYS (realpath, char *,
1183 (const char *restrict name, char *restrict resolved));
1184 # endif
1185 _GL_CXXALIASWARN (realpath);
1186 #elif defined GNULIB_POSIXCHECK
1187 # undef realpath
1188 # if HAVE_RAW_DECL_REALPATH
1189 _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
1190 "canonicalize or canonicalize-lgpl for portability");
1191 # endif
1192 #endif
1193
1194 #if @GNULIB_RPMATCH@
1195 /* Test a user response to a question.
1196 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
1197 # if !@HAVE_RPMATCH@
1198 _GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1)));
1199 # endif
1200 _GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
1201 _GL_CXXALIASWARN (rpmatch);
1202 #elif defined GNULIB_POSIXCHECK
1203 # undef rpmatch
1204 # if HAVE_RAW_DECL_RPMATCH
1205 _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
1206 "use gnulib module rpmatch for portability");
1207 # endif
1208 #endif
1209
1210 #if @GNULIB_SECURE_GETENV@
1211 /* Look up NAME in the environment, returning 0 in insecure situations. */
1212 # if !@HAVE_SECURE_GETENV@
1213 _GL_FUNCDECL_SYS (secure_getenv, char *,
1214 (char const *name) _GL_ARG_NONNULL ((1)));
1215 # endif
1216 _GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
1217 _GL_CXXALIASWARN (secure_getenv);
1218 #elif defined GNULIB_POSIXCHECK
1219 # undef secure_getenv
1220 # if HAVE_RAW_DECL_SECURE_GETENV
1221 _GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
1222 "use gnulib module secure_getenv for portability");
1223 # endif
1224 #endif
1225
1226 #if @GNULIB_SETENV@
1227 /* Set NAME to VALUE in the environment.
1228 If REPLACE is nonzero, overwrite an existing value. */
1229 # if @REPLACE_SETENV@
1230 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1231 # undef setenv
1232 # define setenv rpl_setenv
1233 # endif
1234 _GL_FUNCDECL_RPL (setenv, int,
1235 (const char *name, const char *value, int replace)
1236 _GL_ARG_NONNULL ((1)));
1237 _GL_CXXALIAS_RPL (setenv, int,
1238 (const char *name, const char *value, int replace));
1239 # else
1240 # if !@HAVE_DECL_SETENV@
1241 _GL_FUNCDECL_SYS (setenv, int,
1242 (const char *name, const char *value, int replace)
1243 _GL_ARG_NONNULL ((1)));
1244 # endif
1245 _GL_CXXALIAS_SYS (setenv, int,
1246 (const char *name, const char *value, int replace));
1247 # endif
1248 # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
1249 _GL_CXXALIASWARN (setenv);
1250 # endif
1251 #elif defined GNULIB_POSIXCHECK
1252 # undef setenv
1253 # if HAVE_RAW_DECL_SETENV
1254 _GL_WARN_ON_USE (setenv, "setenv is unportable - "
1255 "use gnulib module setenv for portability");
1256 # endif
1257 #endif
1258
1259 #if @GNULIB_STRTOD@
1260 /* Parse a double from STRING, updating ENDP if appropriate. */
1261 # if @REPLACE_STRTOD@
1262 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1263 # define strtod rpl_strtod
1264 # endif
1265 # define GNULIB_defined_strtod_function 1
1266 _GL_FUNCDECL_RPL (strtod, double,
1267 (const char *restrict str, char **restrict endp)
1268 _GL_ARG_NONNULL ((1)));
1269 _GL_CXXALIAS_RPL (strtod, double,
1270 (const char *restrict str, char **restrict endp));
1271 # else
1272 # if !@HAVE_STRTOD@
1273 _GL_FUNCDECL_SYS (strtod, double,
1274 (const char *restrict str, char **restrict endp)
1275 _GL_ARG_NONNULL ((1)));
1276 # endif
1277 _GL_CXXALIAS_SYS (strtod, double,
1278 (const char *restrict str, char **restrict endp));
1279 # endif
1280 # if __GLIBC__ >= 2
1281 _GL_CXXALIASWARN (strtod);
1282 # endif
1283 #elif defined GNULIB_POSIXCHECK
1284 # undef strtod
1285 # if HAVE_RAW_DECL_STRTOD
1286 _GL_WARN_ON_USE (strtod, "strtod is unportable - "
1287 "use gnulib module strtod for portability");
1288 # endif
1289 #endif
1290
1291 #if @GNULIB_STRTOLD@
1292 /* Parse a 'long double' from STRING, updating ENDP if appropriate. */
1293 # if @REPLACE_STRTOLD@
1294 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1295 # define strtold rpl_strtold
1296 # endif
1297 # define GNULIB_defined_strtold_function 1
1298 _GL_FUNCDECL_RPL (strtold, long double,
1299 (const char *restrict str, char **restrict endp)
1300 _GL_ARG_NONNULL ((1)));
1301 _GL_CXXALIAS_RPL (strtold, long double,
1302 (const char *restrict str, char **restrict endp));
1303 # else
1304 # if !@HAVE_STRTOLD@
1305 _GL_FUNCDECL_SYS (strtold, long double,
1306 (const char *restrict str, char **restrict endp)
1307 _GL_ARG_NONNULL ((1)));
1308 # endif
1309 _GL_CXXALIAS_SYS (strtold, long double,
1310 (const char *restrict str, char **restrict endp));
1311 # endif
1312 _GL_CXXALIASWARN (strtold);
1313 #elif defined GNULIB_POSIXCHECK
1314 # undef strtold
1315 # if HAVE_RAW_DECL_STRTOLD
1316 _GL_WARN_ON_USE (strtold, "strtold is unportable - "
1317 "use gnulib module strtold for portability");
1318 # endif
1319 #endif
1320
1321 #if @GNULIB_STRTOL@
1322 /* Parse a signed integer whose textual representation starts at STRING.
1323 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1324 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1325 "0x").
1326 If ENDPTR is not NULL, the address of the first byte after the integer is
1327 stored in *ENDPTR.
1328 Upon overflow, the return value is LONG_MAX or LONG_MIN, and errno is set
1329 to ERANGE. */
1330 # if @REPLACE_STRTOL@
1331 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1332 # define strtol rpl_strtol
1333 # endif
1334 # define GNULIB_defined_strtol_function 1
1335 _GL_FUNCDECL_RPL (strtol, long,
1336 (const char *restrict string, char **restrict endptr,
1337 int base)
1338 _GL_ARG_NONNULL ((1)));
1339 _GL_CXXALIAS_RPL (strtol, long,
1340 (const char *restrict string, char **restrict endptr,
1341 int base));
1342 # else
1343 # if !@HAVE_STRTOL@
1344 _GL_FUNCDECL_SYS (strtol, long,
1345 (const char *restrict string, char **restrict endptr,
1346 int base)
1347 _GL_ARG_NONNULL ((1)));
1348 # endif
1349 _GL_CXXALIAS_SYS (strtol, long,
1350 (const char *restrict string, char **restrict endptr,
1351 int base));
1352 # endif
1353 _GL_CXXALIASWARN (strtol);
1354 #elif defined GNULIB_POSIXCHECK
1355 # undef strtol
1356 # if HAVE_RAW_DECL_STRTOL
1357 _GL_WARN_ON_USE (strtol, "strtol is unportable - "
1358 "use gnulib module strtol for portability");
1359 # endif
1360 #endif
1361
1362 #if @GNULIB_STRTOLL@
1363 /* Parse a signed integer whose textual representation starts at STRING.
1364 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1365 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1366 "0x").
1367 If ENDPTR is not NULL, the address of the first byte after the integer is
1368 stored in *ENDPTR.
1369 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
1370 to ERANGE. */
1371 # if @REPLACE_STRTOLL@
1372 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1373 # define strtoll rpl_strtoll
1374 # endif
1375 # define GNULIB_defined_strtoll_function 1
1376 _GL_FUNCDECL_RPL (strtoll, long long,
1377 (const char *restrict string, char **restrict endptr,
1378 int base)
1379 _GL_ARG_NONNULL ((1)));
1380 _GL_CXXALIAS_RPL (strtoll, long long,
1381 (const char *restrict string, char **restrict endptr,
1382 int base));
1383 # else
1384 # if !@HAVE_STRTOLL@
1385 _GL_FUNCDECL_SYS (strtoll, long long,
1386 (const char *restrict string, char **restrict endptr,
1387 int base)
1388 _GL_ARG_NONNULL ((1)));
1389 # endif
1390 _GL_CXXALIAS_SYS (strtoll, long long,
1391 (const char *restrict string, char **restrict endptr,
1392 int base));
1393 # endif
1394 _GL_CXXALIASWARN (strtoll);
1395 #elif defined GNULIB_POSIXCHECK
1396 # undef strtoll
1397 # if HAVE_RAW_DECL_STRTOLL
1398 _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
1399 "use gnulib module strtoll for portability");
1400 # endif
1401 #endif
1402
1403 #if @GNULIB_STRTOUL@
1404 /* Parse an unsigned integer whose textual representation starts at STRING.
1405 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1406 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1407 "0x").
1408 If ENDPTR is not NULL, the address of the first byte after the integer is
1409 stored in *ENDPTR.
1410 Upon overflow, the return value is ULONG_MAX, and errno is set to ERANGE. */
1411 # if @REPLACE_STRTOUL@
1412 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1413 # define strtoul rpl_strtoul
1414 # endif
1415 # define GNULIB_defined_strtoul_function 1
1416 _GL_FUNCDECL_RPL (strtoul, unsigned long,
1417 (const char *restrict string, char **restrict endptr,
1418 int base)
1419 _GL_ARG_NONNULL ((1)));
1420 _GL_CXXALIAS_RPL (strtoul, unsigned long,
1421 (const char *restrict string, char **restrict endptr,
1422 int base));
1423 # else
1424 # if !@HAVE_STRTOUL@
1425 _GL_FUNCDECL_SYS (strtoul, unsigned long,
1426 (const char *restrict string, char **restrict endptr,
1427 int base)
1428 _GL_ARG_NONNULL ((1)));
1429 # endif
1430 _GL_CXXALIAS_SYS (strtoul, unsigned long,
1431 (const char *restrict string, char **restrict endptr,
1432 int base));
1433 # endif
1434 _GL_CXXALIASWARN (strtoul);
1435 #elif defined GNULIB_POSIXCHECK
1436 # undef strtoul
1437 # if HAVE_RAW_DECL_STRTOUL
1438 _GL_WARN_ON_USE (strtoul, "strtoul is unportable - "
1439 "use gnulib module strtoul for portability");
1440 # endif
1441 #endif
1442
1443 #if @GNULIB_STRTOULL@
1444 /* Parse an unsigned integer whose textual representation starts at STRING.
1445 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1446 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1447 "0x").
1448 If ENDPTR is not NULL, the address of the first byte after the integer is
1449 stored in *ENDPTR.
1450 Upon overflow, the return value is ULLONG_MAX, and errno is set to
1451 ERANGE. */
1452 # if @REPLACE_STRTOULL@
1453 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1454 # define strtoull rpl_strtoull
1455 # endif
1456 # define GNULIB_defined_strtoull_function 1
1457 _GL_FUNCDECL_RPL (strtoull, unsigned long long,
1458 (const char *restrict string, char **restrict endptr,
1459 int base)
1460 _GL_ARG_NONNULL ((1)));
1461 _GL_CXXALIAS_RPL (strtoull, unsigned long long,
1462 (const char *restrict string, char **restrict endptr,
1463 int base));
1464 # else
1465 # if !@HAVE_STRTOULL@
1466 _GL_FUNCDECL_SYS (strtoull, unsigned long long,
1467 (const char *restrict string, char **restrict endptr,
1468 int base)
1469 _GL_ARG_NONNULL ((1)));
1470 # endif
1471 _GL_CXXALIAS_SYS (strtoull, unsigned long long,
1472 (const char *restrict string, char **restrict endptr,
1473 int base));
1474 # endif
1475 _GL_CXXALIASWARN (strtoull);
1476 #elif defined GNULIB_POSIXCHECK
1477 # undef strtoull
1478 # if HAVE_RAW_DECL_STRTOULL
1479 _GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
1480 "use gnulib module strtoull for portability");
1481 # endif
1482 #endif
1483
1484 #if @GNULIB_UNLOCKPT@
1485 /* Unlock the slave side of the pseudo-terminal whose master side is specified
1486 by FD, so that it can be opened. */
1487 # if !@HAVE_UNLOCKPT@
1488 _GL_FUNCDECL_SYS (unlockpt, int, (int fd));
1489 # endif
1490 _GL_CXXALIAS_SYS (unlockpt, int, (int fd));
1491 _GL_CXXALIASWARN (unlockpt);
1492 #elif defined GNULIB_POSIXCHECK
1493 # undef unlockpt
1494 # if HAVE_RAW_DECL_UNLOCKPT
1495 _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
1496 "use gnulib module unlockpt for portability");
1497 # endif
1498 #endif
1499
1500 #if @GNULIB_UNSETENV@
1501 /* Remove the variable NAME from the environment. */
1502 # if @REPLACE_UNSETENV@
1503 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1504 # undef unsetenv
1505 # define unsetenv rpl_unsetenv
1506 # endif
1507 _GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
1508 _GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
1509 # else
1510 # if !@HAVE_DECL_UNSETENV@
1511 _GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
1512 # endif
1513 _GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
1514 # endif
1515 # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
1516 _GL_CXXALIASWARN (unsetenv);
1517 # endif
1518 #elif defined GNULIB_POSIXCHECK
1519 # undef unsetenv
1520 # if HAVE_RAW_DECL_UNSETENV
1521 _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
1522 "use gnulib module unsetenv for portability");
1523 # endif
1524 #endif
1525
1526 /* Convert a wide character to a multibyte character. */
1527 #if @GNULIB_WCTOMB@
1528 # if @REPLACE_WCTOMB@
1529 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1530 # undef wctomb
1531 # define wctomb rpl_wctomb
1532 # endif
1533 _GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc));
1534 _GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
1535 # else
1536 _GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
1537 # endif
1538 # if __GLIBC__ >= 2
1539 _GL_CXXALIASWARN (wctomb);
1540 # endif
1541 #endif
1542
1543
1544 #endif /* _@GUARD_PREFIX@_STDLIB_H */
1545 #endif /* _@GUARD_PREFIX@_STDLIB_H */
1546 #endif