[libc-commits] [libc] 6a4f842 - [libc] Only use __has_builtin on clang

Alex Brachet via libc-commits libc-commits at lists.llvm.org
Sat Mar 28 09:29:15 PDT 2020


Author: Alex Brachet
Date: 2020-03-28T12:28:43-04:00
New Revision: 6a4f8423ae681c4feb7481b9c7e222cc6cdb2c45

URL: https://github.com/llvm/llvm-project/commit/6a4f8423ae681c4feb7481b9c7e222cc6cdb2c45
DIFF: https://github.com/llvm/llvm-project/commit/6a4f8423ae681c4feb7481b9c7e222cc6cdb2c45.diff

LOG: [libc] Only use __has_builtin on clang

The preprocessor reads the whole line even if the first condition of an and is false so this broke when compiling on older gcc versions which don't recognize `__has_builtin`

Added: 
    

Modified: 
    libc/src/string/memory_utils/memcpy_utils.h

Removed: 
    


################################################################################
diff  --git a/libc/src/string/memory_utils/memcpy_utils.h b/libc/src/string/memory_utils/memcpy_utils.h
index 7975d474d2f6..f6f283e3730d 100644
--- a/libc/src/string/memory_utils/memcpy_utils.h
+++ b/libc/src/string/memory_utils/memcpy_utils.h
@@ -14,8 +14,10 @@
 
 // __builtin_memcpy_inline guarantees to never call external functions.
 // Unfortunately it is not widely available.
-#if defined(__clang__) && __has_builtin(__builtin_memcpy_inline)
+#ifdef __clang__
+#if __has_builtin(__builtin_memcpy_inline)
 #define USE_BUILTIN_MEMCPY_INLINE
+#endif
 #elif defined(__GNUC__)
 #define USE_BUILTIN_MEMCPY
 #endif


        


More information about the libc-commits mailing list