[Zlib-devel] [PATCH 02/13] For x86, add CPUID check.
Mike Frysinger
vapier at gentoo.org
Thu Nov 28 01:51:43 EST 2013
On Monday 25 November 2013 17:21:38 Jim Kukunas wrote:
> --- /dev/null
> +++ b/x86.c
> @@ -0,0 +1,21 @@
> +#include "x86.h"
all files really should have a comment block at the top. a simple one line
explanation, short copyright/license blurb/etc...
> +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));
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://madler.net/pipermail/zlib-devel_madler.net/attachments/20131128/0ef4d7b9/attachment-0001.sig>
More information about the Zlib-devel
mailing list