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.2.3 9 The feraiseexcept function raises the supported exceptions 10 represented by its argument The order in which these exceptions 11 are raised is unspecified, except as stated in F.7.6. 12 Whether the feraiseexcept function additionally raises 13 the inexact exception whenever it raises the overflow 14 or underflow exception is implementation-defined. */ 15 feraiseexcept(int excepts)16int feraiseexcept (int excepts) 17 { 18 fenv_t _env; 19 #if defined(_ARM_) || defined(__arm__) 20 __asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env)); 21 _env.__cw |= excepts & FE_ALL_EXCEPT; 22 __asm__ volatile ("fmxr FPSCR, %0" : : "r" (_env)); 23 #elif defined(_ARM64_) || defined(__aarch64__) 24 unsigned __int64 fpcr; 25 (void) _env; 26 __asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr)); 27 fpcr |= excepts & FE_ALL_EXCEPT; 28 __asm__ volatile ("msr fpcr, %0" : : "r" (fpcr)); 29 #else 30 __asm__ volatile ("fnstenv %0;" : "=m" (_env)); 31 _env.__status_word |= excepts & FE_ALL_EXCEPT; 32 __asm__ volatile ("fldenv %0;" 33 "fwait;" : : "m" (_env)); 34 #endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */ 35 return 0; 36 } 37