xref: /freebsd/contrib/llvm-project/libcxx/include/cstdlib (revision fe6060f10f634930ff71b7c50291ddc610da2475)
10b57cec5SDimitry Andric// -*- C++ -*-
20b57cec5SDimitry Andric//===--------------------------- cstdlib ----------------------------------===//
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
99*fe6060f1SDimitry Andricusing ::size_t _LIBCPP_USING_IF_EXISTS;
100*fe6060f1SDimitry Andricusing ::div_t _LIBCPP_USING_IF_EXISTS;
101*fe6060f1SDimitry Andricusing ::ldiv_t _LIBCPP_USING_IF_EXISTS;
1020b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG
103*fe6060f1SDimitry Andricusing ::lldiv_t _LIBCPP_USING_IF_EXISTS;
1040b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG
105*fe6060f1SDimitry Andricusing ::atof _LIBCPP_USING_IF_EXISTS;
106*fe6060f1SDimitry Andricusing ::atoi _LIBCPP_USING_IF_EXISTS;
107*fe6060f1SDimitry Andricusing ::atol _LIBCPP_USING_IF_EXISTS;
1080b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG
109*fe6060f1SDimitry Andricusing ::atoll _LIBCPP_USING_IF_EXISTS;
1100b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG
111*fe6060f1SDimitry Andricusing ::strtod _LIBCPP_USING_IF_EXISTS;
112*fe6060f1SDimitry Andricusing ::strtof _LIBCPP_USING_IF_EXISTS;
113*fe6060f1SDimitry Andricusing ::strtold _LIBCPP_USING_IF_EXISTS;
114*fe6060f1SDimitry Andricusing ::strtol _LIBCPP_USING_IF_EXISTS;
1150b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG
116*fe6060f1SDimitry Andricusing ::strtoll _LIBCPP_USING_IF_EXISTS;
1170b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG
118*fe6060f1SDimitry Andricusing ::strtoul _LIBCPP_USING_IF_EXISTS;
1190b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG
120*fe6060f1SDimitry Andricusing ::strtoull _LIBCPP_USING_IF_EXISTS;
1210b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG
122*fe6060f1SDimitry Andricusing ::rand _LIBCPP_USING_IF_EXISTS;
123*fe6060f1SDimitry Andricusing ::srand _LIBCPP_USING_IF_EXISTS;
124*fe6060f1SDimitry Andricusing ::calloc _LIBCPP_USING_IF_EXISTS;
125*fe6060f1SDimitry Andricusing ::free _LIBCPP_USING_IF_EXISTS;
126*fe6060f1SDimitry Andricusing ::malloc _LIBCPP_USING_IF_EXISTS;
127*fe6060f1SDimitry Andricusing ::realloc _LIBCPP_USING_IF_EXISTS;
128*fe6060f1SDimitry Andricusing ::abort _LIBCPP_USING_IF_EXISTS;
129*fe6060f1SDimitry Andricusing ::atexit _LIBCPP_USING_IF_EXISTS;
130*fe6060f1SDimitry Andricusing ::exit _LIBCPP_USING_IF_EXISTS;
131*fe6060f1SDimitry Andricusing ::_Exit _LIBCPP_USING_IF_EXISTS;
1320b57cec5SDimitry Andric#ifndef _LIBCPP_WINDOWS_STORE_APP
133*fe6060f1SDimitry Andricusing ::getenv _LIBCPP_USING_IF_EXISTS;
134*fe6060f1SDimitry Andricusing ::system _LIBCPP_USING_IF_EXISTS;
1350b57cec5SDimitry Andric#endif
136*fe6060f1SDimitry Andricusing ::bsearch _LIBCPP_USING_IF_EXISTS;
137*fe6060f1SDimitry Andricusing ::qsort _LIBCPP_USING_IF_EXISTS;
138*fe6060f1SDimitry Andricusing ::abs _LIBCPP_USING_IF_EXISTS;
139*fe6060f1SDimitry Andricusing ::labs _LIBCPP_USING_IF_EXISTS;
1400b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG
141*fe6060f1SDimitry Andricusing ::llabs _LIBCPP_USING_IF_EXISTS;
1420b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG
143*fe6060f1SDimitry Andricusing ::div _LIBCPP_USING_IF_EXISTS;
144*fe6060f1SDimitry Andricusing ::ldiv _LIBCPP_USING_IF_EXISTS;
1450b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG
146*fe6060f1SDimitry Andricusing ::lldiv _LIBCPP_USING_IF_EXISTS;
1470b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG
148*fe6060f1SDimitry Andricusing ::mblen _LIBCPP_USING_IF_EXISTS;
149*fe6060f1SDimitry Andricusing ::mbtowc _LIBCPP_USING_IF_EXISTS;
150*fe6060f1SDimitry Andricusing ::wctomb _LIBCPP_USING_IF_EXISTS;
151*fe6060f1SDimitry Andricusing ::mbstowcs _LIBCPP_USING_IF_EXISTS;
152*fe6060f1SDimitry Andricusing ::wcstombs _LIBCPP_USING_IF_EXISTS;
1530b57cec5SDimitry Andric#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
154*fe6060f1SDimitry Andricusing ::at_quick_exit _LIBCPP_USING_IF_EXISTS;
155*fe6060f1SDimitry Andricusing ::quick_exit _LIBCPP_USING_IF_EXISTS;
1560b57cec5SDimitry Andric#endif
157480093f4SDimitry Andric#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_ALIGNED_ALLOC)
158*fe6060f1SDimitry Andricusing ::aligned_alloc _LIBCPP_USING_IF_EXISTS;
1590b57cec5SDimitry Andric#endif
1600b57cec5SDimitry Andric
1610b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
1620b57cec5SDimitry Andric
1630b57cec5SDimitry Andric#endif // _LIBCPP_CSTDLIB
164