Hide itoa, utoa, __itoa and __utoa in stdlib.h on Cygwin only
[newlib-cygwin.git] / newlib / libc / include / stdlib.h
blobfd89f5ba7b28cb5ae36e30fda349856d775c5b52
1 /*
2 * stdlib.h
4 * Definitions for common types, variables, and functions.
5 */
7 #ifndef _STDLIB_H_
8 #define _STDLIB_H_
10 #include <machine/ieeefp.h>
11 #include "_ansi.h"
13 #define __need_size_t
14 #define __need_wchar_t
15 #define __need_NULL
16 #include <stddef.h>
18 #include <sys/reent.h>
19 #include <sys/cdefs.h>
20 #include <machine/stdlib.h>
21 #ifndef __STRICT_ANSI__
22 #include <alloca.h>
23 #endif
25 #ifdef __CYGWIN__
26 #include <cygwin/stdlib.h>
27 #endif
29 #if __GNU_VISIBLE
30 #include <sys/_locale.h>
31 #endif
33 _BEGIN_STD_C
35 typedef struct
37 int quot; /* quotient */
38 int rem; /* remainder */
39 } div_t;
41 typedef struct
43 long quot; /* quotient */
44 long rem; /* remainder */
45 } ldiv_t;
47 #if __ISO_C_VISIBLE >= 1999
48 typedef struct
50 long long int quot; /* quotient */
51 long long int rem; /* remainder */
52 } lldiv_t;
53 #endif
55 #ifndef __compar_fn_t_defined
56 #define __compar_fn_t_defined
57 typedef int (*__compar_fn_t) (const void *, const void *);
58 #endif
60 #define EXIT_FAILURE 1
61 #define EXIT_SUCCESS 0
63 #define RAND_MAX __RAND_MAX
65 int __locale_mb_cur_max (void);
67 #define MB_CUR_MAX __locale_mb_cur_max()
69 void abort (void) _ATTRIBUTE ((__noreturn__));
70 int abs (int);
71 #if __BSD_VISIBLE
72 __uint32_t arc4random (void);
73 __uint32_t arc4random_uniform (__uint32_t);
74 void arc4random_buf (void *, size_t);
75 #endif
76 int atexit (void (*__func)(void));
77 double atof (const char *__nptr);
78 #if __MISC_VISIBLE
79 float atoff (const char *__nptr);
80 #endif
81 int atoi (const char *__nptr);
82 int _atoi_r (struct _reent *, const char *__nptr);
83 long atol (const char *__nptr);
84 long _atol_r (struct _reent *, const char *__nptr);
85 void * bsearch (const void *__key,
86 const void *__base,
87 size_t __nmemb,
88 size_t __size,
89 __compar_fn_t _compar);
90 void *calloc(size_t, size_t) __malloc_like __result_use_check
91 __alloc_size2(1, 2) _NOTHROW;
92 div_t div (int __numer, int __denom);
93 void exit (int __status) _ATTRIBUTE ((__noreturn__));
94 void free (void *) _NOTHROW;
95 char * getenv (const char *__string);
96 char * _getenv_r (struct _reent *, const char *__string);
97 #if __GNU_VISIBLE
98 char * secure_getenv (const char *__string);
99 #endif
100 char * _findenv (const char *, int *);
101 char * _findenv_r (struct _reent *, const char *, int *);
102 #if __POSIX_VISIBLE >= 200809
103 extern char *suboptarg; /* getsubopt(3) external variable */
104 int getsubopt (char **, char * const *, char **);
105 #endif
106 long labs (long);
107 ldiv_t ldiv (long __numer, long __denom);
108 void *malloc(size_t) __malloc_like __result_use_check __alloc_size(1) _NOTHROW;
109 int mblen (const char *, size_t);
110 int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *);
111 int mbtowc (wchar_t *__restrict, const char *__restrict, size_t);
112 int _mbtowc_r (struct _reent *, wchar_t *__restrict, const char *__restrict, size_t, _mbstate_t *);
113 int wctomb (char *, wchar_t);
114 int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *);
115 size_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t);
116 size_t _mbstowcs_r (struct _reent *, wchar_t *__restrict, const char *__restrict, size_t, _mbstate_t *);
117 size_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t);
118 size_t _wcstombs_r (struct _reent *, char *__restrict, const wchar_t *__restrict, size_t, _mbstate_t *);
119 #ifndef _REENT_ONLY
120 #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
121 char * mkdtemp (char *);
122 #endif
123 #if __GNU_VISIBLE
124 int mkostemp (char *, int);
125 int mkostemps (char *, int, int);
126 #endif
127 #if __MISC_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 4
128 int mkstemp (char *);
129 #endif
130 #if __MISC_VISIBLE
131 int mkstemps (char *, int);
132 #endif
133 #if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112)
134 char * mktemp (char *) _ATTRIBUTE ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead")));
135 #endif
136 #endif /* !_REENT_ONLY */
137 char * _mkdtemp_r (struct _reent *, char *);
138 int _mkostemp_r (struct _reent *, char *, int);
139 int _mkostemps_r (struct _reent *, char *, int, int);
140 int _mkstemp_r (struct _reent *, char *);
141 int _mkstemps_r (struct _reent *, char *, int);
142 char * _mktemp_r (struct _reent *, char *) _ATTRIBUTE ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead")));
143 void qsort (void *__base, size_t __nmemb, size_t __size, __compar_fn_t _compar);
144 int rand (void);
145 void *realloc(void *, size_t) __result_use_check __alloc_size(2) _NOTHROW;
146 #if __BSD_VISIBLE
147 void *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size2(2, 3);
148 void *reallocf(void *, size_t) __result_use_check __alloc_size(2);
149 #endif
150 #if __BSD_VISIBLE || __XSI_VISIBLE >= 4
151 char * realpath (const char *__restrict path, char *__restrict resolved_path);
152 #endif
153 #if __BSD_VISIBLE
154 int rpmatch (const char *response);
155 #endif
156 #if __XSI_VISIBLE
157 void setkey (const char *__key);
158 #endif
159 void srand (unsigned __seed);
160 double strtod (const char *__restrict __n, char **__restrict __end_PTR);
161 double _strtod_r (struct _reent *,const char *__restrict __n, char **__restrict __end_PTR);
162 #if __ISO_C_VISIBLE >= 1999
163 float strtof (const char *__restrict __n, char **__restrict __end_PTR);
164 #endif
165 #if __MISC_VISIBLE
166 /* the following strtodf interface is deprecated...use strtof instead */
167 # ifndef strtodf
168 # define strtodf strtof
169 # endif
170 #endif
171 long strtol (const char *__restrict __n, char **__restrict __end_PTR, int __base);
172 long _strtol_r (struct _reent *,const char *__restrict __n, char **__restrict __end_PTR, int __base);
173 unsigned long strtoul (const char *__restrict __n, char **__restrict __end_PTR, int __base);
174 unsigned long _strtoul_r (struct _reent *,const char *__restrict __n, char **__restrict __end_PTR, int __base);
176 #if __GNU_VISIBLE
177 double strtod_l (const char *__restrict, char **__restrict, locale_t);
178 float strtof_l (const char *__restrict, char **__restrict, locale_t);
179 #ifdef _HAVE_LONG_DOUBLE
180 extern long double strtold_l (const char *__restrict, char **__restrict,
181 locale_t);
182 #endif /* _HAVE_LONG_DOUBLE */
183 long strtol_l (const char *__restrict, char **__restrict, int, locale_t);
184 unsigned long strtoul_l (const char *__restrict, char **__restrict, int,
185 locale_t __loc);
186 long long strtoll_l (const char *__restrict, char **__restrict, int, locale_t);
187 unsigned long long strtoull_l (const char *__restrict, char **__restrict, int,
188 locale_t __loc);
189 #endif
191 int system (const char *__string);
193 #if __SVID_VISIBLE || __XSI_VISIBLE >= 4
194 long a64l (const char *__input);
195 char * l64a (long __input);
196 char * _l64a_r (struct _reent *,long __input);
197 #endif
198 #if __MISC_VISIBLE
199 int on_exit (void (*__func)(int, void *),void *__arg);
200 #endif
201 #if __ISO_C_VISIBLE >= 1999
202 void _Exit (int __status) _ATTRIBUTE ((__noreturn__));
203 #endif
204 #if __SVID_VISIBLE || __XSI_VISIBLE
205 int putenv (char *__string);
206 #endif
207 int _putenv_r (struct _reent *, char *__string);
208 void * _reallocf_r (struct _reent *, void *, size_t);
209 #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112
210 int setenv (const char *__string, const char *__value, int __overwrite);
211 #endif
212 int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite);
214 #if __XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112
215 char * gcvt (double,int,char *);
216 char * gcvtf (float,int,char *);
217 char * fcvt (double,int,int *,int *);
218 char * fcvtf (float,int,int *,int *);
219 char * ecvt (double,int,int *,int *);
220 char * ecvtbuf (double, int, int*, int*, char *);
221 char * fcvtbuf (double, int, int*, int*, char *);
222 char * ecvtf (float,int,int *,int *);
223 #endif
224 #ifndef __CYGWIN__
225 char * __itoa (int, char *, int);
226 char * __utoa (unsigned, char *, int);
227 # if __MISC_VISIBLE
228 char * itoa (int, char *, int);
229 char * utoa (unsigned, char *, int);
230 # endif
231 #endif
232 #if __POSIX_VISIBLE
233 int rand_r (unsigned *__seed);
234 #endif
236 #if __SVID_VISIBLE || __XSI_VISIBLE
237 double drand48 (void);
238 double _drand48_r (struct _reent *);
239 double erand48 (unsigned short [3]);
240 double _erand48_r (struct _reent *, unsigned short [3]);
241 long jrand48 (unsigned short [3]);
242 long _jrand48_r (struct _reent *, unsigned short [3]);
243 void lcong48 (unsigned short [7]);
244 void _lcong48_r (struct _reent *, unsigned short [7]);
245 long lrand48 (void);
246 long _lrand48_r (struct _reent *);
247 long mrand48 (void);
248 long _mrand48_r (struct _reent *);
249 long nrand48 (unsigned short [3]);
250 long _nrand48_r (struct _reent *, unsigned short [3]);
251 unsigned short *
252 seed48 (unsigned short [3]);
253 unsigned short *
254 _seed48_r (struct _reent *, unsigned short [3]);
255 void srand48 (long);
256 void _srand48_r (struct _reent *, long);
257 #endif /* __SVID_VISIBLE || __XSI_VISIBLE */
258 #if __SVID_VISIBLE || __XSI_VISIBLE >= 4 || __BSD_VISIBLE
259 char * initstate (unsigned, char *, size_t);
260 long random (void);
261 char * setstate (char *);
262 void srandom (unsigned);
263 #endif
264 #if __ISO_C_VISIBLE >= 1999
265 long long atoll (const char *__nptr);
266 #endif
267 long long _atoll_r (struct _reent *, const char *__nptr);
268 #if __ISO_C_VISIBLE >= 1999
269 long long llabs (long long);
270 lldiv_t lldiv (long long __numer, long long __denom);
271 long long strtoll (const char *__restrict __n, char **__restrict __end_PTR, int __base);
272 #endif
273 long long _strtoll_r (struct _reent *, const char *__restrict __n, char **__restrict __end_PTR, int __base);
274 #if __ISO_C_VISIBLE >= 1999
275 unsigned long long strtoull (const char *__restrict __n, char **__restrict __end_PTR, int __base);
276 #endif
277 unsigned long long _strtoull_r (struct _reent *, const char *__restrict __n, char **__restrict __end_PTR, int __base);
279 #ifndef __CYGWIN__
280 #if __MISC_VISIBLE
281 void cfree (void *);
282 #endif
283 #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112
284 int unsetenv (const char *__string);
285 #endif
286 int _unsetenv_r (struct _reent *, const char *__string);
287 #endif /* !__CYGWIN__ */
289 #if __POSIX_VISIBLE >= 200112
290 int posix_memalign (void **, size_t, size_t) __nonnull((1))
291 __result_use_check;
292 #endif
294 char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**);
295 #ifndef __CYGWIN__
296 void * _malloc_r (struct _reent *, size_t) _NOTHROW;
297 void * _calloc_r (struct _reent *, size_t, size_t) _NOTHROW;
298 void _free_r (struct _reent *, void *) _NOTHROW;
299 void * _realloc_r (struct _reent *, void *, size_t) _NOTHROW;
300 void _mstats_r (struct _reent *, char *);
301 #endif
302 int _system_r (struct _reent *, const char *);
304 void __eprintf (const char *, const char *, unsigned int, const char *);
306 /* There are two common qsort_r variants. If you request
307 _BSD_SOURCE, you get the BSD version; otherwise you get the GNU
308 version. We want that #undef qsort_r will still let you
309 invoke the underlying function, but that requires gcc support. */
310 #if __GNU_VISIBLE
311 void qsort_r (void *__base, size_t __nmemb, size_t __size, int (*_compar)(const void *, const void *, void *), void *__thunk);
312 #elif __BSD_VISIBLE
313 # ifdef __GNUC__
314 void qsort_r (void *__base, size_t __nmemb, size_t __size, void *__thunk, int (*_compar)(void *, const void *, const void *))
315 __asm__ (__ASMNAME ("__bsd_qsort_r"));
316 # else
317 void __bsd_qsort_r (void *__base, size_t __nmemb, size_t __size, void *__thunk, int (*_compar)(void *, const void *, const void *));
318 # define qsort_r __bsd_qsort_r
319 # endif
320 #endif
322 /* On platforms where long double equals double. */
323 #ifdef _HAVE_LONG_DOUBLE
324 extern long double _strtold_r (struct _reent *, const char *__restrict, char **__restrict);
325 #if __ISO_C_VISIBLE >= 1999
326 extern long double strtold (const char *__restrict, char **__restrict);
327 #endif
328 #endif /* _HAVE_LONG_DOUBLE */
331 * If we're in a mode greater than C99, expose C11 functions.
333 #if __ISO_C_VISIBLE >= 2011
334 void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
335 __alloc_size(2) __result_use_check;
336 int at_quick_exit(void (*)(void));
337 _Noreturn void
338 quick_exit(int);
339 #endif /* __ISO_C_VISIBLE >= 2011 */
341 _END_STD_C
343 #if __SSP_FORTIFY_LEVEL > 0
344 #include <ssp/stdlib.h>
345 #endif
347 #endif /* _STDLIB_H_ */