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 "_ansi.h" 11 12 #define __need_size_t 13 #define __need_wchar_t 14 #include <stddef.h> 15 16 #include <sys/reent.h> 17 #include <machine/stdlib.h> 18 #ifndef __STRICT_ANSI__ 19 #include <alloca.h> 20 #endif 21 22 #ifdef __CYGWIN__ 23 #include <cygwin/stdlib.h> 24 #endif 25 26 _BEGIN_STD_C 27 28 typedef struct 29 { 30 int quot; /* quotient */ 31 int rem; /* remainder */ 32 } div_t; 33 34 typedef struct 35 { 36 long quot; /* quotient */ 37 long rem; /* remainder */ 38 } ldiv_t; 39 40 #ifndef __STRICT_ANSI__ 41 typedef struct 42 { 43 long long int quot; /* quotient */ 44 long long int rem; /* remainder */ 45 } lldiv_t; 46 #endif 47 48 #ifndef NULL 49 #define NULL 0 50 #endif 51 52 #define EXIT_FAILURE 1 53 #define EXIT_SUCCESS 0 54 55 #define RAND_MAX __RAND_MAX 56 57 extern __IMPORT int __mb_cur_max; 58 59 #define MB_CUR_MAX __mb_cur_max 60 61 _VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((noreturn))); 62 int _EXFUN(abs,(int)); 63 int _EXFUN(atexit,(_VOID (*__func)(_VOID))); 64 double _EXFUN(atof,(const char *__nptr)); 65 #ifndef __STRICT_ANSI__ 66 float _EXFUN(atoff,(const char *__nptr)); 67 #endif 68 int _EXFUN(atoi,(const char *__nptr)); 69 int _EXFUN(_atoi_r,(struct _reent *, const char *__nptr)); 70 long _EXFUN(atol,(const char *__nptr)); 71 long _EXFUN(_atol_r,(struct _reent *, const char *__nptr)); 72 _PTR _EXFUN(bsearch,(const _PTR __key, 73 const _PTR __base, 74 size_t __nmemb, 75 size_t __size, 76 int _EXPARM(_compar,(const _PTR, const _PTR)))); 77 _PTR _EXFUN(calloc,(size_t __nmemb, size_t __size)); 78 div_t _EXFUN(div,(int __numer, int __denom)); 79 _VOID _EXFUN(exit,(int __status) _ATTRIBUTE ((noreturn))); 80 _VOID _EXFUN(free,(_PTR)); 81 char * _EXFUN(getenv,(const char *__string)); 82 char * _EXFUN(_getenv_r,(struct _reent *, const char *__string)); 83 char * _EXFUN(_findenv,(_CONST char *, int *)); 84 char * _EXFUN(_findenv_r,(struct _reent *, _CONST char *, int *)); 85 long _EXFUN(labs,(long)); 86 ldiv_t _EXFUN(ldiv,(long __numer, long __denom)); 87 _PTR _EXFUN(malloc,(size_t __size)); 88 int _EXFUN(mblen,(const char *, size_t)); 89 int _EXFUN(_mblen_r,(struct _reent *, const char *, size_t, _mbstate_t *)); 90 int _EXFUN(mbtowc,(wchar_t *, const char *, size_t)); 91 int _EXFUN(_mbtowc_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *)); 92 int _EXFUN(wctomb,(char *, wchar_t)); 93 int _EXFUN(_wctomb_r,(struct _reent *, char *, wchar_t, _mbstate_t *)); 94 size_t _EXFUN(mbstowcs,(wchar_t *, const char *, size_t)); 95 size_t _EXFUN(_mbstowcs_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *)); 96 size_t _EXFUN(wcstombs,(char *, const wchar_t *, size_t)); 97 size_t _EXFUN(_wcstombs_r,(struct _reent *, char *, const wchar_t *, size_t, _mbstate_t *)); 98 #ifndef __STRICT_ANSI__ 99 #ifndef _REENT_ONLY 100 int _EXFUN(mkstemp,(char *)); 101 char * _EXFUN(mktemp,(char *)); 102 #endif 103 #endif 104 _VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, int(*_compar)(const _PTR, const _PTR))); 105 int _EXFUN(rand,(_VOID)); 106 _PTR _EXFUN(realloc,(_PTR __r, size_t __size)); 107 _VOID _EXFUN(srand,(unsigned __seed)); 108 double _EXFUN(strtod,(const char *__n, char **__end_PTR)); 109 double _EXFUN(_strtod_r,(struct _reent *,const char *__n, char **__end_PTR)); 110 float _EXFUN(strtof,(const char *__n, char **__end_PTR)); 111 #ifndef __STRICT_ANSI__ 112 /* the following strtodf interface is deprecated...use strtof instead */ 113 # ifndef strtodf 114 # define strtodf strtof 115 # endif 116 #endif 117 long _EXFUN(strtol,(const char *__n, char **__end_PTR, int __base)); 118 long _EXFUN(_strtol_r,(struct _reent *,const char *__n, char **__end_PTR, int __base)); 119 unsigned long _EXFUN(strtoul,(const char *__n, char **__end_PTR, int __base)); 120 unsigned long _EXFUN(_strtoul_r,(struct _reent *,const char *__n, char **__end_PTR, int __base)); 121 122 int _EXFUN(system,(const char *__string)); 123 124 #ifndef __STRICT_ANSI__ 125 long _EXFUN(a64l,(const char *__input)); 126 char * _EXFUN(l64a,(long __input)); 127 char * _EXFUN(_l64a_r,(struct _reent *,long __input)); 128 int _EXFUN(on_exit,(_VOID (*__func)(int, _PTR),_PTR __arg)); 129 _VOID _EXFUN(_Exit,(int __status) _ATTRIBUTE ((noreturn))); 130 int _EXFUN(putenv,(char *__string)); 131 int _EXFUN(_putenv_r,(struct _reent *, char *__string)); 132 int _EXFUN(setenv,(const char *__string, const char *__value, int __overwrite)); 133 int _EXFUN(_setenv_r,(struct _reent *, const char *__string, const char *__value, int __overwrite)); 134 135 char * _EXFUN(gcvt,(double,int,char *)); 136 char * _EXFUN(gcvtf,(float,int,char *)); 137 char * _EXFUN(fcvt,(double,int,int *,int *)); 138 char * _EXFUN(fcvtf,(float,int,int *,int *)); 139 char * _EXFUN(ecvt,(double,int,int *,int *)); 140 char * _EXFUN(ecvtbuf,(double, int, int*, int*, char *)); 141 char * _EXFUN(fcvtbuf,(double, int, int*, int*, char *)); 142 char * _EXFUN(ecvtf,(float,int,int *,int *)); 143 char * _EXFUN(dtoa,(double, int, int, int *, int*, char**)); 144 int _EXFUN(rand_r,(unsigned *__seed)); 145 146 double _EXFUN(drand48,(_VOID)); 147 double _EXFUN(_drand48_r,(struct _reent *)); 148 double _EXFUN(erand48,(unsigned short [3])); 149 double _EXFUN(_erand48_r,(struct _reent *, unsigned short [3])); 150 long _EXFUN(jrand48,(unsigned short [3])); 151 long _EXFUN(_jrand48_r,(struct _reent *, unsigned short [3])); 152 _VOID _EXFUN(lcong48,(unsigned short [7])); 153 _VOID _EXFUN(_lcong48_r,(struct _reent *, unsigned short [7])); 154 long _EXFUN(lrand48,(_VOID)); 155 long _EXFUN(_lrand48_r,(struct _reent *)); 156 long _EXFUN(mrand48,(_VOID)); 157 long _EXFUN(_mrand48_r,(struct _reent *)); 158 long _EXFUN(nrand48,(unsigned short [3])); 159 long _EXFUN(_nrand48_r,(struct _reent *, unsigned short [3])); 160 unsigned short * 161 _EXFUN(seed48,(unsigned short [3])); 162 unsigned short * 163 _EXFUN(_seed48_r,(struct _reent *, unsigned short [3])); 164 _VOID _EXFUN(srand48,(long)); 165 _VOID _EXFUN(_srand48_r,(struct _reent *, long)); 166 long long _EXFUN(atoll,(const char *__nptr)); 167 long long _EXFUN(_atoll_r,(struct _reent *, const char *__nptr)); 168 long long _EXFUN(llabs,(long long)); 169 lldiv_t _EXFUN(lldiv,(long long __numer, long long __denom)); 170 long long _EXFUN(strtoll,(const char *__n, char **__end_PTR, int __base)); 171 long long _EXFUN(_strtoll_r,(struct _reent *, const char *__n, char **__end_PTR, int __base)); 172 unsigned long long _EXFUN(strtoull,(const char *__n, char **__end_PTR, int __base)); 173 unsigned long long _EXFUN(_strtoull_r,(struct _reent *, const char *__n, char **__end_PTR, int __base)); 174 175 #ifndef __CYGWIN__ 176 _VOID _EXFUN(cfree,(_PTR)); 177 void _EXFUN(unsetenv,(const char *__string)); 178 void _EXFUN(_unsetenv_r,(struct _reent *, const char *__string)); 179 #endif 180 181 #endif /* ! __STRICT_ANSI__ */ 182 183 char * _EXFUN(_dtoa_r,(struct _reent *, double, int, int, int *, int*, char**)); 184 #ifndef __CYGWIN__ 185 _PTR _EXFUN(_malloc_r,(struct _reent *, size_t)); 186 _PTR _EXFUN(_calloc_r,(struct _reent *, size_t, size_t)); 187 _VOID _EXFUN(_free_r,(struct _reent *, _PTR)); 188 _PTR _EXFUN(_realloc_r,(struct _reent *, _PTR, size_t)); 189 _VOID _EXFUN(_mstats_r,(struct _reent *, char *)); 190 #endif 191 int _EXFUN(_system_r,(struct _reent *, const char *)); 192 193 _VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *)); 194 195 _END_STD_C 196 197 #endif /* _STDLIB_H_ */ 198