]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add sse42 support
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 6 Feb 2017 17:04:30 +0000 (17:04 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 6 Feb 2017 17:04:30 +0000 (17:04 +0000)
src/libcryptobox/CMakeLists.txt
src/libcryptobox/cryptobox.c
src/libcryptobox/cryptobox.h
src/libcryptobox/platform_config.h.in

index 165f9b40f3e7b8f1321be0160a22519a93def697..9cca1b69416c7e190981c860bfcd6695d87efdf9 100644 (file)
@@ -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)
index c4d20f9a43e620022a49d070da40378c5c9c1684..d0f89e37b9c0dcef898d14660b58478677b93648 100644 (file)
@@ -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;
index 3ae7679d03a1d5803e5f50a639e7f275c7f0fff6..601b2e5052bf2318cec2683bc17030bf5ef39851 100644 (file)
@@ -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];
index 0eba7cf50992b3b7dca43cee4190b49e512f9927..7b7d17d50d9fee94be2b75874778e23c6a9effd5 100644 (file)
@@ -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