From 30b918b30e23b342a376e8d57ff0cae15ba1bb6c Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 25 Jun 2024 15:09:55 +0200 Subject: [PATCH] Assume cpuid is available on x86_64, needs testing on i386 and unavailable on anything else --- LEGO1/mxdirectx/mxdirect3d.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/LEGO1/mxdirectx/mxdirect3d.cpp b/LEGO1/mxdirectx/mxdirect3d.cpp index ccfd6405..8e4a94e8 100644 --- a/LEGO1/mxdirectx/mxdirect3d.cpp +++ b/LEGO1/mxdirectx/mxdirect3d.cpp @@ -1054,6 +1054,7 @@ int MxDeviceEnumerate::SupportsCPUID() { int has_cpuid; #ifdef _MSC_VER +#if defined(_M_IX86) __asm { xor eax, eax ; Zero EAX register pushfd ; Push EFLAGS register value on the stack @@ -1065,7 +1066,13 @@ int MxDeviceEnumerate::SupportsCPUID() popfd ; Push EFLAGS register value on the stack (again, and makes sure the stack remains the same) mov has_cpuid, eax ; Save eax into C variable } +#elif defined(_M_X64) + has_cpuid = 1; #else + has_cpuid = 0; +#endif +#else +#if defined(__i386__) __asm__("xorl %%eax, %%eax\n\t" // Zero EAX register "pushfl\n\t" // Push EFLAGS register value on the stack "orl $0x200000, (%%esp)\n\t" // Set bit 0x200000: Able to use CPUID instruction (Pentium+) @@ -1076,6 +1083,11 @@ int MxDeviceEnumerate::SupportsCPUID() "popfl" // Push EFLAGS register value on the stack (again, and makes sure the stack remains the same) : "=a"(has_cpuid) // has_cpuid == EAX ); +#elif defined(__x86_64__) || defined(__amd64__) + has_cpuid = 1; +#else + has_cpuid = 0; +#endif #endif return has_cpuid; }