Skip to content

Commit

Permalink
Add option to disable SSE scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroMemes committed Jan 29, 2024
1 parent 5f826b6 commit 82de2e6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ project(libhat)
option(LIBHAT_STATIC_C_LIB "Build a static version of the C library" OFF)
option(LIBHAT_SHARED_C_LIB "Build a shared version of the C library" OFF)
option(LIBHAT_INSTALL_TARGET "Creates install rules for the libhat target" ON)
option(LIBHAT_DISABLE_SSE "Disables SSE scanning" OFF)
option(LIBHAT_DISABLE_AVX512 "Disables AVX512 scanning" OFF)
option(LIBHAT_TESTING "Enable tests" OFF)

Expand Down Expand Up @@ -46,6 +47,7 @@ target_include_directories(libhat PUBLIC
)

target_compile_definitions(libhat PUBLIC
"$<$<BOOL:${LIBHAT_DISABLE_SSE}>:LIBHAT_DISABLE_SSE>"
"$<$<BOOL:${LIBHAT_DISABLE_AVX512}>:LIBHAT_DISABLE_AVX512>"
)

Expand Down
2 changes: 2 additions & 0 deletions src/Scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ namespace hat::detail {
return find_pattern<scan_mode::AVX2, alignment>(begin, end, signature);
}
}
#if !defined(LIBHAT_DISABLE_SSE)
if (ext.sse41) {
return find_pattern<scan_mode::SSE, alignment>(begin, end, signature);
}
#endif
#endif
// If none of the vectorized implementations are available/supported, then fallback to scanning per-byte
return find_pattern<scan_mode::Single, alignment>(begin, end, signature);
Expand Down
2 changes: 1 addition & 1 deletion src/arch/x86/SSE.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <libhat/Defines.hpp>

#ifdef LIBHAT_X86
#if defined(LIBHAT_X86) && !defined(LIBHAT_DISABLE_SSE)

#include <libhat/Scanner.hpp>

Expand Down

0 comments on commit 82de2e6

Please sign in to comment.