mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
Compare commits
3 commits
e2af133dd2
...
2504c9d912
Author | SHA1 | Date | |
---|---|---|---|
|
2504c9d912 | ||
|
e34c793c87 | ||
|
ff27bebb3e |
4 changed files with 0 additions and 25 deletions
|
@ -83,7 +83,6 @@ target_compile_definitions(crc32c_common INTERFACE
|
||||||
HAVE_BUILTIN_PREFETCH=$<BOOL:${HAVE_BUILTIN_PREFETCH}>
|
HAVE_BUILTIN_PREFETCH=$<BOOL:${HAVE_BUILTIN_PREFETCH}>
|
||||||
HAVE_MM_PREFETCH=$<BOOL:${HAVE_MM_PREFETCH}>
|
HAVE_MM_PREFETCH=$<BOOL:${HAVE_MM_PREFETCH}>
|
||||||
HAVE_STRONG_GETAUXVAL=$<BOOL:${HAVE_STRONG_GETAUXVAL}>
|
HAVE_STRONG_GETAUXVAL=$<BOOL:${HAVE_STRONG_GETAUXVAL}>
|
||||||
BYTE_ORDER_BIG_ENDIAN=$<STREQUAL:${CMAKE_CXX_BYTE_ORDER},BIG_ENDIAN>
|
|
||||||
HAVE_SSE42=$<BOOL:${HAVE_SSE42}>
|
HAVE_SSE42=$<BOOL:${HAVE_SSE42}>
|
||||||
HAVE_ARM64_CRC32C=$<BOOL:${HAVE_ARM64_CRC32C}>
|
HAVE_ARM64_CRC32C=$<BOOL:${HAVE_ARM64_CRC32C}>
|
||||||
)
|
)
|
||||||
|
|
|
@ -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_USE_GLOG "Build CRC32C's tests with Google Logging" ON)
|
||||||
option(CRC32C_INSTALL "Install CRC32C's header and library" ON)
|
option(CRC32C_INSTALL "Install CRC32C's header and library" ON)
|
||||||
|
|
||||||
include(TestBigEndian)
|
|
||||||
test_big_endian(BYTE_ORDER_BIG_ENDIAN)
|
|
||||||
|
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
# Used by glog.
|
# Used by glog.
|
||||||
check_cxx_compiler_flag(-Wno-deprecated CRC32C_HAVE_NO_DEPRECATED)
|
check_cxx_compiler_flag(-Wno-deprecated CRC32C_HAVE_NO_DEPRECATED)
|
||||||
|
|
|
@ -5,9 +5,6 @@
|
||||||
#ifndef CRC32C_CRC32C_CONFIG_H_
|
#ifndef CRC32C_CRC32C_CONFIG_H_
|
||||||
#define 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.
|
// Define to 1 if the compiler has the __builtin_prefetch intrinsic.
|
||||||
#cmakedefine01 HAVE_BUILTIN_PREFETCH
|
#cmakedefine01 HAVE_BUILTIN_PREFETCH
|
||||||
|
|
||||||
|
|
|
@ -8,30 +8,18 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#ifdef CRC32C_HAVE_CONFIG_H
|
|
||||||
#include "crc32c/crc32c_config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace crc32c {
|
namespace crc32c {
|
||||||
|
|
||||||
// Reads a little-endian 32-bit integer from a 32-bit-aligned buffer.
|
// Reads a little-endian 32-bit integer from a 32-bit-aligned buffer.
|
||||||
inline uint32_t ReadUint32LE(const uint8_t* buffer) {
|
inline uint32_t ReadUint32LE(const uint8_t* buffer) {
|
||||||
#if BYTE_ORDER_BIG_ENDIAN
|
|
||||||
return ((static_cast<uint32_t>(static_cast<uint8_t>(buffer[0]))) |
|
return ((static_cast<uint32_t>(static_cast<uint8_t>(buffer[0]))) |
|
||||||
(static_cast<uint32_t>(static_cast<uint8_t>(buffer[1])) << 8) |
|
(static_cast<uint32_t>(static_cast<uint8_t>(buffer[1])) << 8) |
|
||||||
(static_cast<uint32_t>(static_cast<uint8_t>(buffer[2])) << 16) |
|
(static_cast<uint32_t>(static_cast<uint8_t>(buffer[2])) << 16) |
|
||||||
(static_cast<uint32_t>(static_cast<uint8_t>(buffer[3])) << 24));
|
(static_cast<uint32_t>(static_cast<uint8_t>(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.
|
// Reads a little-endian 64-bit integer from a 64-bit-aligned buffer.
|
||||||
inline uint64_t ReadUint64LE(const uint8_t* buffer) {
|
inline uint64_t ReadUint64LE(const uint8_t* buffer) {
|
||||||
#if BYTE_ORDER_BIG_ENDIAN
|
|
||||||
return ((static_cast<uint64_t>(static_cast<uint8_t>(buffer[0]))) |
|
return ((static_cast<uint64_t>(static_cast<uint8_t>(buffer[0]))) |
|
||||||
(static_cast<uint64_t>(static_cast<uint8_t>(buffer[1])) << 8) |
|
(static_cast<uint64_t>(static_cast<uint8_t>(buffer[1])) << 8) |
|
||||||
(static_cast<uint64_t>(static_cast<uint8_t>(buffer[2])) << 16) |
|
(static_cast<uint64_t>(static_cast<uint8_t>(buffer[2])) << 16) |
|
||||||
|
@ -40,12 +28,6 @@ inline uint64_t ReadUint64LE(const uint8_t* buffer) {
|
||||||
(static_cast<uint64_t>(static_cast<uint8_t>(buffer[5])) << 40) |
|
(static_cast<uint64_t>(static_cast<uint8_t>(buffer[5])) << 40) |
|
||||||
(static_cast<uint64_t>(static_cast<uint8_t>(buffer[6])) << 48) |
|
(static_cast<uint64_t>(static_cast<uint8_t>(buffer[6])) << 48) |
|
||||||
(static_cast<uint64_t>(static_cast<uint8_t>(buffer[7])) << 56));
|
(static_cast<uint64_t>(static_cast<uint8_t>(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
|
} // namespace crc32c
|
||||||
|
|
Loading…
Add table
Reference in a new issue