1 /* A GNU-like <stdlib.h>.
3 Copyright (C) 1995, 2001-2004, 2006-2020 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/>. */
19 @PRAGMA_SYSTEM_HEADER@
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@
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. */
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>
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
52 # include <sys/time.h>
53 # include <sys/loadavg.h>
56 /* Native Windows platforms declare mktemp() in <io.h>. */
57 #if 0 && (defined _WIN32 && ! defined __CYGWIN__)
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'. */
70 # if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
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
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
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. */
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__))
107 # define _GL_ATTRIBUTE_PURE /* empty */
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. */
121 # define EXIT_SUCCESS 0
123 /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
124 with proper operation of xargs. */
126 # define EXIT_FAILURE 1
127 #elif EXIT_FAILURE != 1
129 # define EXIT_FAILURE 1
134 /* Terminate the current process with the given return code, without running
135 the 'atexit' handlers. */
137 _GL_FUNCDECL_SYS (_Exit
, _Noreturn
void, (int status
));
139 _GL_CXXALIAS_SYS (_Exit
, void, (int status
));
140 _GL_CXXALIASWARN (_Exit
);
141 #elif defined GNULIB_POSIXCHECK
143 # if HAVE_RAW_DECL__EXIT
144 _GL_WARN_ON_USE (_Exit
, "_Exit is unportable - "
145 "use gnulib module _Exit for portability");
151 /* Parse a signed decimal integer.
152 Returns the value of the integer. Errors are not detected. */
154 _GL_FUNCDECL_SYS (atoll
, long long, (const char *string
)
156 _GL_ARG_NONNULL ((1)));
158 _GL_CXXALIAS_SYS (atoll
, long long, (const char *string
));
159 _GL_CXXALIASWARN (atoll
);
160 #elif defined GNULIB_POSIXCHECK
162 # if HAVE_RAW_DECL_ATOLL
163 _GL_WARN_ON_USE (atoll
, "atoll is unportable - "
164 "use gnulib module atoll for portability");
168 #if @GNULIB_CALLOC_POSIX@
169 # if @REPLACE_CALLOC@
170 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
172 # define calloc rpl_calloc
174 _GL_FUNCDECL_RPL (calloc
, void *, (size_t nmemb
, size_t size
));
175 _GL_CXXALIAS_RPL (calloc
, void *, (size_t nmemb
, size_t size
));
177 _GL_CXXALIAS_SYS (calloc
, void *, (size_t nmemb
, size_t size
));
180 _GL_CXXALIASWARN (calloc
);
182 #elif defined GNULIB_POSIXCHECK
184 /* Assume calloc is always declared. */
185 _GL_WARN_ON_USE (calloc
, "calloc is not POSIX compliant everywhere - "
186 "use gnulib module calloc-posix for portability");
189 #if @GNULIB_CANONICALIZE_FILE_NAME@
190 # if @REPLACE_CANONICALIZE_FILE_NAME@
191 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
192 # define canonicalize_file_name rpl_canonicalize_file_name
194 _GL_FUNCDECL_RPL (canonicalize_file_name
, char *, (const char *name
)
195 _GL_ARG_NONNULL ((1)));
196 _GL_CXXALIAS_RPL (canonicalize_file_name
, char *, (const char *name
));
198 # if !@HAVE_CANONICALIZE_FILE_NAME@
199 _GL_FUNCDECL_SYS (canonicalize_file_name
, char *, (const char *name
)
200 _GL_ARG_NONNULL ((1)));
202 _GL_CXXALIAS_SYS (canonicalize_file_name
, char *, (const char *name
));
204 # ifndef GNULIB_defined_canonicalize_file_name
205 # define GNULIB_defined_canonicalize_file_name \
206 (!@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@)
208 _GL_CXXALIASWARN (canonicalize_file_name
);
209 #elif defined GNULIB_POSIXCHECK
210 # undef canonicalize_file_name
211 # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
212 _GL_WARN_ON_USE (canonicalize_file_name
,
213 "canonicalize_file_name is unportable - "
214 "use gnulib module canonicalize-lgpl for portability");
218 #if @GNULIB_GETLOADAVG@
219 /* Store max(NELEM,3) load average numbers in LOADAVG[].
220 The three numbers are the load average of the last 1 minute, the last 5
221 minutes, and the last 15 minutes, respectively.
222 LOADAVG is an array of NELEM numbers. */
223 # if !@HAVE_DECL_GETLOADAVG@
224 _GL_FUNCDECL_SYS (getloadavg
, int, (double loadavg
[], int nelem
)
225 _GL_ARG_NONNULL ((1)));
227 _GL_CXXALIAS_SYS (getloadavg
, int, (double loadavg
[], int nelem
));
228 _GL_CXXALIASWARN (getloadavg
);
229 #elif defined GNULIB_POSIXCHECK
231 # if HAVE_RAW_DECL_GETLOADAVG
232 _GL_WARN_ON_USE (getloadavg
, "getloadavg is not portable - "
233 "use gnulib module getloadavg for portability");
237 #if @GNULIB_GETSUBOPT@
238 /* Assuming *OPTIONP is a comma separated list of elements of the form
239 "token" or "token=value", getsubopt parses the first of these elements.
240 If the first element refers to a "token" that is member of the given
241 NULL-terminated array of tokens:
242 - It replaces the comma with a NUL byte, updates *OPTIONP to point past
243 the first option and the comma, sets *VALUEP to the value of the
244 element (or NULL if it doesn't contain an "=" sign),
245 - It returns the index of the "token" in the given array of tokens.
246 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
247 For more details see the POSIX specification.
248 https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html */
249 # if !@HAVE_GETSUBOPT@
250 _GL_FUNCDECL_SYS (getsubopt
, int,
251 (char **optionp
, char *const *tokens
, char **valuep
)
252 _GL_ARG_NONNULL ((1, 2, 3)));
254 _GL_CXXALIAS_SYS (getsubopt
, int,
255 (char **optionp
, char *const *tokens
, char **valuep
));
256 _GL_CXXALIASWARN (getsubopt
);
257 #elif defined GNULIB_POSIXCHECK
259 # if HAVE_RAW_DECL_GETSUBOPT
260 _GL_WARN_ON_USE (getsubopt
, "getsubopt is unportable - "
261 "use gnulib module getsubopt for portability");
266 /* Change the ownership and access permission of the slave side of the
267 pseudo-terminal whose master side is specified by FD. */
269 _GL_FUNCDECL_SYS (grantpt
, int, (int fd
));
271 _GL_CXXALIAS_SYS (grantpt
, int, (int fd
));
272 _GL_CXXALIASWARN (grantpt
);
273 #elif defined GNULIB_POSIXCHECK
275 # if HAVE_RAW_DECL_GRANTPT
276 _GL_WARN_ON_USE (grantpt
, "grantpt is not portable - "
277 "use gnulib module grantpt for portability");
281 /* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
282 rely on GNU or POSIX semantics for malloc and realloc (for example,
283 by never specifying a zero size), so it does not need malloc or
284 realloc to be redefined. */
285 #if @GNULIB_MALLOC_POSIX@
286 # if @REPLACE_MALLOC@
287 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
288 || _GL_USE_STDLIB_ALLOC)
290 # define malloc rpl_malloc
292 _GL_FUNCDECL_RPL (malloc
, void *, (size_t size
));
293 _GL_CXXALIAS_RPL (malloc
, void *, (size_t size
));
295 _GL_CXXALIAS_SYS (malloc
, void *, (size_t size
));
298 _GL_CXXALIASWARN (malloc
);
300 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
302 /* Assume malloc is always declared. */
303 _GL_WARN_ON_USE (malloc
, "malloc is not POSIX compliant everywhere - "
304 "use gnulib module malloc-posix for portability");
307 /* Convert a multibyte character to a wide character. */
309 # if @REPLACE_MBTOWC@
310 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
312 # define mbtowc rpl_mbtowc
314 _GL_FUNCDECL_RPL (mbtowc
, int, (wchar_t *pwc
, const char *s
, size_t n
));
315 _GL_CXXALIAS_RPL (mbtowc
, int, (wchar_t *pwc
, const char *s
, size_t n
));
318 _GL_FUNCDECL_SYS (mbtowc
, int, (wchar_t *pwc
, const char *s
, size_t n
));
320 _GL_CXXALIAS_SYS (mbtowc
, int, (wchar_t *pwc
, const char *s
, size_t n
));
323 _GL_CXXALIASWARN (mbtowc
);
325 #elif defined GNULIB_POSIXCHECK
327 # if HAVE_RAW_DECL_MBTOWC
328 _GL_WARN_ON_USE (mbtowc
, "mbtowc is not portable - "
329 "use gnulib module mbtowc for portability");
334 /* Create a unique temporary directory from TEMPLATE.
335 The last six characters of TEMPLATE must be "XXXXXX";
336 they are replaced with a string that makes the directory name unique.
337 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
338 The directory is created mode 700. */
340 _GL_FUNCDECL_SYS (mkdtemp
, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
342 _GL_CXXALIAS_SYS (mkdtemp
, char *, (char * /*template*/));
343 _GL_CXXALIASWARN (mkdtemp
);
344 #elif defined GNULIB_POSIXCHECK
346 # if HAVE_RAW_DECL_MKDTEMP
347 _GL_WARN_ON_USE (mkdtemp
, "mkdtemp is unportable - "
348 "use gnulib module mkdtemp for portability");
352 #if @GNULIB_MKOSTEMP@
353 /* Create a unique temporary file from TEMPLATE.
354 The last six characters of TEMPLATE must be "XXXXXX";
355 they are replaced with a string that makes the file name unique.
356 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
357 and O_TEXT, O_BINARY (defined in "binary-io.h").
358 The file is then created, with the specified flags, ensuring it didn't exist
360 The file is created read-write (mask at least 0600 & ~umask), but it may be
361 world-readable and world-writable (mask 0666 & ~umask), depending on the
363 Returns the open file descriptor if successful, otherwise -1 and errno
365 # if !@HAVE_MKOSTEMP@
366 _GL_FUNCDECL_SYS (mkostemp
, int, (char * /*template*/, int /*flags*/)
367 _GL_ARG_NONNULL ((1)));
369 _GL_CXXALIAS_SYS (mkostemp
, int, (char * /*template*/, int /*flags*/));
370 _GL_CXXALIASWARN (mkostemp
);
371 #elif defined GNULIB_POSIXCHECK
373 # if HAVE_RAW_DECL_MKOSTEMP
374 _GL_WARN_ON_USE (mkostemp
, "mkostemp is unportable - "
375 "use gnulib module mkostemp for portability");
379 #if @GNULIB_MKOSTEMPS@
380 /* Create a unique temporary file from TEMPLATE.
381 The last six characters of TEMPLATE before a suffix of length
382 SUFFIXLEN must be "XXXXXX";
383 they are replaced with a string that makes the file name unique.
384 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
385 and O_TEXT, O_BINARY (defined in "binary-io.h").
386 The file is then created, with the specified flags, ensuring it didn't exist
388 The file is created read-write (mask at least 0600 & ~umask), but it may be
389 world-readable and world-writable (mask 0666 & ~umask), depending on the
391 Returns the open file descriptor if successful, otherwise -1 and errno
393 # if !@HAVE_MKOSTEMPS@
394 _GL_FUNCDECL_SYS (mkostemps
, int,
395 (char * /*template*/, int /*suffixlen*/, int /*flags*/)
396 _GL_ARG_NONNULL ((1)));
398 _GL_CXXALIAS_SYS (mkostemps
, int,
399 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
400 _GL_CXXALIASWARN (mkostemps
);
401 #elif defined GNULIB_POSIXCHECK
403 # if HAVE_RAW_DECL_MKOSTEMPS
404 _GL_WARN_ON_USE (mkostemps
, "mkostemps is unportable - "
405 "use gnulib module mkostemps for portability");
410 /* Create a unique temporary file from TEMPLATE.
411 The last six characters of TEMPLATE must be "XXXXXX";
412 they are replaced with a string that makes the file name unique.
413 The file is then created, ensuring it didn't exist before.
414 The file is created read-write (mask at least 0600 & ~umask), but it may be
415 world-readable and world-writable (mask 0666 & ~umask), depending on the
417 Returns the open file descriptor if successful, otherwise -1 and errno
419 # if @REPLACE_MKSTEMP@
420 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
421 # define mkstemp rpl_mkstemp
423 _GL_FUNCDECL_RPL (mkstemp
, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
424 _GL_CXXALIAS_RPL (mkstemp
, int, (char * /*template*/));
426 # if ! @HAVE_MKSTEMP@
427 _GL_FUNCDECL_SYS (mkstemp
, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
429 _GL_CXXALIAS_SYS (mkstemp
, int, (char * /*template*/));
431 _GL_CXXALIASWARN (mkstemp
);
432 #elif defined GNULIB_POSIXCHECK
434 # if HAVE_RAW_DECL_MKSTEMP
435 _GL_WARN_ON_USE (mkstemp
, "mkstemp is unportable - "
436 "use gnulib module mkstemp for portability");
440 #if @GNULIB_MKSTEMPS@
441 /* Create a unique temporary file from TEMPLATE.
442 The last six characters of TEMPLATE prior to a suffix of length
443 SUFFIXLEN must be "XXXXXX";
444 they are replaced with a string that makes the file name unique.
445 The file is then created, ensuring it didn't exist before.
446 The file is created read-write (mask at least 0600 & ~umask), but it may be
447 world-readable and world-writable (mask 0666 & ~umask), depending on the
449 Returns the open file descriptor if successful, otherwise -1 and errno
451 # if !@HAVE_MKSTEMPS@
452 _GL_FUNCDECL_SYS (mkstemps
, int, (char * /*template*/, int /*suffixlen*/)
453 _GL_ARG_NONNULL ((1)));
455 _GL_CXXALIAS_SYS (mkstemps
, int, (char * /*template*/, int /*suffixlen*/));
456 _GL_CXXALIASWARN (mkstemps
);
457 #elif defined GNULIB_POSIXCHECK
459 # if HAVE_RAW_DECL_MKSTEMPS
460 _GL_WARN_ON_USE (mkstemps
, "mkstemps is unportable - "
461 "use gnulib module mkstemps for portability");
465 #if @GNULIB_POSIX_OPENPT@
466 /* Return an FD open to the master side of a pseudo-terminal. Flags should
467 include O_RDWR, and may also include O_NOCTTY. */
468 # if !@HAVE_POSIX_OPENPT@
469 _GL_FUNCDECL_SYS (posix_openpt
, int, (int flags
));
471 _GL_CXXALIAS_SYS (posix_openpt
, int, (int flags
));
472 _GL_CXXALIASWARN (posix_openpt
);
473 #elif defined GNULIB_POSIXCHECK
475 # if HAVE_RAW_DECL_POSIX_OPENPT
476 _GL_WARN_ON_USE (posix_openpt
, "posix_openpt is not portable - "
477 "use gnulib module posix_openpt for portability");
482 /* Return the pathname of the pseudo-terminal slave associated with
483 the master FD is open on, or NULL on errors. */
484 # if @REPLACE_PTSNAME@
485 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
487 # define ptsname rpl_ptsname
489 _GL_FUNCDECL_RPL (ptsname
, char *, (int fd
));
490 _GL_CXXALIAS_RPL (ptsname
, char *, (int fd
));
493 _GL_FUNCDECL_SYS (ptsname
, char *, (int fd
));
495 _GL_CXXALIAS_SYS (ptsname
, char *, (int fd
));
497 _GL_CXXALIASWARN (ptsname
);
498 #elif defined GNULIB_POSIXCHECK
500 # if HAVE_RAW_DECL_PTSNAME
501 _GL_WARN_ON_USE (ptsname
, "ptsname is not portable - "
502 "use gnulib module ptsname for portability");
506 #if @GNULIB_PTSNAME_R@
507 /* Set the pathname of the pseudo-terminal slave associated with
508 the master FD is open on and return 0, or set errno and return
509 non-zero on errors. */
510 # if @REPLACE_PTSNAME_R@
511 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
513 # define ptsname_r rpl_ptsname_r
515 _GL_FUNCDECL_RPL (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
516 _GL_CXXALIAS_RPL (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
518 # if !@HAVE_PTSNAME_R@
519 _GL_FUNCDECL_SYS (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
521 _GL_CXXALIAS_SYS (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
523 # ifndef GNULIB_defined_ptsname_r
524 # define GNULIB_defined_ptsname_r (!@HAVE_PTSNAME_R@ || @REPLACE_PTSNAME_R@)
526 _GL_CXXALIASWARN (ptsname_r
);
527 #elif defined GNULIB_POSIXCHECK
529 # if HAVE_RAW_DECL_PTSNAME_R
530 _GL_WARN_ON_USE (ptsname_r
, "ptsname_r is not portable - "
531 "use gnulib module ptsname_r for portability");
536 # if @REPLACE_PUTENV@
537 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
539 # define putenv rpl_putenv
541 _GL_FUNCDECL_RPL (putenv
, int, (char *string
) _GL_ARG_NONNULL ((1)));
542 _GL_CXXALIAS_RPL (putenv
, int, (char *string
));
544 _GL_CXXALIAS_SYS (putenv
, int, (char *string
));
546 _GL_CXXALIASWARN (putenv
);
550 /* Sort an array of NMEMB elements, starting at address BASE, each element
551 occupying SIZE bytes, in ascending order according to the comparison
553 # if @REPLACE_QSORT_R@
554 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
556 # define qsort_r rpl_qsort_r
558 _GL_FUNCDECL_RPL (qsort_r
, void, (void *base
, size_t nmemb
, size_t size
,
559 int (*compare
) (void const *, void const *,
561 void *arg
) _GL_ARG_NONNULL ((1, 4)));
562 _GL_CXXALIAS_RPL (qsort_r
, void, (void *base
, size_t nmemb
, size_t size
,
563 int (*compare
) (void const *, void const *,
568 _GL_FUNCDECL_SYS (qsort_r
, void, (void *base
, size_t nmemb
, size_t size
,
569 int (*compare
) (void const *, void const *,
571 void *arg
) _GL_ARG_NONNULL ((1, 4)));
573 _GL_CXXALIAS_SYS (qsort_r
, void, (void *base
, size_t nmemb
, size_t size
,
574 int (*compare
) (void const *, void const *,
578 _GL_CXXALIASWARN (qsort_r
);
579 #elif defined GNULIB_POSIXCHECK
581 # if HAVE_RAW_DECL_QSORT_R
582 _GL_WARN_ON_USE (qsort_r
, "qsort_r is not portable - "
583 "use gnulib module qsort_r for portability");
588 #if @GNULIB_RANDOM_R@
589 # if !@HAVE_RANDOM_R@
591 # define RAND_MAX 2147483647
598 # if @REPLACE_RANDOM@
599 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
601 # define random rpl_random
603 _GL_FUNCDECL_RPL (random
, long, (void));
604 _GL_CXXALIAS_RPL (random
, long, (void));
607 _GL_FUNCDECL_SYS (random
, long, (void));
609 /* Need to cast, because on Haiku, the return type is
611 _GL_CXXALIAS_SYS_CAST (random
, long, (void));
613 _GL_CXXALIASWARN (random
);
614 #elif defined GNULIB_POSIXCHECK
616 # if HAVE_RAW_DECL_RANDOM
617 _GL_WARN_ON_USE (random
, "random is unportable - "
618 "use gnulib module random for portability");
623 # if @REPLACE_RANDOM@
624 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
626 # define srandom rpl_srandom
628 _GL_FUNCDECL_RPL (srandom
, void, (unsigned int seed
));
629 _GL_CXXALIAS_RPL (srandom
, void, (unsigned int seed
));
632 _GL_FUNCDECL_SYS (srandom
, void, (unsigned int seed
));
634 /* Need to cast, because on FreeBSD, the first parameter is
635 unsigned long seed. */
636 _GL_CXXALIAS_SYS_CAST (srandom
, void, (unsigned int seed
));
638 _GL_CXXALIASWARN (srandom
);
639 #elif defined GNULIB_POSIXCHECK
641 # if HAVE_RAW_DECL_SRANDOM
642 _GL_WARN_ON_USE (srandom
, "srandom is unportable - "
643 "use gnulib module random for portability");
648 # if @REPLACE_INITSTATE@
649 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
651 # define initstate rpl_initstate
653 _GL_FUNCDECL_RPL (initstate
, char *,
654 (unsigned int seed
, char *buf
, size_t buf_size
)
655 _GL_ARG_NONNULL ((2)));
656 _GL_CXXALIAS_RPL (initstate
, char *,
657 (unsigned int seed
, char *buf
, size_t buf_size
));
659 # if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@
660 _GL_FUNCDECL_SYS (initstate
, char *,
661 (unsigned int seed
, char *buf
, size_t buf_size
)
662 _GL_ARG_NONNULL ((2)));
664 /* Need to cast, because on FreeBSD, the first parameter is
665 unsigned long seed. */
666 _GL_CXXALIAS_SYS_CAST (initstate
, char *,
667 (unsigned int seed
, char *buf
, size_t buf_size
));
669 _GL_CXXALIASWARN (initstate
);
670 #elif defined GNULIB_POSIXCHECK
672 # if HAVE_RAW_DECL_INITSTATE
673 _GL_WARN_ON_USE (initstate
, "initstate is unportable - "
674 "use gnulib module random for portability");
679 # if @REPLACE_SETSTATE@
680 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
682 # define setstate rpl_setstate
684 _GL_FUNCDECL_RPL (setstate
, char *, (char *arg_state
) _GL_ARG_NONNULL ((1)));
685 _GL_CXXALIAS_RPL (setstate
, char *, (char *arg_state
));
687 # if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@
688 _GL_FUNCDECL_SYS (setstate
, char *, (char *arg_state
) _GL_ARG_NONNULL ((1)));
690 /* Need to cast, because on Mac OS X 10.13, HP-UX, Solaris the first parameter
691 is const char *arg_state. */
692 _GL_CXXALIAS_SYS_CAST (setstate
, char *, (char *arg_state
));
694 _GL_CXXALIASWARN (setstate
);
695 #elif defined GNULIB_POSIXCHECK
697 # if HAVE_RAW_DECL_SETSTATE
698 _GL_WARN_ON_USE (setstate
, "setstate is unportable - "
699 "use gnulib module random for portability");
704 #if @GNULIB_RANDOM_R@
705 # if @REPLACE_RANDOM_R@
706 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
708 # define random_r rpl_random_r
710 _GL_FUNCDECL_RPL (random_r
, int, (struct random_data
*buf
, int32_t *result
)
711 _GL_ARG_NONNULL ((1, 2)));
712 _GL_CXXALIAS_RPL (random_r
, int, (struct random_data
*buf
, int32_t *result
));
714 # if !@HAVE_RANDOM_R@
715 _GL_FUNCDECL_SYS (random_r
, int, (struct random_data
*buf
, int32_t *result
)
716 _GL_ARG_NONNULL ((1, 2)));
718 _GL_CXXALIAS_SYS (random_r
, int, (struct random_data
*buf
, int32_t *result
));
720 _GL_CXXALIASWARN (random_r
);
721 #elif defined GNULIB_POSIXCHECK
723 # if HAVE_RAW_DECL_RANDOM_R
724 _GL_WARN_ON_USE (random_r
, "random_r is unportable - "
725 "use gnulib module random_r for portability");
729 #if @GNULIB_RANDOM_R@
730 # if @REPLACE_RANDOM_R@
731 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
733 # define srandom_r rpl_srandom_r
735 _GL_FUNCDECL_RPL (srandom_r
, int,
736 (unsigned int seed
, struct random_data
*rand_state
)
737 _GL_ARG_NONNULL ((2)));
738 _GL_CXXALIAS_RPL (srandom_r
, int,
739 (unsigned int seed
, struct random_data
*rand_state
));
741 # if !@HAVE_RANDOM_R@
742 _GL_FUNCDECL_SYS (srandom_r
, int,
743 (unsigned int seed
, struct random_data
*rand_state
)
744 _GL_ARG_NONNULL ((2)));
746 _GL_CXXALIAS_SYS (srandom_r
, int,
747 (unsigned int seed
, struct random_data
*rand_state
));
749 _GL_CXXALIASWARN (srandom_r
);
750 #elif defined GNULIB_POSIXCHECK
752 # if HAVE_RAW_DECL_SRANDOM_R
753 _GL_WARN_ON_USE (srandom_r
, "srandom_r is unportable - "
754 "use gnulib module random_r for portability");
758 #if @GNULIB_RANDOM_R@
759 # if @REPLACE_RANDOM_R@
760 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
762 # define initstate_r rpl_initstate_r
764 _GL_FUNCDECL_RPL (initstate_r
, int,
765 (unsigned int seed
, char *buf
, size_t buf_size
,
766 struct random_data
*rand_state
)
767 _GL_ARG_NONNULL ((2, 4)));
768 _GL_CXXALIAS_RPL (initstate_r
, int,
769 (unsigned int seed
, char *buf
, size_t buf_size
,
770 struct random_data
*rand_state
));
772 # if !@HAVE_RANDOM_R@
773 _GL_FUNCDECL_SYS (initstate_r
, int,
774 (unsigned int seed
, char *buf
, size_t buf_size
,
775 struct random_data
*rand_state
)
776 _GL_ARG_NONNULL ((2, 4)));
778 /* Need to cast, because on Haiku, the third parameter is
779 unsigned long buf_size. */
780 _GL_CXXALIAS_SYS_CAST (initstate_r
, int,
781 (unsigned int seed
, char *buf
, size_t buf_size
,
782 struct random_data
*rand_state
));
784 _GL_CXXALIASWARN (initstate_r
);
785 #elif defined GNULIB_POSIXCHECK
787 # if HAVE_RAW_DECL_INITSTATE_R
788 _GL_WARN_ON_USE (initstate_r
, "initstate_r is unportable - "
789 "use gnulib module random_r for portability");
793 #if @GNULIB_RANDOM_R@
794 # if @REPLACE_RANDOM_R@
795 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
797 # define setstate_r rpl_setstate_r
799 _GL_FUNCDECL_RPL (setstate_r
, int,
800 (char *arg_state
, struct random_data
*rand_state
)
801 _GL_ARG_NONNULL ((1, 2)));
802 _GL_CXXALIAS_RPL (setstate_r
, int,
803 (char *arg_state
, struct random_data
*rand_state
));
805 # if !@HAVE_RANDOM_R@
806 _GL_FUNCDECL_SYS (setstate_r
, int,
807 (char *arg_state
, struct random_data
*rand_state
)
808 _GL_ARG_NONNULL ((1, 2)));
810 /* Need to cast, because on Haiku, the first parameter is
812 _GL_CXXALIAS_SYS_CAST (setstate_r
, int,
813 (char *arg_state
, struct random_data
*rand_state
));
815 _GL_CXXALIASWARN (setstate_r
);
816 #elif defined GNULIB_POSIXCHECK
818 # if HAVE_RAW_DECL_SETSTATE_R
819 _GL_WARN_ON_USE (setstate_r
, "setstate_r is unportable - "
820 "use gnulib module random_r for portability");
825 #if @GNULIB_REALLOC_POSIX@
826 # if @REPLACE_REALLOC@
827 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
828 || _GL_USE_STDLIB_ALLOC)
830 # define realloc rpl_realloc
832 _GL_FUNCDECL_RPL (realloc
, void *, (void *ptr
, size_t size
));
833 _GL_CXXALIAS_RPL (realloc
, void *, (void *ptr
, size_t size
));
835 _GL_CXXALIAS_SYS (realloc
, void *, (void *ptr
, size_t size
));
838 _GL_CXXALIASWARN (realloc
);
840 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
842 /* Assume realloc is always declared. */
843 _GL_WARN_ON_USE (realloc
, "realloc is not POSIX compliant everywhere - "
844 "use gnulib module realloc-posix for portability");
848 #if @GNULIB_REALLOCARRAY@
849 # if ! @HAVE_REALLOCARRAY@
850 _GL_FUNCDECL_SYS (reallocarray
, void *,
851 (void *ptr
, size_t nmemb
, size_t size
));
853 _GL_CXXALIAS_SYS (reallocarray
, void *,
854 (void *ptr
, size_t nmemb
, size_t size
));
855 _GL_CXXALIASWARN (reallocarray
);
856 #elif defined GNULIB_POSIXCHECK
858 # if HAVE_RAW_DECL_REALLOCARRAY
859 _GL_WARN_ON_USE (reallocarray
, "reallocarray is not portable - "
860 "use gnulib module reallocarray for portability");
864 #if @GNULIB_REALPATH@
865 # if @REPLACE_REALPATH@
866 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
867 # define realpath rpl_realpath
869 _GL_FUNCDECL_RPL (realpath
, char *, (const char *name
, char *resolved
)
870 _GL_ARG_NONNULL ((1)));
871 _GL_CXXALIAS_RPL (realpath
, char *, (const char *name
, char *resolved
));
873 # if !@HAVE_REALPATH@
874 _GL_FUNCDECL_SYS (realpath
, char *, (const char *name
, char *resolved
)
875 _GL_ARG_NONNULL ((1)));
877 _GL_CXXALIAS_SYS (realpath
, char *, (const char *name
, char *resolved
));
879 _GL_CXXALIASWARN (realpath
);
880 #elif defined GNULIB_POSIXCHECK
882 # if HAVE_RAW_DECL_REALPATH
883 _GL_WARN_ON_USE (realpath
, "realpath is unportable - use gnulib module "
884 "canonicalize or canonicalize-lgpl for portability");
889 /* Test a user response to a question.
890 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
892 _GL_FUNCDECL_SYS (rpmatch
, int, (const char *response
) _GL_ARG_NONNULL ((1)));
894 _GL_CXXALIAS_SYS (rpmatch
, int, (const char *response
));
895 _GL_CXXALIASWARN (rpmatch
);
896 #elif defined GNULIB_POSIXCHECK
898 # if HAVE_RAW_DECL_RPMATCH
899 _GL_WARN_ON_USE (rpmatch
, "rpmatch is unportable - "
900 "use gnulib module rpmatch for portability");
904 #if @GNULIB_SECURE_GETENV@
905 /* Look up NAME in the environment, returning 0 in insecure situations. */
906 # if !@HAVE_SECURE_GETENV@
907 _GL_FUNCDECL_SYS (secure_getenv
, char *,
908 (char const *name
) _GL_ARG_NONNULL ((1)));
910 _GL_CXXALIAS_SYS (secure_getenv
, char *, (char const *name
));
911 _GL_CXXALIASWARN (secure_getenv
);
912 #elif defined GNULIB_POSIXCHECK
913 # undef secure_getenv
914 # if HAVE_RAW_DECL_SECURE_GETENV
915 _GL_WARN_ON_USE (secure_getenv
, "secure_getenv is unportable - "
916 "use gnulib module secure_getenv for portability");
921 /* Set NAME to VALUE in the environment.
922 If REPLACE is nonzero, overwrite an existing value. */
923 # if @REPLACE_SETENV@
924 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
926 # define setenv rpl_setenv
928 _GL_FUNCDECL_RPL (setenv
, int,
929 (const char *name
, const char *value
, int replace
)
930 _GL_ARG_NONNULL ((1)));
931 _GL_CXXALIAS_RPL (setenv
, int,
932 (const char *name
, const char *value
, int replace
));
934 # if !@HAVE_DECL_SETENV@
935 _GL_FUNCDECL_SYS (setenv
, int,
936 (const char *name
, const char *value
, int replace
)
937 _GL_ARG_NONNULL ((1)));
939 _GL_CXXALIAS_SYS (setenv
, int,
940 (const char *name
, const char *value
, int replace
));
942 # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
943 _GL_CXXALIASWARN (setenv
);
945 #elif defined GNULIB_POSIXCHECK
947 # if HAVE_RAW_DECL_SETENV
948 _GL_WARN_ON_USE (setenv
, "setenv is unportable - "
949 "use gnulib module setenv for portability");
954 /* Parse a double from STRING, updating ENDP if appropriate. */
955 # if @REPLACE_STRTOD@
956 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
957 # define strtod rpl_strtod
959 # define GNULIB_defined_strtod_function 1
960 _GL_FUNCDECL_RPL (strtod
, double, (const char *str
, char **endp
)
961 _GL_ARG_NONNULL ((1)));
962 _GL_CXXALIAS_RPL (strtod
, double, (const char *str
, char **endp
));
965 _GL_FUNCDECL_SYS (strtod
, double, (const char *str
, char **endp
)
966 _GL_ARG_NONNULL ((1)));
968 _GL_CXXALIAS_SYS (strtod
, double, (const char *str
, char **endp
));
971 _GL_CXXALIASWARN (strtod
);
973 #elif defined GNULIB_POSIXCHECK
975 # if HAVE_RAW_DECL_STRTOD
976 _GL_WARN_ON_USE (strtod
, "strtod is unportable - "
977 "use gnulib module strtod for portability");
982 /* Parse a 'long double' from STRING, updating ENDP if appropriate. */
983 # if @REPLACE_STRTOLD@
984 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
985 # define strtold rpl_strtold
987 # define GNULIB_defined_strtold_function 1
988 _GL_FUNCDECL_RPL (strtold
, long double, (const char *str
, char **endp
)
989 _GL_ARG_NONNULL ((1)));
990 _GL_CXXALIAS_RPL (strtold
, long double, (const char *str
, char **endp
));
993 _GL_FUNCDECL_SYS (strtold
, long double, (const char *str
, char **endp
)
994 _GL_ARG_NONNULL ((1)));
996 _GL_CXXALIAS_SYS (strtold
, long double, (const char *str
, char **endp
));
998 _GL_CXXALIASWARN (strtold
);
999 #elif defined GNULIB_POSIXCHECK
1001 # if HAVE_RAW_DECL_STRTOLD
1002 _GL_WARN_ON_USE (strtold
, "strtold is unportable - "
1003 "use gnulib module strtold for portability");
1007 #if @GNULIB_STRTOLL@
1008 /* Parse a signed integer whose textual representation starts at STRING.
1009 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1010 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1012 If ENDPTR is not NULL, the address of the first byte after the integer is
1014 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
1016 # if !@HAVE_STRTOLL@
1017 _GL_FUNCDECL_SYS (strtoll
, long long,
1018 (const char *string
, char **endptr
, int base
)
1019 _GL_ARG_NONNULL ((1)));
1021 _GL_CXXALIAS_SYS (strtoll
, long long,
1022 (const char *string
, char **endptr
, int base
));
1023 _GL_CXXALIASWARN (strtoll
);
1024 #elif defined GNULIB_POSIXCHECK
1026 # if HAVE_RAW_DECL_STRTOLL
1027 _GL_WARN_ON_USE (strtoll
, "strtoll is unportable - "
1028 "use gnulib module strtoll for portability");
1032 #if @GNULIB_STRTOULL@
1033 /* Parse an unsigned integer whose textual representation starts at STRING.
1034 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1035 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1037 If ENDPTR is not NULL, the address of the first byte after the integer is
1039 Upon overflow, the return value is ULLONG_MAX, and errno is set to
1041 # if !@HAVE_STRTOULL@
1042 _GL_FUNCDECL_SYS (strtoull
, unsigned long long,
1043 (const char *string
, char **endptr
, int base
)
1044 _GL_ARG_NONNULL ((1)));
1046 _GL_CXXALIAS_SYS (strtoull
, unsigned long long,
1047 (const char *string
, char **endptr
, int base
));
1048 _GL_CXXALIASWARN (strtoull
);
1049 #elif defined GNULIB_POSIXCHECK
1051 # if HAVE_RAW_DECL_STRTOULL
1052 _GL_WARN_ON_USE (strtoull
, "strtoull is unportable - "
1053 "use gnulib module strtoull for portability");
1057 #if @GNULIB_UNLOCKPT@
1058 /* Unlock the slave side of the pseudo-terminal whose master side is specified
1059 by FD, so that it can be opened. */
1060 # if !@HAVE_UNLOCKPT@
1061 _GL_FUNCDECL_SYS (unlockpt
, int, (int fd
));
1063 _GL_CXXALIAS_SYS (unlockpt
, int, (int fd
));
1064 _GL_CXXALIASWARN (unlockpt
);
1065 #elif defined GNULIB_POSIXCHECK
1067 # if HAVE_RAW_DECL_UNLOCKPT
1068 _GL_WARN_ON_USE (unlockpt
, "unlockpt is not portable - "
1069 "use gnulib module unlockpt for portability");
1073 #if @GNULIB_UNSETENV@
1074 /* Remove the variable NAME from the environment. */
1075 # if @REPLACE_UNSETENV@
1076 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1078 # define unsetenv rpl_unsetenv
1080 _GL_FUNCDECL_RPL (unsetenv
, int, (const char *name
) _GL_ARG_NONNULL ((1)));
1081 _GL_CXXALIAS_RPL (unsetenv
, int, (const char *name
));
1083 # if !@HAVE_DECL_UNSETENV@
1084 _GL_FUNCDECL_SYS (unsetenv
, int, (const char *name
) _GL_ARG_NONNULL ((1)));
1086 _GL_CXXALIAS_SYS (unsetenv
, int, (const char *name
));
1088 # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
1089 _GL_CXXALIASWARN (unsetenv
);
1091 #elif defined GNULIB_POSIXCHECK
1093 # if HAVE_RAW_DECL_UNSETENV
1094 _GL_WARN_ON_USE (unsetenv
, "unsetenv is unportable - "
1095 "use gnulib module unsetenv for portability");
1099 /* Convert a wide character to a multibyte character. */
1101 # if @REPLACE_WCTOMB@
1102 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1104 # define wctomb rpl_wctomb
1106 _GL_FUNCDECL_RPL (wctomb
, int, (char *s
, wchar_t wc
));
1107 _GL_CXXALIAS_RPL (wctomb
, int, (char *s
, wchar_t wc
));
1109 _GL_CXXALIAS_SYS (wctomb
, int, (char *s
, wchar_t wc
));
1112 _GL_CXXALIASWARN (wctomb
);
1117 #endif /* _@GUARD_PREFIX@_STDLIB_H */
1118 #endif /* _@GUARD_PREFIX@_STDLIB_H */
This page took 0.051027 seconds and 5 git commands to generate.