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