stdlib.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. #ifndef _STDLIB_H
  2. #define _STDLIB_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #if __STDC_VERSION__ >= 199901L
  7. #define __restrict restrict
  8. #elif !defined(__GNUC__)
  9. #define __restrict
  10. #endif
  11. #if __STDC_VERSION__ >= 201112L
  12. #elif defined(__GNUC__)
  13. #define _Noreturn __attribute__((__noreturn__))
  14. #else
  15. #define _Noreturn
  16. #endif
  17. #undef NULL
  18. #ifdef __cplusplus
  19. #define NULL 0
  20. #else
  21. #define NULL ((void*)0)
  22. #endif
  23. #define __NEED_size_t
  24. #define __NEED_wchar_t
  25. #include <bits/alltypes.h>
  26. int atoi (const char *);
  27. long atol (const char *);
  28. long long atoll (const char *);
  29. double atof (const char *);
  30. float strtof (const char *__restrict, char **__restrict);
  31. double strtod (const char *__restrict, char **__restrict);
  32. long double strtold (const char *__restrict, char **__restrict);
  33. long strtol (const char *__restrict, char **__restrict, int);
  34. unsigned long strtoul (const char *__restrict, char **__restrict, int);
  35. long long strtoll (const char *__restrict, char **__restrict, int);
  36. unsigned long long strtoull (const char *__restrict, char **__restrict, int);
  37. int rand (void);
  38. void srand (unsigned);
  39. void *malloc (size_t);
  40. void *calloc (size_t, size_t);
  41. void *realloc (void *, size_t);
  42. void free (void *);
  43. void *aligned_alloc(size_t alignment, size_t size);
  44. _Noreturn void abort (void);
  45. int atexit (void (*) (void));
  46. _Noreturn void exit (int);
  47. _Noreturn void _Exit (int);
  48. int at_quick_exit (void (*) (void));
  49. _Noreturn void quick_exit (int);
  50. char *getenv (const char *);
  51. int system (const char *);
  52. void *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
  53. void qsort (void *, size_t, size_t, int (*)(const void *, const void *));
  54. int abs (int);
  55. long labs (long);
  56. long long llabs (long long);
  57. typedef struct { int quot, rem; } div_t;
  58. typedef struct { long quot, rem; } ldiv_t;
  59. typedef struct { long long quot, rem; } lldiv_t;
  60. div_t div (int, int);
  61. ldiv_t ldiv (long, long);
  62. lldiv_t lldiv (long long, long long);
  63. int mblen (const char *, size_t);
  64. int mbtowc (wchar_t *__restrict, const char *__restrict, size_t);
  65. int wctomb (char *, wchar_t);
  66. size_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t);
  67. size_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t);
  68. #define EXIT_FAILURE 1
  69. #define EXIT_SUCCESS 0
  70. #define MB_CUR_MAX ((size_t)+4)
  71. #define RAND_MAX (0x7fffffff)
  72. #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  73. || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  74. || defined(_BSD_SOURCE)
  75. #ifndef WEXITSTATUS
  76. #define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
  77. #define WTERMSIG(s) ((s) & 0x7f)
  78. #define WSTOPSIG(s) WEXITSTATUS(s)
  79. #define WCOREDUMP(s) ((s) & 0x80)
  80. #define WIFEXITED(s) (!WTERMSIG(s))
  81. #define WIFSTOPPED(s) (((s) & 0xff) == 0x7f)
  82. #define WIFSIGNALED(s) (((signed char) (((s) & 0x7f) + 1) >> 1) > 0)
  83. #define WIFCONTINUED(s) ((s) == 0xffff)
  84. #endif
  85. int posix_memalign (void **, size_t, size_t);
  86. int setenv (const char *, const char *, int);
  87. int unsetenv (const char *);
  88. int mkstemp (char *);
  89. char *mkdtemp (char *);
  90. int getsubopt (char **, char *const *, char **);
  91. int rand_r (unsigned *);
  92. #endif
  93. #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  94. || defined(_BSD_SOURCE)
  95. char *realpath (const char *__restrict, char *__restrict);
  96. long int random (void);
  97. void srandom (unsigned int);
  98. char *initstate (unsigned int, char *, size_t);
  99. char *setstate (char *);
  100. #endif
  101. #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
  102. int putenv (char *);
  103. int posix_openpt (int);
  104. int grantpt (int);
  105. int unlockpt (int);
  106. char *ptsname (int);
  107. char *l64a (long);
  108. long a64l (const char *);
  109. void setkey (const char *);
  110. double drand48 (void);
  111. double erand48 (unsigned short [3]);
  112. long int lrand48 (void);
  113. long int nrand48 (unsigned short [3]);
  114. long mrand48 (void);
  115. long jrand48 (unsigned short [3]);
  116. void srand48 (long);
  117. unsigned short *seed48 (unsigned short [3]);
  118. void lcong48 (unsigned short [7]);
  119. #endif
  120. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  121. #include <alloca.h>
  122. char *mktemp (char *);
  123. void *valloc (size_t);
  124. void *memalign(size_t, size_t);
  125. #endif
  126. #ifdef _GNU_SOURCE
  127. int clearenv(void);
  128. int ptsname_r(int, char *, size_t);
  129. char *ecvt(double, int, int *, int *);
  130. char *fcvt(double, int, int *, int *);
  131. char *gcvt(double, int, char *);
  132. #endif
  133. #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
  134. #define mkstemp64 mkstemp
  135. #endif
  136. #ifdef __cplusplus
  137. }
  138. #endif
  139. #endif