1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* A GNU-like <stdlib.h>.
4 Copyright (C) 1995, 2001-2004, 2006-2014 Free Software Foundation, 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 <http://www.gnu.org/licenses/>. */
20 #pragma GCC system_header
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 <stdlib.h>
31 /* Normal invocation convention. */
35 /* The include_next requires a split double-inclusion guard. */
36 #include_next <stdlib.h>
41 /* NetBSD 5.0 mis-defines NULL. */
44 /* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */
45 #if 0 && !defined WEXITSTATUS
46 # include <sys/wait.h>
49 /* Solaris declares getloadavg() in <sys/loadavg.h>. */
50 #if (0 || defined GNULIB_POSIXCHECK) && 0
51 # include <sys/loadavg.h>
54 /* Native Windows platforms declare mktemp() in <io.h>. */
55 #if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
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'. */
73 /* Define 'struct random_data'.
74 But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
75 # if !GNULIB_defined_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
91 #if (0 || 0 || 0 || 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. */
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__))
104 # define _GL_ATTRIBUTE_PURE /* empty */
107 /* The definition of _Noreturn is copied here. */
108 #if !defined _Noreturn && __STDC_VERSION__ < 201112
109 # if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
110 || 0x5110 <= __SUNPRO_C)
111 # define _Noreturn __attribute__ ((__noreturn__))
112 # elif 1200 <= _MSC_VER
113 # define _Noreturn __declspec (noreturn)
119 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
120 #ifndef _GL_CXXDEFS_H
121 #define _GL_CXXDEFS_H
123 /* The three most frequent use cases of these macros are:
125 * For providing a substitute for a function that is missing on some
126 platforms, but is declared and works fine on the platforms on which
131 _GL_FUNCDECL_SYS (foo, ...);
133 _GL_CXXALIAS_SYS (foo, ...);
134 _GL_CXXALIASWARN (foo);
135 #elif defined GNULIB_POSIXCHECK
139 * For providing a replacement for a function that exists on all platforms,
140 but is broken/insufficient and needs to be replaced on some platforms:
144 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
148 _GL_FUNCDECL_RPL (foo, ...);
149 _GL_CXXALIAS_RPL (foo, ...);
151 _GL_CXXALIAS_SYS (foo, ...);
153 _GL_CXXALIASWARN (foo);
154 #elif defined GNULIB_POSIXCHECK
158 * For providing a replacement for a function that exists on some platforms
159 but is broken/insufficient and needs to be replaced on some of them and
160 is additionally either missing or undeclared on some other platforms:
164 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
168 _GL_FUNCDECL_RPL (foo, ...);
169 _GL_CXXALIAS_RPL (foo, ...);
171 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
172 _GL_FUNCDECL_SYS (foo, ...);
174 _GL_CXXALIAS_SYS (foo, ...);
176 _GL_CXXALIASWARN (foo);
177 #elif defined GNULIB_POSIXCHECK
182 /* _GL_EXTERN_C declaration;
183 performs the declaration with C linkage. */
184 #if defined __cplusplus
185 # define _GL_EXTERN_C extern "C"
187 # define _GL_EXTERN_C extern
190 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
191 declares a replacement function, named rpl_func, with the given prototype,
192 consisting of return type, parameters, and attributes.
194 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
195 _GL_ARG_NONNULL ((1)));
197 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
198 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
199 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
200 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
202 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
203 declares the system function, named func, with the given prototype,
204 consisting of return type, parameters, and attributes.
206 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
207 _GL_ARG_NONNULL ((1)));
209 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
210 _GL_EXTERN_C rettype func parameters_and_attributes
212 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
213 declares a C++ alias called GNULIB_NAMESPACE::func
214 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
216 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
218 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
219 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
220 #if defined __cplusplus && defined GNULIB_NAMESPACE
221 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
222 namespace GNULIB_NAMESPACE \
224 rettype (*const func) parameters = ::rpl_func; \
226 _GL_EXTERN_C int _gl_cxxalias_dummy
228 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
229 _GL_EXTERN_C int _gl_cxxalias_dummy
232 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
233 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
234 except that the C function rpl_func may have a slightly different
235 declaration. A cast is used to silence the "invalid conversion" error
236 that would otherwise occur. */
237 #if defined __cplusplus && defined GNULIB_NAMESPACE
238 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
239 namespace GNULIB_NAMESPACE \
241 rettype (*const func) parameters = \
242 reinterpret_cast<rettype(*)parameters>(::rpl_func); \
244 _GL_EXTERN_C int _gl_cxxalias_dummy
246 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
247 _GL_EXTERN_C int _gl_cxxalias_dummy
250 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
251 declares a C++ alias called GNULIB_NAMESPACE::func
252 that redirects to the system provided function func, if GNULIB_NAMESPACE
255 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
257 #if defined __cplusplus && defined GNULIB_NAMESPACE
258 /* If we were to write
259 rettype (*const func) parameters = ::func;
260 like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
261 better (remove an indirection through a 'static' pointer variable),
262 but then the _GL_CXXALIASWARN macro below would cause a warning not only
263 for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */
264 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
265 namespace GNULIB_NAMESPACE \
267 static rettype (*func) parameters = ::func; \
269 _GL_EXTERN_C int _gl_cxxalias_dummy
271 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
272 _GL_EXTERN_C int _gl_cxxalias_dummy
275 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
276 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
277 except that the C function func may have a slightly different declaration.
278 A cast is used to silence the "invalid conversion" error that would
280 #if defined __cplusplus && defined GNULIB_NAMESPACE
281 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
282 namespace GNULIB_NAMESPACE \
284 static rettype (*func) parameters = \
285 reinterpret_cast<rettype(*)parameters>(::func); \
287 _GL_EXTERN_C int _gl_cxxalias_dummy
289 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
290 _GL_EXTERN_C int _gl_cxxalias_dummy
293 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
294 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
295 except that the C function is picked among a set of overloaded functions,
296 namely the one with rettype2 and parameters2. Two consecutive casts
297 are used to silence the "cannot find a match" and "invalid conversion"
298 errors that would otherwise occur. */
299 #if defined __cplusplus && defined GNULIB_NAMESPACE
300 /* The outer cast must be a reinterpret_cast.
301 The inner cast: When the function is defined as a set of overloaded
302 functions, it works as a static_cast<>, choosing the designated variant.
303 When the function is defined as a single variant, it works as a
304 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
305 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
306 namespace GNULIB_NAMESPACE \
308 static rettype (*func) parameters = \
309 reinterpret_cast<rettype(*)parameters>( \
310 (rettype2(*)parameters2)(::func)); \
312 _GL_EXTERN_C int _gl_cxxalias_dummy
314 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
315 _GL_EXTERN_C int _gl_cxxalias_dummy
318 /* _GL_CXXALIASWARN (func);
319 causes a warning to be emitted when ::func is used but not when
320 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
322 #if defined __cplusplus && defined GNULIB_NAMESPACE
323 # define _GL_CXXALIASWARN(func) \
324 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
325 # define _GL_CXXALIASWARN_1(func,namespace) \
326 _GL_CXXALIASWARN_2 (func, namespace)
327 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
328 we enable the warning only when not optimizing. */
330 # define _GL_CXXALIASWARN_2(func,namespace) \
331 _GL_WARN_ON_USE (func, \
332 "The symbol ::" #func " refers to the system function. " \
333 "Use " #namespace "::" #func " instead.")
334 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
335 # define _GL_CXXALIASWARN_2(func,namespace) \
336 extern __typeof__ (func) func
338 # define _GL_CXXALIASWARN_2(func,namespace) \
339 _GL_EXTERN_C int _gl_cxxalias_dummy
342 # define _GL_CXXALIASWARN(func) \
343 _GL_EXTERN_C int _gl_cxxalias_dummy
346 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
347 causes a warning to be emitted when the given overloaded variant of ::func
348 is used but not when GNULIB_NAMESPACE::func is used. */
349 #if defined __cplusplus && defined GNULIB_NAMESPACE
350 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
351 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
353 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
354 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
355 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
356 we enable the warning only when not optimizing. */
358 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
359 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
360 "The symbol ::" #func " refers to the system function. " \
361 "Use " #namespace "::" #func " instead.")
362 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
363 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
364 extern __typeof__ (func) func
366 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
367 _GL_EXTERN_C int _gl_cxxalias_dummy
370 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
371 _GL_EXTERN_C int _gl_cxxalias_dummy
374 #endif /* _GL_CXXDEFS_H */
376 /* The definition of _GL_ARG_NONNULL is copied here. */
377 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
378 that the values passed as arguments n, ..., m must be non-NULL pointers.
379 n = 1 stands for the first argument, n = 2 for the second argument etc. */
380 #ifndef _GL_ARG_NONNULL
381 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
382 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
384 # define _GL_ARG_NONNULL(params)
388 /* The definition of _GL_WARN_ON_USE is copied here. */
389 #ifndef _GL_WARN_ON_USE
391 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
392 /* A compiler attribute is available in gcc versions 4.3.0 and later. */
393 # define _GL_WARN_ON_USE(function, message) \
394 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
395 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
396 /* Verify the existence of the function. */
397 # define _GL_WARN_ON_USE(function, message) \
398 extern __typeof__ (function) function
399 # else /* Unsupported. */
400 # define _GL_WARN_ON_USE(function, message) \
401 _GL_WARN_EXTERN_C int _gl_warn_on_use
405 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
406 is like _GL_WARN_ON_USE (function, "string"), except that the function is
407 declared with the given prototype, consisting of return type, parameters,
409 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
410 not work in this case. */
411 #ifndef _GL_WARN_ON_USE_CXX
412 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
413 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
414 extern rettype function parameters_and_attributes \
415 __attribute__ ((__warning__ (msg)))
416 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
417 /* Verify the existence of the function. */
418 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
419 extern rettype function parameters_and_attributes
420 # else /* Unsupported. */
421 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
422 _GL_WARN_EXTERN_C int _gl_warn_on_use
426 /* _GL_WARN_EXTERN_C declaration;
427 performs the declaration with C linkage. */
428 #ifndef _GL_WARN_EXTERN_C
429 # if defined __cplusplus
430 # define _GL_WARN_EXTERN_C extern "C"
432 # define _GL_WARN_EXTERN_C extern
437 /* Some systems do not define EXIT_*, despite otherwise supporting C89. */
439 # define EXIT_SUCCESS 0
441 /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
442 with proper operation of xargs. */
444 # define EXIT_FAILURE 1
445 #elif EXIT_FAILURE != 1
447 # define EXIT_FAILURE 1
452 /* Terminate the current process with the given return code, without running
453 the 'atexit' handlers. */
455 _GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status));
457 _GL_CXXALIAS_SYS (_Exit, void, (int status));
458 _GL_CXXALIASWARN (_Exit);
459 #elif defined GNULIB_POSIXCHECK
461 # if HAVE_RAW_DECL__EXIT
462 _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
463 "use gnulib module _Exit for portability");
469 /* Parse a signed decimal integer.
470 Returns the value of the integer. Errors are not detected. */
472 _GL_FUNCDECL_SYS (atoll, long long, (const char *string)
474 _GL_ARG_NONNULL ((1)));
476 _GL_CXXALIAS_SYS (atoll, long long, (const char *string));
477 _GL_CXXALIASWARN (atoll);
478 #elif defined GNULIB_POSIXCHECK
480 # if HAVE_RAW_DECL_ATOLL
481 _GL_WARN_ON_USE (atoll, "atoll is unportable - "
482 "use gnulib module atoll for portability");
488 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
490 # define calloc rpl_calloc
492 _GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size));
493 _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
495 _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
497 _GL_CXXALIASWARN (calloc);
498 #elif defined GNULIB_POSIXCHECK
500 /* Assume calloc is always declared. */
501 _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
502 "use gnulib module calloc-posix for portability");
507 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
508 # define canonicalize_file_name rpl_canonicalize_file_name
510 _GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name)
511 _GL_ARG_NONNULL ((1)));
512 _GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
515 _GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name)
516 _GL_ARG_NONNULL ((1)));
518 _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
520 _GL_CXXALIASWARN (canonicalize_file_name);
521 #elif defined GNULIB_POSIXCHECK
522 # undef canonicalize_file_name
523 # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
524 _GL_WARN_ON_USE (canonicalize_file_name,
525 "canonicalize_file_name is unportable - "
526 "use gnulib module canonicalize-lgpl for portability");
531 /* Store max(NELEM,3) load average numbers in LOADAVG[].
532 The three numbers are the load average of the last 1 minute, the last 5
533 minutes, and the last 15 minutes, respectively.
534 LOADAVG is an array of NELEM numbers. */
536 _GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem)
537 _GL_ARG_NONNULL ((1)));
539 _GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
540 _GL_CXXALIASWARN (getloadavg);
541 #elif defined GNULIB_POSIXCHECK
543 # if HAVE_RAW_DECL_GETLOADAVG
544 _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
545 "use gnulib module getloadavg for portability");
550 /* Assuming *OPTIONP is a comma separated list of elements of the form
551 "token" or "token=value", getsubopt parses the first of these elements.
552 If the first element refers to a "token" that is member of the given
553 NULL-terminated array of tokens:
554 - It replaces the comma with a NUL byte, updates *OPTIONP to point past
555 the first option and the comma, sets *VALUEP to the value of the
556 element (or NULL if it doesn't contain an "=" sign),
557 - It returns the index of the "token" in the given array of tokens.
558 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
559 For more details see the POSIX:2001 specification.
560 http://www.opengroup.org/susv3xsh/getsubopt.html */
562 _GL_FUNCDECL_SYS (getsubopt, int,
563 (char **optionp, char *const *tokens, char **valuep)
564 _GL_ARG_NONNULL ((1, 2, 3)));
566 _GL_CXXALIAS_SYS (getsubopt, int,
567 (char **optionp, char *const *tokens, char **valuep));
568 _GL_CXXALIASWARN (getsubopt);
569 #elif defined GNULIB_POSIXCHECK
571 # if HAVE_RAW_DECL_GETSUBOPT
572 _GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
573 "use gnulib module getsubopt for portability");
578 /* Change the ownership and access permission of the slave side of the
579 pseudo-terminal whose master side is specified by FD. */
581 _GL_FUNCDECL_SYS (grantpt, int, (int fd));
583 _GL_CXXALIAS_SYS (grantpt, int, (int fd));
584 _GL_CXXALIASWARN (grantpt);
585 #elif defined GNULIB_POSIXCHECK
587 # if HAVE_RAW_DECL_GRANTPT
588 _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
589 "use gnulib module grantpt for portability");
593 /* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
594 rely on GNU or POSIX semantics for malloc and realloc (for example,
595 by never specifying a zero size), so it does not need malloc or
596 realloc to be redefined. */
599 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
600 || _GL_USE_STDLIB_ALLOC)
602 # define malloc rpl_malloc
604 _GL_FUNCDECL_RPL (malloc, void *, (size_t size));
605 _GL_CXXALIAS_RPL (malloc, void *, (size_t size));
607 _GL_CXXALIAS_SYS (malloc, void *, (size_t size));
609 _GL_CXXALIASWARN (malloc);
610 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
612 /* Assume malloc is always declared. */
613 _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
614 "use gnulib module malloc-posix for portability");
617 /* Convert a multibyte character to a wide character. */
620 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
622 # define mbtowc rpl_mbtowc
624 _GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
625 _GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
627 _GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
629 _GL_CXXALIASWARN (mbtowc);
633 /* Create a unique temporary directory from TEMPLATE.
634 The last six characters of TEMPLATE must be "XXXXXX";
635 they are replaced with a string that makes the directory name unique.
636 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
637 The directory is created mode 700. */
639 _GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
641 _GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
642 _GL_CXXALIASWARN (mkdtemp);
643 #elif defined GNULIB_POSIXCHECK
645 # if HAVE_RAW_DECL_MKDTEMP
646 _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
647 "use gnulib module mkdtemp for portability");
652 /* Create a unique temporary file from TEMPLATE.
653 The last six characters of TEMPLATE must be "XXXXXX";
654 they are replaced with a string that makes the file name unique.
655 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
656 and O_TEXT, O_BINARY (defined in "binary-io.h").
657 The file is then created, with the specified flags, ensuring it didn't exist
659 The file is created read-write (mask at least 0600 & ~umask), but it may be
660 world-readable and world-writable (mask 0666 & ~umask), depending on the
662 Returns the open file descriptor if successful, otherwise -1 and errno
665 _GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)
666 _GL_ARG_NONNULL ((1)));
668 _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
669 _GL_CXXALIASWARN (mkostemp);
670 #elif defined GNULIB_POSIXCHECK
672 # if HAVE_RAW_DECL_MKOSTEMP
673 _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
674 "use gnulib module mkostemp for portability");
679 /* Create a unique temporary file from TEMPLATE.
680 The last six characters of TEMPLATE before a suffix of length
681 SUFFIXLEN must be "XXXXXX";
682 they are replaced with a string that makes the file name unique.
683 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
684 and O_TEXT, O_BINARY (defined in "binary-io.h").
685 The file is then created, with the specified flags, ensuring it didn't exist
687 The file is created read-write (mask at least 0600 & ~umask), but it may be
688 world-readable and world-writable (mask 0666 & ~umask), depending on the
690 Returns the open file descriptor if successful, otherwise -1 and errno
693 _GL_FUNCDECL_SYS (mkostemps, int,
694 (char * /*template*/, int /*suffixlen*/, int /*flags*/)
695 _GL_ARG_NONNULL ((1)));
697 _GL_CXXALIAS_SYS (mkostemps, int,
698 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
699 _GL_CXXALIASWARN (mkostemps);
700 #elif defined GNULIB_POSIXCHECK
702 # if HAVE_RAW_DECL_MKOSTEMPS
703 _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
704 "use gnulib module mkostemps for portability");
709 /* Create a unique temporary file from TEMPLATE.
710 The last six characters of TEMPLATE must be "XXXXXX";
711 they are replaced with a string that makes the file name unique.
712 The file is then created, ensuring it didn't exist before.
713 The file is created read-write (mask at least 0600 & ~umask), but it may be
714 world-readable and world-writable (mask 0666 & ~umask), depending on the
716 Returns the open file descriptor if successful, otherwise -1 and errno
719 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
720 # define mkstemp rpl_mkstemp
722 _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
723 _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
726 _GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
728 _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
730 _GL_CXXALIASWARN (mkstemp);
731 #elif defined GNULIB_POSIXCHECK
733 # if HAVE_RAW_DECL_MKSTEMP
734 _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
735 "use gnulib module mkstemp for portability");
740 /* Create a unique temporary file from TEMPLATE.
741 The last six characters of TEMPLATE prior to a suffix of length
742 SUFFIXLEN must be "XXXXXX";
743 they are replaced with a string that makes the file name unique.
744 The file is then created, ensuring it didn't exist before.
745 The file is created read-write (mask at least 0600 & ~umask), but it may be
746 world-readable and world-writable (mask 0666 & ~umask), depending on the
748 Returns the open file descriptor if successful, otherwise -1 and errno
751 _GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)
752 _GL_ARG_NONNULL ((1)));
754 _GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
755 _GL_CXXALIASWARN (mkstemps);
756 #elif defined GNULIB_POSIXCHECK
758 # if HAVE_RAW_DECL_MKSTEMPS
759 _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
760 "use gnulib module mkstemps for portability");
765 /* Return an FD open to the master side of a pseudo-terminal. Flags should
766 include O_RDWR, and may also include O_NOCTTY. */
768 _GL_FUNCDECL_SYS (posix_openpt, int, (int flags));
770 _GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
771 _GL_CXXALIASWARN (posix_openpt);
772 #elif defined GNULIB_POSIXCHECK
774 # if HAVE_RAW_DECL_POSIX_OPENPT
775 _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
776 "use gnulib module posix_openpt for portability");
781 /* Return the pathname of the pseudo-terminal slave associated with
782 the master FD is open on, or NULL on errors. */
784 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
786 # define ptsname rpl_ptsname
788 _GL_FUNCDECL_RPL (ptsname, char *, (int fd));
789 _GL_CXXALIAS_RPL (ptsname, char *, (int fd));
792 _GL_FUNCDECL_SYS (ptsname, char *, (int fd));
794 _GL_CXXALIAS_SYS (ptsname, char *, (int fd));
796 _GL_CXXALIASWARN (ptsname);
797 #elif defined GNULIB_POSIXCHECK
799 # if HAVE_RAW_DECL_PTSNAME
800 _GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
801 "use gnulib module ptsname for portability");
806 /* Set the pathname of the pseudo-terminal slave associated with
807 the master FD is open on and return 0, or set errno and return
808 non-zero on errors. */
810 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
812 # define ptsname_r rpl_ptsname_r
814 _GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
815 _GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
818 _GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
820 _GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
822 _GL_CXXALIASWARN (ptsname_r);
823 #elif defined GNULIB_POSIXCHECK
825 # if HAVE_RAW_DECL_PTSNAME_R
826 _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
827 "use gnulib module ptsname_r for portability");
831 #if IN_GREP_GNULIB_TESTS
833 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
835 # define putenv rpl_putenv
837 _GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
838 _GL_CXXALIAS_RPL (putenv, int, (char *string));
840 _GL_CXXALIAS_SYS (putenv, int, (char *string));
842 _GL_CXXALIASWARN (putenv);
849 # define RAND_MAX 2147483647
857 _GL_FUNCDECL_SYS (random, long, (void));
859 _GL_CXXALIAS_SYS (random, long, (void));
860 _GL_CXXALIASWARN (random);
861 #elif defined GNULIB_POSIXCHECK
863 # if HAVE_RAW_DECL_RANDOM
864 _GL_WARN_ON_USE (random, "random is unportable - "
865 "use gnulib module random for portability");
871 _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
873 _GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
874 _GL_CXXALIASWARN (srandom);
875 #elif defined GNULIB_POSIXCHECK
877 # if HAVE_RAW_DECL_SRANDOM
878 _GL_WARN_ON_USE (srandom, "srandom is unportable - "
879 "use gnulib module random for portability");
885 _GL_FUNCDECL_SYS (initstate, char *,
886 (unsigned int seed, char *buf, size_t buf_size)
887 _GL_ARG_NONNULL ((2)));
889 _GL_CXXALIAS_SYS (initstate, char *,
890 (unsigned int seed, char *buf, size_t buf_size));
891 _GL_CXXALIASWARN (initstate);
892 #elif defined GNULIB_POSIXCHECK
894 # if HAVE_RAW_DECL_INITSTATE_R
895 _GL_WARN_ON_USE (initstate, "initstate is unportable - "
896 "use gnulib module random for portability");
902 _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
904 _GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
905 _GL_CXXALIASWARN (setstate);
906 #elif defined GNULIB_POSIXCHECK
908 # if HAVE_RAW_DECL_SETSTATE_R
909 _GL_WARN_ON_USE (setstate, "setstate is unportable - "
910 "use gnulib module random for portability");
917 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
919 # define random_r rpl_random_r
921 _GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
922 _GL_ARG_NONNULL ((1, 2)));
923 _GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
926 _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
927 _GL_ARG_NONNULL ((1, 2)));
929 _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
931 _GL_CXXALIASWARN (random_r);
932 #elif defined GNULIB_POSIXCHECK
934 # if HAVE_RAW_DECL_RANDOM_R
935 _GL_WARN_ON_USE (random_r, "random_r is unportable - "
936 "use gnulib module random_r for portability");
942 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
944 # define srandom_r rpl_srandom_r
946 _GL_FUNCDECL_RPL (srandom_r, int,
947 (unsigned int seed, struct random_data *rand_state)
948 _GL_ARG_NONNULL ((2)));
949 _GL_CXXALIAS_RPL (srandom_r, int,
950 (unsigned int seed, struct random_data *rand_state));
953 _GL_FUNCDECL_SYS (srandom_r, int,
954 (unsigned int seed, struct random_data *rand_state)
955 _GL_ARG_NONNULL ((2)));
957 _GL_CXXALIAS_SYS (srandom_r, int,
958 (unsigned int seed, struct random_data *rand_state));
960 _GL_CXXALIASWARN (srandom_r);
961 #elif defined GNULIB_POSIXCHECK
963 # if HAVE_RAW_DECL_SRANDOM_R
964 _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
965 "use gnulib module random_r for portability");
971 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
973 # define initstate_r rpl_initstate_r
975 _GL_FUNCDECL_RPL (initstate_r, int,
976 (unsigned int seed, char *buf, size_t buf_size,
977 struct random_data *rand_state)
978 _GL_ARG_NONNULL ((2, 4)));
979 _GL_CXXALIAS_RPL (initstate_r, int,
980 (unsigned int seed, char *buf, size_t buf_size,
981 struct random_data *rand_state));
984 _GL_FUNCDECL_SYS (initstate_r, int,
985 (unsigned int seed, char *buf, size_t buf_size,
986 struct random_data *rand_state)
987 _GL_ARG_NONNULL ((2, 4)));
989 _GL_CXXALIAS_SYS (initstate_r, int,
990 (unsigned int seed, char *buf, size_t buf_size,
991 struct random_data *rand_state));
993 _GL_CXXALIASWARN (initstate_r);
994 #elif defined GNULIB_POSIXCHECK
996 # if HAVE_RAW_DECL_INITSTATE_R
997 _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
998 "use gnulib module random_r for portability");
1004 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1006 # define setstate_r rpl_setstate_r
1008 _GL_FUNCDECL_RPL (setstate_r, int,
1009 (char *arg_state, struct random_data *rand_state)
1010 _GL_ARG_NONNULL ((1, 2)));
1011 _GL_CXXALIAS_RPL (setstate_r, int,
1012 (char *arg_state, struct random_data *rand_state));
1015 _GL_FUNCDECL_SYS (setstate_r, int,
1016 (char *arg_state, struct random_data *rand_state)
1017 _GL_ARG_NONNULL ((1, 2)));
1019 _GL_CXXALIAS_SYS (setstate_r, int,
1020 (char *arg_state, struct random_data *rand_state));
1022 _GL_CXXALIASWARN (setstate_r);
1023 #elif defined GNULIB_POSIXCHECK
1025 # if HAVE_RAW_DECL_SETSTATE_R
1026 _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
1027 "use gnulib module random_r for portability");
1034 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
1035 || _GL_USE_STDLIB_ALLOC)
1037 # define realloc rpl_realloc
1039 _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size));
1040 _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
1042 _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
1044 _GL_CXXALIASWARN (realloc);
1045 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
1047 /* Assume realloc is always declared. */
1048 _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
1049 "use gnulib module realloc-posix for portability");
1054 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1055 # define realpath rpl_realpath
1057 _GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved)
1058 _GL_ARG_NONNULL ((1)));
1059 _GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved));
1062 _GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved)
1063 _GL_ARG_NONNULL ((1)));
1065 _GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved));
1067 _GL_CXXALIASWARN (realpath);
1068 #elif defined GNULIB_POSIXCHECK
1070 # if HAVE_RAW_DECL_REALPATH
1071 _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
1072 "canonicalize or canonicalize-lgpl for portability");
1077 /* Test a user response to a question.
1078 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
1080 _GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1)));
1082 _GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
1083 _GL_CXXALIASWARN (rpmatch);
1084 #elif defined GNULIB_POSIXCHECK
1086 # if HAVE_RAW_DECL_RPMATCH
1087 _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
1088 "use gnulib module rpmatch for portability");
1093 /* Look up NAME in the environment, returning 0 in insecure situations. */
1095 _GL_FUNCDECL_SYS (secure_getenv, char *,
1096 (char const *name) _GL_ARG_NONNULL ((1)));
1098 _GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
1099 _GL_CXXALIASWARN (secure_getenv);
1100 #elif defined GNULIB_POSIXCHECK
1101 # undef secure_getenv
1102 # if HAVE_RAW_DECL_SECURE_GETENV
1103 _GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
1104 "use gnulib module secure_getenv for portability");
1108 #if IN_GREP_GNULIB_TESTS
1109 /* Set NAME to VALUE in the environment.
1110 If REPLACE is nonzero, overwrite an existing value. */
1112 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1114 # define setenv rpl_setenv
1116 _GL_FUNCDECL_RPL (setenv, int,
1117 (const char *name, const char *value, int replace)
1118 _GL_ARG_NONNULL ((1)));
1119 _GL_CXXALIAS_RPL (setenv, int,
1120 (const char *name, const char *value, int replace));
1123 _GL_FUNCDECL_SYS (setenv, int,
1124 (const char *name, const char *value, int replace)
1125 _GL_ARG_NONNULL ((1)));
1127 _GL_CXXALIAS_SYS (setenv, int,
1128 (const char *name, const char *value, int replace));
1131 _GL_CXXALIASWARN (setenv);
1133 #elif defined GNULIB_POSIXCHECK
1135 # if HAVE_RAW_DECL_SETENV
1136 _GL_WARN_ON_USE (setenv, "setenv is unportable - "
1137 "use gnulib module setenv for portability");
1142 /* Parse a double from STRING, updating ENDP if appropriate. */
1144 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1145 # define strtod rpl_strtod
1147 _GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp)
1148 _GL_ARG_NONNULL ((1)));
1149 _GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp));
1152 _GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp)
1153 _GL_ARG_NONNULL ((1)));
1155 _GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp));
1157 _GL_CXXALIASWARN (strtod);
1158 #elif defined GNULIB_POSIXCHECK
1160 # if HAVE_RAW_DECL_STRTOD
1161 _GL_WARN_ON_USE (strtod, "strtod is unportable - "
1162 "use gnulib module strtod for portability");
1167 /* Parse a signed integer whose textual representation starts at STRING.
1168 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1169 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1171 If ENDPTR is not NULL, the address of the first byte after the integer is
1173 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
1176 _GL_FUNCDECL_SYS (strtoll, long long,
1177 (const char *string, char **endptr, int base)
1178 _GL_ARG_NONNULL ((1)));
1180 _GL_CXXALIAS_SYS (strtoll, long long,
1181 (const char *string, char **endptr, int base));
1182 _GL_CXXALIASWARN (strtoll);
1183 #elif defined GNULIB_POSIXCHECK
1185 # if HAVE_RAW_DECL_STRTOLL
1186 _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
1187 "use gnulib module strtoll for portability");
1192 /* Parse an unsigned integer whose textual representation starts at STRING.
1193 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1194 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1196 If ENDPTR is not NULL, the address of the first byte after the integer is
1198 Upon overflow, the return value is ULLONG_MAX, and errno is set to
1201 _GL_FUNCDECL_SYS (strtoull, unsigned long long,
1202 (const char *string, char **endptr, int base)
1203 _GL_ARG_NONNULL ((1)));
1205 _GL_CXXALIAS_SYS (strtoull, unsigned long long,
1206 (const char *string, char **endptr, int base));
1207 _GL_CXXALIASWARN (strtoull);
1208 #elif defined GNULIB_POSIXCHECK
1210 # if HAVE_RAW_DECL_STRTOULL
1211 _GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
1212 "use gnulib module strtoull for portability");
1217 /* Unlock the slave side of the pseudo-terminal whose master side is specified
1218 by FD, so that it can be opened. */
1220 _GL_FUNCDECL_SYS (unlockpt, int, (int fd));
1222 _GL_CXXALIAS_SYS (unlockpt, int, (int fd));
1223 _GL_CXXALIASWARN (unlockpt);
1224 #elif defined GNULIB_POSIXCHECK
1226 # if HAVE_RAW_DECL_UNLOCKPT
1227 _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
1228 "use gnulib module unlockpt for portability");
1232 #if IN_GREP_GNULIB_TESTS
1233 /* Remove the variable NAME from the environment. */
1235 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1237 # define unsetenv rpl_unsetenv
1239 _GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
1240 _GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
1243 _GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
1245 _GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
1248 _GL_CXXALIASWARN (unsetenv);
1250 #elif defined GNULIB_POSIXCHECK
1252 # if HAVE_RAW_DECL_UNSETENV
1253 _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
1254 "use gnulib module unsetenv for portability");
1258 /* Convert a wide character to a multibyte character. */
1261 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1263 # define wctomb rpl_wctomb
1265 _GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc));
1266 _GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
1268 _GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
1270 _GL_CXXALIASWARN (wctomb);
1274 #endif /* _GL_STDLIB_H */
1275 #endif /* _GL_STDLIB_H */