xref: /aosp_15_r20/external/libcxx/include/cstdlib (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===--------------------------- cstdlib ----------------------------------===//
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#ifndef _LIBCPP_CSTDLIB
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_CSTDLIB
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker/*
15*58b9f456SAndroid Build Coastguard Worker    cstdlib synopsis
16*58b9f456SAndroid Build Coastguard Worker
17*58b9f456SAndroid Build Coastguard WorkerMacros:
18*58b9f456SAndroid Build Coastguard Worker
19*58b9f456SAndroid Build Coastguard Worker    EXIT_FAILURE
20*58b9f456SAndroid Build Coastguard Worker    EXIT_SUCCESS
21*58b9f456SAndroid Build Coastguard Worker    MB_CUR_MAX
22*58b9f456SAndroid Build Coastguard Worker    NULL
23*58b9f456SAndroid Build Coastguard Worker    RAND_MAX
24*58b9f456SAndroid Build Coastguard Worker
25*58b9f456SAndroid Build Coastguard Workernamespace std
26*58b9f456SAndroid Build Coastguard Worker{
27*58b9f456SAndroid Build Coastguard Worker
28*58b9f456SAndroid Build Coastguard WorkerTypes:
29*58b9f456SAndroid Build Coastguard Worker
30*58b9f456SAndroid Build Coastguard Worker    size_t
31*58b9f456SAndroid Build Coastguard Worker    div_t
32*58b9f456SAndroid Build Coastguard Worker    ldiv_t
33*58b9f456SAndroid Build Coastguard Worker    lldiv_t                                                               // C99
34*58b9f456SAndroid Build Coastguard Worker
35*58b9f456SAndroid Build Coastguard Workerdouble    atof (const char* nptr);
36*58b9f456SAndroid Build Coastguard Workerint       atoi (const char* nptr);
37*58b9f456SAndroid Build Coastguard Workerlong      atol (const char* nptr);
38*58b9f456SAndroid Build Coastguard Workerlong long atoll(const char* nptr);                                        // C99
39*58b9f456SAndroid Build Coastguard Workerdouble             strtod  (const char* restrict nptr, char** restrict endptr);
40*58b9f456SAndroid Build Coastguard Workerfloat              strtof  (const char* restrict nptr, char** restrict endptr); // C99
41*58b9f456SAndroid Build Coastguard Workerlong double        strtold (const char* restrict nptr, char** restrict endptr); // C99
42*58b9f456SAndroid Build Coastguard Workerlong               strtol  (const char* restrict nptr, char** restrict endptr, int base);
43*58b9f456SAndroid Build Coastguard Workerlong long          strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
44*58b9f456SAndroid Build Coastguard Workerunsigned long      strtoul (const char* restrict nptr, char** restrict endptr, int base);
45*58b9f456SAndroid Build Coastguard Workerunsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
46*58b9f456SAndroid Build Coastguard Workerint rand(void);
47*58b9f456SAndroid Build Coastguard Workervoid srand(unsigned int seed);
48*58b9f456SAndroid Build Coastguard Workervoid* calloc(size_t nmemb, size_t size);
49*58b9f456SAndroid Build Coastguard Workervoid free(void* ptr);
50*58b9f456SAndroid Build Coastguard Workervoid* malloc(size_t size);
51*58b9f456SAndroid Build Coastguard Workervoid* realloc(void* ptr, size_t size);
52*58b9f456SAndroid Build Coastguard Workervoid abort(void);
53*58b9f456SAndroid Build Coastguard Workerint atexit(void (*func)(void));
54*58b9f456SAndroid Build Coastguard Workervoid exit(int status);
55*58b9f456SAndroid Build Coastguard Workervoid _Exit(int status);
56*58b9f456SAndroid Build Coastguard Workerchar* getenv(const char* name);
57*58b9f456SAndroid Build Coastguard Workerint system(const char* string);
58*58b9f456SAndroid Build Coastguard Workervoid* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
59*58b9f456SAndroid Build Coastguard Worker              int (*compar)(const void *, const void *));
60*58b9f456SAndroid Build Coastguard Workervoid qsort(void* base, size_t nmemb, size_t size,
61*58b9f456SAndroid Build Coastguard Worker           int (*compar)(const void *, const void *));
62*58b9f456SAndroid Build Coastguard Workerint         abs(      int j);
63*58b9f456SAndroid Build Coastguard Workerlong        abs(     long j);
64*58b9f456SAndroid Build Coastguard Workerlong long   abs(long long j);                                             // C++0X
65*58b9f456SAndroid Build Coastguard Workerlong       labs(     long j);
66*58b9f456SAndroid Build Coastguard Workerlong long llabs(long long j);                                             // C99
67*58b9f456SAndroid Build Coastguard Workerdiv_t     div(      int numer,       int denom);
68*58b9f456SAndroid Build Coastguard Workerldiv_t    div(     long numer,      long denom);
69*58b9f456SAndroid Build Coastguard Workerlldiv_t   div(long long numer, long long denom);                          // C++0X
70*58b9f456SAndroid Build Coastguard Workerldiv_t   ldiv(     long numer,      long denom);
71*58b9f456SAndroid Build Coastguard Workerlldiv_t lldiv(long long numer, long long denom);                          // C99
72*58b9f456SAndroid Build Coastguard Workerint mblen(const char* s, size_t n);
73*58b9f456SAndroid Build Coastguard Workerint mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
74*58b9f456SAndroid Build Coastguard Workerint wctomb(char* s, wchar_t wchar);
75*58b9f456SAndroid Build Coastguard Workersize_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
76*58b9f456SAndroid Build Coastguard Workersize_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
77*58b9f456SAndroid Build Coastguard Workerint at_quick_exit(void (*func)(void))                                     // C++11
78*58b9f456SAndroid Build Coastguard Workervoid quick_exit(int status);                                              // C++11
79*58b9f456SAndroid Build Coastguard Workervoid *aligned_alloc(size_t alignment, size_t size);                       // C11
80*58b9f456SAndroid Build Coastguard Worker
81*58b9f456SAndroid Build Coastguard Worker}  // std
82*58b9f456SAndroid Build Coastguard Worker
83*58b9f456SAndroid Build Coastguard Worker*/
84*58b9f456SAndroid Build Coastguard Worker
85*58b9f456SAndroid Build Coastguard Worker#include <__config>
86*58b9f456SAndroid Build Coastguard Worker#include <stdlib.h>
87*58b9f456SAndroid Build Coastguard Worker
88*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
89*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
90*58b9f456SAndroid Build Coastguard Worker#endif
91*58b9f456SAndroid Build Coastguard Worker
92*58b9f456SAndroid Build Coastguard Worker#ifdef __GNUC__
93*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_UNREACHABLE() __builtin_unreachable()
94*58b9f456SAndroid Build Coastguard Worker#else
95*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_UNREACHABLE() _VSTD::abort()
96*58b9f456SAndroid Build Coastguard Worker#endif
97*58b9f456SAndroid Build Coastguard Worker
98*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD
99*58b9f456SAndroid Build Coastguard Worker
100*58b9f456SAndroid Build Coastguard Workerusing ::size_t;
101*58b9f456SAndroid Build Coastguard Workerusing ::div_t;
102*58b9f456SAndroid Build Coastguard Workerusing ::ldiv_t;
103*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_LONG_LONG
104*58b9f456SAndroid Build Coastguard Workerusing ::lldiv_t;
105*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_HAS_NO_LONG_LONG
106*58b9f456SAndroid Build Coastguard Workerusing ::atof;
107*58b9f456SAndroid Build Coastguard Workerusing ::atoi;
108*58b9f456SAndroid Build Coastguard Workerusing ::atol;
109*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_LONG_LONG
110*58b9f456SAndroid Build Coastguard Workerusing ::atoll;
111*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_HAS_NO_LONG_LONG
112*58b9f456SAndroid Build Coastguard Workerusing ::strtod;
113*58b9f456SAndroid Build Coastguard Workerusing ::strtof;
114*58b9f456SAndroid Build Coastguard Workerusing ::strtold;
115*58b9f456SAndroid Build Coastguard Workerusing ::strtol;
116*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_LONG_LONG
117*58b9f456SAndroid Build Coastguard Workerusing ::strtoll;
118*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_HAS_NO_LONG_LONG
119*58b9f456SAndroid Build Coastguard Workerusing ::strtoul;
120*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_LONG_LONG
121*58b9f456SAndroid Build Coastguard Workerusing ::strtoull;
122*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_HAS_NO_LONG_LONG
123*58b9f456SAndroid Build Coastguard Workerusing ::rand;
124*58b9f456SAndroid Build Coastguard Workerusing ::srand;
125*58b9f456SAndroid Build Coastguard Workerusing ::calloc;
126*58b9f456SAndroid Build Coastguard Workerusing ::free;
127*58b9f456SAndroid Build Coastguard Workerusing ::malloc;
128*58b9f456SAndroid Build Coastguard Workerusing ::realloc;
129*58b9f456SAndroid Build Coastguard Workerusing ::abort;
130*58b9f456SAndroid Build Coastguard Workerusing ::atexit;
131*58b9f456SAndroid Build Coastguard Workerusing ::exit;
132*58b9f456SAndroid Build Coastguard Workerusing ::_Exit;
133*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_WINDOWS_STORE_APP
134*58b9f456SAndroid Build Coastguard Workerusing ::getenv;
135*58b9f456SAndroid Build Coastguard Workerusing ::system;
136*58b9f456SAndroid Build Coastguard Worker#endif
137*58b9f456SAndroid Build Coastguard Workerusing ::bsearch;
138*58b9f456SAndroid Build Coastguard Workerusing ::qsort;
139*58b9f456SAndroid Build Coastguard Workerusing ::abs;
140*58b9f456SAndroid Build Coastguard Workerusing ::labs;
141*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_LONG_LONG
142*58b9f456SAndroid Build Coastguard Workerusing ::llabs;
143*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_HAS_NO_LONG_LONG
144*58b9f456SAndroid Build Coastguard Workerusing ::div;
145*58b9f456SAndroid Build Coastguard Workerusing ::ldiv;
146*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_LONG_LONG
147*58b9f456SAndroid Build Coastguard Workerusing ::lldiv;
148*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_HAS_NO_LONG_LONG
149*58b9f456SAndroid Build Coastguard Workerusing ::mblen;
150*58b9f456SAndroid Build Coastguard Workerusing ::mbtowc;
151*58b9f456SAndroid Build Coastguard Workerusing ::wctomb;
152*58b9f456SAndroid Build Coastguard Workerusing ::mbstowcs;
153*58b9f456SAndroid Build Coastguard Workerusing ::wcstombs;
154*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
155*58b9f456SAndroid Build Coastguard Workerusing ::at_quick_exit;
156*58b9f456SAndroid Build Coastguard Workerusing ::quick_exit;
157*58b9f456SAndroid Build Coastguard Worker#endif
158*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
159*58b9f456SAndroid Build Coastguard Workerusing ::aligned_alloc;
160*58b9f456SAndroid Build Coastguard Worker#endif
161*58b9f456SAndroid Build Coastguard Worker
162*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD
163*58b9f456SAndroid Build Coastguard Worker
164*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CSTDLIB
165