Go to the documentation of this file.
50 bool Foam::sigFpe::sigActive_ =
false;
51 bool Foam::sigFpe::nanActive_ =
false;
59 #ifndef Foam_no_sigFpe
61 _controlfp(
oldFpe_, 0xFFFFFFFF);
70 static bool isTrue(
const char* envName,
bool deflt)
76 return static_cast<bool>(sw);
86 void Foam::sigFpe::sigHandler(
int)
107 wasActive_(
sigFpe::active())
144 return isTrue(
"FOAM_SIGFPE", switchFpe_);
152 #ifdef Foam_no_sigFpe
156 Info<<
"trapFpe: Floating point exception trapping ";
157 Info<<
"- disabled on this platform" <<
endl;
164 const unsigned int newFpe =
166 oldFpe_ & ~(_EM_ZERODIVIDE | _EM_INVALID | _EM_OVERFLOW)
169 _controlfp(newFpe, _MCW_EM);
177 Info<<
"trapFpe: Floating point exception trapping ";
181 Info<<
"enabled (FOAM_SIGFPE)." <<
endl;
185 Info<<
"- not supported on this platform" <<
endl;
193 if (
isTrue(
"FOAM_SETNAN", switchNan_))
197 Info<<
"setNaN : Initialise allocated memory to NaN "
198 <<
"- not supported on this platform" <<
endl;
210 Info<<
"sigFpe : Disabling floating point exception trapping"
227 list = std::numeric_limits<scalar>::signaling_NaN();
static void set(bool verbose=false)
Activate SIGFPE signal handler when FOAM_SIGFPE is set.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
static void printStack(Ostream &os)
Helper function to print a stack.
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
static void resetHandler(const char *what, int sigNum)
ignore()
Constructor deactivates any previously active SIGFPE handler.
static void unset(bool verbose=false)
Deactivate SIGFPE signal handler and NaN memory initialisation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool good() const noexcept
True if the Switch represents a valid enumeration.
static Switch find(const std::string &str)
string getEnv(const std::string &envName)
Get environment value for given envName.
static void fillNan(UList< scalar > &list)
Fill data block with NaN values.
messageStream Info
Information stream (stdout output on master, null elsewhere)
~ignore()
Destructor restores the original state of SIGFPE handler.
File-local code for setting/resetting signal handlers.
int optimisationSwitch(const char *name, const int deflt=0)
Lookup optimisation switch or add default value.
static void shutdown()
Simple shutdown (finalize) of JobInfo.
Set up trapping for floating point exceptions (signal FPE).
static bool requested()
Check if SIGFPE signals handler is to be enabled.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
static void setHandler(const char *what, int sigNum, void(*handler)(int))
void restore()
Restore the original state of SIGFPE handler.
static unsigned int oldFpe_
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
static bool isTrue(const char *envName, bool deflt)