ATLAS Offline Software
excepts.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id$
13 #include "CxxUtils/excepts.h"
14 
15 #ifdef __APPLE__
16 #include <fenv.h>
17 
18 int
19 feenableexcept (unsigned int excepts)
20 {
21  static fenv_t fenv;
22  unsigned int new_excepts = excepts & FE_ALL_EXCEPT,
23  old_excepts; // previous masks
24 
25  if ( fegetenv (&fenv) ) return -1;
26  old_excepts = fenv.__control & FE_ALL_EXCEPT;
27 
28  // unmask
29  fenv.__control &= ~new_excepts;
30  fenv.__mxcsr &= ~(new_excepts << 7);
31 
32  return ( fesetenv (&fenv) ? -1 : old_excepts );
33 }
34 
35 int
36 fedisableexcept (unsigned int excepts)
37 {
38  static fenv_t fenv;
39  unsigned int new_excepts = excepts & FE_ALL_EXCEPT,
40  old_excepts; // all previous masks
41 
42  if ( fegetenv (&fenv) ) return -1;
43  old_excepts = fenv.__control & FE_ALL_EXCEPT;
44 
45  // mask
46  fenv.__control |= new_excepts;
47  fenv.__mxcsr |= new_excepts << 7;
48 
49  return ( fesetenv (&fenv) ? -1 : old_excepts );
50 }
51 #endif
excepts.h
Declarations of feenableexcept()/fedisableexcept() functions for MacOSX.