[libc][NFC] Rename compiler_feature macros
authorGuillaume Chatelet <gchatelet@google.com>
Tue, 7 Feb 2023 11:05:53 +0000 (11:05 +0000)
committerGuillaume Chatelet <gchatelet@google.com>
Tue, 7 Feb 2023 11:13:43 +0000 (11:13 +0000)
12 files changed:
libc/src/__support/CPP/bit.h
libc/src/__support/builtin_wrappers.h
libc/src/__support/macros/compiler_features.h
libc/src/__support/macros/sanitizer.h
libc/src/string/memory_utils/bcmp_implementations.h
libc/src/string/memory_utils/memcmp_implementations.h
libc/src/string/memory_utils/memcpy_implementations.h
libc/src/string/memory_utils/memmove_implementations.h
libc/src/string/memory_utils/memset_implementations.h
libc/src/string/memory_utils/op_generic.h
libc/src/string/memory_utils/utils.h
libc/test/src/string/memory_utils/memory_check_utils.h

index 8af0976..7424f96 100644 (file)
 
 namespace __llvm_libc::cpp {
 
-#if LLVM_LIBC_HAS_BUILTIN(__builtin_bit_cast)
+#if LIBC_HAS_BUILTIN(__builtin_bit_cast)
 #define LLVM_LIBC_HAS_BUILTIN_BIT_CAST
 #endif
 
-#if LLVM_LIBC_HAS_BUILTIN(__builtin_memcpy_inline)
+#if LIBC_HAS_BUILTIN(__builtin_memcpy_inline)
 #define LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE
 #endif
 
index c28d2ad..a3cd1f9 100644 (file)
@@ -84,7 +84,7 @@ add_with_carry(T a, T b, T carry_in) {
   return {sum, carry_out};
 }
 
-#if LLVM_LIBC_HAS_BUILTIN(__builtin_addc)
+#if LIBC_HAS_BUILTIN(__builtin_addc)
 // https://clang.llvm.org/docs/LanguageExtensions.html#multiprecision-arithmetic-builtins
 
 template <>
@@ -132,7 +132,7 @@ add_with_carry<unsigned long long>(unsigned long long a, unsigned long long b,
   return result;
 }
 
-#endif // LLVM_LIBC_HAS_BUILTIN(__builtin_addc)
+#endif // LIBC_HAS_BUILTIN(__builtin_addc)
 
 // Subtract with borrow
 DEFINE_NAMED_PAIR_TEMPLATE(DiffBorrow, diff, borrow);
@@ -147,7 +147,7 @@ sub_with_borrow(T a, T b, T borrow_in) {
   return {diff, borrow_out};
 }
 
-#if LLVM_LIBC_HAS_BUILTIN(__builtin_subc)
+#if LIBC_HAS_BUILTIN(__builtin_subc)
 // https://clang.llvm.org/docs/LanguageExtensions.html#multiprecision-arithmetic-builtins
 
 template <>
@@ -195,7 +195,7 @@ sub_with_borrow<unsigned long long>(unsigned long long a, unsigned long long b,
   return result;
 }
 
-#endif // LLVM_LIBC_HAS_BUILTIN(__builtin_subc)
+#endif // LIBC_HAS_BUILTIN(__builtin_subc)
 
 } // namespace __llvm_libc
 
index 04c1bbd..720afe9 100644 (file)
 // clang.llvm.org/docs/LanguageExtensions.html#has-builtin
 #if defined(LIBC_COMPILER_IS_CLANG) ||                                       \
     (defined(LIBC_COMPILER_IS_GCC) && (__GNUC__ >= 10))
-#define LLVM_LIBC_HAS_BUILTIN(BUILTIN) __has_builtin(BUILTIN)
+#define LIBC_HAS_BUILTIN(BUILTIN) __has_builtin(BUILTIN)
 #else
-#define LLVM_LIBC_HAS_BUILTIN(BUILTIN) 0
+#define LIBC_HAS_BUILTIN(BUILTIN) 0
 #endif
 
 // Compiler feature-detection.
 // clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension
 #if defined(LIBC_COMPILER_IS_CLANG)
