summaryrefslogtreecommitdiff
path: root/compat/cpuid.h
diff options
context:
space:
mode:
Diffstat (limited to 'compat/cpuid.h')
-rw-r--r--compat/cpuid.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/compat/cpuid.h b/compat/cpuid.h
new file mode 100644
index 0000000000..7709e35286
--- /dev/null
+++ b/compat/cpuid.h
@@ -0,0 +1,25 @@
+#ifndef COMPAT_CPUID_H
+#define COMPAT_CPUID_H
+
+#if (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
+#include <cpuid.h>
+#define CPUID_SSE42_BIT (1 << 20)
+
+static int processor_supports_sse42(void)
+{
+ unsigned eax, ebx, ecx, edx;
+ __cpuid(1, eax, ebx, ecx, edx);
+ return ecx & CPUID_SSE42_BIT;
+}
+
+#else
+
+static int processor_supports_sse42(void)
+{
+ /* TODO: handle CPUID on non-GCC compilers */
+ return 0;
+}
+
+#endif
+
+#endif /* COMPAT_CPUID_H */