Skip to content

Commit

Permalink
Add HasAcceleratedCRC32C to port_win.h
Browse files Browse the repository at this point in the history
  • Loading branch information
theuni committed Jul 13, 2017
1 parent 77cfbfd commit 8d4eb08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions port/port_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <windows.h>
#include <cassert>
#include <intrin.h>

namespace leveldb {
namespace port {
Expand Down Expand Up @@ -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
}

}
}
1 change: 1 addition & 0 deletions port/port_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
Expand Down

0 comments on commit 8d4eb08

Please sign in to comment.