1 /* A GNU-like <stdlib.h>.
3 Copyright (C) 1995, 2001-2004, 2006-2015 Free Software Foundation,
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 @PRAGMA_SYSTEM_HEADER@
24 #if defined __need_system_stdlib_h || defined __need_malloc_and_calloc
25 /* Special invocation conventions inside some gnulib header files,
26 and inside some glibc header files, respectively. */
28 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
31 /* Normal invocation convention. */
33 #ifndef _@GUARD_PREFIX@_STDLIB_H
35 /* The include_next requires a split double-inclusion guard. */
36 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
38 #ifndef _@GUARD_PREFIX@_STDLIB_H
39 #define _@GUARD_PREFIX@_STDLIB_H
41 /* NetBSD 5.0 mis-defines NULL. */
44 /* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */
45 #if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS
46 # include <sys/wait.h>
49 /* Solaris declares getloadavg() in <sys/loadavg.h>. */
50 #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
51 # include <sys/loadavg.h>
54 /* Native Windows platforms declare mktemp() in <io.h>. */
55 #if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
61 /* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
62 from <stdlib.h> if _REENTRANT is defined. Include it whenever we need
63 'struct random_data'. */
68 # if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
72 # if !@HAVE_STRUCT_RANDOM_DATA@
73 /* Define 'struct random_data'.
74 But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
75 # if !GNULIB_defined_struct_random_data
78 int32_t *fptr
; /* Front pointer. */
79 int32_t *rptr
; /* Rear pointer. */
80 int32_t *state
; /* Array of state values. */
81 int rand_type
; /* Type of random number generator. */
82 int rand_deg
; /* Degree of random number generator. */
83 int rand_sep
; /* Distance between front and rear. */
84 int32_t *end_ptr
; /* Pointer behind state table. */
86 # define GNULIB_defined_struct_random_data 1
91 #if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
92 /* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */
93 /* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */
94 /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
95 /* But avoid namespace pollution on glibc systems and native Windows. */
99 /* The __attribute__ feature is available in gcc versions 2.5 and later.
100 The attribute __pure__ was added in gcc 2.96. */
101 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
102 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
104 # define _GL_ATTRIBUTE_PURE /* empty */
107 /* The definition of _Noreturn is copied here. */
109 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
111 /* The definition of _GL_ARG_NONNULL is copied here. */
113 /* The definition of _GL_WARN_ON_USE is copied here. */
116 /* Some systems do not define EXIT_*, despite otherwise supporting C89. */
118 # define EXIT_SUCCESS 0
120 /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
121 with proper operation of xargs. */
123 # define EXIT_FAILURE 1
124 #elif EXIT_FAILURE != 1
126 # define EXIT_FAILURE 1
131 /* Terminate the current process with the given return code, without running
132 the 'atexit' handlers. */
134 _GL_FUNCDECL_SYS (_Exit
, _Noreturn
void, (int status
));
136 _GL_CXXALIAS_SYS (_Exit
, void, (int status
));
137 _GL_CXXALIASWARN (_Exit
);
138 #elif defined GNULIB_POSIXCHECK
140 # if HAVE_RAW_DECL__EXIT
141 _GL_WARN_ON_USE (_Exit
, "_Exit is unportable - "
142 "use gnulib module _Exit for portability");
148 /* Parse a signed decimal integer.
149 Returns the value of the integer. Errors are not detected. */
151 _GL_FUNCDECL_SYS (atoll
, long long, (const char *string
)
153 _GL_ARG_NONNULL ((1)));
155 _GL_CXXALIAS_SYS (atoll
, long long, (const char *string
));
156 _GL_CXXALIASWARN (atoll
);
157 #elif defined GNULIB_POSIXCHECK
159 # if HAVE_RAW_DECL_ATOLL
160 _GL_WARN_ON_USE (atoll
, "atoll is unportable - "
161 "use gnulib module atoll for portability");
165 #if @GNULIB_CALLOC_POSIX@
166 # if @REPLACE_CALLOC@
167 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
169 # define calloc rpl_calloc
171 _GL_FUNCDECL_RPL (calloc
, void *, (size_t nmemb
, size_t size
));
172 _GL_CXXALIAS_RPL (calloc
, void *, (size_t nmemb
, size_t size
));
174 _GL_CXXALIAS_SYS (calloc
, void *, (size_t nmemb
, size_t size
));
176 _GL_CXXALIASWARN (calloc
);
177 #elif defined GNULIB_POSIXCHECK
179 /* Assume calloc is always declared. */
180 _GL_WARN_ON_USE (calloc
, "calloc is not POSIX compliant everywhere - "
181 "use gnulib module calloc-posix for portability");
184 #if @GNULIB_CANONICALIZE_FILE_NAME@
185 # if @REPLACE_CANONICALIZE_FILE_NAME@
186 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
187 # define canonicalize_file_name rpl_canonicalize_file_name
189 _GL_FUNCDECL_RPL (canonicalize_file_name
, char *, (const char *name
)
190 _GL_ARG_NONNULL ((1)));
191 _GL_CXXALIAS_RPL (canonicalize_file_name
, char *, (const char *name
));
193 # if !@HAVE_CANONICALIZE_FILE_NAME@
194 _GL_FUNCDECL_SYS (canonicalize_file_name
, char *, (const char *name
)
195 _GL_ARG_NONNULL ((1)));
197 _GL_CXXALIAS_SYS (canonicalize_file_name
, char *, (const char *name
));
199 _GL_CXXALIASWARN (canonicalize_file_name
);
200 #elif defined GNULIB_POSIXCHECK
201 # undef canonicalize_file_name
202 # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
203 _GL_WARN_ON_USE (canonicalize_file_name
,
204 "canonicalize_file_name is unportable - "
205 "use gnulib module canonicalize-lgpl for portability");
209 #if @GNULIB_GETLOADAVG@
210 /* Store max(NELEM,3) load average numbers in LOADAVG[].
211 The three numbers are the load average of the last 1 minute, the last 5
212 minutes, and the last 15 minutes, respectively.
213 LOADAVG is an array of NELEM numbers. */
214 # if !@HAVE_DECL_GETLOADAVG@
215 _GL_FUNCDECL_SYS (getloadavg
, int, (double loadavg
[], int nelem
)
216 _GL_ARG_NONNULL ((1)));
218 _GL_CXXALIAS_SYS (getloadavg
, int, (double loadavg
[], int nelem
));
219 _GL_CXXALIASWARN (getloadavg
);
220 #elif defined GNULIB_POSIXCHECK
222 # if HAVE_RAW_DECL_GETLOADAVG
223 _GL_WARN_ON_USE (getloadavg
, "getloadavg is not portable - "
224 "use gnulib module getloadavg for portability");
228 #if @GNULIB_GETSUBOPT@
229 /* Assuming *OPTIONP is a comma separated list of elements of the form
230 "token" or "token=value", getsubopt parses the first of these elements.
231 If the first element refers to a "token" that is member of the given
232 NULL-terminated array of tokens:
233 - It replaces the comma with a NUL byte, updates *OPTIONP to point past
234 the first option and the comma, sets *VALUEP to the value of the
235 element (or NULL if it doesn't contain an "=" sign),
236 - It returns the index of the "token" in the given array of tokens.
237 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
238 For more details see the POSIX:2001 specification.
239 http://www.opengroup.org/susv3xsh/getsubopt.html */
240 # if !@HAVE_GETSUBOPT@
241 _GL_FUNCDECL_SYS (getsubopt
, int,
242 (char **optionp
, char *const *tokens
, char **valuep
)
243 _GL_ARG_NONNULL ((1, 2, 3)));
245 _GL_CXXALIAS_SYS (getsubopt
, int,
246 (char **optionp
, char *const *tokens
, char **valuep
));
247 _GL_CXXALIASWARN (getsubopt
);
248 #elif defined GNULIB_POSIXCHECK
250 # if HAVE_RAW_DECL_GETSUBOPT
251 _GL_WARN_ON_USE (getsubopt
, "getsubopt is unportable - "
252 "use gnulib module getsubopt for portability");
257 /* Change the ownership and access permission of the slave side of the
258 pseudo-terminal whose master side is specified by FD. */
260 _GL_FUNCDECL_SYS (grantpt
, int, (int fd
));
262 _GL_CXXALIAS_SYS (grantpt
, int, (int fd
));
263 _GL_CXXALIASWARN (grantpt
);
264 #elif defined GNULIB_POSIXCHECK
266 # if HAVE_RAW_DECL_GRANTPT
267 _GL_WARN_ON_USE (grantpt
, "grantpt is not portable - "
268 "use gnulib module grantpt for portability");
272 /* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
273 rely on GNU or POSIX semantics for malloc and realloc (for example,
274 by never specifying a zero size), so it does not need malloc or
275 realloc to be redefined. */
276 #if @GNULIB_MALLOC_POSIX@
277 # if @REPLACE_MALLOC@
278 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
279 || _GL_USE_STDLIB_ALLOC)
281 # define malloc rpl_malloc
283 _GL_FUNCDECL_RPL (malloc
, void *, (size_t size
));
284 _GL_CXXALIAS_RPL (malloc
, void *, (size_t size
));
286 _GL_CXXALIAS_SYS (malloc
, void *, (size_t size
));
288 _GL_CXXALIASWARN (malloc
);
289 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
291 /* Assume malloc is always declared. */
292 _GL_WARN_ON_USE (malloc
, "malloc is not POSIX compliant everywhere - "
293 "use gnulib module malloc-posix for portability");
296 /* Convert a multibyte character to a wide character. */
298 # if @REPLACE_MBTOWC@
299 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
301 # define mbtowc rpl_mbtowc
303 _GL_FUNCDECL_RPL (mbtowc
, int, (wchar_t *pwc
, const char *s
, size_t n
));
304 _GL_CXXALIAS_RPL (mbtowc
, int, (wchar_t *pwc
, const char *s
, size_t n
));
306 _GL_CXXALIAS_SYS (mbtowc
, int, (wchar_t *pwc
, const char *s
, size_t n
));
308 _GL_CXXALIASWARN (mbtowc
);
312 /* Create a unique temporary directory from TEMPLATE.
313 The last six characters of TEMPLATE must be "XXXXXX";
314 they are replaced with a string that makes the directory name unique.
315 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
316 The directory is created mode 700. */
318 _GL_FUNCDECL_SYS (mkdtemp
, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
320 _GL_CXXALIAS_SYS (mkdtemp
, char *, (char * /*template*/));
321 _GL_CXXALIASWARN (mkdtemp
);
322 #elif defined GNULIB_POSIXCHECK
324 # if HAVE_RAW_DECL_MKDTEMP
325 _GL_WARN_ON_USE (mkdtemp
, "mkdtemp is unportable - "
326 "use gnulib module mkdtemp for portability");
330 #if @GNULIB_MKOSTEMP@
331 /* Create a unique temporary file from TEMPLATE.
332 The last six characters of TEMPLATE must be "XXXXXX";
333 they are replaced with a string that makes the file name unique.
334 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
335 and O_TEXT, O_BINARY (defined in "binary-io.h").
336 The file is then created, with the specified flags, ensuring it didn't exist
338 The file is created read-write (mask at least 0600 & ~umask), but it may be
339 world-readable and world-writable (mask 0666 & ~umask), depending on the
341 Returns the open file descriptor if successful, otherwise -1 and errno
343 # if !@HAVE_MKOSTEMP@
344 _GL_FUNCDECL_SYS (mkostemp
, int, (char * /*template*/, int /*flags*/)
345 _GL_ARG_NONNULL ((1)));
347 _GL_CXXALIAS_SYS (mkostemp
, int, (char * /*template*/, int /*flags*/));
348 _GL_CXXALIASWARN (mkostemp
);
349 #elif defined GNULIB_POSIXCHECK
351 # if HAVE_RAW_DECL_MKOSTEMP
352 _GL_WARN_ON_USE (mkostemp
, "mkostemp is unportable - "
353 "use gnulib module mkostemp for portability");
357 #if @GNULIB_MKOSTEMPS@
358 /* Create a unique temporary file from TEMPLATE.
359 The last six characters of TEMPLATE before a suffix of length
360 SUFFIXLEN must be "XXXXXX";
361 they are replaced with a string that makes the file name unique.
362 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
363 and O_TEXT, O_BINARY (defined in "binary-io.h").
364 The file is then created, with the specified flags, ensuring it didn't exist
366 The file is created read-write (mask at least 0600 & ~umask), but it may be
367 world-readable and world-writable (mask 0666 & ~umask), depending on the
369 Returns the open file descriptor if successful, otherwise -1 and errno
371 # if !@HAVE_MKOSTEMPS@
372 _GL_FUNCDECL_SYS (mkostemps
, int,
373 (char * /*template*/, int /*suffixlen*/, int /*flags*/)
374 _GL_ARG_NONNULL ((1)));
376 _GL_CXXALIAS_SYS (mkostemps
, int,
377 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
378 _GL_CXXALIASWARN (mkostemps
);
379 #elif defined GNULIB_POSIXCHECK
381 # if HAVE_RAW_DECL_MKOSTEMPS
382 _GL_WARN_ON_USE (mkostemps
, "mkostemps is unportable - "
383 "use gnulib module mkostemps for portability");
388 /* Create a unique temporary file from TEMPLATE.
389 The last six characters of TEMPLATE must be "XXXXXX";
390 they are replaced with a string that makes the file name unique.
391 The file is then created, ensuring it didn't exist before.
392 The file is created read-write (mask at least 0600 & ~umask), but it may be
393 world-readable and world-writable (mask 0666 & ~umask), depending on the
395 Returns the open file descriptor if successful, otherwise -1 and errno
397 # if @REPLACE_MKSTEMP@
398 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
399 # define mkstemp rpl_mkstemp
401 _GL_FUNCDECL_RPL (mkstemp
, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
402 _GL_CXXALIAS_RPL (mkstemp
, int, (char * /*template*/));
404 # if ! @HAVE_MKSTEMP@
405 _GL_FUNCDECL_SYS (mkstemp
, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
407 _GL_CXXALIAS_SYS (mkstemp
, int, (char * /*template*/));
409 _GL_CXXALIASWARN (mkstemp
);
410 #elif defined GNULIB_POSIXCHECK
412 # if HAVE_RAW_DECL_MKSTEMP
413 _GL_WARN_ON_USE (mkstemp
, "mkstemp is unportable - "
414 "use gnulib module mkstemp for portability");
418 #if @GNULIB_MKSTEMPS@
419 /* Create a unique temporary file from TEMPLATE.
420 The last six characters of TEMPLATE prior to a suffix of length
421 SUFFIXLEN must be "XXXXXX";
422 they are replaced with a string that makes the file name unique.
423 The file is then created, ensuring it didn't exist before.
424 The file is created read-write (mask at least 0600 & ~umask), but it may be
425 world-readable and world-writable (mask 0666 & ~umask), depending on the
427 Returns the open file descriptor if successful, otherwise -1 and errno
429 # if !@HAVE_MKSTEMPS@
430 _GL_FUNCDECL_SYS (mkstemps
, int, (char * /*template*/, int /*suffixlen*/)
431 _GL_ARG_NONNULL ((1)));
433 _GL_CXXALIAS_SYS (mkstemps
, int, (char * /*template*/, int /*suffixlen*/));
434 _GL_CXXALIASWARN (mkstemps
);
435 #elif defined GNULIB_POSIXCHECK
437 # if HAVE_RAW_DECL_MKSTEMPS
438 _GL_WARN_ON_USE (mkstemps
, "mkstemps is unportable - "
439 "use gnulib module mkstemps for portability");
443 #if @GNULIB_POSIX_OPENPT@
444 /* Return an FD open to the master side of a pseudo-terminal. Flags should
445 include O_RDWR, and may also include O_NOCTTY. */
446 # if !@HAVE_POSIX_OPENPT@
447 _GL_FUNCDECL_SYS (posix_openpt
, int, (int flags
));
449 _GL_CXXALIAS_SYS (posix_openpt
, int, (int flags
));
450 _GL_CXXALIASWARN (posix_openpt
);
451 #elif defined GNULIB_POSIXCHECK
453 # if HAVE_RAW_DECL_POSIX_OPENPT
454 _GL_WARN_ON_USE (posix_openpt
, "posix_openpt is not portable - "
455 "use gnulib module posix_openpt for portability");
460 /* Return the pathname of the pseudo-terminal slave associated with
461 the master FD is open on, or NULL on errors. */
462 # if @REPLACE_PTSNAME@
463 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
465 # define ptsname rpl_ptsname
467 _GL_FUNCDECL_RPL (ptsname
, char *, (int fd
));
468 _GL_CXXALIAS_RPL (ptsname
, char *, (int fd
));
471 _GL_FUNCDECL_SYS (ptsname
, char *, (int fd
));
473 _GL_CXXALIAS_SYS (ptsname
, char *, (int fd
));
475 _GL_CXXALIASWARN (ptsname
);
476 #elif defined GNULIB_POSIXCHECK
478 # if HAVE_RAW_DECL_PTSNAME
479 _GL_WARN_ON_USE (ptsname
, "ptsname is not portable - "
480 "use gnulib module ptsname for portability");
484 #if @GNULIB_PTSNAME_R@
485 /* Set the pathname of the pseudo-terminal slave associated with
486 the master FD is open on and return 0, or set errno and return
487 non-zero on errors. */
488 # if @REPLACE_PTSNAME_R@
489 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
491 # define ptsname_r rpl_ptsname_r
493 _GL_FUNCDECL_RPL (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
494 _GL_CXXALIAS_RPL (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
496 # if !@HAVE_PTSNAME_R@
497 _GL_FUNCDECL_SYS (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
499 _GL_CXXALIAS_SYS (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
501 _GL_CXXALIASWARN (ptsname_r
);
502 #elif defined GNULIB_POSIXCHECK
504 # if HAVE_RAW_DECL_PTSNAME_R
505 _GL_WARN_ON_USE (ptsname_r
, "ptsname_r is not portable - "
506 "use gnulib module ptsname_r for portability");
511 # if @REPLACE_PUTENV@
512 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
514 # define putenv rpl_putenv
516 _GL_FUNCDECL_RPL (putenv
, int, (char *string
) _GL_ARG_NONNULL ((1)));
517 _GL_CXXALIAS_RPL (putenv
, int, (char *string
));
519 _GL_CXXALIAS_SYS (putenv
, int, (char *string
));
521 _GL_CXXALIASWARN (putenv
);
525 #if @GNULIB_RANDOM_R@
526 # if !@HAVE_RANDOM_R@
528 # define RAND_MAX 2147483647
536 _GL_FUNCDECL_SYS (random
, long, (void));
538 _GL_CXXALIAS_SYS (random
, long, (void));
539 _GL_CXXALIASWARN (random
);
540 #elif defined GNULIB_POSIXCHECK
542 # if HAVE_RAW_DECL_RANDOM
543 _GL_WARN_ON_USE (random
, "random is unportable - "
544 "use gnulib module random for portability");
550 _GL_FUNCDECL_SYS (srandom
, void, (unsigned int seed
));
552 _GL_CXXALIAS_SYS (srandom
, void, (unsigned int seed
));
553 _GL_CXXALIASWARN (srandom
);
554 #elif defined GNULIB_POSIXCHECK
556 # if HAVE_RAW_DECL_SRANDOM
557 _GL_WARN_ON_USE (srandom
, "srandom is unportable - "
558 "use gnulib module random for portability");
564 _GL_FUNCDECL_SYS (initstate
, char *,
565 (unsigned int seed
, char *buf
, size_t buf_size
)
566 _GL_ARG_NONNULL ((2)));
568 _GL_CXXALIAS_SYS (initstate
, char *,
569 (unsigned int seed
, char *buf
, size_t buf_size
));
570 _GL_CXXALIASWARN (initstate
);
571 #elif defined GNULIB_POSIXCHECK
573 # if HAVE_RAW_DECL_INITSTATE_R
574 _GL_WARN_ON_USE (initstate
, "initstate is unportable - "
575 "use gnulib module random for portability");
581 _GL_FUNCDECL_SYS (setstate
, char *, (char *arg_state
) _GL_ARG_NONNULL ((1)));
583 _GL_CXXALIAS_SYS (setstate
, char *, (char *arg_state
));
584 _GL_CXXALIASWARN (setstate
);
585 #elif defined GNULIB_POSIXCHECK
587 # if HAVE_RAW_DECL_SETSTATE_R
588 _GL_WARN_ON_USE (setstate
, "setstate is unportable - "
589 "use gnulib module random for portability");
594 #if @GNULIB_RANDOM_R@
595 # if @REPLACE_RANDOM_R@
596 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
598 # define random_r rpl_random_r
600 _GL_FUNCDECL_RPL (random_r
, int, (struct random_data
*buf
, int32_t *result
)
601 _GL_ARG_NONNULL ((1, 2)));
602 _GL_CXXALIAS_RPL (random_r
, int, (struct random_data
*buf
, int32_t *result
));
604 # if !@HAVE_RANDOM_R@
605 _GL_FUNCDECL_SYS (random_r
, int, (struct random_data
*buf
, int32_t *result
)
606 _GL_ARG_NONNULL ((1, 2)));
608 _GL_CXXALIAS_SYS (random_r
, int, (struct random_data
*buf
, int32_t *result
));
610 _GL_CXXALIASWARN (random_r
);
611 #elif defined GNULIB_POSIXCHECK
613 # if HAVE_RAW_DECL_RANDOM_R
614 _GL_WARN_ON_USE (random_r
, "random_r is unportable - "
615 "use gnulib module random_r for portability");
619 #if @GNULIB_RANDOM_R@
620 # if @REPLACE_RANDOM_R@
621 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
623 # define srandom_r rpl_srandom_r
625 _GL_FUNCDECL_RPL (srandom_r
, int,
626 (unsigned int seed
, struct random_data
*rand_state
)
627 _GL_ARG_NONNULL ((2)));
628 _GL_CXXALIAS_RPL (srandom_r
, int,
629 (unsigned int seed
, struct random_data
*rand_state
));
631 # if !@HAVE_RANDOM_R@
632 _GL_FUNCDECL_SYS (srandom_r
, int,
633 (unsigned int seed
, struct random_data
*rand_state
)
634 _GL_ARG_NONNULL ((2)));
636 _GL_CXXALIAS_SYS (srandom_r
, int,
637 (unsigned int seed
, struct random_data
*rand_state
));
639 _GL_CXXALIASWARN (srandom_r
);
640 #elif defined GNULIB_POSIXCHECK
642 # if HAVE_RAW_DECL_SRANDOM_R
643 _GL_WARN_ON_USE (srandom_r
, "srandom_r is unportable - "
644 "use gnulib module random_r for portability");
648 #if @GNULIB_RANDOM_R@
649 # if @REPLACE_RANDOM_R@
650 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
652 # define initstate_r rpl_initstate_r
654 _GL_FUNCDECL_RPL (initstate_r
, int,
655 (unsigned int seed
, char *buf
, size_t buf_size
,
656 struct random_data
*rand_state
)
657 _GL_ARG_NONNULL ((2, 4)));
658 _GL_CXXALIAS_RPL (initstate_r
, int,
659 (unsigned int seed
, char *buf
, size_t buf_size
,
660 struct random_data
*rand_state
));
662 # if !@HAVE_RANDOM_R@
663 _GL_FUNCDECL_SYS (initstate_r
, int,
664 (unsigned int seed
, char *buf
, size_t buf_size
,
665 struct random_data
*rand_state
)
666 _GL_ARG_NONNULL ((2, 4)));
668 _GL_CXXALIAS_SYS (initstate_r
, int,
669 (unsigned int seed
, char *buf
, size_t buf_size
,
670 struct random_data
*rand_state
));
672 _GL_CXXALIASWARN (initstate_r
);
673 #elif defined GNULIB_POSIXCHECK
675 # if HAVE_RAW_DECL_INITSTATE_R
676 _GL_WARN_ON_USE (initstate_r
, "initstate_r is unportable - "
677 "use gnulib module random_r for portability");
681 #if @GNULIB_RANDOM_R@
682 # if @REPLACE_RANDOM_R@
683 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
685 # define setstate_r rpl_setstate_r
687 _GL_FUNCDECL_RPL (setstate_r
, int,
688 (char *arg_state
, struct random_data
*rand_state
)
689 _GL_ARG_NONNULL ((1, 2)));
690 _GL_CXXALIAS_RPL (setstate_r
, int,
691 (char *arg_state
, struct random_data
*rand_state
));
693 # if !@HAVE_RANDOM_R@
694 _GL_FUNCDECL_SYS (setstate_r
, int,
695 (char *arg_state
, struct random_data
*rand_state
)
696 _GL_ARG_NONNULL ((1, 2)));
698 _GL_CXXALIAS_SYS (setstate_r
, int,
699 (char *arg_state
, struct random_data
*rand_state
));
701 _GL_CXXALIASWARN (setstate_r
);
702 #elif defined GNULIB_POSIXCHECK
704 # if HAVE_RAW_DECL_SETSTATE_R
705 _GL_WARN_ON_USE (setstate_r
, "setstate_r is unportable - "
706 "use gnulib module random_r for portability");
711 #if @GNULIB_REALLOC_POSIX@
712 # if @REPLACE_REALLOC@
713 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
714 || _GL_USE_STDLIB_ALLOC)
716 # define realloc rpl_realloc
718 _GL_FUNCDECL_RPL (realloc
, void *, (void *ptr
, size_t size
));
719 _GL_CXXALIAS_RPL (realloc
, void *, (void *ptr
, size_t size
));
721 _GL_CXXALIAS_SYS (realloc
, void *, (void *ptr
, size_t size
));
723 _GL_CXXALIASWARN (realloc
);
724 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
726 /* Assume realloc is always declared. */
727 _GL_WARN_ON_USE (realloc
, "realloc is not POSIX compliant everywhere - "
728 "use gnulib module realloc-posix for portability");
731 #if @GNULIB_REALPATH@
732 # if @REPLACE_REALPATH@
733 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
734 # define realpath rpl_realpath
736 _GL_FUNCDECL_RPL (realpath
, char *, (const char *name
, char *resolved
)
737 _GL_ARG_NONNULL ((1)));
738 _GL_CXXALIAS_RPL (realpath
, char *, (const char *name
, char *resolved
));
740 # if !@HAVE_REALPATH@
741 _GL_FUNCDECL_SYS (realpath
, char *, (const char *name
, char *resolved
)
742 _GL_ARG_NONNULL ((1)));
744 _GL_CXXALIAS_SYS (realpath
, char *, (const char *name
, char *resolved
));
746 _GL_CXXALIASWARN (realpath
);
747 #elif defined GNULIB_POSIXCHECK
749 # if HAVE_RAW_DECL_REALPATH
750 _GL_WARN_ON_USE (realpath
, "realpath is unportable - use gnulib module "
751 "canonicalize or canonicalize-lgpl for portability");
756 /* Test a user response to a question.
757 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
759 _GL_FUNCDECL_SYS (rpmatch
, int, (const char *response
) _GL_ARG_NONNULL ((1)));
761 _GL_CXXALIAS_SYS (rpmatch
, int, (const char *response
));
762 _GL_CXXALIASWARN (rpmatch
);
763 #elif defined GNULIB_POSIXCHECK
765 # if HAVE_RAW_DECL_RPMATCH
766 _GL_WARN_ON_USE (rpmatch
, "rpmatch is unportable - "
767 "use gnulib module rpmatch for portability");
771 #if @GNULIB_SECURE_GETENV@
772 /* Look up NAME in the environment, returning 0 in insecure situations. */
773 # if !@HAVE_SECURE_GETENV@
774 _GL_FUNCDECL_SYS (secure_getenv
, char *,
775 (char const *name
) _GL_ARG_NONNULL ((1)));
777 _GL_CXXALIAS_SYS (secure_getenv
, char *, (char const *name
));
778 _GL_CXXALIASWARN (secure_getenv
);
779 #elif defined GNULIB_POSIXCHECK
780 # undef secure_getenv
781 # if HAVE_RAW_DECL_SECURE_GETENV
782 _GL_WARN_ON_USE (secure_getenv
, "secure_getenv is unportable - "
783 "use gnulib module secure_getenv for portability");
788 /* Set NAME to VALUE in the environment.
789 If REPLACE is nonzero, overwrite an existing value. */
790 # if @REPLACE_SETENV@
791 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
793 # define setenv rpl_setenv
795 _GL_FUNCDECL_RPL (setenv
, int,
796 (const char *name
, const char *value
, int replace
)
797 _GL_ARG_NONNULL ((1)));
798 _GL_CXXALIAS_RPL (setenv
, int,
799 (const char *name
, const char *value
, int replace
));
801 # if !@HAVE_DECL_SETENV@
802 _GL_FUNCDECL_SYS (setenv
, int,
803 (const char *name
, const char *value
, int replace
)
804 _GL_ARG_NONNULL ((1)));
806 _GL_CXXALIAS_SYS (setenv
, int,
807 (const char *name
, const char *value
, int replace
));
809 # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
810 _GL_CXXALIASWARN (setenv
);
812 #elif defined GNULIB_POSIXCHECK
814 # if HAVE_RAW_DECL_SETENV
815 _GL_WARN_ON_USE (setenv
, "setenv is unportable - "
816 "use gnulib module setenv for portability");
821 /* Parse a double from STRING, updating ENDP if appropriate. */
822 # if @REPLACE_STRTOD@
823 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
824 # define strtod rpl_strtod
826 _GL_FUNCDECL_RPL (strtod
, double, (const char *str
, char **endp
)
827 _GL_ARG_NONNULL ((1)));
828 _GL_CXXALIAS_RPL (strtod
, double, (const char *str
, char **endp
));
831 _GL_FUNCDECL_SYS (strtod
, double, (const char *str
, char **endp
)
832 _GL_ARG_NONNULL ((1)));
834 _GL_CXXALIAS_SYS (strtod
, double, (const char *str
, char **endp
));
836 _GL_CXXALIASWARN (strtod
);
837 #elif defined GNULIB_POSIXCHECK
839 # if HAVE_RAW_DECL_STRTOD
840 _GL_WARN_ON_USE (strtod
, "strtod is unportable - "
841 "use gnulib module strtod for portability");
846 /* Parse a signed integer whose textual representation starts at STRING.
847 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
848 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
850 If ENDPTR is not NULL, the address of the first byte after the integer is
852 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
855 _GL_FUNCDECL_SYS (strtoll
, long long,
856 (const char *string
, char **endptr
, int base
)
857 _GL_ARG_NONNULL ((1)));
859 _GL_CXXALIAS_SYS (strtoll
, long long,
860 (const char *string
, char **endptr
, int base
));
861 _GL_CXXALIASWARN (strtoll
);
862 #elif defined GNULIB_POSIXCHECK
864 # if HAVE_RAW_DECL_STRTOLL
865 _GL_WARN_ON_USE (strtoll
, "strtoll is unportable - "
866 "use gnulib module strtoll for portability");
870 #if @GNULIB_STRTOULL@
871 /* Parse an unsigned integer whose textual representation starts at STRING.
872 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
873 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
875 If ENDPTR is not NULL, the address of the first byte after the integer is
877 Upon overflow, the return value is ULLONG_MAX, and errno is set to
879 # if !@HAVE_STRTOULL@
880 _GL_FUNCDECL_SYS (strtoull
, unsigned long long,
881 (const char *string
, char **endptr
, int base
)
882 _GL_ARG_NONNULL ((1)));
884 _GL_CXXALIAS_SYS (strtoull
, unsigned long long,
885 (const char *string
, char **endptr
, int base
));
886 _GL_CXXALIASWARN (strtoull
);
887 #elif defined GNULIB_POSIXCHECK
889 # if HAVE_RAW_DECL_STRTOULL
890 _GL_WARN_ON_USE (strtoull
, "strtoull is unportable - "
891 "use gnulib module strtoull for portability");
895 #if @GNULIB_UNLOCKPT@
896 /* Unlock the slave side of the pseudo-terminal whose master side is specified
897 by FD, so that it can be opened. */
898 # if !@HAVE_UNLOCKPT@
899 _GL_FUNCDECL_SYS (unlockpt
, int, (int fd
));
901 _GL_CXXALIAS_SYS (unlockpt
, int, (int fd
));
902 _GL_CXXALIASWARN (unlockpt
);
903 #elif defined GNULIB_POSIXCHECK
905 # if HAVE_RAW_DECL_UNLOCKPT
906 _GL_WARN_ON_USE (unlockpt
, "unlockpt is not portable - "
907 "use gnulib module unlockpt for portability");
911 #if @GNULIB_UNSETENV@
912 /* Remove the variable NAME from the environment. */
913 # if @REPLACE_UNSETENV@
914 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
916 # define unsetenv rpl_unsetenv
918 _GL_FUNCDECL_RPL (unsetenv
, int, (const char *name
) _GL_ARG_NONNULL ((1)));
919 _GL_CXXALIAS_RPL (unsetenv
, int, (const char *name
));
921 # if !@HAVE_DECL_UNSETENV@
922 _GL_FUNCDECL_SYS (unsetenv
, int, (const char *name
) _GL_ARG_NONNULL ((1)));
924 _GL_CXXALIAS_SYS (unsetenv
, int, (const char *name
));
926 # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
927 _GL_CXXALIASWARN (unsetenv
);
929 #elif defined GNULIB_POSIXCHECK
931 # if HAVE_RAW_DECL_UNSETENV
932 _GL_WARN_ON_USE (unsetenv
, "unsetenv is unportable - "
933 "use gnulib module unsetenv for portability");
937 /* Convert a wide character to a multibyte character. */
939 # if @REPLACE_WCTOMB@
940 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
942 # define wctomb rpl_wctomb
944 _GL_FUNCDECL_RPL (wctomb
, int, (char *s
, wchar_t wc
));
945 _GL_CXXALIAS_RPL (wctomb
, int, (char *s
, wchar_t wc
));
947 _GL_CXXALIAS_SYS (wctomb
, int, (char *s
, wchar_t wc
));
949 _GL_CXXALIASWARN (wctomb
);
953 #endif /* _@GUARD_PREFIX@_STDLIB_H */
954 #endif /* _@GUARD_PREFIX@_STDLIB_H */