stdlib.h raw

   1  #ifndef _STDLIB_H
   2  #define _STDLIB_H
   3  
   4  #ifdef __cplusplus
   5  extern "C" {
   6  #endif
   7  
   8  #include <features.h>
   9  
  10  #if __cplusplus >= 201103L
  11  #define NULL nullptr
  12  #elif defined(__cplusplus)
  13  #define NULL 0L
  14  #else
  15  #define NULL ((void*)0)
  16  #endif
  17  
  18  #define __NEED_size_t
  19  #define __NEED_wchar_t
  20  
  21  #include <bits/alltypes.h>
  22  
  23  int atoi (const char *);
  24  long atol (const char *);
  25  long long atoll (const char *);
  26  double atof (const char *);
  27  
  28  float strtof (const char *__restrict, char **__restrict);
  29  double strtod (const char *__restrict, char **__restrict);
  30  long double strtold (const char *__restrict, char **__restrict);
  31  
  32  long strtol (const char *__restrict, char **__restrict, int);
  33  unsigned long strtoul (const char *__restrict, char **__restrict, int);
  34  long long strtoll (const char *__restrict, char **__restrict, int);
  35  unsigned long long strtoull (const char *__restrict, char **__restrict, int);
  36  
  37  int rand (void);
  38  void srand (unsigned);
  39  
  40  void *malloc (size_t);
  41  void *calloc (size_t, size_t);
  42  void *realloc (void *, size_t);
  43  void free (void *);
  44  void *aligned_alloc(size_t, size_t);
  45  
  46  _Noreturn void abort (void);
  47  int atexit (void (*) (void));
  48  _Noreturn void exit (int);
  49  _Noreturn void _Exit (int);
  50  int at_quick_exit (void (*) (void));
  51  _Noreturn void quick_exit (int);
  52  
  53  char *getenv (const char *);
  54  
  55  int system (const char *);
  56  
  57  void *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
  58  void qsort (void *, size_t, size_t, int (*)(const void *, const void *));
  59  
  60  int abs (int);
  61  long labs (long);
  62  long long llabs (long long);
  63  
  64  typedef struct { int quot, rem; } div_t;
  65  typedef struct { long quot, rem; } ldiv_t;
  66  typedef struct { long long quot, rem; } lldiv_t;
  67  
  68  div_t div (int, int);
  69  ldiv_t ldiv (long, long);
  70  lldiv_t lldiv (long long, long long);
  71  
  72  int mblen (const char *, size_t);
  73  int mbtowc (wchar_t *__restrict, const char *__restrict, size_t);
  74  int wctomb (char *, wchar_t);
  75  size_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t);
  76  size_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t);
  77  
  78  #define EXIT_FAILURE 1
  79  #define EXIT_SUCCESS 0
  80  
  81  size_t __ctype_get_mb_cur_max(void);
  82  #define MB_CUR_MAX (__ctype_get_mb_cur_max())
  83  
  84  #define RAND_MAX (0x7fffffff)
  85  
  86  
  87  #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  88   || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  89   || defined(_BSD_SOURCE)
  90  
  91  #define WNOHANG    1
  92  #define WUNTRACED  2
  93  
  94  #define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
  95  #define WTERMSIG(s) ((s) & 0x7f)
  96  #define WSTOPSIG(s) WEXITSTATUS(s)
  97  #define WIFEXITED(s) (!WTERMSIG(s))
  98  #define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00)
  99  #define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu)
 100  
 101  int posix_memalign (void **, size_t, size_t);
 102  int setenv (const char *, const char *, int);
 103  int unsetenv (const char *);
 104  int mkstemp (char *);
 105  int mkostemp (char *, int);
 106  char *mkdtemp (char *);
 107  int getsubopt (char **, char *const *, char **);
 108  int rand_r (unsigned *);
 109  
 110  #endif
 111  
 112  
 113  #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
 114   || defined(_BSD_SOURCE)
 115  char *realpath (const char *__restrict, char *__restrict);
 116  long int random (void);
 117  void srandom (unsigned int);
 118  char *initstate (unsigned int, char *, size_t);
 119  char *setstate (char *);
 120  int putenv (char *);
 121  int posix_openpt (int);
 122  int grantpt (int);
 123  int unlockpt (int);
 124  char *ptsname (int);
 125  char *l64a (long);
 126  long a64l (const char *);
 127  void setkey (const char *);
 128  double drand48 (void);
 129  double erand48 (unsigned short [3]);
 130  long int lrand48 (void);
 131  long int nrand48 (unsigned short [3]);
 132  long mrand48 (void);
 133  long jrand48 (unsigned short [3]);
 134  void srand48 (long);
 135  unsigned short *seed48 (unsigned short [3]);
 136  void lcong48 (unsigned short [7]);
 137  #endif
 138  
 139  #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
 140  #include <alloca.h>
 141  char *mktemp (char *);
 142  int mkstemps (char *, int);
 143  int mkostemps (char *, int, int);
 144  void *valloc (size_t);
 145  void *memalign(size_t, size_t);
 146  int getloadavg(double *, int);
 147  int clearenv(void);
 148  #define WCOREDUMP(s) ((s) & 0x80)
 149  #define WIFCONTINUED(s) ((s) == 0xffff)
 150  void *reallocarray (void *, size_t, size_t);
 151  void qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *);
 152  #endif
 153  
 154  #ifdef _GNU_SOURCE
 155  int ptsname_r(int, char *, size_t);
 156  char *ecvt(double, int, int *, int *);
 157  char *fcvt(double, int, int *, int *);
 158  char *gcvt(double, int, char *);
 159  char *secure_getenv(const char *);
 160  struct __locale_struct;
 161  float strtof_l(const char *__restrict, char **__restrict, struct __locale_struct *);
 162  double strtod_l(const char *__restrict, char **__restrict, struct __locale_struct *);
 163  long double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *);
 164  #endif
 165  
 166  #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
 167  #define mkstemp64 mkstemp
 168  #define mkostemp64 mkostemp
 169  #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
 170  #define mkstemps64 mkstemps
 171  #define mkostemps64 mkostemps
 172  #endif
 173  #endif
 174  
 175  #ifdef __cplusplus
 176  }
 177  #endif
 178  
 179  #endif
 180