From 86fa5cc03af93e07ad809f83218e5fd905f93333 Mon Sep 17 00:00:00 2001 From: fanquake Date: Thu, 11 Apr 2024 14:34:46 +0200 Subject: [PATCH 1/2] crc32c: remove BYTE_ORDER_BIG_ENDIAN Similar to 038755784d88ce7522ac2f98e8ba138010a64f82 from leveldb. --- src/crc32c/CMakeLists.txt | 3 --- src/crc32c/src/crc32c_config.h.in | 3 --- src/crc32c/src/crc32c_read_le.h | 18 ------------------ 3 files changed, 24 deletions(-) diff --git a/src/crc32c/CMakeLists.txt b/src/crc32c/CMakeLists.txt index 2f52db104cf..13f58a08145 100644 --- a/src/crc32c/CMakeLists.txt +++ b/src/crc32c/CMakeLists.txt @@ -69,9 +69,6 @@ option(CRC32C_BUILD_BENCHMARKS "Build CRC32C's benchmarks" ON) option(CRC32C_USE_GLOG "Build CRC32C's tests with Google Logging" ON) option(CRC32C_INSTALL "Install CRC32C's header and library" ON) -include(TestBigEndian) -test_big_endian(BYTE_ORDER_BIG_ENDIAN) - include(CheckCXXCompilerFlag) # Used by glog. check_cxx_compiler_flag(-Wno-deprecated CRC32C_HAVE_NO_DEPRECATED) diff --git a/src/crc32c/src/crc32c_config.h.in b/src/crc32c/src/crc32c_config.h.in index 4034fa56444..d3aa7fa8703 100644 --- a/src/crc32c/src/crc32c_config.h.in +++ b/src/crc32c/src/crc32c_config.h.in @@ -5,9 +5,6 @@ #ifndef CRC32C_CRC32C_CONFIG_H_ #define CRC32C_CRC32C_CONFIG_H_ -// Define to 1 if building for a big-endian platform. -#cmakedefine01 BYTE_ORDER_BIG_ENDIAN - // Define to 1 if the compiler has the __builtin_prefetch intrinsic. #cmakedefine01 HAVE_BUILTIN_PREFETCH diff --git a/src/crc32c/src/crc32c_read_le.h b/src/crc32c/src/crc32c_read_le.h index 673a2a0db77..35ddc59c4aa 100644 --- a/src/crc32c/src/crc32c_read_le.h +++ b/src/crc32c/src/crc32c_read_le.h @@ -8,30 +8,18 @@ #include #include -#ifdef CRC32C_HAVE_CONFIG_H -#include "crc32c/crc32c_config.h" -#endif - namespace crc32c { // Reads a little-endian 32-bit integer from a 32-bit-aligned buffer. inline uint32_t ReadUint32LE(const uint8_t* buffer) { -#if BYTE_ORDER_BIG_ENDIAN return ((static_cast(static_cast(buffer[0]))) | (static_cast(static_cast(buffer[1])) << 8) | (static_cast(static_cast(buffer[2])) << 16) | (static_cast(static_cast(buffer[3])) << 24)); -#else // !BYTE_ORDER_BIG_ENDIAN - uint32_t result; - // This should be optimized to a single instruction. - std::memcpy(&result, buffer, sizeof(result)); - return result; -#endif // BYTE_ORDER_BIG_ENDIAN } // Reads a little-endian 64-bit integer from a 64-bit-aligned buffer. inline uint64_t ReadUint64LE(const uint8_t* buffer) { -#if BYTE_ORDER_BIG_ENDIAN return ((static_cast(static_cast(buffer[0]))) | (static_cast(static_cast(buffer[1])) << 8) | (static_cast(static_cast(buffer[2])) << 16) | @@ -40,12 +28,6 @@ inline uint64_t ReadUint64LE(const uint8_t* buffer) { (static_cast(static_cast(buffer[5])) << 40) | (static_cast(static_cast(buffer[6])) << 48) | (static_cast(static_cast(buffer[7])) << 56)); -#else // !BYTE_ORDER_BIG_ENDIAN - uint64_t result; - // This should be optimized to a single instruction. - std::memcpy(&result, buffer, sizeof(result)); - return result; -#endif // BYTE_ORDER_BIG_ENDIAN } } // namespace crc32c From 11bc8e9ef3e664f3de5d9dc665eb74e56d04c910 Mon Sep 17 00:00:00 2001 From: fanquake Date: Wed, 28 Aug 2024 15:30:33 +0100 Subject: [PATCH 2/2] build: remove BYTE_ORDER_BIG_ENDIAN --- cmake/crc32c.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/crc32c.cmake b/cmake/crc32c.cmake index 25f046bb43a..756b9752994 100644 --- a/cmake/crc32c.cmake +++ b/cmake/crc32c.cmake @@ -89,7 +89,6 @@ target_compile_definitions(crc32c PRIVATE HAVE_BUILTIN_PREFETCH=$ HAVE_MM_PREFETCH=$ HAVE_STRONG_GETAUXVAL=$ - BYTE_ORDER_BIG_ENDIAN=$ HAVE_SSE42=$ HAVE_ARM64_CRC32C=$ )