2 //===--------------------------- cstdlib ----------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_CSTDLIB
12 #define _LIBCPP_CSTDLIB
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
47 void srand(unsigned int seed);
48 void* calloc(size_t nmemb, size_t size);
50 void* malloc(size_t size);
51 void* realloc(void* ptr, size_t size);
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 *));
64 long long abs(long long j); // C++0X
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
88 #include "support/win32/locale_win32.h"
89 #endif // _LIBCPP_MSVCRT
91 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
92 #pragma GCC system_header
95 _LIBCPP_BEGIN_NAMESPACE_STD
100 #ifndef _LIBCPP_HAS_NO_LONG_LONG
102 #endif // _LIBCPP_HAS_NO_LONG_LONG
106 #ifndef _LIBCPP_HAS_NO_LONG_LONG
108 #endif // _LIBCPP_HAS_NO_LONG_LONG
113 #ifndef _LIBCPP_HAS_NO_LONG_LONG
115 #endif // _LIBCPP_HAS_NO_LONG_LONG
117 #ifndef _LIBCPP_HAS_NO_LONG_LONG
119 #endif // _LIBCPP_HAS_NO_LONG_LONG
138 #ifndef _LIBCPP_HAS_NO_LONG_LONG
141 #endif // _LIBCPP_HAS_NO_LONG_LONG
146 #ifndef _LIBCPP_HAS_NO_LONG_LONG
149 #endif // _LIBCPP_HAS_NO_LONG_LONG
150 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
157 #ifdef _LIBCPP_HAS_QUICK_EXIT
158 using ::at_quick_exit;
161 #ifdef _LIBCPP_HAS_C11_FEATURES
162 using ::aligned_alloc;
165 // MSVCRT already has the correct prototype in <stdlib.h> #ifdef __cplusplus
166 #if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
167 inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);}
168 #ifndef _LIBCPP_HAS_NO_LONG_LONG
169 inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
170 #endif // _LIBCPP_HAS_NO_LONG_LONG
172 inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) _NOEXCEPT {return ldiv(__x, __y);}
173 #ifndef _LIBCPP_HAS_NO_LONG_LONG
174 inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
175 #endif // _LIBCPP_HAS_NO_LONG_LONG
176 #endif // _LIBCPP_MSVCRT
178 _LIBCPP_END_NAMESPACE_STD
180 #endif // _LIBCPP_CSTDLIB