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