-#define LLVM_LIBC_HAS_FEATURE(FEATURE) __has_feature(FEATURE)
+#define LIBC_HAS_FEATURE(FEATURE) __has_feature(FEATURE)
 #else
-#define LLVM_LIBC_HAS_FEATURE(FEATURE) 0
+#define LIBC_HAS_FEATURE(FEATURE) 0
 #endif
 
 #if defined(LIBC_COMPILER_IS_CLANG)
-#define LLVM_LIBC_LOOP_NOUNROLL _Pragma("nounroll")
+#define LIBC_LOOP_NOUNROLL _Pragma("nounroll")
 #elif defined(LIBC_COMPILER_IS_GCC)
-#define LLVM_LIBC_LOOP_NOUNROLL _Pragma("GCC unroll 0")
+#define LIBC_LOOP_NOUNROLL _Pragma("GCC unroll 0")
 #else
-#define LLVM_LIBC_LOOP_NOUNROLL
+#define LIBC_LOOP_NOUNROLL
 #endif
 
 #endif // LLVM_LIBC_SUPPORT_MACROS_COMPILER_FEATURES_H
index 5337c08..118dfb8 100644 (file)
@@ -22,7 +22,7 @@
 #ifdef LIBC_HAVE_MEMORY_SANITIZER
 #error "LIBC_HAVE_MEMORY_SANITIZER cannot be directly set."
 #elif defined(MEMORY_SANITIZER) || defined(__SANITIZE_MEMORY__) ||             \
-    (LLVM_LIBC_HAS_FEATURE(memory_sanitizer) && !defined(__native_client__))
+    (LIBC_HAS_FEATURE(memory_sanitizer) && !defined(__native_client__))
 #define LIBC_HAVE_MEMORY_SANITIZER
 #endif
 
 #ifdef LIBC_HAVE_ADDRESS_SANITIZER
 #error "LIBC_HAVE_ADDRESS_SANITIZER cannot be directly set."
 #elif defined(ADDRESS_SANITIZER) || defined(__SANITIZE_ADDRESS__) ||           \
-    LLVM_LIBC_HAS_FEATURE(address_sanitizer)
+    LIBC_HAS_FEATURE(address_sanitizer)
 #define LIBC_HAVE_ADDRESS_SANITIZER
 #endif
 
 // HWAddressSanitizer (HWASan) is a fast, low memory overhead error detector.
 #ifdef LIBC_HAVE_HWADDRESS_SANITIZER
 #error "LIBC_HAVE_HWADDRESS_SANITIZER cannot be directly set."
-#elif LLVM_LIBC_HAS_FEATURE(hwaddress_sanitizer)
+#elif LIBC_HAS_FEATURE(hwaddress_sanitizer)
 #define LIBC_HAVE_HWADDRESS_SANITIZER
 #endif
 
index f3622dd..6d445fb 100644 (file)
@@ -22,7 +22,7 @@ namespace __llvm_libc {
 
 [[maybe_unused]] LIBC_INLINE BcmpReturnType
 inline_bcmp_embedded_tiny(CPtr p1, CPtr p2, size_t count) {
-  LLVM_LIBC_LOOP_NOUNROLL
+  LIBC_LOOP_NOUNROLL
   for (size_t offset = 0; offset < count; ++offset)
     if (auto value = generic::Bcmp<1>::block(p1 + offset, p2 + offset))
       return value;
index e9fed02..834dda0 100644 (file)
@@ -22,7 +22,7 @@
 namespace __llvm_libc {
 [[maybe_unused]] LIBC_INLINE MemcmpReturnType
 inline_memcmp_embedded_tiny(CPtr p1, CPtr p2, size_t count) {
-  LLVM_LIBC_LOOP_NOUNROLL
+  LIBC_LOOP_NOUNROLL
   for (size_t offset = 0; offset < count; ++offset)
     if (auto value = generic::Memcmp<1>::block(p1 + offset, p2 + offset))
       return value;
index 7af309f..b84e520 100644 (file)
@@ -24,7 +24,7 @@ namespace __llvm_libc {
 [[maybe_unused]] LIBC_INLINE void
 inline_memcpy_embedded_tiny(Ptr __restrict dst, CPtr __restrict src,
                             size_t count) {
-  LLVM_LIBC_LOOP_NOUNROLL
+  LIBC_LOOP_NOUNROLL
   for (size_t offset = 0; offset < count; ++offset)
     builtin::Memcpy<1>::block(dst + offset, src + offset);
 }
index d6b7e63..ea068c1 100644 (file)
@@ -23,11 +23,11 @@ inline_memmove_embedded_tiny(Ptr dst, CPtr src, size_t count) {
   if ((count == 0) || (dst == src))
     return;
   if (dst < src) {
-    LLVM_LIBC_LOOP_NOUNROLL
+    LIBC_LOOP_NOUNROLL
     for (size_t offset = 0; offset < count; ++offset)
       builtin::Memcpy<1>::block(dst + offset, src + offset);
   } else {
-    LLVM_LIBC_LOOP_NOUNROLL
+    LIBC_LOOP_NOUNROLL
     for (ptrdiff_t offset = count - 1; offset >= 0; --offset)
       builtin::Memcpy<1>::block(dst + offset, src + offset);
   }
index 2640bd2..b318efd 100644 (file)
@@ -23,7 +23,7 @@ namespace __llvm_libc {
 
 [[maybe_unused]] LIBC_INLINE static void
 inline_memset_embedded_tiny(Ptr dst, uint8_t value, size_t count) {
-  LLVM_LIBC_LOOP_NOUNROLL
+  LIBC_LOOP_NOUNROLL
   for (size_t offset = 0; offset < count; ++offset)
     generic::Memset<1, 1>::block(dst + offset, value);
 }
index 7d827fd..20cba82 100644 (file)
@@ -470,7 +470,7 @@ template <size_t Size, size_t MaxSize> struct Memmove {
     const size_t tail_offset = count - Size;
     const auto tail_value = T::load(src + tail_offset);
     size_t offset = 0;
-    LLVM_LIBC_LOOP_NOUNROLL
+    LIBC_LOOP_NOUNROLL
     do {
       block(dst + offset, src + offset);
       offset += Size;
@@ -497,7 +497,7 @@ template <size_t Size, size_t MaxSize> struct Memmove {
     static_assert(Size > 1, "a loop of size 1 does not need tail");
     const auto head_value = T::load(src);
     ptrdiff_t offset = count - Size;
-    LLVM_LIBC_LOOP_NOUNROLL
+    LIBC_LOOP_NOUNROLL
     do {
       block(dst + offset, src + offset);
       offset -= Size;
index d83cd0c..57c1dac 100644 (file)
@@ -82,11 +82,11 @@ template <size_t alignment, typename T> static T *assume_aligned(T *ptr) {
   return reinterpret_cast<T *>(__builtin_assume_aligned(ptr, alignment));
 }
 
-#if LLVM_LIBC_HAS_BUILTIN(__builtin_memcpy_inline)
+#if LIBC_HAS_BUILTIN(__builtin_memcpy_inline)
 #define LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE
 #endif
 
-#if LLVM_LIBC_HAS_BUILTIN(__builtin_memset_inline)
+#if LIBC_HAS_BUILTIN(__builtin_memset_inline)
 #define LLVM_LIBC_HAS_BUILTIN_MEMSET_INLINE
 #endif
 
index f548a1f..883537d 100644 (file)
@@ -17,7 +17,7 @@
 #include <stdint.h> // uintxx_t
 #include <stdlib.h> // malloc/free
 
-#if LLVM_LIBC_HAS_FEATURE(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
+#if LIBC_HAS_FEATURE(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
 #include <sanitizer/asan_interface.h>
 #define ASAN_POISON_MEMORY_REGION(addr, size)                                  \
   __asan_poison_memory_region((addr), (size))