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