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