summaryrefslogtreecommitdiffstats
path: root/gl/stdlib.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/stdlib.in.h')
-rw-r--r--gl/stdlib.in.h351
1 files changed, 309 insertions, 42 deletions
diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h
index d74c251..c955248 100644
--- a/gl/stdlib.in.h
+++ b/gl/stdlib.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <stdlib.h>. 1/* A GNU-like <stdlib.h>.
2 2
3 Copyright (C) 1995, 2001-2004, 2006-2010 Free Software Foundation, Inc. 3 Copyright (C) 1995, 2001-2004, 2006-2013 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published by
@@ -18,43 +18,60 @@
18#if __GNUC__ >= 3 18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
20#endif 20#endif
21@PRAGMA_COLUMNS@
21 22
22#if defined __need_malloc_and_calloc 23#if defined __need_system_stdlib_h || defined __need_malloc_and_calloc
23/* Special invocation convention inside glibc header files. */ 24/* Special invocation conventions inside some gnulib header files,
25 and inside some glibc header files, respectively. */
24 26
25#@INCLUDE_NEXT@ @NEXT_STDLIB_H@ 27#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
26 28
27#else 29#else
28/* Normal invocation convention. */ 30/* Normal invocation convention. */
29 31
30#ifndef _GL_STDLIB_H 32#ifndef _@GUARD_PREFIX@_STDLIB_H
31 33
32/* The include_next requires a split double-inclusion guard. */ 34/* The include_next requires a split double-inclusion guard. */
33#@INCLUDE_NEXT@ @NEXT_STDLIB_H@ 35#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
34 36
35#ifndef _GL_STDLIB_H 37#ifndef _@GUARD_PREFIX@_STDLIB_H
36#define _GL_STDLIB_H 38#define _@GUARD_PREFIX@_STDLIB_H
37 39
38/* NetBSD 5.0 mis-defines NULL. */ 40/* NetBSD 5.0 mis-defines NULL. */
39#include <stddef.h> 41#include <stddef.h>
40 42
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>
46#endif
47
41/* Solaris declares getloadavg() in <sys/loadavg.h>. */ 48/* Solaris declares getloadavg() in <sys/loadavg.h>. */
42#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@ 49#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
43# include <sys/loadavg.h> 50# include <sys/loadavg.h>
44#endif 51#endif
45 52
46/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included 53/* Native Windows platforms declare mktemp() in <io.h>. */
47 from <stdlib.h> if _REENTRANT is defined. Include it always. */ 54#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
48#if @HAVE_RANDOM_H@ 55# include <io.h>
49# include <random.h>
50#endif 56#endif
51 57
52#if !@HAVE_STRUCT_RANDOM_DATA@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@) \ 58#if @GNULIB_RANDOM_R@
53 || defined GNULIB_POSIXCHECK
54# include <stdint.h>
55#endif
56 59
57#if !@HAVE_STRUCT_RANDOM_DATA@ 60/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
61 from <stdlib.h> if _REENTRANT is defined. Include it whenever we need
62 'struct random_data'. */
63# if @HAVE_RANDOM_H@
64# include <random.h>
65# endif
66
67# if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
68# include <stdint.h>
69# endif
70
71# if !@HAVE_STRUCT_RANDOM_DATA@
72/* Define 'struct random_data'.
73 But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
74# if !GNULIB_defined_struct_random_data
58struct random_data 75struct random_data
59{ 76{
60 int32_t *fptr; /* Front pointer. */ 77 int32_t *fptr; /* Front pointer. */
@@ -65,15 +82,29 @@ struct random_data
65 int rand_sep; /* Distance between front and rear. */ 82 int rand_sep; /* Distance between front and rear. */
66 int32_t *end_ptr; /* Pointer behind state table. */ 83 int32_t *end_ptr; /* Pointer behind state table. */
67}; 84};
85# define GNULIB_defined_struct_random_data 1
86# endif
87# endif
68#endif 88#endif
69 89
70#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) 90#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
71/* On MacOS X 10.3, only <unistd.h> declares mkstemp. */ 91/* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */
92/* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */
72/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */ 93/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
73/* But avoid namespace pollution on glibc systems and native Windows. */ 94/* But avoid namespace pollution on glibc systems and native Windows. */
74# include <unistd.h> 95# include <unistd.h>
75#endif 96#endif
76 97
98/* The __attribute__ feature is available in gcc versions 2.5 and later.
99 The attribute __pure__ was added in gcc 2.96. */
100#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
101# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
102#else
103# define _GL_ATTRIBUTE_PURE /* empty */
104#endif
105
106/* The definition of _Noreturn is copied here. */
107
77/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 108/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
78 109
79/* The definition of _GL_ARG_NONNULL is copied here. */ 110/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -95,11 +126,30 @@ struct random_data
95#endif 126#endif
96 127
97 128
129#if @GNULIB__EXIT@
130/* Terminate the current process with the given return code, without running
131 the 'atexit' handlers. */
132# if !@HAVE__EXIT@
133_GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status));
134# endif
135_GL_CXXALIAS_SYS (_Exit, void, (int status));
136_GL_CXXALIASWARN (_Exit);
137#elif defined GNULIB_POSIXCHECK
138# undef _Exit
139# if HAVE_RAW_DECL__EXIT
140_GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
141 "use gnulib module _Exit for portability");
142# endif
143#endif
144
145
98#if @GNULIB_ATOLL@ 146#if @GNULIB_ATOLL@
99/* Parse a signed decimal integer. 147/* Parse a signed decimal integer.
100 Returns the value of the integer. Errors are not detected. */ 148 Returns the value of the integer. Errors are not detected. */
101# if !@HAVE_ATOLL@ 149# if !@HAVE_ATOLL@
102_GL_FUNCDECL_SYS (atoll, long long, (const char *string) _GL_ARG_NONNULL ((1))); 150_GL_FUNCDECL_SYS (atoll, long long, (const char *string)
151 _GL_ATTRIBUTE_PURE
152 _GL_ARG_NONNULL ((1)));
103# endif 153# endif
104_GL_CXXALIAS_SYS (atoll, long long, (const char *string)); 154_GL_CXXALIAS_SYS (atoll, long long, (const char *string));
105_GL_CXXALIASWARN (atoll); 155_GL_CXXALIASWARN (atoll);
@@ -112,7 +162,7 @@ _GL_WARN_ON_USE (atoll, "atoll is unportable - "
112#endif 162#endif
113 163
114#if @GNULIB_CALLOC_POSIX@ 164#if @GNULIB_CALLOC_POSIX@
115# if !@HAVE_CALLOC_POSIX@ 165# if @REPLACE_CALLOC@
116# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 166# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
117# undef calloc 167# undef calloc
118# define calloc rpl_calloc 168# define calloc rpl_calloc
@@ -149,7 +199,8 @@ _GL_CXXALIASWARN (canonicalize_file_name);
149#elif defined GNULIB_POSIXCHECK 199#elif defined GNULIB_POSIXCHECK
150# undef canonicalize_file_name 200# undef canonicalize_file_name
151# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME 201# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
152_GL_WARN_ON_USE (canonicalize_file_name, "canonicalize_file_name is unportable - " 202_GL_WARN_ON_USE (canonicalize_file_name,
203 "canonicalize_file_name is unportable - "
153 "use gnulib module canonicalize-lgpl for portability"); 204 "use gnulib module canonicalize-lgpl for portability");
154# endif 205# endif
155#endif 206#endif
@@ -212,14 +263,19 @@ _GL_CXXALIASWARN (grantpt);
212#elif defined GNULIB_POSIXCHECK 263#elif defined GNULIB_POSIXCHECK
213# undef grantpt 264# undef grantpt
214# if HAVE_RAW_DECL_GRANTPT 265# if HAVE_RAW_DECL_GRANTPT
215_GL_WARN_ON_USE (ptsname, "grantpt is not portable - " 266_GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
216 "use gnulib module grantpt for portability"); 267 "use gnulib module grantpt for portability");
217# endif 268# endif
218#endif 269#endif
219 270
271/* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
272 rely on GNU or POSIX semantics for malloc and realloc (for example,
273 by never specifying a zero size), so it does not need malloc or
274 realloc to be redefined. */
220#if @GNULIB_MALLOC_POSIX@ 275#if @GNULIB_MALLOC_POSIX@
221# if !@HAVE_MALLOC_POSIX@ 276# if @REPLACE_MALLOC@
222# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 277# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
278 || _GL_USE_STDLIB_ALLOC)
223# undef malloc 279# undef malloc
224# define malloc rpl_malloc 280# define malloc rpl_malloc
225# endif 281# endif
@@ -229,13 +285,28 @@ _GL_CXXALIAS_RPL (malloc, void *, (size_t size));
229_GL_CXXALIAS_SYS (malloc, void *, (size_t size)); 285_GL_CXXALIAS_SYS (malloc, void *, (size_t size));
230# endif 286# endif
231_GL_CXXALIASWARN (malloc); 287_GL_CXXALIASWARN (malloc);
232#elif defined GNULIB_POSIXCHECK 288#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
233# undef malloc 289# undef malloc
234/* Assume malloc is always declared. */ 290/* Assume malloc is always declared. */
235_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " 291_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
236 "use gnulib module malloc-posix for portability"); 292 "use gnulib module malloc-posix for portability");
237#endif 293#endif
238 294
295/* Convert a multibyte character to a wide character. */
296#if @GNULIB_MBTOWC@
297# if @REPLACE_MBTOWC@
298# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
299# undef mbtowc
300# define mbtowc rpl_mbtowc
301# endif
302_GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
303_GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
304# else
305_GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
306# endif
307_GL_CXXALIASWARN (mbtowc);
308#endif
309
239#if @GNULIB_MKDTEMP@ 310#if @GNULIB_MKDTEMP@
240/* Create a unique temporary directory from TEMPLATE. 311/* Create a unique temporary directory from TEMPLATE.
241 The last six characters of TEMPLATE must be "XXXXXX"; 312 The last six characters of TEMPLATE must be "XXXXXX";
@@ -368,13 +439,38 @@ _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
368# endif 439# endif
369#endif 440#endif
370 441
442#if @GNULIB_POSIX_OPENPT@
443/* Return an FD open to the master side of a pseudo-terminal. Flags should
444 include O_RDWR, and may also include O_NOCTTY. */
445# if !@HAVE_POSIX_OPENPT@
446_GL_FUNCDECL_SYS (posix_openpt, int, (int flags));
447# endif
448_GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
449_GL_CXXALIASWARN (posix_openpt);
450#elif defined GNULIB_POSIXCHECK
451# undef posix_openpt
452# if HAVE_RAW_DECL_POSIX_OPENPT
453_GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
454 "use gnulib module posix_openpt for portability");
455# endif
456#endif
457
371#if @GNULIB_PTSNAME@ 458#if @GNULIB_PTSNAME@
372/* Return the pathname of the pseudo-terminal slave associated with 459/* Return the pathname of the pseudo-terminal slave associated with
373 the master FD is open on, or NULL on errors. */ 460 the master FD is open on, or NULL on errors. */
374# if !@HAVE_PTSNAME@ 461# if @REPLACE_PTSNAME@
462# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
463# undef ptsname
464# define ptsname rpl_ptsname
465# endif
466_GL_FUNCDECL_RPL (ptsname, char *, (int fd));
467_GL_CXXALIAS_RPL (ptsname, char *, (int fd));
468# else
469# if !@HAVE_PTSNAME@
375_GL_FUNCDECL_SYS (ptsname, char *, (int fd)); 470_GL_FUNCDECL_SYS (ptsname, char *, (int fd));
376# endif 471# endif
377_GL_CXXALIAS_SYS (ptsname, char *, (int fd)); 472_GL_CXXALIAS_SYS (ptsname, char *, (int fd));
473# endif
378_GL_CXXALIASWARN (ptsname); 474_GL_CXXALIASWARN (ptsname);
379#elif defined GNULIB_POSIXCHECK 475#elif defined GNULIB_POSIXCHECK
380# undef ptsname 476# undef ptsname
@@ -384,6 +480,32 @@ _GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
384# endif 480# endif
385#endif 481#endif
386 482
483#if @GNULIB_PTSNAME_R@
484/* Set the pathname of the pseudo-terminal slave associated with
485 the master FD is open on and return 0, or set errno and return
486 non-zero on errors. */
487# if @REPLACE_PTSNAME_R@
488# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
489# undef ptsname_r
490# define ptsname_r rpl_ptsname_r
491# endif
492_GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
493_GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
494# else
495# if !@HAVE_PTSNAME_R@
496_GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
497# endif
498_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
499# endif
500_GL_CXXALIASWARN (ptsname_r);
501#elif defined GNULIB_POSIXCHECK
502# undef ptsname_r
503# if HAVE_RAW_DECL_PTSNAME_R
504_GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
505 "use gnulib module ptsname_r for portability");
506# endif
507#endif
508
387#if @GNULIB_PUTENV@ 509#if @GNULIB_PUTENV@
388# if @REPLACE_PUTENV@ 510# if @REPLACE_PUTENV@
389# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 511# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -407,12 +529,83 @@ _GL_CXXALIASWARN (putenv);
407# endif 529# endif
408#endif 530#endif
409 531
532
533#if @GNULIB_RANDOM@
534# if !@HAVE_RANDOM@
535_GL_FUNCDECL_SYS (random, long, (void));
536# endif
537_GL_CXXALIAS_SYS (random, long, (void));
538_GL_CXXALIASWARN (random);
539#elif defined GNULIB_POSIXCHECK
540# undef random
541# if HAVE_RAW_DECL_RANDOM
542_GL_WARN_ON_USE (random, "random is unportable - "
543 "use gnulib module random for portability");
544# endif
545#endif
546
547#if @GNULIB_RANDOM@
548# if !@HAVE_RANDOM@
549_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
550# endif
551_GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
552_GL_CXXALIASWARN (srandom);
553#elif defined GNULIB_POSIXCHECK
554# undef srandom
555# if HAVE_RAW_DECL_SRANDOM
556_GL_WARN_ON_USE (srandom, "srandom is unportable - "
557 "use gnulib module random for portability");
558# endif
559#endif
560
561#if @GNULIB_RANDOM@
562# if !@HAVE_RANDOM@
563_GL_FUNCDECL_SYS (initstate, char *,
564 (unsigned int seed, char *buf, size_t buf_size)
565 _GL_ARG_NONNULL ((2)));
566# endif
567_GL_CXXALIAS_SYS (initstate, char *,
568 (unsigned int seed, char *buf, size_t buf_size));
569_GL_CXXALIASWARN (initstate);
570#elif defined GNULIB_POSIXCHECK
571# undef initstate
572# if HAVE_RAW_DECL_INITSTATE_R
573_GL_WARN_ON_USE (initstate, "initstate is unportable - "
574 "use gnulib module random for portability");
575# endif
576#endif
577
578#if @GNULIB_RANDOM@
579# if !@HAVE_RANDOM@
580_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
581# endif
582_GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
583_GL_CXXALIASWARN (setstate);
584#elif defined GNULIB_POSIXCHECK
585# undef setstate
586# if HAVE_RAW_DECL_SETSTATE_R
587_GL_WARN_ON_USE (setstate, "setstate is unportable - "
588 "use gnulib module random for portability");
589# endif
590#endif
591
592
410#if @GNULIB_RANDOM_R@ 593#if @GNULIB_RANDOM_R@
411# if !@HAVE_RANDOM_R@ 594# if @REPLACE_RANDOM_R@
595# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
596# undef random_r
597# define random_r rpl_random_r
598# endif
599_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
600 _GL_ARG_NONNULL ((1, 2)));
601_GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
602# else
603# if !@HAVE_RANDOM_R@
412_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result) 604_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
413 _GL_ARG_NONNULL ((1, 2))); 605 _GL_ARG_NONNULL ((1, 2)));
414# endif 606# endif
415_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); 607_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
608# endif
416_GL_CXXALIASWARN (random_r); 609_GL_CXXALIASWARN (random_r);
417#elif defined GNULIB_POSIXCHECK 610#elif defined GNULIB_POSIXCHECK
418# undef random_r 611# undef random_r
@@ -423,13 +616,25 @@ _GL_WARN_ON_USE (random_r, "random_r is unportable - "
423#endif 616#endif
424 617
425#if @GNULIB_RANDOM_R@ 618#if @GNULIB_RANDOM_R@
426# if !@HAVE_RANDOM_R@ 619# if @REPLACE_RANDOM_R@
620# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
621# undef srandom_r
622# define srandom_r rpl_srandom_r
623# endif
624_GL_FUNCDECL_RPL (srandom_r, int,
625 (unsigned int seed, struct random_data *rand_state)
626 _GL_ARG_NONNULL ((2)));
627_GL_CXXALIAS_RPL (srandom_r, int,
628 (unsigned int seed, struct random_data *rand_state));
629# else
630# if !@HAVE_RANDOM_R@
427_GL_FUNCDECL_SYS (srandom_r, int, 631_GL_FUNCDECL_SYS (srandom_r, int,
428 (unsigned int seed, struct random_data *rand_state) 632 (unsigned int seed, struct random_data *rand_state)
429 _GL_ARG_NONNULL ((2))); 633 _GL_ARG_NONNULL ((2)));
430# endif 634# endif
431_GL_CXXALIAS_SYS (srandom_r, int, 635_GL_CXXALIAS_SYS (srandom_r, int,
432 (unsigned int seed, struct random_data *rand_state)); 636 (unsigned int seed, struct random_data *rand_state));
637# endif
433_GL_CXXALIASWARN (srandom_r); 638_GL_CXXALIASWARN (srandom_r);
434#elif defined GNULIB_POSIXCHECK 639#elif defined GNULIB_POSIXCHECK
435# undef srandom_r 640# undef srandom_r
@@ -440,15 +645,29 @@ _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
440#endif 645#endif
441 646
442#if @GNULIB_RANDOM_R@ 647#if @GNULIB_RANDOM_R@
443# if !@HAVE_RANDOM_R@ 648# if @REPLACE_RANDOM_R@
649# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
650# undef initstate_r
651# define initstate_r rpl_initstate_r
652# endif
653_GL_FUNCDECL_RPL (initstate_r, int,
654 (unsigned int seed, char *buf, size_t buf_size,
655 struct random_data *rand_state)
656 _GL_ARG_NONNULL ((2, 4)));
657_GL_CXXALIAS_RPL (initstate_r, int,
658 (unsigned int seed, char *buf, size_t buf_size,
659 struct random_data *rand_state));
660# else
661# if !@HAVE_RANDOM_R@
444_GL_FUNCDECL_SYS (initstate_r, int, 662_GL_FUNCDECL_SYS (initstate_r, int,
445 (unsigned int seed, char *buf, size_t buf_size, 663 (unsigned int seed, char *buf, size_t buf_size,
446 struct random_data *rand_state) 664 struct random_data *rand_state)
447 _GL_ARG_NONNULL ((2, 4))); 665 _GL_ARG_NONNULL ((2, 4)));
448# endif 666# endif
449_GL_CXXALIAS_SYS (initstate_r, int, 667_GL_CXXALIAS_SYS (initstate_r, int,
450 (unsigned int seed, char *buf, size_t buf_size, 668 (unsigned int seed, char *buf, size_t buf_size,
451 struct random_data *rand_state)); 669 struct random_data *rand_state));
670# endif
452_GL_CXXALIASWARN (initstate_r); 671_GL_CXXALIASWARN (initstate_r);
453#elif defined GNULIB_POSIXCHECK 672#elif defined GNULIB_POSIXCHECK
454# undef initstate_r 673# undef initstate_r
@@ -459,13 +678,25 @@ _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
459#endif 678#endif
460 679
461#if @GNULIB_RANDOM_R@ 680#if @GNULIB_RANDOM_R@
462# if !@HAVE_RANDOM_R@ 681# if @REPLACE_RANDOM_R@
682# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
683# undef setstate_r
684# define setstate_r rpl_setstate_r
685# endif
686_GL_FUNCDECL_RPL (setstate_r, int,
687 (char *arg_state, struct random_data *rand_state)
688 _GL_ARG_NONNULL ((1, 2)));
689_GL_CXXALIAS_RPL (setstate_r, int,
690 (char *arg_state, struct random_data *rand_state));
691# else
692# if !@HAVE_RANDOM_R@
463_GL_FUNCDECL_SYS (setstate_r, int, 693_GL_FUNCDECL_SYS (setstate_r, int,
464 (char *arg_state, struct random_data *rand_state) 694 (char *arg_state, struct random_data *rand_state)
465 _GL_ARG_NONNULL ((1, 2))); 695 _GL_ARG_NONNULL ((1, 2)));
466# endif 696# endif
467_GL_CXXALIAS_SYS (setstate_r, int, 697_GL_CXXALIAS_SYS (setstate_r, int,
468 (char *arg_state, struct random_data *rand_state)); 698 (char *arg_state, struct random_data *rand_state));
699# endif
469_GL_CXXALIASWARN (setstate_r); 700_GL_CXXALIASWARN (setstate_r);
470#elif defined GNULIB_POSIXCHECK 701#elif defined GNULIB_POSIXCHECK
471# undef setstate_r 702# undef setstate_r
@@ -477,8 +708,9 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
477 708
478 709
479#if @GNULIB_REALLOC_POSIX@ 710#if @GNULIB_REALLOC_POSIX@
480# if !@HAVE_REALLOC_POSIX@ 711# if @REPLACE_REALLOC@
481# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 712# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
713 || _GL_USE_STDLIB_ALLOC)
482# undef realloc 714# undef realloc
483# define realloc rpl_realloc 715# define realloc rpl_realloc
484# endif 716# endif
@@ -488,7 +720,7 @@ _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
488_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); 720_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
489# endif 721# endif
490_GL_CXXALIASWARN (realloc); 722_GL_CXXALIASWARN (realloc);
491#elif defined GNULIB_POSIXCHECK 723#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
492# undef realloc 724# undef realloc
493/* Assume realloc is always declared. */ 725/* Assume realloc is always declared. */
494_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - " 726_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
@@ -535,6 +767,22 @@ _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
535# endif 767# endif
536#endif 768#endif
537 769
770#if @GNULIB_SECURE_GETENV@
771/* Look up NAME in the environment, returning 0 in insecure situations. */
772# if !@HAVE_SECURE_GETENV@
773_GL_FUNCDECL_SYS (secure_getenv, char *,
774 (char const *name) _GL_ARG_NONNULL ((1)));
775# endif
776_GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
777_GL_CXXALIASWARN (secure_getenv);
778#elif defined GNULIB_POSIXCHECK
779# undef secure_getenv
780# if HAVE_RAW_DECL_SECURE_GETENV
781_GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
782 "use gnulib module secure_getenv for portability");
783# endif
784#endif
785
538#if @GNULIB_SETENV@ 786#if @GNULIB_SETENV@
539/* Set NAME to VALUE in the environment. 787/* Set NAME to VALUE in the environment.
540 If REPLACE is nonzero, overwrite an existing value. */ 788 If REPLACE is nonzero, overwrite an existing value. */
@@ -549,7 +797,7 @@ _GL_FUNCDECL_RPL (setenv, int,
549_GL_CXXALIAS_RPL (setenv, int, 797_GL_CXXALIAS_RPL (setenv, int,
550 (const char *name, const char *value, int replace)); 798 (const char *name, const char *value, int replace));
551# else 799# else
552# if !@HAVE_SETENV@ 800# if !@HAVE_DECL_SETENV@
553_GL_FUNCDECL_SYS (setenv, int, 801_GL_FUNCDECL_SYS (setenv, int,
554 (const char *name, const char *value, int replace) 802 (const char *name, const char *value, int replace)
555 _GL_ARG_NONNULL ((1))); 803 _GL_ARG_NONNULL ((1)));
@@ -557,7 +805,9 @@ _GL_FUNCDECL_SYS (setenv, int,
557_GL_CXXALIAS_SYS (setenv, int, 805_GL_CXXALIAS_SYS (setenv, int,
558 (const char *name, const char *value, int replace)); 806 (const char *name, const char *value, int replace));
559# endif 807# endif
808# if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
560_GL_CXXALIASWARN (setenv); 809_GL_CXXALIASWARN (setenv);
810# endif
561#elif defined GNULIB_POSIXCHECK 811#elif defined GNULIB_POSIXCHECK
562# undef setenv 812# undef setenv
563# if HAVE_RAW_DECL_SETENV 813# if HAVE_RAW_DECL_SETENV
@@ -652,7 +902,7 @@ _GL_CXXALIASWARN (unlockpt);
652#elif defined GNULIB_POSIXCHECK 902#elif defined GNULIB_POSIXCHECK
653# undef unlockpt 903# undef unlockpt
654# if HAVE_RAW_DECL_UNLOCKPT 904# if HAVE_RAW_DECL_UNLOCKPT
655_GL_WARN_ON_USE (ptsname, "unlockpt is not portable - " 905_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
656 "use gnulib module unlockpt for portability"); 906 "use gnulib module unlockpt for portability");
657# endif 907# endif
658#endif 908#endif
@@ -667,12 +917,14 @@ _GL_WARN_ON_USE (ptsname, "unlockpt is not portable - "
667_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); 917_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
668_GL_CXXALIAS_RPL (unsetenv, int, (const char *name)); 918_GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
669# else 919# else
670# if !@HAVE_UNSETENV@ 920# if !@HAVE_DECL_UNSETENV@
671_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); 921_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
672# endif 922# endif
673_GL_CXXALIAS_SYS (unsetenv, int, (const char *name)); 923_GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
674# endif 924# endif
925# if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
675_GL_CXXALIASWARN (unsetenv); 926_GL_CXXALIASWARN (unsetenv);
927# endif
676#elif defined GNULIB_POSIXCHECK 928#elif defined GNULIB_POSIXCHECK
677# undef unsetenv 929# undef unsetenv
678# if HAVE_RAW_DECL_UNSETENV 930# if HAVE_RAW_DECL_UNSETENV
@@ -681,7 +933,22 @@ _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
681# endif 933# endif
682#endif 934#endif
683 935
936/* Convert a wide character to a multibyte character. */
937#if @GNULIB_WCTOMB@
938# if @REPLACE_WCTOMB@
939# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
940# undef wctomb
941# define wctomb rpl_wctomb
942# endif
943_GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc));
944_GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
945# else
946_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
947# endif
948_GL_CXXALIASWARN (wctomb);
949#endif
950
684 951
685#endif /* _GL_STDLIB_H */ 952#endif /* _@GUARD_PREFIX@_STDLIB_H */
686#endif /* _GL_STDLIB_H */ 953#endif /* _@GUARD_PREFIX@_STDLIB_H */
687#endif 954#endif