summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-11-29 06:33:54 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-11-29 06:33:54 +0100
commit68f2197cf5f81d5197999e5f3d2f980d8b04d4e2 (patch)
treea20ccf8fe39629867415803d29e39e9b5fcc34a6
parent3cd025bb177388556ddaf20e45c0e0ae6b7f7e22 (diff)
downloadfastd-68f2197cf5f81d5197999e5f3d2f980d8b04d4e2.tar
fastd-68f2197cf5f81d5197999e5f3d2f980d8b04d4e2.zip
Use <cpuid.h>
fastd will segfault in valgrind otherwise (O_o)
-rw-r--r--src/cpuid.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cpuid.h b/src/cpuid.h
index eab9110..310f0c2 100644
--- a/src/cpuid.h
+++ b/src/cpuid.h
@@ -27,10 +27,7 @@
#ifndef _FASTD_CPUID_H_
#define _FASTD_CPUID_H_
-#if !(defined(__i386__) || defined(__x86_64__))
-#error Tried to include cpuid.h on a non-x86 system
-#endif
-
+#include <cpuid.h>
#include <stdint.h>
@@ -40,8 +37,11 @@
static inline uint64_t fastd_cpuid(void) {
- uint32_t edx, ecx;
- __asm__("cpuid" : "=d"(edx), "=c"(ecx) : "a"((uint32_t)1));
+ unsigned eax, ebc, ecx, edx;
+
+ if (!__get_cpuid(1, &eax, &ebc, &ecx, &edx))
+ return 0;
+
return ((uint64_t)ecx) << 32 | edx;
}