Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Private Attributes
sigFpe Class Reference

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

Public Member Functions

 sigFpe ()
 Construct null. More...
 
 ~sigFpe ()
 Destructor. More...
 

Static Public Member Functions

static void set (const bool verbose)
 Activate SIGFPE signal handler when FOAM_SIGFPE is set. More...
 
static void unset (const bool verbose)
 Deactivate SIGFPE signal handler and NaN memory initialisation. More...
 
static void fillNan (UList< scalar > &)
 Fill block of data with NaN. More...
 

Static Public Attributes

static bool mallocNanActive_ = false
 Flag to indicate mallocNan is enabled. More...
 

Static Private Attributes

static struct sigaction oldAction_
 Saved old signal trapping setting. More...
 
static bool sigFpeActive_ = false
 Flag to indicate floating point trapping is enabled. More...
 

Detailed Description

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

Controlled by two env vars:

Parameters
FOAM_SIGFPE
exception trapping
FOAM_SETNAN
initialization of all malloced memory to NaN. If FOAM_SIGFPE also set, this will cause usage of uninitialized scalars to trigger an abort.

Can be used either directly through the static member functions or through the scope of the object (constructor sets trapping; destructor restores original).

Source files

Definition at line 71 of file sigFpe.H.

Constructor & Destructor Documentation

◆ sigFpe()

sigFpe ( )

Construct null.

Definition at line 115 of file sigFpe.C.

◆ ~sigFpe()

~sigFpe ( )

Destructor.

Definition at line 123 of file sigFpe.C.

Member Function Documentation

◆ set()

void set ( const bool  verbose)
static

Activate SIGFPE signal handler when FOAM_SIGFPE is set.

Fill memory with NaN when FOAM_SETNAN is set

Definition at line 131 of file sigFpe.C.

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

Referenced by argList::parse(), and runTimePostProcessing::write().

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

◆ unset()

void unset ( const bool  verbose)
static

Deactivate SIGFPE signal handler and NaN memory initialisation.

Definition at line 226 of file sigFpe.C.

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

Referenced by runTimePostProcessing::write().

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

◆ fillNan()

void fillNan ( UList< scalar > &  lst)
static

Fill block of data with NaN.

Definition at line 50 of file sigFpe.C.

Referenced by dynamicRefineFvMesh::refine().

Here is the caller graph for this function:

Field Documentation

◆ oldAction_

struct sigaction oldAction_
staticprivate

Saved old signal trapping setting.

Definition at line 76 of file sigFpe.H.

◆ sigFpeActive_

bool sigFpeActive_ = false
staticprivate

Flag to indicate floating point trapping is enabled.

Definition at line 79 of file sigFpe.H.

◆ mallocNanActive_

bool mallocNanActive_ = false
static

Flag to indicate mallocNan is enabled.

Definition at line 113 of file sigFpe.H.


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