aboutsummaryrefslogtreecommitdiff
path: root/port/port_posix.cc
diff options
context:
space:
mode:
Diffstat (limited to 'port/port_posix.cc')
-rw-r--r--port/port_posix.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/port/port_posix.cc b/port/port_posix.cc
index 30e8007ae3..ec39e92195 100644
--- a/port/port_posix.cc
+++ b/port/port_posix.cc
@@ -8,6 +8,10 @@
#include <stdio.h>
#include <string.h>
+#if (defined(__x86_64__) || defined(__i386__)) && defined(__GNUC__)
+#include <cpuid.h>
+#endif
+
namespace leveldb {
namespace port {
@@ -49,5 +53,15 @@ void InitOnce(OnceType* once, void (*initializer)()) {
PthreadCall("once", pthread_once(once, initializer));
}
+bool HasAcceleratedCRC32C() {
+#if (defined(__x86_64__) || defined(__i386__)) && defined(__GNUC__)
+ unsigned int eax, ebx, ecx, edx;
+ __get_cpuid(1, &eax, &ebx, &ecx, &edx);
+ return (ecx & (1 << 20)) != 0;
+#else
+ return false;
+#endif
+}
+
} // namespace port
} // namespace leveldb