[PATCH v2 4/4] ntdll: Avoid inline assembly in have_cpuid().

Zebediah Figura z.figura12 at gmail.com
Sun Nov 25 22:31:52 CST 2018


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/ntdll/nt.c | 42 ++++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index a3aa6358a6..eaff8df8bf 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -978,30 +978,32 @@ void do_cpuid(unsigned int ax, unsigned int *p)
 }
 #endif
 
-/* From xf86info havecpuid.c 1.11 */
-static inline BOOL have_cpuid(void)
-{
+extern int have_cpuid(void);
+
 #ifdef __i386__
-	unsigned int f1, f2;
-	__asm__("pushfl\n\t"
-                "pushfl\n\t"
-                "popl %0\n\t"
-                "movl %0,%1\n\t"
-                "xorl %2,%0\n\t"
-                "pushl %0\n\t"
-                "popfl\n\t"
-                "pushfl\n\t"
-                "popl %0\n\t"
-                "popfl"
-                : "=&r" (f1), "=&r" (f2)
-                : "ir" (0x00200000));
-	return ((f1^f2) & 0x00200000) != 0;
+__ASM_GLOBAL_FUNC( have_cpuid,
+                   "pushfl\n\t"
+                   "pushfl\n\t"
+                   "movl (%esp),%ecx\n\t"
+                   "xorl $0x00200000,(%esp)\n\t"
+                   "popfl\n\t"
+                   "pushfl\n\t"
+                   "popl %eax\n\t"
+                   "popfl\n\t"
+                   "xorl %ecx,%eax\n\t"
+                   "andl $0x00200000,%eax\n\t"
+                   "ret" );
 #elif defined(__x86_64__)
-        return TRUE;
+int have_cpuid(void)
+{
+    return 1;
+}
 #else
-        return FALSE;
-#endif
+int have_cpuid(void)
+{
+    return 0;
 }
+#endif
 
 /* Detect if a SSE2 processor is capable of Denormals Are Zero (DAZ) mode.
  *
-- 
2.14.1




More information about the wine-devel mailing list