@@ -506,6 +506,11 @@ void resetSignalHandling()
506506 }
507507}
508508
509+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
510+ int getDefaultFloatingPointExceptions ()
511+ {
512+ return ( FE_DIVBYZERO | FE_OVERFLOW | FE_INVALID );
513+ }
509514
510515// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
511516int enableFloatingPointExceptions ( int const exceptions )
@@ -515,14 +520,13 @@ int enableFloatingPointExceptions( int const exceptions )
515520 // http://www-personal.umich.edu/~williams/archive/computation/fe-handling-example.c
516521 static fenv_t fenv;
517522 int const newExcepts = exceptions & FE_ALL_EXCEPT;
518- // previous masks
519- int oldExcepts;
520523
521524 if ( fegetenv ( &fenv ))
522525 {
523526 return -1 ;
524527 }
525- oldExcepts = fenv.__control & FE_ALL_EXCEPT;
528+ // all previous masks
529+ int const oldExcepts = fenv.__control & FE_ALL_EXCEPT;
526530
527531 // unmask
528532 fenv.__control &= ~newExcepts;
@@ -544,14 +548,13 @@ int disableFloatingPointExceptions( int const exceptions )
544548 // http://www-personal.umich.edu/~williams/archive/computation/fe-handling-example.c
545549 static fenv_t fenv;
546550 int const newExcepts = exceptions & FE_ALL_EXCEPT;
547- // all previous masks
548- int oldExcepts;
549551
550552 if ( fegetenv ( &fenv ))
551553 {
552554 return -1 ;
553555 }
554- oldExcepts = fenv.__control & FE_ALL_EXCEPT;
556+ // all previous masks
557+ int const oldExcepts = ~( fenv.__control & FE_ALL_EXCEPT );
555558
556559 // mask
557560 fenv.__control |= newExcepts;
@@ -575,13 +578,9 @@ void setFPE()
575578 _MM_SET_DENORMALS_ZERO_MODE ( _MM_DENORMALS_ZERO_ON );
576579#endif
577580#if defined(__x86_64__)
578- enableFloatingPointExceptions ( FE_DIVBYZERO | FE_OVERFLOW | FE_INVALID );
581+ enableFloatingPointExceptions ( getDefaultFloatingPointExceptions () );
579582#endif
580583}
581584
582- // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
583- int getAllExceptionsMask ()
584- { return FE_ALL_EXCEPT; }
585-
586585} // namespace system
587586} // namespace LvArray
0 commit comments