xref: /freebsd/contrib/llvm-project/libcxx/include/cstdlib (revision 6b4981df6008fb59a5b4c1f0b79f0a0b21ac232e)
10b57cec5SDimitry Andric// -*- C++ -*-
2349cc55cSDimitry 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>
85bdd1243dSDimitry Andric
860b57cec5SDimitry Andric#include <stdlib.h>
870b57cec5SDimitry Andric
88bdd1243dSDimitry Andric#ifndef _LIBCPP_STDLIB_H
89bdd1243dSDimitry Andric#   error <cstdlib> tried including <stdlib.h> but didn't find libc++'s <stdlib.h> header. \
90bdd1243dSDimitry Andric          This usually means that your header search paths are not configured properly. \
91bdd1243dSDimitry Andric          The header search paths should contain the C++ Standard Library headers before \
92bdd1243dSDimitry Andric          any C Standard Library, and you are probably using compiler flags that make that \
93bdd1243dSDimitry Andric          not be the case.
94bdd1243dSDimitry Andric#endif
95bdd1243dSDimitry Andric
960b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
970b57cec5SDimitry Andric#  pragma GCC system_header
980b57cec5SDimitry Andric#endif
990b57cec5SDimitry Andric
1000b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
1010b57cec5SDimitry Andric
102fe6060f1SDimitry Andricusing ::size_t _LIBCPP_USING_IF_EXISTS;
103fe6060f1SDimitry Andricusing ::div_t _LIBCPP_USING_IF_EXISTS;
104fe6060f1SDimitry Andricusing ::ldiv_t _LIBCPP_USING_IF_EXISTS;
105*6b4981dfSDimitry Andric#if defined(__FreeBSD__) && defined(__LONG_LONG_SUPPORTED)
106fe6060f1SDimitry Andricusing ::lldiv_t _LIBCPP_USING_IF_EXISTS;
107*6b4981dfSDimitry Andric#endif
108fe6060f1SDimitry Andricusing ::atof _LIBCPP_USING_IF_EXISTS;
109fe6060f1SDimitry Andricusing ::atoi _LIBCPP_USING_IF_EXISTS;
110fe6060f1SDimitry Andricusing ::atol _LIBCPP_USING_IF_EXISTS;
111*6b4981dfSDimitry Andric#if defined(__FreeBSD__) && defined(__LONG_LONG_SUPPORTED)
112fe6060f1SDimitry Andricusing ::atoll _LIBCPP_USING_IF_EXISTS;
113*6b4981dfSDimitry Andric#endif
114fe6060f1SDimitry Andricusing ::strtod _LIBCPP_USING_IF_EXISTS;
115fe6060f1SDimitry Andricusing ::strtof _LIBCPP_USING_IF_EXISTS;
116fe6060f1SDimitry Andricusing ::strtold _LIBCPP_USING_IF_EXISTS;
117fe6060f1SDimitry Andricusing ::strtol _LIBCPP_USING_IF_EXISTS;
118*6b4981dfSDimitry Andric#if defined(__FreeBSD__) && defined(__LONG_LONG_SUPPORTED)
119fe6060f1SDimitry Andricusing ::strtoll _LIBCPP_USING_IF_EXISTS;
120*6b4981dfSDimitry Andric#endif
121fe6060f1SDimitry Andricusing ::strtoul _LIBCPP_USING_IF_EXISTS;
122*6b4981dfSDimitry Andric#if defined(__FreeBSD__) && defined(__LONG_LONG_SUPPORTED)
123fe6060f1SDimitry Andricusing ::strtoull _LIBCPP_USING_IF_EXISTS;
124*6b4981dfSDimitry Andric#endif
125fe6060f1SDimitry Andricusing ::rand _LIBCPP_USING_IF_EXISTS;
126fe6060f1SDimitry Andricusing ::srand _LIBCPP_USING_IF_EXISTS;
127fe6060f1SDimitry Andricusing ::calloc _LIBCPP_USING_IF_EXISTS;
128fe6060f1SDimitry Andricusing ::free _LIBCPP_USING_IF_EXISTS;
129fe6060f1SDimitry Andricusing ::malloc _LIBCPP_USING_IF_EXISTS;
130fe6060f1SDimitry Andricusing ::realloc _LIBCPP_USING_IF_EXISTS;
131fe6060f1SDimitry Andricusing ::abort _LIBCPP_USING_IF_EXISTS;
132fe6060f1SDimitry Andricusing ::atexit _LIBCPP_USING_IF_EXISTS;
133fe6060f1SDimitry Andricusing ::exit _LIBCPP_USING_IF_EXISTS;
134fe6060f1SDimitry Andricusing ::_Exit _LIBCPP_USING_IF_EXISTS;
135fe6060f1SDimitry Andricusing ::getenv _LIBCPP_USING_IF_EXISTS;
136fe6060f1SDimitry Andricusing ::system _LIBCPP_USING_IF_EXISTS;
137fe6060f1SDimitry Andricusing ::bsearch _LIBCPP_USING_IF_EXISTS;
138fe6060f1SDimitry Andricusing ::qsort _LIBCPP_USING_IF_EXISTS;
139fe6060f1SDimitry Andricusing ::abs _LIBCPP_USING_IF_EXISTS;
140fe6060f1SDimitry Andricusing ::labs _LIBCPP_USING_IF_EXISTS;
141*6b4981dfSDimitry Andric#if defined(__FreeBSD__) && defined(__LONG_LONG_SUPPORTED)
142fe6060f1SDimitry Andricusing ::llabs _LIBCPP_USING_IF_EXISTS;
143*6b4981dfSDimitry Andric#endif
144fe6060f1SDimitry Andricusing ::div _LIBCPP_USING_IF_EXISTS;
145fe6060f1SDimitry Andricusing ::ldiv _LIBCPP_USING_IF_EXISTS;
146*6b4981dfSDimitry Andric#if defined(__FreeBSD__) && defined(__LONG_LONG_SUPPORTED)
147fe6060f1SDimitry Andricusing ::lldiv _LIBCPP_USING_IF_EXISTS;
148*6b4981dfSDimitry Andric#endif
149fe6060f1SDimitry Andricusing ::mblen _LIBCPP_USING_IF_EXISTS;
1505f757f3fSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
151fe6060f1SDimitry Andricusing ::mbtowc _LIBCPP_USING_IF_EXISTS;
152fe6060f1SDimitry Andricusing ::wctomb _LIBCPP_USING_IF_EXISTS;
153fe6060f1SDimitry Andricusing ::mbstowcs _LIBCPP_USING_IF_EXISTS;
154fe6060f1SDimitry Andricusing ::wcstombs _LIBCPP_USING_IF_EXISTS;
1555f757f3fSDimitry Andric#endif
15681ad6265SDimitry Andric#if !defined(_LIBCPP_CXX03_LANG)
157fe6060f1SDimitry Andricusing ::at_quick_exit _LIBCPP_USING_IF_EXISTS;
158fe6060f1SDimitry Andricusing ::quick_exit _LIBCPP_USING_IF_EXISTS;
1590b57cec5SDimitry Andric#endif
16006c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
161fe6060f1SDimitry Andricusing ::aligned_alloc _LIBCPP_USING_IF_EXISTS;
1620b57cec5SDimitry Andric#endif
1630b57cec5SDimitry Andric
1640b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
1650b57cec5SDimitry Andric
1660b57cec5SDimitry Andric#endif // _LIBCPP_CSTDLIB
167