source: trunk/libs/newlib/src/newlib/libc/include/stdlib.h @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

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