Skip to content

Commit

Permalink
Switch main wz::crc to using crc-32 model with a slicing-by-8 algorithm
Browse files Browse the repository at this point in the history
For a substantial performance improvement on most systems
  • Loading branch information
past-due committed May 10, 2024
1 parent 99684c9 commit 717e5bd
Show file tree
Hide file tree
Showing 3 changed files with 428 additions and 21 deletions.
27 changes: 27 additions & 0 deletions lib/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,30 @@ endif()
if (APPLE)
target_link_libraries(framework PUBLIC "-framework ApplicationServices" "-framework AppKit")
endif (APPLE)

# Detect endianness (for crc.cpp)
if (NOT DEFINED CMAKE_CXX_BYTE_ORDER AND CMAKE_VERSION VERSION_LESS 3.20)
# CMake < 3.20 does not have CMAKE_<LANG>_BYTE_ORDER
# Instead, use the older TestBigEndian module (although this may not work for cross-compilation)
if (NOT CMAKE_CROSSCOMPILING)
include(TestBigEndian)
test_big_endian(IS_BIGENDIAN)
if (IS_BIGENDIAN)
set(CMAKE_CXX_BYTE_ORDER "BIG_ENDIAN")
else()
set(CMAKE_CXX_BYTE_ORDER "LITTLE_ENDIAN")
endif()
else()
message(WARNING "Unable to determine endianness for target architecture. Either upgrade to CMake 3.20+ or manually set the CMAKE_CXX_BYTE_ORDER cache variable to \"LITTLE_ENDIAN\" or \"BIG_ENDIAN\". Otherwise, will attempt preprocessor endian detection on compile.")
endif()
endif()
if (DEFINED CMAKE_CXX_BYTE_ORDER AND NOT CMAKE_CXX_BYTE_ORDER STREQUAL "")
message(STATUS "CMAKE_CXX_BYTE_ORDER: ${CMAKE_CXX_BYTE_ORDER}")
if (CMAKE_CXX_BYTE_ORDER STREQUAL "LITTLE_ENDIAN")
set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/crc.cpp" APPEND PROPERTY COMPILE_DEFINITIONS WZ_IS_BIG_ENDIAN=0)
elseif (CMAKE_CXX_BYTE_ORDER STREQUAL "BIG_ENDIAN")
set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/crc.cpp" APPEND PROPERTY COMPILE_DEFINITIONS WZ_IS_BIG_ENDIAN=1)
else()
message(FATAL_ERROR "Unsupported / unexpected endianness? (CMAKE_CXX_BYTE_ORDER: \"${CMAKE_CXX_BYTE_ORDER}\")")
endif()
endif()
Loading

0 comments on commit 717e5bd

Please sign in to comment.