[Zlib-devel] [PATCH 02/13] For x86, add CPUID check.

Jim Kukunas james.t.kukunas at linux.intel.com
Fri Nov 29 05:02:35 EST 2013


On Thu, Nov 28, 2013 at 01:51:43AM -0500, Mike Frysinger wrote:
> > +int x86_cpu_has_sse2;
> > +int x86_cpu_has_sse42;
> > +int x86_cpu_has_pclmulqdq;
> > +
> > +void x86_check_features(void)
> > +{
> > +    unsigned eax, ebx, ecx, edx;
> > +
> > +    eax = 1;
> > +    __asm__ __volatile__ (
> > +        "cpuid\n\t"
> > +    : "+a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
> > +    );
> 
> pretty sure this won't compile under PIC.  it'll complain about ebx being 
> clobbered.  this one will always work:
> 	__asm__ __volatile__ (
> 		"xchg %%ebx, %%esi;"
> 		"cpuid;"
> 		"xchg %%esi, %%ebx;"
> 		: "=S" (ebx), "=a" (eax), "=c" (ecx), "=d" (edx)
> 		: "a" (1));

Hi Mike,

Do you actually see a compiler error here?

In the extended assembler syntax, ebx is marked as being clobbered,
so the compiler should automatically handle the save and restore. I know
GCC does.

Thanks.

-- 
Jim Kukunas
Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://madler.net/pipermail/zlib-devel_madler.net/attachments/20131129/54906583/attachment-0001.sig>


More information about the Zlib-devel mailing list