Assume Autoconf >= 2.63.
[gnulib.git] / lib / stdlib.in.h
blob441c018ec18906488c0df224488f3a50727410b5
1 /* A GNU-like <stdlib.h>.
3 Copyright (C) 1995, 2001-2004, 2006-2018 Free Software Foundation, Inc.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 #if __GNUC__ >= 3
19 @PRAGMA_SYSTEM_HEADER@
20 #endif
21 @PRAGMA_COLUMNS@
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. */
27 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
29 #else
30 /* Normal invocation convention. */
32 #ifndef _@GUARD_PREFIX@_STDLIB_H
34 /* The include_next requires a split double-inclusion guard. */
35 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
37 #ifndef _@GUARD_PREFIX@_STDLIB_H
38 #define _@GUARD_PREFIX@_STDLIB_H
40 /* NetBSD 5.0 mis-defines NULL. */
41 #include <stddef.h>
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
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
56 /* Native Windows platforms declare mktemp() in <io.h>. */
57 #if 0 && (defined _WIN32 && ! defined __CYGWIN__)
58 # include <io.h>
59 #endif
61 #if @GNULIB_RANDOM_R@
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
70 # if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
71 # include <stdint.h>
72 # endif
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
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. */
88 # define GNULIB_defined_struct_random_data 1
89 # endif
90 # endif
91 #endif
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
102 /* The __attribute__ feature is available in gcc versions 2.5 and later.
103 The attribute __pure__ was added in gcc 2.96. */
104 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
105 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
106 #else
107 # define _GL_ATTRIBUTE_PURE /* empty */
108 #endif
110 /* The definition of _Noreturn is copied here. */
112 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
114 /* The definition of _GL_ARG_NONNULL is copied here. */
116 /* The definition of _GL_WARN_ON_USE is copied here. */
119 /* Some systems do not define EXIT_*, despite otherwise supporting C89. */
120 #ifndef EXIT_SUCCESS
121 # define EXIT_SUCCESS 0
122 #endif
123 /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
124 with proper operation of xargs. */
125 #ifndef EXIT_FAILURE
126 # define EXIT_FAILURE 1
127 #elif EXIT_FAILURE != 1
128 # undef EXIT_FAILURE
129 # define EXIT_FAILURE 1
130 #endif
133 #if @GNULIB__EXIT@
134 /* Terminate the current process with the given return code, without running
135 the 'atexit' handlers. */
136 # if !@HAVE__EXIT@
137 _GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status));
138 # endif
139 _GL_CXXALIAS_SYS (_Exit, void, (int status));
140 _GL_CXXALIASWARN (_Exit);
141 #elif defined GNULIB_POSIXCHECK
142 # undef _Exit
143 # if HAVE_RAW_DECL__EXIT
144 _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
145 "use gnulib module _Exit for portability");
146 # endif
147 #endif
150 #if @GNULIB_ATOLL@
151 /* Parse a signed decimal integer.
152 Returns the value of the integer. Errors are not detected. */
153 # if !@HAVE_ATOLL@
154 _GL_FUNCDECL_SYS (atoll, long long, (const char *string)
155 _GL_ATTRIBUTE_PURE
156 _GL_ARG_NONNULL ((1)));
157 # endif
158 _GL_CXXALIAS_SYS (atoll, long long, (const char *string));
159 _GL_CXXALIASWARN (atoll);
160 #elif defined GNULIB_POSIXCHECK
161 # undef atoll
162 # if HAVE_RAW_DECL_ATOLL
163 _GL_WARN_ON_USE (atoll, "atoll is unportable - "
164 "use gnulib module atoll for portability");
165 # endif
166 #endif
168 #if @GNULIB_CALLOC_POSIX@
169 # if @REPLACE_CALLOC@
170 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
171 # undef calloc
172 # define calloc rpl_calloc
173 # endif
174 _GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size));
175 _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
176 # else
177 _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
178 # endif
179 _GL_CXXALIASWARN (calloc);
180 #elif defined GNULIB_POSIXCHECK
181 # undef calloc
182 /* Assume calloc is always declared. */
183 _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
184 "use gnulib module calloc-posix for portability");
185 #endif
187 #if @GNULIB_CANONICALIZE_FILE_NAME@
188 # if @REPLACE_CANONICALIZE_FILE_NAME@
189 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
190 # define canonicalize_file_name rpl_canonicalize_file_name
191 # endif
192 _GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name)
193 _GL_ARG_NONNULL ((1)));
194 _GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
195 # else
196 # if !@HAVE_CANONICALIZE_FILE_NAME@
197 _GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name)
198 _GL_ARG_NONNULL ((1)));
199 # endif
200 _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
201 # endif
202 _GL_CXXALIASWARN (canonicalize_file_name);
203 #elif defined GNULIB_POSIXCHECK
204 # undef canonicalize_file_name
205 # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
206 _GL_WARN_ON_USE (canonicalize_file_name,
207 "canonicalize_file_name is unportable - "
208 "use gnulib module canonicalize-lgpl for portability");
209 # endif
210 #endif
212 #if @GNULIB_GETLOADAVG@
213 /* Store max(NELEM,3) load average numbers in LOADAVG[].
214 The three numbers are the load average of the last 1 minute, the last 5
215 minutes, and the last 15 minutes, respectively.
216 LOADAVG is an array of NELEM numbers. */
217 # if !@HAVE_DECL_GETLOADAVG@
218 _GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem)
219 _GL_ARG_NONNULL ((1)));
220 # endif
221 _GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
222 _GL_CXXALIASWARN (getloadavg);
223 #elif defined GNULIB_POSIXCHECK
224 # undef getloadavg
225 # if HAVE_RAW_DECL_GETLOADAVG
226 _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
227 "use gnulib module getloadavg for portability");
228 # endif
229 #endif
231 #if @GNULIB_GETSUBOPT@
232 /* Assuming *OPTIONP is a comma separated list of elements of the form
233 "token" or "token=value", getsubopt parses the first of these elements.
234 If the first element refers to a "token" that is member of the given
235 NULL-terminated array of tokens:
236 - It replaces the comma with a NUL byte, updates *OPTIONP to point past
237 the first option and the comma, sets *VALUEP to the value of the
238 element (or NULL if it doesn't contain an "=" sign),
239 - It returns the index of the "token" in the given array of tokens.
240 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
241 For more details see the POSIX:2001 specification.
242 http://www.opengroup.org/susv3xsh/getsubopt.html */
243 # if !@HAVE_GETSUBOPT@
244 _GL_FUNCDECL_SYS (getsubopt, int,
245 (char **optionp, char *const *tokens, char **valuep)
246 _GL_ARG_NONNULL ((1, 2, 3)));
247 # endif
248 _GL_CXXALIAS_SYS (getsubopt, int,
249 (char **optionp, char *const *tokens, char **valuep));
250 _GL_CXXALIASWARN (getsubopt);
251 #elif defined GNULIB_POSIXCHECK
252 # undef getsubopt
253 # if HAVE_RAW_DECL_GETSUBOPT
254 _GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
255 "use gnulib module getsubopt for portability");
256 # endif
257 #endif
259 #if @GNULIB_GRANTPT@
260 /* Change the ownership and access permission of the slave side of the
261 pseudo-terminal whose master side is specified by FD. */
262 # if !@HAVE_GRANTPT@
263 _GL_FUNCDECL_SYS (grantpt, int, (int fd));
264 # endif
265 _GL_CXXALIAS_SYS (grantpt, int, (int fd));
266 _GL_CXXALIASWARN (grantpt);
267 #elif defined GNULIB_POSIXCHECK
268 # undef grantpt
269 # if HAVE_RAW_DECL_GRANTPT
270 _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
271 "use gnulib module grantpt for portability");
272 # endif
273 #endif
275 /* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
276 rely on GNU or POSIX semantics for malloc and realloc (for example,
277 by never specifying a zero size), so it does not need malloc or
278 realloc to be redefined. */
279 #if @GNULIB_MALLOC_POSIX@
280 # if @REPLACE_MALLOC@
281 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
282 || _GL_USE_STDLIB_ALLOC)
283 # undef malloc
284 # define malloc rpl_malloc
285 # endif
286 _GL_FUNCDECL_RPL (malloc, void *, (size_t size));
287 _GL_CXXALIAS_RPL (malloc, void *, (size_t size));
288 # else
289 _GL_CXXALIAS_SYS (malloc, void *, (size_t size));
290 # endif
291 _GL_CXXALIASWARN (malloc);
292 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
293 # undef malloc
294 /* Assume malloc is always declared. */
295 _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
296 "use gnulib module malloc-posix for portability");
297 #endif
299 /* Convert a multibyte character to a wide character. */
300 #if @GNULIB_MBTOWC@
301 # if @REPLACE_MBTOWC@
302 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
303 # undef mbtowc
304 # define mbtowc rpl_mbtowc
305 # endif
306 _GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
307 _GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
308 # else
309 _GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
310 # endif
311 _GL_CXXALIASWARN (mbtowc);
312 #endif
314 #if @GNULIB_MKDTEMP@
315 /* Create a unique temporary directory from TEMPLATE.
316 The last six characters of TEMPLATE must be "XXXXXX";
317 they are replaced with a string that makes the directory name unique.
318 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
319 The directory is created mode 700. */
320 # if !@HAVE_MKDTEMP@
321 _GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
322 # endif
323 _GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
324 _GL_CXXALIASWARN (mkdtemp);
325 #elif defined GNULIB_POSIXCHECK
326 # undef mkdtemp
327 # if HAVE_RAW_DECL_MKDTEMP
328 _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
329 "use gnulib module mkdtemp for portability");
330 # endif
331 #endif
333 #if @GNULIB_MKOSTEMP@
334 /* Create a unique temporary file from TEMPLATE.
335 The last six characters of TEMPLATE must be "XXXXXX";
336 they are replaced with a string that makes the file name unique.
337 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
338 and O_TEXT, O_BINARY (defined in "binary-io.h").
339 The file is then created, with the specified flags, ensuring it didn't exist
340 before.
341 The file is created read-write (mask at least 0600 & ~umask), but it may be
342 world-readable and world-writable (mask 0666 & ~umask), depending on the
343 implementation.
344 Returns the open file descriptor if successful, otherwise -1 and errno
345 set. */
346 # if !@HAVE_MKOSTEMP@
347 _GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)
348 _GL_ARG_NONNULL ((1)));
349 # endif
350 _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
351 _GL_CXXALIASWARN (mkostemp);
352 #elif defined GNULIB_POSIXCHECK
353 # undef mkostemp
354 # if HAVE_RAW_DECL_MKOSTEMP
355 _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
356 "use gnulib module mkostemp for portability");
357 # endif
358 #endif
360 #if @GNULIB_MKOSTEMPS@
361 /* Create a unique temporary file from TEMPLATE.
362 The last six characters of TEMPLATE before a suffix of length
363 SUFFIXLEN must be "XXXXXX";
364 they are replaced with a string that makes the file name unique.
365 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
366 and O_TEXT, O_BINARY (defined in "binary-io.h").
367 The file is then created, with the specified flags, ensuring it didn't exist
368 before.
369 The file is created read-write (mask at least 0600 & ~umask), but it may be
370 world-readable and world-writable (mask 0666 & ~umask), depending on the
371 implementation.
372 Returns the open file descriptor if successful, otherwise -1 and errno
373 set. */
374 # if !@HAVE_MKOSTEMPS@
375 _GL_FUNCDECL_SYS (mkostemps, int,
376 (char * /*template*/, int /*suffixlen*/, int /*flags*/)
377 _GL_ARG_NONNULL ((1)));
378 # endif
379 _GL_CXXALIAS_SYS (mkostemps, int,
380 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
381 _GL_CXXALIASWARN (mkostemps);
382 #elif defined GNULIB_POSIXCHECK
383 # undef mkostemps
384 # if HAVE_RAW_DECL_MKOSTEMPS
385 _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
386 "use gnulib module mkostemps for portability");
387 # endif
388 #endif
390 #if @GNULIB_MKSTEMP@
391 /* Create a unique temporary file from TEMPLATE.
392 The last six characters of TEMPLATE must be "XXXXXX";
393 they are replaced with a string that makes the file name unique.
394 The file is then created, ensuring it didn't exist before.
395 The file is created read-write (mask at least 0600 & ~umask), but it may be
396 world-readable and world-writable (mask 0666 & ~umask), depending on the
397 implementation.
398 Returns the open file descriptor if successful, otherwise -1 and errno
399 set. */
400 # if @REPLACE_MKSTEMP@
401 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
402 # define mkstemp rpl_mkstemp
403 # endif
404 _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
405 _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
406 # else
407 # if ! @HAVE_MKSTEMP@
408 _GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
409 # endif
410 _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
411 # endif
412 _GL_CXXALIASWARN (mkstemp);
413 #elif defined GNULIB_POSIXCHECK
414 # undef mkstemp
415 # if HAVE_RAW_DECL_MKSTEMP
416 _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
417 "use gnulib module mkstemp for portability");
418 # endif
419 #endif
421 #if @GNULIB_MKSTEMPS@
422 /* Create a unique temporary file from TEMPLATE.
423 The last six characters of TEMPLATE prior to a suffix of length
424 SUFFIXLEN must be "XXXXXX";
425 they are replaced with a string that makes the file name unique.
426 The file is then created, ensuring it didn't exist before.
427 The file is created read-write (mask at least 0600 & ~umask), but it may be
428 world-readable and world-writable (mask 0666 & ~umask), depending on the
429 implementation.
430 Returns the open file descriptor if successful, otherwise -1 and errno
431 set. */
432 # if !@HAVE_MKSTEMPS@
433 _GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)
434 _GL_ARG_NONNULL ((1)));
435 # endif
436 _GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
437 _GL_CXXALIASWARN (mkstemps);
438 #elif defined GNULIB_POSIXCHECK
439 # undef mkstemps
440 # if HAVE_RAW_DECL_MKSTEMPS
441 _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
442 "use gnulib module mkstemps for portability");
443 # endif
444 #endif
446 #if @GNULIB_POSIX_OPENPT@
447 /* Return an FD open to the master side of a pseudo-terminal. Flags should
448 include O_RDWR, and may also include O_NOCTTY. */
449 # if !@HAVE_POSIX_OPENPT@
450 _GL_FUNCDECL_SYS (posix_openpt, int, (int flags));
451 # endif
452 _GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
453 _GL_CXXALIASWARN (posix_openpt);
454 #elif defined GNULIB_POSIXCHECK
455 # undef posix_openpt
456 # if HAVE_RAW_DECL_POSIX_OPENPT
457 _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
458 "use gnulib module posix_openpt for portability");
459 # endif
460 #endif
462 #if @GNULIB_PTSNAME@
463 /* Return the pathname of the pseudo-terminal slave associated with
464 the master FD is open on, or NULL on errors. */
465 # if @REPLACE_PTSNAME@
466 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
467 # undef ptsname
468 # define ptsname rpl_ptsname
469 # endif
470 _GL_FUNCDECL_RPL (ptsname, char *, (int fd));
471 _GL_CXXALIAS_RPL (ptsname, char *, (int fd));
472 # else
473 # if !@HAVE_PTSNAME@
474 _GL_FUNCDECL_SYS (ptsname, char *, (int fd));
475 # endif
476 _GL_CXXALIAS_SYS (ptsname, char *, (int fd));
477 # endif
478 _GL_CXXALIASWARN (ptsname);
479 #elif defined GNULIB_POSIXCHECK
480 # undef ptsname
481 # if HAVE_RAW_DECL_PTSNAME
482 _GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
483 "use gnulib module ptsname for portability");
484 # endif
485 #endif
487 #if @GNULIB_PTSNAME_R@
488 /* Set the pathname of the pseudo-terminal slave associated with
489 the master FD is open on and return 0, or set errno and return
490 non-zero on errors. */
491 # if @REPLACE_PTSNAME_R@
492 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
493 # undef ptsname_r
494 # define ptsname_r rpl_ptsname_r
495 # endif
496 _GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
497 _GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
498 # else
499 # if !@HAVE_PTSNAME_R@
500 _GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
501 # endif
502 _GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
503 # endif
504 _GL_CXXALIASWARN (ptsname_r);
505 #elif defined GNULIB_POSIXCHECK
506 # undef ptsname_r
507 # if HAVE_RAW_DECL_PTSNAME_R
508 _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
509 "use gnulib module ptsname_r for portability");
510 # endif
511 #endif
513 #if @GNULIB_PUTENV@
514 # if @REPLACE_PUTENV@
515 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
516 # undef putenv
517 # define putenv rpl_putenv
518 # endif
519 _GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
520 _GL_CXXALIAS_RPL (putenv, int, (char *string));
521 # else
522 _GL_CXXALIAS_SYS (putenv, int, (char *string));
523 # endif
524 _GL_CXXALIASWARN (putenv);
525 #endif
527 #if @GNULIB_QSORT_R@
528 /* Sort an array of NMEMB elements, starting at address BASE, each element
529 occupying SIZE bytes, in ascending order according to the comparison
530 function COMPARE. */
531 # if @REPLACE_QSORT_R@
532 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
533 # undef qsort_r
534 # define qsort_r rpl_qsort_r
535 # endif
536 _GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
537 int (*compare) (void const *, void const *,
538 void *),
539 void *arg) _GL_ARG_NONNULL ((1, 4)));
540 _GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
541 int (*compare) (void const *, void const *,
542 void *),
543 void *arg));
544 # else
545 # if !@HAVE_QSORT_R@
546 _GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
547 int (*compare) (void const *, void const *,
548 void *),
549 void *arg) _GL_ARG_NONNULL ((1, 4)));
550 # endif
551 _GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
552 int (*compare) (void const *, void const *,
553 void *),
554 void *arg));
555 # endif
556 _GL_CXXALIASWARN (qsort_r);
557 #elif defined GNULIB_POSIXCHECK
558 # undef qsort_r
559 # if HAVE_RAW_DECL_QSORT_R
560 _GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
561 "use gnulib module qsort_r for portability");
562 # endif
563 #endif
566 #if @GNULIB_RANDOM_R@
567 # if !@HAVE_RANDOM_R@
568 # ifndef RAND_MAX
569 # define RAND_MAX 2147483647
570 # endif
571 # endif
572 #endif
575 #if @GNULIB_RANDOM@
576 # if !@HAVE_RANDOM@
577 _GL_FUNCDECL_SYS (random, long, (void));
578 # endif
579 _GL_CXXALIAS_SYS (random, long, (void));
580 _GL_CXXALIASWARN (random);
581 #elif defined GNULIB_POSIXCHECK
582 # undef random
583 # if HAVE_RAW_DECL_RANDOM
584 _GL_WARN_ON_USE (random, "random is unportable - "
585 "use gnulib module random for portability");
586 # endif
587 #endif
589 #if @GNULIB_RANDOM@
590 # if !@HAVE_RANDOM@
591 _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
592 # endif
593 _GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
594 _GL_CXXALIASWARN (srandom);
595 #elif defined GNULIB_POSIXCHECK
596 # undef srandom
597 # if HAVE_RAW_DECL_SRANDOM
598 _GL_WARN_ON_USE (srandom, "srandom is unportable - "
599 "use gnulib module random for portability");
600 # endif
601 #endif
603 #if @GNULIB_RANDOM@
604 # if !@HAVE_RANDOM@ || !@HAVE_DECL_INITSTATE@
605 _GL_FUNCDECL_SYS (initstate, char *,
606 (unsigned int seed, char *buf, size_t buf_size)
607 _GL_ARG_NONNULL ((2)));
608 # endif
609 _GL_CXXALIAS_SYS (initstate, char *,
610 (unsigned int seed, char *buf, size_t buf_size));
611 _GL_CXXALIASWARN (initstate);
612 #elif defined GNULIB_POSIXCHECK
613 # undef initstate
614 # if HAVE_RAW_DECL_INITSTATE_R
615 _GL_WARN_ON_USE (initstate, "initstate is unportable - "
616 "use gnulib module random for portability");
617 # endif
618 #endif
620 #if @GNULIB_RANDOM@
621 # if !@HAVE_RANDOM@ || !@HAVE_DECL_SETSTATE@
622 _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
623 # endif
624 _GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
625 _GL_CXXALIASWARN (setstate);
626 #elif defined GNULIB_POSIXCHECK
627 # undef setstate
628 # if HAVE_RAW_DECL_SETSTATE_R
629 _GL_WARN_ON_USE (setstate, "setstate is unportable - "
630 "use gnulib module random for portability");
631 # endif
632 #endif
635 #if @GNULIB_RANDOM_R@
636 # if @REPLACE_RANDOM_R@
637 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
638 # undef random_r
639 # define random_r rpl_random_r
640 # endif
641 _GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
642 _GL_ARG_NONNULL ((1, 2)));
643 _GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
644 # else
645 # if !@HAVE_RANDOM_R@
646 _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
647 _GL_ARG_NONNULL ((1, 2)));
648 # endif
649 _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
650 # endif
651 _GL_CXXALIASWARN (random_r);
652 #elif defined GNULIB_POSIXCHECK
653 # undef random_r
654 # if HAVE_RAW_DECL_RANDOM_R
655 _GL_WARN_ON_USE (random_r, "random_r is unportable - "
656 "use gnulib module random_r for portability");
657 # endif
658 #endif
660 #if @GNULIB_RANDOM_R@
661 # if @REPLACE_RANDOM_R@
662 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
663 # undef srandom_r
664 # define srandom_r rpl_srandom_r
665 # endif
666 _GL_FUNCDECL_RPL (srandom_r, int,
667 (unsigned int seed, struct random_data *rand_state)
668 _GL_ARG_NONNULL ((2)));
669 _GL_CXXALIAS_RPL (srandom_r, int,
670 (unsigned int seed, struct random_data *rand_state));
671 # else
672 # if !@HAVE_RANDOM_R@
673 _GL_FUNCDECL_SYS (srandom_r, int,
674 (unsigned int seed, struct random_data *rand_state)
675 _GL_ARG_NONNULL ((2)));
676 # endif
677 _GL_CXXALIAS_SYS (srandom_r, int,
678 (unsigned int seed, struct random_data *rand_state));
679 # endif
680 _GL_CXXALIASWARN (srandom_r);
681 #elif defined GNULIB_POSIXCHECK
682 # undef srandom_r
683 # if HAVE_RAW_DECL_SRANDOM_R
684 _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
685 "use gnulib module random_r for portability");
686 # endif
687 #endif
689 #if @GNULIB_RANDOM_R@
690 # if @REPLACE_RANDOM_R@
691 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
692 # undef initstate_r
693 # define initstate_r rpl_initstate_r
694 # endif
695 _GL_FUNCDECL_RPL (initstate_r, int,
696 (unsigned int seed, char *buf, size_t buf_size,
697 struct random_data *rand_state)
698 _GL_ARG_NONNULL ((2, 4)));
699 _GL_CXXALIAS_RPL (initstate_r, int,
700 (unsigned int seed, char *buf, size_t buf_size,
701 struct random_data *rand_state));
702 # else
703 # if !@HAVE_RANDOM_R@
704 _GL_FUNCDECL_SYS (initstate_r, int,
705 (unsigned int seed, char *buf, size_t buf_size,
706 struct random_data *rand_state)
707 _GL_ARG_NONNULL ((2, 4)));
708 # endif
709 _GL_CXXALIAS_SYS (initstate_r, int,
710 (unsigned int seed, char *buf, size_t buf_size,
711 struct random_data *rand_state));
712 # endif
713 _GL_CXXALIASWARN (initstate_r);
714 #elif defined GNULIB_POSIXCHECK
715 # undef initstate_r
716 # if HAVE_RAW_DECL_INITSTATE_R
717 _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
718 "use gnulib module random_r for portability");
719 # endif
720 #endif
722 #if @GNULIB_RANDOM_R@
723 # if @REPLACE_RANDOM_R@
724 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
725 # undef setstate_r
726 # define setstate_r rpl_setstate_r
727 # endif
728 _GL_FUNCDECL_RPL (setstate_r, int,
729 (char *arg_state, struct random_data *rand_state)
730 _GL_ARG_NONNULL ((1, 2)));
731 _GL_CXXALIAS_RPL (setstate_r, int,
732 (char *arg_state, struct random_data *rand_state));
733 # else
734 # if !@HAVE_RANDOM_R@
735 _GL_FUNCDECL_SYS (setstate_r, int,
736 (char *arg_state, struct random_data *rand_state)
737 _GL_ARG_NONNULL ((1, 2)));
738 # endif
739 _GL_CXXALIAS_SYS (setstate_r, int,
740 (char *arg_state, struct random_data *rand_state));
741 # endif
742 _GL_CXXALIASWARN (setstate_r);
743 #elif defined GNULIB_POSIXCHECK
744 # undef setstate_r
745 # if HAVE_RAW_DECL_SETSTATE_R
746 _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
747 "use gnulib module random_r for portability");
748 # endif
749 #endif
752 #if @GNULIB_REALLOC_POSIX@
753 # if @REPLACE_REALLOC@
754 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
755 || _GL_USE_STDLIB_ALLOC)
756 # undef realloc
757 # define realloc rpl_realloc
758 # endif
759 _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size));
760 _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
761 # else
762 _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
763 # endif
764 _GL_CXXALIASWARN (realloc);
765 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
766 # undef realloc
767 /* Assume realloc is always declared. */
768 _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
769 "use gnulib module realloc-posix for portability");
770 #endif
773 #if @GNULIB_REALLOCARRAY@
774 # if ! @HAVE_REALLOCARRAY@
775 _GL_FUNCDECL_SYS (reallocarray, void *,
776 (void *ptr, size_t nmemb, size_t size));
777 # endif
778 _GL_CXXALIAS_SYS (reallocarray, void *,
779 (void *ptr, size_t nmemb, size_t size));
780 _GL_CXXALIASWARN (reallocarray);
781 #elif defined GNULIB_POSIXCHECK
782 # undef reallocarray
783 # if HAVE_RAW_DECL_REALLOCARRAY
784 _GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - "
785 "use gnulib module reallocarray for portability");
786 # endif
787 #endif
789 #if @GNULIB_REALPATH@
790 # if @REPLACE_REALPATH@
791 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
792 # define realpath rpl_realpath
793 # endif
794 _GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved)
795 _GL_ARG_NONNULL ((1)));
796 _GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved));
797 # else
798 # if !@HAVE_REALPATH@
799 _GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved)
800 _GL_ARG_NONNULL ((1)));
801 # endif
802 _GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved));
803 # endif
804 _GL_CXXALIASWARN (realpath);
805 #elif defined GNULIB_POSIXCHECK
806 # undef realpath
807 # if HAVE_RAW_DECL_REALPATH
808 _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
809 "canonicalize or canonicalize-lgpl for portability");
810 # endif
811 #endif
813 #if @GNULIB_RPMATCH@
814 /* Test a user response to a question.
815 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
816 # if !@HAVE_RPMATCH@
817 _GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1)));
818 # endif
819 _GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
820 _GL_CXXALIASWARN (rpmatch);
821 #elif defined GNULIB_POSIXCHECK
822 # undef rpmatch
823 # if HAVE_RAW_DECL_RPMATCH
824 _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
825 "use gnulib module rpmatch for portability");
826 # endif
827 #endif
829 #if @GNULIB_SECURE_GETENV@
830 /* Look up NAME in the environment, returning 0 in insecure situations. */
831 # if !@HAVE_SECURE_GETENV@
832 _GL_FUNCDECL_SYS (secure_getenv, char *,
833 (char const *name) _GL_ARG_NONNULL ((1)));
834 # endif
835 _GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
836 _GL_CXXALIASWARN (secure_getenv);
837 #elif defined GNULIB_POSIXCHECK
838 # undef secure_getenv
839 # if HAVE_RAW_DECL_SECURE_GETENV
840 _GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
841 "use gnulib module secure_getenv for portability");
842 # endif
843 #endif
845 #if @GNULIB_SETENV@
846 /* Set NAME to VALUE in the environment.
847 If REPLACE is nonzero, overwrite an existing value. */
848 # if @REPLACE_SETENV@
849 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
850 # undef setenv
851 # define setenv rpl_setenv
852 # endif
853 _GL_FUNCDECL_RPL (setenv, int,
854 (const char *name, const char *value, int replace)
855 _GL_ARG_NONNULL ((1)));
856 _GL_CXXALIAS_RPL (setenv, int,
857 (const char *name, const char *value, int replace));
858 # else
859 # if !@HAVE_DECL_SETENV@
860 _GL_FUNCDECL_SYS (setenv, int,
861 (const char *name, const char *value, int replace)
862 _GL_ARG_NONNULL ((1)));
863 # endif
864 _GL_CXXALIAS_SYS (setenv, int,
865 (const char *name, const char *value, int replace));
866 # endif
867 # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
868 _GL_CXXALIASWARN (setenv);
869 # endif
870 #elif defined GNULIB_POSIXCHECK
871 # undef setenv
872 # if HAVE_RAW_DECL_SETENV
873 _GL_WARN_ON_USE (setenv, "setenv is unportable - "
874 "use gnulib module setenv for portability");
875 # endif
876 #endif
878 #if @GNULIB_STRTOD@
879 /* Parse a double from STRING, updating ENDP if appropriate. */
880 # if @REPLACE_STRTOD@
881 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
882 # define strtod rpl_strtod
883 # endif
884 _GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp)
885 _GL_ARG_NONNULL ((1)));
886 _GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp));
887 # else
888 # if !@HAVE_STRTOD@
889 _GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp)
890 _GL_ARG_NONNULL ((1)));
891 # endif
892 _GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp));
893 # endif
894 _GL_CXXALIASWARN (strtod);
895 #elif defined GNULIB_POSIXCHECK
896 # undef strtod
897 # if HAVE_RAW_DECL_STRTOD
898 _GL_WARN_ON_USE (strtod, "strtod is unportable - "
899 "use gnulib module strtod for portability");
900 # endif
901 #endif
903 #if @GNULIB_STRTOLL@
904 /* Parse a signed integer whose textual representation starts at STRING.
905 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
906 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
907 "0x").
908 If ENDPTR is not NULL, the address of the first byte after the integer is
909 stored in *ENDPTR.
910 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
911 to ERANGE. */
912 # if !@HAVE_STRTOLL@
913 _GL_FUNCDECL_SYS (strtoll, long long,
914 (const char *string, char **endptr, int base)
915 _GL_ARG_NONNULL ((1)));
916 # endif
917 _GL_CXXALIAS_SYS (strtoll, long long,
918 (const char *string, char **endptr, int base));
919 _GL_CXXALIASWARN (strtoll);
920 #elif defined GNULIB_POSIXCHECK
921 # undef strtoll
922 # if HAVE_RAW_DECL_STRTOLL
923 _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
924 "use gnulib module strtoll for portability");
925 # endif
926 #endif
928 #if @GNULIB_STRTOULL@
929 /* Parse an unsigned integer whose textual representation starts at STRING.
930 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
931 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
932 "0x").
933 If ENDPTR is not NULL, the address of the first byte after the integer is
934 stored in *ENDPTR.
935 Upon overflow, the return value is ULLONG_MAX, and errno is set to
936 ERANGE. */
937 # if !@HAVE_STRTOULL@
938 _GL_FUNCDECL_SYS (strtoull, unsigned long long,
939 (const char *string, char **endptr, int base)
940 _GL_ARG_NONNULL ((1)));
941 # endif
942 _GL_CXXALIAS_SYS (strtoull, unsigned long long,
943 (const char *string, char **endptr, int base));
944 _GL_CXXALIASWARN (strtoull);
945 #elif defined GNULIB_POSIXCHECK
946 # undef strtoull
947 # if HAVE_RAW_DECL_STRTOULL
948 _GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
949 "use gnulib module strtoull for portability");
950 # endif
951 #endif
953 #if @GNULIB_UNLOCKPT@
954 /* Unlock the slave side of the pseudo-terminal whose master side is specified
955 by FD, so that it can be opened. */
956 # if !@HAVE_UNLOCKPT@
957 _GL_FUNCDECL_SYS (unlockpt, int, (int fd));
958 # endif
959 _GL_CXXALIAS_SYS (unlockpt, int, (int fd));
960 _GL_CXXALIASWARN (unlockpt);
961 #elif defined GNULIB_POSIXCHECK
962 # undef unlockpt
963 # if HAVE_RAW_DECL_UNLOCKPT
964 _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
965 "use gnulib module unlockpt for portability");
966 # endif
967 #endif
969 #if @GNULIB_UNSETENV@
970 /* Remove the variable NAME from the environment. */
971 # if @REPLACE_UNSETENV@
972 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
973 # undef unsetenv
974 # define unsetenv rpl_unsetenv
975 # endif
976 _GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
977 _GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
978 # else
979 # if !@HAVE_DECL_UNSETENV@
980 _GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
981 # endif
982 _GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
983 # endif
984 # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
985 _GL_CXXALIASWARN (unsetenv);
986 # endif
987 #elif defined GNULIB_POSIXCHECK
988 # undef unsetenv
989 # if HAVE_RAW_DECL_UNSETENV
990 _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
991 "use gnulib module unsetenv for portability");
992 # endif
993 #endif
995 /* Convert a wide character to a multibyte character. */
996 #if @GNULIB_WCTOMB@
997 # if @REPLACE_WCTOMB@
998 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
999 # undef wctomb
1000 # define wctomb rpl_wctomb
1001 # endif
1002 _GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc));
1003 _GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
1004 # else
1005 _GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
1006 # endif
1007 _GL_CXXALIASWARN (wctomb);
1008 #endif
1011 #endif /* _@GUARD_PREFIX@_STDLIB_H */
1012 #endif /* _@GUARD_PREFIX@_STDLIB_H */
1013 #endif