Mesa (master): util: Fix cpuid invocation for x86_64.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Sun Oct 4 21:03:45 UTC 2009


Module: Mesa
Branch: master
Commit: 7a7dfb09aadf0509db4c1e2752fff5b75c59406b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7a7dfb09aadf0509db4c1e2752fff5b75c59406b

Author: José Fonseca <jfonseca at vmware.com>
Date:   Sun Oct  4 12:49:31 2009 +0100

util: Fix cpuid invocation for x86_64.

---

 src/gallium/auxiliary/util/u_cpu_detect.c |   34 +++++++++++++++++++---------
 1 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_cpu_detect.c b/src/gallium/auxiliary/util/u_cpu_detect.c
index ecfb961..e26214c 100644
--- a/src/gallium/auxiliary/util/u_cpu_detect.c
+++ b/src/gallium/auxiliary/util/u_cpu_detect.c
@@ -336,23 +336,35 @@ cpuid(unsigned int ax, unsigned int *p)
 {
    int ret = -1;
 
-#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
-#if defined(PIPE_CC_GCC)
-   __asm __volatile
-      ("movl %%ebx, %%esi\n\t"
-       "cpuid\n\t"
-       "xchgl %%ebx, %%esi"
-       : "=a" (p[0]), "=S" (p[1]),
-       "=c" (p[2]), "=d" (p[3])
-       : "0" (ax));
-
+#if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)
+   __asm __volatile (
+     "movl %%ebx, %%esi\n\t"
+     "cpuid\n\t"
+     "xchgl %%ebx, %%esi"
+     : "=a" (p[0]),
+       "=S" (p[1]),
+       "=c" (p[2]),
+       "=d" (p[3])
+     : "0" (ax)
+   );
+   ret = 0;
+#elif defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86_64)
+   __asm __volatile (
+     "movq %%rbx, %%rsi\n\t"
+     "cpuid\n\t"
+     "xchgq %%rbx, %%rsi"
+     : "=a" (p[0]),
+       "=S" (p[1]),
+       "=c" (p[2]),
+       "=d" (p[3])
+     : "0" (ax)
+   );
    ret = 0;
 #elif defined(PIPE_CC_MSVC)
    __cpuid(ax, p);
 
    ret = 0;
 #endif
-#endif
 
    return ret;
 }




More information about the mesa-commit mailing list