brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.1 KiB · 5e7da5d Raw
152 lines · c
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-exception7//8//===----------------------------------------------------------------------===//9 10#if defined(__need_malloc_and_calloc)11 12#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)13#    pragma GCC system_header14#  endif15 16#  include_next <stdlib.h>17 18#elif !defined(_LIBCPP___CXX03_STDLIB_H)19#  define _LIBCPP___CXX03_STDLIB_H20 21/*22    stdlib.h synopsis23 24Macros:25 26    EXIT_FAILURE27    EXIT_SUCCESS28    MB_CUR_MAX29    NULL30    RAND_MAX31 32Types:33 34    size_t35    div_t36    ldiv_t37    lldiv_t                                                               // C9938 39double    atof (const char* nptr);40int       atoi (const char* nptr);41long      atol (const char* nptr);42long long atoll(const char* nptr);                                        // C9943double             strtod  (const char* restrict nptr, char** restrict endptr);44float              strtof  (const char* restrict nptr, char** restrict endptr); // C9945long double        strtold (const char* restrict nptr, char** restrict endptr); // C9946long               strtol  (const char* restrict nptr, char** restrict endptr, int base);47long long          strtoll (const char* restrict nptr, char** restrict endptr, int base); // C9948unsigned long      strtoul (const char* restrict nptr, char** restrict endptr, int base);49unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C9950int rand(void);51void srand(unsigned int seed);52void* calloc(size_t nmemb, size_t size);53void free(void* ptr);54void* malloc(size_t size);55void* realloc(void* ptr, size_t size);56void abort(void);57int atexit(void (*func)(void));58void exit(int status);59void _Exit(int status);60char* getenv(const char* name);61int system(const char* string);62void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,63              int (*compar)(const void *, const void *));64void qsort(void* base, size_t nmemb, size_t size,65           int (*compar)(const void *, const void *));66int         abs(      int j);67long        abs(     long j);68long long   abs(long long j);                                             // C++0X69long       labs(     long j);70long long llabs(long long j);                                             // C9971div_t     div(      int numer,       int denom);72ldiv_t    div(     long numer,      long denom);73lldiv_t   div(long long numer, long long denom);                          // C++0X74ldiv_t   ldiv(     long numer,      long denom);75lldiv_t lldiv(long long numer, long long denom);                          // C9976int mblen(const char* s, size_t n);77int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);78int wctomb(char* s, wchar_t wchar);79size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);80size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);81int at_quick_exit(void (*func)(void))                                     // C++1182void quick_exit(int status);                                              // C++1183void *aligned_alloc(size_t alignment, size_t size);                       // C1184 85*/86 87#  include <__cxx03/__config>88 89#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)90#    pragma GCC system_header91#  endif92 93#  if __has_include_next(<stdlib.h>)94#    include_next <stdlib.h>95#  endif96 97#  ifdef __cplusplus98extern "C++" {99// abs100 101#    ifdef abs102#      undef abs103#    endif104#    ifdef labs105#      undef labs106#    endif107#    ifdef llabs108#      undef llabs109#    endif110 111// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined112#    if !defined(_LIBCPP_MSVCRT)113_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); }114_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); }115#    endif // !defined(_LIBCPP_MSVCRT)116 117_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT {118  return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h119}120 121_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT {122  return __builtin_fabs(__lcpp_x);123}124 125_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT {126  return __builtin_fabsl(__lcpp_x);127}128 129// div130 131#    ifdef div132#      undef div133#    endif134#    ifdef ldiv135#      undef ldiv136#    endif137#    ifdef lldiv138#      undef lldiv139#    endif140 141// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined142#    if !defined(_LIBCPP_MSVCRT)143inline _LIBCPP_HIDE_FROM_ABI ldiv_t div(long __x, long __y) _NOEXCEPT { return ::ldiv(__x, __y); }144#      if !(defined(__FreeBSD__) && !defined(__LONG_LONG_SUPPORTED))145inline _LIBCPP_HIDE_FROM_ABI lldiv_t div(long long __x, long long __y) _NOEXCEPT { return ::lldiv(__x, __y); }146#      endif147#    endif // _LIBCPP_MSVCRT148} // extern "C++"149#  endif   // __cplusplus150 151#endif // _LIBCPP___CXX03_STDLIB_H152