From c137a0754c4e13181c226359687ae9f3d8b488f0 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Tue, 24 Aug 2021 10:30:39 -0400 Subject: [PATCH] [libc++] Remove _LIBCPP_HAS_NO_LONG_LONG in favour of using_if_exists _LIBCPP_HAS_NO_LONG_LONG was only defined on FreeBSD. Instead, use the using_if_exists attribute to skip over declarations that are not available on the base system. Note that there's an annoying limitation that we can't conditionally define a function based on whether the base system provides a function, so for example we still need preprocessor logic to define the abs() and div() overloads. Differential Revision: https://reviews.llvm.org/D108630 --- libcxx/include/__config | 3 --- libcxx/include/cstdlib | 12 ------------ libcxx/include/cwchar | 4 ---- libcxx/include/stdlib.h | 30 ++++++++++++++++++------------ 4 files changed, 18 insertions(+), 31 deletions(-) diff --git a/libcxx/include/__config b/libcxx/include/__config index 2275bcc..2a63641 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -255,9 +255,6 @@ # else // _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_BIG_ENDIAN # endif // _BYTE_ORDER == _LITTLE_ENDIAN -# ifndef __LONG_LONG_SUPPORTED -# define _LIBCPP_HAS_NO_LONG_LONG -# endif // __LONG_LONG_SUPPORTED #endif // __FreeBSD__ #if defined(__NetBSD__) || defined(__OpenBSD__) diff --git a/libcxx/include/cstdlib b/libcxx/include/cstdlib index ced0321..e1645f6 100644 --- a/libcxx/include/cstdlib +++ b/libcxx/include/cstdlib @@ -99,26 +99,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD using ::size_t _LIBCPP_USING_IF_EXISTS; using ::div_t _LIBCPP_USING_IF_EXISTS; using ::ldiv_t _LIBCPP_USING_IF_EXISTS; -#ifndef _LIBCPP_HAS_NO_LONG_LONG using ::lldiv_t _LIBCPP_USING_IF_EXISTS; -#endif // _LIBCPP_HAS_NO_LONG_LONG using ::atof _LIBCPP_USING_IF_EXISTS; using ::atoi _LIBCPP_USING_IF_EXISTS; using ::atol _LIBCPP_USING_IF_EXISTS; -#ifndef _LIBCPP_HAS_NO_LONG_LONG using ::atoll _LIBCPP_USING_IF_EXISTS; -#endif // _LIBCPP_HAS_NO_LONG_LONG using ::strtod _LIBCPP_USING_IF_EXISTS; using ::strtof _LIBCPP_USING_IF_EXISTS; using ::strtold _LIBCPP_USING_IF_EXISTS; using ::strtol _LIBCPP_USING_IF_EXISTS; -#ifndef _LIBCPP_HAS_NO_LONG_LONG using ::strtoll _LIBCPP_USING_IF_EXISTS; -#endif // _LIBCPP_HAS_NO_LONG_LONG using ::strtoul _LIBCPP_USING_IF_EXISTS; -#ifndef _LIBCPP_HAS_NO_LONG_LONG using ::strtoull _LIBCPP_USING_IF_EXISTS; -#endif // _LIBCPP_HAS_NO_LONG_LONG using ::rand _LIBCPP_USING_IF_EXISTS; using ::srand _LIBCPP_USING_IF_EXISTS; using ::calloc _LIBCPP_USING_IF_EXISTS; @@ -137,14 +129,10 @@ using ::bsearch _LIBCPP_USING_IF_EXISTS; using ::qsort _LIBCPP_USING_IF_EXISTS; using ::abs _LIBCPP_USING_IF_EXISTS; using ::labs _LIBCPP_USING_IF_EXISTS; -#ifndef _LIBCPP_HAS_NO_LONG_LONG using ::llabs _LIBCPP_USING_IF_EXISTS; -#endif // _LIBCPP_HAS_NO_LONG_LONG using ::div _LIBCPP_USING_IF_EXISTS; using ::ldiv _LIBCPP_USING_IF_EXISTS; -#ifndef _LIBCPP_HAS_NO_LONG_LONG using ::lldiv _LIBCPP_USING_IF_EXISTS; -#endif // _LIBCPP_HAS_NO_LONG_LONG using ::mblen _LIBCPP_USING_IF_EXISTS; using ::mbtowc _LIBCPP_USING_IF_EXISTS; using ::wctomb _LIBCPP_USING_IF_EXISTS; diff --git a/libcxx/include/cwchar b/libcxx/include/cwchar index 5de1b62..c596398 100644 --- a/libcxx/include/cwchar +++ b/libcxx/include/cwchar @@ -137,13 +137,9 @@ using ::wcstod _LIBCPP_USING_IF_EXISTS; using ::wcstof _LIBCPP_USING_IF_EXISTS; using ::wcstold _LIBCPP_USING_IF_EXISTS; using ::wcstol _LIBCPP_USING_IF_EXISTS; -#ifndef _LIBCPP_HAS_NO_LONG_LONG using ::wcstoll _LIBCPP_USING_IF_EXISTS; -#endif // _LIBCPP_HAS_NO_LONG_LONG using ::wcstoul _LIBCPP_USING_IF_EXISTS; -#ifndef _LIBCPP_HAS_NO_LONG_LONG using ::wcstoull _LIBCPP_USING_IF_EXISTS; -#endif // _LIBCPP_HAS_NO_LONG_LONG using ::wcscpy _LIBCPP_USING_IF_EXISTS; using ::wcsncpy _LIBCPP_USING_IF_EXISTS; using ::wcscat _LIBCPP_USING_IF_EXISTS; diff --git a/libcxx/include/stdlib.h b/libcxx/include/stdlib.h index 242eedc..a2b7cbd 100644 --- a/libcxx/include/stdlib.h +++ b/libcxx/include/stdlib.h @@ -96,10 +96,14 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 extern "C++" { // abs -#undef abs -#undef labs -#ifndef _LIBCPP_HAS_NO_LONG_LONG -#undef llabs +#ifdef abs +# undef abs +#endif +#ifdef labs +# undef labs +#endif +#ifdef llabs +# undef llabs #endif // MSVCRT already has the correct prototype in if __cplusplus is defined @@ -107,11 +111,9 @@ extern "C++" { inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); } -#ifndef _LIBCPP_HAS_NO_LONG_LONG inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); } -#endif // _LIBCPP_HAS_NO_LONG_LONG #endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__) #if !defined(__sun__) @@ -131,10 +133,14 @@ abs(long double __lcpp_x) _NOEXCEPT { // div -#undef div -#undef ldiv -#ifndef _LIBCPP_HAS_NO_LONG_LONG -#undef lldiv +#ifdef div +# undef div +#endif +#ifdef ldiv +# undef ldiv +#endif +#ifdef lldiv +# undef lldiv #endif // MSVCRT already has the correct prototype in if __cplusplus is defined @@ -142,12 +148,12 @@ abs(long double __lcpp_x) _NOEXCEPT { inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT { return ::ldiv(__x, __y); } -#ifndef _LIBCPP_HAS_NO_LONG_LONG +#if !(defined(__FreeBSD__) && !defined(__LONG_LONG_SUPPORTED)) inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT { return ::lldiv(__x, __y); } -#endif // _LIBCPP_HAS_NO_LONG_LONG +#endif #endif // _LIBCPP_MSVCRT / __sun__ } // extern "C++" #endif // __cplusplus -- 2.7.4