xref: /freebsd/contrib/llvm-project/libcxx/include/cstdlib (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1*0b57cec5SDimitry Andric// -*- C++ -*-
2*0b57cec5SDimitry Andric//===--------------------------- cstdlib ----------------------------------===//
3*0b57cec5SDimitry Andric//
4*0b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5*0b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
6*0b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7*0b57cec5SDimitry Andric//
8*0b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9*0b57cec5SDimitry Andric
10*0b57cec5SDimitry Andric#ifndef _LIBCPP_CSTDLIB
11*0b57cec5SDimitry Andric#define _LIBCPP_CSTDLIB
12*0b57cec5SDimitry Andric
13*0b57cec5SDimitry Andric/*
14*0b57cec5SDimitry Andric    cstdlib synopsis
15*0b57cec5SDimitry Andric
16*0b57cec5SDimitry AndricMacros:
17*0b57cec5SDimitry Andric
18*0b57cec5SDimitry Andric    EXIT_FAILURE
19*0b57cec5SDimitry Andric    EXIT_SUCCESS
20*0b57cec5SDimitry Andric    MB_CUR_MAX
21*0b57cec5SDimitry Andric    NULL
22*0b57cec5SDimitry Andric    RAND_MAX
23*0b57cec5SDimitry Andric
24*0b57cec5SDimitry Andricnamespace std
25*0b57cec5SDimitry Andric{
26*0b57cec5SDimitry Andric
27*0b57cec5SDimitry AndricTypes:
28*0b57cec5SDimitry Andric
29*0b57cec5SDimitry Andric    size_t
30*0b57cec5SDimitry Andric    div_t
31*0b57cec5SDimitry Andric    ldiv_t
32*0b57cec5SDimitry Andric    lldiv_t                                                               // C99
33*0b57cec5SDimitry Andric
34*0b57cec5SDimitry Andricdouble    atof (const char* nptr);
35*0b57cec5SDimitry Andricint       atoi (const char* nptr);
36*0b57cec5SDimitry Andriclong      atol (const char* nptr);
37*0b57cec5SDimitry Andriclong long atoll(const char* nptr);                                        // C99
38*0b57cec5SDimitry Andricdouble             strtod  (const char* restrict nptr, char** restrict endptr);
39*0b57cec5SDimitry Andricfloat              strtof  (const char* restrict nptr, char** restrict endptr); // C99
40*0b57cec5SDimitry Andriclong double        strtold (const char* restrict nptr, char** restrict endptr); // C99
41*0b57cec5SDimitry Andriclong               strtol  (const char* restrict nptr, char** restrict endptr, int base);
42*0b57cec5SDimitry Andriclong long          strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
43*0b57cec5SDimitry Andricunsigned long      strtoul (const char* restrict nptr, char** restrict endptr, int base);
44*0b57cec5SDimitry Andricunsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
45*0b57cec5SDimitry Andricint rand(void);
46*0b57cec5SDimitry Andricvoid srand(unsigned int seed);
47*0b57cec5SDimitry Andricvoid* calloc(size_t nmemb, size_t size);
48*0b57cec5SDimitry Andricvoid free(void* ptr);
49*0b57cec5SDimitry Andricvoid* malloc(size_t size);
50*0b57cec5SDimitry Andricvoid* realloc(void* ptr, size_t size);
51*0b57cec5SDimitry Andricvoid abort(void);
52*0b57cec5SDimitry Andricint atexit(void (*func)(void));
53*0b57cec5SDimitry Andricvoid exit(int status);
54*0b57cec5SDimitry Andricvoid _Exit(int status);
55*0b57cec5SDimitry Andricchar* getenv(const char* name);
56*0b57cec5SDimitry Andricint system(const char* string);
57*0b57cec5SDimitry Andricvoid* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
58*0b57cec5SDimitry Andric              int (*compar)(const void *, const void *));
59*0b57cec5SDimitry Andricvoid qsort(void* base, size_t nmemb, size_t size,
60*0b57cec5SDimitry Andric           int (*compar)(const void *, const void *));
61*0b57cec5SDimitry Andricint         abs(      int j);
62*0b57cec5SDimitry Andriclong        abs(     long j);
63*0b57cec5SDimitry Andriclong long   abs(long long j);                                             // C++0X
64*0b57cec5SDimitry Andriclong       labs(     long j);
65*0b57cec5SDimitry Andriclong long llabs(long long j);                                             // C99
66*0b57cec5SDimitry Andricdiv_t     div(      int numer,       int denom);
67*0b57cec5SDimitry Andricldiv_t    div(     long numer,      long denom);
68*0b57cec5SDimitry Andriclldiv_t   div(long long numer, long long denom);                          // C++0X
69*0b57cec5SDimitry Andricldiv_t   ldiv(     long numer,      long denom);
70*0b57cec5SDimitry Andriclldiv_t lldiv(long long numer, long long denom);                          // C99
71*0b57cec5SDimitry Andricint mblen(const char* s, size_t n);
72*0b57cec5SDimitry Andricint mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
73*0b57cec5SDimitry Andricint wctomb(char* s, wchar_t wchar);
74*0b57cec5SDimitry Andricsize_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
75*0b57cec5SDimitry Andricsize_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
76*0b57cec5SDimitry Andricint at_quick_exit(void (*func)(void))                                     // C++11
77*0b57cec5SDimitry Andricvoid quick_exit(int status);                                              // C++11
78*0b57cec5SDimitry Andricvoid *aligned_alloc(size_t alignment, size_t size);                       // C11
79*0b57cec5SDimitry Andric
80*0b57cec5SDimitry Andric}  // std
81*0b57cec5SDimitry Andric
82*0b57cec5SDimitry Andric*/
83*0b57cec5SDimitry Andric
84*0b57cec5SDimitry Andric#include <__config>
85*0b57cec5SDimitry Andric#include <stdlib.h>
86*0b57cec5SDimitry Andric
87*0b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
88*0b57cec5SDimitry Andric#pragma GCC system_header
89*0b57cec5SDimitry Andric#endif
90*0b57cec5SDimitry Andric
91*0b57cec5SDimitry Andric#ifdef __GNUC__
92*0b57cec5SDimitry Andric#define _LIBCPP_UNREACHABLE() __builtin_unreachable()
93*0b57cec5SDimitry Andric#else
94*0b57cec5SDimitry Andric#define _LIBCPP_UNREACHABLE() _VSTD::abort()
95*0b57cec5SDimitry Andric#endif
96*0b57cec5SDimitry Andric
97*0b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
98*0b57cec5SDimitry Andric
99*0b57cec5SDimitry Andricusing ::size_t;
100*0b57cec5SDimitry Andricusing ::div_t;
101*0b57cec5SDimitry Andricusing ::ldiv_t;
102*0b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG
103*0b57cec5SDimitry Andricusing ::lldiv_t;
104*0b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG
105*0b57cec5SDimitry Andricusing ::atof;
106*0b57cec5SDimitry Andricusing ::atoi;
107*0b57cec5SDimitry Andricusing ::atol;
108*0b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG
109*0b57cec5SDimitry Andricusing ::atoll;
110*0b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG
111*0b57cec5SDimitry Andricusing ::strtod;
112*0b57cec5SDimitry Andricusing ::strtof;
113*0b57cec5SDimitry Andricusing ::strtold;
114*0b57cec5SDimitry Andricusing ::strtol;
115*0b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG
116*0b57cec5SDimitry Andricusing ::strtoll;
117*0b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG
118*0b57cec5SDimitry Andricusing ::strtoul;
119*0b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG
120*0b57cec5SDimitry Andricusing ::strtoull;
121*0b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG
122*0b57cec5SDimitry Andricusing ::rand;
123*0b57cec5SDimitry Andricusing ::srand;
124*0b57cec5SDimitry Andricusing ::calloc;
125*0b57cec5SDimitry Andricusing ::free;
126*0b57cec5SDimitry Andricusing ::malloc;
127*0b57cec5SDimitry Andricusing ::realloc;
128*0b57cec5SDimitry Andricusing ::abort;
129*0b57cec5SDimitry Andricusing ::atexit;
130*0b57cec5SDimitry Andricusing ::exit;
131*0b57cec5SDimitry Andricusing ::_Exit;
132*0b57cec5SDimitry Andric#ifndef _LIBCPP_WINDOWS_STORE_APP
133*0b57cec5SDimitry Andricusing ::getenv;
134*0b57cec5SDimitry Andricusing ::system;
135*0b57cec5SDimitry Andric#endif
136*0b57cec5SDimitry Andricusing ::bsearch;
137*0b57cec5SDimitry Andricusing ::qsort;
138*0b57cec5SDimitry Andricusing ::abs;
139*0b57cec5SDimitry Andricusing ::labs;
140*0b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG
141*0b57cec5SDimitry Andricusing ::llabs;
142*0b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG
143*0b57cec5SDimitry Andricusing ::div;
144*0b57cec5SDimitry Andricusing ::ldiv;
145*0b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG
146*0b57cec5SDimitry Andricusing ::lldiv;
147*0b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG
148*0b57cec5SDimitry Andricusing ::mblen;
149*0b57cec5SDimitry Andricusing ::mbtowc;
150*0b57cec5SDimitry Andricusing ::wctomb;
151*0b57cec5SDimitry Andricusing ::mbstowcs;
152*0b57cec5SDimitry Andricusing ::wcstombs;
153*0b57cec5SDimitry Andric#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
154*0b57cec5SDimitry Andricusing ::at_quick_exit;
155*0b57cec5SDimitry Andricusing ::quick_exit;
156*0b57cec5SDimitry Andric#endif
157*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
158*0b57cec5SDimitry Andricusing ::aligned_alloc;
159*0b57cec5SDimitry Andric#endif
160*0b57cec5SDimitry Andric
161*0b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
162*0b57cec5SDimitry Andric
163*0b57cec5SDimitry Andric#endif  // _LIBCPP_CSTDLIB
164