; * lisp/ldefs-boot.el: Update.
[emacs.git] / lib / stdlib.in.h
blob6e3866dd8a133d566a6d9ca148c1b7ef6d493517
1 /* A GNU-like <stdlib.h>.
3 Copyright (C) 1995, 2001-2004, 2006-2019 Free Software Foundation,
4 Inc.
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.
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.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19 #if __GNUC__ >= 3
20 @PRAGMA_SYSTEM_HEADER@
21 #endif
22 @PRAGMA_COLUMNS@
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. */
28 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
30 #else
31 /* Normal invocation convention. */
33 #ifndef _@GUARD_PREFIX@_STDLIB_H
35 /* The include_next requires a split double-inclusion guard. */
36 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
38 #ifndef _@GUARD_PREFIX@_STDLIB_H
39 #define _@GUARD_PREFIX@_STDLIB_H
41 /* NetBSD 5.0 mis-defines NULL. */
42 #include <stddef.h>
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
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
54 /* Native Windows platforms declare mktemp() in <io.h>. */
55 #if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
56 # include <io.h>
57 #endif
59 #if @GNULIB_RANDOM_R@
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
68 # if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
69 # include <stdint.h>
70 # endif
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
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. */
86 # define GNULIB_defined_struct_random_data 1
87 # endif
88 # endif
89 #endif
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
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
107 /* The definition of _Noreturn is copied here. */
109 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
111 /* The definition of _GL_ARG_NONNULL is copied here. */
113 /* The definition of _GL_WARN_ON_USE is copied here. */
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
524 #if @GNULIB_QSORT_R@
525 /* Sort an array of NMEMB elements, starting at address BASE, each element
526 occupying SIZE bytes, in ascending order according to the comparison
527 function COMPARE. */
528 # if @REPLACE_QSORT_R@
529 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
530 # undef qsort_r
531 # define qsort_r rpl_qsort_r
532 # endif
533 _GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
534 int (*compare) (void const *, void const *,
535 void *),
536 void *arg) _GL_ARG_NONNULL ((1, 4)));
537 _GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
538 int (*compare) (void const *, void const *,
539 void *),
540 void *arg));
541 # else
542 # if !@HAVE_QSORT_R@
543 _GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
544 int (*compare) (void const *, void const *,
545 void *),
546 void *arg) _GL_ARG_NONNULL ((1, 4)));
547 # endif
548 _GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
549 int (*compare) (void const *, void const *,
550 void *),
551 void *arg));
552 # endif
553 _GL_CXXALIASWARN (qsort_r);
554 #elif defined GNULIB_POSIXCHECK
555 # undef qsort_r
556 # if HAVE_RAW_DECL_QSORT_R
557 _GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
558 "use gnulib module qsort_r for portability");
559 # endif
560 #endif
563 #if @GNULIB_RANDOM_R@
564 # if !@HAVE_RANDOM_R@
565 # ifndef RAND_MAX
566 # define RAND_MAX 2147483647
567 # endif
568 # endif
569 #endif
572 #if @GNULIB_RANDOM@
573 # if !@HAVE_RANDOM@
574 _GL_FUNCDECL_SYS (random, long, (void));
575 # endif
576 _GL_CXXALIAS_SYS (random, long, (void));
577 _GL_CXXALIASWARN (random);
578 #elif defined GNULIB_POSIXCHECK
579 # undef random
580 # if HAVE_RAW_DECL_RANDOM
581 _GL_WARN_ON_USE (random, "random is unportable - "
582 "use gnulib module random for portability");
583 # endif
584 #endif
586 #if @GNULIB_RANDOM@
587 # if !@HAVE_RANDOM@
588 _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
589 # endif
590 _GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
591 _GL_CXXALIASWARN (srandom);
592 #elif defined GNULIB_POSIXCHECK
593 # undef srandom
594 # if HAVE_RAW_DECL_SRANDOM
595 _GL_WARN_ON_USE (srandom, "srandom is unportable - "
596 "use gnulib module random for portability");
597 # endif
598 #endif
600 #if @GNULIB_RANDOM@
601 # if !@HAVE_RANDOM@ || !@HAVE_DECL_INITSTATE@
602 _GL_FUNCDECL_SYS (initstate, char *,
603 (unsigned int seed, char *buf, size_t buf_size)
604 _GL_ARG_NONNULL ((2)));
605 # endif
606 _GL_CXXALIAS_SYS (initstate, char *,
607 (unsigned int seed, char *buf, size_t buf_size));
608 _GL_CXXALIASWARN (initstate);
609 #elif defined GNULIB_POSIXCHECK
610 # undef initstate
611 # if HAVE_RAW_DECL_INITSTATE_R
612 _GL_WARN_ON_USE (initstate, "initstate is unportable - "
613 "use gnulib module random for portability");
614 # endif
615 #endif
617 #if @GNULIB_RANDOM@
618 # if !@HAVE_RANDOM@ || !@HAVE_DECL_SETSTATE@
619 _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
620 # endif
621 _GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
622 _GL_CXXALIASWARN (setstate);
623 #elif defined GNULIB_POSIXCHECK
624 # undef setstate
625 # if HAVE_RAW_DECL_SETSTATE_R
626 _GL_WARN_ON_USE (setstate, "setstate is unportable - "
627 "use gnulib module random for portability");
628 # endif
629 #endif
632 #if @GNULIB_RANDOM_R@
633 # if @REPLACE_RANDOM_R@
634 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
635 # undef random_r
636 # define random_r rpl_random_r
637 # endif
638 _GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
639 _GL_ARG_NONNULL ((1, 2)));
640 _GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
641 # else
642 # if !@HAVE_RANDOM_R@
643 _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
644 _GL_ARG_NONNULL ((1, 2)));
645 # endif
646 _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
647 # endif
648 _GL_CXXALIASWARN (random_r);
649 #elif defined GNULIB_POSIXCHECK
650 # undef random_r
651 # if HAVE_RAW_DECL_RANDOM_R
652 _GL_WARN_ON_USE (random_r, "random_r is unportable - "
653 "use gnulib module random_r for portability");
654 # endif
655 #endif
657 #if @GNULIB_RANDOM_R@
658 # if @REPLACE_RANDOM_R@
659 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
660 # undef srandom_r
661 # define srandom_r rpl_srandom_r
662 # endif
663 _GL_FUNCDECL_RPL (srandom_r, int,
664 (unsigned int seed, struct random_data *rand_state)
665 _GL_ARG_NONNULL ((2)));
666 _GL_CXXALIAS_RPL (srandom_r, int,
667 (unsigned int seed, struct random_data *rand_state));
668 # else
669 # if !@HAVE_RANDOM_R@
670 _GL_FUNCDECL_SYS (srandom_r, int,
671 (unsigned int seed, struct random_data *rand_state)
672 _GL_ARG_NONNULL ((2)));
673 # endif
674 _GL_CXXALIAS_SYS (srandom_r, int,
675 (unsigned int seed, struct random_data *rand_state));
676 # endif
677 _GL_CXXALIASWARN (srandom_r);
678 #elif defined GNULIB_POSIXCHECK
679 # undef srandom_r
680 # if HAVE_RAW_DECL_SRANDOM_R
681 _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
682 "use gnulib module random_r for portability");
683 # endif
684 #endif
686 #if @GNULIB_RANDOM_R@
687 # if @REPLACE_RANDOM_R@
688 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
689 # undef initstate_r
690 # define initstate_r rpl_initstate_r
691 # endif
692 _GL_FUNCDECL_RPL (initstate_r, int,
693 (unsigned int seed, char *buf, size_t buf_size,
694 struct random_data *rand_state)
695 _GL_ARG_NONNULL ((2, 4)));
696 _GL_CXXALIAS_RPL (initstate_r, int,
697 (unsigned int seed, char *buf, size_t buf_size,
698 struct random_data *rand_state));
699 # else
700 # if !@HAVE_RANDOM_R@
701 _GL_FUNCDECL_SYS (initstate_r, int,
702 (unsigned int seed, char *buf, size_t buf_size,
703 struct random_data *rand_state)
704 _GL_ARG_NONNULL ((2, 4)));
705 # endif
706 _GL_CXXALIAS_SYS (initstate_r, int,
707 (unsigned int seed, char *buf, size_t buf_size,
708 struct random_data *rand_state));
709 # endif
710 _GL_CXXALIASWARN (initstate_r);
711 #elif defined GNULIB_POSIXCHECK
712 # undef initstate_r
713 # if HAVE_RAW_DECL_INITSTATE_R
714 _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
715 "use gnulib module random_r for portability");
716 # endif
717 #endif
719 #if @GNULIB_RANDOM_R@
720 # if @REPLACE_RANDOM_R@
721 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
722 # undef setstate_r
723 # define setstate_r rpl_setstate_r
724 # endif
725 _GL_FUNCDECL_RPL (setstate_r, int,
726 (char *arg_state, struct random_data *rand_state)
727 _GL_ARG_NONNULL ((1, 2)));
728 _GL_CXXALIAS_RPL (setstate_r, int,
729 (char *arg_state, struct random_data *rand_state));
730 # else
731 # if !@HAVE_RANDOM_R@
732 _GL_FUNCDECL_SYS (setstate_r, int,
733 (char *arg_state, struct random_data *rand_state)
734 _GL_ARG_NONNULL ((1, 2)));
735 # endif
736 _GL_CXXALIAS_SYS (setstate_r, int,
737 (char *arg_state, struct random_data *rand_state));
738 # endif
739 _GL_CXXALIASWARN (setstate_r);
740 #elif defined GNULIB_POSIXCHECK
741 # undef setstate_r
742 # if HAVE_RAW_DECL_SETSTATE_R
743 _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
744 "use gnulib module random_r for portability");
745 # endif
746 #endif
749 #if @GNULIB_REALLOC_POSIX@
750 # if @REPLACE_REALLOC@
751 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
752 || _GL_USE_STDLIB_ALLOC)
753 # undef realloc
754 # define realloc rpl_realloc
755 # endif
756 _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size));
757 _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
758 # else
759 _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
760 # endif
761 _GL_CXXALIASWARN (realloc);
762 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
763 # undef realloc
764 /* Assume realloc is always declared. */
765 _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
766 "use gnulib module realloc-posix for portability");
767 #endif
770 #if @GNULIB_REALLOCARRAY@
771 # if ! @HAVE_REALLOCARRAY@
772 _GL_FUNCDECL_SYS (reallocarray, void *,
773 (void *ptr, size_t nmemb, size_t size));
774 # endif
775 _GL_CXXALIAS_SYS (reallocarray, void *,
776 (void *ptr, size_t nmemb, size_t size));
777 _GL_CXXALIASWARN (reallocarray);
778 #elif defined GNULIB_POSIXCHECK
779 # undef reallocarray
780 # if HAVE_RAW_DECL_REALLOCARRAY
781 _GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - "
782 "use gnulib module reallocarray for portability");
783 # endif
784 #endif
786 #if @GNULIB_REALPATH@
787 # if @REPLACE_REALPATH@
788 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
789 # define realpath rpl_realpath
790 # endif
791 _GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved)
792 _GL_ARG_NONNULL ((1)));
793 _GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved));
794 # else
795 # if !@HAVE_REALPATH@
796 _GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved)
797 _GL_ARG_NONNULL ((1)));
798 # endif
799 _GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved));
800 # endif
801 _GL_CXXALIASWARN (realpath);
802 #elif defined GNULIB_POSIXCHECK
803 # undef realpath
804 # if HAVE_RAW_DECL_REALPATH
805 _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
806 "canonicalize or canonicalize-lgpl for portability");
807 # endif
808 #endif
810 #if @GNULIB_RPMATCH@
811 /* Test a user response to a question.
812 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
813 # if !@HAVE_RPMATCH@
814 _GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1)));
815 # endif
816 _GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
817 _GL_CXXALIASWARN (rpmatch);
818 #elif defined GNULIB_POSIXCHECK
819 # undef rpmatch
820 # if HAVE_RAW_DECL_RPMATCH
821 _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
822 "use gnulib module rpmatch for portability");
823 # endif
824 #endif
826 #if @GNULIB_SECURE_GETENV@
827 /* Look up NAME in the environment, returning 0 in insecure situations. */
828 # if !@HAVE_SECURE_GETENV@
829 _GL_FUNCDECL_SYS (secure_getenv, char *,
830 (char const *name) _GL_ARG_NONNULL ((1)));
831 # endif
832 _GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
833 _GL_CXXALIASWARN (secure_getenv);
834 #elif defined GNULIB_POSIXCHECK
835 # undef secure_getenv
836 # if HAVE_RAW_DECL_SECURE_GETENV
837 _GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
838 "use gnulib module secure_getenv for portability");
839 # endif
840 #endif
842 #if @GNULIB_SETENV@
843 /* Set NAME to VALUE in the environment.
844 If REPLACE is nonzero, overwrite an existing value. */
845 # if @REPLACE_SETENV@
846 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
847 # undef setenv
848 # define setenv rpl_setenv
849 # endif
850 _GL_FUNCDECL_RPL (setenv, int,
851 (const char *name, const char *value, int replace)
852 _GL_ARG_NONNULL ((1)));
853 _GL_CXXALIAS_RPL (setenv, int,
854 (const char *name, const char *value, int replace));
855 # else
856 # if !@HAVE_DECL_SETENV@
857 _GL_FUNCDECL_SYS (setenv, int,
858 (const char *name, const char *value, int replace)
859 _GL_ARG_NONNULL ((1)));
860 # endif
861 _GL_CXXALIAS_SYS (setenv, int,
862 (const char *name, const char *value, int replace));
863 # endif
864 # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
865 _GL_CXXALIASWARN (setenv);
866 # endif
867 #elif defined GNULIB_POSIXCHECK
868 # undef setenv
869 # if HAVE_RAW_DECL_SETENV
870 _GL_WARN_ON_USE (setenv, "setenv is unportable - "
871 "use gnulib module setenv for portability");
872 # endif
873 #endif
875 #if @GNULIB_STRTOD@
876 /* Parse a double from STRING, updating ENDP if appropriate. */
877 # if @REPLACE_STRTOD@
878 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
879 # define strtod rpl_strtod
880 # endif
881 _GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp)
882 _GL_ARG_NONNULL ((1)));
883 _GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp));
884 # else
885 # if !@HAVE_STRTOD@
886 _GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp)
887 _GL_ARG_NONNULL ((1)));
888 # endif
889 _GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp));
890 # endif
891 _GL_CXXALIASWARN (strtod);
892 #elif defined GNULIB_POSIXCHECK
893 # undef strtod
894 # if HAVE_RAW_DECL_STRTOD
895 _GL_WARN_ON_USE (strtod, "strtod is unportable - "
896 "use gnulib module strtod for portability");
897 # endif
898 #endif
900 #if @GNULIB_STRTOLL@
901 /* Parse a signed integer whose textual representation starts at STRING.
902 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
903 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
904 "0x").
905 If ENDPTR is not NULL, the address of the first byte after the integer is
906 stored in *ENDPTR.
907 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
908 to ERANGE. */
909 # if !@HAVE_STRTOLL@
910 _GL_FUNCDECL_SYS (strtoll, long long,
911 (const char *string, char **endptr, int base)
912 _GL_ARG_NONNULL ((1)));
913 # endif
914 _GL_CXXALIAS_SYS (strtoll, long long,
915 (const char *string, char **endptr, int base));
916 _GL_CXXALIASWARN (strtoll);
917 #elif defined GNULIB_POSIXCHECK
918 # undef strtoll
919 # if HAVE_RAW_DECL_STRTOLL
920 _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
921 "use gnulib module strtoll for portability");
922 # endif
923 #endif
925 #if @GNULIB_STRTOULL@
926 /* Parse an unsigned integer whose textual representation starts at STRING.
927 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
928 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
929 "0x").
930 If ENDPTR is not NULL, the address of the first byte after the integer is
931 stored in *ENDPTR.
932 Upon overflow, the return value is ULLONG_MAX, and errno is set to
933 ERANGE. */
934 # if !@HAVE_STRTOULL@
935 _GL_FUNCDECL_SYS (strtoull, unsigned long long,
936 (const char *string, char **endptr, int base)
937 _GL_ARG_NONNULL ((1)));
938 # endif
939 _GL_CXXALIAS_SYS (strtoull, unsigned long long,
940 (const char *string, char **endptr, int base));
941 _GL_CXXALIASWARN (strtoull);
942 #elif defined GNULIB_POSIXCHECK
943 # undef strtoull
944 # if HAVE_RAW_DECL_STRTOULL
945 _GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
946 "use gnulib module strtoull for portability");
947 # endif
948 #endif
950 #if @GNULIB_UNLOCKPT@
951 /* Unlock the slave side of the pseudo-terminal whose master side is specified
952 by FD, so that it can be opened. */
953 # if !@HAVE_UNLOCKPT@
954 _GL_FUNCDECL_SYS (unlockpt, int, (int fd));
955 # endif
956 _GL_CXXALIAS_SYS (unlockpt, int, (int fd));
957 _GL_CXXALIASWARN (unlockpt);
958 #elif defined GNULIB_POSIXCHECK
959 # undef unlockpt
960 # if HAVE_RAW_DECL_UNLOCKPT
961 _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
962 "use gnulib module unlockpt for portability");
963 # endif
964 #endif
966 #if @GNULIB_UNSETENV@
967 /* Remove the variable NAME from the environment. */
968 # if @REPLACE_UNSETENV@
969 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
970 # undef unsetenv
971 # define unsetenv rpl_unsetenv
972 # endif
973 _GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
974 _GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
975 # else
976 # if !@HAVE_DECL_UNSETENV@
977 _GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
978 # endif
979 _GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
980 # endif
981 # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
982 _GL_CXXALIASWARN (unsetenv);
983 # endif
984 #elif defined GNULIB_POSIXCHECK
985 # undef unsetenv
986 # if HAVE_RAW_DECL_UNSETENV
987 _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
988 "use gnulib module unsetenv for portability");
989 # endif
990 #endif
992 /* Convert a wide character to a multibyte character. */
993 #if @GNULIB_WCTOMB@
994 # if @REPLACE_WCTOMB@
995 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
996 # undef wctomb
997 # define wctomb rpl_wctomb
998 # endif
999 _GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc));
1000 _GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
1001 # else
1002 _GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
1003 # endif
1004 _GL_CXXALIASWARN (wctomb);
1005 #endif
1008 #endif /* _@GUARD_PREFIX@_STDLIB_H */
1009 #endif /* _@GUARD_PREFIX@_STDLIB_H */
1010 #endif