summaryrefslogtreecommitdiff
path: root/tier1/processor_detect_linux.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /tier1/processor_detect_linux.cpp
downloadarchived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz
archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip
Diffstat (limited to 'tier1/processor_detect_linux.cpp')
-rw-r--r--tier1/processor_detect_linux.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/tier1/processor_detect_linux.cpp b/tier1/processor_detect_linux.cpp
new file mode 100644
index 0000000..c7c95d0
--- /dev/null
+++ b/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;
+}