1 change: 0 additions & 1 deletion libc/src/__support/macros/optimization.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions libc/src/__support/macros/sanitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sanitizer/msan_interface.h>
#define MSAN_UNPOISON(addr, size) \
Expand Down
9 changes: 4 additions & 5 deletions libc/src/__support/math_extras.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -61,7 +60,7 @@ add_with_carry(T a, T b, T carry_in) {
return add_with_carry_const<T>(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 <>
Expand Down Expand Up @@ -129,7 +128,7 @@ add_with_carry<unsigned long long>(unsigned long long a, unsigned long long b,
}
}

#endif // LIBC_HAS_BUILTIN(__builtin_addc)
#endif // __has_builtin(__builtin_addc)

// Subtract with borrow
template <typename T> struct DiffBorrow {
Expand Down Expand Up @@ -157,7 +156,7 @@ sub_with_borrow(T a, T b, T borrow_in) {
return sub_with_borrow_const<T>(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 <>
Expand Down Expand Up @@ -225,7 +224,7 @@ sub_with_borrow<unsigned long long>(unsigned long long a, unsigned long long b,
}
}

#endif // LIBC_HAS_BUILTIN(__builtin_subc)
#endif // __has_builtin(__builtin_subc)

template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
Expand Down
2 changes: 1 addition & 1 deletion libc/src/__support/memory_size.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace LIBC_NAMESPACE {
namespace internal {
template <class T> 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<T>::max();
Expand Down
8 changes: 4 additions & 4 deletions libc/src/string/memory_utils/generic/builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stddef.h> // 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) {
Expand Down
5 changes: 2 additions & 3 deletions libc/src/string/memory_utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stddef.h> // size_t
Expand Down Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions libc/utils/gpu/server/rpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
//
//===----------------------------------------------------------------------===//

// Workaround for missing __has_builtin in < GCC 10.
#ifndef __has_builtin
#define __has_builtin(x) 0
#endif

#include "llvmlibc_rpc_server.h"

#include "src/__support/RPC/rpc.h"
Expand Down
4 changes: 0 additions & 4 deletions utils/bazel/llvm-project-overlay/libc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ libc_support_library(
":__support_cpp_limits",
":__support_cpp_type_traits",
":__support_macros_attributes",
":__support_macros_config",
":__support_macros_sanitizer",
],
)
Expand Down Expand Up @@ -383,7 +382,6 @@ libc_support_library(
],
deps = [
":__support_macros_attributes",
":__support_macros_config",
":__support_macros_properties_types",
":llvm_libc_macros_stdfix_macros",
],
Expand Down Expand Up @@ -663,7 +661,6 @@ libc_support_library(
":__support_cpp_limits",
":__support_cpp_type_traits",
":__support_macros_attributes",
":__support_macros_config",
],
)

Expand Down Expand Up @@ -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",
Expand Down