[MPlayer-dev-eng] Re: [PATCH] Various improvement in TOOLS/cpuinfo.c
Zuxy Meng
zuxy.meng at gmail.com
Wed May 17 20:38:25 CEST 2006
2006/5/16, Zuxy Meng <zuxy.meng at gmail.com>:
> 2006/5/16, Guillaume POIRIER <poirierg at gmail.com>:
> > Hi,
> >
> > On 5/15/06, Zuxy Meng <zuxy.meng at gmail.com> wrote:
> > > Hi,
> > >
> > > 2006/5/16, Guillaume POIRIER <poirierg at gmail.com>:
> > > > Hi,
> > > >
> > > >
> > > > Ok, good to know. The previous version (before last night) wasn't
> > > > working on amd64 anyhow, so at least your patch fixes a known
> > > > regression.
> > > >
> > > > I'm sure there's a way to support "macintel", amd64 and ia34...
> > >
> > > Will gcc define a macro like TARGET_64BIT under amd64?
> >
> > Maybe it does, I have not been able to find much information about it
> > besides http://gcc.gnu.org/onlinedocs/gccint/Defining-Mode-Macros.html
> > and http://gcc.gnu.org/onlinedocs/gccint/Examples.html
> >
> > The simplest way is probably to test on an amd64 machine.
>
> Would please try __x86_64__? See if it's defined under amd64, and
> undefined under x86 and amd64 with -m32.
>
> >
> > In any case, no need to worry, the patch you sent today works on AMD64
> > (I just checked now as I'm home).
> >
>
> It might work, if the context use rbx as a 32 bit int; it mighty fail,
> if the context use rbx as a 64 bit pointer. There's no guarantee
> here:-(
I checked gcc's source and confirmed that __x86_64__ would indicate
that we're under x86_64, so the attached patch should be OK.
--
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6
-------------- next part --------------
--- main/TOOLS/cpuinfo.c 2006-05-16 01:31:44.000000000 +0800
+++ main.new/TOOLS/cpuinfo.c 2006-05-16 01:34:29.000000000 +0800
@@ -43,9 +43,17 @@
cpuid(int func) {
cpuid_regs_t regs;
#define CPUID ".byte 0x0f, 0xa2; "
+#ifdef __x86_64__
+ asm("mov %%rbx, %%rsi\n\t"
+#else
asm("mov %%ebx, %%esi\n\t"
+#endif
CPUID"\n\t"
- "xchg %%esi, %%ebx"
+#ifdef __x86_64__
+ "xchg %%rsi, %%rbx\n\t"
+#else
+ "xchg %%esi, %%ebx\n\t"
+#endif
: "=a" (regs.eax), "=S" (regs.ebx), "=c" (regs.ecx), "=d" (regs.edx)
: "0" (func));
return regs;
More information about the MPlayer-dev-eng
mailing list