[rdrand] add possible workaround for fPIC building

This commit is contained in:
Vincent Hanquez 2016-06-14 07:24:08 +01:00
parent de17b66e31
commit 8c19352e48

View File

@ -37,7 +37,12 @@
int cryptonite_cpu_has_rdrand()
{
uint32_t ax,bx,cx,dx,func=1;
#if defined(__PIC__) && defined(__i386__)
__asm__ volatile ("mov %%ebx, %%edi;" "cpuid;" "xchgl %%ebx, %%edi;"
: "=a" (ax), "=D" (bx), "=c" (cx), "=d" (dx) : "a" (func));
#else
__asm__ volatile ("cpuid": "=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) : "a" (func));
#endif
return (cx & 0x40000000);
}