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