xref: /minix3/external/bsd/libc++/dist/libcxx/include/cstdlib (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
14684ddb6SLionel Sambuc// -*- C++ -*-
24684ddb6SLionel Sambuc//===--------------------------- cstdlib ----------------------------------===//
34684ddb6SLionel Sambuc//
44684ddb6SLionel Sambuc//                     The LLVM Compiler Infrastructure
54684ddb6SLionel Sambuc//
64684ddb6SLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open
74684ddb6SLionel Sambuc// Source Licenses. See LICENSE.TXT for details.
84684ddb6SLionel Sambuc//
94684ddb6SLionel Sambuc//===----------------------------------------------------------------------===//
104684ddb6SLionel Sambuc
114684ddb6SLionel Sambuc#ifndef _LIBCPP_CSTDLIB
124684ddb6SLionel Sambuc#define _LIBCPP_CSTDLIB
134684ddb6SLionel Sambuc
144684ddb6SLionel Sambuc/*
154684ddb6SLionel Sambuc    cstdlib synopsis
164684ddb6SLionel Sambuc
174684ddb6SLionel SambucMacros:
184684ddb6SLionel Sambuc
194684ddb6SLionel Sambuc    EXIT_FAILURE
204684ddb6SLionel Sambuc    EXIT_SUCCESS
214684ddb6SLionel Sambuc    MB_CUR_MAX
224684ddb6SLionel Sambuc    NULL
234684ddb6SLionel Sambuc    RAND_MAX
244684ddb6SLionel Sambuc
254684ddb6SLionel Sambucnamespace std
264684ddb6SLionel Sambuc{
274684ddb6SLionel Sambuc
284684ddb6SLionel SambucTypes:
294684ddb6SLionel Sambuc
304684ddb6SLionel Sambuc    size_t
314684ddb6SLionel Sambuc    div_t
324684ddb6SLionel Sambuc    ldiv_t
334684ddb6SLionel Sambuc    lldiv_t                                                               // C99
344684ddb6SLionel Sambuc
354684ddb6SLionel Sambucdouble    atof (const char* nptr);
364684ddb6SLionel Sambucint       atoi (const char* nptr);
374684ddb6SLionel Sambuclong      atol (const char* nptr);
384684ddb6SLionel Sambuclong long atoll(const char* nptr);                                        // C99
394684ddb6SLionel Sambucdouble             strtod  (const char* restrict nptr, char** restrict endptr);
404684ddb6SLionel Sambucfloat              strtof  (const char* restrict nptr, char** restrict endptr); // C99
414684ddb6SLionel Sambuclong double        strtold (const char* restrict nptr, char** restrict endptr); // C99
424684ddb6SLionel Sambuclong               strtol  (const char* restrict nptr, char** restrict endptr, int base);
434684ddb6SLionel Sambuclong long          strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
444684ddb6SLionel Sambucunsigned long      strtoul (const char* restrict nptr, char** restrict endptr, int base);
454684ddb6SLionel Sambucunsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
464684ddb6SLionel Sambucint rand(void);
474684ddb6SLionel Sambucvoid srand(unsigned int seed);
484684ddb6SLionel Sambucvoid* calloc(size_t nmemb, size_t size);
494684ddb6SLionel Sambucvoid free(void* ptr);
504684ddb6SLionel Sambucvoid* malloc(size_t size);
514684ddb6SLionel Sambucvoid* realloc(void* ptr, size_t size);
524684ddb6SLionel Sambucvoid abort(void);
534684ddb6SLionel Sambucint atexit(void (*func)(void));
544684ddb6SLionel Sambucvoid exit(int status);
554684ddb6SLionel Sambucvoid _Exit(int status);
564684ddb6SLionel Sambucchar* getenv(const char* name);
574684ddb6SLionel Sambucint system(const char* string);
584684ddb6SLionel Sambucvoid* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
594684ddb6SLionel Sambuc              int (*compar)(const void *, const void *));
604684ddb6SLionel Sambucvoid qsort(void* base, size_t nmemb, size_t size,
614684ddb6SLionel Sambuc           int (*compar)(const void *, const void *));
624684ddb6SLionel Sambucint         abs(      int j);
634684ddb6SLionel Sambuclong        abs(     long j);
644684ddb6SLionel Sambuclong long   abs(long long j);                                             // C++0X
654684ddb6SLionel Sambuclong       labs(     long j);
664684ddb6SLionel Sambuclong long llabs(long long j);                                             // C99
674684ddb6SLionel Sambucdiv_t     div(      int numer,       int denom);
684684ddb6SLionel Sambucldiv_t    div(     long numer,      long denom);
694684ddb6SLionel Sambuclldiv_t   div(long long numer, long long denom);                          // C++0X
704684ddb6SLionel Sambucldiv_t   ldiv(     long numer,      long denom);
714684ddb6SLionel Sambuclldiv_t lldiv(long long numer, long long denom);                          // C99
724684ddb6SLionel Sambucint mblen(const char* s, size_t n);
734684ddb6SLionel Sambucint mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
744684ddb6SLionel Sambucint wctomb(char* s, wchar_t wchar);
754684ddb6SLionel Sambucsize_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
764684ddb6SLionel Sambucsize_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
774684ddb6SLionel Sambucint at_quick_exit(void (*func)(void))                                     // C++11
784684ddb6SLionel Sambucvoid quick_exit(int status);                                              // C++11
794684ddb6SLionel Sambucvoid *aligned_alloc(size_t alignment, size_t size);                       // C11
804684ddb6SLionel Sambuc
814684ddb6SLionel Sambuc}  // std
824684ddb6SLionel Sambuc
834684ddb6SLionel Sambuc*/
844684ddb6SLionel Sambuc
854684ddb6SLionel Sambuc#include <__config>
864684ddb6SLionel Sambuc#include <stdlib.h>
874684ddb6SLionel Sambuc#ifdef _LIBCPP_MSVCRT
884684ddb6SLionel Sambuc#include "support/win32/locale_win32.h"
894684ddb6SLionel Sambuc#endif // _LIBCPP_MSVCRT
904684ddb6SLionel Sambuc
914684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
924684ddb6SLionel Sambuc#pragma GCC system_header
934684ddb6SLionel Sambuc#endif
944684ddb6SLionel Sambuc
954684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD
964684ddb6SLionel Sambuc
974684ddb6SLionel Sambucusing ::size_t;
984684ddb6SLionel Sambucusing ::div_t;
994684ddb6SLionel Sambucusing ::ldiv_t;
1004684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_LONG_LONG
1014684ddb6SLionel Sambucusing ::lldiv_t;
1024684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_LONG_LONG
1034684ddb6SLionel Sambucusing ::atof;
1044684ddb6SLionel Sambucusing ::atoi;
1054684ddb6SLionel Sambucusing ::atol;
1064684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_LONG_LONG
1074684ddb6SLionel Sambucusing ::atoll;
1084684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_LONG_LONG
1094684ddb6SLionel Sambucusing ::strtod;
1104684ddb6SLionel Sambucusing ::strtof;
1114684ddb6SLionel Sambucusing ::strtold;
1124684ddb6SLionel Sambucusing ::strtol;
1134684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_LONG_LONG
1144684ddb6SLionel Sambucusing ::strtoll;
1154684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_LONG_LONG
1164684ddb6SLionel Sambucusing ::strtoul;
1174684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_LONG_LONG
1184684ddb6SLionel Sambucusing ::strtoull;
1194684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_LONG_LONG
1204684ddb6SLionel Sambucusing ::rand;
1214684ddb6SLionel Sambucusing ::srand;
1224684ddb6SLionel Sambucusing ::calloc;
1234684ddb6SLionel Sambucusing ::free;
1244684ddb6SLionel Sambucusing ::malloc;
1254684ddb6SLionel Sambucusing ::realloc;
1264684ddb6SLionel Sambucusing ::abort;
1274684ddb6SLionel Sambucusing ::atexit;
1284684ddb6SLionel Sambucusing ::exit;
1294684ddb6SLionel Sambucusing ::_Exit;
1304684ddb6SLionel Sambucusing ::getenv;
1314684ddb6SLionel Sambucusing ::system;
1324684ddb6SLionel Sambucusing ::bsearch;
1334684ddb6SLionel Sambucusing ::qsort;
134*0a6a1f1dSLionel Sambuc#undef abs
1354684ddb6SLionel Sambucusing ::abs;
136*0a6a1f1dSLionel Sambuc#undef labs
1374684ddb6SLionel Sambucusing ::labs;
1384684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_LONG_LONG
139*0a6a1f1dSLionel Sambuc#undef llabs
1404684ddb6SLionel Sambucusing ::llabs;
1414684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_LONG_LONG
142*0a6a1f1dSLionel Sambuc#undef div
1434684ddb6SLionel Sambucusing ::div;
144*0a6a1f1dSLionel Sambuc#undef ldiv
1454684ddb6SLionel Sambucusing ::ldiv;
1464684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_LONG_LONG
147*0a6a1f1dSLionel Sambuc#undef lldiv
1484684ddb6SLionel Sambucusing ::lldiv;
1494684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_LONG_LONG
150*0a6a1f1dSLionel Sambuc#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
1514684ddb6SLionel Sambucusing ::mblen;
1524684ddb6SLionel Sambucusing ::mbtowc;
1534684ddb6SLionel Sambucusing ::wctomb;
154*0a6a1f1dSLionel Sambuc#endif
1554684ddb6SLionel Sambucusing ::mbstowcs;
1564684ddb6SLionel Sambucusing ::wcstombs;
1574684ddb6SLionel Sambuc#ifdef _LIBCPP_HAS_QUICK_EXIT
1584684ddb6SLionel Sambucusing ::at_quick_exit;
1594684ddb6SLionel Sambucusing ::quick_exit;
1604684ddb6SLionel Sambuc#endif
1614684ddb6SLionel Sambuc#ifdef _LIBCPP_HAS_C11_FEATURES
1624684ddb6SLionel Sambucusing ::aligned_alloc;
1634684ddb6SLionel Sambuc#endif
1644684ddb6SLionel Sambuc
1654684ddb6SLionel Sambuc// MSVCRT already has the correct prototype in <stdlib.h> #ifdef __cplusplus
1664684ddb6SLionel Sambuc#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
1674684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
1684684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_LONG_LONG
1694684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
1704684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_LONG_LONG
1714684ddb6SLionel Sambuc
1724684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY  ldiv_t div(     long __x,      long __y) _NOEXCEPT {return  ldiv(__x, __y);}
1734684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_LONG_LONG
1744684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
1754684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_LONG_LONG
1764684ddb6SLionel Sambuc#endif // _LIBCPP_MSVCRT
1774684ddb6SLionel Sambuc
1784684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD
1794684ddb6SLionel Sambuc
1804684ddb6SLionel Sambuc#endif  // _LIBCPP_CSTDLIB
181