STYLE: update noexcept and default construct for signals

- eliminate ClassName in favour of simple debug

- include Apple-specific FPE handling after local definition
  to allow for more redefinitions

COMP: remove stray <csignal> includes
This commit is contained in:
Mark Olesen 2023-08-09 11:50:30 +02:00
parent b620152191
commit 97668eab26
36 changed files with 156 additions and 221 deletions

View File

@ -38,7 +38,6 @@ Description
#include "OSspecific.H"
#include "Switch.H"
#include <csignal>
#include <cstdlib>
#include <iostream>

View File

@ -40,8 +40,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cpuInfo_H
#define cpuInfo_H
#ifndef Foam_cpuInfo_H
#define Foam_cpuInfo_H
#include <string>

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef cpuTime_H
#define cpuTime_H
#ifndef Foam_cpuTime_H
#define Foam_cpuTime_H
#include "cpuTimeCxx.H"
#include "cpuTimeFwd.H"

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef cpuTimeFwd_H
#define cpuTimeFwd_H
#ifndef Foam_cpuTimeFwd_H
#define Foam_cpuTimeFwd_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,6 +27,9 @@ License
\*---------------------------------------------------------------------------*/
#include "fileMonitor.H"
#include "error.H"
#include "Enum.H"
#include "defineDebugSwitch.H"
#include "IOstreams.H"
#include "Pstream.H"
#include "PackedList.H"
@ -64,12 +67,12 @@ Foam::fileMonitor::fileStateNames_
namespace Foam
{
defineTypeNameAndDebug(fileMonitor, 0);
defineDebugSwitchWithName(fileMonitor, "fileMonitor", 0);
registerDebugSwitchWithName(fileMonitor, fileMonitor, "fileMonitor");
//- Reduction operator for PackedList of fileState
class reduceFileStates
struct reduceFileStates
{
public:
unsigned int operator()(const unsigned int x, const unsigned int y)
const
{
@ -98,9 +101,8 @@ namespace Foam
};
//- Combine operator for PackedList of fileState
class combineReduceFileStates
struct combineReduceFileStates
{
public:
void operator()(unsigned int& x, const unsigned int y) const
{
x = reduceFileStates()(x, y);

View File

@ -42,11 +42,9 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef fileMonitor_H
#define fileMonitor_H
#ifndef Foam_fileMonitor_H
#define Foam_fileMonitor_H
#include "Enum.H"
#include "className.H"
#include "DynamicList.H"
#include <memory>
#include <sys/types.h>
@ -59,6 +57,7 @@ namespace Foam
// Forward Declarations
class fileMonitor;
class fileMonitorWatcher;
template<class EnumType> class Enum;
/*---------------------------------------------------------------------------*\
Class fileMonitor Declaration
@ -117,13 +116,14 @@ private:
public:
// Declare name of the class and its debug switch
ClassName("fileMonitor");
//- Named/registered debug switch: 'fileMonitor'
static int debug;
// Constructors
//- Construct null
fileMonitor(const bool useInotify);
//- Construct with specified inotify use
explicit fileMonitor(const bool useInotify);
//- Destructor

View File

@ -32,7 +32,7 @@ License
#include "JobInfo.H"
#include "OSspecific.H"
#include "IOstreams.H"
#include "List.H"
#include "UList.H"
#include "Switch.H"
#include <float.h> // For *fp functions

View File

@ -54,10 +54,11 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef sigFpe_H
#define sigFpe_H
#ifndef Foam_sigFpe_H
#define Foam_sigFpe_H
#include "scalar.H"
#include <cstddef> // for std::size_t
#include "scalarFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -118,16 +119,10 @@ public:
static bool requested();
//- True if SIGFPE handling is currently active.
static inline bool active()
{
return sigActive_;
}
static bool active() noexcept { return sigActive_; }
//- True if NaN memory initialisation is currently active.
static inline bool nanActive()
{
return nanActive_;
}
static bool nanActive() noexcept { return nanActive_; }
//- Activate SIGFPE signal handler when FOAM_SIGFPE is %set
// Fill memory with NaN when FOAM_SETNAN is %set

View File

@ -45,8 +45,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef sigInt_H
#define sigInt_H
#ifndef Foam_sigInt_H
#define Foam_sigInt_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -59,7 +59,7 @@ namespace Foam
class sigInt
{
// Private data
// Private Data
//- Signal trapping enabled?
static bool sigActive_;
@ -74,7 +74,7 @@ public:
// Constructors
//- Construct null
//- Default construct
sigInt();

View File

@ -44,8 +44,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef sigQuit_H
#define sigQuit_H
#ifndef Foam_sigQuit_H
#define Foam_sigQuit_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -74,7 +74,7 @@ public:
// Constructors
//- Construct null
//- Default construct
sigQuit();

View File

@ -44,8 +44,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef sigSegv_H
#define sigSegv_H
#ifndef Foam_sigSegv_H
#define Foam_sigSegv_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -74,7 +74,7 @@ public:
// Constructors
//- Construct null
//- Default construct
sigSegv();

View File

@ -109,10 +109,6 @@ void Foam::sigStopAtWriteNow::sigHandler(int)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sigStopAtWriteNow::sigStopAtWriteNow()
{}
Foam::sigStopAtWriteNow::sigStopAtWriteNow(const Time& runTime, bool verbose)
{
runTimePtr_ = &runTime; // Store runTime
@ -135,18 +131,6 @@ Foam::sigStopAtWriteNow::~sigStopAtWriteNow()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::sigStopAtWriteNow::active()
{
return signal_ > 0;
}
int Foam::sigStopAtWriteNow::signalNumber()
{
return signal_;
}
void Foam::sigStopAtWriteNow::set(bool verbose)
{
if (!active())

View File

@ -34,10 +34,13 @@ Description
SourceFiles
sigStopAtWriteNow.C
See also
Foam::JobInfo
\*---------------------------------------------------------------------------*/
#ifndef sigStopAtWriteNow_H
#define sigStopAtWriteNow_H
#ifndef Foam_sigStopAtWriteNow_H
#define Foam_sigStopAtWriteNow_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -73,11 +76,11 @@ public:
// Constructors
//- Construct null
//- Default construct
sigStopAtWriteNow();
//- Construct from components
sigStopAtWriteNow(const Time& runTime, bool verbose=false);
//- Construct with Time reference
explicit sigStopAtWriteNow(const Time& runTime, bool verbose=false);
//- Destructor
@ -87,10 +90,10 @@ public:
// Member Functions
//- Is active?
static bool active();
static bool active() noexcept { return (signal_ > 0); }
//- Signal number being used
static int signalNumber();
static int signalNumber() noexcept { return signal_; }
//- Set/reset signal handler
static void set(bool verbose=false);

View File

@ -101,13 +101,9 @@ void Foam::sigWriteNow::sigHandler(int)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sigWriteNow::sigWriteNow()
{}
Foam::sigWriteNow::sigWriteNow(Time& runTime, bool verbose)
{
runTimePtr_ = &runTime; // Store runTime
runTimePtr_ = &runTime; // Store Time reference
set(verbose);
}
@ -127,18 +123,6 @@ Foam::sigWriteNow::~sigWriteNow()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::sigWriteNow::active()
{
return signal_ > 0;
}
int Foam::sigWriteNow::signalNumber()
{
return signal_;
}
void Foam::sigWriteNow::set(bool verbose)
{
if (!active())

View File

@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef sigWriteNow_H
#define sigWriteNow_H
#ifndef Foam_sigWriteNow_H
#define Foam_sigWriteNow_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -73,11 +73,11 @@ public:
// Constructors
//- Construct null
sigWriteNow();
//- Default construct
sigWriteNow() noexcept = default;
//- Construct from components
sigWriteNow(Time& runTime, bool verbose=false);
//- Construct with Time reference
explicit sigWriteNow(Time& runTime, bool verbose=false);
//- Destructor
@ -87,14 +87,13 @@ public:
// Member Functions
//- Is active?
static bool active();
static bool active() noexcept { return (signal_ > 0); }
//- The signal number being used
static int signalNumber();
//- Signal number being used
static int signalNumber() noexcept { return signal_; }
//- Set/reset signal handler
static void set(bool verbose=false);
};

View File

@ -7,7 +7,7 @@
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2011 Symscape
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,6 +29,7 @@ License
#include "timer.H"
#include "error.H"
#include "defineDebugSwitch.H"
#include "MSwindows.H"
#undef DebugInfo // Windows name clash with OpenFOAM messageStream
@ -40,6 +41,7 @@ License
// File-local functions
#include "signalMacros.C"
#undef SIGALRM
#define SIGALRM 14
@ -47,7 +49,8 @@ License
namespace Foam
{
defineTypeNameAndDebug(timer, 0);
defineDebugSwitchWithName(timer, "timer", 0);
registerDebugSwitchWithName(timer, timer, "timer");
}
jmp_buf Foam::timer::envAlarm;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,16 +61,16 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef timer_H
#define timer_H
#ifndef Foam_timer_H
#define Foam_timer_H
#include "className.H"
#include <csetjmp>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Check if timeout has occurred
// keep setjmp in same stack frame so no function calls
#undef timedOut
#define timedOut(x) \
((x).timeOut_ ? setjmp(Foam::timer::envAlarm) : false)
@ -99,8 +99,8 @@ public:
// Public Data
//- Declare name of the class and its debug switch
ClassName("timer");
//- Named/registered debug switch: 'timer'
static int debug;
//- The time-out value (seconds). Needed by macro timedOut
unsigned int timeOut_;
@ -112,7 +112,7 @@ public:
// Constructors
//- Construct with specified time-out, a value of 0 makes it a no-op.
timer(unsigned int seconds);
explicit timer(unsigned int seconds);
//- Destructor. Restores the alarm and signal handler as required.

View File

@ -40,8 +40,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cpuInfo_H
#define cpuInfo_H
#ifndef Foam_cpuInfo_H
#define Foam_cpuInfo_H
#include <string>
@ -90,6 +90,7 @@ public:
//- Construct and populate with information
cpuInfo();
//- Destructor
~cpuInfo() = default;

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef cpuTime_H
#define cpuTime_H
#ifndef Foam_cpuTime_H
#define Foam_cpuTime_H
#include "cpuTimePosix.H"
#include "cpuTimeFwd.H"

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef cpuTimeFwd_H
#define cpuTimeFwd_H
#ifndef Foam_cpuTimeFwd_H
#define Foam_cpuTimeFwd_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -38,8 +38,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cpuTimePosix_H
#define cpuTimePosix_H
#ifndef Foam_cpuTimePosix_H
#define Foam_cpuTimePosix_H
#include <string>
#include <ctime>

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,6 +27,9 @@ License
\*---------------------------------------------------------------------------*/
#include "fileMonitor.H"
#include "error.H"
#include "Enum.H"
#include "defineDebugSwitch.H"
#include "IOstreams.H"
#include "Pstream.H"
#include "PackedList.H"
@ -60,12 +63,12 @@ Foam::fileMonitor::fileStateNames_
namespace Foam
{
defineTypeNameAndDebug(fileMonitor, 0);
defineDebugSwitchWithName(fileMonitor, "fileMonitor", 0);
registerDebugSwitchWithName(fileMonitor, fileMonitor, "fileMonitor");
//- Reduction operator for PackedList of fileState
class reduceFileStates
struct reduceFileStates
{
public:
unsigned int operator()(const unsigned int x, const unsigned int y)
const
{
@ -94,9 +97,8 @@ namespace Foam
};
//- Combine operator for PackedList of fileState
class combineReduceFileStates
struct combineReduceFileStates
{
public:
void operator()(unsigned int& x, const unsigned int y) const
{
x = reduceFileStates()(x, y);

View File

@ -42,11 +42,9 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef fileMonitor_H
#define fileMonitor_H
#ifndef Foam_fileMonitor_H
#define Foam_fileMonitor_H
#include "Enum.H"
#include "className.H"
#include "DynamicList.H"
#include <memory>
#include <sys/types.h>
@ -59,6 +57,7 @@ namespace Foam
// Forward Declarations
class fileMonitor;
class fileMonitorWatcher;
template<class EnumType> class Enum;
/*---------------------------------------------------------------------------*\
Class fileMonitor Declaration
@ -117,12 +116,13 @@ private:
public:
// Declare name of the class and its debug switch
ClassName("fileMonitor");
//- Named/registered debug switch: 'fileMonitor'
static int debug;
// Constructors
//- Construct null
//- Construct with specified inotify use
explicit fileMonitor(const bool useInotify);

View File

@ -30,12 +30,8 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::error::safePrintStack(std::ostream& os, int size)
{}
void Foam::error::printStack(Ostream& os, int size)
{}
void Foam::error::safePrintStack(std::ostream& os, int size) {}
void Foam::error::printStack(Ostream& os, int size) {}
// ************************************************************************* //

View File

@ -31,9 +31,12 @@ License
#include "JobInfo.H"
#include "OSspecific.H"
#include "IOstreams.H"
#include "List.H"
#include "UList.H"
#include "Switch.H"
// File-local functions
#include "signalMacros.C"
#include <limits>
#if defined(__linux__) && defined(__GNUC__)
@ -44,13 +47,11 @@ License
#include <malloc.h>
#endif
// Special handling for APPLE
#ifdef __APPLE__
#include "feexceptErsatz.H"
#endif
// File-local functions
#include "signalMacros.C"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -54,10 +54,11 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef sigFpe_H
#define sigFpe_H
#ifndef Foam_sigFpe_H
#define Foam_sigFpe_H
#include "scalar.H"
#include <cstddef> // for std::size_t
#include "scalarFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -118,16 +119,10 @@ public:
static bool requested();
//- True if SIGFPE handling is currently active.
static inline bool active()
{
return sigActive_;
}
static bool active() noexcept { return sigActive_; }
//- True if NaN memory initialisation is currently active.
static inline bool nanActive()
{
return nanActive_;
}
static bool nanActive() noexcept { return nanActive_; }
//- Activate SIGFPE signal handler when FOAM_SIGFPE is %set
// Fill memory with NaN when FOAM_SETNAN is %set

View File

@ -45,8 +45,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef sigInt_H
#define sigInt_H
#ifndef Foam_sigInt_H
#define Foam_sigInt_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -59,7 +59,7 @@ namespace Foam
class sigInt
{
// Private data
// Private Data
//- Signal trapping enabled?
static bool sigActive_;
@ -74,7 +74,7 @@ public:
// Constructors
//- Construct null
//- Default construct
sigInt();
@ -82,7 +82,7 @@ public:
~sigInt();
// Member functions
// Member Functions
//- Activate SIGINT signal handler
static void set(bool verbose=false);

View File

@ -44,8 +44,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef sigQuit_H
#define sigQuit_H
#ifndef Foam_sigQuit_H
#define Foam_sigQuit_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -74,7 +74,7 @@ public:
// Constructors
//- Construct null
//- Default construct
sigQuit();

View File

@ -44,8 +44,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef sigSegv_H
#define sigSegv_H
#ifndef Foam_sigSegv_H
#define Foam_sigSegv_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -74,7 +74,7 @@ public:
// Constructors
//- Construct null
//- Default construct
sigSegv();
@ -82,7 +82,7 @@ public:
~sigSegv();
// Member functions
// Member Functions
//- Activate SIGSEGV signal handler
static void set(bool verbose=false);

View File

@ -111,10 +111,6 @@ void Foam::sigStopAtWriteNow::sigHandler(int)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sigStopAtWriteNow::sigStopAtWriteNow()
{}
Foam::sigStopAtWriteNow::sigStopAtWriteNow(const Time& runTime, bool verbose)
{
runTimePtr_ = &runTime; // Store runTime
@ -137,18 +133,6 @@ Foam::sigStopAtWriteNow::~sigStopAtWriteNow()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::sigStopAtWriteNow::active()
{
return signal_ > 0;
}
int Foam::sigStopAtWriteNow::signalNumber()
{
return signal_;
}
void Foam::sigStopAtWriteNow::set(bool verbose)
{
if (!active())

View File

@ -34,10 +34,13 @@ Description
SourceFiles
sigStopAtWriteNow.C
See also
Foam::JobInfo
\*---------------------------------------------------------------------------*/
#ifndef sigStopAtWriteNow_H
#define sigStopAtWriteNow_H
#ifndef Foam_sigStopAtWriteNow_H
#define Foam_sigStopAtWriteNow_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -73,11 +76,11 @@ public:
// Constructors
//- Construct null
sigStopAtWriteNow();
//- Default construct
sigStopAtWriteNow() noexcept = default;
//- Construct from components
sigStopAtWriteNow(const Time& runTime, bool verbose=false);
//- Construct with Time reference
explicit sigStopAtWriteNow(const Time& runTime, bool verbose=false);
//- Destructor
@ -87,10 +90,10 @@ public:
// Member Functions
//- Is active?
static bool active();
static bool active() noexcept { return (signal_ > 0); }
//- Signal number being used
static int signalNumber();
static int signalNumber() noexcept { return signal_; }
//- Set/reset signal handler
static void set(bool verbose=false);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,9 +28,8 @@ License
#include "sigWriteNow.H"
#include "error.H"
#include "JobInfo.H"
#include "IOstreams.H"
#include "Time.H"
#include "IOstreams.H"
// File-local functions
#include "signalMacros.C"
@ -103,13 +102,9 @@ void Foam::sigWriteNow::sigHandler(int)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sigWriteNow::sigWriteNow()
{}
Foam::sigWriteNow::sigWriteNow(Time& runTime, bool verbose)
{
runTimePtr_ = &runTime; // Store runTime
runTimePtr_ = &runTime; // Store Time reference
set(verbose);
}
@ -129,18 +124,6 @@ Foam::sigWriteNow::~sigWriteNow()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::sigWriteNow::active()
{
return signal_ > 0;
}
int Foam::sigWriteNow::signalNumber()
{
return signal_;
}
void Foam::sigWriteNow::set(bool verbose)
{
if (!active())

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef sigWriteNow_H
#define sigWriteNow_H
#ifndef Foam_sigWriteNow_H
#define Foam_sigWriteNow_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -73,11 +73,11 @@ public:
// Constructors
//- Construct null
sigWriteNow();
//- Default construct
sigWriteNow() noexcept = default;
//- Construct from components
sigWriteNow(Time& runTime, bool verbose=false);
//- Construct with Time reference
explicit sigWriteNow(Time& runTime, bool verbose=false);
//- Destructor
@ -87,14 +87,13 @@ public:
// Member Functions
//- Is active?
static bool active();
static bool active() noexcept { return (signal_ > 0); }
//- The signal number being used
static int signalNumber();
static int signalNumber() noexcept { return signal_; }
//- Set/reset signal handler
static void set(bool verbose=false);
};

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,8 +26,9 @@ License
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "timer.H"
#include "error.H"
#include "defineDebugSwitch.H"
#include <unistd.h>
@ -39,7 +40,8 @@ License
namespace Foam
{
defineTypeNameAndDebug(timer, 0);
defineDebugSwitchWithName(timer, "timer", 0);
registerDebugSwitchWithName(timer, timer, "timer");
}
jmp_buf Foam::timer::envAlarm;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,16 +61,16 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef timer_H
#define timer_H
#ifndef Foam_timer_H
#define Foam_timer_H
#include "className.H"
#include <csetjmp>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Check if timeout has occurred
// keep setjmp in same stack frame so no function calls
#undef timedOut
#define timedOut(x) \
((x).timeOut_ ? setjmp(Foam::timer::envAlarm) : false)
@ -99,8 +99,8 @@ public:
// Public Data
//- Declare name of the class and its debug switch
ClassName("timer");
//- Named/registered debug switch: 'timer'
static int debug;
//- The time-out value (seconds). Needed by macro timedOut
unsigned int timeOut_;

View File

@ -34,11 +34,11 @@ License
#include "UPstreamWrapping.H"
#include "collatedFileOperation.H"
#include <cstring>
#include <cstdlib>
#include <csignal>
#include <cstring>
#include <memory>
#include <numeric>
#include <string>
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //