Limit use of hardware crc32 check to SSE 4.2
authorDaniel M. Weeks <dan@danweeks.net>
Mon, 17 Aug 2015 17:40:12 +0000 (10:40 -0700)
committerfacebook-github-bot-1 <folly-bot@fb.com>
Mon, 17 Aug 2015 18:20:28 +0000 (11:20 -0700)
Summary: Fixes compiling crc32c function on older hardware. (I believe this problem was introduced by 7ec1fc0e0e27ed56c1d18d33af9711a17e9ec750).

Also ensures is in final library since the API suggests it should be. This should correct a number of build problems for other projects like wdt and hhvm when they are compiled using a shared folly library rather than borrowing sources at compile time.
Closes #296

Reviewed By: @yfeldblum

Differential Revision: D2340699

Pulled By: @sgolemon

folly/Checksum.cpp
folly/Makefile.am

index a7afa352b8a789eac91c23725b9983032f89c67e..d8daf66fcd11bd55efebb48403a2b7cba047d9ab 100644 (file)
@@ -29,10 +29,11 @@ namespace detail {
   #define __has_builtin(x) 0
 #endif
 
   #define __has_builtin(x) 0
 #endif
 
-#if (__has_builtin(__builtin_ia32_crc32qi) && \
+#if __SSE4_2__ && \
+    ((__has_builtin(__builtin_ia32_crc32qi) && \
      __has_builtin(__builtin_ia32_crc32di)) || \
     (FOLLY_X64 && defined(__GNUC__) && defined(__GNUC_MINOR__) && \
      __has_builtin(__builtin_ia32_crc32di)) || \
     (FOLLY_X64 && defined(__GNUC__) && defined(__GNUC_MINOR__) && \
-     (((__GNUC__ * 100) + __GNUC_MINOR__) >= 407))
+     (((__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,
 
 // Fast SIMD implementation of CRC-32C for x86 with SSE 4.2
 uint32_t crc32c_hw(const uint8_t *data, size_t nbytes,
index 6fe63d0b22bafe0468877a6458a40827986ad9d9..ffc9aef033c0ab3a082f0ba99a04698158a66be5 100644 (file)
@@ -310,6 +310,7 @@ libfollybase_la_SOURCES = \
 
 libfolly_la_SOURCES = \
        Bits.cpp \
 
 libfolly_la_SOURCES = \
        Bits.cpp \
+       Checksum.cpp \
        detail/CacheLocality.cpp \
        dynamic.cpp \
        File.cpp \
        detail/CacheLocality.cpp \
        dynamic.cpp \
        File.cpp \