wingo pushed a commit to branch lightning
in repository guile.
commit c146f067937fbd285ec378b1e7e0583f60a74bae
Author: pcpa <[email protected]>
Date: Sun Feb 23 17:31:12 2014 -0300
x86_64: Change x86_64 to also save/restore %rbx in inline asm.
* lib/jit_x86.c: Rewrite previous patch to inline save/restore
because clobbering %ebx in x86 is treated as an error
(jit_x86.c:239:5: error: PIC register clobbered by 'ebx' in 'asm').
---
ChangeLog | 6 ++++++
lib/jit_x86.c | 20 +++++++++++---------
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f3ab5a0..d5a24a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-23-02 Paulo Andrade <[email protected]>
+
+ * lib/jit_x86.c: Rewrite previous patch to inline save/restore
+ because clobbering %ebx in x86 is treated as an error
+ (jit_x86.c:239:5: error: PIC register clobbered by 'ebx' in 'asm').
+
2014-19-02 Paulo Andrade <[email protected]>
* lib/jit_x86.c: Rewrite incorrect inline assembly that could
diff --git a/lib/jit_x86.c b/lib/jit_x86.c
index 027e6db..5eaad68 100644
--- a/lib/jit_x86.c
+++ b/lib/jit_x86.c
@@ -170,7 +170,7 @@ jit_get_cpu(void)
jit_uint32_t __reserved3 : 1;
jit_uint32_t __alwayszero : 1; /* amd RAZ */
} bits;
- jit_uint32_t cpuid;
+ jit_uword_t cpuid;
} ecx;
union {
struct {
@@ -207,12 +207,12 @@ jit_get_cpu(void)
jit_uint32_t __reserved2 : 1;
jit_uint32_t pbe : 1; /* amd reserved */
} bits;
- jit_uint32_t cpuid;
+ jit_uword_t cpuid;
} edx;
#if __WORDSIZE == 32
int ac, flags;
#endif
- jit_uint32_t eax, ebx;
+ jit_uword_t eax, ebx;
#if __WORDSIZE == 32
/* adapted from glibc __sysconf */
@@ -236,11 +236,14 @@ jit_get_cpu(void)
#endif
/* query %eax = 1 function */
- __asm__ volatile ("cpuid; movl %%ebx, %1"
+#if __WORDSIZE == 32
+ __asm__ volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1"
+#else
+ __asm__ volatile ("xchgq %%rbx, %1; cpuid; xchgq %%rbx, %1"
+#endif
: "=a" (eax), "=r" (ebx),
"=c" (ecx.cpuid), "=d" (edx.cpuid)
- : "0" (1)
- : "ebx");
+ : "0" (1));
jit_cpu.fpu = edx.bits.fpu;
jit_cpu.cmpxchg8b = edx.bits.cmpxchg8b;
@@ -262,11 +265,10 @@ jit_get_cpu(void)
#if __WORDSIZE == 64
/* query %eax = 0x80000001 function */
- __asm__ volatile ("cpuid; movl %%ebx, %1"
+ __asm__ volatile ("xchgq %%rbx, %1; cpuid; xchgq %%rbx, %1"
: "=a" (eax), "=r" (ebx),
"=c" (ecx.cpuid), "=d" (edx.cpuid)
- : "0" (0x80000001)
- : "ebx");
+ : "0" (0x80000001));
jit_cpu.lahf = ecx.cpuid & 1;
#endif
}