commit c4e54b4: [Minor] Limit sse/avx implementations to x86_64 only
Vsevolod Stakhov
vsevolod at rspamd.com
Tue Aug 29 18:21:03 UTC 2023
Author: Vsevolod Stakhov
Date: 2023-08-29 19:20:25 +0100
URL: https://github.com/rspamd/rspamd/commit/c4e54b4daa77bee29862a00900bede165ea16b52 (HEAD -> master)
[Minor] Limit sse/avx implementations to x86_64 only
---
src/libcryptobox/CMakeLists.txt | 62 +++++++++++++++++++++-------------------
src/libcryptobox/base64/base64.c | 10 +++----
2 files changed, 37 insertions(+), 35 deletions(-)
diff --git a/src/libcryptobox/CMakeLists.txt b/src/libcryptobox/CMakeLists.txt
index a7f86650c..d1c8e3d61 100644
--- a/src/libcryptobox/CMakeLists.txt
+++ b/src/libcryptobox/CMakeLists.txt
@@ -1,39 +1,41 @@
SET(CHACHASRC ${CMAKE_CURRENT_SOURCE_DIR}/chacha20/chacha.c
- ${CMAKE_CURRENT_SOURCE_DIR}/chacha20/ref.c)
+ ${CMAKE_CURRENT_SOURCE_DIR}/chacha20/ref.c)
SET(BASE64SRC ${CMAKE_CURRENT_SOURCE_DIR}/base64/ref.c
- ${CMAKE_CURRENT_SOURCE_DIR}/base64/base64.c)
+ ${CMAKE_CURRENT_SOURCE_DIR}/base64/base64.c)
-IF(HAVE_AVX2)
- IF ("${ARCH}" STREQUAL "x86_64")
- SET(CHACHASRC ${CHACHASRC} ${CMAKE_CURRENT_SOURCE_DIR}/chacha20/avx2.S)
- MESSAGE(STATUS "Cryptobox: AVX2 support is added (chacha20)")
- ENDIF()
- SET(BASE64SRC ${BASE64SRC} ${CMAKE_CURRENT_SOURCE_DIR}/base64/avx2.c)
- MESSAGE(STATUS "Cryptobox: AVX2 support is added (base64)")
-ENDIF(HAVE_AVX2)
-IF(HAVE_AVX)
- IF ("${ARCH}" STREQUAL "x86_64")
- SET(CHACHASRC ${CHACHASRC} ${CMAKE_CURRENT_SOURCE_DIR}/chacha20/avx.S)
- MESSAGE(STATUS "Cryptobox: AVX support is added (chacha20)")
- ENDIF()
-ENDIF(HAVE_AVX)
-IF(HAVE_SSE2)
- IF ("${ARCH}" STREQUAL "x86_64")
- SET(CHACHASRC ${CHACHASRC} ${CMAKE_CURRENT_SOURCE_DIR}/chacha20/sse2.S)
- MESSAGE(STATUS "Cryptobox: SSE2 support is added (chacha20)")
- ENDIF()
-ENDIF(HAVE_SSE2)
-IF(HAVE_SSE42)
- SET(BASE64SRC ${BASE64SRC} ${CMAKE_CURRENT_SOURCE_DIR}/base64/sse42.c)
- MESSAGE(STATUS "Cryptobox: SSE42 support is added (base64)")
-ENDIF(HAVE_SSE42)
+IF (HAVE_AVX2)
+ IF ("${ARCH}" STREQUAL "x86_64")
+ SET(CHACHASRC ${CHACHASRC} ${CMAKE_CURRENT_SOURCE_DIR}/chacha20/avx2.S)
+ MESSAGE(STATUS "Cryptobox: AVX2 support is added (chacha20)")
+ ENDIF ()
+ SET(BASE64SRC ${BASE64SRC} ${CMAKE_CURRENT_SOURCE_DIR}/base64/avx2.c)
+ MESSAGE(STATUS "Cryptobox: AVX2 support is added (base64)")
+ENDIF (HAVE_AVX2)
+IF (HAVE_AVX)
+ IF ("${ARCH}" STREQUAL "x86_64")
+ SET(CHACHASRC ${CHACHASRC} ${CMAKE_CURRENT_SOURCE_DIR}/chacha20/avx.S)
+ MESSAGE(STATUS "Cryptobox: AVX support is added (chacha20)")
+ ENDIF ()
+ENDIF (HAVE_AVX)
+IF (HAVE_SSE2)
+ IF ("${ARCH}" STREQUAL "x86_64")
+ SET(CHACHASRC ${CHACHASRC} ${CMAKE_CURRENT_SOURCE_DIR}/chacha20/sse2.S)
+ MESSAGE(STATUS "Cryptobox: SSE2 support is added (chacha20)")
+ ENDIF ()
+ENDIF (HAVE_SSE2)
+IF (HAVE_SSE42)
+ IF ("${ARCH}" STREQUAL "x86_64")
+ SET(BASE64SRC ${BASE64SRC} ${CMAKE_CURRENT_SOURCE_DIR}/base64/sse42.c)
+ MESSAGE(STATUS "Cryptobox: SSE42 support is added (base64)")
+ ENDIF ()
+ENDIF (HAVE_SSE42)
CONFIGURE_FILE(platform_config.h.in platform_config.h)
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}")
-SET(LIBCRYPTOBOXSRC ${CMAKE_CURRENT_SOURCE_DIR}/cryptobox.c
- ${CMAKE_CURRENT_SOURCE_DIR}/keypair.c
- ${CMAKE_CURRENT_SOURCE_DIR}/keypairs_cache.c
- ${CMAKE_CURRENT_SOURCE_DIR}/catena/catena.c)
+SET(LIBCRYPTOBOXSRC ${CMAKE_CURRENT_SOURCE_DIR}/cryptobox.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/keypair.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/keypairs_cache.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/catena/catena.c)
SET(RSPAMD_CRYPTOBOX ${LIBCRYPTOBOXSRC} ${CHACHASRC} ${BASE64SRC} PARENT_SCOPE)
diff --git a/src/libcryptobox/base64/base64.c b/src/libcryptobox/base64/base64.c
index 0dc93b3d2..e86892443 100644
--- a/src/libcryptobox/base64/base64.c
+++ b/src/libcryptobox/base64/base64.c
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2023 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -306,7 +306,7 @@ BASE64_DECLARE(ref);
#define BASE64_REF BASE64_IMPL(0, 0, "ref", ref)
#ifdef RSPAMD_HAS_TARGET_ATTR
-#if defined(HAVE_SSE42)
+#if defined(HAVE_SSE42) && defined(__x86_64__)
int base64_decode_sse42(const char *in, size_t inlen,
unsigned char *out, size_t *outlen) __attribute__((__target__("sse4.2")));
@@ -316,7 +316,7 @@ BASE64_DECLARE(sse42);
#endif
#ifdef RSPAMD_HAS_TARGET_ATTR
-#if defined(HAVE_AVX2)
+#if defined(HAVE_AVX2) && defined(__x86_64__)
int base64_decode_avx2(const char *in, size_t inlen,
unsigned char *out, size_t *outlen) __attribute__((__target__("avx2")));
More information about the Commits
mailing list