Home | History | Annotate | Download | only in v1
      1 // -*- C++ -*-
      2 //===--------------------------- cstdlib ----------------------------------===//
      3 //
      4 //                     The LLVM Compiler Infrastructure
      5 //
      6 // This file is dual licensed under the MIT and the University of Illinois Open
      7 // Source Licenses. See LICENSE.TXT for details.
      8 //
      9 //===----------------------------------------------------------------------===//
     10 
     11 #ifndef _LIBCPP_CSTDLIB
     12 #define _LIBCPP_CSTDLIB
     13 
     14 /*
     15     cstdlib synopsis
     16 
     17 Macros:
     18 
     19     EXIT_FAILURE
     20     EXIT_SUCCESS
     21     MB_CUR_MAX
     22     NULL
     23     RAND_MAX
     24 
     25 namespace std
     26 {
     27 
     28 Types:
     29 
     30     size_t
     31     div_t
     32     ldiv_t
     33     lldiv_t                                                               // C99
     34 
     35 double    atof (const char* nptr);
     36 int       atoi (const char* nptr);
     37 long      atol (const char* nptr);
     38 long long atoll(const char* nptr);                                        // C99
     39 double             strtod  (const char* restrict nptr, char** restrict endptr);
     40 float              strtof  (const char* restrict nptr, char** restrict endptr); // C99
     41 long double        strtold (const char* restrict nptr, char** restrict endptr); // C99
     42 long               strtol  (const char* restrict nptr, char** restrict endptr, int base);
     43 long long          strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
     44 unsigned long      strtoul (const char* restrict nptr, char** restrict endptr, int base);
     45 unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
     46 int rand(void);
     47 void srand(unsigned int seed);
     48 void* calloc(size_t nmemb, size_t size);
     49 void free(void* ptr);
     50 void* malloc(size_t size);
     51 void* realloc(void* ptr, size_t size);
     52 void abort(void);
     53 int atexit(void (*func)(void));
     54 void exit(int status);
     55 void _Exit(int status);
     56 char* getenv(const char* name);
     57 int system(const char* string);
     58 void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
     59               int (*compar)(const void *, const void *));
     60 void qsort(void* base, size_t nmemb, size_t size,
     61            int (*compar)(const void *, const void *));
     62 int         abs(      int j);
     63 long        abs(     long j);
     64 long long   abs(long long j);                                             // C++0X
     65 long       labs(     long j);
     66 long long llabs(long long j);                                             // C99
     67 div_t     div(      int numer,       int denom);
     68 ldiv_t    div(     long numer,      long denom);
     69 lldiv_t   div(long long numer, long long denom);                          // C++0X
     70 ldiv_t   ldiv(     long numer,      long denom);
     71 lldiv_t lldiv(long long numer, long long denom);                          // C99
     72 int mblen(const char* s, size_t n);
     73 int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
     74 int wctomb(char* s, wchar_t wchar);
     75 size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
     76 size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
     77 int at_quick_exit(void (*func)(void))                                     // C++11
     78 void quick_exit(int status);                                              // C++11
     79 void *aligned_alloc(size_t alignment, size_t size);                       // C11
     80 
     81 }  // std
     82 
     83 */
     84 
     85 #include <__config>
     86 #include <stdlib.h>
     87 
     88 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
     89 #pragma GCC system_header
     90 #endif
     91 
     92 #ifdef __GNUC__
     93 #define _LIBCPP_UNREACHABLE() __builtin_unreachable()
     94 #else
     95 #define _LIBCPP_UNREACHABLE() _VSTD::abort()
     96 #endif
     97 
     98 _LIBCPP_BEGIN_NAMESPACE_STD
     99 
    100 using ::size_t;
    101 using ::div_t;
    102 using ::ldiv_t;
    103 #ifndef _LIBCPP_HAS_NO_LONG_LONG
    104 using ::lldiv_t;
    105 #endif // _LIBCPP_HAS_NO_LONG_LONG
    106 using ::atof;
    107 using ::atoi;
    108 using ::atol;
    109 #ifndef _LIBCPP_HAS_NO_LONG_LONG
    110 using ::atoll;
    111 #endif // _LIBCPP_HAS_NO_LONG_LONG
    112 using ::strtod;
    113 using ::strtof;
    114 using ::strtold;
    115 using ::strtol;
    116 #ifndef _LIBCPP_HAS_NO_LONG_LONG
    117 using ::strtoll;
    118 #endif // _LIBCPP_HAS_NO_LONG_LONG
    119 using ::strtoul;
    120 #ifndef _LIBCPP_HAS_NO_LONG_LONG
    121 using ::strtoull;
    122 #endif // _LIBCPP_HAS_NO_LONG_LONG
    123 using ::rand;
    124 using ::srand;
    125 using ::calloc;
    126 using ::free;
    127 using ::malloc;
    128 using ::realloc;
    129 using ::abort;
    130 using ::atexit;
    131 using ::exit;
    132 using ::_Exit;
    133 #ifndef _LIBCPP_WINDOWS_STORE_APP
    134 using ::getenv;
    135 using ::system;
    136 #endif
    137 using ::bsearch;
    138 using ::qsort;
    139 using ::abs;
    140 using ::labs;
    141 #ifndef _LIBCPP_HAS_NO_LONG_LONG
    142 using ::llabs;
    143 #endif // _LIBCPP_HAS_NO_LONG_LONG
    144 using ::div;
    145 using ::ldiv;
    146 #ifndef _LIBCPP_HAS_NO_LONG_LONG
    147 using ::lldiv;
    148 #endif // _LIBCPP_HAS_NO_LONG_LONG
    149 using ::mblen;
    150 using ::mbtowc;
    151 using ::wctomb;
    152 using ::mbstowcs;
    153 using ::wcstombs;
    154 #ifdef _LIBCPP_HAS_QUICK_EXIT
    155 using ::at_quick_exit;
    156 using ::quick_exit;
    157 #endif
    158 #ifdef _LIBCPP_HAS_C11_FEATURES
    159 using ::aligned_alloc;
    160 #endif
    161 
    162 _LIBCPP_END_NAMESPACE_STD
    163 
    164 #endif  // _LIBCPP_CSTDLIB
    165