From 8d4eb0847041a26377dc99b1c4fb5c22d4841d5e Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Fri, 16 Jun 2017 19:33:20 -0400 Subject: [PATCH] Add HasAcceleratedCRC32C to port_win.h --- port/port_win.cc | 11 +++++++++++ port/port_win.h | 1 + 2 files changed, 12 insertions(+) diff --git a/port/port_win.cc b/port/port_win.cc index 1b0f060a19caab..62e19d41038831 100644 --- a/port/port_win.cc +++ b/port/port_win.cc @@ -32,6 +32,7 @@ #include #include +#include namespace leveldb { namespace port { @@ -143,5 +144,15 @@ void AtomicPointer::NoBarrier_Store(void* v) { rep_ = v; } +bool HasAcceleratedCRC32C() { +#if (__x86_64__ || __i386__) + int cpu_info[4]; + __cpuid(cpu_info, 1); + return (cpu_info[2] & (1 << 20)) != 0; +#else + return false; +#endif +} + } } diff --git a/port/port_win.h b/port/port_win.h index 50090048228389..e8bf46ef27cd68 100644 --- a/port/port_win.h +++ b/port/port_win.h @@ -168,6 +168,7 @@ inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) { return false; } +bool HasAcceleratedCRC32C(); uint32_t AcceleratedCRC32C(uint32_t crc, const char* buf, size_t size); }