1*9729cf09SDimitry Andric // -*- C++ -*-
2*9729cf09SDimitry Andric //===--------------------------- stdlib.h ---------------------------------===//
3*9729cf09SDimitry Andric //
4*9729cf09SDimitry Andric // The LLVM Compiler Infrastructure
5*9729cf09SDimitry Andric //
6*9729cf09SDimitry Andric // This file is dual licensed under the MIT and the University of Illinois Open
7*9729cf09SDimitry Andric // Source Licenses. See LICENSE.TXT for details.
8*9729cf09SDimitry Andric //
9*9729cf09SDimitry Andric //===----------------------------------------------------------------------===//
10*9729cf09SDimitry Andric
11*9729cf09SDimitry Andric #if defined(__need_malloc_and_calloc)
12*9729cf09SDimitry Andric
13*9729cf09SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
14*9729cf09SDimitry Andric #pragma GCC system_header
15*9729cf09SDimitry Andric #endif
16*9729cf09SDimitry Andric
17*9729cf09SDimitry Andric #include_next <stdlib.h>
18*9729cf09SDimitry Andric
19*9729cf09SDimitry Andric #elif !defined(_LIBCPP_STDLIB_H)
20*9729cf09SDimitry Andric #define _LIBCPP_STDLIB_H
21*9729cf09SDimitry Andric
22*9729cf09SDimitry Andric /*
23*9729cf09SDimitry Andric stdlib.h synopsis
24*9729cf09SDimitry Andric
25*9729cf09SDimitry Andric Macros:
26*9729cf09SDimitry Andric
27*9729cf09SDimitry Andric EXIT_FAILURE
28*9729cf09SDimitry Andric EXIT_SUCCESS
29*9729cf09SDimitry Andric MB_CUR_MAX
30*9729cf09SDimitry Andric NULL
31*9729cf09SDimitry Andric RAND_MAX
32*9729cf09SDimitry Andric
33*9729cf09SDimitry Andric Types:
34*9729cf09SDimitry Andric
35*9729cf09SDimitry Andric size_t
36*9729cf09SDimitry Andric div_t
37*9729cf09SDimitry Andric ldiv_t
38*9729cf09SDimitry Andric lldiv_t // C99
39*9729cf09SDimitry Andric
40*9729cf09SDimitry Andric double atof (const char* nptr);
41*9729cf09SDimitry Andric int atoi (const char* nptr);
42*9729cf09SDimitry Andric long atol (const char* nptr);
43*9729cf09SDimitry Andric long long atoll(const char* nptr); // C99
44*9729cf09SDimitry Andric double strtod (const char* restrict nptr, char** restrict endptr);
45*9729cf09SDimitry Andric float strtof (const char* restrict nptr, char** restrict endptr); // C99
46*9729cf09SDimitry Andric long double strtold (const char* restrict nptr, char** restrict endptr); // C99
47*9729cf09SDimitry Andric long strtol (const char* restrict nptr, char** restrict endptr, int base);
48*9729cf09SDimitry Andric long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
49*9729cf09SDimitry Andric unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base);
50*9729cf09SDimitry Andric unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
51*9729cf09SDimitry Andric int rand(void);
52*9729cf09SDimitry Andric void srand(unsigned int seed);
53*9729cf09SDimitry Andric void* calloc(size_t nmemb, size_t size);
54*9729cf09SDimitry Andric void free(void* ptr);
55*9729cf09SDimitry Andric void* malloc(size_t size);
56*9729cf09SDimitry Andric void* realloc(void* ptr, size_t size);
57*9729cf09SDimitry Andric void abort(void);
58*9729cf09SDimitry Andric int atexit(void (*func)(void));
59*9729cf09SDimitry Andric void exit(int status);
60*9729cf09SDimitry Andric void _Exit(int status);
61*9729cf09SDimitry Andric char* getenv(const char* name);
62*9729cf09SDimitry Andric int system(const char* string);
63*9729cf09SDimitry Andric void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
64*9729cf09SDimitry Andric int (*compar)(const void *, const void *));
65*9729cf09SDimitry Andric void qsort(void* base, size_t nmemb, size_t size,
66*9729cf09SDimitry Andric int (*compar)(const void *, const void *));
67*9729cf09SDimitry Andric int abs( int j);
68*9729cf09SDimitry Andric long abs( long j);
69*9729cf09SDimitry Andric long long abs(long long j); // C++0X
70*9729cf09SDimitry Andric long labs( long j);
71*9729cf09SDimitry Andric long long llabs(long long j); // C99
72*9729cf09SDimitry Andric div_t div( int numer, int denom);
73*9729cf09SDimitry Andric ldiv_t div( long numer, long denom);
74*9729cf09SDimitry Andric lldiv_t div(long long numer, long long denom); // C++0X
75*9729cf09SDimitry Andric ldiv_t ldiv( long numer, long denom);
76*9729cf09SDimitry Andric lldiv_t lldiv(long long numer, long long denom); // C99
77*9729cf09SDimitry Andric int mblen(const char* s, size_t n);
78*9729cf09SDimitry Andric int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
79*9729cf09SDimitry Andric int wctomb(char* s, wchar_t wchar);
80*9729cf09SDimitry Andric size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
81*9729cf09SDimitry Andric size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
82*9729cf09SDimitry Andric int at_quick_exit(void (*func)(void)) // C++11
83*9729cf09SDimitry Andric void quick_exit(int status); // C++11
84*9729cf09SDimitry Andric void *aligned_alloc(size_t alignment, size_t size); // C11
85*9729cf09SDimitry Andric
86*9729cf09SDimitry Andric */
87*9729cf09SDimitry Andric
88*9729cf09SDimitry Andric #include <__config>
89*9729cf09SDimitry Andric
90*9729cf09SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
91*9729cf09SDimitry Andric #pragma GCC system_header
92*9729cf09SDimitry Andric #endif
93*9729cf09SDimitry Andric
94*9729cf09SDimitry Andric #include_next <stdlib.h>
95*9729cf09SDimitry Andric
96*9729cf09SDimitry Andric #ifdef __cplusplus
97*9729cf09SDimitry Andric
98*9729cf09SDimitry Andric extern "C++" {
99*9729cf09SDimitry Andric
100*9729cf09SDimitry Andric #undef abs
101*9729cf09SDimitry Andric #undef div
102*9729cf09SDimitry Andric #undef labs
103*9729cf09SDimitry Andric #undef ldiv
104*9729cf09SDimitry Andric #ifndef _LIBCPP_HAS_NO_LONG_LONG
105*9729cf09SDimitry Andric #undef llabs
106*9729cf09SDimitry Andric #undef lldiv
107*9729cf09SDimitry Andric #endif
108*9729cf09SDimitry Andric
109*9729cf09SDimitry Andric // MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
110*9729cf09SDimitry Andric #if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
abs(long __x)111*9729cf09SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);}
112*9729cf09SDimitry Andric #ifndef _LIBCPP_HAS_NO_LONG_LONG
abs(long long __x)113*9729cf09SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
114*9729cf09SDimitry Andric #endif // _LIBCPP_HAS_NO_LONG_LONG
115*9729cf09SDimitry Andric
div(long __x,long __y)116*9729cf09SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) _NOEXCEPT {return ldiv(__x, __y);}
117*9729cf09SDimitry Andric #ifndef _LIBCPP_HAS_NO_LONG_LONG
div(long long __x,long long __y)118*9729cf09SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
119*9729cf09SDimitry Andric #endif // _LIBCPP_HAS_NO_LONG_LONG
120*9729cf09SDimitry Andric #endif // _LIBCPP_MSVCRT / __sun__ / _AIX
121*9729cf09SDimitry Andric
122*9729cf09SDimitry Andric } // extern "C++"
123*9729cf09SDimitry Andric
124*9729cf09SDimitry Andric #endif // __cplusplus
125*9729cf09SDimitry Andric
126*9729cf09SDimitry Andric #endif // _LIBCPP_STDLIB_H
127