Subversion Repositories Kolibri OS

Rev

Rev 4921 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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