cstdlib 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  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. #ifndef _LIBCPP_CSTDLIB
  10. #define _LIBCPP_CSTDLIB
  11. /*
  12. cstdlib synopsis
  13. Macros:
  14. EXIT_FAILURE
  15. EXIT_SUCCESS
  16. MB_CUR_MAX
  17. NULL
  18. RAND_MAX
  19. namespace std
  20. {
  21. Types:
  22. size_t
  23. div_t
  24. ldiv_t
  25. lldiv_t // C99
  26. double atof (const char* nptr);
  27. int atoi (const char* nptr);
  28. long atol (const char* nptr);
  29. long long atoll(const char* nptr); // C99
  30. double strtod (const char* restrict nptr, char** restrict endptr);
  31. float strtof (const char* restrict nptr, char** restrict endptr); // C99
  32. long double strtold (const char* restrict nptr, char** restrict endptr); // C99
  33. long strtol (const char* restrict nptr, char** restrict endptr, int base);
  34. long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
  35. unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base);
  36. unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
  37. int rand(void);
  38. void srand(unsigned int seed);
  39. void* calloc(size_t nmemb, size_t size);
  40. void free(void* ptr);
  41. void* malloc(size_t size);
  42. void* realloc(void* ptr, size_t size);
  43. void abort(void);
  44. int atexit(void (*func)(void));
  45. void exit(int status);
  46. void _Exit(int status);
  47. char* getenv(const char* name);
  48. int system(const char* string);
  49. void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
  50. int (*compar)(const void *, const void *));
  51. void qsort(void* base, size_t nmemb, size_t size,
  52. int (*compar)(const void *, const void *));
  53. int abs( int j);
  54. long abs( long j);
  55. long long abs(long long j); // C++0X
  56. long labs( long j);
  57. long long llabs(long long j); // C99
  58. div_t div( int numer, int denom);
  59. ldiv_t div( long numer, long denom);
  60. lldiv_t div(long long numer, long long denom); // C++0X
  61. ldiv_t ldiv( long numer, long denom);
  62. lldiv_t lldiv(long long numer, long long denom); // C99
  63. int mblen(const char* s, size_t n);
  64. int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
  65. int wctomb(char* s, wchar_t wchar);
  66. size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
  67. size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
  68. int at_quick_exit(void (*func)(void)) // C++11
  69. void quick_exit(int status); // C++11
  70. void *aligned_alloc(size_t alignment, size_t size); // C11
  71. } // std
  72. */
  73. #include <__config>
  74. #include <stdlib.h>
  75. #ifndef _LIBCPP_STDLIB_H
  76. # error <cstdlib> tried including <stdlib.h> but didn't find libc++'s <stdlib.h> header. \
  77. This usually means that your header search paths are not configured properly. \
  78. The header search paths should contain the C++ Standard Library headers before \
  79. any C Standard Library, and you are probably using compiler flags that make that \
  80. not be the case.
  81. #endif
  82. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  83. # pragma GCC system_header
  84. #endif
  85. _LIBCPP_BEGIN_NAMESPACE_STD
  86. using ::size_t _LIBCPP_USING_IF_EXISTS;
  87. using ::div_t _LIBCPP_USING_IF_EXISTS;
  88. using ::ldiv_t _LIBCPP_USING_IF_EXISTS;
  89. using ::lldiv_t _LIBCPP_USING_IF_EXISTS;
  90. using ::atof _LIBCPP_USING_IF_EXISTS;
  91. using ::atoi _LIBCPP_USING_IF_EXISTS;
  92. using ::atol _LIBCPP_USING_IF_EXISTS;
  93. using ::atoll _LIBCPP_USING_IF_EXISTS;
  94. using ::strtod _LIBCPP_USING_IF_EXISTS;
  95. using ::strtof _LIBCPP_USING_IF_EXISTS;
  96. using ::strtold _LIBCPP_USING_IF_EXISTS;
  97. using ::strtol _LIBCPP_USING_IF_EXISTS;
  98. using ::strtoll _LIBCPP_USING_IF_EXISTS;
  99. using ::strtoul _LIBCPP_USING_IF_EXISTS;
  100. using ::strtoull _LIBCPP_USING_IF_EXISTS;
  101. using ::rand _LIBCPP_USING_IF_EXISTS;
  102. using ::srand _LIBCPP_USING_IF_EXISTS;
  103. using ::calloc _LIBCPP_USING_IF_EXISTS;
  104. using ::free _LIBCPP_USING_IF_EXISTS;
  105. using ::malloc _LIBCPP_USING_IF_EXISTS;
  106. using ::realloc _LIBCPP_USING_IF_EXISTS;
  107. using ::abort _LIBCPP_USING_IF_EXISTS;
  108. using ::atexit _LIBCPP_USING_IF_EXISTS;
  109. using ::exit _LIBCPP_USING_IF_EXISTS;
  110. using ::_Exit _LIBCPP_USING_IF_EXISTS;
  111. using ::getenv _LIBCPP_USING_IF_EXISTS;
  112. using ::system _LIBCPP_USING_IF_EXISTS;
  113. using ::bsearch _LIBCPP_USING_IF_EXISTS;
  114. using ::qsort _LIBCPP_USING_IF_EXISTS;
  115. using ::abs _LIBCPP_USING_IF_EXISTS;
  116. using ::labs _LIBCPP_USING_IF_EXISTS;
  117. using ::llabs _LIBCPP_USING_IF_EXISTS;
  118. using ::div _LIBCPP_USING_IF_EXISTS;
  119. using ::ldiv _LIBCPP_USING_IF_EXISTS;
  120. using ::lldiv _LIBCPP_USING_IF_EXISTS;
  121. using ::mblen _LIBCPP_USING_IF_EXISTS;
  122. #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
  123. using ::mbtowc _LIBCPP_USING_IF_EXISTS;
  124. using ::wctomb _LIBCPP_USING_IF_EXISTS;
  125. using ::mbstowcs _LIBCPP_USING_IF_EXISTS;
  126. using ::wcstombs _LIBCPP_USING_IF_EXISTS;
  127. #endif
  128. #if !defined(_LIBCPP_CXX03_LANG) && __has_attribute(using_if_exists)
  129. using ::at_quick_exit _LIBCPP_USING_IF_EXISTS;
  130. using ::quick_exit _LIBCPP_USING_IF_EXISTS;
  131. #endif
  132. #if _LIBCPP_STD_VER >= 17 && __has_attribute(using_if_exists) && !defined(_LIBCPP_MSVCRT)
  133. using ::aligned_alloc _LIBCPP_USING_IF_EXISTS;
  134. #endif
  135. _LIBCPP_END_NAMESPACE_STD
  136. #endif // _LIBCPP_CSTDLIB