[PATCH v3 3/4] ntdll: Avoid inline assembly in do_cpuid().
Zebediah Figura
z.figura12 at gmail.com
Mon Nov 26 10:00:05 CST 2018
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
v3: fix stack offsets
dlls/ntdll/nt.c | 47 +++++++++++++++++++++++++++++------------------
1 file changed, 29 insertions(+), 18 deletions(-)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 5c711ef25b..288f4a4f16 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -944,27 +944,38 @@ static SYSTEM_CPU_INFORMATION cached_sci;
#define INEI 0x49656e69 /* "ineI" */
#define NTEL 0x6c65746e /* "ntel" */
-/* Calls cpuid with an eax of 'ax' and returns the 16 bytes in *p
- * We are compiled with -fPIC, so we can't clobber ebx.
- */
-static inline void do_cpuid(unsigned int ax, unsigned int *p)
-{
+extern void do_cpuid(unsigned int ax, unsigned int *p);
+
#ifdef __i386__
- __asm__("pushl %%ebx\n\t"
- "cpuid\n\t"
- "movl %%ebx, %%esi\n\t"
- "popl %%ebx"
- : "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3])
- : "0" (ax));
+__ASM_GLOBAL_FUNC( do_cpuid,
+ "pushl %esi\n\t"
+ "pushl %ebx\n\t"
+ "movl 12(%esp),%eax\n\t"
+ "movl 16(%esp),%esi\n\t"
+ "cpuid\n\t"
+ "movl %eax,(%esi)\n\t"
+ "movl %ebx,4(%esi)\n\t"
+ "movl %ecx,8(%esi)\n\t"
+ "movl %edx,12(%esi)\n\t"
+ "popl %ebx\n\t"
+ "popl %esi\n\t"
+ "ret" );
#elif defined(__x86_64__)
- __asm__("push %%rbx\n\t"
- "cpuid\n\t"
- "movq %%rbx, %%rsi\n\t"
- "pop %%rbx"
- : "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3])
- : "0" (ax));
-#endif
+__ASM_GLOBAL_FUNC( do_cpuid,
+ "pushq %rbx\n\t"
+ "movl %edi,%eax\n\t"
+ "cpuid\n\t"
+ "movl %eax,(%rsi)\n\t"
+ "movl %ebx,4(%rsi)\n\t"
+ "movl %ecx,8(%rsi)\n\t"
+ "movl %edx,12(%rsi)\n\t"
+ "popq %rbx\n\t"
+ "ret" );
+#else
+void do_cpuid(unsigned int ax, unsigned int *p)
+{
}
+#endif
/* From xf86info havecpuid.c 1.11 */
static inline BOOL have_cpuid(void)
--
2.14.1
More information about the wine-devel
mailing list