1 /** 2 * This file has no copyright assigned and is placed in the Public Domain. 3 * This file is part of the mingw-w64 runtime package. 4 * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 */ 6 #include <fenv.h> 7 8 /* 7.6.4.2 9 The feholdexcept function saves the current floating-point 10 environment in the object pointed to by envp, clears the exception 11 flags, and then installs a non-stop (continue on exceptions) mode, 12 if available, for all exceptions. */ 13 feholdexcept(fenv_t * envp)14int feholdexcept (fenv_t * envp) 15 { 16 #if defined(_ARM_) || defined(__arm__) 17 fenv_t _env; 18 __asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env)); 19 envp->__cw = _env.__cw; 20 _env.__cw &= ~(FE_ALL_EXCEPT); 21 __asm__ volatile ("fmxr FPSCR, %0" : : "r" (_env)); 22 #elif defined(_ARM64_) || defined(__aarch64__) 23 unsigned __int64 fpcr; 24 __asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr)); 25 envp->__cw = fpcr; 26 fpcr &= ~(FE_ALL_EXCEPT); 27 __asm__ volatile ("msr fpcr, %0" : : "r" (fpcr)); 28 #else 29 __asm__ __volatile__ ("fnstenv %0;" : "=m" (* envp)); /* save current into envp */ 30 /* fnstenv sets control word to non-stop for all exceptions, so all we 31 need to do is clear the exception flags. */ 32 __asm__ __volatile__ ("fnclex"); 33 #endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */ 34 return 0; 35 } 36