Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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