From 9e525098910bdde15bab418f0528cf7c6f213219 Mon Sep 17 00:00:00 2001 From: RainbowC0 <67918391+RainbowC0@users.noreply.github.com> Date: Fri, 3 Feb 2023 22:14:20 +0800 Subject: [PATCH] Update x64emu.c Added some adapations for Android as there is no __builtin_aarch64_get_fpcr and __builtin_aarch64_set_fpcr in Bionic. --- src/emu/x64emu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/emu/x64emu.c b/src/emu/x64emu.c index 6442adf72..2f46472ce 100755 --- a/src/emu/x64emu.c +++ b/src/emu/x64emu.c @@ -518,10 +518,19 @@ void applyFlushTo0(x64emu_t* emu) #ifdef __x86_64__ _mm_setcsr(_mm_getcsr() | (emu->mxcsr.x32&0x8040)); #elif defined(__aarch64__) + #ifdef __ANDROID__ + uint64_t fpcr; + __asm__ __volatile__ ("mrs %0, fpcr":"=r"(fpcr)); + #else uint64_t fpcr = __builtin_aarch64_get_fpcr(); + #endif fpcr &= ~((1<<24) | (1<<1)); // clear bit FZ (24) and AH (1) fpcr |= (emu->mxcsr.f.MXCSR_FZ)<<24; // set FZ as mxcsr FZ fpcr |= ((emu->mxcsr.f.MXCSR_DAZ)^(emu->mxcsr.f.MXCSR_FZ))<<1; // set AH if DAZ different from FZ + #ifdef __ANDROID__ + __asm__ __volatile__ ("msr fpcr, %0"::"r"(fpcr)); + #else __builtin_aarch64_set_fpcr(fpcr); #endif -} \ No newline at end of file + #endif +}