summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralkis <alkis@google.com>2017-06-02 10:21:49 -0700
committerVictor Costan <pwnall@chromium.org>2017-06-05 13:54:17 -0700
commit7b9532b8781c5beaf99eef8ca7535d969a129d78 (patch)
treead803b04bba46196c09abe4fe83b69dcd873b5a1
parent7dadceea528fcaf33af7f2cf8322d8789e4e9b1d (diff)
downloadsnappy-7b9532b8781c5beaf99eef8ca7535d969a129d78.tar.gz
snappy-7b9532b8781c5beaf99eef8ca7535d969a129d78.tar.bz2
snappy-7b9532b8781c5beaf99eef8ca7535d969a129d78.zip
Improve the SSE2 macro check on Windows.
This lands https://github.com/google/snappy/pull/37
-rw-r--r--snappy.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/snappy.cc b/snappy.cc
index 90c0787..8bb5d23 100644
--- a/snappy.cc
+++ b/snappy.cc
@@ -30,7 +30,16 @@
#include "snappy-internal.h"
#include "snappy-sinksource.h"
-#ifdef __SSE2__
+#ifndef SNAPPY_HAVE_SSE2
+#if defined(__SSE2__) || defined(_M_X64) || \
+ (defined(_M_IX86_FP) && _M_IX86_FP >= 2)
+#define SNAPPY_HAVE_SSE2 1
+#else
+#define SNAPPY_HAVE_SSE2 0
+#endif
+#endif
+
+#if SNAPPY_HAVE_SSE2
#include <emmintrin.h>
#endif
#include <stdio.h>
@@ -96,7 +105,7 @@ void UnalignedCopy64(const void* src, void* dst) {
void UnalignedCopy128(const void* src, void* dst) {
// TODO(alkis): Remove this when we upgrade to a recent compiler that emits
// SSE2 moves for memcpy(dst, src, 16).
-#ifdef __SSE2__
+#if SNAPPY_HAVE_SSE2
__m128i x = _mm_loadu_si128(static_cast<const __m128i*>(src));
_mm_storeu_si128(static_cast<__m128i*>(dst), x);
#else