1 /* A GNU-like <stdlib.h>.
3 Copyright (C) 1995, 2001-2004, 2006-2011 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. */
33 /* The include_next requires a split double-inclusion guard. */
34 #@INCLUDE_NEXT@ @NEXT_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>
54 /* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
55 from <stdlib.h> if _REENTRANT is defined. Include it whenever we need
56 'struct random_data'. */
61 # if !@HAVE_STRUCT_RANDOM_DATA@ || !@HAVE_RANDOM_R@
65 # if !@HAVE_STRUCT_RANDOM_DATA@
66 /* Define 'struct random_data'.
67 But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
68 # if !GNULIB_defined_struct_random_data
71 int32_t *fptr
; /* Front pointer. */
72 int32_t *rptr
; /* Rear pointer. */
73 int32_t *state
; /* Array of state values. */
74 int rand_type
; /* Type of random number generator. */
75 int rand_deg
; /* Degree of random number generator. */
76 int rand_sep
; /* Distance between front and rear. */
77 int32_t *end_ptr
; /* Pointer behind state table. */
79 # define GNULIB_defined_struct_random_data 1
84 #if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
85 /* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
86 /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
87 /* But avoid namespace pollution on glibc systems and native Windows. */
91 #if 3 <= __GNUC__ || __GNUC__ == 2 && 8 <= __GNUC_MINOR__
92 # define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
94 # define _GL_ATTRIBUTE_NORETURN
97 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
99 /* The definition of _GL_ARG_NONNULL is copied here. */
101 /* The definition of _GL_WARN_ON_USE is copied here. */
104 /* Some systems do not define EXIT_*, despite otherwise supporting C89. */
106 # define EXIT_SUCCESS 0
108 /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
109 with proper operation of xargs. */
111 # define EXIT_FAILURE 1
112 #elif EXIT_FAILURE != 1
114 # define EXIT_FAILURE 1
119 /* Terminate the current process with the given return code, without running
120 the 'atexit' handlers. */
122 _GL_FUNCDECL_SYS (_Exit
, void, (int status
) _GL_ATTRIBUTE_NORETURN
);
124 _GL_CXXALIAS_SYS (_Exit
, void, (int status
));
125 _GL_CXXALIASWARN (_Exit
);
126 #elif defined GNULIB_POSIXCHECK
128 # if HAVE_RAW_DECL__EXIT
129 _GL_WARN_ON_USE (_Exit
, "_Exit is unportable - "
130 "use gnulib module _Exit for portability");
136 /* Parse a signed decimal integer.
137 Returns the value of the integer. Errors are not detected. */
139 _GL_FUNCDECL_SYS (atoll
, long long, (const char *string
) _GL_ARG_NONNULL ((1)));
141 _GL_CXXALIAS_SYS (atoll
, long long, (const char *string
));
142 _GL_CXXALIASWARN (atoll
);
143 #elif defined GNULIB_POSIXCHECK
145 # if HAVE_RAW_DECL_ATOLL
146 _GL_WARN_ON_USE (atoll
, "atoll is unportable - "
147 "use gnulib module atoll for portability");
151 #if @GNULIB_CALLOC_POSIX@
152 # if @REPLACE_CALLOC@
153 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
155 # define calloc rpl_calloc
157 _GL_FUNCDECL_RPL (calloc
, void *, (size_t nmemb
, size_t size
));
158 _GL_CXXALIAS_RPL (calloc
, void *, (size_t nmemb
, size_t size
));
160 _GL_CXXALIAS_SYS (calloc
, void *, (size_t nmemb
, size_t size
));
162 _GL_CXXALIASWARN (calloc
);
163 #elif defined GNULIB_POSIXCHECK
165 /* Assume calloc is always declared. */
166 _GL_WARN_ON_USE (calloc
, "calloc is not POSIX compliant everywhere - "
167 "use gnulib module calloc-posix for portability");
170 #if @GNULIB_CANONICALIZE_FILE_NAME@
171 # if @REPLACE_CANONICALIZE_FILE_NAME@
172 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
173 # define canonicalize_file_name rpl_canonicalize_file_name
175 _GL_FUNCDECL_RPL (canonicalize_file_name
, char *, (const char *name
)
176 _GL_ARG_NONNULL ((1)));
177 _GL_CXXALIAS_RPL (canonicalize_file_name
, char *, (const char *name
));
179 # if !@HAVE_CANONICALIZE_FILE_NAME@
180 _GL_FUNCDECL_SYS (canonicalize_file_name
, char *, (const char *name
)
181 _GL_ARG_NONNULL ((1)));
183 _GL_CXXALIAS_SYS (canonicalize_file_name
, char *, (const char *name
));
185 _GL_CXXALIASWARN (canonicalize_file_name
);
186 #elif defined GNULIB_POSIXCHECK
187 # undef canonicalize_file_name
188 # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
189 _GL_WARN_ON_USE (canonicalize_file_name
,
190 "canonicalize_file_name is unportable - "
191 "use gnulib module canonicalize-lgpl for portability");
195 #if @GNULIB_GETLOADAVG@
196 /* Store max(NELEM,3) load average numbers in LOADAVG[].
197 The three numbers are the load average of the last 1 minute, the last 5
198 minutes, and the last 15 minutes, respectively.
199 LOADAVG is an array of NELEM numbers. */
200 # if !@HAVE_DECL_GETLOADAVG@
201 _GL_FUNCDECL_SYS (getloadavg
, int, (double loadavg
[], int nelem
)
202 _GL_ARG_NONNULL ((1)));
204 _GL_CXXALIAS_SYS (getloadavg
, int, (double loadavg
[], int nelem
));
205 _GL_CXXALIASWARN (getloadavg
);
206 #elif defined GNULIB_POSIXCHECK
208 # if HAVE_RAW_DECL_GETLOADAVG
209 _GL_WARN_ON_USE (getloadavg
, "getloadavg is not portable - "
210 "use gnulib module getloadavg for portability");
214 #if @GNULIB_GETSUBOPT@
215 /* Assuming *OPTIONP is a comma separated list of elements of the form
216 "token" or "token=value", getsubopt parses the first of these elements.
217 If the first element refers to a "token" that is member of the given
218 NULL-terminated array of tokens:
219 - It replaces the comma with a NUL byte, updates *OPTIONP to point past
220 the first option and the comma, sets *VALUEP to the value of the
221 element (or NULL if it doesn't contain an "=" sign),
222 - It returns the index of the "token" in the given array of tokens.
223 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
224 For more details see the POSIX:2001 specification.
225 http://www.opengroup.org/susv3xsh/getsubopt.html */
226 # if !@HAVE_GETSUBOPT@
227 _GL_FUNCDECL_SYS (getsubopt
, int,
228 (char **optionp
, char *const *tokens
, char **valuep
)
229 _GL_ARG_NONNULL ((1, 2, 3)));
231 _GL_CXXALIAS_SYS (getsubopt
, int,
232 (char **optionp
, char *const *tokens
, char **valuep
));
233 _GL_CXXALIASWARN (getsubopt
);
234 #elif defined GNULIB_POSIXCHECK
236 # if HAVE_RAW_DECL_GETSUBOPT
237 _GL_WARN_ON_USE (getsubopt
, "getsubopt is unportable - "
238 "use gnulib module getsubopt for portability");
243 /* Change the ownership and access permission of the slave side of the
244 pseudo-terminal whose master side is specified by FD. */
246 _GL_FUNCDECL_SYS (grantpt
, int, (int fd
));
248 _GL_CXXALIAS_SYS (grantpt
, int, (int fd
));
249 _GL_CXXALIASWARN (grantpt
);
250 #elif defined GNULIB_POSIXCHECK
252 # if HAVE_RAW_DECL_GRANTPT
253 _GL_WARN_ON_USE (ptsname
, "grantpt is not portable - "
254 "use gnulib module grantpt for portability");
258 /* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
259 rely on GNU or POSIX semantics for malloc and realloc (for example,
260 by never specifying a zero size), so it does not need malloc or
261 realloc to be redefined. */
262 #if @GNULIB_MALLOC_POSIX@
263 # if @REPLACE_MALLOC@
264 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
265 || _GL_USE_STDLIB_ALLOC)
267 # define malloc rpl_malloc
269 _GL_FUNCDECL_RPL (malloc
, void *, (size_t size
));
270 _GL_CXXALIAS_RPL (malloc
, void *, (size_t size
));
272 _GL_CXXALIAS_SYS (malloc
, void *, (size_t size
));
274 _GL_CXXALIASWARN (malloc
);
275 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
277 /* Assume malloc is always declared. */
278 _GL_WARN_ON_USE (malloc
, "malloc is not POSIX compliant everywhere - "
279 "use gnulib module malloc-posix for portability");
282 /* Convert a multibyte character to a wide character. */
284 # if @REPLACE_MBTOWC@
285 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
287 # define mbtowc rpl_mbtowc
289 _GL_FUNCDECL_RPL (mbtowc
, int, (wchar_t *pwc
, const char *s
, size_t n
));
290 _GL_CXXALIAS_RPL (mbtowc
, int, (wchar_t *pwc
, const char *s
, size_t n
));
292 _GL_CXXALIAS_SYS (mbtowc
, int, (wchar_t *pwc
, const char *s
, size_t n
));
294 _GL_CXXALIASWARN (mbtowc
);
298 /* Create a unique temporary directory from TEMPLATE.
299 The last six characters of TEMPLATE must be "XXXXXX";
300 they are replaced with a string that makes the directory name unique.
301 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
302 The directory is created mode 700. */
304 _GL_FUNCDECL_SYS (mkdtemp
, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
306 _GL_CXXALIAS_SYS (mkdtemp
, char *, (char * /*template*/));
307 _GL_CXXALIASWARN (mkdtemp
);
308 #elif defined GNULIB_POSIXCHECK
310 # if HAVE_RAW_DECL_MKDTEMP
311 _GL_WARN_ON_USE (mkdtemp
, "mkdtemp is unportable - "
312 "use gnulib module mkdtemp for portability");
316 #if @GNULIB_MKOSTEMP@
317 /* Create a unique temporary file from TEMPLATE.
318 The last six characters of TEMPLATE must be "XXXXXX";
319 they are replaced with a string that makes the file name unique.
320 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
321 and O_TEXT, O_BINARY (defined in "binary-io.h").
322 The file is then created, with the specified flags, ensuring it didn't exist
324 The file is created read-write (mask at least 0600 & ~umask), but it may be
325 world-readable and world-writable (mask 0666 & ~umask), depending on the
327 Returns the open file descriptor if successful, otherwise -1 and errno
329 # if !@HAVE_MKOSTEMP@
330 _GL_FUNCDECL_SYS (mkostemp
, int, (char * /*template*/, int /*flags*/)
331 _GL_ARG_NONNULL ((1)));
333 _GL_CXXALIAS_SYS (mkostemp
, int, (char * /*template*/, int /*flags*/));
334 _GL_CXXALIASWARN (mkostemp
);
335 #elif defined GNULIB_POSIXCHECK
337 # if HAVE_RAW_DECL_MKOSTEMP
338 _GL_WARN_ON_USE (mkostemp
, "mkostemp is unportable - "
339 "use gnulib module mkostemp for portability");
343 #if @GNULIB_MKOSTEMPS@
344 /* Create a unique temporary file from TEMPLATE.
345 The last six characters of TEMPLATE before a suffix of length
346 SUFFIXLEN must be "XXXXXX";
347 they are replaced with a string that makes the file name unique.
348 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
349 and O_TEXT, O_BINARY (defined in "binary-io.h").
350 The file is then created, with the specified flags, ensuring it didn't exist
352 The file is created read-write (mask at least 0600 & ~umask), but it may be
353 world-readable and world-writable (mask 0666 & ~umask), depending on the
355 Returns the open file descriptor if successful, otherwise -1 and errno
357 # if !@HAVE_MKOSTEMPS@
358 _GL_FUNCDECL_SYS (mkostemps
, int,
359 (char * /*template*/, int /*suffixlen*/, int /*flags*/)
360 _GL_ARG_NONNULL ((1)));
362 _GL_CXXALIAS_SYS (mkostemps
, int,
363 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
364 _GL_CXXALIASWARN (mkostemps
);
365 #elif defined GNULIB_POSIXCHECK
367 # if HAVE_RAW_DECL_MKOSTEMPS
368 _GL_WARN_ON_USE (mkostemps
, "mkostemps is unportable - "
369 "use gnulib module mkostemps for portability");
374 /* Create a unique temporary file from TEMPLATE.
375 The last six characters of TEMPLATE must be "XXXXXX";
376 they are replaced with a string that makes the file name unique.
377 The file is then created, ensuring it didn't exist before.
378 The file is created read-write (mask at least 0600 & ~umask), but it may be
379 world-readable and world-writable (mask 0666 & ~umask), depending on the
381 Returns the open file descriptor if successful, otherwise -1 and errno
383 # if @REPLACE_MKSTEMP@
384 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
385 # define mkstemp rpl_mkstemp
387 _GL_FUNCDECL_RPL (mkstemp
, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
388 _GL_CXXALIAS_RPL (mkstemp
, int, (char * /*template*/));
390 # if ! @HAVE_MKSTEMP@
391 _GL_FUNCDECL_SYS (mkstemp
, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
393 _GL_CXXALIAS_SYS (mkstemp
, int, (char * /*template*/));
395 _GL_CXXALIASWARN (mkstemp
);
396 #elif defined GNULIB_POSIXCHECK
398 # if HAVE_RAW_DECL_MKSTEMP
399 _GL_WARN_ON_USE (mkstemp
, "mkstemp is unportable - "
400 "use gnulib module mkstemp for portability");
404 #if @GNULIB_MKSTEMPS@
405 /* Create a unique temporary file from TEMPLATE.
406 The last six characters of TEMPLATE prior to a suffix of length
407 SUFFIXLEN must be "XXXXXX";
408 they are replaced with a string that makes the file name unique.
409 The file is then created, ensuring it didn't exist before.
410 The file is created read-write (mask at least 0600 & ~umask), but it may be
411 world-readable and world-writable (mask 0666 & ~umask), depending on the
413 Returns the open file descriptor if successful, otherwise -1 and errno
415 # if !@HAVE_MKSTEMPS@
416 _GL_FUNCDECL_SYS (mkstemps
, int, (char * /*template*/, int /*suffixlen*/)
417 _GL_ARG_NONNULL ((1)));
419 _GL_CXXALIAS_SYS (mkstemps
, int, (char * /*template*/, int /*suffixlen*/));
420 _GL_CXXALIASWARN (mkstemps
);
421 #elif defined GNULIB_POSIXCHECK
423 # if HAVE_RAW_DECL_MKSTEMPS
424 _GL_WARN_ON_USE (mkstemps
, "mkstemps is unportable - "
425 "use gnulib module mkstemps for portability");
430 /* Return the pathname of the pseudo-terminal slave associated with
431 the master FD is open on, or NULL on errors. */
433 _GL_FUNCDECL_SYS (ptsname
, char *, (int fd
));
435 _GL_CXXALIAS_SYS (ptsname
, char *, (int fd
));
436 _GL_CXXALIASWARN (ptsname
);
437 #elif defined GNULIB_POSIXCHECK
439 # if HAVE_RAW_DECL_PTSNAME
440 _GL_WARN_ON_USE (ptsname
, "ptsname is not portable - "
441 "use gnulib module ptsname for portability");
446 # if @REPLACE_PUTENV@
447 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
449 # define putenv rpl_putenv
451 _GL_FUNCDECL_RPL (putenv
, int, (char *string
) _GL_ARG_NONNULL ((1)));
452 _GL_CXXALIAS_RPL (putenv
, int, (char *string
));
454 _GL_CXXALIAS_SYS (putenv
, int, (char *string
));
456 _GL_CXXALIASWARN (putenv
);
460 #if @GNULIB_RANDOM_R@
461 # if !@HAVE_RANDOM_R@
463 # define RAND_MAX 2147483647
468 #if @GNULIB_RANDOM_R@
469 # if !@HAVE_RANDOM_R@
470 _GL_FUNCDECL_SYS (random_r
, int, (struct random_data
*buf
, int32_t *result
)
471 _GL_ARG_NONNULL ((1, 2)));
473 _GL_CXXALIAS_SYS (random_r
, int, (struct random_data
*buf
, int32_t *result
));
474 _GL_CXXALIASWARN (random_r
);
475 #elif defined GNULIB_POSIXCHECK
477 # if HAVE_RAW_DECL_RANDOM_R
478 _GL_WARN_ON_USE (random_r
, "random_r is unportable - "
479 "use gnulib module random_r for portability");
483 #if @GNULIB_RANDOM_R@
484 # if !@HAVE_RANDOM_R@
485 _GL_FUNCDECL_SYS (srandom_r
, int,
486 (unsigned int seed
, struct random_data
*rand_state
)
487 _GL_ARG_NONNULL ((2)));
489 _GL_CXXALIAS_SYS (srandom_r
, int,
490 (unsigned int seed
, struct random_data
*rand_state
));
491 _GL_CXXALIASWARN (srandom_r
);
492 #elif defined GNULIB_POSIXCHECK
494 # if HAVE_RAW_DECL_SRANDOM_R
495 _GL_WARN_ON_USE (srandom_r
, "srandom_r is unportable - "
496 "use gnulib module random_r for portability");
500 #if @GNULIB_RANDOM_R@
501 # if !@HAVE_RANDOM_R@
502 _GL_FUNCDECL_SYS (initstate_r
, int,
503 (unsigned int seed
, char *buf
, size_t buf_size
,
504 struct random_data
*rand_state
)
505 _GL_ARG_NONNULL ((2, 4)));
507 _GL_CXXALIAS_SYS (initstate_r
, int,
508 (unsigned int seed
, char *buf
, size_t buf_size
,
509 struct random_data
*rand_state
));
510 _GL_CXXALIASWARN (initstate_r
);
511 #elif defined GNULIB_POSIXCHECK
513 # if HAVE_RAW_DECL_INITSTATE_R
514 _GL_WARN_ON_USE (initstate_r
, "initstate_r is unportable - "
515 "use gnulib module random_r for portability");
519 #if @GNULIB_RANDOM_R@
520 # if !@HAVE_RANDOM_R@
521 _GL_FUNCDECL_SYS (setstate_r
, int,
522 (char *arg_state
, struct random_data
*rand_state
)
523 _GL_ARG_NONNULL ((1, 2)));
525 _GL_CXXALIAS_SYS (setstate_r
, int,
526 (char *arg_state
, struct random_data
*rand_state
));
527 _GL_CXXALIASWARN (setstate_r
);
528 #elif defined GNULIB_POSIXCHECK
530 # if HAVE_RAW_DECL_SETSTATE_R
531 _GL_WARN_ON_USE (setstate_r
, "setstate_r is unportable - "
532 "use gnulib module random_r for portability");
537 #if @GNULIB_REALLOC_POSIX@
538 # if @REPLACE_REALLOC@
539 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
540 || _GL_USE_STDLIB_ALLOC)
542 # define realloc rpl_realloc
544 _GL_FUNCDECL_RPL (realloc
, void *, (void *ptr
, size_t size
));
545 _GL_CXXALIAS_RPL (realloc
, void *, (void *ptr
, size_t size
));
547 _GL_CXXALIAS_SYS (realloc
, void *, (void *ptr
, size_t size
));
549 _GL_CXXALIASWARN (realloc
);
550 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
552 /* Assume realloc is always declared. */
553 _GL_WARN_ON_USE (realloc
, "realloc is not POSIX compliant everywhere - "
554 "use gnulib module realloc-posix for portability");
557 #if @GNULIB_REALPATH@
558 # if @REPLACE_REALPATH@
559 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
560 # define realpath rpl_realpath
562 _GL_FUNCDECL_RPL (realpath
, char *, (const char *name
, char *resolved
)
563 _GL_ARG_NONNULL ((1)));
564 _GL_CXXALIAS_RPL (realpath
, char *, (const char *name
, char *resolved
));
566 # if !@HAVE_REALPATH@
567 _GL_FUNCDECL_SYS (realpath
, char *, (const char *name
, char *resolved
)
568 _GL_ARG_NONNULL ((1)));
570 _GL_CXXALIAS_SYS (realpath
, char *, (const char *name
, char *resolved
));
572 _GL_CXXALIASWARN (realpath
);
573 #elif defined GNULIB_POSIXCHECK
575 # if HAVE_RAW_DECL_REALPATH
576 _GL_WARN_ON_USE (realpath
, "realpath is unportable - use gnulib module "
577 "canonicalize or canonicalize-lgpl for portability");
582 /* Test a user response to a question.
583 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
585 _GL_FUNCDECL_SYS (rpmatch
, int, (const char *response
) _GL_ARG_NONNULL ((1)));
587 _GL_CXXALIAS_SYS (rpmatch
, int, (const char *response
));
588 _GL_CXXALIASWARN (rpmatch
);
589 #elif defined GNULIB_POSIXCHECK
591 # if HAVE_RAW_DECL_RPMATCH
592 _GL_WARN_ON_USE (rpmatch
, "rpmatch is unportable - "
593 "use gnulib module rpmatch for portability");
598 /* Set NAME to VALUE in the environment.
599 If REPLACE is nonzero, overwrite an existing value. */
600 # if @REPLACE_SETENV@
601 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
603 # define setenv rpl_setenv
605 _GL_FUNCDECL_RPL (setenv
, int,
606 (const char *name
, const char *value
, int replace
)
607 _GL_ARG_NONNULL ((1)));
608 _GL_CXXALIAS_RPL (setenv
, int,
609 (const char *name
, const char *value
, int replace
));
611 # if !@HAVE_DECL_SETENV@
612 _GL_FUNCDECL_SYS (setenv
, int,
613 (const char *name
, const char *value
, int replace
)
614 _GL_ARG_NONNULL ((1)));
616 _GL_CXXALIAS_SYS (setenv
, int,
617 (const char *name
, const char *value
, int replace
));
619 # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
620 _GL_CXXALIASWARN (setenv
);
622 #elif defined GNULIB_POSIXCHECK
624 # if HAVE_RAW_DECL_SETENV
625 _GL_WARN_ON_USE (setenv
, "setenv is unportable - "
626 "use gnulib module setenv for portability");
631 /* Parse a double from STRING, updating ENDP if appropriate. */
632 # if @REPLACE_STRTOD@
633 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
634 # define strtod rpl_strtod
636 _GL_FUNCDECL_RPL (strtod
, double, (const char *str
, char **endp
)
637 _GL_ARG_NONNULL ((1)));
638 _GL_CXXALIAS_RPL (strtod
, double, (const char *str
, char **endp
));
641 _GL_FUNCDECL_SYS (strtod
, double, (const char *str
, char **endp
)
642 _GL_ARG_NONNULL ((1)));
644 _GL_CXXALIAS_SYS (strtod
, double, (const char *str
, char **endp
));
646 _GL_CXXALIASWARN (strtod
);
647 #elif defined GNULIB_POSIXCHECK
649 # if HAVE_RAW_DECL_STRTOD
650 _GL_WARN_ON_USE (strtod
, "strtod is unportable - "
651 "use gnulib module strtod for portability");
656 /* Parse a signed integer whose textual representation starts at STRING.
657 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
658 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
660 If ENDPTR is not NULL, the address of the first byte after the integer is
662 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
665 _GL_FUNCDECL_SYS (strtoll
, long long,
666 (const char *string
, char **endptr
, int base
)
667 _GL_ARG_NONNULL ((1)));
669 _GL_CXXALIAS_SYS (strtoll
, long long,
670 (const char *string
, char **endptr
, int base
));
671 _GL_CXXALIASWARN (strtoll
);
672 #elif defined GNULIB_POSIXCHECK
674 # if HAVE_RAW_DECL_STRTOLL
675 _GL_WARN_ON_USE (strtoll
, "strtoll is unportable - "
676 "use gnulib module strtoll for portability");
680 #if @GNULIB_STRTOULL@
681 /* Parse an unsigned integer whose textual representation starts at STRING.
682 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
683 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
685 If ENDPTR is not NULL, the address of the first byte after the integer is
687 Upon overflow, the return value is ULLONG_MAX, and errno is set to
689 # if !@HAVE_STRTOULL@
690 _GL_FUNCDECL_SYS (strtoull
, unsigned long long,
691 (const char *string
, char **endptr
, int base
)
692 _GL_ARG_NONNULL ((1)));
694 _GL_CXXALIAS_SYS (strtoull
, unsigned long long,
695 (const char *string
, char **endptr
, int base
));
696 _GL_CXXALIASWARN (strtoull
);
697 #elif defined GNULIB_POSIXCHECK
699 # if HAVE_RAW_DECL_STRTOULL
700 _GL_WARN_ON_USE (strtoull
, "strtoull is unportable - "
701 "use gnulib module strtoull for portability");
705 #if @GNULIB_UNLOCKPT@
706 /* Unlock the slave side of the pseudo-terminal whose master side is specified
707 by FD, so that it can be opened. */
708 # if !@HAVE_UNLOCKPT@
709 _GL_FUNCDECL_SYS (unlockpt
, int, (int fd
));
711 _GL_CXXALIAS_SYS (unlockpt
, int, (int fd
));
712 _GL_CXXALIASWARN (unlockpt
);
713 #elif defined GNULIB_POSIXCHECK
715 # if HAVE_RAW_DECL_UNLOCKPT
716 _GL_WARN_ON_USE (unlockpt
, "unlockpt is not portable - "
717 "use gnulib module unlockpt for portability");
721 #if @GNULIB_UNSETENV@
722 /* Remove the variable NAME from the environment. */
723 # if @REPLACE_UNSETENV@
724 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
726 # define unsetenv rpl_unsetenv
728 _GL_FUNCDECL_RPL (unsetenv
, int, (const char *name
) _GL_ARG_NONNULL ((1)));
729 _GL_CXXALIAS_RPL (unsetenv
, int, (const char *name
));
731 # if !@HAVE_DECL_UNSETENV@
732 _GL_FUNCDECL_SYS (unsetenv
, int, (const char *name
) _GL_ARG_NONNULL ((1)));
734 _GL_CXXALIAS_SYS (unsetenv
, int, (const char *name
));
736 # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
737 _GL_CXXALIASWARN (unsetenv
);
739 #elif defined GNULIB_POSIXCHECK
741 # if HAVE_RAW_DECL_UNSETENV
742 _GL_WARN_ON_USE (unsetenv
, "unsetenv is unportable - "
743 "use gnulib module unsetenv for portability");
747 /* Convert a wide character to a multibyte character. */
749 # if @REPLACE_WCTOMB@
750 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
752 # define wctomb rpl_wctomb
754 _GL_FUNCDECL_RPL (wctomb
, int, (char *s
, wchar_t wc
));
755 _GL_CXXALIAS_RPL (wctomb
, int, (char *s
, wchar_t wc
));
757 _GL_CXXALIAS_SYS (wctomb
, int, (char *s
, wchar_t wc
));
759 _GL_CXXALIASWARN (wctomb
);
763 #endif /* _GL_STDLIB_H */
764 #endif /* _GL_STDLIB_H */