Skip to content

Commit

Permalink
Little fix proposal for i386 arch.
Browse files Browse the repository at this point in the history
needs to preserv ebx for the i386 architecture with PIC builds.
  • Loading branch information
devnexen committed Jun 6, 2020
1 parent db085ff commit eb6d59c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sources/Core/CpuID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit eb6d59c

Please sign in to comment.