[PATCH 1/2] msvcrt: Implement fesetenv for aarch64

Martin Storsjo martin at martin.st
Sun Aug 1 16:04:30 CDT 2021


This uses _control87 for setting the control bits, and implements
the mirror operation of _statusfp.

This fixes a bunch of tests in msvcr120.

Signed-off-by: Martin Storsjo <martin at martin.st>
---
 dlls/msvcrt/math.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 124cdf80098..81ae9b02a61 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -5988,6 +5988,19 @@ int CDECL fesetenv(const fenv_t *env)
         __asm__ __volatile__( "ldmxcsr %0" : : "m" (fpword) );
     }
 
+    return 0;
+#elif defined(__aarch64__)
+    _control87(env->_Fe_ctl, 0xffffffff);
+    ULONG_PTR fpsr;
+    __asm__ __volatile__( "mrs %0, fpsr" : "=r" (fpsr) );
+    fpsr &= ~0x9f;
+    if (env->_Fe_stat & _SW_INVALID)    fpsr |= 0x1;
+    if (env->_Fe_stat & _SW_ZERODIVIDE) fpsr |= 0x2;
+    if (env->_Fe_stat & _SW_OVERFLOW)   fpsr |= 0x4;
+    if (env->_Fe_stat & _SW_UNDERFLOW)  fpsr |= 0x8;
+    if (env->_Fe_stat & _SW_INEXACT)    fpsr |= 0x10;
+    if (env->_Fe_stat & _SW_DENORMAL)   fpsr |= 0x80;
+    __asm__ __volatile__( "msr fpsr, %0" :: "r" (fpsr) );
     return 0;
 #else
     FIXME( "not implemented\n" );
-- 
2.25.1




More information about the wine-devel mailing list