xref: /freebsd/contrib/llvm-project/libcxx/include/cstdlib (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
10b57cec5SDimitry Andric// -*- C++ -*-
2*349cc55cSDimitry Andric//===----------------------------------------------------------------------===//
30b57cec5SDimitry Andric//
40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
70b57cec5SDimitry Andric//
80b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
90b57cec5SDimitry Andric
100b57cec5SDimitry Andric#ifndef _LIBCPP_CSTDLIB
110b57cec5SDimitry Andric#define _LIBCPP_CSTDLIB
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric/*
140b57cec5SDimitry Andric    cstdlib synopsis
150b57cec5SDimitry Andric
160b57cec5SDimitry AndricMacros:
170b57cec5SDimitry Andric
180b57cec5SDimitry Andric    EXIT_FAILURE
190b57cec5SDimitry Andric    EXIT_SUCCESS
200b57cec5SDimitry Andric    MB_CUR_MAX
210b57cec5SDimitry Andric    NULL
220b57cec5SDimitry Andric    RAND_MAX
230b57cec5SDimitry Andric
240b57cec5SDimitry Andricnamespace std
250b57cec5SDimitry Andric{
260b57cec5SDimitry Andric
270b57cec5SDimitry AndricTypes:
280b57cec5SDimitry Andric
290b57cec5SDimitry Andric    size_t
300b57cec5SDimitry Andric    div_t
310b57cec5SDimitry Andric    ldiv_t
320b57cec5SDimitry Andric    lldiv_t                                                               // C99
330b57cec5SDimitry Andric
340b57cec5SDimitry Andricdouble    atof (const char* nptr);
350b57cec5SDimitry Andricint       atoi (const char* nptr);
360b57cec5SDimitry Andriclong      atol (const char* nptr);
370b57cec5SDimitry Andriclong long atoll(const char* nptr);                                        // C99
380b57cec5SDimitry Andricdouble             strtod  (const char* restrict nptr, char** restrict endptr);
390b57cec5SDimitry Andricfloat              strtof  (const char* restrict nptr, char** restrict endptr); // C99
400b57cec5SDimitry Andriclong double        strtold (const char* restrict nptr, char** restrict endptr); // C99
410b57cec5SDimitry Andriclong               strtol  (const char* restrict nptr, char** restrict endptr, int base);
420b57cec5SDimitry Andriclong long          strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
430b57cec5SDimitry Andricunsigned long      strtoul (const char* restrict nptr, char** restrict endptr, int base);
440b57cec5SDimitry Andricunsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
450b57cec5SDimitry Andricint rand(void);
460b57cec5SDimitry Andricvoid srand(unsigned int seed);
470b57cec5SDimitry Andricvoid* calloc(size_t nmemb, size_t size);
480b57cec5SDimitry Andricvoid free(void* ptr);
490b57cec5SDimitry Andricvoid* malloc(size_t size);
500b57cec5SDimitry Andricvoid* realloc(void* ptr, size_t size);
510b57cec5SDimitry Andricvoid abort(void);
520b57cec5SDimitry Andricint atexit(void (*func)(void));
530b57cec5SDimitry Andricvoid exit(int status);
540b57cec5SDimitry Andricvoid _Exit(int status);
550b57cec5SDimitry Andricchar* getenv(const char* name);
560b57cec5SDimitry Andricint system(const char* string);
570b57cec5SDimitry Andricvoid* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
580b57cec5SDimitry Andric              int (*compar)(const void *, const void *));
590b57cec5SDimitry Andricvoid qsort(void* base, size_t nmemb, size_t size,
600b57cec5SDimitry Andric           int (*compar)(const void *, const void *));
610b57cec5SDimitry Andricint         abs(      int j);
620b57cec5SDimitry Andriclong        abs(     long j);
630b57cec5SDimitry Andriclong long   abs(long long j);                                             // C++0X
640b57cec5SDimitry Andriclong       labs(     long j);
650b57cec5SDimitry Andriclong long llabs(long long j);                                             // C99
660b57cec5SDimitry Andricdiv_t     div(      int numer,       int denom);
670b57cec5SDimitry Andricldiv_t    div(     long numer,      long denom);
680b57cec5SDimitry Andriclldiv_t   div(long long numer, long long denom);                          // C++0X
690b57cec5SDimitry Andricldiv_t   ldiv(     long numer,      long denom);
700b57cec5SDimitry Andriclldiv_t lldiv(long long numer, long long denom);                          // C99
710b57cec5SDimitry Andricint mblen(const char* s, size_t n);
720b57cec5SDimitry Andricint mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
730b57cec5SDimitry Andricint wctomb(char* s, wchar_t wchar);
740b57cec5SDimitry Andricsize_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
750b57cec5SDimitry Andricsize_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
760b57cec5SDimitry Andricint at_quick_exit(void (*func)(void))                                     // C++11
770b57cec5SDimitry Andricvoid quick_exit(int status);                                              // C++11
780b57cec5SDimitry Andricvoid *aligned_alloc(size_t alignment, size_t size);                       // C11
790b57cec5SDimitry Andric
800b57cec5SDimitry Andric}  // std
810b57cec5SDimitry Andric
820b57cec5SDimitry Andric*/
830b57cec5SDimitry Andric
840b57cec5SDimitry Andric#include <__config>
850b57cec5SDimitry Andric#include <stdlib.h>
860b57cec5SDimitry Andric
870b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
880b57cec5SDimitry Andric#pragma GCC system_header
890b57cec5SDimitry Andric#endif
900b57cec5SDimitry Andric
910b57cec5SDimitry Andric#ifdef __GNUC__
920b57cec5SDimitry Andric#define _LIBCPP_UNREACHABLE() __builtin_unreachable()
930b57cec5SDimitry Andric#else
940b57cec5SDimitry Andric#define _LIBCPP_UNREACHABLE() _VSTD::abort()
950b57cec5SDimitry Andric#endif
960b57cec5SDimitry Andric
970b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
980b57cec5SDimitry Andric
99fe6060f1SDimitry Andricusing ::size_t _LIBCPP_USING_IF_EXISTS;
100fe6060f1SDimitry Andricusing ::div_t _LIBCPP_USING_IF_EXISTS;
101fe6060f1SDimitry Andricusing ::ldiv_t _LIBCPP_USING_IF_EXISTS;
102fe6060f1SDimitry Andricusing ::lldiv_t _LIBCPP_USING_IF_EXISTS;
103fe6060f1SDimitry Andricusing ::atof _LIBCPP_USING_IF_EXISTS;
104fe6060f1SDimitry Andricusing ::atoi _LIBCPP_USING_IF_EXISTS;
105fe6060f1SDimitry Andricusing ::atol _LIBCPP_USING_IF_EXISTS;
106fe6060f1SDimitry Andricusing ::atoll _LIBCPP_USING_IF_EXISTS;
107fe6060f1SDimitry Andricusing ::strtod _LIBCPP_USING_IF_EXISTS;
108fe6060f1SDimitry Andricusing ::strtof _LIBCPP_USING_IF_EXISTS;
109fe6060f1SDimitry Andricusing ::strtold _LIBCPP_USING_IF_EXISTS;
110fe6060f1SDimitry Andricusing ::strtol _LIBCPP_USING_IF_EXISTS;
111fe6060f1SDimitry Andricusing ::strtoll _LIBCPP_USING_IF_EXISTS;
112fe6060f1SDimitry Andricusing ::strtoul _LIBCPP_USING_IF_EXISTS;
113fe6060f1SDimitry Andricusing ::strtoull _LIBCPP_USING_IF_EXISTS;
114fe6060f1SDimitry Andricusing ::rand _LIBCPP_USING_IF_EXISTS;
115fe6060f1SDimitry Andricusing ::srand _LIBCPP_USING_IF_EXISTS;
116fe6060f1SDimitry Andricusing ::calloc _LIBCPP_USING_IF_EXISTS;
117fe6060f1SDimitry Andricusing ::free _LIBCPP_USING_IF_EXISTS;
118fe6060f1SDimitry Andricusing ::malloc _LIBCPP_USING_IF_EXISTS;
119fe6060f1SDimitry Andricusing ::realloc _LIBCPP_USING_IF_EXISTS;
120fe6060f1SDimitry Andricusing ::abort _LIBCPP_USING_IF_EXISTS;
121fe6060f1SDimitry Andricusing ::atexit _LIBCPP_USING_IF_EXISTS;
122fe6060f1SDimitry Andricusing ::exit _LIBCPP_USING_IF_EXISTS;
123fe6060f1SDimitry Andricusing ::_Exit _LIBCPP_USING_IF_EXISTS;
1240b57cec5SDimitry Andric#ifndef _LIBCPP_WINDOWS_STORE_APP
125fe6060f1SDimitry Andricusing ::getenv _LIBCPP_USING_IF_EXISTS;
126fe6060f1SDimitry Andricusing ::system _LIBCPP_USING_IF_EXISTS;
1270b57cec5SDimitry Andric#endif
128fe6060f1SDimitry Andricusing ::bsearch _LIBCPP_USING_IF_EXISTS;
129fe6060f1SDimitry Andricusing ::qsort _LIBCPP_USING_IF_EXISTS;
130fe6060f1SDimitry Andricusing ::abs _LIBCPP_USING_IF_EXISTS;
131fe6060f1SDimitry Andricusing ::labs _LIBCPP_USING_IF_EXISTS;
132fe6060f1SDimitry Andricusing ::llabs _LIBCPP_USING_IF_EXISTS;
133fe6060f1SDimitry Andricusing ::div _LIBCPP_USING_IF_EXISTS;
134fe6060f1SDimitry Andricusing ::ldiv _LIBCPP_USING_IF_EXISTS;
135fe6060f1SDimitry Andricusing ::lldiv _LIBCPP_USING_IF_EXISTS;
136fe6060f1SDimitry Andricusing ::mblen _LIBCPP_USING_IF_EXISTS;
137fe6060f1SDimitry Andricusing ::mbtowc _LIBCPP_USING_IF_EXISTS;
138fe6060f1SDimitry Andricusing ::wctomb _LIBCPP_USING_IF_EXISTS;
139fe6060f1SDimitry Andricusing ::mbstowcs _LIBCPP_USING_IF_EXISTS;
140fe6060f1SDimitry Andricusing ::wcstombs _LIBCPP_USING_IF_EXISTS;
1410b57cec5SDimitry Andric#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
142fe6060f1SDimitry Andricusing ::at_quick_exit _LIBCPP_USING_IF_EXISTS;
143fe6060f1SDimitry Andricusing ::quick_exit _LIBCPP_USING_IF_EXISTS;
1440b57cec5SDimitry Andric#endif
145480093f4SDimitry Andric#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_ALIGNED_ALLOC)
146fe6060f1SDimitry Andricusing ::aligned_alloc _LIBCPP_USING_IF_EXISTS;
1470b57cec5SDimitry Andric#endif
1480b57cec5SDimitry Andric
1490b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
1500b57cec5SDimitry Andric
1510b57cec5SDimitry Andric#endif // _LIBCPP_CSTDLIB
152