Changeset View
Changeset View
Standalone View
Standalone View
src/leveldb/util/crc32c.cc
Show First 20 Lines • Show All 282 Lines • ▼ Show 20 Lines | |||||
// Used to fetch a naturally-aligned 32-bit word in little endian byte-order | // Used to fetch a naturally-aligned 32-bit word in little endian byte-order | ||||
static inline uint32_t LE_LOAD32(const uint8_t *p) { | static inline uint32_t LE_LOAD32(const uint8_t *p) { | ||||
return DecodeFixed32(reinterpret_cast<const char*>(p)); | return DecodeFixed32(reinterpret_cast<const char*>(p)); | ||||
} | } | ||||
// Determine if the CPU running this program can accelerate the CRC32C | // Determine if the CPU running this program can accelerate the CRC32C | ||||
// calculation. | // calculation. | ||||
static bool CanAccelerateCRC32C() { | static bool CanAccelerateCRC32C() { | ||||
if (!port::HasAcceleratedCRC32C()) | |||||
return false; | |||||
// Double-check that the accelerated implementation functions correctly. | |||||
// port::AcceleretedCRC32C returns zero when unable to accelerate. | // port::AcceleretedCRC32C returns zero when unable to accelerate. | ||||
static const char kTestCRCBuffer[] = "TestCRCBuffer"; | static const char kTestCRCBuffer[] = "TestCRCBuffer"; | ||||
static const char kBufSize = sizeof(kTestCRCBuffer) - 1; | static const char kBufSize = sizeof(kTestCRCBuffer) - 1; | ||||
static const uint32_t kTestCRCValue = 0xdcbc59fa; | static const uint32_t kTestCRCValue = 0xdcbc59fa; | ||||
return port::AcceleratedCRC32C(0, kTestCRCBuffer, kBufSize) == kTestCRCValue; | return port::AcceleratedCRC32C(0, kTestCRCBuffer, kBufSize) == kTestCRCValue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |