diff --git a/libc/docs/dev/code_style.rst b/libc/docs/dev/code_style.rst index e6fc6df5a0f6b..22a18b7a4cc1d 100644 --- a/libc/docs/dev/code_style.rst +++ b/libc/docs/dev/code_style.rst @@ -55,7 +55,7 @@ We define two kinds of macros: * ``src/__support/macros/config.h`` - Important compiler and platform features. Such macros can be used to produce portable code by parameterizing compilation based on the presence or lack of a given - feature. e.g., ``LIBC_HAS_BUILTIN`` + feature. e.g., ``LIBC_HAS_FEATURE`` * ``src/__support/macros/attributes.h`` - Attributes for functions, types, and variables. e.g., ``LIBC_UNUSED`` * ``src/__support/macros/optimization.h`` - Portable macros for performance diff --git a/libc/src/__support/CPP/CMakeLists.txt b/libc/src/__support/CPP/CMakeLists.txt index f76285be52194..84d01fe045160 100644 --- a/libc/src/__support/CPP/CMakeLists.txt +++ b/libc/src/__support/CPP/CMakeLists.txt @@ -18,7 +18,6 @@ add_header_library( .limits .type_traits libc.src.__support.macros.attributes - libc.src.__support.macros.config libc.src.__support.macros.sanitizer ) @@ -157,7 +156,6 @@ add_header_library( DEPENDS libc.include.llvm-libc-macros.stdfix_macros libc.src.__support.macros.attributes - libc.src.__support.macros.config libc.src.__support.macros.properties.types ) diff --git a/libc/src/__support/CPP/atomic.h b/libc/src/__support/CPP/atomic.h index b74cb5981dbaf..5e428940565b9 100644 --- a/libc/src/__support/CPP/atomic.h +++ b/libc/src/__support/CPP/atomic.h @@ -71,10 +71,11 @@ template struct Atomic { T load(MemoryOrder mem_ord = MemoryOrder::SEQ_CST, [[maybe_unused]] MemoryScope mem_scope = MemoryScope::DEVICE) { - if constexpr (LIBC_HAS_BUILTIN(__scoped_atomic_load_n)) - return __scoped_atomic_load_n(&val, int(mem_ord), (int)(mem_scope)); - else - return __atomic_load_n(&val, int(mem_ord)); +#if __has_builtin(__scoped_atomic_load_n) + return __scoped_atomic_load_n(&val, int(mem_ord), (int)(mem_scope)); +#else + return __atomic_load_n(&val, int(mem_ord)); +#endif } // Atomic store. @@ -85,10 +86,11 @@ template struct Atomic { void store(T rhs, MemoryOrder mem_ord = MemoryOrder::SEQ_CST, [[maybe_unused]] MemoryScope mem_scope = MemoryScope::DEVICE) { - if constexpr (LIBC_HAS_BUILTIN(__scoped_atomic_store_n)) - __scoped_atomic_store_n(&val, rhs, int(mem_ord), (int)(mem_scope)); - else - __atomic_store_n(&val, rhs, int(mem_ord)); +#if __has_builtin(__scoped_atomic_store_n) + __scoped_atomic_store_n(&val, rhs, int(mem_ord), (int)(mem_scope)); +#else + __atomic_store_n(&val, rhs, int(mem_ord)); +#endif } // Atomic compare exchange @@ -101,47 +103,51 @@ template struct Atomic { T exchange(T desired, MemoryOrder mem_ord = MemoryOrder::SEQ_CST, [[maybe_unused]] MemoryScope mem_scope = MemoryScope::DEVICE) { - if constexpr (LIBC_HAS_BUILTIN(__scoped_atomic_exchange_n)) - return __scoped_atomic_exchange_n(&val, desired, int(mem_ord), - (int)(mem_scope)); - else - return __atomic_exchange_n(&val, desired, int(mem_ord)); +#if __has_builtin(__scoped_atomic_exchange_n) + return __scoped_atomic_exchange_n(&val, desired, int(mem_ord), + (int)(mem_scope)); +#else + return __atomic_exchange_n(&val, desired, int(mem_ord)); +#endif } T fetch_add(T increment, MemoryOrder mem_ord = MemoryOrder::SEQ_CST, [[maybe_unused]] MemoryScope mem_scope = MemoryScope::DEVICE) { - if constexpr (LIBC_HAS_BUILTIN(__scoped_atomic_fetch_add)) - return __scoped_atomic_fetch_add(&val, increment, int(mem_ord), - (int)(mem_scope)); - else - return __atomic_fetch_add(&val, increment, int(mem_ord)); +#if __has_builtin(__scoped_atomic_fetch_add) + return __scoped_atomic_fetch_add(&val, increment, int(mem_ord), + (int)(mem_scope)); +#else + return __atomic_fetch_add(&val, increment, int(mem_ord)); +#endif } T fetch_or(T mask, MemoryOrder mem_ord = MemoryOrder::SEQ_CST, [[maybe_unused]] MemoryScope mem_scope = MemoryScope::DEVICE) { - if constexpr (LIBC_HAS_BUILTIN(__scoped_atomic_fetch_or)) - return __scoped_atomic_fetch_or(&val, mask, int(mem_ord), - (int)(mem_scope)); - else - return __atomic_fetch_or(&val, mask, int(mem_ord)); +#if __has_builtin(__scoped_atomic_fetch_or) + return __scoped_atomic_fetch_or(&val, mask, int(mem_ord), (int)(mem_scope)); +#else + return __atomic_fetch_or(&val, mask, int(mem_ord)); +#endif } T fetch_and(T mask, MemoryOrder mem_ord = MemoryOrder::SEQ_CST, [[maybe_unused]] MemoryScope mem_scope = MemoryScope::DEVICE) { - if constexpr (LIBC_HAS_BUILTIN(__scoped_atomic_fetch_and)) - return __scoped_atomic_fetch_and(&val, mask, int(mem_ord), - (int)(mem_scope)); - else - return __atomic_fetch_and(&val, mask, int(mem_ord)); +#if __has_builtin(__scoped_atomic_fetch_and) + return __scoped_atomic_fetch_and(&val, mask, int(mem_ord), + (int)(mem_scope)); +#else + return __atomic_fetch_and(&val, mask, int(mem_ord)); +#endif } T fetch_sub(T decrement, MemoryOrder mem_ord = MemoryOrder::SEQ_CST, [[maybe_unused]] MemoryScope mem_scope = MemoryScope::DEVICE) { - if constexpr (LIBC_HAS_BUILTIN(__scoped_atomic_fetch_sub)) - return __scoped_atomic_fetch_sub(&val, decrement, int(mem_ord), - (int)(mem_scope)); - else - return __atomic_fetch_sub(&val, decrement, int(mem_ord)); +#if __has_builtin(__scoped_atomic_fetch_sub) + return __scoped_atomic_fetch_sub(&val, decrement, int(mem_ord), + (int)(mem_scope)); +#else + return __atomic_fetch_sub(&val, decrement, int(mem_ord)); +#endif } // Set the value without using an atomic operation. This is useful @@ -166,7 +172,7 @@ LIBC_INLINE void atomic_thread_fence([[maybe_unused]] MemoryOrder mem_ord) { // except no instructions for memory ordering are issued. Only reordering of // the instructions by the compiler is suppressed as order instructs. LIBC_INLINE void atomic_signal_fence([[maybe_unused]] MemoryOrder mem_ord) { -#if LIBC_HAS_BUILTIN(__atomic_signal_fence) +#if __has_builtin(__atomic_signal_fence) __atomic_signal_fence(static_cast(mem_ord)); #else // if the builtin is not ready, use asm as a full compiler barrier. diff --git a/libc/src/__support/CPP/bit.h b/libc/src/__support/CPP/bit.h index 3f2fbec944054..17d2e5b26e353 100644 --- a/libc/src/__support/CPP/bit.h +++ b/libc/src/__support/CPP/bit.h @@ -14,14 +14,13 @@ #include "src/__support/CPP/limits.h" // numeric_limits #include "src/__support/CPP/type_traits.h" #include "src/__support/macros/attributes.h" -#include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN #include "src/__support/macros/sanitizer.h" #include namespace LIBC_NAMESPACE::cpp { -#if LIBC_HAS_BUILTIN(__builtin_memcpy_inline) +#if __has_builtin(__builtin_memcpy_inline) #define LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE #endif @@ -36,20 +35,20 @@ LIBC_INLINE constexpr cpp::enable_if_t< To> bit_cast(const From &from) { MSAN_UNPOISON(&from, sizeof(From)); -#if LIBC_HAS_BUILTIN(__builtin_bit_cast) +#if __has_builtin(__builtin_bit_cast) return __builtin_bit_cast(To, from); #else To to; char *dst = reinterpret_cast(&to); const char *src = reinterpret_cast(&from); -#if LIBC_HAS_BUILTIN(__builtin_memcpy_inline) +#if __has_builtin(__builtin_memcpy_inline) __builtin_memcpy_inline(dst, src, sizeof(To)); #else for (unsigned i = 0; i < sizeof(To); ++i) dst[i] = src[i]; -#endif // LIBC_HAS_BUILTIN(__builtin_memcpy_inline) +#endif // __has_builtin(__builtin_memcpy_inline) return to; -#endif // LIBC_HAS_BUILTIN(__builtin_bit_cast) +#endif // __has_builtin(__builtin_bit_cast) } template @@ -94,7 +93,7 @@ countr_zero(T value) { } return zero_bits; } -#if LIBC_HAS_BUILTIN(__builtin_ctzs) +#if __has_builtin(__builtin_ctzs) ADD_SPECIALIZATION(countr_zero, unsigned short, __builtin_ctzs) #endif ADD_SPECIALIZATION(countr_zero, unsigned int, __builtin_ctz) @@ -124,7 +123,7 @@ countl_zero(T value) { } return zero_bits; } -#if LIBC_HAS_BUILTIN(__builtin_clzs) +#if __has_builtin(__builtin_clzs) ADD_SPECIALIZATION(countl_zero, unsigned short, __builtin_clzs) #endif ADD_SPECIALIZATION(countl_zero, unsigned int, __builtin_clz) diff --git a/libc/src/__support/CPP/type_traits/is_destructible.h b/libc/src/__support/CPP/type_traits/is_destructible.h index d47de1cc797b2..f94fe309ac8f7 100644 --- a/libc/src/__support/CPP/type_traits/is_destructible.h +++ b/libc/src/__support/CPP/type_traits/is_destructible.h @@ -16,12 +16,11 @@ #include "src/__support/CPP/type_traits/true_type.h" #include "src/__support/CPP/type_traits/type_identity.h" #include "src/__support/macros/attributes.h" -#include "src/__support/macros/config.h" namespace LIBC_NAMESPACE::cpp { // is_destructible -#if LIBC_HAS_BUILTIN(__is_destructible) +#if __has_builtin(__is_destructible) template struct is_destructible : bool_constant<__is_destructible(T)> {}; #else diff --git a/libc/src/__support/CPP/type_traits/is_function.h b/libc/src/__support/CPP/type_traits/is_function.h index 557b3224484bc..0eba5860ad607 100644 --- a/libc/src/__support/CPP/type_traits/is_function.h +++ b/libc/src/__support/CPP/type_traits/is_function.h @@ -12,12 +12,11 @@ #include "src/__support/CPP/type_traits/is_const.h" #include "src/__support/CPP/type_traits/is_reference.h" #include "src/__support/macros/attributes.h" -#include "src/__support/macros/config.h" namespace LIBC_NAMESPACE::cpp { // is_function -#if LIBC_HAS_BUILTIN(__is_function) +#if __has_builtin(__is_function) template struct is_function : integral_constant {}; #else diff --git a/libc/src/__support/CPP/type_traits/is_lvalue_reference.h b/libc/src/__support/CPP/type_traits/is_lvalue_reference.h index f52e303afad2a..1dff57f186a3a 100644 --- a/libc/src/__support/CPP/type_traits/is_lvalue_reference.h +++ b/libc/src/__support/CPP/type_traits/is_lvalue_reference.h @@ -12,12 +12,11 @@ #include "src/__support/CPP/type_traits/false_type.h" #include "src/__support/CPP/type_traits/true_type.h" #include "src/__support/macros/attributes.h" -#include "src/__support/macros/config.h" namespace LIBC_NAMESPACE::cpp { // is_lvalue_reference -#if LIBC_HAS_BUILTIN(__is_lvalue_reference) +#if __has_builtin(__is_lvalue_reference) template struct is_lvalue_reference : bool_constant<__is_lvalue_reference(T)> {}; #else diff --git a/libc/src/__support/CPP/type_traits/is_reference.h b/libc/src/__support/CPP/type_traits/is_reference.h index c017028edf411..bbfb2b7359c3e 100644 --- a/libc/src/__support/CPP/type_traits/is_reference.h +++ b/libc/src/__support/CPP/type_traits/is_reference.h @@ -12,12 +12,11 @@ #include "src/__support/CPP/type_traits/false_type.h" #include "src/__support/CPP/type_traits/true_type.h" #include "src/__support/macros/attributes.h" -#include "src/__support/macros/config.h" namespace LIBC_NAMESPACE::cpp { // is_reference -#if LIBC_HAS_BUILTIN(__is_reference) +#if __has_builtin(__is_reference) template struct is_reference : bool_constant<__is_reference(T)> {}; #else template struct is_reference : public false_type {}; diff --git a/libc/src/__support/CPP/type_traits/is_rvalue_reference.h b/libc/src/__support/CPP/type_traits/is_rvalue_reference.h index f0487e41c998f..3efbbe6b033a0 100644 --- a/libc/src/__support/CPP/type_traits/is_rvalue_reference.h +++ b/libc/src/__support/CPP/type_traits/is_rvalue_reference.h @@ -12,12 +12,11 @@ #include "src/__support/CPP/type_traits/false_type.h" #include "src/__support/CPP/type_traits/true_type.h" #include "src/__support/macros/attributes.h" -#include "src/__support/macros/config.h" namespace LIBC_NAMESPACE::cpp { // is_rvalue_reference -#if LIBC_HAS_BUILTIN(__is_rvalue_reference) +#if __has_builtin(__is_rvalue_reference) template struct is_rvalue_reference : bool_constant<__is_rvalue_reference(T)> {}; #else diff --git a/libc/src/__support/CPP/type_traits/is_trivially_destructible.h b/libc/src/__support/CPP/type_traits/is_trivially_destructible.h index 3345149433afc..37e0e869266e1 100644 --- a/libc/src/__support/CPP/type_traits/is_trivially_destructible.h +++ b/libc/src/__support/CPP/type_traits/is_trivially_destructible.h @@ -11,12 +11,11 @@ #include "src/__support/CPP/type_traits/bool_constant.h" #include "src/__support/CPP/type_traits/is_destructible.h" #include "src/__support/macros/attributes.h" -#include "src/__support/macros/config.h" namespace LIBC_NAMESPACE::cpp { // is_trivially_destructible -#if LIBC_HAS_BUILTIN(__is_trivially_destructible) +#if __has_builtin(__is_trivially_destructible) template struct is_trivially_destructible : public bool_constant<__is_trivially_destructible(T)> {}; @@ -25,7 +24,7 @@ template struct is_trivially_destructible : public bool_constant &&__has_trivial_destructor( T)> {}; -#endif // LIBC_HAS_BUILTIN(__is_trivially_destructible) +#endif // __has_builtin(__is_trivially_destructible) template LIBC_INLINE_VAR constexpr bool is_trivially_destructible_v = is_trivially_destructible::value; diff --git a/libc/src/__support/CPP/type_traits/remove_all_extents.h b/libc/src/__support/CPP/type_traits/remove_all_extents.h index bff6341d3e456..5941b82bbc161 100644 --- a/libc/src/__support/CPP/type_traits/remove_all_extents.h +++ b/libc/src/__support/CPP/type_traits/remove_all_extents.h @@ -9,14 +9,13 @@ #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H #include "src/__support/CPP/type_traits/type_identity.h" -#include "src/__support/macros/config.h" #include // size_t namespace LIBC_NAMESPACE::cpp { // remove_all_extents -#if LIBC_HAS_BUILTIN(__remove_all_extents) +#if __has_builtin(__remove_all_extents) template using remove_all_extents_t = __remove_all_extents(T); template struct remove_all_extents : cpp::type_identity> {}; diff --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt index 4ded70a675ea8..538d732ad9ebc 100644 --- a/libc/src/__support/FPUtil/CMakeLists.txt +++ b/libc/src/__support/FPUtil/CMakeLists.txt @@ -6,7 +6,6 @@ add_header_library( libc.include.fenv libc.include.math libc.src.__support.macros.attributes - libc.src.__support.macros.config libc.src.errno.errno ) diff --git a/libc/src/__support/FPUtil/FEnvImpl.h b/libc/src/__support/FPUtil/FEnvImpl.h index a6a533dcfdf4a..6086d5d3de2dc 100644 --- a/libc/src/__support/FPUtil/FEnvImpl.h +++ b/libc/src/__support/FPUtil/FEnvImpl.h @@ -11,7 +11,6 @@ #include "include/llvm-libc-macros/math-macros.h" #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN #include "src/__support/macros/properties/architectures.h" #include "src/errno/libc_errno.h" #include diff --git a/libc/src/__support/FPUtil/gpu/FMA.h b/libc/src/__support/FPUtil/gpu/FMA.h index 86bc860314961..ef1cd26a72dd7 100644 --- a/libc/src/__support/FPUtil/gpu/FMA.h +++ b/libc/src/__support/FPUtil/gpu/FMA.h @@ -10,12 +10,12 @@ #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_GPU_FMA_H #include "src/__support/CPP/type_traits.h" -#include "src/__support/macros/config.h" -// These intrinsics map to the FMA instrunctions in the target ISA for the GPU. +// These intrinsics map to the FMA instructions in the target ISA for the GPU. // The default rounding mode generated from these will be to the nearest even. -static_assert(LIBC_HAS_BUILTIN(__builtin_fma), "FMA builtins must be defined"); -static_assert(LIBC_HAS_BUILTIN(__builtin_fmaf), "FMA builtins must be defined"); +#if !__has_builtin(__builtin_fma) || !__has_builtin(__builtin_fmaf) +#error "FMA builtins must be defined"); +#endif namespace LIBC_NAMESPACE { namespace fputil { diff --git a/libc/src/__support/macros/config.h b/libc/src/__support/macros/config.h index fcc8f551a783f..97599566eaa5e 100644 --- a/libc/src/__support/macros/config.h +++ b/libc/src/__support/macros/config.h @@ -13,24 +13,6 @@ #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H #define LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H -// LIBC_HAS_BUILTIN() -// -// Checks whether the compiler supports a Clang Feature Checking Macro, and if -// so, checks whether it supports the provided builtin function "x" where x -// is one of the functions noted in -// https://clang.llvm.org/docs/LanguageExtensions.html -// -// Note: Use this macro to avoid an extra level of #ifdef __has_builtin check. -// http://releases.llvm.org/3.3/tools/clang/docs/LanguageExtensions.html - -// Compiler builtin-detection. -// clang.llvm.org/docs/LanguageExtensions.html#has-builtin -#ifdef __has_builtin -#define LIBC_HAS_BUILTIN(x) __has_builtin(x) -#else -#define LIBC_HAS_BUILTIN(x) 0 -#endif - // Compiler feature-detection. // clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension #ifdef __has_feature diff --git a/libc/src/__support/macros/optimization.h b/libc/src/__support/macros/optimization.h index ae97efcaa4170..59886ca44be12 100644 --- a/libc/src/__support/macros/optimization.h +++ b/libc/src/__support/macros/optimization.h @@ -11,7 +11,6 @@ #define LLVM_LIBC_SRC___SUPPORT_MACROS_OPTIMIZATION_H #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN #include "src/__support/macros/properties/compiler.h" // LIBC_COMPILER_IS_CLANG // We use a template to implement likely/unlikely to make sure that we don't diff --git a/libc/src/__support/macros/sanitizer.h b/libc/src/__support/macros/sanitizer.h index fc66c2005c42d..bd9b62b7121a1 100644 --- a/libc/src/__support/macros/sanitizer.h +++ b/libc/src/__support/macros/sanitizer.h @@ -47,8 +47,7 @@ // Functions to unpoison memory //----------------------------------------------------------------------------- -#if defined(LIBC_HAVE_MEMORY_SANITIZER) && \ - LIBC_HAS_BUILTIN(__builtin_constant_p) +#if defined(LIBC_HAVE_MEMORY_SANITIZER) && __has_builtin(__builtin_constant_p) // Only perform MSAN unpoison in non-constexpr context. #include #define MSAN_UNPOISON(addr, size) \ diff --git a/libc/src/__support/math_extras.h b/libc/src/__support/math_extras.h index 28ee1be8b9999..70a8800b285d0 100644 --- a/libc/src/__support/math_extras.h +++ b/libc/src/__support/math_extras.h @@ -14,7 +14,6 @@ #include "src/__support/CPP/limits.h" // CHAR_BIT, numeric_limits #include "src/__support/CPP/type_traits.h" // is_unsigned_v #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN namespace LIBC_NAMESPACE { @@ -61,7 +60,7 @@ add_with_carry(T a, T b, T carry_in) { return add_with_carry_const(a, b, carry_in); } -#if LIBC_HAS_BUILTIN(__builtin_addc) +#if __has_builtin(__builtin_addc) // https://clang.llvm.org/docs/LanguageExtensions.html#multiprecision-arithmetic-builtins template <> @@ -129,7 +128,7 @@ add_with_carry(unsigned long long a, unsigned long long b, } } -#endif // LIBC_HAS_BUILTIN(__builtin_addc) +#endif // __has_builtin(__builtin_addc) // Subtract with borrow template struct DiffBorrow { @@ -157,7 +156,7 @@ sub_with_borrow(T a, T b, T borrow_in) { return sub_with_borrow_const(a, b, borrow_in); } -#if LIBC_HAS_BUILTIN(__builtin_subc) +#if __has_builtin(__builtin_subc) // https://clang.llvm.org/docs/LanguageExtensions.html#multiprecision-arithmetic-builtins template <> @@ -225,7 +224,7 @@ sub_with_borrow(unsigned long long a, unsigned long long b, } } -#endif // LIBC_HAS_BUILTIN(__builtin_subc) +#endif // __has_builtin(__builtin_subc) template [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t, int> diff --git a/libc/src/__support/memory_size.h b/libc/src/__support/memory_size.h index 7bd16a1695be9..491123bbabf30 100644 --- a/libc/src/__support/memory_size.h +++ b/libc/src/__support/memory_size.h @@ -19,7 +19,7 @@ namespace LIBC_NAMESPACE { namespace internal { template LIBC_INLINE bool mul_overflow(T a, T b, T *res) { -#if LIBC_HAS_BUILTIN(__builtin_mul_overflow) +#if __has_builtin(__builtin_mul_overflow) return __builtin_mul_overflow(a, b, res); #else T max = cpp::numeric_limits::max(); diff --git a/libc/src/string/memory_utils/generic/builtin.h b/libc/src/string/memory_utils/generic/builtin.h index 5239329f653b3..ba4f4b8984088 100644 --- a/libc/src/string/memory_utils/generic/builtin.h +++ b/libc/src/string/memory_utils/generic/builtin.h @@ -10,16 +10,16 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_GENERIC_BUILTIN_H #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN #include "src/string/memory_utils/utils.h" // Ptr, CPtr #include // size_t namespace LIBC_NAMESPACE { -static_assert(LIBC_HAS_BUILTIN(__builtin_memcpy), "Builtin not defined"); -static_assert(LIBC_HAS_BUILTIN(__builtin_memset), "Builtin not defined"); -static_assert(LIBC_HAS_BUILTIN(__builtin_memmove), "Builtin not defined"); +#if !__has_builtin(__builtin_memcpy) || !__has_builtin(__builtin_memset) || \ + !__has_builtin(__builtin_memmove) +#error "Builtin not defined"); +#endif [[maybe_unused]] LIBC_INLINE void inline_memcpy_builtin(Ptr dst, CPtr src, size_t count, size_t offset = 0) { diff --git a/libc/src/string/memory_utils/utils.h b/libc/src/string/memory_utils/utils.h index 79526d19c6b3d..b3e1a26ad9961 100644 --- a/libc/src/string/memory_utils/utils.h +++ b/libc/src/string/memory_utils/utils.h @@ -14,7 +14,6 @@ #include "src/__support/CPP/type_traits.h" #include "src/__support/endian.h" #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN #include "src/__support/macros/properties/architectures.h" #include // size_t @@ -71,11 +70,11 @@ LIBC_INLINE bool is_disjoint(const void *p1, const void *p2, size_t size) { return sdiff >= 0 ? size <= udiff : size <= neg_udiff; } -#if LIBC_HAS_BUILTIN(__builtin_memcpy_inline) +#if __has_builtin(__builtin_memcpy_inline) #define LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE #endif -#if LIBC_HAS_BUILTIN(__builtin_memset_inline) +#if __has_builtin(__builtin_memset_inline) #define LLVM_LIBC_HAS_BUILTIN_MEMSET_INLINE #endif diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel index 0d531a3dc12a7..ea7b625b89a50 100644 --- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel @@ -216,7 +216,6 @@ libc_support_library( ":__support_cpp_limits", ":__support_cpp_type_traits", ":__support_macros_attributes", - ":__support_macros_config", ":__support_macros_sanitizer", ], ) @@ -383,7 +382,6 @@ libc_support_library( ], deps = [ ":__support_macros_attributes", - ":__support_macros_config", ":__support_macros_properties_types", ":llvm_libc_macros_stdfix_macros", ], @@ -660,7 +658,6 @@ libc_support_library( ":__support_cpp_limits", ":__support_cpp_type_traits", ":__support_macros_attributes", - ":__support_macros_config", ], ) @@ -2318,7 +2315,6 @@ libc_support_library( ":__support_cpp_cstddef", ":__support_cpp_type_traits", ":__support_macros_attributes", - ":__support_macros_config", ":__support_macros_optimization", ":__support_macros_properties_architectures", ":__support_macros_properties_cpu_features",