New module 'random'.
[gnulib.git] / lib / stdlib.in.h
1 /* A GNU-like <stdlib.h>.
2
3    Copyright (C) 1995, 2001-2004, 2006-2012 Free Software Foundation, Inc.
4
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.
9
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.
14
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/>.  */
17
18 #if __GNUC__ >= 3
19 @PRAGMA_SYSTEM_HEADER@
20 #endif
21 @PRAGMA_COLUMNS@
22
23 #if defined __need_malloc_and_calloc
24 /* Special invocation convention inside glibc header files.  */
25
26 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
27
28 #else
29 /* Normal invocation convention.  */
30
31 #ifndef _@GUARD_PREFIX@_STDLIB_H
32
33 /* The include_next requires a split double-inclusion guard.  */
34 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
35
36 #ifndef _@GUARD_PREFIX@_STDLIB_H
37 #define _@GUARD_PREFIX@_STDLIB_H
38
39 /* NetBSD 5.0 mis-defines NULL.  */
40 #include <stddef.h>
41
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>
45 #endif
46
47 /* Solaris declares getloadavg() in <sys/loadavg.h>.  */
48 #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
49 # include <sys/loadavg.h>
50 #endif
51
52 #if @GNULIB_RANDOM_R@
53
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'.  */
57 # if @HAVE_RANDOM_H@
58 #  include <random.h>
59 # endif
60
61 # if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
62 #  include <stdint.h>
63 # endif
64
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
69 struct random_data
70 {
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.  */
78 };
79 #   define GNULIB_defined_struct_random_data 1
80 #  endif
81 # endif
82 #endif
83
84 #if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @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 MacOS X 10.5, only <unistd.h> declares mkstemps.  */
87 /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt.  */
88 /* But avoid namespace pollution on glibc systems and native Windows.  */
89 # include <unistd.h>
90 #endif
91
92 /* The definition of _Noreturn is copied here.  */
93
94 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
95
96 /* The definition of _GL_ARG_NONNULL is copied here.  */
97
98 /* The definition of _GL_WARN_ON_USE is copied here.  */
99
100
101 /* Some systems do not define EXIT_*, despite otherwise supporting C89.  */
102 #ifndef EXIT_SUCCESS
103 # define EXIT_SUCCESS 0
104 #endif
105 /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
106    with proper operation of xargs.  */
107 #ifndef EXIT_FAILURE
108 # define EXIT_FAILURE 1
109 #elif EXIT_FAILURE != 1
110 # undef EXIT_FAILURE
111 # define EXIT_FAILURE 1
112 #endif
113
114
115 #if @GNULIB__EXIT@
116 /* Terminate the current process with the given return code, without running
117    the 'atexit' handlers.  */
118 # if !@HAVE__EXIT@
119 _GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status));
120 # endif
121 _GL_CXXALIAS_SYS (_Exit, void, (int status));
122 _GL_CXXALIASWARN (_Exit);
123 #elif defined GNULIB_POSIXCHECK
124 # undef _Exit
125 # if HAVE_RAW_DECL__EXIT
126 _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
127                  "use gnulib module _Exit for portability");
128 # endif
129 #endif
130
131
132 #if @GNULIB_ATOLL@
133 /* Parse a signed decimal integer.
134    Returns the value of the integer.  Errors are not detected.  */
135 # if !@HAVE_ATOLL@
136 _GL_FUNCDECL_SYS (atoll, long long, (const char *string) _GL_ARG_NONNULL ((1)));
137 # endif
138 _GL_CXXALIAS_SYS (atoll, long long, (const char *string));
139 _GL_CXXALIASWARN (atoll);
140 #elif defined GNULIB_POSIXCHECK
141 # undef atoll
142 # if HAVE_RAW_DECL_ATOLL
143 _GL_WARN_ON_USE (atoll, "atoll is unportable - "
144                  "use gnulib module atoll for portability");
145 # endif
146 #endif
147
148 #if @GNULIB_CALLOC_POSIX@
149 # if @REPLACE_CALLOC@
150 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
151 #   undef calloc
152 #   define calloc rpl_calloc
153 #  endif
154 _GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size));
155 _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
156 # else
157 _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
158 # endif
159 _GL_CXXALIASWARN (calloc);
160 #elif defined GNULIB_POSIXCHECK
161 # undef calloc
162 /* Assume calloc is always declared.  */
163 _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
164                  "use gnulib module calloc-posix for portability");
165 #endif
166
167 #if @GNULIB_CANONICALIZE_FILE_NAME@
168 # if @REPLACE_CANONICALIZE_FILE_NAME@
169 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
170 #   define canonicalize_file_name rpl_canonicalize_file_name
171 #  endif
172 _GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name)
173                                                   _GL_ARG_NONNULL ((1)));
174 _GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
175 # else
176 #  if !@HAVE_CANONICALIZE_FILE_NAME@
177 _GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name)
178                                                   _GL_ARG_NONNULL ((1)));
179 #  endif
180 _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
181 # endif
182 _GL_CXXALIASWARN (canonicalize_file_name);
183 #elif defined GNULIB_POSIXCHECK
184 # undef canonicalize_file_name
185 # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
186 _GL_WARN_ON_USE (canonicalize_file_name,
187                  "canonicalize_file_name is unportable - "
188                  "use gnulib module canonicalize-lgpl for portability");
189 # endif
190 #endif
191
192 #if @GNULIB_GETLOADAVG@
193 /* Store max(NELEM,3) load average numbers in LOADAVG[].
194    The three numbers are the load average of the last 1 minute, the last 5
195    minutes, and the last 15 minutes, respectively.
196    LOADAVG is an array of NELEM numbers.  */
197 # if !@HAVE_DECL_GETLOADAVG@
198 _GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem)
199                                    _GL_ARG_NONNULL ((1)));
200 # endif
201 _GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
202 _GL_CXXALIASWARN (getloadavg);
203 #elif defined GNULIB_POSIXCHECK
204 # undef getloadavg
205 # if HAVE_RAW_DECL_GETLOADAVG
206 _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
207                  "use gnulib module getloadavg for portability");
208 # endif
209 #endif
210
211 #if @GNULIB_GETSUBOPT@
212 /* Assuming *OPTIONP is a comma separated list of elements of the form
213    "token" or "token=value", getsubopt parses the first of these elements.
214    If the first element refers to a "token" that is member of the given
215    NULL-terminated array of tokens:
216      - It replaces the comma with a NUL byte, updates *OPTIONP to point past
217        the first option and the comma, sets *VALUEP to the value of the
218        element (or NULL if it doesn't contain an "=" sign),
219      - It returns the index of the "token" in the given array of tokens.
220    Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
221    For more details see the POSIX:2001 specification.
222    http://www.opengroup.org/susv3xsh/getsubopt.html */
223 # if !@HAVE_GETSUBOPT@
224 _GL_FUNCDECL_SYS (getsubopt, int,
225                   (char **optionp, char *const *tokens, char **valuep)
226                   _GL_ARG_NONNULL ((1, 2, 3)));
227 # endif
228 _GL_CXXALIAS_SYS (getsubopt, int,
229                   (char **optionp, char *const *tokens, char **valuep));
230 _GL_CXXALIASWARN (getsubopt);
231 #elif defined GNULIB_POSIXCHECK
232 # undef getsubopt
233 # if HAVE_RAW_DECL_GETSUBOPT
234 _GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
235                  "use gnulib module getsubopt for portability");
236 # endif
237 #endif
238
239 #if @GNULIB_GRANTPT@
240 /* Change the ownership and access permission of the slave side of the
241    pseudo-terminal whose master side is specified by FD.  */
242 # if !@HAVE_GRANTPT@
243 _GL_FUNCDECL_SYS (grantpt, int, (int fd));
244 # endif
245 _GL_CXXALIAS_SYS (grantpt, int, (int fd));
246 _GL_CXXALIASWARN (grantpt);
247 #elif defined GNULIB_POSIXCHECK
248 # undef grantpt
249 # if HAVE_RAW_DECL_GRANTPT
250 _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
251                  "use gnulib module grantpt for portability");
252 # endif
253 #endif
254
255 /* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
256    rely on GNU or POSIX semantics for malloc and realloc (for example,
257    by never specifying a zero size), so it does not need malloc or
258    realloc to be redefined.  */
259 #if @GNULIB_MALLOC_POSIX@
260 # if @REPLACE_MALLOC@
261 #  if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
262         || _GL_USE_STDLIB_ALLOC)
263 #   undef malloc
264 #   define malloc rpl_malloc
265 #  endif
266 _GL_FUNCDECL_RPL (malloc, void *, (size_t size));
267 _GL_CXXALIAS_RPL (malloc, void *, (size_t size));
268 # else
269 _GL_CXXALIAS_SYS (malloc, void *, (size_t size));
270 # endif
271 _GL_CXXALIASWARN (malloc);
272 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
273 # undef malloc
274 /* Assume malloc is always declared.  */
275 _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
276                  "use gnulib module malloc-posix for portability");
277 #endif
278
279 /* Convert a multibyte character to a wide character.  */
280 #if @GNULIB_MBTOWC@
281 # if @REPLACE_MBTOWC@
282 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
283 #   undef mbtowc
284 #   define mbtowc rpl_mbtowc
285 #  endif
286 _GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
287 _GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
288 # else
289 _GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
290 # endif
291 _GL_CXXALIASWARN (mbtowc);
292 #endif
293
294 #if @GNULIB_MKDTEMP@
295 /* Create a unique temporary directory from TEMPLATE.
296    The last six characters of TEMPLATE must be "XXXXXX";
297    they are replaced with a string that makes the directory name unique.
298    Returns TEMPLATE, or a null pointer if it cannot get a unique name.
299    The directory is created mode 700.  */
300 # if !@HAVE_MKDTEMP@
301 _GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
302 # endif
303 _GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
304 _GL_CXXALIASWARN (mkdtemp);
305 #elif defined GNULIB_POSIXCHECK
306 # undef mkdtemp
307 # if HAVE_RAW_DECL_MKDTEMP
308 _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
309                  "use gnulib module mkdtemp for portability");
310 # endif
311 #endif
312
313 #if @GNULIB_MKOSTEMP@
314 /* Create a unique temporary file from TEMPLATE.
315    The last six characters of TEMPLATE must be "XXXXXX";
316    they are replaced with a string that makes the file name unique.
317    The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
318    and O_TEXT, O_BINARY (defined in "binary-io.h").
319    The file is then created, with the specified flags, ensuring it didn't exist
320    before.
321    The file is created read-write (mask at least 0600 & ~umask), but it may be
322    world-readable and world-writable (mask 0666 & ~umask), depending on the
323    implementation.
324    Returns the open file descriptor if successful, otherwise -1 and errno
325    set.  */
326 # if !@HAVE_MKOSTEMP@
327 _GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)
328                                  _GL_ARG_NONNULL ((1)));
329 # endif
330 _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
331 _GL_CXXALIASWARN (mkostemp);
332 #elif defined GNULIB_POSIXCHECK
333 # undef mkostemp
334 # if HAVE_RAW_DECL_MKOSTEMP
335 _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
336                  "use gnulib module mkostemp for portability");
337 # endif
338 #endif
339
340 #if @GNULIB_MKOSTEMPS@
341 /* Create a unique temporary file from TEMPLATE.
342    The last six characters of TEMPLATE before a suffix of length
343    SUFFIXLEN must be "XXXXXX";
344    they are replaced with a string that makes the file name unique.
345    The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
346    and O_TEXT, O_BINARY (defined in "binary-io.h").
347    The file is then created, with the specified flags, ensuring it didn't exist
348    before.
349    The file is created read-write (mask at least 0600 & ~umask), but it may be
350    world-readable and world-writable (mask 0666 & ~umask), depending on the
351    implementation.
352    Returns the open file descriptor if successful, otherwise -1 and errno
353    set.  */
354 # if !@HAVE_MKOSTEMPS@
355 _GL_FUNCDECL_SYS (mkostemps, int,
356                   (char * /*template*/, int /*suffixlen*/, int /*flags*/)
357                   _GL_ARG_NONNULL ((1)));
358 # endif
359 _GL_CXXALIAS_SYS (mkostemps, int,
360                   (char * /*template*/, int /*suffixlen*/, int /*flags*/));
361 _GL_CXXALIASWARN (mkostemps);
362 #elif defined GNULIB_POSIXCHECK
363 # undef mkostemps
364 # if HAVE_RAW_DECL_MKOSTEMPS
365 _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
366                  "use gnulib module mkostemps for portability");
367 # endif
368 #endif
369
370 #if @GNULIB_MKSTEMP@
371 /* Create a unique temporary file from TEMPLATE.
372    The last six characters of TEMPLATE must be "XXXXXX";
373    they are replaced with a string that makes the file name unique.
374    The file is then created, ensuring it didn't exist before.
375    The file is created read-write (mask at least 0600 & ~umask), but it may be
376    world-readable and world-writable (mask 0666 & ~umask), depending on the
377    implementation.
378    Returns the open file descriptor if successful, otherwise -1 and errno
379    set.  */
380 # if @REPLACE_MKSTEMP@
381 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
382 #   define mkstemp rpl_mkstemp
383 #  endif
384 _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
385 _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
386 # else
387 #  if ! @HAVE_MKSTEMP@
388 _GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
389 #  endif
390 _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
391 # endif
392 _GL_CXXALIASWARN (mkstemp);
393 #elif defined GNULIB_POSIXCHECK
394 # undef mkstemp
395 # if HAVE_RAW_DECL_MKSTEMP
396 _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
397                  "use gnulib module mkstemp for portability");
398 # endif
399 #endif
400
401 #if @GNULIB_MKSTEMPS@
402 /* Create a unique temporary file from TEMPLATE.
403    The last six characters of TEMPLATE prior to a suffix of length
404    SUFFIXLEN must be "XXXXXX";
405    they are replaced with a string that makes the file name unique.
406    The file is then created, ensuring it didn't exist before.
407    The file is created read-write (mask at least 0600 & ~umask), but it may be
408    world-readable and world-writable (mask 0666 & ~umask), depending on the
409    implementation.
410    Returns the open file descriptor if successful, otherwise -1 and errno
411    set.  */
412 # if !@HAVE_MKSTEMPS@
413 _GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)
414                                  _GL_ARG_NONNULL ((1)));
415 # endif
416 _GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
417 _GL_CXXALIASWARN (mkstemps);
418 #elif defined GNULIB_POSIXCHECK
419 # undef mkstemps
420 # if HAVE_RAW_DECL_MKSTEMPS
421 _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
422                  "use gnulib module mkstemps for portability");
423 # endif
424 #endif
425
426 #if @GNULIB_POSIX_OPENPT@
427 /* Return an FD open to the master side of a pseudo-terminal.  Flags should
428    include O_RDWR, and may also include O_NOCTTY.  */
429 # if !@HAVE_POSIX_OPENPT@
430 _GL_FUNCDECL_SYS (posix_openpt, int, (int flags));
431 # endif
432 _GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
433 _GL_CXXALIASWARN (posix_openpt);
434 #elif defined GNULIB_POSIXCHECK
435 # undef posix_openpt
436 # if HAVE_RAW_DECL_POSIX_OPENPT
437 _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
438                  "use gnulib module posix_openpt for portability");
439 # endif
440 #endif
441
442 #if @GNULIB_PTSNAME@
443 /* Return the pathname of the pseudo-terminal slave associated with
444    the master FD is open on, or NULL on errors.  */
445 # if !@HAVE_PTSNAME@
446 _GL_FUNCDECL_SYS (ptsname, char *, (int fd));
447 # endif
448 _GL_CXXALIAS_SYS (ptsname, char *, (int fd));
449 _GL_CXXALIASWARN (ptsname);
450 #elif defined GNULIB_POSIXCHECK
451 # undef ptsname
452 # if HAVE_RAW_DECL_PTSNAME
453 _GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
454                  "use gnulib module ptsname for portability");
455 # endif
456 #endif
457
458 #if @GNULIB_PTSNAME_R@
459 /* Set the pathname of the pseudo-terminal slave associated with
460    the master FD is open on and return 0, or set errno and return
461    non-zero on errors.  */
462 # if @REPLACE_PTSNAME_R@
463 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
464 #   undef ptsname_r
465 #   define ptsname_r rpl_ptsname_r
466 #  endif
467 _GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
468 _GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
469 # else
470 #  if !@HAVE_PTSNAME_R@
471 _GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
472 #  endif
473 _GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
474 # endif
475 _GL_CXXALIASWARN (ptsname_r);
476 #elif defined GNULIB_POSIXCHECK
477 # undef ptsname_r
478 # if HAVE_RAW_DECL_PTSNAME_R
479 _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
480                  "use gnulib module ptsname_r for portability");
481 # endif
482 #endif
483
484 #if @GNULIB_PUTENV@
485 # if @REPLACE_PUTENV@
486 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
487 #   undef putenv
488 #   define putenv rpl_putenv
489 #  endif
490 _GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
491 _GL_CXXALIAS_RPL (putenv, int, (char *string));
492 # else
493 _GL_CXXALIAS_SYS (putenv, int, (char *string));
494 # endif
495 _GL_CXXALIASWARN (putenv);
496 #endif
497
498
499 #if @GNULIB_RANDOM_R@
500 # if !@HAVE_RANDOM_R@
501 #  ifndef RAND_MAX
502 #   define RAND_MAX 2147483647
503 #  endif
504 # endif
505 #endif
506
507
508 #if @GNULIB_RANDOM@
509 # if !@HAVE_RANDOM@
510 _GL_FUNCDECL_SYS (random, long, (void));
511 # endif
512 _GL_CXXALIAS_SYS (random, long, (void));
513 _GL_CXXALIASWARN (random);
514 #elif defined GNULIB_POSIXCHECK
515 # undef random
516 # if HAVE_RAW_DECL_RANDOM
517 _GL_WARN_ON_USE (random, "random is unportable - "
518                  "use gnulib module random for portability");
519 # endif
520 #endif
521
522 #if @GNULIB_RANDOM@
523 # if !@HAVE_RANDOM@
524 _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
525 # endif
526 _GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
527 _GL_CXXALIASWARN (srandom);
528 #elif defined GNULIB_POSIXCHECK
529 # undef srandom
530 # if HAVE_RAW_DECL_SRANDOM
531 _GL_WARN_ON_USE (srandom, "srandom is unportable - "
532                  "use gnulib module random for portability");
533 # endif
534 #endif
535
536 #if @GNULIB_RANDOM@
537 # if !@HAVE_RANDOM@
538 _GL_FUNCDECL_SYS (initstate, char *,
539                   (unsigned int seed, char *buf, size_t buf_size)
540                   _GL_ARG_NONNULL ((2)));
541 # endif
542 _GL_CXXALIAS_SYS (initstate, char *,
543                   (unsigned int seed, char *buf, size_t buf_size));
544 _GL_CXXALIASWARN (initstate);
545 #elif defined GNULIB_POSIXCHECK
546 # undef initstate
547 # if HAVE_RAW_DECL_INITSTATE_R
548 _GL_WARN_ON_USE (initstate, "initstate is unportable - "
549                  "use gnulib module random for portability");
550 # endif
551 #endif
552
553 #if @GNULIB_RANDOM@
554 # if !@HAVE_RANDOM@
555 _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
556 # endif
557 _GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
558 _GL_CXXALIASWARN (setstate);
559 #elif defined GNULIB_POSIXCHECK
560 # undef setstate
561 # if HAVE_RAW_DECL_SETSTATE_R
562 _GL_WARN_ON_USE (setstate, "setstate is unportable - "
563                  "use gnulib module random for portability");
564 # endif
565 #endif
566
567
568 #if @GNULIB_RANDOM_R@
569 # if @REPLACE_RANDOM_R@
570 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
571 #   undef random_r
572 #   define random_r rpl_random_r
573 #  endif
574 _GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
575                                  _GL_ARG_NONNULL ((1, 2)));
576 _GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
577 # else
578 #  if !@HAVE_RANDOM_R@
579 _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
580                                  _GL_ARG_NONNULL ((1, 2)));
581 #  endif
582 _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
583 # endif
584 _GL_CXXALIASWARN (random_r);
585 #elif defined GNULIB_POSIXCHECK
586 # undef random_r
587 # if HAVE_RAW_DECL_RANDOM_R
588 _GL_WARN_ON_USE (random_r, "random_r is unportable - "
589                  "use gnulib module random_r for portability");
590 # endif
591 #endif
592
593 #if @GNULIB_RANDOM_R@
594 # if @REPLACE_RANDOM_R@
595 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
596 #   undef srandom_r
597 #   define srandom_r rpl_srandom_r
598 #  endif
599 _GL_FUNCDECL_RPL (srandom_r, int,
600                   (unsigned int seed, struct random_data *rand_state)
601                   _GL_ARG_NONNULL ((2)));
602 _GL_CXXALIAS_RPL (srandom_r, int,
603                   (unsigned int seed, struct random_data *rand_state));
604 # else
605 #  if !@HAVE_RANDOM_R@
606 _GL_FUNCDECL_SYS (srandom_r, int,
607                   (unsigned int seed, struct random_data *rand_state)
608                   _GL_ARG_NONNULL ((2)));
609 #  endif
610 _GL_CXXALIAS_SYS (srandom_r, int,
611                   (unsigned int seed, struct random_data *rand_state));
612 # endif
613 _GL_CXXALIASWARN (srandom_r);
614 #elif defined GNULIB_POSIXCHECK
615 # undef srandom_r
616 # if HAVE_RAW_DECL_SRANDOM_R
617 _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
618                  "use gnulib module random_r for portability");
619 # endif
620 #endif
621
622 #if @GNULIB_RANDOM_R@
623 # if @REPLACE_RANDOM_R@
624 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
625 #   undef initstate_r
626 #   define initstate_r rpl_initstate_r
627 #  endif
628 _GL_FUNCDECL_RPL (initstate_r, int,
629                   (unsigned int seed, char *buf, size_t buf_size,
630                    struct random_data *rand_state)
631                   _GL_ARG_NONNULL ((2, 4)));
632 _GL_CXXALIAS_RPL (initstate_r, int,
633                   (unsigned int seed, char *buf, size_t buf_size,
634                    struct random_data *rand_state));
635 # else
636 #  if !@HAVE_RANDOM_R@
637 _GL_FUNCDECL_SYS (initstate_r, int,
638                   (unsigned int seed, char *buf, size_t buf_size,
639                    struct random_data *rand_state)
640                   _GL_ARG_NONNULL ((2, 4)));
641 #  endif
642 _GL_CXXALIAS_SYS (initstate_r, int,
643                   (unsigned int seed, char *buf, size_t buf_size,
644                    struct random_data *rand_state));
645 # endif
646 _GL_CXXALIASWARN (initstate_r);
647 #elif defined GNULIB_POSIXCHECK
648 # undef initstate_r
649 # if HAVE_RAW_DECL_INITSTATE_R
650 _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
651                  "use gnulib module random_r for portability");
652 # endif
653 #endif
654
655 #if @GNULIB_RANDOM_R@
656 # if @REPLACE_RANDOM_R@
657 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
658 #   undef setstate_r
659 #   define setstate_r rpl_setstate_r
660 #  endif
661 _GL_FUNCDECL_RPL (setstate_r, int,
662                   (char *arg_state, struct random_data *rand_state)
663                   _GL_ARG_NONNULL ((1, 2)));
664 _GL_CXXALIAS_RPL (setstate_r, int,
665                   (char *arg_state, struct random_data *rand_state));
666 # else
667 #  if !@HAVE_RANDOM_R@
668 _GL_FUNCDECL_SYS (setstate_r, int,
669                   (char *arg_state, struct random_data *rand_state)
670                   _GL_ARG_NONNULL ((1, 2)));
671 #  endif
672 _GL_CXXALIAS_SYS (setstate_r, int,
673                   (char *arg_state, struct random_data *rand_state));
674 # endif
675 _GL_CXXALIASWARN (setstate_r);
676 #elif defined GNULIB_POSIXCHECK
677 # undef setstate_r
678 # if HAVE_RAW_DECL_SETSTATE_R
679 _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
680                  "use gnulib module random_r for portability");
681 # endif
682 #endif
683
684
685 #if @GNULIB_REALLOC_POSIX@
686 # if @REPLACE_REALLOC@
687 #  if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
688         || _GL_USE_STDLIB_ALLOC)
689 #   undef realloc
690 #   define realloc rpl_realloc
691 #  endif
692 _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size));
693 _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
694 # else
695 _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
696 # endif
697 _GL_CXXALIASWARN (realloc);
698 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
699 # undef realloc
700 /* Assume realloc is always declared.  */
701 _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
702                  "use gnulib module realloc-posix for portability");
703 #endif
704
705 #if @GNULIB_REALPATH@
706 # if @REPLACE_REALPATH@
707 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
708 #   define realpath rpl_realpath
709 #  endif
710 _GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved)
711                                     _GL_ARG_NONNULL ((1)));
712 _GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved));
713 # else
714 #  if !@HAVE_REALPATH@
715 _GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved)
716                                     _GL_ARG_NONNULL ((1)));
717 #  endif
718 _GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved));
719 # endif
720 _GL_CXXALIASWARN (realpath);
721 #elif defined GNULIB_POSIXCHECK
722 # undef realpath
723 # if HAVE_RAW_DECL_REALPATH
724 _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
725                  "canonicalize or canonicalize-lgpl for portability");
726 # endif
727 #endif
728
729 #if @GNULIB_RPMATCH@
730 /* Test a user response to a question.
731    Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear.  */
732 # if !@HAVE_RPMATCH@
733 _GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1)));
734 # endif
735 _GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
736 _GL_CXXALIASWARN (rpmatch);
737 #elif defined GNULIB_POSIXCHECK
738 # undef rpmatch
739 # if HAVE_RAW_DECL_RPMATCH
740 _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
741                  "use gnulib module rpmatch for portability");
742 # endif
743 #endif
744
745 #if @GNULIB_SETENV@
746 /* Set NAME to VALUE in the environment.
747    If REPLACE is nonzero, overwrite an existing value.  */
748 # if @REPLACE_SETENV@
749 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
750 #   undef setenv
751 #   define setenv rpl_setenv
752 #  endif
753 _GL_FUNCDECL_RPL (setenv, int,
754                   (const char *name, const char *value, int replace)
755                   _GL_ARG_NONNULL ((1)));
756 _GL_CXXALIAS_RPL (setenv, int,
757                   (const char *name, const char *value, int replace));
758 # else
759 #  if !@HAVE_DECL_SETENV@
760 _GL_FUNCDECL_SYS (setenv, int,
761                   (const char *name, const char *value, int replace)
762                   _GL_ARG_NONNULL ((1)));
763 #  endif
764 _GL_CXXALIAS_SYS (setenv, int,
765                   (const char *name, const char *value, int replace));
766 # endif
767 # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
768 _GL_CXXALIASWARN (setenv);
769 # endif
770 #elif defined GNULIB_POSIXCHECK
771 # undef setenv
772 # if HAVE_RAW_DECL_SETENV
773 _GL_WARN_ON_USE (setenv, "setenv is unportable - "
774                  "use gnulib module setenv for portability");
775 # endif
776 #endif
777
778 #if @GNULIB_STRTOD@
779  /* Parse a double from STRING, updating ENDP if appropriate.  */
780 # if @REPLACE_STRTOD@
781 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
782 #   define strtod rpl_strtod
783 #  endif
784 _GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp)
785                                   _GL_ARG_NONNULL ((1)));
786 _GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp));
787 # else
788 #  if !@HAVE_STRTOD@
789 _GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp)
790                                   _GL_ARG_NONNULL ((1)));
791 #  endif
792 _GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp));
793 # endif
794 _GL_CXXALIASWARN (strtod);
795 #elif defined GNULIB_POSIXCHECK
796 # undef strtod
797 # if HAVE_RAW_DECL_STRTOD
798 _GL_WARN_ON_USE (strtod, "strtod is unportable - "
799                  "use gnulib module strtod for portability");
800 # endif
801 #endif
802
803 #if @GNULIB_STRTOLL@
804 /* Parse a signed integer whose textual representation starts at STRING.
805    The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
806    it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
807    "0x").
808    If ENDPTR is not NULL, the address of the first byte after the integer is
809    stored in *ENDPTR.
810    Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
811    to ERANGE.  */
812 # if !@HAVE_STRTOLL@
813 _GL_FUNCDECL_SYS (strtoll, long long,
814                   (const char *string, char **endptr, int base)
815                   _GL_ARG_NONNULL ((1)));
816 # endif
817 _GL_CXXALIAS_SYS (strtoll, long long,
818                   (const char *string, char **endptr, int base));
819 _GL_CXXALIASWARN (strtoll);
820 #elif defined GNULIB_POSIXCHECK
821 # undef strtoll
822 # if HAVE_RAW_DECL_STRTOLL
823 _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
824                  "use gnulib module strtoll for portability");
825 # endif
826 #endif
827
828 #if @GNULIB_STRTOULL@
829 /* Parse an unsigned integer whose textual representation starts at STRING.
830    The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
831    it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
832    "0x").
833    If ENDPTR is not NULL, the address of the first byte after the integer is
834    stored in *ENDPTR.
835    Upon overflow, the return value is ULLONG_MAX, and errno is set to
836    ERANGE.  */
837 # if !@HAVE_STRTOULL@
838 _GL_FUNCDECL_SYS (strtoull, unsigned long long,
839                   (const char *string, char **endptr, int base)
840                   _GL_ARG_NONNULL ((1)));
841 # endif
842 _GL_CXXALIAS_SYS (strtoull, unsigned long long,
843                   (const char *string, char **endptr, int base));
844 _GL_CXXALIASWARN (strtoull);
845 #elif defined GNULIB_POSIXCHECK
846 # undef strtoull
847 # if HAVE_RAW_DECL_STRTOULL
848 _GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
849                  "use gnulib module strtoull for portability");
850 # endif
851 #endif
852
853 #if @GNULIB_UNLOCKPT@
854 /* Unlock the slave side of the pseudo-terminal whose master side is specified
855    by FD, so that it can be opened.  */
856 # if !@HAVE_UNLOCKPT@
857 _GL_FUNCDECL_SYS (unlockpt, int, (int fd));
858 # endif
859 _GL_CXXALIAS_SYS (unlockpt, int, (int fd));
860 _GL_CXXALIASWARN (unlockpt);
861 #elif defined GNULIB_POSIXCHECK
862 # undef unlockpt
863 # if HAVE_RAW_DECL_UNLOCKPT
864 _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
865                  "use gnulib module unlockpt for portability");
866 # endif
867 #endif
868
869 #if @GNULIB_UNSETENV@
870 /* Remove the variable NAME from the environment.  */
871 # if @REPLACE_UNSETENV@
872 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
873 #   undef unsetenv
874 #   define unsetenv rpl_unsetenv
875 #  endif
876 _GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
877 _GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
878 # else
879 #  if !@HAVE_DECL_UNSETENV@
880 _GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
881 #  endif
882 _GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
883 # endif
884 # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
885 _GL_CXXALIASWARN (unsetenv);
886 # endif
887 #elif defined GNULIB_POSIXCHECK
888 # undef unsetenv
889 # if HAVE_RAW_DECL_UNSETENV
890 _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
891                  "use gnulib module unsetenv for portability");
892 # endif
893 #endif
894
895 /* Convert a wide character to a multibyte character.  */
896 #if @GNULIB_WCTOMB@
897 # if @REPLACE_WCTOMB@
898 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
899 #   undef wctomb
900 #   define wctomb rpl_wctomb
901 #  endif
902 _GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc));
903 _GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
904 # else
905 _GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
906 # endif
907 _GL_CXXALIASWARN (wctomb);
908 #endif
909
910
911 #endif /* _@GUARD_PREFIX@_STDLIB_H */
912 #endif /* _@GUARD_PREFIX@_STDLIB_H */
913 #endif