Clang Love
authorDarren Mo <dmo@fb.com>
Sun, 17 Aug 2014 00:32:54 +0000 (17:32 -0700)
committerSara Golemon <sgolemon@fb.com>
Tue, 9 Sep 2014 21:22:22 +0000 (14:22 -0700)
Summary: Added support for clang in Checksum.cpp preprocessor statements.

Test Plan: The right code path is chosen using both gcc and clang now.

Reviewed By: brianp@fb.com

Subscribers: mathieubaudet, sroy, satadru

FB internal diff: D1502289

folly/Checksum.cpp

index 3882a6e8c13f28951aaa7b728ecc3c30410ace59..881fc7d20ff1ff3aa483319c4d290e5fd585e153 100644 (file)
@@ -24,8 +24,14 @@ namespace folly {
 
 namespace detail {
 
-#if FOLLY_X64 && defined(__GNUC__) && defined(__GNUC_MINOR__) && \
-    (((__GNUC__ * 100) + __GNUC_MINOR__) >= 407)
+#ifndef __has_builtin
+  #define __has_builtin(x) 0
+#endif
+
+#if (__has_builtin(__builtin_ia32_crc32qi) && \
+     __has_builtin(__builtin_ia32_crc32di)) || \
+    (FOLLY_X64 && defined(__GNUC__) && defined(__GNUC_MINOR__) && \
+     (((__GNUC__ * 100) + __GNUC_MINOR__) >= 407))
 
 // Fast SIMD implementation of CRC-32C for x86 with SSE 4.2
 uint32_t crc32c_hw(const uint8_t *data, size_t nbytes,