summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2020-01-08 23:59:40 +0700
committerEugene Kosov <claprix@yandex.ru>2020-01-14 02:16:33 +0700
commit1536afd3f4b0c8fab3d89d67ded74680749eead1 (patch)
treea6a8f3dd5cfc4045dc7c45793f7749a400baddf9
parent2ccb888b4203922e257956cbb6bde643b90d2ab7 (diff)
downloadmariadb-git-bb-10.2-release-kevgs.tar.gz
MDEV-20377 fix build for CRC32bb-10.2-release-kevgs
-rw-r--r--storage/innobase/innodb.cmake19
-rw-r--r--storage/innobase/ut/ut0crc32.cc28
2 files changed, 28 insertions, 19 deletions
diff --git a/storage/innobase/innodb.cmake b/storage/innobase/innodb.cmake
index 01048e9c4e8..724b2c78598 100644
--- a/storage/innobase/innodb.cmake
+++ b/storage/innobase/innodb.cmake
@@ -273,6 +273,25 @@ IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND CMAKE_SYSTEM_PROCESSOR MATCHES "i386")
ENDIF()
IF(MSVC)
+ ADD_DEFINITIONS(-DHAVE_SSE42)
+ELSE()
+ SET(CMAKE_REQUIRED_FLAGS "-msse4.2")
+ CHECK_CXX_SOURCE_COMPILES("
+ #include <nmmintrin.h>
+ int main()
+ {
+ (void) _mm_crc32_u32(0, 0);
+ return 0;
+ }
+ " HAVE_SSE42)
+ UNSET(CMAKE_REQUIRED_FLAGS)
+ IF(HAVE_SSE42)
+ SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/ut/ut0crc32.cc
+ PROPERTIES COMPILE_FLAGS "-DHAVE_SSE42 -msse4.2")
+ ENDIF()
+ENDIF()
+
+IF(MSVC)
# Avoid "unreferenced label" warning in generated file
GET_FILENAME_COMPONENT(_SRC_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
SET_SOURCE_FILES_PROPERTIES(${_SRC_DIR}/pars/pars0grm.c
diff --git a/storage/innobase/ut/ut0crc32.cc b/storage/innobase/ut/ut0crc32.cc
index 223e69cd12c..c0ffc1a3e65 100644
--- a/storage/innobase/ut/ut0crc32.cc
+++ b/storage/innobase/ut/ut0crc32.cc
@@ -136,7 +136,7 @@ ut_crc32_power8(
}
#endif
-#if (defined(__GNUC__) && defined(__x86_64__)) || defined(_MSC_VER)
+#ifdef HAVE_SSE42
/********************************************************************//**
Fetches CPU info */
static
@@ -187,6 +187,8 @@ ut_cpuid(
}
}
+#include <nmmintrin.h>
+
/** Calculate CRC32 over 8-bit data using a hardware/CPU instruction.
@param[in,out] crc crc32 checksum so far when this function is called,
when the function ends it will contain the new checksum
@@ -200,11 +202,7 @@ ut_crc32_8_hw(
const byte** data,
ulint* len)
{
-#ifdef _MSC_VER
*crc = _mm_crc32_u8(*crc, (*data)[0]);
-#else
- *crc = __builtin_ia32_crc32qi(*crc, (*data)[0]);
-#endif
(*data)++;
(*len)--;
@@ -220,19 +218,11 @@ ut_crc32_64_low_hw(
uint32_t crc,
uint64_t data)
{
-#ifdef _MSC_VER
- uint64_t crc_64bit = crc;
-#ifdef _M_X64
- crc_64bit = _mm_crc32_u64(crc_64bit, data);
-#elif defined(_M_IX86)
- crc = _mm_crc32_u32(crc, static_cast<uint32_t>(data));
- crc_64bit = _mm_crc32_u32(crc, static_cast<uint32_t>(data >> 32));
-#else
-#error Not Supported processors type.
-#endif
- return(static_cast<uint32_t>(crc_64bit));
+#if SIZEOF_VOIDP == 8
+ return static_cast<uint32_t>(_mm_crc32_u64(crc, data));
#else
- return static_cast<uint32_t>(__builtin_ia32_crc32di(crc, data));
+ crc = _mm_crc32_u32(crc, static_cast<uint32_t>(data));
+ return _mm_crc32_u32(crc, static_cast<uint32_t>(data >> 32));
#endif
}
@@ -438,7 +428,7 @@ ut_crc32_legacy_big_endian_hw(
return(~crc);
}
# endif /* INNODB_BUG_ENDIAN_CRC32 */
-#endif /* defined(__GNUC__) && defined(__x86_64__) || (_WIN64) */
+#endif
/* CRC32 software implementation. */
@@ -696,7 +686,7 @@ ut_crc32_init()
#endif /* INNODB_BUG_ENDIAN_CRC32 */
ut_crc32_implementation = "Using generic crc32 instructions";
-#if (defined(__GNUC__) && defined(__x86_64__)) || defined(_MSC_VER)
+#ifdef HAVE_SSE42
uint32_t vend[3];
uint32_t model;
uint32_t family;