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 ()
 
 ~sigFpe ()
 
 sigFpe ()
 
 ~sigFpe ()
 

Static Public Member Functions

static bool requested ()
 Check if SIGFPE signals handler is to be enabled. More...
 
static bool active ()
 True if SIGFPE handling is currently active. More...
 
static bool nanActive ()
 True if NaN memory initialisation is currently active. More...
 
static void set (bool verbose=false)
 Activate SIGFPE signal handler when FOAM_SIGFPE is set. More...
 
static void unset (bool verbose=false)
 Deactivate SIGFPE signal handler and NaN memory initialisation. More...
 
static void fillNan (UList< scalar > &list)
 Fill data block with NaN values. More...
 
static bool requested ()
 Check if SIGFPE signals handler is to be enabled. More...
 
static bool active ()
 True if SIGFPE handling is currently active. More...
 
static bool nanActive ()
 True if NaN memory initialisation is currently active. More...
 
static void set (bool verbose=false)
 Activate SIGFPE signal handler when FOAM_SIGFPE is set. More...
 
static void unset (bool verbose=false)
 Deactivate SIGFPE signal handler and NaN memory initialisation. More...
 
static void fillNan (UList< scalar > &list)
 Fill data block with 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

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 73 of file sigFpe.H.

Constructor & Destructor Documentation

◆ sigFpe() [1/2]

sigFpe ( )

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

Definition at line 99 of file sigFpe.C.

◆ ~sigFpe() [1/2]

~sigFpe ( )

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

Definition at line 118 of file sigFpe.C.

References sigFpe::unset().

Here is the call graph for this function:

◆ sigFpe() [2/2]

sigFpe ( )

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

◆ ~sigFpe() [2/2]

~sigFpe ( )

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

Member Function Documentation

◆ requested() [1/2]

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 142 of file sigFpe.C.

References isTrue().

Referenced by sigFpe::set().

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

◆ active() [1/2]

static bool active ( )
inlinestatic

True if SIGFPE handling is currently active.

Definition at line 120 of file sigFpe.H.

◆ nanActive() [1/2]

static bool nanActive ( )
inlinestatic

True if NaN memory initialisation is currently active.

Definition at line 126 of file sigFpe.H.

◆ set() [1/2]

void set ( bool  verbose = false)
static

Activate SIGFPE signal handler when FOAM_SIGFPE is set.

Fill memory with NaN when FOAM_SETNAN is set

Definition at line 148 of file sigFpe.C.

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

Here is the call graph for this function:

◆ unset() [1/2]

void unset ( bool  verbose = false)
static

Deactivate SIGFPE signal handler and NaN memory initialisation.

Definition at line 204 of file sigFpe.C.

References clearFpe(), Foam::endl(), Foam::Info, and Foam::resetHandler().

Referenced by sigFpe::~sigFpe().

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

◆ fillNan() [1/2]

void fillNan ( UList< scalar > &  list)
static

Fill data block with NaN values.

Definition at line 225 of file sigFpe.C.

Referenced by dynamicRefineFvMesh::mapFields().

Here is the caller graph for this function:

◆ requested() [2/2]

static 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

◆ active() [2/2]

static bool active ( )
inlinestatic

True if SIGFPE handling is currently active.

Definition at line 120 of file sigFpe.H.

◆ nanActive() [2/2]

static bool nanActive ( )
inlinestatic

True if NaN memory initialisation is currently active.

Definition at line 126 of file sigFpe.H.

◆ set() [2/2]

static void set ( bool  verbose = false)
static

Activate SIGFPE signal handler when FOAM_SIGFPE is set.

Fill memory with NaN when FOAM_SETNAN is set

◆ unset() [2/2]

static void unset ( bool  verbose = false)
static

Deactivate SIGFPE signal handler and NaN memory initialisation.

◆ fillNan() [2/2]

static void fillNan ( UList< scalar > &  list)
static

Fill data block with NaN values.


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