sigFpe Class Reference

Set up trapping for floating point exceptions (signal FPE). More...

Classes

class  ignore
 Helper to locally ignore SIGFPE handling. More...
 

Public Member Functions

 sigFpe ()
 Constructor calls set() to activate the FPE signal handler if it was was not previously activate and requested() returns true. More...
 
 ~sigFpe ()
 Destructor calls unset() to deactivate the FPE signal handler as required. More...
 

Static Public Member Functions

static bool requested ()
 Check if SIGFPE signals handler is to be enabled. More...
 
static bool active () noexcept
 True if SIGFPE handling is currently active. More...
 
static bool nanActive () noexcept
 True if NaN memory initialisation is currently active. More...
 
static void set (bool verbose=false)
 Activate SIGFPE handler when FOAM_SIGFPE is enabled. Activate fill memory with signaling_NaN when FOAM_SETNAN is enabled. More...
 
static void unset (bool verbose=false)
 Deactivate SIGFPE handler and NaN memory initialisation. More...
 
static void fillNan (char *buf, size_t count)
 Fill data block with signaling_NaN values. More...
 
static void fillNan (UList< scalar > &list)
 Fill data block with signaling_NaN values. More...
 

Detailed Description

Set up trapping for floating point exceptions (signal FPE).

Defined by controlDict InfoSwitch entries:

  • trapFpe
    Enable floating point exception trapping.
  • setNaN
    Initialization all malloced memory to NaN. Combined with trapFpe, this causes usage of uninitialized scalars to trigger an abort.
    Environment variables:
    • FOAM_SIGFPE (true|false)
      overrides trapFpe
    • FOAM_SETNAN (true|false)
      overrides setNaN
      Note that trapping can be set/removed through the static member functions or through the scope of the object (constructor sets trapping; destructor restores original). The class behaves as a singleton.
Source files

Definition at line 70 of file sigFpe.H.

Constructor & Destructor Documentation

◆ sigFpe()

sigFpe ( )

Constructor calls set() to activate the FPE signal handler if it was was not previously activate and requested() returns true.

Definition at line 128 of file sigFpe.C.

◆ ~sigFpe()

~sigFpe ( )

Destructor calls unset() to deactivate the FPE signal handler as required.

Definition at line 136 of file sigFpe.C.

References Foam::BitOps::unset().

Here is the call graph for this function:

Member Function Documentation

◆ requested()

bool requested ( )
static

Check if SIGFPE signals handler is to be enabled.

This is controlled by the trapFpe entry or the FOAM_SIGFPE environment variable

Definition at line 144 of file sigFpe.C.

References isTrue().

Here is the call graph for this function:

◆ active()

static bool active ( )
inlinestaticnoexcept

True if SIGFPE handling is currently active.

Definition at line 138 of file sigFpe.H.

◆ nanActive()

static bool nanActive ( )
inlinestaticnoexcept

True if NaN memory initialisation is currently active.

Definition at line 143 of file sigFpe.H.

◆ set()

void set ( bool  verbose = false)
static

Activate SIGFPE handler when FOAM_SIGFPE is enabled. Activate fill memory with signaling_NaN when FOAM_SETNAN is enabled.

Definition at line 150 of file sigFpe.C.

References Foam::endl(), Foam::Info, isTrue(), and Foam::setHandler().

Referenced by argList::parse(), and sigFpe::ignore::reset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unset()

void unset ( bool  verbose = false)
static

Deactivate SIGFPE handler and NaN memory initialisation.

Definition at line 208 of file sigFpe.C.

References Foam::abort(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, Foam::Info, and Foam::resetHandler().

Referenced by sigFpe::ignore::ignore().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fillNan() [1/2]

void fillNan ( char *  buf,
size_t  count 
)
static

Fill data block with signaling_NaN values.

Definition at line 244 of file sigFpe.C.

References Foam::BitOps::count().

Referenced by dynamicRefineFvMesh::mapFields().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fillNan() [2/2]

void fillNan ( UList< scalar > &  list)
static

Fill data block with signaling_NaN values.

Definition at line 261 of file sigFpe.C.

References UList< T >::data(), UList< T >::empty(), and UList< T >::size().

Here is the call graph for this function:

The documentation for this class was generated from the following files: