Subversion Repositories Kolibri OS

Rev

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

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