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 _Noreturn void __cfi_fail_report (void);
48 int atexit (void (*) (void));
49 _Noreturn void exit (int);
50 _Noreturn void _Exit (int);
51 int at_quick_exit (void (*) (void));
52 _Noreturn void quick_exit (int);
53 
54 char *getenv (const char *);
55 
56 int system (const char *);
57 
58 void *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
59 void qsort (void *, size_t, size_t, int (*)(const void *, const void *));
60 
61 int abs (int);
62 long labs (long);
63 long long llabs (long long);
64 
65 typedef struct { int quot, rem; } div_t;
66 typedef struct { long quot, rem; } ldiv_t;
67 typedef struct { long long quot, rem; } lldiv_t;
68 
69 div_t div (int, int);
70 ldiv_t ldiv (long, long);
71 lldiv_t lldiv (long long, long long);
72 
73 int mblen (const char *, size_t);
74 int mbtowc (wchar_t *__restrict, const char *__restrict, size_t);
75 int wctomb (char *, wchar_t);
76 size_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t);
77 size_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t);
78 
79 unsigned int arc4random(void);
80 unsigned int arc4random_uniform(unsigned int);
81 void arc4random_buf(void *, size_t);
82 
83 #define EXIT_FAILURE 1
84 #define EXIT_SUCCESS 0
85 
86 size_t __ctype_get_mb_cur_max(void);
87 #define MB_CUR_MAX (__ctype_get_mb_cur_max())
88 
89 #define RAND_MAX (0x7fffffff)
90 
91 
92 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
93  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
94  || defined(_BSD_SOURCE)
95 
96 #define WNOHANG    1
97 #define WUNTRACED  2
98 
99 #define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
100 #define WTERMSIG(s) ((s) & 0x7f)
101 #define WSTOPSIG(s) WEXITSTATUS(s)
102 #define WIFEXITED(s) (!WTERMSIG(s))
103 #define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001U)>>8) > 0x7f00)
104 #define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu)
105 
106 int posix_memalign (void **, size_t, size_t);
107 int setenv (const char *, const char *, int);
108 int unsetenv (const char *);
109 int mkstemp (char *);
110 int mkostemp (char *, int);
111 char *mkdtemp (char *);
112 int getsubopt (char **, char *const *, char **);
113 int rand_r (unsigned *);
114 
115 #endif
116 
117 
118 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
119  || defined(_BSD_SOURCE)
120 char *realpath (const char *__restrict, char *__restrict);
121 long int random (void);
122 void srandom (unsigned int);
123 char *initstate (unsigned int, char *, size_t);
124 char *setstate (char *);
125 int putenv (char *);
126 int posix_openpt (int);
127 int grantpt (int);
128 int unlockpt (int);
129 char *ptsname (int);
130 char *l64a (long);
131 long a64l (const char *);
132 void setkey (const char *);
133 double drand48 (void);
134 double erand48 (unsigned short [3]);
135 long int lrand48 (void);
136 long int nrand48 (unsigned short [3]);
137 long mrand48 (void);
138 long jrand48 (unsigned short [3]);
139 void srand48 (long);
140 unsigned short *seed48 (unsigned short [3]);
141 void lcong48 (unsigned short [7]);
142 #endif
143 
144 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
145 #include <alloca.h>
146 char *mktemp (char *);
147 int mkstemps (char *, int);
148 int mkostemps (char *, int, int);
149 void *valloc (size_t);
150 void *memalign(size_t, size_t);
151 int getloadavg(double *, int);
152 int clearenv(void);
153 #define WCOREDUMP(s) ((s) & 0x80)
154 #define WIFCONTINUED(s) ((s) == 0xffff)
155 void *reallocarray (void *, size_t, size_t);
156 void qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *);
157 #endif
158 
159 #ifdef _GNU_SOURCE
160 int ptsname_r(int, char *, size_t);
161 char *ecvt(double, int, int *, int *);
162 char *fcvt(double, int, int *, int *);
163 char *gcvt(double, int, char *);
164 char *secure_getenv(const char *);
165 struct __locale_struct;
166 float strtof_l(const char *__restrict, char **__restrict, struct __locale_struct *);
167 double strtod_l(const char *__restrict, char **__restrict, struct __locale_struct *);
168 long double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *);
169 #endif
170 
171 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
172 #define mkstemp64 mkstemp
173 #define mkostemp64 mkostemp
174 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
175 #define mkstemps64 mkstemps
176 #define mkostemps64 mkostemps
177 #endif
178 #endif
179 
180 #ifndef __LITEOS__
181 #include <fortify/stdlib.h>
182 #endif
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif
188