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: _BEGIN_STD_C 23: 24: typedef struct 25: { 26: int quot; /* quotient */ 27: int rem; /* remainder */ 28: } div_t; 29: 30: typedef struct 31: { 32: long quot; /* quotient */ 33: long rem; /* remainder */ 34: } ldiv_t; 35: 36: #ifndef __STRICT_ANSI__ 37: typedef struct 38: { 39: long long int quot; /* quotient */ 40: long long int rem; /* remainder */ 41: } lldiv_t; 42: #endif 43: 44: #ifndef NULL 45: #define NULL 0 46: #endif 47: 48: #define EXIT_FAILURE 1 49: #define EXIT_SUCCESS 0 50: 51: #define RAND_MAX __RAND_MAX 52: 53: extern __IMPORT int __mb_cur_max; 54: 55: #define MB_CUR_MAX __mb_cur_max 56: 57: _VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((noreturn))); 58: int _EXFUN(abs,(int)); 59: int _EXFUN(atexit,(_VOID (*__func)(_VOID))); 60: double _EXFUN(atof,(const char *__nptr)); 61: #ifndef __STRICT_ANSI__ 62: float _EXFUN(atoff,(const char *__nptr)); 63: #endif 64: int _EXFUN(atoi,(const char *__nptr)); 65: int _EXFUN(_atoi_r,(struct _reent *, const char *__nptr)); 66: long _EXFUN(atol,(const char *__nptr)); 67: long _EXFUN(_atol_r,(struct _reent *, const char *__nptr)); 68: _PTR _EXFUN(bsearch,(const _PTR __key, 69: const _PTR __base, 70: size_t __nmemb, 71: size_t __size, 72: int _EXPARM(_compar,(const _PTR, const _PTR)))); 73: _PTR _EXFUN(calloc,(size_t __nmemb, size_t __size)); 74: div_t _EXFUN(div,(int __numer, int __denom)); 75: _VOID _EXFUN(exit,(int __status) _ATTRIBUTE ((noreturn))); 76: _VOID _EXFUN(free,(_PTR)); 77: char * _EXFUN(getenv,(const char *__string)); 78: char * _EXFUN(_getenv_r,(struct _reent *, const char *__string)); 79: #ifdef __CYGWIN__ 80: const char *_EXFUN(getprogname,(void)); 81: #endif 82: char * _EXFUN(_findenv,(_CONST char *, int *)); 83: char * _EXFUN(_findenv_r,(struct _reent *, _CONST char *, int *)); 84: long _EXFUN(labs,(long)); 85: ldiv_t _EXFUN(ldiv,(long __numer, long __denom)); 86: _PTR _EXFUN(malloc,(size_t __size)); 87: int _EXFUN(mblen,(const char *, size_t)); 88: int _EXFUN(_mblen_r,(struct _reent *, const char *, size_t, _mbstate_t *)); 89: int _EXFUN(mbtowc,(wchar_t *, const char *, size_t)); 90: int _EXFUN(_mbtowc_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *)); 91: int _EXFUN(wctomb,(char *, wchar_t)); 92: int _EXFUN(_wctomb_r,(struct _reent *, char *, wchar_t, _mbstate_t *)); 93: size_t _EXFUN(mbstowcs,(wchar_t *, const char *, size_t)); 94: size_t _EXFUN(_mbstowcs_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *)); 95: size_t _EXFUN(wcstombs,(char *, const wchar_t *, size_t)); 96: size_t _EXFUN(_wcstombs_r,(struct _reent *, char *, const wchar_t *, size_t, _mbstate_t *)); 97: #ifndef __STRICT_ANSI__ 98: #ifndef _REENT_ONLY 99: int _EXFUN(mkstemp,(char *)); 100: char * _EXFUN(mktemp,(char *)); 101: #endif 102: #endif 103: _VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, int(*_compar)(const _PTR, const _PTR))); 104: int _EXFUN(rand,(_VOID)); 105: _PTR _EXFUN(realloc,(_PTR __r, size_t __size)); 106: #ifdef __CYGWIN__ 107: void _EXFUN(setprogname,(const char *)); 108: #endif 109: _VOID _EXFUN(srand,(unsigned __seed)); 110: double _EXFUN(strtod,(const char *__n, char **__end_PTR)); 111: double _EXFUN(_strtod_r,(struct _reent *,const char *__n, char **__end_PTR)); 112: float _EXFUN(strtof,(const char *__n, char **__end_PTR)); 113: #ifndef __STRICT_ANSI__ 114: /* the following strtodf interface is deprecated...use strtof instead */ 115: # ifndef strtodf 116: # define strtodf strtof 117: # endif 118: #endif 119: long _EXFUN(strtol,(const char *__n, char **__end_PTR, int __base)); 120: long _EXFUN(_strtol_r,(struct _reent *,const char *__n, char **__end_PTR, int __base)); 121: unsigned long _EXFUN(strtoul,(const char *__n, char **__end_PTR, int __base)); 122: unsigned long _EXFUN(_strtoul_r,(struct _reent *,const char *__n, char **__end_PTR, int __base)); 123: 124: int _EXFUN(system,(const char *__string)); 125: 126: #ifndef __STRICT_ANSI__ 127: long _EXFUN(a64l,(const char *__input)); 128: char * _EXFUN(l64a,(long __input)); 129: char * _EXFUN(_l64a_r,(struct _reent *,long __input)); 130: int _EXFUN(on_exit,(_VOID (*__func)(int, _PTR),_PTR __arg)); 131: _VOID _EXFUN(_Exit,(int __status) _ATTRIBUTE ((noreturn))); 132: int _EXFUN(putenv,(const char *__string)); 133: int _EXFUN(_putenv_r,(struct _reent *, const char *__string)); 134: int _EXFUN(setenv,(const char *__string, const char *__value, int __overwrite)); 135: int _EXFUN(_setenv_r,(struct _reent *, const char *__string, const char *__value, int __overwrite)); 136: 137: char * _EXFUN(gcvt,(double,int,char *)); 138: char * _EXFUN(gcvtf,(float,int,char *)); 139: char * _EXFUN(fcvt,(double,int,int *,int *)); 140: char * _EXFUN(fcvtf,(float,int,int *,int *)); 141: char * _EXFUN(ecvt,(double,int,int *,int *)); 142: char * _EXFUN(ecvtbuf,(double, int, int*, int*, char *)); 143: char * _EXFUN(fcvtbuf,(double, int, int*, int*, char *)); 144: char * _EXFUN(ecvtf,(float,int,int *,int *)); 145: char * _EXFUN(dtoa,(double, int, int, int *, int*, char**)); 146: int _EXFUN(rand_r,(unsigned *__seed)); 147: 148: double _EXFUN(drand48,(_VOID)); 149: double _EXFUN(_drand48_r,(struct _reent *)); 150: double _EXFUN(erand48,(unsigned short [3])); 151: double _EXFUN(_erand48_r,(struct _reent *, unsigned short [3])); 152: long _EXFUN(jrand48,(unsigned short [3])); 153: long _EXFUN(_jrand48_r,(struct _reent *, unsigned short [3])); 154: _VOID _EXFUN(lcong48,(unsigned short [7])); 155: _VOID _EXFUN(_lcong48_r,(struct _reent *, unsigned short [7])); 156: long _EXFUN(lrand48,(_VOID)); 157: long _EXFUN(_lrand48_r,(struct _reent *)); 158: long _EXFUN(mrand48,(_VOID)); 159: long _EXFUN(_mrand48_r,(struct _reent *)); 160: long _EXFUN(nrand48,(unsigned short [3])); 161: long _EXFUN(_nrand48_r,(struct _reent *, unsigned short [3])); 162: unsigned short * 163: _EXFUN(seed48,(unsigned short [3])); 164: unsigned short * 165: _EXFUN(_seed48_r,(struct _reent *, unsigned short [3])); 166: _VOID _EXFUN(srand48,(long)); 167: _VOID _EXFUN(_srand48_r,(struct _reent *, long)); 168: long long _EXFUN(atoll,(const char *__nptr)); 169: long long _EXFUN(_atoll_r,(struct _reent *, const char *__nptr)); 170: long long _EXFUN(llabs,(long long)); 171: lldiv_t _EXFUN(lldiv,(long long __numer, long long __denom)); 172: long long _EXFUN(strtoll,(const char *__n, char **__end_PTR, int __base)); 173: long long _EXFUN(_strtoll_r,(struct _reent *, const char *__n, char **__end_PTR, int __base)); 174: unsigned long long _EXFUN(strtoull,(const char *__n, char **__end_PTR, int __base)); 175: unsigned long long _EXFUN(_strtoull_r,(struct _reent *, const char *__n, char **__end_PTR, int __base)); 176: 177: #ifndef __CYGWIN__ 178: _VOID _EXFUN(cfree,(_PTR)); 179: #else 180: char * _EXFUN(realpath,(const char *, char *)); 181: void _EXFUN(unsetenv,(const char *__string)); 182: void _EXFUN(_unsetenv_r,(struct _reent *, const char *__string)); 183: int _EXFUN(random,(_VOID)); 184: long _EXFUN(srandom,(unsigned __seed)); 185: char * _EXFUN(ptsname, (int)); 186: int _EXFUN(grantpt, (int)); 187: int _EXFUN(unlockpt,(int)); 188: #endif 189: 190: #endif /* ! __STRICT_ANSI__ */ 191: 192: char * _EXFUN(_dtoa_r,(struct _reent *, double, int, int, int *, int*, char**)); 193: #ifndef __CYGWIN__ 194: _PTR _EXFUN(_malloc_r,(struct _reent *, size_t)); 195: _PTR _EXFUN(_calloc_r,(struct _reent *, size_t, size_t)); 196: _VOID _EXFUN(_free_r,(struct _reent *, _PTR)); 197: _PTR _EXFUN(_realloc_r,(struct _reent *, _PTR, size_t)); 198: _VOID _EXFUN(_mstats_r,(struct _reent *, char *)); 199: #endif 200: int _EXFUN(_system_r,(struct _reent *, const char *)); 201: 202: _VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *)); 203: 204: #ifdef __CYGWIN__ 205: #undef _malloc_r 206: #define _malloc_r(r, s) malloc (s) 207: #undef _free_r 208: #define _free_r(r, p) free (p) 209: #undef _realloc_r 210: #define _realloc_r(r, p, s) realloc (p, s) 211: #undef _calloc_r 212: #define _calloc_r(r, s1, s2) calloc (s1, s2); 213: #undef _memalign_r 214: #define _memalign_r(r, s1, s2) memalign (s1, s2); 215: #undef _mallinfo_r 216: #define _mallinfo_r(r) mallinfo () 217: #undef _malloc_stats_r 218: #define _malloc_stats_r(r) malloc_stats () 219: #undef _mallopt_r 220: #define _mallopt_r(i1, i2) mallopt (i1, i2) 221: #undef _malloc_usable_size_r 222: #define _malloc_usable_size_r(r, p) malloc_usable_size (p) 223: #undef _valloc_r 224: #define _valloc_r(r, s) valloc (s) 225: #undef _pvalloc_r 226: #define _pvalloc_r(r, s) pvalloc (s) 227: #undef _malloc_trim_r 228: #define _malloc_trim_r(r, s) malloc_trim (s) 229: #undef _mstats_r 230: #define _mstats_r(r, p) mstats (p) 231: #endif 232: 233: _END_STD_C 234: 235: #endif /* _STDLIB_H_ */ 236: