1 /* A GNU-like <stdlib.h>.
3 Copyright (C) 1995, 2001-2004, 2006-2023 Free Software Foundation, Inc.
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
10 This file 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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19 @PRAGMA_SYSTEM_HEADER@
23 #if defined __need_system_stdlib_h || defined __need_malloc_and_calloc
24 /* Special invocation conventions inside some gnulib header files,
25 and inside some glibc header files, respectively. */
27 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
30 /* Normal invocation convention. */
32 #ifndef _@GUARD_PREFIX@_STDLIB_H
34 /* The include_next requires a split double-inclusion guard. */
35 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
37 #ifndef _@GUARD_PREFIX@_STDLIB_H
38 #define _@GUARD_PREFIX@_STDLIB_H
40 /* NetBSD 5.0 mis-defines NULL. */
43 /* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */
44 #if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS
45 # include <sys/wait.h>
48 /* Solaris declares getloadavg() in <sys/loadavg.h>. */
49 #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
50 /* OpenIndiana has a bug: <sys/time.h> must be included before
52 # include <sys/time.h>
53 # include <sys/loadavg.h>
56 /* Native Windows platforms declare _mktemp() in <io.h>. */
57 #if defined _WIN32 && !defined __CYGWIN__
63 /* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
64 from <stdlib.h> if _REENTRANT is defined. Include it whenever we need
65 'struct random_data'. */
70 # if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
74 # if !@HAVE_STRUCT_RANDOM_DATA@
75 /* Define 'struct random_data'.
76 But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
77 # if !GNULIB_defined_struct_random_data
80 int32_t *fptr
; /* Front pointer. */
81 int32_t *rptr
; /* Rear pointer. */
82 int32_t *state
; /* Array of state values. */
83 int rand_type
; /* Type of random number generator. */
84 int rand_deg
; /* Degree of random number generator. */
85 int rand_sep
; /* Distance between front and rear. */
86 int32_t *end_ptr
; /* Pointer behind state table. */
88 # define GNULIB_defined_struct_random_data 1
93 #if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_MKOSTEMP@ || @GNULIB_MKOSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !(defined _WIN32 && ! defined __CYGWIN__)
94 /* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */
95 /* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */
96 /* On Mac OS X 10.13, only <unistd.h> declares mkostemp and mkostemps. */
97 /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
98 /* But avoid namespace pollution on glibc systems and native Windows. */
102 /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
103 that can be freed by passing them as the Ith argument to the
105 #ifndef _GL_ATTRIBUTE_DEALLOC
107 # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
109 # define _GL_ATTRIBUTE_DEALLOC(f, i)
113 /* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
114 can be freed via 'free'; it can be used only after declaring 'free'. */
115 /* Applies to: functions. Cannot be used on inline functions. */
116 #ifndef _GL_ATTRIBUTE_DEALLOC_FREE
117 # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
120 /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
122 /* Applies to: functions. */
123 #ifndef _GL_ATTRIBUTE_MALLOC
124 # if __GNUC__ >= 3 || defined __clang__
125 # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
127 # define _GL_ATTRIBUTE_MALLOC
131 /* The __attribute__ feature is available in gcc versions 2.5 and later.
132 The attribute __pure__ was added in gcc 2.96. */
133 #ifndef _GL_ATTRIBUTE_PURE
134 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
135 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
137 # define _GL_ATTRIBUTE_PURE /* empty */
141 /* The definition of _Noreturn is copied here. */
143 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
145 /* The definition of _GL_ARG_NONNULL is copied here. */
147 /* The definition of _GL_WARN_ON_USE is copied here. */
150 /* Some systems do not define EXIT_*, despite otherwise supporting C89. */
152 # define EXIT_SUCCESS 0
154 /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
155 with proper operation of xargs. */
157 # define EXIT_FAILURE 1
158 #elif EXIT_FAILURE != 1
160 # define EXIT_FAILURE 1
165 /* Terminate the current process with the given return code, without running
166 the 'atexit' handlers. */
168 _GL_FUNCDECL_SYS (_Exit
, _Noreturn
void, (int status
));
170 _GL_CXXALIAS_SYS (_Exit
, void, (int status
));
171 _GL_CXXALIASWARN (_Exit
);
172 #elif defined GNULIB_POSIXCHECK
174 # if HAVE_RAW_DECL__EXIT
175 _GL_WARN_ON_USE (_Exit
, "_Exit is unportable - "
176 "use gnulib module _Exit for portability");
181 #if @GNULIB_FREE_POSIX@
183 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
185 # define free rpl_free
187 # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
188 _GL_FUNCDECL_RPL (free
, void, (void *ptr
) throw ());
190 _GL_FUNCDECL_RPL (free
, void, (void *ptr
));
192 _GL_CXXALIAS_RPL (free
, void, (void *ptr
));
194 _GL_CXXALIAS_SYS (free
, void, (void *ptr
));
197 _GL_CXXALIASWARN (free
);
199 #elif defined GNULIB_POSIXCHECK
201 /* Assume free is always declared. */
202 _GL_WARN_ON_USE (free
, "free is not future POSIX compliant everywhere - "
203 "use gnulib module free for portability");
207 /* Allocate memory with indefinite extent and specified alignment. */
208 #if @GNULIB_ALIGNED_ALLOC@
209 # if @REPLACE_ALIGNED_ALLOC@
210 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
211 # undef aligned_alloc
212 # define aligned_alloc rpl_aligned_alloc
214 _GL_FUNCDECL_RPL (aligned_alloc
, void *,
215 (size_t alignment
, size_t size
)
216 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
217 _GL_CXXALIAS_RPL (aligned_alloc
, void *, (size_t alignment
, size_t size
));
219 # if @HAVE_ALIGNED_ALLOC@
221 /* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
222 _GL_FUNCDECL_SYS (aligned_alloc
, void *,
223 (size_t alignment
, size_t size
)
224 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
226 _GL_CXXALIAS_SYS (aligned_alloc
, void *, (size_t alignment
, size_t size
));
229 # if (__GLIBC__ >= 2) && @HAVE_ALIGNED_ALLOC@
230 _GL_CXXALIASWARN (aligned_alloc
);
233 # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined aligned_alloc
234 /* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
235 _GL_FUNCDECL_SYS (aligned_alloc
, void *,
236 (size_t alignment
, size_t size
)
237 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
239 # if defined GNULIB_POSIXCHECK
240 # undef aligned_alloc
241 # if HAVE_RAW_DECL_ALIGNED_ALLOC
242 _GL_WARN_ON_USE (aligned_alloc
, "aligned_alloc is not portable - "
243 "use gnulib module aligned_alloc for portability");
249 /* Parse a signed decimal integer.
250 Returns the value of the integer. Errors are not detected. */
252 _GL_FUNCDECL_SYS (atoll
, long long, (const char *string
)
254 _GL_ARG_NONNULL ((1)));
256 _GL_CXXALIAS_SYS (atoll
, long long, (const char *string
));
257 _GL_CXXALIASWARN (atoll
);
258 #elif defined GNULIB_POSIXCHECK
260 # if HAVE_RAW_DECL_ATOLL
261 _GL_WARN_ON_USE (atoll
, "atoll is unportable - "
262 "use gnulib module atoll for portability");
266 #if @GNULIB_CALLOC_POSIX@
267 # if (@GNULIB_CALLOC_POSIX@ && @REPLACE_CALLOC_FOR_CALLOC_POSIX@) \
268 || (@GNULIB_CALLOC_GNU@ && @REPLACE_CALLOC_FOR_CALLOC_GNU@)
269 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
271 # define calloc rpl_calloc
273 _GL_FUNCDECL_RPL (calloc
, void *,
274 (size_t nmemb
, size_t size
)
275 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
276 _GL_CXXALIAS_RPL (calloc
, void *, (size_t nmemb
, size_t size
));
279 /* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
280 _GL_FUNCDECL_SYS (calloc
, void *,
281 (size_t nmemb
, size_t size
)
282 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
284 _GL_CXXALIAS_SYS (calloc
, void *, (size_t nmemb
, size_t size
));
287 _GL_CXXALIASWARN (calloc
);
290 # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined calloc
291 /* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
292 _GL_FUNCDECL_SYS (calloc
, void *,
293 (size_t nmemb
, size_t size
)
294 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
296 # if defined GNULIB_POSIXCHECK
298 /* Assume calloc is always declared. */
299 _GL_WARN_ON_USE (calloc
, "calloc is not POSIX compliant everywhere - "
300 "use gnulib module calloc-posix for portability");
304 #if @GNULIB_CANONICALIZE_FILE_NAME@
305 # if @REPLACE_CANONICALIZE_FILE_NAME@
306 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
307 # define canonicalize_file_name rpl_canonicalize_file_name
309 _GL_FUNCDECL_RPL (canonicalize_file_name
, char *,
311 _GL_ARG_NONNULL ((1))
312 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
313 _GL_CXXALIAS_RPL (canonicalize_file_name
, char *, (const char *name
));
315 # if !@HAVE_CANONICALIZE_FILE_NAME@ || __GNUC__ >= 11
316 _GL_FUNCDECL_SYS (canonicalize_file_name
, char *,
318 _GL_ARG_NONNULL ((1))
319 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
321 _GL_CXXALIAS_SYS (canonicalize_file_name
, char *, (const char *name
));
323 # ifndef GNULIB_defined_canonicalize_file_name
324 # define GNULIB_defined_canonicalize_file_name \
325 (!@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@)
327 _GL_CXXALIASWARN (canonicalize_file_name
);
329 # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined canonicalize_file_name
330 /* For -Wmismatched-dealloc: Associate canonicalize_file_name with free or
332 _GL_FUNCDECL_SYS (canonicalize_file_name
, char *,
334 _GL_ARG_NONNULL ((1))
335 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
337 # if defined GNULIB_POSIXCHECK
338 # undef canonicalize_file_name
339 # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
340 _GL_WARN_ON_USE (canonicalize_file_name
,
341 "canonicalize_file_name is unportable - "
342 "use gnulib module canonicalize-lgpl for portability");
347 #if @GNULIB_MDA_ECVT@
348 /* On native Windows, map 'ecvt' to '_ecvt', so that -loldnames is not
349 required. In C++ with GNULIB_NAMESPACE, avoid differences between
350 platforms by defining GNULIB_NAMESPACE::ecvt on all platforms that have
352 # if defined _WIN32 && !defined __CYGWIN__
353 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
357 _GL_CXXALIAS_MDA (ecvt
, char *,
358 (double number
, int ndigits
, int *decptp
, int *signp
));
360 # if @HAVE_DECL_ECVT@
361 _GL_CXXALIAS_SYS (ecvt
, char *,
362 (double number
, int ndigits
, int *decptp
, int *signp
));
365 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_ECVT@
366 _GL_CXXALIASWARN (ecvt
);
370 #if @GNULIB_MDA_FCVT@
371 /* On native Windows, map 'fcvt' to '_fcvt', so that -loldnames is not
372 required. In C++ with GNULIB_NAMESPACE, avoid differences between
373 platforms by defining GNULIB_NAMESPACE::fcvt on all platforms that have
375 # if defined _WIN32 && !defined __CYGWIN__
376 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
380 _GL_CXXALIAS_MDA (fcvt
, char *,
381 (double number
, int ndigits
, int *decptp
, int *signp
));
383 # if @HAVE_DECL_FCVT@
384 _GL_CXXALIAS_SYS (fcvt
, char *,
385 (double number
, int ndigits
, int *decptp
, int *signp
));
388 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_FCVT@
389 _GL_CXXALIASWARN (fcvt
);
393 #if @GNULIB_MDA_GCVT@
394 /* On native Windows, map 'gcvt' to '_gcvt', so that -loldnames is not
395 required. In C++ with GNULIB_NAMESPACE, avoid differences between
396 platforms by defining GNULIB_NAMESPACE::gcvt on all platforms that have
398 # if defined _WIN32 && !defined __CYGWIN__
399 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
403 _GL_CXXALIAS_MDA (gcvt
, char *, (double number
, int ndigits
, char *buf
));
405 # if @HAVE_DECL_GCVT@
406 _GL_CXXALIAS_SYS (gcvt
, char *, (double number
, int ndigits
, char *buf
));
409 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_GCVT@
410 _GL_CXXALIASWARN (gcvt
);
414 #if @GNULIB_GETLOADAVG@
415 /* Store max(NELEM,3) load average numbers in LOADAVG[].
416 The three numbers are the load average of the last 1 minute, the last 5
417 minutes, and the last 15 minutes, respectively.
418 LOADAVG is an array of NELEM numbers. */
419 # if !@HAVE_DECL_GETLOADAVG@
420 _GL_FUNCDECL_SYS (getloadavg
, int, (double loadavg
[], int nelem
)
421 _GL_ARG_NONNULL ((1)));
423 _GL_CXXALIAS_SYS (getloadavg
, int, (double loadavg
[], int nelem
));
424 _GL_CXXALIASWARN (getloadavg
);
425 #elif defined GNULIB_POSIXCHECK
427 # if HAVE_RAW_DECL_GETLOADAVG
428 _GL_WARN_ON_USE (getloadavg
, "getloadavg is not portable - "
429 "use gnulib module getloadavg for portability");
433 #if @GNULIB_GETSUBOPT@
434 /* Assuming *OPTIONP is a comma separated list of elements of the form
435 "token" or "token=value", getsubopt parses the first of these elements.
436 If the first element refers to a "token" that is member of the given
437 NULL-terminated array of tokens:
438 - It replaces the comma with a NUL byte, updates *OPTIONP to point past
439 the first option and the comma, sets *VALUEP to the value of the
440 element (or NULL if it doesn't contain an "=" sign),
441 - It returns the index of the "token" in the given array of tokens.
442 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
443 For more details see the POSIX specification.
444 https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html */
445 # if !@HAVE_GETSUBOPT@
446 _GL_FUNCDECL_SYS (getsubopt
, int,
447 (char **optionp
, char *const *tokens
, char **valuep
)
448 _GL_ARG_NONNULL ((1, 2, 3)));
450 _GL_CXXALIAS_SYS (getsubopt
, int,
451 (char **optionp
, char *const *tokens
, char **valuep
));
452 _GL_CXXALIASWARN (getsubopt
);
453 #elif defined GNULIB_POSIXCHECK
455 # if HAVE_RAW_DECL_GETSUBOPT
456 _GL_WARN_ON_USE (getsubopt
, "getsubopt is unportable - "
457 "use gnulib module getsubopt for portability");
462 /* Change the ownership and access permission of the slave side of the
463 pseudo-terminal whose master side is specified by FD. */
465 _GL_FUNCDECL_SYS (grantpt
, int, (int fd
));
467 _GL_CXXALIAS_SYS (grantpt
, int, (int fd
));
468 _GL_CXXALIASWARN (grantpt
);
469 #elif defined GNULIB_POSIXCHECK
471 # if HAVE_RAW_DECL_GRANTPT
472 _GL_WARN_ON_USE (grantpt
, "grantpt is not portable - "
473 "use gnulib module grantpt for portability");
477 /* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
478 rely on GNU or POSIX semantics for malloc and realloc (for example,
479 by never specifying a zero size), so it does not need malloc or
480 realloc to be redefined. */
481 #if @GNULIB_MALLOC_POSIX@
482 # if (@GNULIB_MALLOC_POSIX@ && @REPLACE_MALLOC_FOR_MALLOC_POSIX@) \
483 || (@GNULIB_MALLOC_GNU@ && @REPLACE_MALLOC_FOR_MALLOC_GNU@)
484 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
485 || _GL_USE_STDLIB_ALLOC)
487 # define malloc rpl_malloc
489 _GL_FUNCDECL_RPL (malloc
, void *,
491 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
492 _GL_CXXALIAS_RPL (malloc
, void *, (size_t size
));
495 /* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
496 _GL_FUNCDECL_SYS (malloc
, void *,
498 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
500 _GL_CXXALIAS_SYS (malloc
, void *, (size_t size
));
503 _GL_CXXALIASWARN (malloc
);
506 # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined malloc
507 /* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
508 _GL_FUNCDECL_SYS (malloc
, void *,
510 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
512 # if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
514 /* Assume malloc is always declared. */
515 _GL_WARN_ON_USE (malloc
, "malloc is not POSIX compliant everywhere - "
516 "use gnulib module malloc-posix for portability");
520 /* Convert a multibyte character to a wide character. */
522 # if @REPLACE_MBTOWC@
523 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
525 # define mbtowc rpl_mbtowc
527 _GL_FUNCDECL_RPL (mbtowc
, int,
528 (wchar_t *restrict pwc
, const char *restrict s
, size_t n
));
529 _GL_CXXALIAS_RPL (mbtowc
, int,
530 (wchar_t *restrict pwc
, const char *restrict s
, size_t n
));
533 _GL_FUNCDECL_SYS (mbtowc
, int,
534 (wchar_t *restrict pwc
, const char *restrict s
, size_t n
));
536 _GL_CXXALIAS_SYS (mbtowc
, int,
537 (wchar_t *restrict pwc
, const char *restrict s
, size_t n
));
540 _GL_CXXALIASWARN (mbtowc
);
542 #elif defined GNULIB_POSIXCHECK
544 # if HAVE_RAW_DECL_MBTOWC
545 _GL_WARN_ON_USE (mbtowc
, "mbtowc is not portable - "
546 "use gnulib module mbtowc for portability");
551 /* Create a unique temporary directory from TEMPLATE.
552 The last six characters of TEMPLATE must be "XXXXXX";
553 they are replaced with a string that makes the directory name unique.
554 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
555 The directory is created mode 700. */
557 _GL_FUNCDECL_SYS (mkdtemp
, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
559 _GL_CXXALIAS_SYS (mkdtemp
, char *, (char * /*template*/));
560 _GL_CXXALIASWARN (mkdtemp
);
561 #elif defined GNULIB_POSIXCHECK
563 # if HAVE_RAW_DECL_MKDTEMP
564 _GL_WARN_ON_USE (mkdtemp
, "mkdtemp is unportable - "
565 "use gnulib module mkdtemp for portability");
569 #if @GNULIB_MKOSTEMP@
570 /* Create a unique temporary file from TEMPLATE.
571 The last six characters of TEMPLATE must be "XXXXXX";
572 they are replaced with a string that makes the file name unique.
573 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
574 and O_TEXT, O_BINARY (defined in "binary-io.h").
575 The file is then created, with the specified flags, ensuring it didn't exist
577 The file is created read-write (mask at least 0600 & ~umask), but it may be
578 world-readable and world-writable (mask 0666 & ~umask), depending on the
580 Returns the open file descriptor if successful, otherwise -1 and errno
582 # if !@HAVE_MKOSTEMP@
583 _GL_FUNCDECL_SYS (mkostemp
, int, (char * /*template*/, int /*flags*/)
584 _GL_ARG_NONNULL ((1)));
586 _GL_CXXALIAS_SYS (mkostemp
, int, (char * /*template*/, int /*flags*/));
587 _GL_CXXALIASWARN (mkostemp
);
588 #elif defined GNULIB_POSIXCHECK
590 # if HAVE_RAW_DECL_MKOSTEMP
591 _GL_WARN_ON_USE (mkostemp
, "mkostemp is unportable - "
592 "use gnulib module mkostemp for portability");
596 #if @GNULIB_MKOSTEMPS@
597 /* Create a unique temporary file from TEMPLATE.
598 The last six characters of TEMPLATE before a suffix of length
599 SUFFIXLEN must be "XXXXXX";
600 they are replaced with a string that makes the file name unique.
601 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
602 and O_TEXT, O_BINARY (defined in "binary-io.h").
603 The file is then created, with the specified flags, ensuring it didn't exist
605 The file is created read-write (mask at least 0600 & ~umask), but it may be
606 world-readable and world-writable (mask 0666 & ~umask), depending on the
608 Returns the open file descriptor if successful, otherwise -1 and errno
610 # if !@HAVE_MKOSTEMPS@
611 _GL_FUNCDECL_SYS (mkostemps
, int,
612 (char * /*template*/, int /*suffixlen*/, int /*flags*/)
613 _GL_ARG_NONNULL ((1)));
615 _GL_CXXALIAS_SYS (mkostemps
, int,
616 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
617 _GL_CXXALIASWARN (mkostemps
);
618 #elif defined GNULIB_POSIXCHECK
620 # if HAVE_RAW_DECL_MKOSTEMPS
621 _GL_WARN_ON_USE (mkostemps
, "mkostemps is unportable - "
622 "use gnulib module mkostemps for portability");
627 /* Create a unique temporary file from TEMPLATE.
628 The last six characters of TEMPLATE must be "XXXXXX";
629 they are replaced with a string that makes the file name unique.
630 The file is then created, ensuring it didn't exist before.
631 The file is created read-write (mask at least 0600 & ~umask), but it may be
632 world-readable and world-writable (mask 0666 & ~umask), depending on the
634 Returns the open file descriptor if successful, otherwise -1 and errno
636 # if @REPLACE_MKSTEMP@
637 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
638 # define mkstemp rpl_mkstemp
640 _GL_FUNCDECL_RPL (mkstemp
, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
641 _GL_CXXALIAS_RPL (mkstemp
, int, (char * /*template*/));
643 # if ! @HAVE_MKSTEMP@
644 _GL_FUNCDECL_SYS (mkstemp
, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
646 _GL_CXXALIAS_SYS (mkstemp
, int, (char * /*template*/));
648 _GL_CXXALIASWARN (mkstemp
);
649 #elif defined GNULIB_POSIXCHECK
651 # if HAVE_RAW_DECL_MKSTEMP
652 _GL_WARN_ON_USE (mkstemp
, "mkstemp is unportable - "
653 "use gnulib module mkstemp for portability");
657 #if @GNULIB_MKSTEMPS@
658 /* Create a unique temporary file from TEMPLATE.
659 The last six characters of TEMPLATE prior to a suffix of length
660 SUFFIXLEN must be "XXXXXX";
661 they are replaced with a string that makes the file name unique.
662 The file is then created, ensuring it didn't exist before.
663 The file is created read-write (mask at least 0600 & ~umask), but it may be
664 world-readable and world-writable (mask 0666 & ~umask), depending on the
666 Returns the open file descriptor if successful, otherwise -1 and errno
668 # if !@HAVE_MKSTEMPS@
669 _GL_FUNCDECL_SYS (mkstemps
, int, (char * /*template*/, int /*suffixlen*/)
670 _GL_ARG_NONNULL ((1)));
672 _GL_CXXALIAS_SYS (mkstemps
, int, (char * /*template*/, int /*suffixlen*/));
673 _GL_CXXALIASWARN (mkstemps
);
674 #elif defined GNULIB_POSIXCHECK
676 # if HAVE_RAW_DECL_MKSTEMPS
677 _GL_WARN_ON_USE (mkstemps
, "mkstemps is unportable - "
678 "use gnulib module mkstemps for portability");
682 #if @GNULIB_MDA_MKTEMP@
683 /* On native Windows, map 'mktemp' to '_mktemp', so that -loldnames is not
684 required. In C++ with GNULIB_NAMESPACE, avoid differences between
685 platforms by defining GNULIB_NAMESPACE::mktemp always. */
686 # if defined _WIN32 && !defined __CYGWIN__
687 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
689 # define mktemp _mktemp
691 _GL_CXXALIAS_MDA (mktemp
, char *, (char * /*template*/));
693 _GL_CXXALIAS_SYS (mktemp
, char *, (char * /*template*/));
695 _GL_CXXALIASWARN (mktemp
);
698 /* Allocate memory with indefinite extent and specified alignment. */
699 #if @GNULIB_POSIX_MEMALIGN@
700 # if @REPLACE_POSIX_MEMALIGN@
701 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
702 # undef posix_memalign
703 # define posix_memalign rpl_posix_memalign
705 _GL_FUNCDECL_RPL (posix_memalign
, int,
706 (void **memptr
, size_t alignment
, size_t size
)
707 _GL_ARG_NONNULL ((1)));
708 _GL_CXXALIAS_RPL (posix_memalign
, int,
709 (void **memptr
, size_t alignment
, size_t size
));
711 # if @HAVE_POSIX_MEMALIGN@
712 _GL_CXXALIAS_SYS (posix_memalign
, int,
713 (void **memptr
, size_t alignment
, size_t size
));
716 # if @HAVE_POSIX_MEMALIGN@
717 _GL_CXXALIASWARN (posix_memalign
);
719 #elif defined GNULIB_POSIXCHECK
720 # undef posix_memalign
721 # if HAVE_RAW_DECL_POSIX_MEMALIGN
722 _GL_WARN_ON_USE (posix_memalign
, "posix_memalign is not portable - "
723 "use gnulib module posix_memalign for portability");
727 #if @GNULIB_POSIX_OPENPT@
728 /* Return an FD open to the master side of a pseudo-terminal. Flags should
729 include O_RDWR, and may also include O_NOCTTY. */
730 # if !@HAVE_POSIX_OPENPT@
731 _GL_FUNCDECL_SYS (posix_openpt
, int, (int flags
));
733 _GL_CXXALIAS_SYS (posix_openpt
, int, (int flags
));
734 _GL_CXXALIASWARN (posix_openpt
);
735 #elif defined GNULIB_POSIXCHECK
737 # if HAVE_RAW_DECL_POSIX_OPENPT
738 _GL_WARN_ON_USE (posix_openpt
, "posix_openpt is not portable - "
739 "use gnulib module posix_openpt for portability");
744 /* Return the pathname of the pseudo-terminal slave associated with
745 the master FD is open on, or NULL on errors. */
746 # if @REPLACE_PTSNAME@
747 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
749 # define ptsname rpl_ptsname
751 _GL_FUNCDECL_RPL (ptsname
, char *, (int fd
));
752 _GL_CXXALIAS_RPL (ptsname
, char *, (int fd
));
755 _GL_FUNCDECL_SYS (ptsname
, char *, (int fd
));
757 _GL_CXXALIAS_SYS (ptsname
, char *, (int fd
));
759 _GL_CXXALIASWARN (ptsname
);
760 #elif defined GNULIB_POSIXCHECK
762 # if HAVE_RAW_DECL_PTSNAME
763 _GL_WARN_ON_USE (ptsname
, "ptsname is not portable - "
764 "use gnulib module ptsname for portability");
768 #if @GNULIB_PTSNAME_R@
769 /* Set the pathname of the pseudo-terminal slave associated with
770 the master FD is open on and return 0, or set errno and return
771 non-zero on errors. */
772 # if @REPLACE_PTSNAME_R@
773 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
775 # define ptsname_r rpl_ptsname_r
777 _GL_FUNCDECL_RPL (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
778 _GL_CXXALIAS_RPL (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
780 # if !@HAVE_PTSNAME_R@
781 _GL_FUNCDECL_SYS (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
783 _GL_CXXALIAS_SYS (ptsname_r
, int, (int fd
, char *buf
, size_t len
));
785 # ifndef GNULIB_defined_ptsname_r
786 # define GNULIB_defined_ptsname_r (!@HAVE_PTSNAME_R@ || @REPLACE_PTSNAME_R@)
788 _GL_CXXALIASWARN (ptsname_r
);
789 #elif defined GNULIB_POSIXCHECK
791 # if HAVE_RAW_DECL_PTSNAME_R
792 _GL_WARN_ON_USE (ptsname_r
, "ptsname_r is not portable - "
793 "use gnulib module ptsname_r for portability");
798 # if @REPLACE_PUTENV@
799 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
801 # define putenv rpl_putenv
803 _GL_FUNCDECL_RPL (putenv
, int, (char *string
) _GL_ARG_NONNULL ((1)));
804 _GL_CXXALIAS_RPL (putenv
, int, (char *string
));
805 # elif defined _WIN32 && !defined __CYGWIN__
806 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
808 # define putenv _putenv
810 _GL_CXXALIAS_MDA (putenv
, int, (char *string
));
812 _GL_CXXALIAS_SYS (putenv
, int, (char *string
));
814 _GL_CXXALIASWARN (putenv
);
815 #elif @GNULIB_MDA_PUTENV@
816 /* On native Windows, map 'putenv' to '_putenv', so that -loldnames is not
817 required. In C++ with GNULIB_NAMESPACE, avoid differences between
818 platforms by defining GNULIB_NAMESPACE::putenv always. */
819 # if defined _WIN32 && !defined __CYGWIN__
820 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
822 # define putenv _putenv
824 /* Need to cast, because on mingw, the parameter is either
825 'const char *string' or 'char *string'. */
826 _GL_CXXALIAS_MDA_CAST (putenv
, int, (char *string
));
828 _GL_CXXALIAS_SYS (putenv
, int, (char *string
));
830 _GL_CXXALIASWARN (putenv
);
834 /* Sort an array of NMEMB elements, starting at address BASE, each element
835 occupying SIZE bytes, in ascending order according to the comparison
840 # if !GNULIB_defined_qsort_r_fn_types
841 typedef int (*_gl_qsort_r_compar_fn
) (void const *, void const *, void *);
842 # define GNULIB_defined_qsort_r_fn_types 1
847 # if @REPLACE_QSORT_R@
848 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
850 # define qsort_r rpl_qsort_r
852 _GL_FUNCDECL_RPL (qsort_r
, void, (void *base
, size_t nmemb
, size_t size
,
853 _gl_qsort_r_compar_fn compare
,
854 void *arg
) _GL_ARG_NONNULL ((1, 4)));
855 _GL_CXXALIAS_RPL (qsort_r
, void, (void *base
, size_t nmemb
, size_t size
,
856 _gl_qsort_r_compar_fn compare
,
860 _GL_FUNCDECL_SYS (qsort_r
, void, (void *base
, size_t nmemb
, size_t size
,
861 _gl_qsort_r_compar_fn compare
,
862 void *arg
) _GL_ARG_NONNULL ((1, 4)));
864 _GL_CXXALIAS_SYS (qsort_r
, void, (void *base
, size_t nmemb
, size_t size
,
865 _gl_qsort_r_compar_fn compare
,
868 _GL_CXXALIASWARN (qsort_r
);
869 #elif defined GNULIB_POSIXCHECK
871 # if HAVE_RAW_DECL_QSORT_R
872 _GL_WARN_ON_USE (qsort_r
, "qsort_r is not portable - "
873 "use gnulib module qsort_r for portability");
878 #if @GNULIB_RANDOM_R@
879 # if !@HAVE_RANDOM_R@
881 # define RAND_MAX 2147483647
888 # if @REPLACE_RANDOM@
889 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
891 # define random rpl_random
893 _GL_FUNCDECL_RPL (random
, long, (void));
894 _GL_CXXALIAS_RPL (random
, long, (void));
897 _GL_FUNCDECL_SYS (random
, long, (void));
899 /* Need to cast, because on Haiku, the return type is
901 _GL_CXXALIAS_SYS_CAST (random
, long, (void));
903 _GL_CXXALIASWARN (random
);
904 #elif defined GNULIB_POSIXCHECK
906 # if HAVE_RAW_DECL_RANDOM
907 _GL_WARN_ON_USE (random
, "random is unportable - "
908 "use gnulib module random for portability");
913 # if @REPLACE_RANDOM@
914 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
916 # define srandom rpl_srandom
918 _GL_FUNCDECL_RPL (srandom
, void, (unsigned int seed
));
919 _GL_CXXALIAS_RPL (srandom
, void, (unsigned int seed
));
922 _GL_FUNCDECL_SYS (srandom
, void, (unsigned int seed
));
924 /* Need to cast, because on FreeBSD, the first parameter is
925 unsigned long seed. */
926 _GL_CXXALIAS_SYS_CAST (srandom
, void, (unsigned int seed
));
928 _GL_CXXALIASWARN (srandom
);
929 #elif defined GNULIB_POSIXCHECK
931 # if HAVE_RAW_DECL_SRANDOM
932 _GL_WARN_ON_USE (srandom
, "srandom is unportable - "
933 "use gnulib module random for portability");
938 # if @REPLACE_INITSTATE@
939 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
941 # define initstate rpl_initstate
943 _GL_FUNCDECL_RPL (initstate
, char *,
944 (unsigned int seed
, char *buf
, size_t buf_size
)
945 _GL_ARG_NONNULL ((2)));
946 _GL_CXXALIAS_RPL (initstate
, char *,
947 (unsigned int seed
, char *buf
, size_t buf_size
));
949 # if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@
950 _GL_FUNCDECL_SYS (initstate
, char *,
951 (unsigned int seed
, char *buf
, size_t buf_size
)
952 _GL_ARG_NONNULL ((2)));
954 /* Need to cast, because on FreeBSD, the first parameter is
955 unsigned long seed. */
956 _GL_CXXALIAS_SYS_CAST (initstate
, char *,
957 (unsigned int seed
, char *buf
, size_t buf_size
));
959 _GL_CXXALIASWARN (initstate
);
960 #elif defined GNULIB_POSIXCHECK
962 # if HAVE_RAW_DECL_INITSTATE
963 _GL_WARN_ON_USE (initstate
, "initstate is unportable - "
964 "use gnulib module random for portability");
969 # if @REPLACE_SETSTATE@
970 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
972 # define setstate rpl_setstate
974 _GL_FUNCDECL_RPL (setstate
, char *, (char *arg_state
) _GL_ARG_NONNULL ((1)));
975 _GL_CXXALIAS_RPL (setstate
, char *, (char *arg_state
));
977 # if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@
978 _GL_FUNCDECL_SYS (setstate
, char *, (char *arg_state
) _GL_ARG_NONNULL ((1)));
980 /* Need to cast, because on Mac OS X 10.13, HP-UX, Solaris the first parameter
981 is const char *arg_state. */
982 _GL_CXXALIAS_SYS_CAST (setstate
, char *, (char *arg_state
));
984 _GL_CXXALIASWARN (setstate
);
985 #elif defined GNULIB_POSIXCHECK
987 # if HAVE_RAW_DECL_SETSTATE
988 _GL_WARN_ON_USE (setstate
, "setstate is unportable - "
989 "use gnulib module random for portability");
994 #if @GNULIB_RANDOM_R@
995 # if @REPLACE_RANDOM_R@
996 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
998 # define random_r rpl_random_r
1000 _GL_FUNCDECL_RPL (random_r
, int, (struct random_data
*buf
, int32_t *result
)
1001 _GL_ARG_NONNULL ((1, 2)));
1002 _GL_CXXALIAS_RPL (random_r
, int, (struct random_data
*buf
, int32_t *result
));
1004 # if !@HAVE_RANDOM_R@
1005 _GL_FUNCDECL_SYS (random_r
, int, (struct random_data
*buf
, int32_t *result
)
1006 _GL_ARG_NONNULL ((1, 2)));
1008 _GL_CXXALIAS_SYS (random_r
, int, (struct random_data
*buf
, int32_t *result
));
1010 _GL_CXXALIASWARN (random_r
);
1011 #elif defined GNULIB_POSIXCHECK
1013 # if HAVE_RAW_DECL_RANDOM_R
1014 _GL_WARN_ON_USE (random_r
, "random_r is unportable - "
1015 "use gnulib module random_r for portability");
1019 #if @GNULIB_RANDOM_R@
1020 # if @REPLACE_RANDOM_R@
1021 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1023 # define srandom_r rpl_srandom_r
1025 _GL_FUNCDECL_RPL (srandom_r
, int,
1026 (unsigned int seed
, struct random_data
*rand_state
)
1027 _GL_ARG_NONNULL ((2)));
1028 _GL_CXXALIAS_RPL (srandom_r
, int,
1029 (unsigned int seed
, struct random_data
*rand_state
));
1031 # if !@HAVE_RANDOM_R@
1032 _GL_FUNCDECL_SYS (srandom_r
, int,
1033 (unsigned int seed
, struct random_data
*rand_state
)
1034 _GL_ARG_NONNULL ((2)));
1036 _GL_CXXALIAS_SYS (srandom_r
, int,
1037 (unsigned int seed
, struct random_data
*rand_state
));
1039 _GL_CXXALIASWARN (srandom_r
);
1040 #elif defined GNULIB_POSIXCHECK
1042 # if HAVE_RAW_DECL_SRANDOM_R
1043 _GL_WARN_ON_USE (srandom_r
, "srandom_r is unportable - "
1044 "use gnulib module random_r for portability");
1048 #if @GNULIB_RANDOM_R@
1049 # if @REPLACE_RANDOM_R@
1050 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1052 # define initstate_r rpl_initstate_r
1054 _GL_FUNCDECL_RPL (initstate_r
, int,
1055 (unsigned int seed
, char *buf
, size_t buf_size
,
1056 struct random_data
*rand_state
)
1057 _GL_ARG_NONNULL ((2, 4)));
1058 _GL_CXXALIAS_RPL (initstate_r
, int,
1059 (unsigned int seed
, char *buf
, size_t buf_size
,
1060 struct random_data
*rand_state
));
1062 # if !@HAVE_RANDOM_R@
1063 _GL_FUNCDECL_SYS (initstate_r
, int,
1064 (unsigned int seed
, char *buf
, size_t buf_size
,
1065 struct random_data
*rand_state
)
1066 _GL_ARG_NONNULL ((2, 4)));
1068 /* Need to cast, because on Haiku, the third parameter is
1069 unsigned long buf_size. */
1070 _GL_CXXALIAS_SYS_CAST (initstate_r
, int,
1071 (unsigned int seed
, char *buf
, size_t buf_size
,
1072 struct random_data
*rand_state
));
1074 _GL_CXXALIASWARN (initstate_r
);
1075 #elif defined GNULIB_POSIXCHECK
1077 # if HAVE_RAW_DECL_INITSTATE_R
1078 _GL_WARN_ON_USE (initstate_r
, "initstate_r is unportable - "
1079 "use gnulib module random_r for portability");
1083 #if @GNULIB_RANDOM_R@
1084 # if @REPLACE_RANDOM_R@
1085 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1087 # define setstate_r rpl_setstate_r
1089 _GL_FUNCDECL_RPL (setstate_r
, int,
1090 (char *arg_state
, struct random_data
*rand_state
)
1091 _GL_ARG_NONNULL ((1, 2)));
1092 _GL_CXXALIAS_RPL (setstate_r
, int,
1093 (char *arg_state
, struct random_data
*rand_state
));
1095 # if !@HAVE_RANDOM_R@
1096 _GL_FUNCDECL_SYS (setstate_r
, int,
1097 (char *arg_state
, struct random_data
*rand_state
)
1098 _GL_ARG_NONNULL ((1, 2)));
1100 /* Need to cast, because on Haiku, the first parameter is
1102 _GL_CXXALIAS_SYS_CAST (setstate_r
, int,
1103 (char *arg_state
, struct random_data
*rand_state
));
1105 _GL_CXXALIASWARN (setstate_r
);
1106 #elif defined GNULIB_POSIXCHECK
1108 # if HAVE_RAW_DECL_SETSTATE_R
1109 _GL_WARN_ON_USE (setstate_r
, "setstate_r is unportable - "
1110 "use gnulib module random_r for portability");
1115 #if @GNULIB_REALLOC_POSIX@
1116 # if (@GNULIB_REALLOC_POSIX@ && @REPLACE_REALLOC_FOR_REALLOC_POSIX@) \
1117 || (@GNULIB_REALLOC_GNU@ && @REPLACE_REALLOC_FOR_REALLOC_GNU@)
1118 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
1119 || _GL_USE_STDLIB_ALLOC)
1121 # define realloc rpl_realloc
1123 _GL_FUNCDECL_RPL (realloc
, void *, (void *ptr
, size_t size
)
1124 _GL_ATTRIBUTE_DEALLOC_FREE
);
1125 _GL_CXXALIAS_RPL (realloc
, void *, (void *ptr
, size_t size
));
1128 /* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1129 _GL_FUNCDECL_SYS (realloc
, void *, (void *ptr
, size_t size
)
1130 _GL_ATTRIBUTE_DEALLOC_FREE
);
1132 _GL_CXXALIAS_SYS (realloc
, void *, (void *ptr
, size_t size
));
1135 _GL_CXXALIASWARN (realloc
);
1138 # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined realloc
1139 /* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1140 _GL_FUNCDECL_SYS (realloc
, void *, (void *ptr
, size_t size
)
1141 _GL_ATTRIBUTE_DEALLOC_FREE
);
1143 # if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
1145 /* Assume realloc is always declared. */
1146 _GL_WARN_ON_USE (realloc
, "realloc is not POSIX compliant everywhere - "
1147 "use gnulib module realloc-posix for portability");
1152 #if @GNULIB_REALLOCARRAY@
1153 # if @REPLACE_REALLOCARRAY@
1154 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1155 # undef reallocarray
1156 # define reallocarray rpl_reallocarray
1158 _GL_FUNCDECL_RPL (reallocarray
, void *,
1159 (void *ptr
, size_t nmemb
, size_t size
));
1160 _GL_CXXALIAS_RPL (reallocarray
, void *,
1161 (void *ptr
, size_t nmemb
, size_t size
));
1163 # if ! @HAVE_REALLOCARRAY@
1164 _GL_FUNCDECL_SYS (reallocarray
, void *,
1165 (void *ptr
, size_t nmemb
, size_t size
));
1167 _GL_CXXALIAS_SYS (reallocarray
, void *,
1168 (void *ptr
, size_t nmemb
, size_t size
));
1170 _GL_CXXALIASWARN (reallocarray
);
1171 #elif defined GNULIB_POSIXCHECK
1172 # undef reallocarray
1173 # if HAVE_RAW_DECL_REALLOCARRAY
1174 _GL_WARN_ON_USE (reallocarray
, "reallocarray is not portable - "
1175 "use gnulib module reallocarray for portability");
1179 #if @GNULIB_REALPATH@
1180 # if @REPLACE_REALPATH@
1181 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1182 # define realpath rpl_realpath
1184 _GL_FUNCDECL_RPL (realpath
, char *,
1185 (const char *restrict name
, char *restrict resolved
)
1186 _GL_ARG_NONNULL ((1)));
1187 _GL_CXXALIAS_RPL (realpath
, char *,
1188 (const char *restrict name
, char *restrict resolved
));
1190 # if !@HAVE_REALPATH@
1191 _GL_FUNCDECL_SYS (realpath
, char *,
1192 (const char *restrict name
, char *restrict resolved
)
1193 _GL_ARG_NONNULL ((1)));
1195 _GL_CXXALIAS_SYS (realpath
, char *,
1196 (const char *restrict name
, char *restrict resolved
));
1198 _GL_CXXALIASWARN (realpath
);
1199 #elif defined GNULIB_POSIXCHECK
1201 # if HAVE_RAW_DECL_REALPATH
1202 _GL_WARN_ON_USE (realpath
, "realpath is unportable - use gnulib module "
1203 "canonicalize or canonicalize-lgpl for portability");
1207 #if @GNULIB_RPMATCH@
1208 /* Test a user response to a question.
1209 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
1210 # if !@HAVE_RPMATCH@
1211 _GL_FUNCDECL_SYS (rpmatch
, int, (const char *response
) _GL_ARG_NONNULL ((1)));
1213 _GL_CXXALIAS_SYS (rpmatch
, int, (const char *response
));
1214 _GL_CXXALIASWARN (rpmatch
);
1215 #elif defined GNULIB_POSIXCHECK
1217 # if HAVE_RAW_DECL_RPMATCH
1218 _GL_WARN_ON_USE (rpmatch
, "rpmatch is unportable - "
1219 "use gnulib module rpmatch for portability");
1223 #if @GNULIB_SECURE_GETENV@
1224 /* Look up NAME in the environment, returning 0 in insecure situations. */
1225 # if !@HAVE_SECURE_GETENV@
1226 _GL_FUNCDECL_SYS (secure_getenv
, char *,
1227 (char const *name
) _GL_ARG_NONNULL ((1)));
1229 _GL_CXXALIAS_SYS (secure_getenv
, char *, (char const *name
));
1230 _GL_CXXALIASWARN (secure_getenv
);
1231 #elif defined GNULIB_POSIXCHECK
1232 # undef secure_getenv
1233 # if HAVE_RAW_DECL_SECURE_GETENV
1234 _GL_WARN_ON_USE (secure_getenv
, "secure_getenv is unportable - "
1235 "use gnulib module secure_getenv for portability");
1240 /* Set NAME to VALUE in the environment.
1241 If REPLACE is nonzero, overwrite an existing value. */
1242 # if @REPLACE_SETENV@
1243 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1245 # define setenv rpl_setenv
1247 _GL_FUNCDECL_RPL (setenv
, int,
1248 (const char *name
, const char *value
, int replace
)
1249 _GL_ARG_NONNULL ((1)));
1250 _GL_CXXALIAS_RPL (setenv
, int,
1251 (const char *name
, const char *value
, int replace
));
1253 # if !@HAVE_DECL_SETENV@
1254 _GL_FUNCDECL_SYS (setenv
, int,
1255 (const char *name
, const char *value
, int replace
)
1256 _GL_ARG_NONNULL ((1)));
1258 _GL_CXXALIAS_SYS (setenv
, int,
1259 (const char *name
, const char *value
, int replace
));
1261 # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
1262 _GL_CXXALIASWARN (setenv
);
1264 #elif defined GNULIB_POSIXCHECK
1266 # if HAVE_RAW_DECL_SETENV
1267 _GL_WARN_ON_USE (setenv
, "setenv is unportable - "
1268 "use gnulib module setenv for portability");
1273 /* Parse a double from STRING, updating ENDP if appropriate. */
1274 # if @REPLACE_STRTOD@
1275 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1276 # define strtod rpl_strtod
1278 # define GNULIB_defined_strtod_function 1
1279 _GL_FUNCDECL_RPL (strtod
, double,
1280 (const char *restrict str
, char **restrict endp
)
1281 _GL_ARG_NONNULL ((1)));
1282 _GL_CXXALIAS_RPL (strtod
, double,
1283 (const char *restrict str
, char **restrict endp
));
1286 _GL_FUNCDECL_SYS (strtod
, double,
1287 (const char *restrict str
, char **restrict endp
)
1288 _GL_ARG_NONNULL ((1)));
1290 _GL_CXXALIAS_SYS (strtod
, double,
1291 (const char *restrict str
, char **restrict endp
));
1294 _GL_CXXALIASWARN (strtod
);
1296 #elif defined GNULIB_POSIXCHECK
1298 # if HAVE_RAW_DECL_STRTOD
1299 _GL_WARN_ON_USE (strtod
, "strtod is unportable - "
1300 "use gnulib module strtod for portability");
1304 #if @GNULIB_STRTOLD@
1305 /* Parse a 'long double' from STRING, updating ENDP if appropriate. */
1306 # if @REPLACE_STRTOLD@
1307 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1308 # define strtold rpl_strtold
1310 # define GNULIB_defined_strtold_function 1
1311 _GL_FUNCDECL_RPL (strtold
, long double,
1312 (const char *restrict str
, char **restrict endp
)
1313 _GL_ARG_NONNULL ((1)));
1314 _GL_CXXALIAS_RPL (strtold
, long double,
1315 (const char *restrict str
, char **restrict endp
));
1317 # if !@HAVE_STRTOLD@
1318 _GL_FUNCDECL_SYS (strtold
, long double,
1319 (const char *restrict str
, char **restrict endp
)
1320 _GL_ARG_NONNULL ((1)));
1322 _GL_CXXALIAS_SYS (strtold
, long double,
1323 (const char *restrict str
, char **restrict endp
));
1325 _GL_CXXALIASWARN (strtold
);
1326 #elif defined GNULIB_POSIXCHECK
1328 # if HAVE_RAW_DECL_STRTOLD
1329 _GL_WARN_ON_USE (strtold
, "strtold is unportable - "
1330 "use gnulib module strtold for portability");
1335 /* Parse a signed integer whose textual representation starts at STRING.
1336 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1337 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1339 If ENDPTR is not NULL, the address of the first byte after the integer is
1341 Upon overflow, the return value is LONG_MAX or LONG_MIN, and errno is set
1343 # if @REPLACE_STRTOL@
1344 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1345 # define strtol rpl_strtol
1347 # define GNULIB_defined_strtol_function 1
1348 _GL_FUNCDECL_RPL (strtol
, long,
1349 (const char *restrict string
, char **restrict endptr
,
1351 _GL_ARG_NONNULL ((1)));
1352 _GL_CXXALIAS_RPL (strtol
, long,
1353 (const char *restrict string
, char **restrict endptr
,
1357 _GL_FUNCDECL_SYS (strtol
, long,
1358 (const char *restrict string
, char **restrict endptr
,
1360 _GL_ARG_NONNULL ((1)));
1362 _GL_CXXALIAS_SYS (strtol
, long,
1363 (const char *restrict string
, char **restrict endptr
,
1367 _GL_CXXALIASWARN (strtol
);
1369 #elif defined GNULIB_POSIXCHECK
1371 # if HAVE_RAW_DECL_STRTOL
1372 _GL_WARN_ON_USE (strtol
, "strtol is unportable - "
1373 "use gnulib module strtol for portability");
1377 #if @GNULIB_STRTOLL@
1378 /* Parse a signed integer whose textual representation starts at STRING.
1379 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1380 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1382 If ENDPTR is not NULL, the address of the first byte after the integer is
1384 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
1386 # if @REPLACE_STRTOLL@
1387 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1388 # define strtoll rpl_strtoll
1390 # define GNULIB_defined_strtoll_function 1
1391 _GL_FUNCDECL_RPL (strtoll
, long long,
1392 (const char *restrict string
, char **restrict endptr
,
1394 _GL_ARG_NONNULL ((1)));
1395 _GL_CXXALIAS_RPL (strtoll
, long long,
1396 (const char *restrict string
, char **restrict endptr
,
1399 # if !@HAVE_STRTOLL@
1400 _GL_FUNCDECL_SYS (strtoll
, long long,
1401 (const char *restrict string
, char **restrict endptr
,
1403 _GL_ARG_NONNULL ((1)));
1405 _GL_CXXALIAS_SYS (strtoll
, long long,
1406 (const char *restrict string
, char **restrict endptr
,
1409 _GL_CXXALIASWARN (strtoll
);
1410 #elif defined GNULIB_POSIXCHECK
1412 # if HAVE_RAW_DECL_STRTOLL
1413 _GL_WARN_ON_USE (strtoll
, "strtoll is unportable - "
1414 "use gnulib module strtoll for portability");
1418 #if @GNULIB_STRTOUL@
1419 /* Parse an unsigned integer whose textual representation starts at STRING.
1420 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1421 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1423 If ENDPTR is not NULL, the address of the first byte after the integer is
1425 Upon overflow, the return value is ULONG_MAX, and errno is set to ERANGE. */
1426 # if @REPLACE_STRTOUL@
1427 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1428 # define strtoul rpl_strtoul
1430 # define GNULIB_defined_strtoul_function 1
1431 _GL_FUNCDECL_RPL (strtoul
, unsigned long,
1432 (const char *restrict string
, char **restrict endptr
,
1434 _GL_ARG_NONNULL ((1)));
1435 _GL_CXXALIAS_RPL (strtoul
, unsigned long,
1436 (const char *restrict string
, char **restrict endptr
,
1439 # if !@HAVE_STRTOUL@
1440 _GL_FUNCDECL_SYS (strtoul
, unsigned long,
1441 (const char *restrict string
, char **restrict endptr
,
1443 _GL_ARG_NONNULL ((1)));
1445 _GL_CXXALIAS_SYS (strtoul
, unsigned long,
1446 (const char *restrict string
, char **restrict endptr
,
1450 _GL_CXXALIASWARN (strtoul
);
1452 #elif defined GNULIB_POSIXCHECK
1454 # if HAVE_RAW_DECL_STRTOUL
1455 _GL_WARN_ON_USE (strtoul
, "strtoul is unportable - "
1456 "use gnulib module strtoul for portability");
1460 #if @GNULIB_STRTOULL@
1461 /* Parse an unsigned integer whose textual representation starts at STRING.
1462 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1463 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1465 If ENDPTR is not NULL, the address of the first byte after the integer is
1467 Upon overflow, the return value is ULLONG_MAX, and errno is set to
1469 # if @REPLACE_STRTOULL@
1470 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1471 # define strtoull rpl_strtoull
1473 # define GNULIB_defined_strtoull_function 1
1474 _GL_FUNCDECL_RPL (strtoull
, unsigned long long,
1475 (const char *restrict string
, char **restrict endptr
,
1477 _GL_ARG_NONNULL ((1)));
1478 _GL_CXXALIAS_RPL (strtoull
, unsigned long long,
1479 (const char *restrict string
, char **restrict endptr
,
1482 # if !@HAVE_STRTOULL@
1483 _GL_FUNCDECL_SYS (strtoull
, unsigned long long,
1484 (const char *restrict string
, char **restrict endptr
,
1486 _GL_ARG_NONNULL ((1)));
1488 _GL_CXXALIAS_SYS (strtoull
, unsigned long long,
1489 (const char *restrict string
, char **restrict endptr
,
1492 _GL_CXXALIASWARN (strtoull
);
1493 #elif defined GNULIB_POSIXCHECK
1495 # if HAVE_RAW_DECL_STRTOULL
1496 _GL_WARN_ON_USE (strtoull
, "strtoull is unportable - "
1497 "use gnulib module strtoull for portability");
1501 #if @GNULIB_UNLOCKPT@
1502 /* Unlock the slave side of the pseudo-terminal whose master side is specified
1503 by FD, so that it can be opened. */
1504 # if !@HAVE_UNLOCKPT@
1505 _GL_FUNCDECL_SYS (unlockpt
, int, (int fd
));
1507 _GL_CXXALIAS_SYS (unlockpt
, int, (int fd
));
1508 _GL_CXXALIASWARN (unlockpt
);
1509 #elif defined GNULIB_POSIXCHECK
1511 # if HAVE_RAW_DECL_UNLOCKPT
1512 _GL_WARN_ON_USE (unlockpt
, "unlockpt is not portable - "
1513 "use gnulib module unlockpt for portability");
1517 #if @GNULIB_UNSETENV@
1518 /* Remove the variable NAME from the environment. */
1519 # if @REPLACE_UNSETENV@
1520 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1522 # define unsetenv rpl_unsetenv
1524 _GL_FUNCDECL_RPL (unsetenv
, int, (const char *name
) _GL_ARG_NONNULL ((1)));
1525 _GL_CXXALIAS_RPL (unsetenv
, int, (const char *name
));
1527 # if !@HAVE_DECL_UNSETENV@
1528 _GL_FUNCDECL_SYS (unsetenv
, int, (const char *name
) _GL_ARG_NONNULL ((1)));
1530 _GL_CXXALIAS_SYS (unsetenv
, int, (const char *name
));
1532 # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
1533 _GL_CXXALIASWARN (unsetenv
);
1535 #elif defined GNULIB_POSIXCHECK
1537 # if HAVE_RAW_DECL_UNSETENV
1538 _GL_WARN_ON_USE (unsetenv
, "unsetenv is unportable - "
1539 "use gnulib module unsetenv for portability");
1543 /* Convert a wide character to a multibyte character. */
1545 # if @REPLACE_WCTOMB@
1546 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1548 # define wctomb rpl_wctomb
1550 _GL_FUNCDECL_RPL (wctomb
, int, (char *s
, wchar_t wc
));
1551 _GL_CXXALIAS_RPL (wctomb
, int, (char *s
, wchar_t wc
));
1553 _GL_CXXALIAS_SYS (wctomb
, int, (char *s
, wchar_t wc
));
1556 _GL_CXXALIASWARN (wctomb
);
1561 #endif /* _@GUARD_PREFIX@_STDLIB_H */
1562 #endif /* _@GUARD_PREFIX@_STDLIB_H */