ref: 766a20f4816f5d08275a430ed68d788aefb23e5b
parent: 1f2c97ef13d66e4787ea1da86a75c6ab7d3b66a7
author: Chris Moeller <kode54@gmail.com>
date: Fri Jan 16 15:52:57 EST 2015
Fixed compilation with -fPIC on x86 and x64
--- a/dumb/src/it/itrender.c
+++ b/dumb/src/it/itrender.c
@@ -753,6 +753,21 @@
static inline void
__cpuid(int *data, int selector)
{
+#if defined(__PIC__) && defined(__i386__)
+ asm("xchgl %%ebx, %%esi; cpuid; xchgl %%ebx, %%esi"
+ : "=a" (data[0]),
+ "=S" (data[1]),
+ "=c" (data[2]),
+ "=d" (data[3])
+ : "0" (selector));
+#elif defined(__PIC__) && defined(__amd64__)
+ asm("xchg{q} {%%}rbx, %q1; cpuid; xchg{q} {%%}rbx, %q1"
+ : "=a" (data[0]),
+ "=&r" (data[1]),
+ "=c" (data[2]),
+ "=d" (data[3])
+ : "0" (selector));
+#else
asm("cpuid"
: "=a" (data[0]),
"=b" (data[1]),
@@ -759,6 +774,7 @@
"=c" (data[2]),
"=d" (data[3])
: "a"(selector));
+#endif
}
#else
#define __cpuid(a,b) memset((a), 0, sizeof(int) * 4)