summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Kukunas <james.t.kukunas@linux.intel.com>2013-09-16 11:40:18 -0700
committerJim Kukunas <james.t.kukunas@linux.intel.com>2014-01-17 13:12:46 -0800
commitd24da7ca5e4587abcaf545d9c5bb85603e7b4e66 (patch)
treeddbc9a91ef0cb7970311b91dbb9d92a11248ede3
parent1af4192c78f291a3575fd4d83a2dc9f5e82e4458 (diff)
downloadProject-Tick-d24da7ca5e4587abcaf545d9c5bb85603e7b4e66.tar.gz
Project-Tick-d24da7ca5e4587abcaf545d9c5bb85603e7b4e66.zip
For x86, add CPUID check.
Adds check for SSE2, SSE4.2, and the PCLMULQDQ instructions.
-rwxr-xr-xconfigure8
-rw-r--r--x86.c38
-rw-r--r--x86.h15
3 files changed, 57 insertions, 4 deletions
diff --git a/configure b/configure
index dfdde3ee2e..8924d5dbcf 100755
--- a/configure
+++ b/configure
@@ -763,15 +763,15 @@ fi
# Set ARCH specific FLAGS
case "${ARCH}" in
x86_64)
- OBJC="${OBJC}"
- PIC_OBJC="${PIC_OBJC}"
+ OBJC="${OBJC} x86.o"
+ PIC_OBJC="${PIC_OBJC} x86.lo"
CFLAGS="${CFLAGS} -DX86_64"
SFLAGS="${SFLAGS} -DX86_64"
;;
i386 | i486 | i586 | i686)
- OBJC="${OBJC}"
- PIC_OBJC="${PIC_OBJC}"
+ OBJC="${OBJC} x86.o"
+ PIC_OBJC="${PIC_OBJC} x86.lo"
CFLAGS="${CFLAGS} -DX86"
SFLAGS="${SFLAGS} -DX86"
diff --git a/x86.c b/x86.c
new file mode 100644
index 0000000000..097d27964d
--- /dev/null
+++ b/x86.c
@@ -0,0 +1,38 @@
+/*
+ * x86 feature check
+ *
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ * Author:
+ * Jim Kukunas
+ *
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#include "x86.h"
+
+int x86_cpu_has_sse2;
+int x86_cpu_has_sse42;
+int x86_cpu_has_pclmulqdq;
+
+void x86_check_features(void)
+{
+ unsigned eax, ebx, ecx, edx;
+
+ eax = 1;
+ __asm__ __volatile__ (
+#ifdef X86
+ "xchg %%ebx, %1\n\t"
+#endif
+ "cpuid\n\t"
+#ifdef X86
+ "xchg %1, %%ebx\n\t"
+ : "+a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx)
+#else
+ : "+a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
+#endif
+ );
+
+ x86_cpu_has_sse2 = edx & 0x4000000;
+ x86_cpu_has_sse42= ecx & 0x100000;
+ x86_cpu_has_pclmulqdq = ecx & 0x2;
+}
diff --git a/x86.h b/x86.h
new file mode 100644
index 0000000000..99f4499820
--- /dev/null
+++ b/x86.h
@@ -0,0 +1,15 @@
+ /* cpu.h -- check for CPU features
+ * Copyright (C) 2013 Intel Corporation Jim Kukunas
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#ifndef CPU_H
+#define CPU_H
+
+extern int x86_cpu_has_sse2;
+extern int x86_cpu_has_sse42;
+extern int x86_cpu_has_pclmulqdq;
+
+void x86_check_features(void);
+
+#endif