20 #pragma GCC system_header
24 #if defined __need_malloc_and_calloc
27 #include_next <stdlib.h>
35 #include_next <stdlib.h>
44 #if 0 && !defined WEXITSTATUS
45 # include <sys/wait.h>
49 #if (0 || defined GNULIB_POSIXCHECK) && 0
50 # include <sys/loadavg.h>
54 #if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
74 # if !GNULIB_defined_struct_random_data
85 # define GNULIB_defined_struct_random_data 1
90 #if (0 || 0 || 0 || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
100 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
101 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
103 # define _GL_ATTRIBUTE_PURE
107 #if !defined _Noreturn && __STDC_VERSION__ < 201112
108 # if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
109 || 0x5110 <= __SUNPRO_C)
110 # define _Noreturn __attribute__ ((__noreturn__))
111 # elif 1200 <= _MSC_VER
112 # define _Noreturn __declspec (noreturn)
119 #ifndef _GL_CXXDEFS_H
120 #define _GL_CXXDEFS_H
183 #if defined __cplusplus
184 # define _GL_EXTERN_C extern "C"
186 # define _GL_EXTERN_C extern
196 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
197 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
198 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
199 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
208 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
209 _GL_EXTERN_C rettype func parameters_and_attributes
217 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
218 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
219 #if defined __cplusplus && defined GNULIB_NAMESPACE
220 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
221 namespace GNULIB_NAMESPACE \
223 rettype (*const func) parameters = ::rpl_func; \
225 _GL_EXTERN_C int _gl_cxxalias_dummy
227 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
228 _GL_EXTERN_C int _gl_cxxalias_dummy
236 #if defined __cplusplus && defined GNULIB_NAMESPACE
237 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
238 namespace GNULIB_NAMESPACE \
240 rettype (*const func) parameters = \
241 reinterpret_cast<rettype(*)parameters>(::rpl_func); \
243 _GL_EXTERN_C int _gl_cxxalias_dummy
245 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
246 _GL_EXTERN_C int _gl_cxxalias_dummy
256 #if defined __cplusplus && defined GNULIB_NAMESPACE
263 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
264 namespace GNULIB_NAMESPACE \
266 static rettype (*func) parameters = ::func; \
268 _GL_EXTERN_C int _gl_cxxalias_dummy
270 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
271 _GL_EXTERN_C int _gl_cxxalias_dummy
279 #if defined __cplusplus && defined GNULIB_NAMESPACE
280 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
281 namespace GNULIB_NAMESPACE \
283 static rettype (*func) parameters = \
284 reinterpret_cast<rettype(*)parameters>(::func); \
286 _GL_EXTERN_C int _gl_cxxalias_dummy
288 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
289 _GL_EXTERN_C int _gl_cxxalias_dummy
298 #if defined __cplusplus && defined GNULIB_NAMESPACE
304 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
305 namespace GNULIB_NAMESPACE \
307 static rettype (*func) parameters = \
308 reinterpret_cast<rettype(*)parameters>( \
309 (rettype2(*)parameters2)(::func)); \
311 _GL_EXTERN_C int _gl_cxxalias_dummy
313 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
314 _GL_EXTERN_C int _gl_cxxalias_dummy
321 #if defined __cplusplus && defined GNULIB_NAMESPACE
322 # define _GL_CXXALIASWARN(func) \
323 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
324 # define _GL_CXXALIASWARN_1(func,namespace) \
325 _GL_CXXALIASWARN_2 (func, namespace)
329 # define _GL_CXXALIASWARN_2(func,namespace) \
330 _GL_WARN_ON_USE (func, \
331 "The symbol ::" #func " refers to the system function. " \
332 "Use " #namespace "::" #func " instead.")
333 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
334 # define _GL_CXXALIASWARN_2(func,namespace) \
335 extern __typeof__ (func) func
337 # define _GL_CXXALIASWARN_2(func,namespace) \
338 _GL_EXTERN_C int _gl_cxxalias_dummy
341 # define _GL_CXXALIASWARN(func) \
342 _GL_EXTERN_C int _gl_cxxalias_dummy
348 #if defined __cplusplus && defined GNULIB_NAMESPACE
349 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
350 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
352 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
353 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
357 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
358 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
359 "The symbol ::" #func " refers to the system function. " \
360 "Use " #namespace "::" #func " instead.")
361 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
362 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
363 extern __typeof__ (func) func
365 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
366 _GL_EXTERN_C int _gl_cxxalias_dummy
369 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
370 _GL_EXTERN_C int _gl_cxxalias_dummy
379 #ifndef _GL_ARG_NONNULL
380 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
381 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
383 # define _GL_ARG_NONNULL(params)
388 #ifndef _GL_WARN_ON_USE
390 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
392 # define _GL_WARN_ON_USE(function, message) \
393 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
394 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
396 # define _GL_WARN_ON_USE(function, message) \
397 extern __typeof__ (function) function
399 # define _GL_WARN_ON_USE(function, message) \
400 _GL_WARN_EXTERN_C int _gl_warn_on_use
410 #ifndef _GL_WARN_ON_USE_CXX
411 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
412 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
413 extern rettype function parameters_and_attributes \
414 __attribute__ ((__warning__ (msg)))
415 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
417 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
418 extern rettype function parameters_and_attributes
420 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
421 _GL_WARN_EXTERN_C int _gl_warn_on_use
427 #ifndef _GL_WARN_EXTERN_C
428 # if defined __cplusplus
429 # define _GL_WARN_EXTERN_C extern "C"
431 # define _GL_WARN_EXTERN_C extern
438 # define EXIT_SUCCESS 0
443 # define EXIT_FAILURE 1
444 #elif EXIT_FAILURE != 1
446 # define EXIT_FAILURE 1
458 #elif defined GNULIB_POSIXCHECK
460 # if HAVE_RAW_DECL__EXIT
462 "use gnulib module _Exit for portability");
477 #elif defined GNULIB_POSIXCHECK
479 # if HAVE_RAW_DECL_ATOLL
481 "use gnulib module atoll for portability");
487 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
489 # define calloc rpl_calloc
497 #elif defined GNULIB_POSIXCHECK
501 "use gnulib module calloc-posix for portability");
506 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
507 # define canonicalize_file_name rpl_canonicalize_file_name
520 #elif defined GNULIB_POSIXCHECK
521 # undef canonicalize_file_name
522 # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
524 "canonicalize_file_name is unportable - "
525 "use gnulib module canonicalize-lgpl for portability");
540 #elif defined GNULIB_POSIXCHECK
542 # if HAVE_RAW_DECL_GETLOADAVG
544 "use gnulib module getloadavg for portability");
562 (
char **optionp,
char *
const *tokens,
char **valuep)
566 (
char **optionp,
char *
const *tokens,
char **valuep));
568 #elif defined GNULIB_POSIXCHECK
570 # if HAVE_RAW_DECL_GETSUBOPT
572 "use gnulib module getsubopt for portability");
584 #elif defined GNULIB_POSIXCHECK
586 # if HAVE_RAW_DECL_GRANTPT
588 "use gnulib module grantpt for portability");
598 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
599 || _GL_USE_STDLIB_ALLOC)
601 # define malloc rpl_malloc
609 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
613 "use gnulib module malloc-posix for portability");
619 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
621 # define mbtowc rpl_mbtowc
642 #elif defined GNULIB_POSIXCHECK
644 # if HAVE_RAW_DECL_MKDTEMP
646 "use gnulib module mkdtemp for portability");
669 #elif defined GNULIB_POSIXCHECK
671 # if HAVE_RAW_DECL_MKOSTEMP
673 "use gnulib module mkostemp for portability");
693 (
char * ,
int ,
int )
697 (
char * ,
int ,
int ));
699 #elif defined GNULIB_POSIXCHECK
701 # if HAVE_RAW_DECL_MKOSTEMPS
703 "use gnulib module mkostemps for portability");
718 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
719 # define mkstemp rpl_mkstemp
730 #elif defined GNULIB_POSIXCHECK
732 # if HAVE_RAW_DECL_MKSTEMP
734 "use gnulib module mkstemp for portability");
755 #elif defined GNULIB_POSIXCHECK
757 # if HAVE_RAW_DECL_MKSTEMPS
759 "use gnulib module mkstemps for portability");
771 #elif defined GNULIB_POSIXCHECK
773 # if HAVE_RAW_DECL_POSIX_OPENPT
775 "use gnulib module posix_openpt for portability");
783 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
785 # define ptsname rpl_ptsname
796 #elif defined GNULIB_POSIXCHECK
798 # if HAVE_RAW_DECL_PTSNAME
800 "use gnulib module ptsname for portability");
809 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
811 # define ptsname_r rpl_ptsname_r
822 #elif defined GNULIB_POSIXCHECK
824 # if HAVE_RAW_DECL_PTSNAME_R
826 "use gnulib module ptsname_r for portability");
832 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
834 # define putenv rpl_putenv
848 # define RAND_MAX 2147483647
860 #elif defined GNULIB_POSIXCHECK
862 # if HAVE_RAW_DECL_RANDOM
864 "use gnulib module random for portability");
874 #elif defined GNULIB_POSIXCHECK
876 # if HAVE_RAW_DECL_SRANDOM
878 "use gnulib module random for portability");
885 (
unsigned int seed,
char *buf,
size_t buf_size)
889 (
unsigned int seed,
char *buf,
size_t buf_size));
891 #elif defined GNULIB_POSIXCHECK
893 # if HAVE_RAW_DECL_INITSTATE_R
895 "use gnulib module random for portability");
905 #elif defined GNULIB_POSIXCHECK
907 # if HAVE_RAW_DECL_SETSTATE_R
909 "use gnulib module random for portability");
916 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
918 # define random_r rpl_random_r
922 _GL_CXXALIAS_RPL (random_r,
int, (
struct random_data *buf, int32_t *result));
928 _GL_CXXALIAS_SYS (random_r,
int, (
struct random_data *buf, int32_t *result));
931 #elif defined GNULIB_POSIXCHECK
933 # if HAVE_RAW_DECL_RANDOM_R
935 "use gnulib module random_r for portability");
941 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
943 # define srandom_r rpl_srandom_r
946 (
unsigned int seed,
struct random_data *rand_state)
949 (
unsigned int seed,
struct random_data *rand_state));
953 (
unsigned int seed,
struct random_data *rand_state)
957 (
unsigned int seed,
struct random_data *rand_state));
960 #elif defined GNULIB_POSIXCHECK
962 # if HAVE_RAW_DECL_SRANDOM_R
964 "use gnulib module random_r for portability");
970 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
972 # define initstate_r rpl_initstate_r
975 (
unsigned int seed,
char *buf,
size_t buf_size,
976 struct random_data *rand_state)
979 (
unsigned int seed,
char *buf,
size_t buf_size,
980 struct random_data *rand_state));
984 (
unsigned int seed,
char *buf,
size_t buf_size,
985 struct random_data *rand_state)
989 (
unsigned int seed,
char *buf,
size_t buf_size,
990 struct random_data *rand_state));
993 #elif defined GNULIB_POSIXCHECK
995 # if HAVE_RAW_DECL_INITSTATE_R
997 "use gnulib module random_r for portability");
1003 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1005 # define setstate_r rpl_setstate_r
1008 (
char *arg_state,
struct random_data *rand_state)
1011 (
char *arg_state,
struct random_data *rand_state));
1015 (
char *arg_state,
struct random_data *rand_state)
1019 (
char *arg_state,
struct random_data *rand_state));
1022 #elif defined GNULIB_POSIXCHECK
1024 # if HAVE_RAW_DECL_SETSTATE_R
1026 "use gnulib module random_r for portability");
1033 # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
1034 || _GL_USE_STDLIB_ALLOC)
1036 # define realloc rpl_realloc
1044 #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
1047 _GL_WARN_ON_USE (realloc,
"realloc is not POSIX compliant everywhere - "
1048 "use gnulib module realloc-posix for portability");
1053 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1054 # define realpath rpl_realpath
1067 #elif defined GNULIB_POSIXCHECK
1069 # if HAVE_RAW_DECL_REALPATH
1070 _GL_WARN_ON_USE (realpath,
"realpath is unportable - use gnulib module "
1071 "canonicalize or canonicalize-lgpl for portability");
1083 #elif defined GNULIB_POSIXCHECK
1085 # if HAVE_RAW_DECL_RPMATCH
1087 "use gnulib module rpmatch for portability");
1095 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1097 # define setenv rpl_setenv
1100 (
const char *name,
const char *value,
int replace)
1103 (
const char *name,
const char *value,
int replace));
1107 (
const char *name,
const char *value,
int replace)
1111 (
const char *name,
const char *value,
int replace));
1116 #elif defined GNULIB_POSIXCHECK
1118 # if HAVE_RAW_DECL_SETENV
1120 "use gnulib module setenv for portability");
1127 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1128 # define strtod rpl_strtod
1141 #elif defined GNULIB_POSIXCHECK
1143 # if HAVE_RAW_DECL_STRTOD
1145 "use gnulib module strtod for portability");
1160 (
const char *
string,
char **endptr,
int base)
1164 (
const char *
string,
char **endptr,
int base));
1166 #elif defined GNULIB_POSIXCHECK
1168 # if HAVE_RAW_DECL_STRTOLL
1170 "use gnulib module strtoll for portability");
1185 (
const char *
string,
char **endptr,
int base)
1189 (
const char *
string,
char **endptr,
int base));
1191 #elif defined GNULIB_POSIXCHECK
1193 # if HAVE_RAW_DECL_STRTOULL
1195 "use gnulib module strtoull for portability");
1207 #elif defined GNULIB_POSIXCHECK
1209 # if HAVE_RAW_DECL_UNLOCKPT
1211 "use gnulib module unlockpt for portability");
1218 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1220 # define unsetenv rpl_unsetenv
1233 #elif defined GNULIB_POSIXCHECK
1235 # if HAVE_RAW_DECL_UNSETENV
1237 "use gnulib module unsetenv for portability");
1244 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1246 # define wctomb rpl_wctomb
#define _GL_ARG_NONNULL(params)
#define _GL_FUNCDECL_RPL(func, rettype, parameters_and_attributes)
#define _GL_CXXALIASWARN(func)
#define _GL_FUNCDECL_SYS(func, rettype, parameters_and_attributes)
#define _GL_WARN_ON_USE(function, message)
#define _GL_ATTRIBUTE_PURE
#define _GL_CXXALIAS_RPL(func, rettype, parameters)
#define _GL_CXXALIAS_SYS(func, rettype, parameters)