1 /* A GNU-like <stdlib.h>.
3 Copyright (C) 1995, 2001-2004, 2006-2012 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 <http://www.gnu.org/licenses/>. */
19 @PRAGMA_SYSTEM_HEADER@
23 #if defined __need_malloc_and_calloc
24 /* Special invocation convention inside glibc header files. */
26 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
29 /* Normal invocation convention. */
31 #ifndef _@GUARD_PREFIX@_STDLIB_H
33 /* The include_next requires a split double-inclusion guard. */
34 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
36 #ifndef _@GUARD_PREFIX@_STDLIB_H
37 #define _@GUARD_PREFIX@_STDLIB_H
39 /* NetBSD 5.0 mis-defines NULL. */
42 /* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */
43 #if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS
44 # include <sys/wait.h>
47 /* Solaris declares getloadavg() in <sys/loadavg.h>. */
48 #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
49 # include <sys/loadavg.h>
52 /* Native Windows platforms declare mktemp() in <io.h>. */
53 #if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
59 /* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
60 from <stdlib.h> if _REENTRANT is defined. Include it whenever we need
61 'struct random_data'. */
66 # if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
70 # if !@HAVE_STRUCT_RANDOM_DATA@
71 /* Define 'struct random_data'.
72 But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
73 # if !GNULIB_defined_struct_random_data
76 int32_t *fptr; /* Front pointer. */
77 int32_t *rptr; /* Rear pointer. */
78 int32_t *state; /* Array of state values. */
79 int rand_type; /* Type of random number generator. */
80 int rand_deg; /* Degree of random number generator. */
81 int rand_sep; /* Distance between front and rear. */
82 int32_t *end_ptr; /* Pointer behind state table. */
84 # define GNULIB_defined_struct_random_data 1
89 #if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
90 /* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
91 /* On MacOS X 10.5, only <unistd.h> declares mkstemps. */
92 /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
93 /* But avoid namespace pollution on glibc systems and native Windows. */
97 /* The definition of _Noreturn is copied here. */
99 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
101 /* The definition of _GL_ARG_NONNULL is copied here. */
103 /* The definition of _GL_WARN_ON_USE is copied here. */
106 /* Some systems do not define EXIT_*, despite otherwise supporting C89. */
108 # define EXIT_SUCCESS 0
110 /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
111 with proper operation of xargs. */
113 # define EXIT_FAILURE 1
114 #elif EXIT_FAILURE != 1
116 # define EXIT_FAILURE 1
121 /* Terminate the current process with the given return code, without running
122 the 'atexit' handlers. */
124 _GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status));
126 _GL_CXXALIAS_SYS (_Exit, void, (int status));
127 _GL_CXXALIASWARN (_Exit);
128 #elif defined GNULIB_POSIXCHECK
130 # if HAVE_RAW_DECL__EXIT
131 _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
132 "use gnulib module _Exit for portability");
138 /* Parse a signed decimal integer.
139 Returns the value of the integer. Errors are not detected. */
141 _GL_FUNCDECL_SYS (atoll, long long, (const char *string) _GL_ARG_NONNULL ((1)));
143 _GL_CXXALIAS_SYS (atoll, long long, (const char *string));
144 _GL_CXXALIASWARN (atoll);
145 #elif defined GNULIB_POSIXCHECK
147 # if HAVE_RAW_DECL_ATOLL
148 _GL_WARN_ON_USE (atoll, "atoll is unportable - "
149 "use gnulib module atoll for portability");
153 #if @GNULIB_CALLOC_POSIX@
154 # if @REPLACE_CALLOC@
155 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
157 # define calloc rpl_calloc
159 _GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size));
160 _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
162 _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
164 _GL_CXXALIASWARN (calloc);
165 #elif defined GNULIB_POSIXCHECK
167 /* Assume calloc is always declared. */
168 _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
169 "use gnulib module calloc-posix for portability");
172 #if @GNULIB_CANONICALIZE_FILE_NAME@
173 # if @REPLACE_CANONICALIZE_FILE_NAME@
174 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
175 # define canonicalize_file_name rpl_canonicalize_file_name
177 _GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name)
178 _GL_ARG_NONNULL ((1)));
179 _GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
181 # if !@HAVE_CANONICALIZE_FILE_NAME@
182 _GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name)
183 _GL_ARG_NONNULL ((1)));
185 _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
187 _GL_CXXALIASWARN (canonicalize_file_name);
188 #elif defined GNULIB_POSIXCHECK
189 # undef canonicalize_file_name
190 # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
191 _GL_WARN_ON_USE (canonicalize_file_name,
192 "canonicalize_file_name is unportable - "
193 "use gnulib module canonicalize-lgpl for portability");
197 #if @GNULIB_GETLOADAVG@
198 /* Store max(NELEM,3) load average numbers in LOADAVG[].
199 The three numbers are the load average of the last 1 minute, the last 5
200 minutes, and the last 15 minutes, respectively.
201 LOADAVG is an array of NELEM numbers. */
202 # if !@HAVE_DECL_GETLOADAVG@
203 _GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem)
204 _GL_ARG_NONNULL ((1)));
206 _GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
207 _GL_CXXALIASWARN (getloadavg);
208 #elif defined GNULIB_POSIXCHECK
210 # if HAVE_RAW_DECL_GETLOADAVG
211 _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
212 "use gnulib module getloadavg for portability");
216 #if @GNULIB_GETSUBOPT@
217 /* Assuming *OPTIONP is a comma separated list of elements of the form
218 "token" or "token=value", getsubopt parses the first of these elements.
219 If the first element refers to a "token" that is member of the given
220 NULL-terminated array of tokens:
221 - It replaces the comma with a NUL byte, updates *OPTIONP to point past
222 the first option and the comma, sets *VALUEP to the value of the
223 element (or NULL if it doesn't contain an "=" sign),
224 - It returns the index of the "token" in the given array of tokens.
225 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
226 For more details see the POSIX:2001 specification.
227 http://www.opengroup.org/susv3xsh/getsubopt.html */
228 # if !@HAVE_GETSUBOPT@
229 _GL_FUNCDECL_SYS (getsubopt, int,
230 (char **optionp, char *const *tokens, char **valuep)
231 _GL_ARG_NONNULL ((1, 2, 3)));
233 _GL_CXXALIAS_SYS (getsubopt, int,
234 (char **optionp, char *const *tokens, char **valuep));
235 _GL_CXXALIASWARN (getsubopt);
236 #elif defined GNULIB_POSIXCHECK
238 # if HAVE_RAW_DECL_GETSUBOPT
239 _GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
240 "use gnulib module getsubopt for portability");
245 /* Change the ownership and access permission of the slave side of the
246 pseudo-terminal whose master side is specified by FD. */
248 _GL_FUNCDECL_SYS (grantpt, int, (int fd));
250 _GL_CXXALIAS_SYS (grantpt, int, (int fd));
251 _GL_CXXALIASWARN (grantpt);
252 #elif defined GNULIB_POSIXCHECK
254 # if HAVE_RAW_DECL_GRANTPT
255 _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
256 "use gnulib module grantpt for portability");
260 /* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
261 rely on GNU or POSIX semantics for malloc and realloc (for example,
262 by never specifying a zero size), so it does not need malloc or
263 realloc to be redefined. */
264 #if @GNULIB_MALLOC_POSIX@
265 # if @REPLACE_MALLOC@
266 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
267 || _GL_USE_STDLIB_ALLOC)
269 # define malloc rpl_malloc
271 _GL_FUNCDECL_RPL (malloc, void *, (size_t size));
272 _GL_CXXALIAS_RPL (malloc, void *, (size_t size));
274 _GL_CXXALIAS_SYS (malloc, void *, (size_t size));
276 _GL_CXXALIASWARN (malloc);
277 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
279 /* Assume malloc is always declared. */
280 _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
281 "use gnulib module malloc-posix for portability");
284 /* Convert a multibyte character to a wide character. */
286 # if @REPLACE_MBTOWC@
287 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
289 # define mbtowc rpl_mbtowc
291 _GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
292 _GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
294 _GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
296 _GL_CXXALIASWARN (mbtowc);
300 /* Create a unique temporary directory from TEMPLATE.
301 The last six characters of TEMPLATE must be "XXXXXX";
302 they are replaced with a string that makes the directory name unique.
303 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
304 The directory is created mode 700. */
306 _GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
308 _GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
309 _GL_CXXALIASWARN (mkdtemp);
310 #elif defined GNULIB_POSIXCHECK
312 # if HAVE_RAW_DECL_MKDTEMP
313 _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
314 "use gnulib module mkdtemp for portability");
318 #if @GNULIB_MKOSTEMP@
319 /* Create a unique temporary file from TEMPLATE.
320 The last six characters of TEMPLATE must be "XXXXXX";
321 they are replaced with a string that makes the file name unique.
322 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
323 and O_TEXT, O_BINARY (defined in "binary-io.h").
324 The file is then created, with the specified flags, ensuring it didn't exist
326 The file is created read-write (mask at least 0600 & ~umask), but it may be
327 world-readable and world-writable (mask 0666 & ~umask), depending on the
329 Returns the open file descriptor if successful, otherwise -1 and errno
331 # if !@HAVE_MKOSTEMP@
332 _GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)
333 _GL_ARG_NONNULL ((1)));
335 _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
336 _GL_CXXALIASWARN (mkostemp);
337 #elif defined GNULIB_POSIXCHECK
339 # if HAVE_RAW_DECL_MKOSTEMP
340 _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
341 "use gnulib module mkostemp for portability");
345 #if @GNULIB_MKOSTEMPS@
346 /* Create a unique temporary file from TEMPLATE.
347 The last six characters of TEMPLATE before a suffix of length
348 SUFFIXLEN must be "XXXXXX";
349 they are replaced with a string that makes the file name unique.
350 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
351 and O_TEXT, O_BINARY (defined in "binary-io.h").
352 The file is then created, with the specified flags, ensuring it didn't exist
354 The file is created read-write (mask at least 0600 & ~umask), but it may be
355 world-readable and world-writable (mask 0666 & ~umask), depending on the
357 Returns the open file descriptor if successful, otherwise -1 and errno
359 # if !@HAVE_MKOSTEMPS@
360 _GL_FUNCDECL_SYS (mkostemps, int,
361 (char * /*template*/, int /*suffixlen*/, int /*flags*/)
362 _GL_ARG_NONNULL ((1)));
364 _GL_CXXALIAS_SYS (mkostemps, int,
365 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
366 _GL_CXXALIASWARN (mkostemps);
367 #elif defined GNULIB_POSIXCHECK
369 # if HAVE_RAW_DECL_MKOSTEMPS
370 _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
371 "use gnulib module mkostemps for portability");
376 /* Create a unique temporary file from TEMPLATE.
377 The last six characters of TEMPLATE must be "XXXXXX";
378 they are replaced with a string that makes the file name unique.
379 The file is then created, ensuring it didn't exist before.
380 The file is created read-write (mask at least 0600 & ~umask), but it may be
381 world-readable and world-writable (mask 0666 & ~umask), depending on the
383 Returns the open file descriptor if successful, otherwise -1 and errno
385 # if @REPLACE_MKSTEMP@
386 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
387 # define mkstemp rpl_mkstemp
389 _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
390 _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
392 # if ! @HAVE_MKSTEMP@
393 _GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
395 _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
397 _GL_CXXALIASWARN (mkstemp);
398 #elif defined GNULIB_POSIXCHECK
400 # if HAVE_RAW_DECL_MKSTEMP
401 _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
402 "use gnulib module mkstemp for portability");
406 #if @GNULIB_MKSTEMPS@
407 /* Create a unique temporary file from TEMPLATE.
408 The last six characters of TEMPLATE prior to a suffix of length
409 SUFFIXLEN must be "XXXXXX";
410 they are replaced with a string that makes the file name unique.
411 The file is then created, ensuring it didn't exist before.
412 The file is created read-write (mask at least 0600 & ~umask), but it may be
413 world-readable and world-writable (mask 0666 & ~umask), depending on the
415 Returns the open file descriptor if successful, otherwise -1 and errno
417 # if !@HAVE_MKSTEMPS@
418 _GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)
419 _GL_ARG_NONNULL ((1)));
421 _GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
422 _GL_CXXALIASWARN (mkstemps);
423 #elif defined GNULIB_POSIXCHECK
425 # if HAVE_RAW_DECL_MKSTEMPS
426 _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
427 "use gnulib module mkstemps for portability");
431 #if @GNULIB_POSIX_OPENPT@
432 /* Return an FD open to the master side of a pseudo-terminal. Flags should
433 include O_RDWR, and may also include O_NOCTTY. */
434 # if !@HAVE_POSIX_OPENPT@
435 _GL_FUNCDECL_SYS (posix_openpt, int, (int flags));
437 _GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
438 _GL_CXXALIASWARN (posix_openpt);
439 #elif defined GNULIB_POSIXCHECK
441 # if HAVE_RAW_DECL_POSIX_OPENPT
442 _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
443 "use gnulib module posix_openpt for portability");
448 /* Return the pathname of the pseudo-terminal slave associated with
449 the master FD is open on, or NULL on errors. */
451 _GL_FUNCDECL_SYS (ptsname, char *, (int fd));
453 _GL_CXXALIAS_SYS (ptsname, char *, (int fd));
454 _GL_CXXALIASWARN (ptsname);
455 #elif defined GNULIB_POSIXCHECK
457 # if HAVE_RAW_DECL_PTSNAME
458 _GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
459 "use gnulib module ptsname for portability");
463 #if @GNULIB_PTSNAME_R@
464 /* Set the pathname of the pseudo-terminal slave associated with
465 the master FD is open on and return 0, or set errno and return
466 non-zero on errors. */
467 # if @REPLACE_PTSNAME_R@
468 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
470 # define ptsname_r rpl_ptsname_r
472 _GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
473 _GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
475 # if !@HAVE_PTSNAME_R@
476 _GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
478 _GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
480 _GL_CXXALIASWARN (ptsname_r);
481 #elif defined GNULIB_POSIXCHECK
483 # if HAVE_RAW_DECL_PTSNAME_R
484 _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
485 "use gnulib module ptsname_r for portability");
490 # if @REPLACE_PUTENV@
491 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
493 # define putenv rpl_putenv
495 _GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
496 _GL_CXXALIAS_RPL (putenv, int, (char *string));
498 _GL_CXXALIAS_SYS (putenv, int, (char *string));
500 _GL_CXXALIASWARN (putenv);
504 #if @GNULIB_RANDOM_R@
505 # if !@HAVE_RANDOM_R@
507 # define RAND_MAX 2147483647
515 _GL_FUNCDECL_SYS (random, long, (void));
517 _GL_CXXALIAS_SYS (random, long, (void));
518 _GL_CXXALIASWARN (random);
519 #elif defined GNULIB_POSIXCHECK
521 # if HAVE_RAW_DECL_RANDOM
522 _GL_WARN_ON_USE (random, "random is unportable - "
523 "use gnulib module random for portability");
529 _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
531 _GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
532 _GL_CXXALIASWARN (srandom);
533 #elif defined GNULIB_POSIXCHECK
535 # if HAVE_RAW_DECL_SRANDOM
536 _GL_WARN_ON_USE (srandom, "srandom is unportable - "
537 "use gnulib module random for portability");
543 _GL_FUNCDECL_SYS (initstate, char *,
544 (unsigned int seed, char *buf, size_t buf_size)
545 _GL_ARG_NONNULL ((2)));
547 _GL_CXXALIAS_SYS (initstate, char *,
548 (unsigned int seed, char *buf, size_t buf_size));
549 _GL_CXXALIASWARN (initstate);
550 #elif defined GNULIB_POSIXCHECK
552 # if HAVE_RAW_DECL_INITSTATE_R
553 _GL_WARN_ON_USE (initstate, "initstate is unportable - "
554 "use gnulib module random for portability");
560 _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
562 _GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
563 _GL_CXXALIASWARN (setstate);
564 #elif defined GNULIB_POSIXCHECK
566 # if HAVE_RAW_DECL_SETSTATE_R
567 _GL_WARN_ON_USE (setstate, "setstate is unportable - "
568 "use gnulib module random for portability");
573 #if @GNULIB_RANDOM_R@
574 # if @REPLACE_RANDOM_R@
575 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
577 # define random_r rpl_random_r
579 _GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
580 _GL_ARG_NONNULL ((1, 2)));
581 _GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
583 # if !@HAVE_RANDOM_R@
584 _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
585 _GL_ARG_NONNULL ((1, 2)));
587 _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
589 _GL_CXXALIASWARN (random_r);
590 #elif defined GNULIB_POSIXCHECK
592 # if HAVE_RAW_DECL_RANDOM_R
593 _GL_WARN_ON_USE (random_r, "random_r is unportable - "
594 "use gnulib module random_r for portability");
598 #if @GNULIB_RANDOM_R@
599 # if @REPLACE_RANDOM_R@
600 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
602 # define srandom_r rpl_srandom_r
604 _GL_FUNCDECL_RPL (srandom_r, int,
605 (unsigned int seed, struct random_data *rand_state)
606 _GL_ARG_NONNULL ((2)));
607 _GL_CXXALIAS_RPL (srandom_r, int,
608 (unsigned int seed, struct random_data *rand_state));
610 # if !@HAVE_RANDOM_R@
611 _GL_FUNCDECL_SYS (srandom_r, int,
612 (unsigned int seed, struct random_data *rand_state)
613 _GL_ARG_NONNULL ((2)));
615 _GL_CXXALIAS_SYS (srandom_r, int,
616 (unsigned int seed, struct random_data *rand_state));
618 _GL_CXXALIASWARN (srandom_r);
619 #elif defined GNULIB_POSIXCHECK
621 # if HAVE_RAW_DECL_SRANDOM_R
622 _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
623 "use gnulib module random_r for portability");
627 #if @GNULIB_RANDOM_R@
628 # if @REPLACE_RANDOM_R@
629 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
631 # define initstate_r rpl_initstate_r
633 _GL_FUNCDECL_RPL (initstate_r, int,
634 (unsigned int seed, char *buf, size_t buf_size,
635 struct random_data *rand_state)
636 _GL_ARG_NONNULL ((2, 4)));
637 _GL_CXXALIAS_RPL (initstate_r, int,
638 (unsigned int seed, char *buf, size_t buf_size,
639 struct random_data *rand_state));
641 # if !@HAVE_RANDOM_R@
642 _GL_FUNCDECL_SYS (initstate_r, int,
643 (unsigned int seed, char *buf, size_t buf_size,
644 struct random_data *rand_state)
645 _GL_ARG_NONNULL ((2, 4)));
647 _GL_CXXALIAS_SYS (initstate_r, int,
648 (unsigned int seed, char *buf, size_t buf_size,
649 struct random_data *rand_state));
651 _GL_CXXALIASWARN (initstate_r);
652 #elif defined GNULIB_POSIXCHECK
654 # if HAVE_RAW_DECL_INITSTATE_R
655 _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
656 "use gnulib module random_r for portability");
660 #if @GNULIB_RANDOM_R@
661 # if @REPLACE_RANDOM_R@
662 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
664 # define setstate_r rpl_setstate_r
666 _GL_FUNCDECL_RPL (setstate_r, int,
667 (char *arg_state, struct random_data *rand_state)
668 _GL_ARG_NONNULL ((1, 2)));
669 _GL_CXXALIAS_RPL (setstate_r, int,
670 (char *arg_state, struct random_data *rand_state));
672 # if !@HAVE_RANDOM_R@
673 _GL_FUNCDECL_SYS (setstate_r, int,
674 (char *arg_state, struct random_data *rand_state)
675 _GL_ARG_NONNULL ((1, 2)));
677 _GL_CXXALIAS_SYS (setstate_r, int,
678 (char *arg_state, struct random_data *rand_state));
680 _GL_CXXALIASWARN (setstate_r);
681 #elif defined GNULIB_POSIXCHECK
683 # if HAVE_RAW_DECL_SETSTATE_R
684 _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
685 "use gnulib module random_r for portability");
690 #if @GNULIB_REALLOC_POSIX@
691 # if @REPLACE_REALLOC@
692 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
693 || _GL_USE_STDLIB_ALLOC)
695 # define realloc rpl_realloc
697 _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size));
698 _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
700 _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
702 _GL_CXXALIASWARN (realloc);
703 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
705 /* Assume realloc is always declared. */
706 _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
707 "use gnulib module realloc-posix for portability");
710 #if @GNULIB_REALPATH@
711 # if @REPLACE_REALPATH@
712 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
713 # define realpath rpl_realpath
715 _GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved)
716 _GL_ARG_NONNULL ((1)));
717 _GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved));
719 # if !@HAVE_REALPATH@
720 _GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved)
721 _GL_ARG_NONNULL ((1)));
723 _GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved));
725 _GL_CXXALIASWARN (realpath);
726 #elif defined GNULIB_POSIXCHECK
728 # if HAVE_RAW_DECL_REALPATH
729 _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
730 "canonicalize or canonicalize-lgpl for portability");
735 /* Test a user response to a question.
736 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
738 _GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1)));
740 _GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
741 _GL_CXXALIASWARN (rpmatch);
742 #elif defined GNULIB_POSIXCHECK
744 # if HAVE_RAW_DECL_RPMATCH
745 _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
746 "use gnulib module rpmatch for portability");
751 /* Set NAME to VALUE in the environment.
752 If REPLACE is nonzero, overwrite an existing value. */
753 # if @REPLACE_SETENV@
754 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
756 # define setenv rpl_setenv
758 _GL_FUNCDECL_RPL (setenv, int,
759 (const char *name, const char *value, int replace)
760 _GL_ARG_NONNULL ((1)));
761 _GL_CXXALIAS_RPL (setenv, int,
762 (const char *name, const char *value, int replace));
764 # if !@HAVE_DECL_SETENV@
765 _GL_FUNCDECL_SYS (setenv, int,
766 (const char *name, const char *value, int replace)
767 _GL_ARG_NONNULL ((1)));
769 _GL_CXXALIAS_SYS (setenv, int,
770 (const char *name, const char *value, int replace));
772 # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
773 _GL_CXXALIASWARN (setenv);
775 #elif defined GNULIB_POSIXCHECK
777 # if HAVE_RAW_DECL_SETENV
778 _GL_WARN_ON_USE (setenv, "setenv is unportable - "
779 "use gnulib module setenv for portability");
784 /* Parse a double from STRING, updating ENDP if appropriate. */
785 # if @REPLACE_STRTOD@
786 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
787 # define strtod rpl_strtod
789 _GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp)
790 _GL_ARG_NONNULL ((1)));
791 _GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp));
794 _GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp)
795 _GL_ARG_NONNULL ((1)));
797 _GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp));
799 _GL_CXXALIASWARN (strtod);
800 #elif defined GNULIB_POSIXCHECK
802 # if HAVE_RAW_DECL_STRTOD
803 _GL_WARN_ON_USE (strtod, "strtod is unportable - "
804 "use gnulib module strtod for portability");
809 /* Parse a signed integer whose textual representation starts at STRING.
810 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
811 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
813 If ENDPTR is not NULL, the address of the first byte after the integer is
815 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
818 _GL_FUNCDECL_SYS (strtoll, long long,
819 (const char *string, char **endptr, int base)
820 _GL_ARG_NONNULL ((1)));
822 _GL_CXXALIAS_SYS (strtoll, long long,
823 (const char *string, char **endptr, int base));
824 _GL_CXXALIASWARN (strtoll);
825 #elif defined GNULIB_POSIXCHECK
827 # if HAVE_RAW_DECL_STRTOLL
828 _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
829 "use gnulib module strtoll for portability");
833 #if @GNULIB_STRTOULL@
834 /* Parse an unsigned integer whose textual representation starts at STRING.
835 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
836 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
838 If ENDPTR is not NULL, the address of the first byte after the integer is
840 Upon overflow, the return value is ULLONG_MAX, and errno is set to
842 # if !@HAVE_STRTOULL@
843 _GL_FUNCDECL_SYS (strtoull, unsigned long long,
844 (const char *string, char **endptr, int base)
845 _GL_ARG_NONNULL ((1)));
847 _GL_CXXALIAS_SYS (strtoull, unsigned long long,
848 (const char *string, char **endptr, int base));
849 _GL_CXXALIASWARN (strtoull);
850 #elif defined GNULIB_POSIXCHECK
852 # if HAVE_RAW_DECL_STRTOULL
853 _GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
854 "use gnulib module strtoull for portability");
858 #if @GNULIB_UNLOCKPT@
859 /* Unlock the slave side of the pseudo-terminal whose master side is specified
860 by FD, so that it can be opened. */
861 # if !@HAVE_UNLOCKPT@
862 _GL_FUNCDECL_SYS (unlockpt, int, (int fd));
864 _GL_CXXALIAS_SYS (unlockpt, int, (int fd));
865 _GL_CXXALIASWARN (unlockpt);
866 #elif defined GNULIB_POSIXCHECK
868 # if HAVE_RAW_DECL_UNLOCKPT
869 _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
870 "use gnulib module unlockpt for portability");
874 #if @GNULIB_UNSETENV@
875 /* Remove the variable NAME from the environment. */
876 # if @REPLACE_UNSETENV@
877 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
879 # define unsetenv rpl_unsetenv
881 _GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
882 _GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
884 # if !@HAVE_DECL_UNSETENV@
885 _GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
887 _GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
889 # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
890 _GL_CXXALIASWARN (unsetenv);
892 #elif defined GNULIB_POSIXCHECK
894 # if HAVE_RAW_DECL_UNSETENV
895 _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
896 "use gnulib module unsetenv for portability");
900 /* Convert a wide character to a multibyte character. */
902 # if @REPLACE_WCTOMB@
903 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
905 # define wctomb rpl_wctomb
907 _GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc));
908 _GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
910 _GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
912 _GL_CXXALIASWARN (wctomb);
916 #endif /* _@GUARD_PREFIX@_STDLIB_H */
917 #endif /* _@GUARD_PREFIX@_STDLIB_H */