summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_cpu_detect.h
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-09-29 13:25:08 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-09-29 13:59:16 +0100
commita81fb2a0d2c9a94fa362705edd1281fa7699d093 (patch)
tree76cef41b41721b15e100a706ec7f6832b2c9a0ef /src/gallium/auxiliary/util/u_cpu_detect.h
parent8210abb113462c781a8f3ffee3406493c108a2f0 (diff)
util: Cleanup u_cpu_detect, build. Support X86_64 and detect SSE4.1 too.
I was waiting for the need to use this code to arise, and it finally came. I've tested building this on Linux and Windows, both x86 and x64_64. But it might break other platforms. Please bear with me and help me fix it. Many thanks to Dennis Smit who submitted this, and Eric Anholt whose work this was based on.
Diffstat (limited to 'src/gallium/auxiliary/util/u_cpu_detect.h')
-rw-r--r--src/gallium/auxiliary/util/u_cpu_detect.h82
1 files changed, 40 insertions, 42 deletions
diff --git a/src/gallium/auxiliary/util/u_cpu_detect.h b/src/gallium/auxiliary/util/u_cpu_detect.h
index 1612d49286..7ea0121c07 100644
--- a/src/gallium/auxiliary/util/u_cpu_detect.h
+++ b/src/gallium/auxiliary/util/u_cpu_detect.h
@@ -24,55 +24,53 @@
*
***************************************************************************/
-/*
- * Based on the work of Eric Anholt <anholt@FreeBSD.org>
+/**
+ * @file
+ * CPU feature detection.
+ *
+ * @author Dennis Smit
+ * @author Based on the work of Eric Anholt <anholt@FreeBSD.org>
*/
-#ifndef _CPU_DETECT_H
-#define _CPU_DETECT_H
+#ifndef _UTIL_CPU_DETECT_H
+#define _UTIL_CPU_DETECT_H
+
+#include "pipe/p_compiler.h"
-typedef enum {
- CPU_DETECT_TYPE_MIPS,
- CPU_DETECT_TYPE_ALPHA,
- CPU_DETECT_TYPE_SPARC,
- CPU_DETECT_TYPE_X86,
- CPU_DETECT_TYPE_POWERPC,
- CPU_DETECT_TYPE_OTHER
-} cpu_detect_type;
+enum util_cpu_arch {
+ UTIL_CPU_ARCH_UNKNOWN = 0,
+ UTIL_CPU_ARCH_MIPS,
+ UTIL_CPU_ARCH_ALPHA,
+ UTIL_CPU_ARCH_SPARC,
+ UTIL_CPU_ARCH_X86,
+ UTIL_CPU_ARCH_POWERPC
+};
-struct cpu_detect_caps {
- cpu_detect_type type;
- int nrcpu;
+struct util_cpu_caps {
+ enum util_cpu_arch arch;
+ unsigned nr_cpus;
- /* Feature flags */
- int x86cpuType;
- int cacheline;
+ /* Feature flags */
+ int x86_cpu_type;
+ unsigned cacheline;
- int hasTSC;
- int hasMMX;
- int hasMMX2;
- int hasSSE;
- int hasSSE2;
- int hasSSE3;
- int hasSSSE3;
- int has3DNow;
- int has3DNowExt;
- int hasAltiVec;
+ unsigned has_tsc:1;
+ unsigned has_mmx:1;
+ unsigned has_mmx2:1;
+ unsigned has_sse:1;
+ unsigned has_sse2:1;
+ unsigned has_sse3:1;
+ unsigned has_ssse3:1;
+ unsigned has_sse4_1:1;
+ unsigned has_3dnow:1;
+ unsigned has_3dnow_ext:1;
+ unsigned has_altivec:1;
};
-/* prototypes */
-void cpu_detect_initialize(void);
-struct cpu_detect_caps *cpu_detect_get_caps(void);
+extern struct util_cpu_caps
+util_cpu_caps;
+
+void util_cpu_detect(void);
-int cpu_detect_get_tsc(void);
-int cpu_detect_get_mmx(void);
-int cpu_detect_get_mmx2(void);
-int cpu_detect_get_sse(void);
-int cpu_detect_get_sse2(void);
-int cpu_detect_get_sse3(void);
-int cpu_detect_get_ssse3(void);
-int cpu_detect_get_3dnow(void);
-int cpu_detect_get_3dnow2(void);
-int cpu_detect_get_altivec(void);
-#endif /* _CPU_DETECT_H */
+#endif /* _UTIL_CPU_DETECT_H */