aboutsummaryrefslogtreecommitdiff
path: root/sp/src/tier1/processor_detect_linux.cpp
diff options
context:
space:
mode:
authorJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
committerJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
commit39ed87570bdb2f86969d4be821c94b722dc71179 (patch)
treeabc53757f75f40c80278e87650ea92808274aa59 /sp/src/tier1/processor_detect_linux.cpp
downloadsource-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz
source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip
First version of the SOurce SDK 2013
Diffstat (limited to 'sp/src/tier1/processor_detect_linux.cpp')
-rw-r--r--sp/src/tier1/processor_detect_linux.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/sp/src/tier1/processor_detect_linux.cpp b/sp/src/tier1/processor_detect_linux.cpp
new file mode 100644
index 00000000..8e4f709f
--- /dev/null
+++ b/sp/src/tier1/processor_detect_linux.cpp
@@ -0,0 +1,47 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: linux dependant ASM code for CPU capability detection
+//
+// $Workfile: $
+// $NoKeywords: $
+//=============================================================================//
+
+#define cpuid(in,a,b,c,d) \
+ asm("pushl %%ebx\n\t" "cpuid\n\t" "movl %%ebx,%%esi\n\t" "pop %%ebx": "=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (in));
+
+bool CheckMMXTechnology(void)
+{
+ unsigned long eax,ebx,edx,unused;
+ cpuid(1,eax,ebx,unused,edx);
+
+ return edx & 0x800000;
+}
+
+bool CheckSSETechnology(void)
+{
+ unsigned long eax,ebx,edx,unused;
+ cpuid(1,eax,ebx,unused,edx);
+
+ return edx & 0x2000000L;
+}
+
+bool CheckSSE2Technology(void)
+{
+ unsigned long eax,ebx,edx,unused;
+ cpuid(1,eax,ebx,unused,edx);
+
+ return edx & 0x04000000;
+}
+
+bool Check3DNowTechnology(void)
+{
+ unsigned long eax, unused;
+ cpuid(0x80000000,eax,unused,unused,unused);
+
+ if ( eax > 0x80000000L )
+ {
+ cpuid(0x80000001,unused,unused,unused,eax);
+ return ( eax & 1<<31 );
+ }
+ return false;
+}