Skip to content

Commit

Permalink
[libc++][RFC] Always define internal feature test macros
Browse files Browse the repository at this point in the history
  • Loading branch information
philnik777 committed Oct 8, 2024
1 parent 1df8ccd commit cc8658f
Show file tree
Hide file tree
Showing 136 changed files with 998 additions and 812 deletions.
2 changes: 1 addition & 1 deletion libcxx/include/__atomic/aliases.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ using atomic_long = atomic<long>;
using atomic_ulong = atomic<unsigned long>;
using atomic_llong = atomic<long long>;
using atomic_ullong = atomic<unsigned long long>;
#ifndef _LIBCPP_HAS_NO_CHAR8_T
#if _LIBCPP_HAS_CHAR8_T
using atomic_char8_t = atomic<char8_t>;
#endif
using atomic_char16_t = atomic<char16_t>;
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__atomic/atomic_lock_free.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#if defined(__CLANG_ATOMIC_BOOL_LOCK_FREE)
# define ATOMIC_BOOL_LOCK_FREE __CLANG_ATOMIC_BOOL_LOCK_FREE
# define ATOMIC_CHAR_LOCK_FREE __CLANG_ATOMIC_CHAR_LOCK_FREE
# ifndef _LIBCPP_HAS_NO_CHAR8_T
# if _LIBCPP_HAS_CHAR8_T
# define ATOMIC_CHAR8_T_LOCK_FREE __CLANG_ATOMIC_CHAR8_T_LOCK_FREE
# endif
# define ATOMIC_CHAR16_T_LOCK_FREE __CLANG_ATOMIC_CHAR16_T_LOCK_FREE
Expand All @@ -32,7 +32,7 @@
#elif defined(__GCC_ATOMIC_BOOL_LOCK_FREE)
# define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
# define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
# ifndef _LIBCPP_HAS_NO_CHAR8_T
# if _LIBCPP_HAS_CHAR8_T
# define ATOMIC_CHAR8_T_LOCK_FREE __GCC_ATOMIC_CHAR8_T_LOCK_FREE
# endif
# define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__bit/byteswap.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ template <integral _Tp>
return __builtin_bswap32(__val);
} else if constexpr (sizeof(_Tp) == 8) {
return __builtin_bswap64(__val);
# ifndef _LIBCPP_HAS_NO_INT128
# if _LIBCPP_HAS_INT128
} else if constexpr (sizeof(_Tp) == 16) {
# if __has_builtin(__builtin_bswap128)
return __builtin_bswap128(__val);
# else
return static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val))) << 64 |
static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val >> 64)));
# endif // __has_builtin(__builtin_bswap128)
# endif // _LIBCPP_HAS_NO_INT128
# endif // _LIBCPP_HAS_INT128
} else {
static_assert(sizeof(_Tp) == 0, "byteswap is unimplemented for integral types of this size");
}
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__bit/countl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
return __builtin_clzll(__x);
}

#ifndef _LIBCPP_HAS_NO_INT128
#if _LIBCPP_HAS_INT128
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x) _NOEXCEPT {
# if __has_builtin(__builtin_clzg)
return __builtin_clzg(__x);
Expand All @@ -57,7 +57,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x)
: __builtin_clzll(static_cast<unsigned long long>(__x >> 64));
# endif
}
#endif // _LIBCPP_HAS_NO_INT128
#endif // _LIBCPP_HAS_INT128

template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT {
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__charconv/tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ inline constexpr uint64_t __pow10_64[20] = {
UINT64_C(1000000000000000000),
UINT64_C(10000000000000000000)};

# ifndef _LIBCPP_HAS_NO_INT128
# if _LIBCPP_HAS_INT128
inline constexpr int __pow10_128_offset = 0;
inline constexpr __uint128_t __pow10_128[40] = {
UINT64_C(0),
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__charconv/to_chars_base_10.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ __base_10_u64(char* __buffer, uint64_t __value) noexcept {
return __itoa::__append10(__buffer, __value);
}

# ifndef _LIBCPP_HAS_NO_INT128
# if _LIBCPP_HAS_INT128
/// \returns 10^\a exp
///
/// \pre \a exp [19, 39]
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__charconv/to_chars_integral.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) {
return {__last, errc::value_too_large};
}

# ifndef _LIBCPP_HAS_NO_INT128
# if _LIBCPP_HAS_INT128
template <>
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
__to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) {
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__charconv/traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(uin
}
};

# ifndef _LIBCPP_HAS_NO_INT128
# if _LIBCPP_HAS_INT128
template <typename _Tp>
struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__uint128_t)> > {
using type = __uint128_t;
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__chrono/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class nonexistent_local_time : public runtime_error {
template <class _Duration>
[[noreturn]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_nonexistent_local_time(
[[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
throw nonexistent_local_time(__time, __info);
# else
_LIBCPP_VERBOSE_ABORT("nonexistent_local_time was thrown in -fno-exceptions mode");
Expand Down Expand Up @@ -117,7 +117,7 @@ class ambiguous_local_time : public runtime_error {
template <class _Duration>
[[noreturn]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_ambiguous_local_time(
[[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
throw ambiguous_local_time(__time, __info);
# else
_LIBCPP_VERBOSE_ABORT("ambiguous_local_time was thrown in -fno-exceptions mode");
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__chrono/file_clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ _LIBCPP_END_NAMESPACE_STD
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
struct _FilesystemClock {
# if !defined(_LIBCPP_HAS_NO_INT128)
# if _LIBCPP_HAS_INT128
typedef __int128_t rep;
typedef nano period;
# else
Expand Down
8 changes: 4 additions & 4 deletions libcxx/include/__condition_variable/condition_variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class _LIBCPP_EXPORTED_FROM_ABI condition_variable {
public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR condition_variable() _NOEXCEPT = default;

# ifdef _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
# if _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
~condition_variable() = default;
# else
~condition_variable();
Expand Down Expand Up @@ -83,7 +83,7 @@ class _LIBCPP_EXPORTED_FROM_ABI condition_variable {
private:
void
__do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::system_clock, chrono::nanoseconds>) _NOEXCEPT;
# if defined(_LIBCPP_HAS_COND_CLOCKWAIT)
# if _LIBCPP_HAS_COND_CLOCKWAIT
_LIBCPP_HIDE_FROM_ABI void
__do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds>) _NOEXCEPT;
# endif
Expand Down Expand Up @@ -180,7 +180,7 @@ cv_status condition_variable::wait_for(unique_lock<mutex>& __lk, const chrono::d
using __ns_rep = nanoseconds::rep;
steady_clock::time_point __c_now = steady_clock::now();

# if defined(_LIBCPP_HAS_COND_CLOCKWAIT)
# if _LIBCPP_HAS_COND_CLOCKWAIT
using __clock_tp_ns = time_point<steady_clock, nanoseconds>;
__ns_rep __now_count_ns = std::__safe_nanosecond_cast(__c_now.time_since_epoch()).count();
# else
Expand All @@ -205,7 +205,7 @@ condition_variable::wait_for(unique_lock<mutex>& __lk, const chrono::duration<_R
return wait_until(__lk, chrono::steady_clock::now() + __d, std::move(__pred));
}

# if defined(_LIBCPP_HAS_COND_CLOCKWAIT)
# if _LIBCPP_HAS_COND_CLOCKWAIT
inline void condition_variable::__do_timed_wait(
unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds> __tp) _NOEXCEPT {
using namespace chrono;
Expand Down
Loading

0 comments on commit cc8658f

Please sign in to comment.