Created
May 15, 2017 17:05
-
-
Save mariuz/753f6fce7ebe0ac9bcf2cb26905c1cc1 to your computer and use it in GitHub Desktop.
Fix firebird crc32c compilation withot msse4 compiler flag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/builds/posix/prefix.linux b/builds/posix/prefix.linux | |
index 56d1529570..e0bb64150e 100644 | |
--- a/builds/posix/prefix.linux | |
+++ b/builds/posix/prefix.linux | |
@@ -26,7 +26,4 @@ PROD_FLAGS=$(COMMON_FLAGS) $(OPTIMIZE_FLAGS) | |
#DEV_FLAGS=-DUSE_VALGRIND -p $(COMMON_FLAGS) $(WARN_FLAGS) | |
DEV_FLAGS=-p $(COMMON_FLAGS) $(WARN_FLAGS) | |
-# This file must be compiled with SSE4.2 support | |
-%/CRC32C.o: COMMON_FLAGS += -msse4 | |
- | |
CXXFLAGS := $(CXXFLAGS) -std=c++11 | |
diff --git a/builds/posix/prefix.linux_amd64 b/builds/posix/prefix.linux_amd64 | |
index 394286f334..c4ccbb14f6 100644 | |
--- a/builds/posix/prefix.linux_amd64 | |
+++ b/builds/posix/prefix.linux_amd64 | |
@@ -26,7 +26,4 @@ PROD_FLAGS=$(COMMON_FLAGS) $(OPTIMIZE_FLAGS) | |
#DEV_FLAGS=-DUSE_VALGRIND $(COMMON_FLAGS) $(WARN_FLAGS) -fmax-errors=8 | |
DEV_FLAGS=$(COMMON_FLAGS) $(WARN_FLAGS) -fmax-errors=8 | |
-# This file must be compiled with SSE4.2 support | |
-%/CRC32C.o: COMMON_FLAGS += -msse4 | |
- | |
CXXFLAGS := $(CXXFLAGS) -std=c++11 | |
diff --git a/src/common/CRC32C.cpp b/src/common/CRC32C.cpp | |
index 9630b4ab7a..2808109d45 100644 | |
--- a/src/common/CRC32C.cpp | |
+++ b/src/common/CRC32C.cpp | |
@@ -31,8 +31,15 @@ | |
// WARNING: With GCC must be compiled separately with -msse4.2 flag | |
#if defined(_M_IX86) || defined(_M_X64) || defined(__x86_64__) || defined(__i386__) | |
-#include <nmmintrin.h> | |
+#if defined(_MSC_VER) | |
+ /* Microsoft C/C++-compatible compiler */ | |
+ #include <intrin.h> | |
+#elif defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__)) | |
+ /* GCC-compatible compiler, targeting x86/x86-64 */ | |
+ #include <x86intrin.h> | |
+#endif | |
+__attribute__((target("sse4.2"))) | |
unsigned int CRC32C(unsigned int length, const unsigned char* value) | |
{ | |
unsigned int hash_value = 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment