1 #ifndef _STDLIB_H 2 #define _STDLIB_H 3 4 #ifdef __cplusplus 5 extern "C" { 6 #endif 7 8 #include <features.h> 9 10 #if __cplusplus >= 201103L 11 #define NULL nullptr 12 #elif defined(__cplusplus) 13 #define NULL 0L 14 #else 15 #define NULL ((void*)0) 16 #endif 17 18 #define __NEED_size_t 19 #define __NEED_wchar_t 20 21 #include <bits/alltypes.h> 22 23 int atoi (const char *); 24 long atol (const char *); 25 long long atoll (const char *); 26 double atof (const char *); 27 28 float strtof (const char *__restrict, char **__restrict); 29 double strtod (const char *__restrict, char **__restrict); 30 long double strtold (const char *__restrict, char **__restrict); 31 32 long strtol (const char *__restrict, char **__restrict, int); 33 unsigned long strtoul (const char *__restrict, char **__restrict, int); 34 long long strtoll (const char *__restrict, char **__restrict, int); 35 unsigned long long strtoull (const char *__restrict, char **__restrict, int); 36 37 int rand (void); 38 void srand (unsigned); 39 40 void *malloc (size_t); 41 void *calloc (size_t, size_t); 42 void *realloc (void *, size_t); 43 void free (void *); 44 void *aligned_alloc(size_t, size_t); 45 46 _Noreturn void abort (void); 47 int atexit (void (*) (void)); 48 _Noreturn void exit (int); 49 _Noreturn void _Exit (int); 50 int at_quick_exit (void (*) (void)); 51 _Noreturn void quick_exit (int); 52 53 char *getenv (const char *); 54 55 int system (const char *); 56 57 void *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *, const void *)); 58 void qsort (void *, size_t, size_t, int (*)(const void *, const void *)); 59 60 int abs (int); 61 long labs (long); 62 long long llabs (long long); 63 64 typedef struct { int quot, rem; } div_t; 65 typedef struct { long quot, rem; } ldiv_t; 66 typedef struct { long long quot, rem; } lldiv_t; 67 68 div_t div (int, int); 69 ldiv_t ldiv (long, long); 70 lldiv_t lldiv (long long, long long); 71 72 int mblen (const char *, size_t); 73 int mbtowc (wchar_t *__restrict, const char *__restrict, size_t); 74 int wctomb (char *, wchar_t); 75 size_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t); 76 size_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t); 77 78 unsigned int arc4random(void); 79 unsigned int arc4random_uniform(unsigned int); 80 void arc4random_buf(void *, size_t); 81 82 #define EXIT_FAILURE 1 83 #define EXIT_SUCCESS 0 84 85 size_t __ctype_get_mb_cur_max(void); 86 #define MB_CUR_MAX (__ctype_get_mb_cur_max()) 87 88 #define RAND_MAX (0x7fffffff) 89 90 91 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ 92 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ 93 || defined(_BSD_SOURCE) 94 95 #define WNOHANG 1 96 #define WUNTRACED 2 97 98 #define WEXITSTATUS(s) (((s) & 0xff00) >> 8) 99 #define WTERMSIG(s) ((s) & 0x7f) 100 #define WSTOPSIG(s) WEXITSTATUS(s) 101 #define WIFEXITED(s) (!WTERMSIG(s)) 102 #define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00) 103 #define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu) 104 105 int posix_memalign (void **, size_t, size_t); 106 int setenv (const char *, const char *, int); 107 int unsetenv (const char *); 108 int mkstemp (char *); 109 int mkostemp (char *, int); 110 char *mkdtemp (char *); 111 int getsubopt (char **, char *const *, char **); 112 int rand_r (unsigned *); 113 114 #endif 115 116 117 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ 118 || defined(_BSD_SOURCE) 119 char *realpath (const char *__restrict, char *__restrict); 120 long int random (void); 121 void srandom (unsigned int); 122 char *initstate (unsigned int, char *, size_t); 123 char *setstate (char *); 124 int putenv (char *); 125 int posix_openpt (int); 126 int grantpt (int); 127 int unlockpt (int); 128 char *ptsname (int); 129 char *l64a (long); 130 long a64l (const char *); 131 void setkey (const char *); 132 double drand48 (void); 133 double erand48 (unsigned short [3]); 134 long int lrand48 (void); 135 long int nrand48 (unsigned short [3]); 136 long mrand48 (void); 137 long jrand48 (unsigned short [3]); 138 void srand48 (long); 139 unsigned short *seed48 (unsigned short [3]); 140 void lcong48 (unsigned short [7]); 141 #endif 142 143 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 144 #include <alloca.h> 145 char *mktemp (char *); 146 int mkstemps (char *, int); 147 int mkostemps (char *, int, int); 148 void *valloc (size_t); 149 void *memalign(size_t, size_t); 150 int getloadavg(double *, int); 151 int clearenv(void); 152 #define WCOREDUMP(s) ((s) & 0x80) 153 #define WIFCONTINUED(s) ((s) == 0xffff) 154 void *reallocarray (void *, size_t, size_t); 155 void qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *); 156 #endif 157 158 #ifdef _GNU_SOURCE 159 int ptsname_r(int, char *, size_t); 160 char *ecvt(double, int, int *, int *); 161 char *fcvt(double, int, int *, int *); 162 char *gcvt(double, int, char *); 163 char *secure_getenv(const char *); 164 struct __locale_struct; 165 float strtof_l(const char *__restrict, char **__restrict, struct __locale_struct *); 166 double strtod_l(const char *__restrict, char **__restrict, struct __locale_struct *); 167 long double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *); 168 #endif 169 170 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) 171 #define mkstemp64 mkstemp 172 #define mkostemp64 mkostemp 173 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 174 #define mkstemps64 mkstemps 175 #define mkostemps64 mkostemps 176 #endif 177 #endif 178 179 #include <fortify/stdlib.h> 180 181 #ifdef __cplusplus 182 } 183 #endif 184 185 #endif 186