aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-02-06 17:04:30 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-02-06 17:04:30 +0000
commit84a551b5fb0d3c052b7f06a46400cc841ebba7c0 (patch)
tree134411f8c24c5fa27932ab3b849bec7636b34e1a
parentceb87422adb1d3cc36a7e4de9c728299c31f465a (diff)
downloadrspamd-84a551b5fb0d3c052b7f06a46400cc841ebba7c0.tar.gz
rspamd-84a551b5fb0d3c052b7f06a46400cc841ebba7c0.zip
[Minor] Add sse42 support
-rw-r--r--src/libcryptobox/CMakeLists.txt2
-rw-r--r--src/libcryptobox/cryptobox.c16
-rw-r--r--src/libcryptobox/cryptobox.h3
-rw-r--r--src/libcryptobox/platform_config.h.in1
4 files changed, 21 insertions, 1 deletions
diff --git a/src/libcryptobox/CMakeLists.txt b/src/libcryptobox/CMakeLists.txt
index 165f9b40f..9cca1b694 100644
--- a/src/libcryptobox/CMakeLists.txt
+++ b/src/libcryptobox/CMakeLists.txt
@@ -52,6 +52,8 @@ IF("${ARCH}" STREQUAL "x86_64")
ASM_OP(HAVE_SSSE3 "ssse3")
SET(ASM_CODE "pblendw \$0, %xmm0, %xmm0")
ASM_OP(HAVE_SSE41 "sse41")
+ SET(ASM_CODE "crc32 %eax, %eax")
+ ASM_OP(HAVE_SSE42 "sse42")
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
SET(POLYSRC ${POLYSRC} ${CMAKE_CURRENT_SOURCE_DIR}/poly1305/ref-64.c)
diff --git a/src/libcryptobox/cryptobox.c b/src/libcryptobox/cryptobox.c
index c4d20f9a4..d0f89e37b 100644
--- a/src/libcryptobox/cryptobox.c
+++ b/src/libcryptobox/cryptobox.c
@@ -177,6 +177,14 @@ rspamd_cryptobox_test_instr (gint instr)
__asm__ volatile ("pcmpeqq %xmm0, %xmm0");
break;
#endif
+#ifdef HAVE_SSE42
+ case CPUID_SSE42:
+ __asm__ volatile ("pushq %rax\n"
+ "xorq %rax, %rax\n"
+ "crc32 %rax, %rax\n"
+ "popq %rax");
+ break;
+#endif
#ifdef HAVE_AVX
case CPUID_AVX:
__asm__ volatile ("vpaddq %xmm0, %xmm0, %xmm0");
@@ -243,6 +251,11 @@ rspamd_cryptobox_init (void)
cpu_config |= CPUID_SSE41;
}
}
+ if ((cpu[2] & ((guint32)1 << 20))) {
+ if (rspamd_cryptobox_test_instr (CPUID_SSE42)) {
+ cpu_config |= CPUID_SSE42;
+ }
+ }
if ((cpu[2] & ((guint32)1 << 30))) {
if (rspamd_cryptobox_test_instr (CPUID_RDRAND)) {
cpu_config |= CPUID_RDRAND;
@@ -287,6 +300,9 @@ rspamd_cryptobox_init (void)
case CPUID_SSE41:
rspamd_printf_gstring (buf, "sse4.1, ");
break;
+ case CPUID_SSE42:
+ rspamd_printf_gstring (buf, "sse4.2, ");
+ break;
case CPUID_AVX:
rspamd_printf_gstring (buf, "avx, ");
break;
diff --git a/src/libcryptobox/cryptobox.h b/src/libcryptobox/cryptobox.h
index 3ae7679d0..601b2e505 100644
--- a/src/libcryptobox/cryptobox.h
+++ b/src/libcryptobox/cryptobox.h
@@ -42,7 +42,8 @@ struct rspamd_cryptobox_segment {
#define CPUID_SSE3 0x8
#define CPUID_SSSE3 0x10
#define CPUID_SSE41 0x20
-#define CPUID_RDRAND 0x40
+#define CPUID_SSE42 0x40
+#define CPUID_RDRAND 0x80
typedef guchar rspamd_pk_t[rspamd_cryptobox_MAX_PKBYTES];
typedef guchar rspamd_sk_t[rspamd_cryptobox_MAX_SKBYTES];
diff --git a/src/libcryptobox/platform_config.h.in b/src/libcryptobox/platform_config.h.in
index 0eba7cf50..7b7d17d50 100644
--- a/src/libcryptobox/platform_config.h.in
+++ b/src/libcryptobox/platform_config.h.in
@@ -7,6 +7,7 @@
#cmakedefine HAVE_AVX 1
#cmakedefine HAVE_SSE2 1
#cmakedefine HAVE_SSE41 1
+#cmakedefine HAVE_SSE42 1
#cmakedefine HAVE_SSE3 1
#cmakedefine HAVE_SSSE3 1
#cmakedefine HAVE_SLASHMACRO 1