39#if defined(__linux__) && defined(__GNUC__)
60bool Foam::sigFpe::sigActive_ =
false;
61bool Foam::sigFpe::nanActive_ =
false;
68static bool isTrue(
const char* envName,
bool deflt)
74 return static_cast<bool>(sw);
85 extern void* __libc_malloc(
size_t size);
88 void* malloc(
size_t size)
92 return Foam::sigFpe::mallocNan(size);
96 return __libc_malloc(size);
102void* Foam::sigFpe::mallocNan(
size_t size)
105 void* result = __libc_malloc(size);
108 UList<scalar> list(
reinterpret_cast<scalar*
>(result), size/
sizeof(scalar));
118void Foam::sigFpe::sigHandler(
int)
120 #if (defined(__linux__) && defined(__GNUC__)) || defined(__APPLE__)
142 wasActive_(sigFpe::active())
179 return isTrue(
"FOAM_SIGFPE", switchFpe_);
185 if (!sigActive_ && requested())
187 #if (defined(__linux__) && defined(__GNUC__)) || defined(__APPLE__)
203 Info<<
"trapFpe: Floating point exception trapping ";
207 Info<<
"enabled (FOAM_SIGFPE)." <<
endl;
211 Info<<
"- not supported on this platform" <<
endl;
218 if (
isTrue(
"FOAM_SETNAN", switchNan_))
226 Info<<
"setNaN : Initialise allocated memory to NaN ";
230 Info<<
"enabled (FOAM_SETNAN)." <<
endl;
234 Info<<
" - not supported on this platform" <<
endl;
243 #if (defined(__linux__) && defined(__GNUC__)) || defined(__APPLE__)
248 Info<<
"sigFpe : Disabling floating point exception trapping"
255 const int oldExcept = fedisableexcept
265 <<
"Cannot reset SIGFPE trapping"
279 list = std::numeric_limits<scalar>::signaling_NaN();
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
static bool isTrue(const char *envName, bool deflt)
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
static bool isTrue(const char *envName, bool deflt)
File-local code for setting/resetting signal handlers.
static void shutdown()
Simple shutdown (finalize) of JobInfo.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
bool good() const noexcept
True if the Switch represents a valid enumeration.
static Switch find(const std::string &str)
static void printStack(Ostream &os)
Helper function to print a stack.
ignore()
Constructor deactivates any previously active SIGFPE handler.
~ignore()
Destructor restores the original state of SIGFPE handler.
void restore()
Restore the original state of SIGFPE handler.
static void fillNan(UList< scalar > &list)
Fill data block with NaN values.
static bool nanActive()
True if NaN memory initialisation is currently active.
static void unset(bool verbose=false)
Deactivate SIGFPE signal handler and NaN memory initialisation.
static bool requested()
Check if SIGFPE signals handler is to be enabled.
bool set() const
Are all the vector set.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
int optimisationSwitch(const char *name, const int deflt=0)
Lookup optimisation switch or add default value.
string getEnv(const std::string &envName)
Get environment value for given envName.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
static void setHandler(const char *what, int sigNum, void(*handler)(int))
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
static void resetHandler(const char *what, int sigNum)