1 /* A GNU-like <stdlib.h>.
3 Copyright (C) 1995, 2001-2004, 2006-2013 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 Mac OS X 10.3, only <unistd.h> declares mkstemp. */
91 /* On Mac OS 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 __attribute__ feature is available in gcc versions 2.5 and later.
98 The attribute __pure__ was added in gcc 2.96. */
99 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
100 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
102 # define _GL_ATTRIBUTE_PURE /* empty */
105 /* The definition of _Noreturn is copied here. */
107 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
109 /* The definition of _GL_ARG_NONNULL is copied here. */
111 /* The definition of _GL_WARN_ON_USE is copied here. */
114 /* Some systems do not define EXIT_*, despite otherwise supporting C89. */
116 # define EXIT_SUCCESS 0
118 /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
119 with proper operation of xargs. */
121 # define EXIT_FAILURE 1
122 #elif EXIT_FAILURE != 1
124 # define EXIT_FAILURE 1
129 /* Terminate the current process with the given return code, without running
130 the 'atexit' handlers. */
132 _GL_FUNCDECL_SYS (_Exit
, _Noreturn
void, (int status
));
134 _GL_CXXALIAS_SYS (_Exit
, void, (int status
));
135 _GL_CXXALIASWARN (_Exit
);
136 #elif defined GNULIB_POSIXCHECK
138 # if HAVE_RAW_DECL__EXIT
139 _GL_WARN_ON_USE (_Exit
, "_Exit is unportable - "
140 "use gnulib module _Exit for portability");
146 /* Parse a signed decimal integer.
147 Returns the value of the integer. Errors are not detected. */
149 _GL_FUNCDECL_SYS (atoll
, long long, (const char *string
)
151 _GL_ARG_NONNULL ((1)));
153 _GL_CXXALIAS_SYS (atoll
, long long, (const char *string
));
154 _GL_CXXALIASWARN (atoll
);
155 #elif defined GNULIB_POSIXCHECK
157 # if HAVE_RAW_DECL_ATOLL
158 _GL_WARN_ON_USE (atoll
, "atoll is unportable - "
159 "use gnulib module atoll for portability");
163 #if @GNULIB_CALLOC_POSIX@
164 # if @REPLACE_CALLOC@
165 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
167 # define calloc rpl_calloc
169 _GL_FUNCDECL_RPL (calloc
, void *, (size_t nmemb
, size_t size
));
170 _GL_CXXALIAS_RPL (calloc
, void *, (size_t nmemb
, size_t size
));
172 _GL_CXXALIAS_SYS (calloc
, void *, (size_t nmemb
, size_t size
));
174 _GL_CXXALIASWARN (calloc
);
175 #elif defined GNULIB_POSIXCHECK
177 /* Assume calloc is always declared. */
178 _GL_WARN_ON_USE (calloc
, "calloc is not POSIX compliant everywhere - "
179 "use gnulib module calloc-posix for portability");
182 #if @GNULIB_CANONICALIZE_FILE_NAME@
183 # if @REPLACE_CANONICALIZE_FILE_NAME@
184 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
185 # define canonicalize_file_name rpl_canonicalize_file_name
187 _GL_FUNCDECL_RPL (canonicalize_file_name
, char *, (const char *name
)
188 _GL_ARG_NONNULL ((1)));
189 _GL_CXXALIAS_RPL (canonicalize_file_name
, char *, (const char *name
));
191 # if !@HAVE_CANONICALIZE_FILE_NAME@
192 _GL_FUNCDECL_SYS (canonicalize_file_name
, char *, (const char *name
)
193 _GL_ARG_NONNULL ((1)));
195 _GL_CXXALIAS_SYS (canonicalize_file_name
, char *, (const char *name
));
197 _GL_CXXALIASWARN (canonicalize_file_name
);
198 #elif defined GNULIB_POSIXCHECK
199 # undef canonicalize_file_name
200 # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
201 _GL_WARN_ON_USE (canonicalize_file_name
,
202 "canonicalize_file_name is unportable - "
203 "use gnulib module canonicalize-lgpl for portability");
207 #if @GNULIB_GETLOADAVG@
208 /* Store max(NELEM,3) load average numbers in LOADAVG[].
209 The three numbers are the load average of the last 1 minute, the last 5
210 minutes, and the last 15 minutes, respectively.
211 LOADAVG is an array of NELEM numbers. */
212 # if !@HAVE_DECL_GETLOADAVG@
213 _GL_FUNCDECL_SYS (getloadavg
, int, (double loadavg
[], int nelem
)
214 _GL_ARG_NONNULL ((1)));
216 _GL_CXXALIAS_SYS (getloadavg
, int, (double loadavg
[], int nelem
));
217 _GL_CXXALIASWARN (getloadavg
);
218 #elif defined GNULIB_POSIXCHECK
220 # if HAVE_RAW_DECL_GETLOADAVG
221 _GL_WARN_ON_USE (getloadavg
, "getloadavg is not portable - "
222 "use gnulib module getloadavg for portability");
226 #if @GNULIB_GETSUBOPT@
227 /* Assuming *OPTIONP is a comma separated list of elements of the form
228 "token" or "token=value", getsubopt parses the first of these elements.
229 If the first element refers to a "token" that is member of the given
230 NULL-terminated array of tokens:
231 - It replaces the comma with a NUL byte, updates *OPTIONP to point past
232 the first option and the comma, sets *VALUEP to the value of the
233 element (or NULL if it doesn't contain an "=" sign),
234 - It returns the index of the "token" in the given array of tokens.
235 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
236 For more details see the POSIX:2001 specification.
237 http://www.opengroup.org/susv3xsh/getsubopt.html */
238 # if !@HAVE_GETSUBOPT@
239 _GL_FUNCDECL_SYS (getsubopt
, int,
240 (char **optionp
, char *const *tokens
, char **valuep
)
241 _GL_ARG_NONNULL ((1, 2, 3)));
243 _GL_CXXALIAS_SYS (getsubopt
, int,
244 (char **optionp
, char *const *tokens
, char **valuep
));
245 _GL_CXXALIASWARN (getsubopt
);
246 #elif defined GNULIB_POSIXCHECK
248 # if HAVE_RAW_DECL_GETSUBOPT
249 _GL_WARN_ON_USE (getsubopt
, "getsubopt is unportable - "
250 "use gnulib module getsubopt for portability");
255 /* Change the ownership and access permission of the slave side of the
256 pseudo-terminal whose master side is specified by FD. */
258 _GL_FUNCDECL_SYS (grantpt
, int, (int fd
));
260 _GL_CXXALIAS_SYS (grantpt
, int, (int fd
));
261 _GL_CXXALIASWARN (grantpt
);
262 #elif defined GNULIB_POSIXCHECK
264 # if HAVE_RAW_DECL_GRANTPT
265 _GL_WARN_ON_USE (grantpt
, "grantpt is not portable - "
266 "use gnulib module grantpt for portability");
270 /* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
271 rely on GNU or POSIX semantics for malloc and realloc (for example,
272 by never specifying a zero size), so it does not need malloc or
273 realloc to be redefined. */
274 #if @GNULIB_MALLOC_POSIX@
275 # if @REPLACE_MALLOC@
276 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
277 || _GL_USE_STDLIB_ALLOC)
279 # define malloc rpl_malloc
281 _GL_FUNCDECL_RPL (malloc
, void *, (size_t size
));
282 _GL_CXXALIAS_RPL (malloc
, void *, (size_t size
));
284 _GL_CXXALIAS_SYS (malloc
, void *, (size_t size
));
286 _GL_CXXALIASWARN (malloc
);
287 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
289 /* Assume malloc is always declared. */
290 _GL_WARN_ON_USE (malloc
, "malloc is not POSIX compliant everywhere - "
291 "use gnulib module malloc-posix for portability");
294 /* Convert a multibyte character to a wide character. */
296 # if @REPLACE_MBTOWC@
297 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
299 # define mbtowc rpl_mbtowc
301 _GL_FUNCDECL_RPL (mbtowc
, int, (wchar_t *pwc
, const char *s
, size_t n
));
302 _GL_CXXALIAS_RPL (mbtowc
, int, (wchar_t *pwc
, const char *s
, size_t n
));
304 _GL_CXXALIAS_SYS (mbtowc
, int, (wchar_t *pwc
, const char *s
, size_t n
));
306 _GL_CXXALIASWARN (mbtowc
);
310 /* Create a unique temporary directory from TEMPLATE.
311 The last six characters of TEMPLATE must be "XXXXXX";
312 they are replaced with a string that makes the directory name unique.
313 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
314 The directory is created mode 700. */
316 _GL_FUNCDECL_SYS (mkdtemp
, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
318 _GL_CXXALIAS_SYS (mkdtemp
, char *, (char * /*template*/));
319 _GL_CXXALIASWARN (mkdtemp
);
320 #elif defined GNULIB_POSIXCHECK
322 # if HAVE_RAW_DECL_MKDTEMP
323 _GL_WARN_ON_USE (mkdtemp
, "mkdtemp is unportable - "
324 "use gnulib module mkdtemp for portability");
328 #if @GNULIB_MKOSTEMP@
329 /* Create a unique temporary file from TEMPLATE.
330 The last six characters of TEMPLATE must be "XXXXXX";
331 they are replaced with a string that makes the file name unique.
332 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
333 and O_TEXT, O_BINARY (defined in "binary-io.h").
334 The file is then created, with the specified flags, ensuring it didn't exist
336 The file is created read-write (mask at least 0600 & ~umask), but it may be
337 world-readable and world-writable (mask 0666 & ~umask), depending on the
339 Returns the open file descriptor if successful, otherwise -1 and errno
341 # if !@HAVE_MKOSTEMP@
342 _GL_FUNCDECL_SYS (mkostemp
, int, (char * /*template*/, int /*flags*/)
343 _GL_ARG_NONNULL ((1)));
345 _GL_CXXALIAS_SYS (mkostemp
, int, (char * /*template*/, int /*flags*/));
346 _GL_CXXALIASWARN (mkostemp
);
347 #elif defined GNULIB_POSIXCHECK
349 # if HAVE_RAW_DECL_MKOSTEMP
350 _GL_WARN_ON_USE (mkostemp
, "mkostemp is unportable - "
351 "use gnulib module mkostemp for portability");
355 #if @GNULIB_MKOSTEMPS@
356 /* Create a unique temporary file from TEMPLATE.
357 The last six characters of TEMPLATE before a suffix of length
358 SUFFIXLEN must be "XXXXXX";
359 they are replaced with a string that makes the file name unique.
360 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
361 and O_TEXT, O_BINARY (defined in "binary-io.h").
362 The file is then created, with the specified flags, ensuring it didn't exist
364 The file is created read-write (mask at least 0600 & ~umask), but it may be
365 world-readable and world-writable (mask 0666 & ~umask), depending on the
367 Returns the open file descriptor if successful, otherwise -1 and errno
369 # if !@HAVE_MKOSTEMPS@
370 _GL_FUNCDECL_SYS (mkostemps
, int,
371 (char * /*template*/, int /*suffixlen*/, int /*flags*/)
372 _GL_ARG_NONNULL ((1)));
374 _GL_CXXALIAS_SYS (mkostemps
, int,
375 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
376 _GL_CXXALIASWARN (mkostemps
);
377 #elif defined GNULIB_POSIXCHECK
379 # if HAVE_RAW_DECL_MKOSTEMPS
380 _GL_WARN_ON_USE (mkostemps
, "mkostemps is unportable - "
381 "use gnulib module mkostemps for portability");
386 /* Create a unique temporary file from TEMPLATE.
387 The last six characters of TEMPLATE must be "XXXXXX";
388 they are replaced with a string that makes the file name unique.
389 The file is then created, ensuring it didn't exist before.
390 The file is created read-write (mask at least 0600 & ~umask), but it may be
391 world-readable and world-writable (mask 0666 & ~umask), depending on the
393 Returns the open file descriptor if successful, otherwise -1 and errno
395 # if @REPLACE_MKSTEMP@
396 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
397 # define mkstemp rpl_mkstemp
399 _GL_FUNCDECL_RPL (mkstemp
, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
400 _GL_CXXALIAS_RPL (mkstemp
, int, (char * /*template*/));
402 # if ! @HAVE_MKSTEMP@
403 _GL_FUNCDECL_SYS (mkstemp
, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
405 _GL_CXXALIAS_SYS (mkstemp
, int, (char * /*template*/));
407 _GL_CXXALIASWARN (mkstemp
);
408 #elif defined GNULIB_POSIXCHECK
410 # if HAVE_RAW_DECL_MKSTEMP
411 _GL_WARN_ON_USE (mkstemp
, "mkstemp is unportable - "
412 "use gnulib module mkstemp for portability");
416 #if @GNULIB_MKSTEMPS@
417 /* Create a unique temporary file from TEMPLATE.
418 The last six characters of TEMPLATE prior to a suffix of length
419 SUFFIXLEN must be "XXXXXX";
420 they are replaced with a string that makes the file name unique.
421 The file is then created, ensuring it didn't exist before.
422 The file is created read-write (mask at least 0600 & ~umask), but it may be
423 world-readable and world-writable (mask 0666 & ~umask), depending on the
425 Returns the open file descriptor if successful, otherwise -1 and errno
427 # if !@HAVE_MKSTEMPS@
428 _GL_FUNCDECL_SYS (mkstemps
, int, (char * /*template*/, int /*suffixlen*/)
429 _GL_ARG_NONNULL ((1)));
431 _GL_CXXALIAS_SYS (mkstemps
, int, (char * /*template*/, int /*suffixlen*/));
432 _GL_CXXALIASWARN (mkstemps
);
433 #elif defined GNULIB_POSIXCHECK
435 # if HAVE_RAW_DECL_MKSTEMPS
436 _GL_WARN_ON_USE (mkstemps
, "mkstemps is unportable - "
437 "use gnulib module mkstemps for portability");
441 #if @GNULIB_POSIX_OPENPT@
442 /* Return an FD open to the master side of a pseudo-terminal. Flags should
443 include O_RDWR, and may also include O_NOCTTY. */
444 # if !@HAVE_POSIX_OPENPT@
445 _GL_FUNCDECL_SYS (posix_openpt
, int, (int flags
));
447 _GL_CXXALIAS_SYS (posix_openpt
, int, (int flags
));
448 _GL_CXXALIASWARN (posix_openpt
);
449 #elif defined GNULIB_POSIXCHECK
451 # if HAVE_RAW_DECL_POSIX_OPENPT
452 _GL_WARN_ON_USE (posix_openpt
, "posix_openpt is not portable - "
453 "use gnulib module posix_openpt for portability");
458 /* Return the pathname of the pseudo-terminal slave associated with
459 the master FD is open on, or NULL on errors. */
460 # if @REPLACE_PTSNAME@
461 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
463 # define ptsname rpl_ptsname
465 _GL_FUNCDECL_RPL (ptsname
, char *, (int fd
));
466 _GL_CXXALIAS_RPL (ptsname
, char *, (int fd
));
469 _GL_FUNCDECL_SYS (ptsname
, char *, (int fd
));
471 _GL_CXXALIAS_SYS (ptsname
, char *, (int fd
));
473 _GL_CXXALIASWARN (ptsname
);
474 #elif defined GNULIB_POSIXCHECK
476 # if HAVE_RAW_DECL_PTSNAME
477 _GL_WARN_ON_USE (ptsname
, "ptsname is not portable - "
478 "use gnulib module ptsname for portability");
482 #if @GNULIB_PTSNAME_R@
483 /* Set the pathname of the pseudo-terminal slave associated with
484 the master FD is open on and return 0, or set errno and return
485 non-zero on errors. */
486 # if @REPLACE_PTSNAME_R@
487 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
489 # define ptsname_r rpl_ptsname_r
491 _GL_FUNCDECL_RPL (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
492 _GL_CXXALIAS_RPL (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
494 # if !@HAVE_PTSNAME_R@
495 _GL_FUNCDECL_SYS (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
497 _GL_CXXALIAS_SYS (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
499 _GL_CXXALIASWARN (ptsname_r
);
500 #elif defined GNULIB_POSIXCHECK
502 # if HAVE_RAW_DECL_PTSNAME_R
503 _GL_WARN_ON_USE (ptsname_r
, "ptsname_r is not portable - "
504 "use gnulib module ptsname_r for portability");
509 # if @REPLACE_PUTENV@
510 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
512 # define putenv rpl_putenv
514 _GL_FUNCDECL_RPL (putenv
, int, (char *string
) _GL_ARG_NONNULL ((1)));
515 _GL_CXXALIAS_RPL (putenv
, int, (char *string
));
517 _GL_CXXALIAS_SYS (putenv
, int, (char *string
));
519 _GL_CXXALIASWARN (putenv
);
523 #if @GNULIB_RANDOM_R@
524 # if !@HAVE_RANDOM_R@
526 # define RAND_MAX 2147483647
534 _GL_FUNCDECL_SYS (random
, long, (void));
536 _GL_CXXALIAS_SYS (random
, long, (void));
537 _GL_CXXALIASWARN (random
);
538 #elif defined GNULIB_POSIXCHECK
540 # if HAVE_RAW_DECL_RANDOM
541 _GL_WARN_ON_USE (random
, "random is unportable - "
542 "use gnulib module random for portability");
548 _GL_FUNCDECL_SYS (srandom
, void, (unsigned int seed
));
550 _GL_CXXALIAS_SYS (srandom
, void, (unsigned int seed
));
551 _GL_CXXALIASWARN (srandom
);
552 #elif defined GNULIB_POSIXCHECK
554 # if HAVE_RAW_DECL_SRANDOM
555 _GL_WARN_ON_USE (srandom
, "srandom is unportable - "
556 "use gnulib module random for portability");
562 _GL_FUNCDECL_SYS (initstate
, char *,
563 (unsigned int seed
, char *buf
, size_t buf_size
)
564 _GL_ARG_NONNULL ((2)));
566 _GL_CXXALIAS_SYS (initstate
, char *,
567 (unsigned int seed
, char *buf
, size_t buf_size
));
568 _GL_CXXALIASWARN (initstate
);
569 #elif defined GNULIB_POSIXCHECK
571 # if HAVE_RAW_DECL_INITSTATE_R
572 _GL_WARN_ON_USE (initstate
, "initstate is unportable - "
573 "use gnulib module random for portability");
579 _GL_FUNCDECL_SYS (setstate
, char *, (char *arg_state
) _GL_ARG_NONNULL ((1)));
581 _GL_CXXALIAS_SYS (setstate
, char *, (char *arg_state
));
582 _GL_CXXALIASWARN (setstate
);
583 #elif defined GNULIB_POSIXCHECK
585 # if HAVE_RAW_DECL_SETSTATE_R
586 _GL_WARN_ON_USE (setstate
, "setstate is unportable - "
587 "use gnulib module random for portability");
592 #if @GNULIB_RANDOM_R@
593 # if @REPLACE_RANDOM_R@
594 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
596 # define random_r rpl_random_r
598 _GL_FUNCDECL_RPL (random_r
, int, (struct random_data
*buf
, int32_t *result
)
599 _GL_ARG_NONNULL ((1, 2)));
600 _GL_CXXALIAS_RPL (random_r
, int, (struct random_data
*buf
, int32_t *result
));
602 # if !@HAVE_RANDOM_R@
603 _GL_FUNCDECL_SYS (random_r
, int, (struct random_data
*buf
, int32_t *result
)
604 _GL_ARG_NONNULL ((1, 2)));
606 _GL_CXXALIAS_SYS (random_r
, int, (struct random_data
*buf
, int32_t *result
));
608 _GL_CXXALIASWARN (random_r
);
609 #elif defined GNULIB_POSIXCHECK
611 # if HAVE_RAW_DECL_RANDOM_R
612 _GL_WARN_ON_USE (random_r
, "random_r is unportable - "
613 "use gnulib module random_r for portability");
617 #if @GNULIB_RANDOM_R@
618 # if @REPLACE_RANDOM_R@
619 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
621 # define srandom_r rpl_srandom_r
623 _GL_FUNCDECL_RPL (srandom_r
, int,
624 (unsigned int seed
, struct random_data
*rand_state
)
625 _GL_ARG_NONNULL ((2)));
626 _GL_CXXALIAS_RPL (srandom_r
, int,
627 (unsigned int seed
, struct random_data
*rand_state
));
629 # if !@HAVE_RANDOM_R@
630 _GL_FUNCDECL_SYS (srandom_r
, int,
631 (unsigned int seed
, struct random_data
*rand_state
)
632 _GL_ARG_NONNULL ((2)));
634 _GL_CXXALIAS_SYS (srandom_r
, int,
635 (unsigned int seed
, struct random_data
*rand_state
));
637 _GL_CXXALIASWARN (srandom_r
);
638 #elif defined GNULIB_POSIXCHECK
640 # if HAVE_RAW_DECL_SRANDOM_R
641 _GL_WARN_ON_USE (srandom_r
, "srandom_r is unportable - "
642 "use gnulib module random_r for portability");
646 #if @GNULIB_RANDOM_R@
647 # if @REPLACE_RANDOM_R@
648 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
650 # define initstate_r rpl_initstate_r
652 _GL_FUNCDECL_RPL (initstate_r
, int,
653 (unsigned int seed
, char *buf
, size_t buf_size
,
654 struct random_data
*rand_state
)
655 _GL_ARG_NONNULL ((2, 4)));
656 _GL_CXXALIAS_RPL (initstate_r
, int,
657 (unsigned int seed
, char *buf
, size_t buf_size
,
658 struct random_data
*rand_state
));
660 # if !@HAVE_RANDOM_R@
661 _GL_FUNCDECL_SYS (initstate_r
, int,
662 (unsigned int seed
, char *buf
, size_t buf_size
,
663 struct random_data
*rand_state
)
664 _GL_ARG_NONNULL ((2, 4)));
666 _GL_CXXALIAS_SYS (initstate_r
, int,
667 (unsigned int seed
, char *buf
, size_t buf_size
,
668 struct random_data
*rand_state
));
670 _GL_CXXALIASWARN (initstate_r
);
671 #elif defined GNULIB_POSIXCHECK
673 # if HAVE_RAW_DECL_INITSTATE_R
674 _GL_WARN_ON_USE (initstate_r
, "initstate_r is unportable - "
675 "use gnulib module random_r for portability");
679 #if @GNULIB_RANDOM_R@
680 # if @REPLACE_RANDOM_R@
681 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
683 # define setstate_r rpl_setstate_r
685 _GL_FUNCDECL_RPL (setstate_r
, int,
686 (char *arg_state
, struct random_data
*rand_state
)
687 _GL_ARG_NONNULL ((1, 2)));
688 _GL_CXXALIAS_RPL (setstate_r
, int,
689 (char *arg_state
, struct random_data
*rand_state
));
691 # if !@HAVE_RANDOM_R@
692 _GL_FUNCDECL_SYS (setstate_r
, int,
693 (char *arg_state
, struct random_data
*rand_state
)
694 _GL_ARG_NONNULL ((1, 2)));
696 _GL_CXXALIAS_SYS (setstate_r
, int,
697 (char *arg_state
, struct random_data
*rand_state
));
699 _GL_CXXALIASWARN (setstate_r
);
700 #elif defined GNULIB_POSIXCHECK
702 # if HAVE_RAW_DECL_SETSTATE_R
703 _GL_WARN_ON_USE (setstate_r
, "setstate_r is unportable - "
704 "use gnulib module random_r for portability");
709 #if @GNULIB_REALLOC_POSIX@
710 # if @REPLACE_REALLOC@
711 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
712 || _GL_USE_STDLIB_ALLOC)
714 # define realloc rpl_realloc
716 _GL_FUNCDECL_RPL (realloc
, void *, (void *ptr
, size_t size
));
717 _GL_CXXALIAS_RPL (realloc
, void *, (void *ptr
, size_t size
));
719 _GL_CXXALIAS_SYS (realloc
, void *, (void *ptr
, size_t size
));
721 _GL_CXXALIASWARN (realloc
);
722 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
724 /* Assume realloc is always declared. */
725 _GL_WARN_ON_USE (realloc
, "realloc is not POSIX compliant everywhere - "
726 "use gnulib module realloc-posix for portability");
729 #if @GNULIB_REALPATH@
730 # if @REPLACE_REALPATH@
731 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
732 # define realpath rpl_realpath
734 _GL_FUNCDECL_RPL (realpath
, char *, (const char *name
, char *resolved
)
735 _GL_ARG_NONNULL ((1)));
736 _GL_CXXALIAS_RPL (realpath
, char *, (const char *name
, char *resolved
));
738 # if !@HAVE_REALPATH@
739 _GL_FUNCDECL_SYS (realpath
, char *, (const char *name
, char *resolved
)
740 _GL_ARG_NONNULL ((1)));
742 _GL_CXXALIAS_SYS (realpath
, char *, (const char *name
, char *resolved
));
744 _GL_CXXALIASWARN (realpath
);
745 #elif defined GNULIB_POSIXCHECK
747 # if HAVE_RAW_DECL_REALPATH
748 _GL_WARN_ON_USE (realpath
, "realpath is unportable - use gnulib module "
749 "canonicalize or canonicalize-lgpl for portability");
754 /* Test a user response to a question.
755 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
757 _GL_FUNCDECL_SYS (rpmatch
, int, (const char *response
) _GL_ARG_NONNULL ((1)));
759 _GL_CXXALIAS_SYS (rpmatch
, int, (const char *response
));
760 _GL_CXXALIASWARN (rpmatch
);
761 #elif defined GNULIB_POSIXCHECK
763 # if HAVE_RAW_DECL_RPMATCH
764 _GL_WARN_ON_USE (rpmatch
, "rpmatch is unportable - "
765 "use gnulib module rpmatch for portability");
770 /* Set NAME to VALUE in the environment.
771 If REPLACE is nonzero, overwrite an existing value. */
772 # if @REPLACE_SETENV@
773 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
775 # define setenv rpl_setenv
777 _GL_FUNCDECL_RPL (setenv
, int,
778 (const char *name
, const char *value
, int replace
)
779 _GL_ARG_NONNULL ((1)));
780 _GL_CXXALIAS_RPL (setenv
, int,
781 (const char *name
, const char *value
, int replace
));
783 # if !@HAVE_DECL_SETENV@
784 _GL_FUNCDECL_SYS (setenv
, int,
785 (const char *name
, const char *value
, int replace
)
786 _GL_ARG_NONNULL ((1)));
788 _GL_CXXALIAS_SYS (setenv
, int,
789 (const char *name
, const char *value
, int replace
));
791 # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
792 _GL_CXXALIASWARN (setenv
);
794 #elif defined GNULIB_POSIXCHECK
796 # if HAVE_RAW_DECL_SETENV
797 _GL_WARN_ON_USE (setenv
, "setenv is unportable - "
798 "use gnulib module setenv for portability");
803 /* Parse a double from STRING, updating ENDP if appropriate. */
804 # if @REPLACE_STRTOD@
805 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
806 # define strtod rpl_strtod
808 _GL_FUNCDECL_RPL (strtod
, double, (const char *str
, char **endp
)
809 _GL_ARG_NONNULL ((1)));
810 _GL_CXXALIAS_RPL (strtod
, double, (const char *str
, char **endp
));
813 _GL_FUNCDECL_SYS (strtod
, double, (const char *str
, char **endp
)
814 _GL_ARG_NONNULL ((1)));
816 _GL_CXXALIAS_SYS (strtod
, double, (const char *str
, char **endp
));
818 _GL_CXXALIASWARN (strtod
);
819 #elif defined GNULIB_POSIXCHECK
821 # if HAVE_RAW_DECL_STRTOD
822 _GL_WARN_ON_USE (strtod
, "strtod is unportable - "
823 "use gnulib module strtod for portability");
828 /* Parse a signed integer whose textual representation starts at STRING.
829 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
830 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
832 If ENDPTR is not NULL, the address of the first byte after the integer is
834 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
837 _GL_FUNCDECL_SYS (strtoll
, long long,
838 (const char *string
, char **endptr
, int base
)
839 _GL_ARG_NONNULL ((1)));
841 _GL_CXXALIAS_SYS (strtoll
, long long,
842 (const char *string
, char **endptr
, int base
));
843 _GL_CXXALIASWARN (strtoll
);
844 #elif defined GNULIB_POSIXCHECK
846 # if HAVE_RAW_DECL_STRTOLL
847 _GL_WARN_ON_USE (strtoll
, "strtoll is unportable - "
848 "use gnulib module strtoll for portability");
852 #if @GNULIB_STRTOULL@
853 /* Parse an unsigned integer whose textual representation starts at STRING.
854 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
855 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
857 If ENDPTR is not NULL, the address of the first byte after the integer is
859 Upon overflow, the return value is ULLONG_MAX, and errno is set to
861 # if !@HAVE_STRTOULL@
862 _GL_FUNCDECL_SYS (strtoull
, unsigned long long,
863 (const char *string
, char **endptr
, int base
)
864 _GL_ARG_NONNULL ((1)));
866 _GL_CXXALIAS_SYS (strtoull
, unsigned long long,
867 (const char *string
, char **endptr
, int base
));
868 _GL_CXXALIASWARN (strtoull
);
869 #elif defined GNULIB_POSIXCHECK
871 # if HAVE_RAW_DECL_STRTOULL
872 _GL_WARN_ON_USE (strtoull
, "strtoull is unportable - "
873 "use gnulib module strtoull for portability");
877 #if @GNULIB_UNLOCKPT@
878 /* Unlock the slave side of the pseudo-terminal whose master side is specified
879 by FD, so that it can be opened. */
880 # if !@HAVE_UNLOCKPT@
881 _GL_FUNCDECL_SYS (unlockpt
, int, (int fd
));
883 _GL_CXXALIAS_SYS (unlockpt
, int, (int fd
));
884 _GL_CXXALIASWARN (unlockpt
);
885 #elif defined GNULIB_POSIXCHECK
887 # if HAVE_RAW_DECL_UNLOCKPT
888 _GL_WARN_ON_USE (unlockpt
, "unlockpt is not portable - "
889 "use gnulib module unlockpt for portability");
893 #if @GNULIB_UNSETENV@
894 /* Remove the variable NAME from the environment. */
895 # if @REPLACE_UNSETENV@
896 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
898 # define unsetenv rpl_unsetenv
900 _GL_FUNCDECL_RPL (unsetenv
, int, (const char *name
) _GL_ARG_NONNULL ((1)));
901 _GL_CXXALIAS_RPL (unsetenv
, int, (const char *name
));
903 # if !@HAVE_DECL_UNSETENV@
904 _GL_FUNCDECL_SYS (unsetenv
, int, (const char *name
) _GL_ARG_NONNULL ((1)));
906 _GL_CXXALIAS_SYS (unsetenv
, int, (const char *name
));
908 # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
909 _GL_CXXALIASWARN (unsetenv
);
911 #elif defined GNULIB_POSIXCHECK
913 # if HAVE_RAW_DECL_UNSETENV
914 _GL_WARN_ON_USE (unsetenv
, "unsetenv is unportable - "
915 "use gnulib module unsetenv for portability");
919 /* Convert a wide character to a multibyte character. */
921 # if @REPLACE_WCTOMB@
922 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
924 # define wctomb rpl_wctomb
926 _GL_FUNCDECL_RPL (wctomb
, int, (char *s
, wchar_t wc
));
927 _GL_CXXALIAS_RPL (wctomb
, int, (char *s
, wchar_t wc
));
929 _GL_CXXALIAS_SYS (wctomb
, int, (char *s
, wchar_t wc
));
931 _GL_CXXALIASWARN (wctomb
);
935 #endif /* _@GUARD_PREFIX@_STDLIB_H */
936 #endif /* _@GUARD_PREFIX@_STDLIB_H */