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