stdlib.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // -*- C++ -*-
  2. //===--------------------------- stdlib.h ---------------------------------===//
  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. #if defined(__need_malloc_and_calloc) || defined(_LIBCPP_STDLIB_INCLUDE_NEXT)
  10. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  11. #pragma GCC system_header
  12. #endif
  13. #if defined(_LIBCPP_STDLIB_INCLUDE_NEXT)
  14. #undef _LIBCPP_STDLIB_INCLUDE_NEXT
  15. #endif
  16. #include_next <stdlib.h>
  17. #elif !defined(_LIBCPP_STDLIB_H)
  18. #define _LIBCPP_STDLIB_H
  19. /*
  20. stdlib.h synopsis
  21. Macros:
  22. EXIT_FAILURE
  23. EXIT_SUCCESS
  24. MB_CUR_MAX
  25. NULL
  26. RAND_MAX
  27. Types:
  28. size_t
  29. div_t
  30. ldiv_t
  31. lldiv_t // C99
  32. double atof (const char* nptr);
  33. int atoi (const char* nptr);
  34. long atol (const char* nptr);
  35. long long atoll(const char* nptr); // C99
  36. double strtod (const char* restrict nptr, char** restrict endptr);
  37. float strtof (const char* restrict nptr, char** restrict endptr); // C99
  38. long double strtold (const char* restrict nptr, char** restrict endptr); // C99
  39. long strtol (const char* restrict nptr, char** restrict endptr, int base);
  40. long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
  41. unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base);
  42. unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
  43. int rand(void);
  44. void srand(unsigned int seed);
  45. void* calloc(size_t nmemb, size_t size);
  46. void free(void* ptr);
  47. void* malloc(size_t size);
  48. void* realloc(void* ptr, size_t size);
  49. void abort(void);
  50. int atexit(void (*func)(void));
  51. void exit(int status);
  52. void _Exit(int status);
  53. char* getenv(const char* name);
  54. int system(const char* string);
  55. void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
  56. int (*compar)(const void *, const void *));
  57. void qsort(void* base, size_t nmemb, size_t size,
  58. int (*compar)(const void *, const void *));
  59. int abs( int j);
  60. long abs( long j);
  61. long long abs(long long j); // C++0X
  62. long labs( long j);
  63. long long llabs(long long j); // C99
  64. div_t div( int numer, int denom);
  65. ldiv_t div( long numer, long denom);
  66. lldiv_t div(long long numer, long long denom); // C++0X
  67. ldiv_t ldiv( long numer, long denom);
  68. lldiv_t lldiv(long long numer, long long denom); // C99
  69. int mblen(const char* s, size_t n);
  70. int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
  71. int wctomb(char* s, wchar_t wchar);
  72. size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
  73. size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
  74. int at_quick_exit(void (*func)(void)) // C++11
  75. void quick_exit(int status); // C++11
  76. void *aligned_alloc(size_t alignment, size_t size); // C11
  77. */
  78. #include <__config>
  79. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  80. #pragma GCC system_header
  81. #endif
  82. #include_next <stdlib.h>
  83. #ifdef __cplusplus
  84. #include <math.h>
  85. #endif // __cplusplus
  86. #endif // _LIBCPP_STDLIB_H