Subversion Repositories Kolibri OS

Rev

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