Skip to content

Commit

Permalink
[Minor] Limit sse41 code to sse41 and x86_64
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Jul 23, 2023
1 parent 1e22437 commit 80e8a76
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
6 changes: 2 additions & 4 deletions contrib/fastutf8/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
SET(UTFSRC ${CMAKE_CURRENT_SOURCE_DIR}/fastutf8.c)
IF(HAVE_AVX2)
IF(HAVE_AVX2 AND "${ARCH}" STREQUAL "x86_64")
SET(UTFSRC ${UTFSRC} ${CMAKE_CURRENT_SOURCE_DIR}/avx2.c)
MESSAGE(STATUS "UTF8: AVX2 support is added")
ENDIF()
IF(HAVE_SSE41)
IF(HAVE_SSE41 AND "${ARCH}" STREQUAL "x86_64")
SET(UTFSRC ${UTFSRC} ${CMAKE_CURRENT_SOURCE_DIR}/sse41.c)
MESSAGE(STATUS "UTF8: SSE41 support is added")
ENDIF()

CONFIGURE_FILE(platform_config.h.in platform_config.h)

ADD_LIBRARY(rspamd-fastutf8 STATIC ${UTFSRC})
10 changes: 5 additions & 5 deletions contrib/fastutf8/fastutf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

#include "fastutf8.h"
#include "platform_config.h"
#include "libcryptobox/platform_config.h"


/*
Expand Down Expand Up @@ -125,10 +125,10 @@ rspamd_fast_utf8_validate_ref (const unsigned char *data, size_t len)
}

/* Prototypes */
#ifdef HAVE_SSSE3
#if defined(HAVE_SSE41) && defined(__x86_64__)
extern off_t rspamd_fast_utf8_validate_sse41 (const unsigned char *data, size_t len);
#endif
#ifdef HAVE_AVX2
#if defined(HAVE_AVX2) && defined(__x86_64__)
extern off_t rspamd_fast_utf8_validate_avx2 (const unsigned char *data, size_t len);
#endif

Expand All @@ -139,12 +139,12 @@ static off_t (*validate_func) (const unsigned char *data, size_t len) =
void
rspamd_fast_utf8_library_init (unsigned flags)
{
#ifdef HAVE_SSSE3
#if defined(HAVE_SSE41) && defined(__x86_64__)
if (flags & RSPAMD_FAST_UTF8_FLAG_SSE41) {
validate_func = rspamd_fast_utf8_validate_sse41;
}
#endif
#ifdef HAVE_AVX2
#if defined(HAVE_AVX2) && defined(__x86_64__)
if (flags & RSPAMD_FAST_UTF8_FLAG_AVX2) {
validate_func = rspamd_fast_utf8_validate_avx2;
}
Expand Down
13 changes: 0 additions & 13 deletions contrib/fastutf8/platform_config.h.in

This file was deleted.

0 comments on commit 80e8a76

Please sign in to comment.