Skip to content

Commit 8d4eb08

Browse files
committed
Add HasAcceleratedCRC32C to port_win.h
1 parent 77cfbfd commit 8d4eb08

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

port/port_win.cc

+11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include <windows.h>
3434
#include <cassert>
35+
#include <intrin.h>
3536

3637
namespace leveldb {
3738
namespace port {
@@ -143,5 +144,15 @@ void AtomicPointer::NoBarrier_Store(void* v) {
143144
rep_ = v;
144145
}
145146

147+
bool HasAcceleratedCRC32C() {
148+
#if (__x86_64__ || __i386__)
149+
int cpu_info[4];
150+
__cpuid(cpu_info, 1);
151+
return (cpu_info[2] & (1 << 20)) != 0;
152+
#else
153+
return false;
154+
#endif
155+
}
156+
146157
}
147158
}

port/port_win.h

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) {
168168
return false;
169169
}
170170

171+
bool HasAcceleratedCRC32C();
171172
uint32_t AcceleratedCRC32C(uint32_t crc, const char* buf, size_t size);
172173

173174
}

0 commit comments

Comments
 (0)