1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-04 14:20:26 +02:00

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').
This commit is contained in:
pcpa 2014-02-23 17:31:12 -03:00
parent dbb9fe1e81
commit c146f06793
2 changed files with 17 additions and 9 deletions

View file

@ -1,3 +1,9 @@
2014-23-02 Paulo Andrade <pcpa@gnu.org>
* 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 <pcpa@gnu.org>
* lib/jit_x86.c: Rewrite incorrect inline assembly that could

View file

@ -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
}