cstdlib revision 288943
1227825Stheraven// -*- C++ -*-
2227825Stheraven//===--------------------------- cstdlib ----------------------------------===//
3227825Stheraven//
4227825Stheraven//                     The LLVM Compiler Infrastructure
5227825Stheraven//
6227825Stheraven// This file is dual licensed under the MIT and the University of Illinois Open
7227825Stheraven// Source Licenses. See LICENSE.TXT for details.
8227825Stheraven//
9227825Stheraven//===----------------------------------------------------------------------===//
10227825Stheraven
11227825Stheraven#ifndef _LIBCPP_CSTDLIB
12227825Stheraven#define _LIBCPP_CSTDLIB
13227825Stheraven
14227825Stheraven/*
15227825Stheraven    cstdlib synopsis
16227825Stheraven
17227825StheravenMacros:
18227825Stheraven
19227825Stheraven    EXIT_FAILURE
20227825Stheraven    EXIT_SUCCESS
21227825Stheraven    MB_CUR_MAX
22227825Stheraven    NULL
23227825Stheraven    RAND_MAX
24227825Stheraven
25227825Stheravennamespace std
26227825Stheraven{
27227825Stheraven
28227825StheravenTypes:
29241900Sdim
30227825Stheraven    size_t
31227825Stheraven    div_t
32227825Stheraven    ldiv_t
33227825Stheraven    lldiv_t                                                               // C99
34241900Sdim
35227825Stheravendouble    atof (const char* nptr);
36227825Stheravenint       atoi (const char* nptr);
37241900Sdimlong      atol (const char* nptr);
38227825Stheravenlong long atoll(const char* nptr);                                        // C99
39241900Sdimdouble             strtod  (const char* restrict nptr, char** restrict endptr);
40227825Stheravenfloat              strtof  (const char* restrict nptr, char** restrict endptr); // C99
41241900Sdimlong double        strtold (const char* restrict nptr, char** restrict endptr); // C99
42227825Stheravenlong               strtol  (const char* restrict nptr, char** restrict endptr, int base);
43227825Stheravenlong long          strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
44241900Sdimunsigned long      strtoul (const char* restrict nptr, char** restrict endptr, int base);
45227825Stheravenunsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
46227825Stheravenint rand(void);
47241900Sdimvoid srand(unsigned int seed);
48227825Stheravenvoid* calloc(size_t nmemb, size_t size);
49227825Stheravenvoid free(void* ptr);
50241900Sdimvoid* malloc(size_t size);
51227825Stheravenvoid* realloc(void* ptr, size_t size);
52227825Stheravenvoid abort(void);
53227825Stheravenint atexit(void (*func)(void));
54227825Stheravenvoid exit(int status);
55241900Sdimvoid _Exit(int status);
56227825Stheravenchar* getenv(const char* name);
57227825Stheravenint system(const char* string);
58241900Sdimvoid* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
59241900Sdim              int (*compar)(const void *, const void *));
60241900Sdimvoid qsort(void* base, size_t nmemb, size_t size,
61241900Sdim           int (*compar)(const void *, const void *));
62241900Sdimint         abs(      int j);
63241900Sdimlong        abs(     long j);
64227825Stheravenlong long   abs(long long j);                                             // C++0X
65227825Stheravenlong       labs(     long j);
66227825Stheravenlong long llabs(long long j);                                             // C99
67227825Stheravendiv_t     div(      int numer,       int denom);
68227825Stheravenldiv_t    div(     long numer,      long denom);
69227825Stheravenlldiv_t   div(long long numer, long long denom);                          // C++0X
70227825Stheravenldiv_t   ldiv(     long numer,      long denom);
71227825Stheravenlldiv_t lldiv(long long numer, long long denom);                          // C99
72241900Sdimint mblen(const char* s, size_t n);
73227825Stheravenint mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
74241900Sdimint wctomb(char* s, wchar_t wchar);
75227825Stheravensize_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
76227825Stheravensize_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
77227825Stheravenint at_quick_exit(void (*func)(void))                                     // C++11
78227825Stheravenvoid quick_exit(int status);                                              // C++11
79227825Stheravenvoid *aligned_alloc(size_t alignment, size_t size);                       // C11
80227825Stheraven
81227825Stheraven}  // std
82227825Stheraven
83227825Stheraven*/
84227825Stheraven
85227825Stheraven#include <__config>
86227825Stheraven#include <stdlib.h>
87227825Stheraven#ifdef _LIBCPP_MSVCRT
88227825Stheraven#include "support/win32/locale_win32.h"
89227825Stheraven#endif // _LIBCPP_MSVCRT
90227825Stheraven
91227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
92227825Stheraven#pragma GCC system_header
93227825Stheraven#endif
94227825Stheraven
95227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD
96227825Stheraven
97227825Stheravenusing ::size_t;
98227825Stheravenusing ::div_t;
99227825Stheravenusing ::ldiv_t;
100227825Stheraven#ifndef _LIBCPP_HAS_NO_LONG_LONG
101227825Stheravenusing ::lldiv_t;
102227825Stheraven#endif // _LIBCPP_HAS_NO_LONG_LONG
103227825Stheravenusing ::atof;
104227825Stheravenusing ::atoi;
105227825Stheravenusing ::atol;
106227825Stheraven#ifndef _LIBCPP_HAS_NO_LONG_LONG
107227825Stheravenusing ::atoll;
108227825Stheraven#endif // _LIBCPP_HAS_NO_LONG_LONG
109227825Stheravenusing ::strtod;
110227825Stheravenusing ::strtof;
111227825Stheravenusing ::strtold;
112227825Stheravenusing ::strtol;
113227825Stheraven#ifndef _LIBCPP_HAS_NO_LONG_LONG
114227825Stheravenusing ::strtoll;
115227825Stheraven#endif // _LIBCPP_HAS_NO_LONG_LONG
116227825Stheravenusing ::strtoul;
117227825Stheraven#ifndef _LIBCPP_HAS_NO_LONG_LONG
118227825Stheravenusing ::strtoull;
119227825Stheraven#endif // _LIBCPP_HAS_NO_LONG_LONG
120227825Stheravenusing ::rand;
121227825Stheravenusing ::srand;
122227825Stheravenusing ::calloc;
123227825Stheravenusing ::free;
124227825Stheravenusing ::malloc;
125227825Stheravenusing ::realloc;
126227825Stheravenusing ::abort;
127227825Stheravenusing ::atexit;
128227825Stheravenusing ::exit;
129227825Stheravenusing ::_Exit;
130227825Stheravenusing ::getenv;
131227825Stheravenusing ::system;
132227825Stheravenusing ::bsearch;
133227825Stheravenusing ::qsort;
134227825Stheraven#undef abs
135227825Stheravenusing ::abs;
136227825Stheraven#undef labs
137227825Stheravenusing ::labs;
138227825Stheraven#ifndef _LIBCPP_HAS_NO_LONG_LONG
139227825Stheraven#undef llabs
140227825Stheravenusing ::llabs;
141227825Stheraven#endif // _LIBCPP_HAS_NO_LONG_LONG
142227825Stheraven#undef div
143227825Stheravenusing ::div;
144227825Stheraven#undef ldiv
145227825Stheravenusing ::ldiv;
146227825Stheraven#ifndef _LIBCPP_HAS_NO_LONG_LONG
147227825Stheraven#undef lldiv
148227825Stheravenusing ::lldiv;
149227825Stheraven#endif // _LIBCPP_HAS_NO_LONG_LONG
150227825Stheraven#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
151227825Stheravenusing ::mblen;
152227825Stheravenusing ::mbtowc;
153227825Stheravenusing ::wctomb;
154227825Stheraven#endif
155227825Stheravenusing ::mbstowcs;
156227825Stheravenusing ::wcstombs;
157227825Stheraven#ifdef _LIBCPP_HAS_QUICK_EXIT
158227825Stheravenusing ::at_quick_exit;
159227825Stheravenusing ::quick_exit;
160227825Stheraven#endif
161227825Stheraven#ifdef _LIBCPP_HAS_C11_FEATURES
162227825Stheravenusing ::aligned_alloc;
163227825Stheraven#endif
164227825Stheraven
165227825Stheraven// MSVCRT already has the correct prototype in <stdlib.h> #ifdef __cplusplus
166227825Stheraven#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
167227825Stheraveninline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
168227825Stheraven#ifndef _LIBCPP_HAS_NO_LONG_LONG
169227825Stheraveninline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
170227825Stheraven#endif // _LIBCPP_HAS_NO_LONG_LONG
171227825Stheraven
172227825Stheraveninline _LIBCPP_INLINE_VISIBILITY  ldiv_t div(     long __x,      long __y) _NOEXCEPT {return  ldiv(__x, __y);}
173227825Stheraven#ifndef _LIBCPP_HAS_NO_LONG_LONG
174227825Stheraveninline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
175227825Stheraven#endif // _LIBCPP_HAS_NO_LONG_LONG
176241900Sdim#endif // _LIBCPP_MSVCRT
177241900Sdim
178227825Stheraven_LIBCPP_END_NAMESPACE_STD
179227825Stheraven
180227825Stheraven#endif  // _LIBCPP_CSTDLIB
181227825Stheraven