Loading...
Searching...
No Matches
sigFpe Class Reference

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

#include <sigFpe.H>

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.
 ~sigFpe ()
 Destructor calls unset() to deactivate the FPE signal handler as required.

Static Public Member Functions

static bool requested ()
 Check if SIGFPE signals handler is to be enabled.
static bool active () noexcept
 True if SIGFPE handling is currently active.
static bool nanActive () noexcept
 True if NaN memory initialisation is currently active.
static bool nanActive (bool on) noexcept
 Set NaN memory initialisation on/off.
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.
static void unset (bool verbose=false)
 Deactivate SIGFPE handler and NaN memory initialisation.
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 void fillNan (char *buf, size_t count)
 Fill data block with signaling_NaN values. Does a reinterpret to Foam::scalar.
static void fillNan (UList< float > &list)
 Fill data block with (float) signaling_NaN values.
static void fillNan (UList< double > &list)
 Fill data block with (double) signaling_NaN values.

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 72 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.

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

Here is the caller graph for this function:

◆ ~sigFpe()

~sigFpe ( )

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

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

◆ active()

bool active ( )
inlinestaticnoexcept

True if SIGFPE handling is currently active.

Definition at line 159 of file sigFpe.H.

References Foam::noexcept.

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

Here is the caller graph for this function:

◆ nanActive() [1/2]

bool nanActive ( )
inlinestaticnoexcept

True if NaN memory initialisation is currently active.

Definition at line 164 of file sigFpe.H.

References Foam::noexcept.

◆ nanActive() [2/2]

bool nanActive ( bool on)
inlinestaticnoexcept

Set NaN memory initialisation on/off.

Returns
the previous value

Definition at line 171 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.

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

Here is the caller graph for this function:

◆ unset()

void unset ( bool verbose = false)
static

Deactivate SIGFPE handler and NaN memory initialisation.

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

Here is the caller graph for this function:

◆ fillNan_if()

void fillNan_if ( void * buf,
size_t count )
inlinestatic

Fill data block with signaling_NaN values if nanActive(). Does a reinterpret to Foam::scalar.

Definition at line 193 of file sigFpe.H.

◆ fillNan() [1/3]

void fillNan ( char * buf,
size_t count )
inlinestatic

Fill data block with signaling_NaN values. Does a reinterpret to Foam::scalar.

Definition at line 209 of file sigFpe.H.

Referenced by dynamicRefineFvMesh::mapFields().

Here is the caller graph for this function:

◆ fillNan() [2/3]

void fillNan ( UList< float > & list)
static

Fill data block with (float) signaling_NaN values.

◆ fillNan() [3/3]

void fillNan ( UList< double > & list)
static

Fill data block with (double) signaling_NaN values.


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