71 template<
class T>
class UList;
83 static bool switchFpe_;
87 static bool switchNan_;
90 static bool sigActive_;
93 static bool nanActive_;
99 static void sigHandler(
int);
102 template<
class FloatType>
103 inline static void fill_with_NaN(FloatType* buf,
size_t count)
108 std::numeric_limits<FloatType>::signaling_NaN();
114 std::fill_n(buf,
count, val);
150 bool old(nanActive_);
157 static void set(
bool verbose=
false);
160 static void unset(
bool verbose=
false);
170 reinterpret_cast<Foam::scalar*>(buf),
182 reinterpret_cast<Foam::scalar*>(buf),
183 (
count/
sizeof(Foam::scalar))
188 static void fillNan(UList<float>& list);
191 static void fillNan(UList<double>& list);
static void set(bool verbose=false)
Activate SIGFPE handler when FOAM_SIGFPE is enabled. Activate fill memory with signaling_NaN when FOA...
static void fillNan(char *buf, size_t count)
Fill data block with signaling_NaN values. Does a reinterpret to Foam::scalar.
static bool active() noexcept
True if SIGFPE handling is currently active.
static void fillNan_if(void *buf, size_t count)
Fill data block with signaling_NaN values if nanActive(). Does a reinterpret to Foam::scalar.
static bool requested()
Check if SIGFPE signals handler is to be enabled.
ignore()
Constructor deactivates any previously active SIGFPE handler.
~sigFpe()
Destructor calls unset() to deactivate the FPE signal handler as required.
static void unset(bool verbose=false)
Deactivate SIGFPE handler and NaN memory initialisation.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Set up trapping for floating point exceptions (signal FPE).
~ignore()
Destructor restores the original state of SIGFPE handler.
Helper to locally ignore SIGFPE handling.
static bool nanActive() noexcept
True if NaN memory initialisation is currently active.
Typedefs for float/double/scalar without requiring scalar.H.
void operator=(const ignore &)=delete
No copy assignment.
void reset()
Restore the original state of SIGFPE handler.
sigFpe()
Constructor calls set() to activate the FPE signal handler if it was was not previously activate and ...
void restore()
Same as reset()