]> git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/include/stdlib.h
Define _ALL_SOURCE when generating predefined-macros.txt.
[wasi-libc.git] / libc-top-half / musl / include / stdlib.h
1 #ifndef _STDLIB_H
2 #define _STDLIB_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #include <features.h>
9
10 #ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
11 #ifdef __cplusplus
12 #define NULL 0L
13 #else
14 #define NULL ((void*)0)
15 #endif
16 #else
17 #include <__header_stdlib.h>
18 #define __need_NULL
19 #include <stddef.h>
20 #endif
21
22 #define __NEED_size_t
23 #define __NEED_wchar_t
24
25 #include <bits/alltypes.h>
26
27 int atoi (const char *);
28 long atol (const char *);
29 long long atoll (const char *);
30 double atof (const char *);
31
32 float strtof (const char *__restrict, char **__restrict);
33 double strtod (const char *__restrict, char **__restrict);
34 long double strtold (const char *__restrict, char **__restrict);
35
36 long strtol (const char *__restrict, char **__restrict, int);
37 unsigned long strtoul (const char *__restrict, char **__restrict, int);
38 long long strtoll (const char *__restrict, char **__restrict, int);
39 unsigned long long strtoull (const char *__restrict, char **__restrict, int);
40
41 int rand (void);
42 void srand (unsigned);
43
44 void *malloc (size_t);
45 void *calloc (size_t, size_t);
46 void *realloc (void *, size_t);
47 void free (void *);
48 void *aligned_alloc(size_t, size_t);
49
50 _Noreturn void abort (void);
51 int atexit (void (*) (void));
52 _Noreturn void exit (int);
53 _Noreturn void _Exit (int);
54 int at_quick_exit (void (*) (void));
55 _Noreturn void quick_exit (int);
56
57 char *getenv (const char *);
58
59 int system (const char *);
60
61 void *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
62 void qsort (void *, size_t, size_t, int (*)(const void *, const void *));
63
64 int abs (int);
65 long labs (long);
66 long long llabs (long long);
67
68 typedef struct { int quot, rem; } div_t;
69 typedef struct { long quot, rem; } ldiv_t;
70 typedef struct { long long quot, rem; } lldiv_t;
71
72 div_t div (int, int);
73 ldiv_t ldiv (long, long);
74 lldiv_t lldiv (long long, long long);
75
76 int mblen (const char *, size_t);
77 int mbtowc (wchar_t *__restrict, const char *__restrict, size_t);
78 int wctomb (char *, wchar_t);
79 size_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t);
80 size_t wcstombs (char *__restrict, const wchar_t *__restrict, 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 #ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
109 int mkstemp (char *);
110 int mkostemp (char *, int);
111 char *mkdtemp (char *);
112 #endif
113 int getsubopt (char **, char *const *, char **);
114 int rand_r (unsigned *);
115
116 #endif
117
118
119 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
120 || defined(_BSD_SOURCE)
121 char *realpath (const char *__restrict, char *__restrict);
122 long int random (void);
123 void srandom (unsigned int);
124 char *initstate (unsigned int, char *, size_t);
125 char *setstate (char *);
126 int putenv (char *);
127 int posix_openpt (int);
128 int grantpt (int);
129 int unlockpt (int);
130 char *ptsname (int);
131 char *l64a (long);
132 long a64l (const char *);
133 void setkey (const char *);
134 double drand48 (void);
135 double erand48 (unsigned short [3]);
136 long int lrand48 (void);
137 long int nrand48 (unsigned short [3]);
138 long mrand48 (void);
139 long jrand48 (unsigned short [3]);
140 void srand48 (long);
141 unsigned short *seed48 (unsigned short [3]);
142 void lcong48 (unsigned short [7]);
143 #endif
144
145 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
146 #include <alloca.h>
147 char *mktemp (char *);
148 int mkstemps (char *, int);
149 int mkostemps (char *, int, int);
150 void *valloc (size_t);
151 void *memalign(size_t, size_t);
152 int getloadavg(double *, int);
153 int clearenv(void);
154 #define WCOREDUMP(s) ((s) & 0x80)
155 #define WIFCONTINUED(s) ((s) == 0xffff)
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 struct __locale_struct;
164 float strtof_l(const char *__restrict, char **__restrict, struct __locale_struct *);
165 double strtod_l(const char *__restrict, char **__restrict, struct __locale_struct *);
166 long double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *);
167 #endif
168
169 #ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
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 #endif
179
180 #ifdef __wasilibc_unmodified_upstream /* Declare arc4random functions */
181 #else
182 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
183 #include <stdint.h>
184 uint32_t arc4random(void);
185 void arc4random_buf(void *, size_t);
186 uint32_t arc4random_uniform(uint32_t);
187 #endif
188 #endif
189
190 #ifdef __cplusplus
191 }
192 #endif
193
194 #endif