Merge pull request #899 from devnexen/i386_build_fix

Preserves EBX manually for the i386 architecture with PIC builds.
This commit is contained in:
Tomoaki Kawada 2020-06-08 12:54:04 +09:00 committed by GitHub
commit 502e02a2df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,11 @@ namespace spades {
std::array<uint32_t, 4> regs;
#ifdef WIN32
__cpuid(reinterpret_cast<int *>(regs.data()), a);
#else
#if defined(__i386__) && (defined(__pic__) || defined(__PIC__))
asm volatile("mov %%ebx, %%edi\ncpuid\nxchg %%edi, %%ebx\n"
: "=a"(regs[0]), "=D"(regs[1]), "=c"(regs[2]), "=d"(regs[2])
: "a"(a), "c"(0));
#else
asm volatile("cpuid"
: "=a"(regs[0]), "=b"(regs[1]), "=c"(regs[2]), "=d"(regs[3])