mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add OSspecific/MSwindows (#1238)
This commit is contained in:
committed by
Andrew Heather
parent
83d26d19b5
commit
07ec741e2a
12
src/OSspecific/MSwindows/Allwmake
Executable file
12
src/OSspecific/MSwindows/Allwmake
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
cd ${0%/*} || exit 1 # Run from this directory
|
||||||
|
targetType=libo # Preferred library type
|
||||||
|
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments $*
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
unset COMP_FLAGS LINK_FLAGS
|
||||||
|
|
||||||
|
# Make object (non-shared by default)
|
||||||
|
wmake $targetType
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
1288
src/OSspecific/MSwindows/MSwindows.C
Normal file
1288
src/OSspecific/MSwindows/MSwindows.C
Normal file
File diff suppressed because it is too large
Load Diff
69
src/OSspecific/MSwindows/MSwindows.H
Normal file
69
src/OSspecific/MSwindows/MSwindows.H
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011 Symscape
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Namespace
|
||||||
|
Foam::MSwindows
|
||||||
|
|
||||||
|
Description
|
||||||
|
OS-specific functions implemented for MS-windows.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
MSwindows.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef MSwindows_H
|
||||||
|
#define MSwindows_H
|
||||||
|
|
||||||
|
#include "className.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace MSwindows
|
||||||
|
{
|
||||||
|
//- Declare namespace and its debug switch
|
||||||
|
NamespaceName("MSwindows");
|
||||||
|
|
||||||
|
//- The last Windows API error from GetLastError
|
||||||
|
std::string lastError();
|
||||||
|
|
||||||
|
//- The user-name from Windows API GetUserName
|
||||||
|
std::string userName();
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
21
src/OSspecific/MSwindows/Make/files
Normal file
21
src/OSspecific/MSwindows/Make/files
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MSwindows.C
|
||||||
|
|
||||||
|
cpuInfo/cpuInfo.C
|
||||||
|
memInfo/memInfo.C
|
||||||
|
|
||||||
|
signals/sigFpe.C
|
||||||
|
signals/sigInt.C
|
||||||
|
signals/sigQuit.C
|
||||||
|
signals/sigSegv.C
|
||||||
|
signals/sigStopAtWriteNow.C
|
||||||
|
signals/sigWriteNow.C
|
||||||
|
signals/timer.C
|
||||||
|
|
||||||
|
fileStat/fileStat.C
|
||||||
|
|
||||||
|
/* Without inotify */
|
||||||
|
fileMonitor/fileMonitor.C
|
||||||
|
|
||||||
|
printStack/dummyPrintStack.C
|
||||||
|
|
||||||
|
LIB = $(FOAM_LIBBIN)/libOSspecific
|
||||||
1
src/OSspecific/MSwindows/Make/options
Normal file
1
src/OSspecific/MSwindows/Make/options
Normal file
@ -0,0 +1 @@
|
|||||||
|
EXE_INC = $(COMP_FLAGS)
|
||||||
68
src/OSspecific/MSwindows/cpuInfo/cpuInfo.C
Normal file
68
src/OSspecific/MSwindows/cpuInfo/cpuInfo.C
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "cpuInfo.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cpuInfo::cpuInfo()
|
||||||
|
:
|
||||||
|
vendor_id(),
|
||||||
|
model_name(),
|
||||||
|
cpu_family(-1),
|
||||||
|
model(-1),
|
||||||
|
cpu_MHz(0),
|
||||||
|
siblings(0),
|
||||||
|
cpu_cores(std::thread::hardware_concurrency())
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::cpuInfo::write(Ostream& os) const
|
||||||
|
{
|
||||||
|
if (!vendor_id.empty())
|
||||||
|
{
|
||||||
|
os.writeEntry("vendor_id", vendor_id);
|
||||||
|
}
|
||||||
|
if (!model_name.empty())
|
||||||
|
{
|
||||||
|
os.writeEntry("model_name", model_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
os.writeEntryIfDifferent<int>("cpu_family", -1, cpu_family);
|
||||||
|
os.writeEntryIfDifferent<int>("model", -1, model);
|
||||||
|
os.writeEntryIfDifferent<float>("cpu_MHz", 0, cpu_MHz);
|
||||||
|
os.writeEntryIfDifferent<int>("cpu_cores", 0, cpu_cores);
|
||||||
|
os.writeEntryIfDifferent<int>("siblings", 0, siblings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
111
src/OSspecific/MSwindows/cpuInfo/cpuInfo.H
Normal file
111
src/OSspecific/MSwindows/cpuInfo/cpuInfo.H
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::cpuInfo
|
||||||
|
|
||||||
|
Description
|
||||||
|
General CPU characteristics.
|
||||||
|
|
||||||
|
If the machine has multiple cpus/cores, only the characteristics
|
||||||
|
of the first core are used.
|
||||||
|
|
||||||
|
Note
|
||||||
|
Windows variant only provides the number of cores.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
cpuInfo.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef cpuInfo_H
|
||||||
|
#define cpuInfo_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
class Ostream;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class cpuInfo Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class cpuInfo
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
// Various bits from /proc/cpuinfo
|
||||||
|
|
||||||
|
std::string vendor_id;
|
||||||
|
std::string model_name;
|
||||||
|
int cpu_family;
|
||||||
|
int model;
|
||||||
|
float cpu_MHz;
|
||||||
|
int siblings;
|
||||||
|
int cpu_cores;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Parse /proc/cpuinfo
|
||||||
|
void parse();
|
||||||
|
|
||||||
|
//- No copy construct
|
||||||
|
cpuInfo(const cpuInfo&) = delete;
|
||||||
|
|
||||||
|
//- No copy assignment
|
||||||
|
void operator=(const cpuInfo&) = delete;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct and populate with information
|
||||||
|
cpuInfo();
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~cpuInfo() = default;
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Write content as dictionary entries
|
||||||
|
void write(Ostream& os) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
40
src/OSspecific/MSwindows/cpuTime/cpuTime.H
Normal file
40
src/OSspecific/MSwindows/cpuTime/cpuTime.H
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Typedef
|
||||||
|
Foam::cpuTime
|
||||||
|
|
||||||
|
Description
|
||||||
|
Selection of preferred clock mechanism for the elapsed cpu time.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef cpuTime_H
|
||||||
|
#define cpuTime_H
|
||||||
|
|
||||||
|
#include "cpuTimeCxx.H"
|
||||||
|
#include "cpuTimeFwd.H"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
48
src/OSspecific/MSwindows/cpuTime/cpuTimeFwd.H
Normal file
48
src/OSspecific/MSwindows/cpuTime/cpuTimeFwd.H
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Typedef
|
||||||
|
Foam::cpuTime
|
||||||
|
|
||||||
|
Description
|
||||||
|
Selection of preferred clock mechanism for the elapsed cpu time.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef cpuTimeFwd_H
|
||||||
|
#define cpuTimeFwd_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
class cpuTimeCxx;
|
||||||
|
|
||||||
|
typedef cpuTimeCxx cpuTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
625
src/OSspecific/MSwindows/fileMonitor/fileMonitor.C
Normal file
625
src/OSspecific/MSwindows/fileMonitor/fileMonitor.C
Normal file
@ -0,0 +1,625 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2011, 2018 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "fileMonitor.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "Pstream.H"
|
||||||
|
#include "PackedList.H"
|
||||||
|
#include "PstreamReduceOps.H"
|
||||||
|
#include "OSspecific.H"
|
||||||
|
#include "regIOobject.H" // for fileModificationSkew symbol
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#undef FOAM_USE_INOTIFY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef FOAM_USE_INOTIFY
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/inotify.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#define EVENT_SIZE ( sizeof (struct inotify_event) )
|
||||||
|
#define EVENT_LEN (EVENT_SIZE + 16)
|
||||||
|
#define EVENT_BUF_LEN ( 1024 * EVENT_LEN )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const Foam::Enum
|
||||||
|
<
|
||||||
|
Foam::fileMonitor::fileState
|
||||||
|
>
|
||||||
|
Foam::fileMonitor::fileStateNames_
|
||||||
|
({
|
||||||
|
{ fileState::UNMODIFIED, "unmodified" },
|
||||||
|
{ fileState::MODIFIED, "modified" },
|
||||||
|
{ fileState::DELETED, "deleted" },
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(fileMonitor, 0);
|
||||||
|
|
||||||
|
//- Reduction operator for PackedList of fileState
|
||||||
|
class reduceFileStates
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
unsigned int operator()(const unsigned int x, const unsigned int y)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
// x,y are sets of 2bits representing fileState
|
||||||
|
|
||||||
|
unsigned int mask = 3u;
|
||||||
|
unsigned int shift = 0;
|
||||||
|
unsigned int result = 0;
|
||||||
|
|
||||||
|
while (mask)
|
||||||
|
{
|
||||||
|
// Combine state
|
||||||
|
unsigned int xState = (x & mask) >> shift;
|
||||||
|
unsigned int yState = (y & mask) >> shift;
|
||||||
|
|
||||||
|
// Combine and add to result. Combine is such that UNMODIFIED
|
||||||
|
// wins.
|
||||||
|
unsigned int state = min(xState, yState);
|
||||||
|
result |= (state << shift);
|
||||||
|
|
||||||
|
shift += 2;
|
||||||
|
mask <<= 2;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//- Combine operator for PackedList of fileState
|
||||||
|
class combineReduceFileStates
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void operator()(unsigned int& x, const unsigned int y) const
|
||||||
|
{
|
||||||
|
x = reduceFileStates()(x, y);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//- Internal tracking via stat(3p) or inotify(7)
|
||||||
|
class fileMonitorWatcher
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
const bool useInotify_;
|
||||||
|
|
||||||
|
// For inotify
|
||||||
|
|
||||||
|
//- File descriptor for the inotify instance
|
||||||
|
int inotifyFd_;
|
||||||
|
|
||||||
|
//- Current watchIDs and corresponding directory id
|
||||||
|
DynamicList<label> dirWatches_;
|
||||||
|
DynamicList<fileName> dirFiles_;
|
||||||
|
|
||||||
|
// For stat
|
||||||
|
|
||||||
|
//- From watch descriptor to modified time
|
||||||
|
DynamicList<double> lastMod_;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//- Initialise inotify
|
||||||
|
inline fileMonitorWatcher(const bool useInotify, const label sz = 20)
|
||||||
|
:
|
||||||
|
useInotify_(useInotify),
|
||||||
|
inotifyFd_(-1)
|
||||||
|
{
|
||||||
|
if (useInotify_)
|
||||||
|
{
|
||||||
|
#ifdef FOAM_USE_INOTIFY
|
||||||
|
inotifyFd_ = inotify_init();
|
||||||
|
dirWatches_.setCapacity(sz);
|
||||||
|
dirFiles_.setCapacity(sz);
|
||||||
|
|
||||||
|
if (inotifyFd_ < 0)
|
||||||
|
{
|
||||||
|
static bool hasWarned = false;
|
||||||
|
if (!hasWarned)
|
||||||
|
{
|
||||||
|
hasWarned = true;
|
||||||
|
WarningInFunction
|
||||||
|
<< "Failed allocating an inotify descriptor : "
|
||||||
|
<< string(strerror(errno)) << endl
|
||||||
|
<< " Please increase the number of allowable "
|
||||||
|
<< "inotify instances" << endl
|
||||||
|
<< " (/proc/sys/fs/inotify/max_user_instances"
|
||||||
|
<< " on Linux)" << endl
|
||||||
|
<< " , switch off runTimeModifiable." << endl
|
||||||
|
<< " or compile this file without "
|
||||||
|
<< "FOAM_USE_INOTIFY"
|
||||||
|
<< " to use time stamps instead of inotify." << endl
|
||||||
|
<< " Continuing without additional file"
|
||||||
|
<< " monitoring."
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "You selected inotify but this file was compiled"
|
||||||
|
<< " without FOAM_USE_INOTIFY"
|
||||||
|
<< " Please select another fileModification test method"
|
||||||
|
<< exit(FatalError);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lastMod_.setCapacity(sz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Remove all watches
|
||||||
|
inline ~fileMonitorWatcher()
|
||||||
|
{
|
||||||
|
#ifdef FOAM_USE_INOTIFY
|
||||||
|
if (useInotify_ && inotifyFd_ >= 0)
|
||||||
|
{
|
||||||
|
forAll(dirWatches_, i)
|
||||||
|
{
|
||||||
|
if (dirWatches_[i] >= 0)
|
||||||
|
{
|
||||||
|
if (inotify_rm_watch(inotifyFd_, int(dirWatches_[i])))
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Failed deleting directory watch "
|
||||||
|
<< dirWatches_[i] << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool addWatch(const label watchFd, const fileName& fName)
|
||||||
|
{
|
||||||
|
if (useInotify_)
|
||||||
|
{
|
||||||
|
if (inotifyFd_ < 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef FOAM_USE_INOTIFY
|
||||||
|
// Add/retrieve watch on directory containing file.
|
||||||
|
// Note that fName might be non-existing in special situations
|
||||||
|
// (master-only reading for IODictionaries)
|
||||||
|
|
||||||
|
const fileName dir = fName.path();
|
||||||
|
|
||||||
|
label dirWatchID = -1;
|
||||||
|
if (isDir(dir))
|
||||||
|
{
|
||||||
|
dirWatchID = inotify_add_watch
|
||||||
|
(
|
||||||
|
inotifyFd_,
|
||||||
|
dir.c_str(),
|
||||||
|
IN_CLOSE_WRITE
|
||||||
|
);
|
||||||
|
|
||||||
|
if (dirWatchID < 0)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Failed adding watch " << watchFd
|
||||||
|
<< " to directory " << fName << " due to "
|
||||||
|
<< string(strerror(errno))
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (watchFd < dirWatches_.size() && dirWatches_[watchFd] != -1)
|
||||||
|
{
|
||||||
|
// Reuse of watchFd : should have dir watchID set to -1.
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Problem adding watch " << watchFd
|
||||||
|
<< " to file " << fName
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
dirWatches_(watchFd) = dirWatchID;
|
||||||
|
dirFiles_(watchFd) = fName.name();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (watchFd < lastMod_.size() && lastMod_[watchFd] != 0)
|
||||||
|
{
|
||||||
|
// Reuse of watchFd : should have lastMod set to 0.
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Problem adding watch " << watchFd
|
||||||
|
<< " to file " << fName
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
lastMod_(watchFd) = highResLastModified(fName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool removeWatch(const label watchFd)
|
||||||
|
{
|
||||||
|
if (useInotify_)
|
||||||
|
{
|
||||||
|
if (inotifyFd_ < 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
dirWatches_[watchFd] = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lastMod_[watchFd] = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fileMonitor::checkFiles() const
|
||||||
|
{
|
||||||
|
if (useInotify_)
|
||||||
|
{
|
||||||
|
#ifdef FOAM_USE_INOTIFY
|
||||||
|
// Large buffer for lots of events
|
||||||
|
char buffer[EVENT_BUF_LEN];
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
struct timeval zeroTimeout = {0, 0};
|
||||||
|
|
||||||
|
//- Pre-allocated structure containing file descriptors
|
||||||
|
fd_set fdSet;
|
||||||
|
// Add notify descriptor to select fd_set
|
||||||
|
FD_ZERO(&fdSet);
|
||||||
|
FD_SET(watcher_->inotifyFd_, &fdSet);
|
||||||
|
|
||||||
|
int ready = select
|
||||||
|
(
|
||||||
|
watcher_->inotifyFd_+1, // num filedescriptors in fdSet
|
||||||
|
&fdSet, // fdSet with only inotifyFd
|
||||||
|
nullptr, // No writefds
|
||||||
|
nullptr, // No errorfds
|
||||||
|
&zeroTimeout // eNo timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
if (ready < 0)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Problem in issuing select."
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
else if (FD_ISSET(watcher_->inotifyFd_, &fdSet))
|
||||||
|
{
|
||||||
|
// Read events
|
||||||
|
ssize_t nBytes = ::read
|
||||||
|
(
|
||||||
|
watcher_->inotifyFd_,
|
||||||
|
buffer,
|
||||||
|
EVENT_BUF_LEN
|
||||||
|
);
|
||||||
|
|
||||||
|
if (nBytes < 0)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "read of " << watcher_->inotifyFd_
|
||||||
|
<< " failed with " << label(nBytes)
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Go through buffer, consuming events
|
||||||
|
int i = 0;
|
||||||
|
while (i < nBytes)
|
||||||
|
{
|
||||||
|
const struct inotify_event* inotifyEvent =
|
||||||
|
reinterpret_cast<const struct inotify_event*>
|
||||||
|
(
|
||||||
|
&buffer[i]
|
||||||
|
);
|
||||||
|
|
||||||
|
//Pout<< "watchFd:" << inotifyEvent->wd << nl
|
||||||
|
// << "mask:" << inotifyEvent->mask << nl
|
||||||
|
// << endl;
|
||||||
|
//Pout<< "file:" << fileName(inotifyEvent->name) << endl;
|
||||||
|
//Pout<< "len:" << inotifyEvent->len << endl;
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
(inotifyEvent->mask & IN_CLOSE_WRITE)
|
||||||
|
&& inotifyEvent->len
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Search for file
|
||||||
|
forAll(watcher_->dirWatches_, i)
|
||||||
|
{
|
||||||
|
label id = watcher_->dirWatches_[i];
|
||||||
|
if
|
||||||
|
(
|
||||||
|
id == inotifyEvent->wd
|
||||||
|
&& inotifyEvent->name == watcher_->dirFiles_[i]
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Correct directory and name
|
||||||
|
localState_[i] = MODIFIED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
i += EVENT_SIZE + inotifyEvent->len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No data
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
forAll(watcher_->lastMod_, watchFd)
|
||||||
|
{
|
||||||
|
double oldTime = watcher_->lastMod_[watchFd];
|
||||||
|
|
||||||
|
if (oldTime != 0)
|
||||||
|
{
|
||||||
|
const fileName& fName = watchFile_[watchFd];
|
||||||
|
double newTime = highResLastModified(fName);
|
||||||
|
|
||||||
|
if (newTime == 0)
|
||||||
|
{
|
||||||
|
localState_[watchFd] = DELETED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (newTime > (oldTime + regIOobject::fileModificationSkew))
|
||||||
|
{
|
||||||
|
localState_[watchFd] = MODIFIED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
localState_[watchFd] = UNMODIFIED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileMonitor::fileMonitor(const bool useInotify)
|
||||||
|
:
|
||||||
|
useInotify_(useInotify),
|
||||||
|
localState_(20),
|
||||||
|
state_(20),
|
||||||
|
watchFile_(20),
|
||||||
|
freeWatchFds_(2),
|
||||||
|
watcher_(new fileMonitorWatcher(useInotify_, 20))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fileMonitor::~fileMonitor()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Note: fName might not exist (on slaves if in master-only mode for
|
||||||
|
// regIOobject)
|
||||||
|
Foam::label Foam::fileMonitor::addWatch(const fileName& fName)
|
||||||
|
{
|
||||||
|
label watchFd;
|
||||||
|
|
||||||
|
label sz = freeWatchFds_.size();
|
||||||
|
|
||||||
|
if (sz)
|
||||||
|
{
|
||||||
|
watchFd = freeWatchFds_[sz-1];
|
||||||
|
freeWatchFds_.setSize(sz-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
watchFd = state_.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
watcher_->addWatch(watchFd, fName);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "fileMonitor : added watch " << watchFd << " on file "
|
||||||
|
<< fName << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (watchFd < 0)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "could not add watch for file " << fName << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
localState_(watchFd) = UNMODIFIED;
|
||||||
|
state_(watchFd) = UNMODIFIED;
|
||||||
|
watchFile_(watchFd) = fName;
|
||||||
|
}
|
||||||
|
return watchFd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fileMonitor::removeWatch(const label watchFd)
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "fileMonitor : removing watch " << watchFd << " on file "
|
||||||
|
<< watchFile_[watchFd] << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
freeWatchFds_.append(watchFd);
|
||||||
|
return watcher_->removeWatch(watchFd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::fileName& Foam::fileMonitor::getFile(const label watchFd) const
|
||||||
|
{
|
||||||
|
return watchFile_[watchFd];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileMonitor::fileState Foam::fileMonitor::getState(const label watchFd)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
return state_[watchFd];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fileMonitor::updateStates
|
||||||
|
(
|
||||||
|
const bool masterOnly,
|
||||||
|
const bool syncPar
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (Pstream::master() || !masterOnly)
|
||||||
|
{
|
||||||
|
// Update the localState_
|
||||||
|
checkFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (syncPar)
|
||||||
|
{
|
||||||
|
// Pack local state (might be on master only)
|
||||||
|
PackedList<2> stats(state_.size(), MODIFIED);
|
||||||
|
if (Pstream::master() || !masterOnly)
|
||||||
|
{
|
||||||
|
forAll(state_, watchFd)
|
||||||
|
{
|
||||||
|
stats.set
|
||||||
|
(
|
||||||
|
watchFd,
|
||||||
|
static_cast<unsigned int>(localState_[watchFd])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Scatter or reduce to synchronise state
|
||||||
|
if (masterOnly)
|
||||||
|
{
|
||||||
|
// Scatter
|
||||||
|
if (stats.storage().size() == 1)
|
||||||
|
{
|
||||||
|
Pstream::scatter(stats.storage()[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Pstream::listCombineScatter(stats.storage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Reduce
|
||||||
|
if (stats.storage().size() == 1)
|
||||||
|
{
|
||||||
|
// Optimisation valid for most cases.
|
||||||
|
reduce(stats.storage()[0], reduceFileStates());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Pstream::listCombineGather
|
||||||
|
(
|
||||||
|
stats.storage(),
|
||||||
|
combineReduceFileStates()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Update synchronised state
|
||||||
|
forAll(state_, watchFd)
|
||||||
|
{
|
||||||
|
// Assign synchronised state
|
||||||
|
unsigned int stat = stats[watchFd];
|
||||||
|
state_[watchFd] = fileState(stat);
|
||||||
|
|
||||||
|
if (!masterOnly)
|
||||||
|
{
|
||||||
|
// Give warning for inconsistent state
|
||||||
|
if (state_[watchFd] != localState_[watchFd])
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "fileMonitor : Delaying reading "
|
||||||
|
<< watchFile_[watchFd]
|
||||||
|
<< " due to inconsistent "
|
||||||
|
"file time-stamps between processors"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
WarningInFunction
|
||||||
|
<< "Delaying reading " << watchFile_[watchFd]
|
||||||
|
<< " due to inconsistent "
|
||||||
|
"file time-stamps between processors" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state_ = localState_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fileMonitor::setUnmodified(const label watchFd)
|
||||||
|
{
|
||||||
|
state_[watchFd] = UNMODIFIED;
|
||||||
|
localState_[watchFd] = UNMODIFIED;
|
||||||
|
|
||||||
|
if (!useInotify_)
|
||||||
|
{
|
||||||
|
watcher_->lastMod_[watchFd] = highResLastModified(watchFile_[watchFd]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
165
src/OSspecific/MSwindows/fileMonitor/fileMonitor.H
Normal file
165
src/OSspecific/MSwindows/fileMonitor/fileMonitor.H
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010, 2017-2018 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::fileMonitor
|
||||||
|
|
||||||
|
Description
|
||||||
|
Checking for changes to files.
|
||||||
|
|
||||||
|
Note
|
||||||
|
The default is to use stat to get the timestamp.
|
||||||
|
|
||||||
|
Compile with FOAM_USE_INOTIFY to use the inotify
|
||||||
|
(Linux specific, since 2.6.13) framework. The problem is that inotify does
|
||||||
|
not work on nfs3 mounted directories!!
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
fileMonitor.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef fileMonitor_H
|
||||||
|
#define fileMonitor_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include "Enum.H"
|
||||||
|
#include "className.H"
|
||||||
|
#include "DynamicList.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
class fileMonitor;
|
||||||
|
class fileMonitorWatcher;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class fileMonitor Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class fileMonitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Public data types
|
||||||
|
|
||||||
|
//- Enumeration defining the file state.
|
||||||
|
enum fileState
|
||||||
|
{
|
||||||
|
UNMODIFIED = 0,
|
||||||
|
MODIFIED = 1,
|
||||||
|
DELETED = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Enum<fileState> fileStateNames_;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Whether to use inotify (requires -DFOAM_USE_INOTIFY, see above)
|
||||||
|
const bool useInotify_;
|
||||||
|
|
||||||
|
//- State for all watchFds based on local files
|
||||||
|
mutable DynamicList<fileState> localState_;
|
||||||
|
|
||||||
|
//- State for all watchFds - synchronised
|
||||||
|
mutable DynamicList<fileState> state_;
|
||||||
|
|
||||||
|
//- Filename for all watchFds
|
||||||
|
DynamicList<fileName> watchFile_;
|
||||||
|
|
||||||
|
//- Free watchFds
|
||||||
|
DynamicList<label> freeWatchFds_;
|
||||||
|
|
||||||
|
//- Watch mechanism (stat or inotify)
|
||||||
|
mutable autoPtr<fileMonitorWatcher> watcher_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Update localState_ from any events.
|
||||||
|
void checkFiles() const;
|
||||||
|
|
||||||
|
//- No copy construct
|
||||||
|
fileMonitor(const fileMonitor&) = delete;
|
||||||
|
|
||||||
|
//- No copy assignment
|
||||||
|
void operator=(const fileMonitor&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Declare name of the class and its debug switch
|
||||||
|
ClassName("fileMonitor");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
fileMonitor(const bool useInotify);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~fileMonitor();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Add file to watch. Return watch descriptor
|
||||||
|
label addWatch(const fileName&);
|
||||||
|
|
||||||
|
//- Remove file to watch. Return true if successful
|
||||||
|
bool removeWatch(const label watchFd);
|
||||||
|
|
||||||
|
//- Get name of file being watched
|
||||||
|
const fileName& getFile(const label watchFd) const;
|
||||||
|
|
||||||
|
//- Check state using handle
|
||||||
|
fileState getState(const label watchFd) const;
|
||||||
|
|
||||||
|
//- Check state of all files. Updates state_.
|
||||||
|
void updateStates
|
||||||
|
(
|
||||||
|
const bool masterOnly,
|
||||||
|
const bool syncPar
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Reset state (e.g. after having read it) using handle
|
||||||
|
void setUnmodified(const label watchFd);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
214
src/OSspecific/MSwindows/fileStat/fileStat.C
Normal file
214
src/OSspecific/MSwindows/fileStat/fileStat.C
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2011, 2016-2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "fileStat.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "timer.H"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#undef major
|
||||||
|
#undef minor
|
||||||
|
#undef makedev
|
||||||
|
|
||||||
|
#define major(dev) int(((dev) >> 8) & 0xff)
|
||||||
|
#define minor(dev) int((dev) & 0xff)
|
||||||
|
#define makedev(majNum, minNum) (((unsigned(majNum)) << 8) | (unsigned(minNum)))
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fileStat::fileStat()
|
||||||
|
:
|
||||||
|
valid_(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileStat::fileStat
|
||||||
|
(
|
||||||
|
const char* fName,
|
||||||
|
const bool followLink,
|
||||||
|
const unsigned int maxTime
|
||||||
|
)
|
||||||
|
:
|
||||||
|
valid_(false)
|
||||||
|
{
|
||||||
|
if (!fName || !fName[0])
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work on volatile
|
||||||
|
volatile bool locIsValid = false;
|
||||||
|
|
||||||
|
timer myTimer(maxTime);
|
||||||
|
|
||||||
|
if (!timedOut(myTimer))
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
locIsValid = (::stat(fName, &status_) == 0);
|
||||||
|
#else
|
||||||
|
if (followLink)
|
||||||
|
{
|
||||||
|
locIsValid = (::stat(fName, &status_) == 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
locIsValid = (::lstat(fName, &status_) == 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy into (non-volatile, possible register based) member var
|
||||||
|
valid_ = locIsValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileStat::fileStat
|
||||||
|
(
|
||||||
|
const fileName& fName,
|
||||||
|
const bool followLink,
|
||||||
|
const unsigned int maxTime
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fileStat(fName.c_str(), followLink, maxTime)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileStat::fileStat(Istream& is)
|
||||||
|
{
|
||||||
|
is >> *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::label Foam::fileStat::size() const
|
||||||
|
{
|
||||||
|
return valid_ ? label(status_.st_size) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
time_t Foam::fileStat::modTime() const
|
||||||
|
{
|
||||||
|
return valid_ ? status_.st_mtime : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double Foam::fileStat::dmodTime() const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
(
|
||||||
|
valid_
|
||||||
|
?
|
||||||
|
#ifdef __APPLE__
|
||||||
|
(status_.st_mtime + 1e-9*status_.st_mtimespec.tv_nsec)
|
||||||
|
#elif defined (_WIN32)
|
||||||
|
(status_.st_mtime)
|
||||||
|
#else
|
||||||
|
(status_.st_mtime + 1e-9*status_.st_mtim.tv_nsec)
|
||||||
|
#endif
|
||||||
|
: 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fileStat::sameDevice(const fileStat& other) const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
valid_
|
||||||
|
&& (
|
||||||
|
major(status_.st_dev) == major(other.status_.st_dev)
|
||||||
|
&& minor(status_.st_dev) == minor(other.status_.st_dev)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fileStat::sameINode(const fileStat& other) const
|
||||||
|
{
|
||||||
|
return valid_ && (status_.st_ino == other.status_.st_ino);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fileStat::sameINode(const label iNode) const
|
||||||
|
{
|
||||||
|
return valid_ && (status_.st_ino == ino_t(iNode));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::Istream& Foam::operator>>(Istream& is, fileStat& fs)
|
||||||
|
{
|
||||||
|
FixedList<label, 13> list(is);
|
||||||
|
|
||||||
|
fs.valid_ = list[0];
|
||||||
|
|
||||||
|
dev_t st_dev = makedev(list[1], list[2]);
|
||||||
|
fs.status_.st_dev = st_dev;
|
||||||
|
|
||||||
|
fs.status_.st_ino = list[3];
|
||||||
|
fs.status_.st_mode = list[4];
|
||||||
|
fs.status_.st_uid = list[5];
|
||||||
|
fs.status_.st_gid = list[6];
|
||||||
|
|
||||||
|
dev_t st_rdev = makedev(list[7], list[8]);
|
||||||
|
fs.status_.st_rdev = st_rdev;
|
||||||
|
|
||||||
|
fs.status_.st_size = list[9];
|
||||||
|
fs.status_.st_atime = list[10];
|
||||||
|
fs.status_.st_mtime = list[11];
|
||||||
|
fs.status_.st_ctime = list[12];
|
||||||
|
|
||||||
|
is.check(FUNCTION_NAME);
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::operator<<(Ostream& os, const fileStat& fs)
|
||||||
|
{
|
||||||
|
FixedList<label, 13> list;
|
||||||
|
|
||||||
|
list[0] = label(fs.valid_);
|
||||||
|
list[1] = label(major(fs.status_.st_dev));
|
||||||
|
list[2] = label(minor(fs.status_.st_dev));
|
||||||
|
list[3] = label(fs.status_.st_ino);
|
||||||
|
list[4] = label(fs.status_.st_mode);
|
||||||
|
list[5] = label(fs.status_.st_uid);
|
||||||
|
list[6] = label(fs.status_.st_gid);
|
||||||
|
list[7] = label(major(fs.status_.st_rdev));
|
||||||
|
list[8] = label(minor(fs.status_.st_rdev));
|
||||||
|
list[9] = label(fs.status_.st_size);
|
||||||
|
list[10] = label(fs.status_.st_atime);
|
||||||
|
list[11] = label(fs.status_.st_mtime);
|
||||||
|
list[12] = label(fs.status_.st_ctime);
|
||||||
|
|
||||||
|
return os << list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
180
src/OSspecific/MSwindows/fileStat/fileStat.H
Normal file
180
src/OSspecific/MSwindows/fileStat/fileStat.H
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2010, 2016-2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::fileStat
|
||||||
|
|
||||||
|
Description
|
||||||
|
Wrapper for stat() and lstat() system calls.
|
||||||
|
|
||||||
|
Warning
|
||||||
|
On Linux (an maybe on others) a stat() of an nfs mounted (remote)
|
||||||
|
file does never timeout and cannot be interrupted!
|
||||||
|
So e.g. Foam::ping first and hope nfs is running.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
fileStat.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef fileStat_H
|
||||||
|
#define fileStat_H
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "label.H"
|
||||||
|
#include "fileName.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
class fileStat;
|
||||||
|
|
||||||
|
Istream& operator>>(Istream& is, fileStat& fs);
|
||||||
|
Ostream& operator<<(Ostream& os, const fileStat& fs);
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class fileStat Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class fileStat
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
struct stat status_;
|
||||||
|
|
||||||
|
bool valid_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Empty constructor
|
||||||
|
fileStat();
|
||||||
|
|
||||||
|
//- Construct from components.
|
||||||
|
//
|
||||||
|
// \param fName The file name or directory name to stat.
|
||||||
|
// \param followLink If it is a link, get the status of the source
|
||||||
|
// file/directory.
|
||||||
|
// \param maxTime The timeout value.
|
||||||
|
//
|
||||||
|
// \note An empty filename is a no-op.
|
||||||
|
fileStat
|
||||||
|
(
|
||||||
|
const char* fName,
|
||||||
|
const bool followLink = true,
|
||||||
|
const unsigned int maxTime = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from components.
|
||||||
|
//
|
||||||
|
// \param fName The file name or directory name to stat.
|
||||||
|
// \param followLink If it is a link, get the status of the source
|
||||||
|
// file/directory.
|
||||||
|
// \param maxTime The timeout value.
|
||||||
|
//
|
||||||
|
// \note An empty filename is a no-op.
|
||||||
|
fileStat
|
||||||
|
(
|
||||||
|
const fileName& fName,
|
||||||
|
const bool followLink = true,
|
||||||
|
const unsigned int maxTime = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
explicit fileStat(Istream& is);
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
//- Raw status
|
||||||
|
const struct stat& status() const
|
||||||
|
{
|
||||||
|
return status_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Was file-stat successful?
|
||||||
|
bool valid() const
|
||||||
|
{
|
||||||
|
return valid_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Size in bytes. Zero for an invalid file-stat.
|
||||||
|
label size() const;
|
||||||
|
|
||||||
|
//- Return the modification time in seconds.
|
||||||
|
// Zero for an invalid file-stat.
|
||||||
|
time_t modTime() const;
|
||||||
|
|
||||||
|
//- Return the modification time in seconds (nanosecond resolution)
|
||||||
|
// Zero for an invalid file-stat.
|
||||||
|
double dmodTime() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Check
|
||||||
|
|
||||||
|
//- Compare two fileStats for same device
|
||||||
|
bool sameDevice(const fileStat& other) const;
|
||||||
|
|
||||||
|
//- Compare two fileStats for same Inode
|
||||||
|
bool sameINode(const fileStat& other) const;
|
||||||
|
|
||||||
|
//- Compare state against inode
|
||||||
|
bool sameINode(const label iNode) const;
|
||||||
|
|
||||||
|
|
||||||
|
// IOstream Operators
|
||||||
|
|
||||||
|
friend Istream& operator>>(Istream& is, fileStat& fs);
|
||||||
|
friend Ostream& operator<<(Ostream& os, const fileStat& fs);
|
||||||
|
|
||||||
|
|
||||||
|
// Housekeeping
|
||||||
|
|
||||||
|
//- Deprecated(2019-04) Was file-stat successful?
|
||||||
|
// \deprecated(2019-04) - use valid() method
|
||||||
|
bool isValid() const { return valid_; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
109
src/OSspecific/MSwindows/memInfo/memInfo.C
Normal file
109
src/OSspecific/MSwindows/memInfo/memInfo.C
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010, 2016-2017 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "memInfo.H"
|
||||||
|
#include "OSspecific.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::memInfo::memInfo()
|
||||||
|
:
|
||||||
|
peak_(0),
|
||||||
|
size_(0),
|
||||||
|
rss_(0),
|
||||||
|
free_(0)
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::memInfo::valid() const
|
||||||
|
{
|
||||||
|
return peak_ > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::memInfo::clear()
|
||||||
|
{
|
||||||
|
peak_ = size_ = rss_ = 0;
|
||||||
|
free_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::memInfo& Foam::memInfo::update()
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
|
||||||
|
// Not supported under Windows
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::memInfo::write(Ostream& os) const
|
||||||
|
{
|
||||||
|
os.writeEntry("size", size_);
|
||||||
|
os.writeEntry("peak", peak_);
|
||||||
|
os.writeEntry("rss", rss_);
|
||||||
|
os.writeEntry("free", free_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::Istream& Foam::operator>>(Istream& is, memInfo& m)
|
||||||
|
{
|
||||||
|
is.readBegin("memInfo");
|
||||||
|
is >> m.peak_ >> m.size_ >> m.rss_ >> m.free_;
|
||||||
|
is.readEnd("memInfo");
|
||||||
|
|
||||||
|
is.check(FUNCTION_NAME);
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::operator<<(Ostream& os, const memInfo& m)
|
||||||
|
{
|
||||||
|
os << token::BEGIN_LIST
|
||||||
|
<< m.peak_ << token::SPACE
|
||||||
|
<< m.size_ << token::SPACE
|
||||||
|
<< m.rss_ << token::SPACE
|
||||||
|
<< m.free_
|
||||||
|
<< token::END_LIST;
|
||||||
|
|
||||||
|
os.check(FUNCTION_NAME);
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
151
src/OSspecific/MSwindows/memInfo/memInfo.H
Normal file
151
src/OSspecific/MSwindows/memInfo/memInfo.H
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010, 2016-2017 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::memInfo
|
||||||
|
|
||||||
|
Description
|
||||||
|
Memory usage information for the current process, and the system memory
|
||||||
|
that is free.
|
||||||
|
|
||||||
|
Note
|
||||||
|
Windows variant does nothing.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
memInfo.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef memInfo_H
|
||||||
|
#define memInfo_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward declaration of friend functions and operators
|
||||||
|
class memInfo;
|
||||||
|
class Istream;
|
||||||
|
class Ostream;
|
||||||
|
|
||||||
|
Istream& operator>>(Istream& is, memInfo& m);
|
||||||
|
Ostream& operator<<(Ostream& os, const memInfo& m);
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class memInfo Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class memInfo
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Peak memory used by the process (VmPeak in /proc/PID/status)
|
||||||
|
int peak_;
|
||||||
|
|
||||||
|
//- Memory used by the process (VmSize in /proc/PID/status)
|
||||||
|
int size_;
|
||||||
|
|
||||||
|
//- Resident set size of the process (VmRSS in /proc/PID/status)
|
||||||
|
int rss_;
|
||||||
|
|
||||||
|
//- System memory free (MemFree in /proc/meminfo)
|
||||||
|
int free_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct and populate with values
|
||||||
|
memInfo();
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~memInfo() = default;
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- True if the memory information appears valid
|
||||||
|
bool valid() const;
|
||||||
|
|
||||||
|
//- Reset to zero
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
//- Update according to /proc/PID/status and /proc/memory contents
|
||||||
|
const memInfo& update();
|
||||||
|
|
||||||
|
|
||||||
|
//- Peak memory (VmPeak in /proc/PID/status) at last update()
|
||||||
|
inline int peak() const
|
||||||
|
{
|
||||||
|
return peak_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Memory size (VmSize in /proc/PID/status) at last update()
|
||||||
|
inline int size() const
|
||||||
|
{
|
||||||
|
return size_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Resident set size (VmRSS in /proc/PID/status) at last update()
|
||||||
|
inline int rss() const
|
||||||
|
{
|
||||||
|
return rss_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- System memory free (MemFree in /proc/meminfo)
|
||||||
|
inline int free() const
|
||||||
|
{
|
||||||
|
return free_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Write
|
||||||
|
|
||||||
|
//- Write content as dictionary entries
|
||||||
|
void write(Ostream& os) const;
|
||||||
|
|
||||||
|
|
||||||
|
// IOstream Operators
|
||||||
|
|
||||||
|
//- Read peak/size/rss from stream
|
||||||
|
friend Istream& operator>>(Istream& is, memInfo& m);
|
||||||
|
|
||||||
|
//- Write peak/size/rss to stream
|
||||||
|
friend Ostream& operator<<(Ostream& os, const memInfo& m);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
40
src/OSspecific/MSwindows/printStack/dummyPrintStack.C
Normal file
40
src/OSspecific/MSwindows/printStack/dummyPrintStack.C
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "error.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::error::safePrintStack(std::ostream& os)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::error::printStack(Ostream& os)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
40
src/OSspecific/MSwindows/regExp/regExp.H
Normal file
40
src/OSspecific/MSwindows/regExp/regExp.H
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Typedef
|
||||||
|
Foam::regExp
|
||||||
|
|
||||||
|
Description
|
||||||
|
Selection of preferred regular expression implementation
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef regExp_H
|
||||||
|
#define regExp_H
|
||||||
|
|
||||||
|
#include "regExpCxx.H"
|
||||||
|
#include "regExpFwd.H"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
48
src/OSspecific/MSwindows/regExp/regExpFwd.H
Normal file
48
src/OSspecific/MSwindows/regExp/regExpFwd.H
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Typedef
|
||||||
|
Foam::regExp
|
||||||
|
|
||||||
|
Description
|
||||||
|
Selection of preferred regular expression implementation
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef regExpFwd_H
|
||||||
|
#define regExpFwd_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
class regExpCxx;
|
||||||
|
|
||||||
|
typedef regExpCxx regExp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
235
src/OSspecific/MSwindows/signals/sigFpe.C
Normal file
235
src/OSspecific/MSwindows/signals/sigFpe.C
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2011, 2016-2018 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
| Copyright (C) 2011 Symscape
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "sigFpe.H"
|
||||||
|
#include "error.H"
|
||||||
|
#include "JobInfo.H"
|
||||||
|
#include "OSspecific.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "Switch.H"
|
||||||
|
#include "UList.H"
|
||||||
|
|
||||||
|
#include <float.h> // For *fp functions
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
// File-local functions
|
||||||
|
#include "signalMacros.C"
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::sigFpe::switchFpe_(Foam::debug::optimisationSwitch("trapFpe", 0));
|
||||||
|
bool Foam::sigFpe::switchNan_(Foam::debug::optimisationSwitch("setNaN", 0));
|
||||||
|
|
||||||
|
bool Foam::sigFpe::sigActive_ = false;
|
||||||
|
bool Foam::sigFpe::nanActive_ = false;
|
||||||
|
|
||||||
|
// Saved old FPE signal trapping setting (file-local variable)
|
||||||
|
static unsigned int oldFpe_ = 0u;
|
||||||
|
|
||||||
|
|
||||||
|
static void clearFpe()
|
||||||
|
{
|
||||||
|
#ifndef Foam_no_sigFpe
|
||||||
|
_clearfp();
|
||||||
|
_controlfp(oldFpe_, 0xFFFFFFFF);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Can turn on/off via env variable containing a bool (true|false|on|off ...)
|
||||||
|
// or by the specified flag
|
||||||
|
static bool isTrue(const char* envName, bool deflt)
|
||||||
|
{
|
||||||
|
const auto str(Foam::getEnv(envName));
|
||||||
|
|
||||||
|
if (str.size())
|
||||||
|
{
|
||||||
|
Foam::Switch sw(str, true); // Silently ignores bad input
|
||||||
|
|
||||||
|
if (sw.valid())
|
||||||
|
{
|
||||||
|
return sw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Env was not set or did not contain a valid bool value
|
||||||
|
return deflt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::sigFpe::sigHandler(int)
|
||||||
|
{
|
||||||
|
resetHandler("SIGFPE", SIGFPE);
|
||||||
|
|
||||||
|
jobInfo.signalEnd(); // Update jobInfo file
|
||||||
|
error::printStack(Perr);
|
||||||
|
clearFpe();
|
||||||
|
::raise(SIGFPE); // Throw signal (to old handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sigFpe::sigFpe()
|
||||||
|
{
|
||||||
|
set(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::sigFpe::ignore::ignore()
|
||||||
|
:
|
||||||
|
wasActive_(sigFpe::active())
|
||||||
|
{
|
||||||
|
if (wasActive_)
|
||||||
|
{
|
||||||
|
sigFpe::unset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sigFpe::~sigFpe()
|
||||||
|
{
|
||||||
|
unset(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::sigFpe::ignore::~ignore()
|
||||||
|
{
|
||||||
|
restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::sigFpe::ignore::restore()
|
||||||
|
{
|
||||||
|
if (wasActive_)
|
||||||
|
{
|
||||||
|
sigFpe::set();
|
||||||
|
}
|
||||||
|
wasActive_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::sigFpe::requested()
|
||||||
|
{
|
||||||
|
return isTrue("FOAM_SIGFPE", switchFpe_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::sigFpe::set(bool verbose)
|
||||||
|
{
|
||||||
|
if (!sigActive_ && requested())
|
||||||
|
{
|
||||||
|
#ifdef Foam_no_sigFpe
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "trapFpe: Floating point exception trapping ";
|
||||||
|
Info<< "- disabled on this platform" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
oldFpe_ = _controlfp(0, 0);
|
||||||
|
|
||||||
|
const unsigned int newFpe =
|
||||||
|
(
|
||||||
|
oldFpe_ & ~(_EM_ZERODIVIDE | _EM_INVALID | _EM_OVERFLOW)
|
||||||
|
);
|
||||||
|
|
||||||
|
_controlfp(newFpe, _MCW_EM);
|
||||||
|
|
||||||
|
setHandler("SIGFPE", SIGFPE, sigHandler);
|
||||||
|
|
||||||
|
sigActive_ = true;
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "trapFpe: Floating point exception trapping ";
|
||||||
|
|
||||||
|
if (sigActive_)
|
||||||
|
{
|
||||||
|
Info<< "enabled (FOAM_SIGFPE)." << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "- not supported on this platform" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nanActive_ = false;
|
||||||
|
if (isTrue("FOAM_SETNAN", switchNan_))
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "setNaN : Initialise allocated memory to NaN "
|
||||||
|
<< "- not supported on this platform" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::sigFpe::unset(bool verbose)
|
||||||
|
{
|
||||||
|
if (sigActive_)
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "sigFpe : Disabling floating point exception trapping"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
sigActive_ = false;
|
||||||
|
|
||||||
|
clearFpe();
|
||||||
|
|
||||||
|
resetHandler("SIGFPE", SIGFPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
nanActive_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::sigFpe::fillNan(UList<scalar>& list)
|
||||||
|
{
|
||||||
|
list = std::numeric_limits<scalar>::signaling_NaN();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
186
src/OSspecific/MSwindows/signals/sigFpe.H
Normal file
186
src/OSspecific/MSwindows/signals/sigFpe.H
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2011, 2018-2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::sigFpe
|
||||||
|
|
||||||
|
Description
|
||||||
|
Set up trapping for floating point exceptions (signal FPE).
|
||||||
|
|
||||||
|
Defined by controlDict InfoSwitch entries:
|
||||||
|
- \par trapFpe
|
||||||
|
Enable floating point exception trapping.
|
||||||
|
|
||||||
|
- \par setNaN
|
||||||
|
Initialization all malloced memory to NaN.
|
||||||
|
Combined with \c trapFpe, this causes usage of uninitialized scalars
|
||||||
|
to trigger an abort.
|
||||||
|
|
||||||
|
Environment variables:
|
||||||
|
- \par FOAM_SIGFPE (true|false)
|
||||||
|
overrides \c trapFpe
|
||||||
|
- \par FOAM_SETNAN (true|false)
|
||||||
|
overrides \c 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.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
sigFpe.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef sigFpe_H
|
||||||
|
#define sigFpe_H
|
||||||
|
|
||||||
|
#include "scalar.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
template<class T> class UList;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class sigFpe Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class sigFpe
|
||||||
|
{
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- Flag that floating point trapping should be used.
|
||||||
|
// Can override with FOAM_SIGFPE env variable
|
||||||
|
static bool switchFpe_;
|
||||||
|
|
||||||
|
//- Flag that NaN initialisation should be used.
|
||||||
|
// Can override with FOAM_SETNAN env variable
|
||||||
|
static bool switchNan_;
|
||||||
|
|
||||||
|
//- Floating point trapping currently active?
|
||||||
|
static bool sigActive_;
|
||||||
|
|
||||||
|
//- Flag to indicate mallocNan is currently active
|
||||||
|
static bool nanActive_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Handler for caught signals - ends job and prints stack
|
||||||
|
static void sigHandler(int);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- 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.
|
||||||
|
~sigFpe();
|
||||||
|
|
||||||
|
|
||||||
|
// Static Member Functions
|
||||||
|
|
||||||
|
//- Check if SIGFPE signals handler is to be enabled.
|
||||||
|
// This is controlled by the trapFpe entry or the FOAM_SIGFPE
|
||||||
|
// environment variable
|
||||||
|
static bool requested();
|
||||||
|
|
||||||
|
//- True if SIGFPE handling is currently active.
|
||||||
|
static inline bool active()
|
||||||
|
{
|
||||||
|
return sigActive_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- True if NaN memory initialisation is currently active.
|
||||||
|
static inline bool nanActive()
|
||||||
|
{
|
||||||
|
return nanActive_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Activate SIGFPE signal handler when FOAM_SIGFPE is %set
|
||||||
|
// Fill memory with NaN when FOAM_SETNAN is %set
|
||||||
|
static void set(bool verbose=false);
|
||||||
|
|
||||||
|
//- Deactivate SIGFPE signal handler and NaN memory initialisation
|
||||||
|
static void unset(bool verbose=false);
|
||||||
|
|
||||||
|
//- Fill data block with NaN values
|
||||||
|
static void fillNan(UList<scalar>& list);
|
||||||
|
|
||||||
|
|
||||||
|
// Helper classes
|
||||||
|
|
||||||
|
//- Helper to locally ignore SIGFPE handling.
|
||||||
|
// Restores the original state of the SIGFPE handler on destruction.
|
||||||
|
class ignore
|
||||||
|
{
|
||||||
|
//- The signal handler state when entering
|
||||||
|
bool wasActive_;
|
||||||
|
|
||||||
|
//- No copy construct
|
||||||
|
ignore(const ignore&) = delete;
|
||||||
|
|
||||||
|
//- No copy assignment
|
||||||
|
void operator=(const ignore&) = delete;
|
||||||
|
|
||||||
|
//- No move construct
|
||||||
|
ignore(ignore&&) = delete;
|
||||||
|
|
||||||
|
//- No move assignment
|
||||||
|
void operator=(ignore&&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Constructor deactivates any previously active SIGFPE handler
|
||||||
|
ignore();
|
||||||
|
|
||||||
|
//- Destructor restores the original state of SIGFPE handler
|
||||||
|
~ignore();
|
||||||
|
|
||||||
|
//- Restore the original state of SIGFPE handler
|
||||||
|
void restore();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
96
src/OSspecific/MSwindows/signals/sigInt.C
Normal file
96
src/OSspecific/MSwindows/signals/sigInt.C
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2011, 2018-2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
| Copyright (C) 2011 Symscape
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "sigInt.H"
|
||||||
|
#include "error.H"
|
||||||
|
#include "JobInfo.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
|
||||||
|
// File-local functions
|
||||||
|
#include "signalMacros.C"
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::sigInt::sigActive_ = false;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::sigInt::sigHandler(int)
|
||||||
|
{
|
||||||
|
resetHandler("SIGINT", SIGINT);
|
||||||
|
|
||||||
|
jobInfo.signalEnd(); // Update jobInfo file
|
||||||
|
::raise(SIGINT); // Throw signal (to old handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sigInt::sigInt()
|
||||||
|
{
|
||||||
|
set(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sigInt::~sigInt()
|
||||||
|
{
|
||||||
|
unset(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::sigInt::set(bool)
|
||||||
|
{
|
||||||
|
if (sigActive_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sigActive_ = true;
|
||||||
|
|
||||||
|
setHandler("SIGINT", SIGINT, sigHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::sigInt::unset(const bool verbose)
|
||||||
|
{
|
||||||
|
if (!sigActive_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sigActive_ = false;
|
||||||
|
|
||||||
|
resetHandler("SIGINT", SIGINT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
102
src/OSspecific/MSwindows/signals/sigInt.H
Normal file
102
src/OSspecific/MSwindows/signals/sigInt.H
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2011, 2018-2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::sigInt
|
||||||
|
|
||||||
|
Description
|
||||||
|
Signal handler for INT interupt.
|
||||||
|
|
||||||
|
The standard interupt handler is overridden to ensure that the
|
||||||
|
runningJob file is removed.
|
||||||
|
|
||||||
|
Can be used either directly through the static member functions or
|
||||||
|
through the scope of the object (constructor sets trapping; destructor
|
||||||
|
restores original).
|
||||||
|
|
||||||
|
See also
|
||||||
|
Foam::JobInfo
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
sigInt.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef sigInt_H
|
||||||
|
#define sigInt_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class sigInt Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class sigInt
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Signal trapping enabled?
|
||||||
|
static bool sigActive_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
static void sigHandler(int);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
sigInt();
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~sigInt();
|
||||||
|
|
||||||
|
|
||||||
|
// Member functions
|
||||||
|
|
||||||
|
//- Activate SIGINT signal handler
|
||||||
|
static void set(bool verbose=false);
|
||||||
|
|
||||||
|
//- Deactivate SIGINT signal handler
|
||||||
|
static void unset(bool verbose=false);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
99
src/OSspecific/MSwindows/signals/sigQuit.C
Normal file
99
src/OSspecific/MSwindows/signals/sigQuit.C
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2011, 2018-2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
| Copyright (C) 2011 Symscape
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "sigQuit.H"
|
||||||
|
#include "error.H"
|
||||||
|
#include "JobInfo.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
|
||||||
|
// File-local functions
|
||||||
|
#include "signalMacros.C"
|
||||||
|
|
||||||
|
// NOTE: SIGBREAK is the best alternative to SIGQUIT on windows
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::sigQuit::sigActive_ = false;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::sigQuit::sigHandler(int)
|
||||||
|
{
|
||||||
|
resetHandler("SIGBREAK", SIGBREAK);
|
||||||
|
|
||||||
|
jobInfo.signalEnd(); // Update jobInfo file
|
||||||
|
error::printStack(Perr);
|
||||||
|
::raise(SIGBREAK); // Throw signal (to old handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sigQuit::sigQuit()
|
||||||
|
{
|
||||||
|
set(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sigQuit::~sigQuit()
|
||||||
|
{
|
||||||
|
unset(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::sigQuit::set(bool)
|
||||||
|
{
|
||||||
|
if (sigActive_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sigActive_ = true;
|
||||||
|
|
||||||
|
setHandler("SIGBREAK", SIGBREAK, sigHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::sigQuit::unset(bool)
|
||||||
|
{
|
||||||
|
if (!sigActive_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sigActive_ = false;
|
||||||
|
|
||||||
|
resetHandler("SIGBREAK", SIGBREAK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
102
src/OSspecific/MSwindows/signals/sigQuit.H
Normal file
102
src/OSspecific/MSwindows/signals/sigQuit.H
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2011, 2017-2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::sigQuit
|
||||||
|
|
||||||
|
Description
|
||||||
|
Signal handler for QUIT interupt.
|
||||||
|
|
||||||
|
The standard interupt handler is overridden to ensure that the
|
||||||
|
runningJob file is removed.
|
||||||
|
Can be used either directly through the static member functions or
|
||||||
|
through the scope of the object (constructor sets trapping; destructor
|
||||||
|
restores original).
|
||||||
|
|
||||||
|
See also
|
||||||
|
Foam::JobInfo
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
sigQuit.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef sigQuit_H
|
||||||
|
#define sigQuit_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class sigQuit Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class sigQuit
|
||||||
|
{
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- Signal trapping enabled?
|
||||||
|
static bool sigActive_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Handler for caught signals
|
||||||
|
static void sigHandler(int);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
sigQuit();
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~sigQuit();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Activate SIGQUIT signal handler
|
||||||
|
static void set(bool verbose=false);
|
||||||
|
|
||||||
|
//- Deactivate SIGQUIT signal handler
|
||||||
|
static void unset(bool verbose=false);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
96
src/OSspecific/MSwindows/signals/sigSegv.C
Normal file
96
src/OSspecific/MSwindows/signals/sigSegv.C
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2011, 2018-2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "sigSegv.H"
|
||||||
|
#include "error.H"
|
||||||
|
#include "JobInfo.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
|
||||||
|
// File-local functions
|
||||||
|
#include "signalMacros.C"
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::sigSegv::sigActive_ = false;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::sigSegv::sigHandler(int)
|
||||||
|
{
|
||||||
|
resetHandler("SIGSEGV", SIGSEGV);
|
||||||
|
|
||||||
|
jobInfo.signalEnd(); // Update jobInfo file
|
||||||
|
error::printStack(Perr);
|
||||||
|
::raise(SIGSEGV); // Throw signal (to old handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sigSegv::sigSegv()
|
||||||
|
{
|
||||||
|
set(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sigSegv::~sigSegv()
|
||||||
|
{
|
||||||
|
unset(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::sigSegv::set(bool)
|
||||||
|
{
|
||||||
|
if (sigActive_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sigActive_ = true;
|
||||||
|
|
||||||
|
setHandler("SIGSEGV", SIGSEGV, sigHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::sigSegv::unset(bool)
|
||||||
|
{
|
||||||
|
if (!sigActive_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sigActive_ = false;
|
||||||
|
|
||||||
|
resetHandler("SIGSEGV", SIGSEGV);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
102
src/OSspecific/MSwindows/signals/sigSegv.H
Normal file
102
src/OSspecific/MSwindows/signals/sigSegv.H
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2011, 2018-2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::sigSegv
|
||||||
|
|
||||||
|
Description
|
||||||
|
Signal handler for SEGV interupt.
|
||||||
|
|
||||||
|
The standard interupt handler is overridden to ensure that the
|
||||||
|
runningJob file is removed.
|
||||||
|
Can be used either directly through the static member functions or
|
||||||
|
through the scope of the object (constructor sets trapping; destructor
|
||||||
|
restores original).
|
||||||
|
|
||||||
|
See also
|
||||||
|
Foam::JobInfo
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
sigSegv.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef sigSegv_H
|
||||||
|
#define sigSegv_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class sigSegv Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class sigSegv
|
||||||
|
{
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- Signal trapping enabled?
|
||||||
|
static bool sigActive_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Handler for caught signals
|
||||||
|
static void sigHandler(int);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
sigSegv();
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~sigSegv();
|
||||||
|
|
||||||
|
|
||||||
|
// Member functions
|
||||||
|
|
||||||
|
//- Activate SIGSEGV signal handler
|
||||||
|
static void set(bool verbose=false);
|
||||||
|
|
||||||
|
//- Deactivate SIGSEGV signal handler
|
||||||
|
static void unset(bool verbose=false);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
174
src/OSspecific/MSwindows/signals/sigStopAtWriteNow.C
Normal file
174
src/OSspecific/MSwindows/signals/sigStopAtWriteNow.C
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "sigWriteNow.H"
|
||||||
|
#include "sigStopAtWriteNow.H"
|
||||||
|
#include "error.H"
|
||||||
|
#include "JobInfo.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "Time.H"
|
||||||
|
|
||||||
|
// File-local functions
|
||||||
|
#include "signalMacros.C"
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Signal number to catch
|
||||||
|
int Foam::sigStopAtWriteNow::signal_
|
||||||
|
(
|
||||||
|
Foam::debug::optimisationSwitch("stopAtWriteNowSignal", -1)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Pointer to Time (file-local variable)
|
||||||
|
static Foam::Time const* runTimePtr_ = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Local Classes * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
// Register re-reader
|
||||||
|
struct addstopAtWriteNowSignalToOpt
|
||||||
|
:
|
||||||
|
public ::Foam::simpleRegIOobject
|
||||||
|
{
|
||||||
|
addstopAtWriteNowSignalToOpt(const char* name)
|
||||||
|
:
|
||||||
|
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual ~addstopAtWriteNowSignalToOpt() = default;
|
||||||
|
|
||||||
|
virtual void readData(Foam::Istream& is)
|
||||||
|
{
|
||||||
|
sigStopAtWriteNow::signal_ = readLabel(is);
|
||||||
|
sigStopAtWriteNow::set(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void writeData(Foam::Ostream& os) const
|
||||||
|
{
|
||||||
|
os << sigStopAtWriteNow::signal_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
addstopAtWriteNowSignalToOpt addstopAtWriteNowSignalToOpt_
|
||||||
|
(
|
||||||
|
"stopAtWriteNowSignal"
|
||||||
|
);
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::sigStopAtWriteNow::sigHandler(int)
|
||||||
|
{
|
||||||
|
resetHandler("stopAtWriteNow", signal_);
|
||||||
|
|
||||||
|
jobInfo.signalEnd(); // Update jobInfo file
|
||||||
|
|
||||||
|
if (runTimePtr_)
|
||||||
|
{
|
||||||
|
Info<< "sigStopAtWriteNow :"
|
||||||
|
<< " setting up write and stop at end of the next iteration"
|
||||||
|
<< nl << endl;
|
||||||
|
runTimePtr_->stopAt(Time::saWriteNow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sigStopAtWriteNow::sigStopAtWriteNow()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::sigStopAtWriteNow::sigStopAtWriteNow(const Time& runTime, bool verbose)
|
||||||
|
{
|
||||||
|
runTimePtr_ = &runTime; // Store runTime
|
||||||
|
set(verbose);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sigStopAtWriteNow::~sigStopAtWriteNow()
|
||||||
|
{
|
||||||
|
if (!active())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
resetHandler("stopAtWriteNow", signal_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::sigStopAtWriteNow::active()
|
||||||
|
{
|
||||||
|
return signal_ > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Foam::sigStopAtWriteNow::signalNumber()
|
||||||
|
{
|
||||||
|
return signal_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::sigStopAtWriteNow::set(bool verbose)
|
||||||
|
{
|
||||||
|
if (!active())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Check that the signal is different from the writeNowSignal
|
||||||
|
if (sigWriteNow::signalNumber() == signal_)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "stopAtWriteNowSignal : " << signal_
|
||||||
|
<< " cannot be the same as the writeNowSignal."
|
||||||
|
<< " Please change this in the etc/controlDict."
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "sigStopAtWriteNow :"
|
||||||
|
<< " Enabling writing and stopping upon signal " << signal_
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
setHandler("stopAtWriteNow", signal_, sigHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
107
src/OSspecific/MSwindows/signals/sigStopAtWriteNow.H
Normal file
107
src/OSspecific/MSwindows/signals/sigStopAtWriteNow.H
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::sigStopAtWriteNow
|
||||||
|
|
||||||
|
Description
|
||||||
|
Signal handler to write and stop the job.
|
||||||
|
The interrupt is defined by OptimisationSwitches::stopAtWriteNowSignal
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
sigStopAtWriteNow.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef sigStopAtWriteNow_H
|
||||||
|
#define sigStopAtWriteNow_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
class Time;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class sigStopAtWriteNow Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class sigStopAtWriteNow
|
||||||
|
{
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- Signal number to use
|
||||||
|
static int signal_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Handler for caught signals
|
||||||
|
static void sigHandler(int);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Allow setter access to signal_
|
||||||
|
friend class addstopAtWriteNowSignalToOpt;
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
sigStopAtWriteNow();
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
sigStopAtWriteNow(const Time& runTime, bool verbose=false);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~sigStopAtWriteNow();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Is active?
|
||||||
|
static bool active();
|
||||||
|
|
||||||
|
//- Signal number being used
|
||||||
|
static int signalNumber();
|
||||||
|
|
||||||
|
//- Set/reset signal handler
|
||||||
|
static void set(bool verbose=false);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
154
src/OSspecific/MSwindows/signals/sigWriteNow.C
Normal file
154
src/OSspecific/MSwindows/signals/sigWriteNow.C
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "sigWriteNow.H"
|
||||||
|
#include "error.H"
|
||||||
|
#include "JobInfo.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "Time.H"
|
||||||
|
|
||||||
|
// File-local functions
|
||||||
|
#include "signalMacros.C"
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Signal number to catch
|
||||||
|
int Foam::sigWriteNow::signal_
|
||||||
|
(
|
||||||
|
Foam::debug::optimisationSwitch("writeNowSignal", -1)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Pointer to Time (file-local variable)
|
||||||
|
static Foam::Time* runTimePtr_ = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Local Classes * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Register re-reader
|
||||||
|
struct addwriteNowSignalToOpt
|
||||||
|
:
|
||||||
|
public ::Foam::simpleRegIOobject
|
||||||
|
{
|
||||||
|
addwriteNowSignalToOpt(const char* name)
|
||||||
|
:
|
||||||
|
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual ~addwriteNowSignalToOpt() = default;
|
||||||
|
|
||||||
|
virtual void readData(Foam::Istream& is)
|
||||||
|
{
|
||||||
|
sigWriteNow::signal_ = readLabel(is);
|
||||||
|
sigWriteNow::set(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void writeData(Foam::Ostream& os) const
|
||||||
|
{
|
||||||
|
os << sigWriteNow::signal_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
addwriteNowSignalToOpt addwriteNowSignalToOpt_("writeNowSignal");
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::sigWriteNow::sigHandler(int)
|
||||||
|
{
|
||||||
|
if (runTimePtr_)
|
||||||
|
{
|
||||||
|
Info<< "sigWriteNow :"
|
||||||
|
<< " setting up write at end of the next iteration" << nl << endl;
|
||||||
|
runTimePtr_->writeOnce();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sigWriteNow::sigWriteNow()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::sigWriteNow::sigWriteNow(Time& runTime, bool verbose)
|
||||||
|
{
|
||||||
|
runTimePtr_ = &runTime; // Store runTime
|
||||||
|
set(verbose);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sigWriteNow::~sigWriteNow()
|
||||||
|
{
|
||||||
|
if (!active())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
resetHandler("writeNow", signal_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::sigWriteNow::active()
|
||||||
|
{
|
||||||
|
return signal_ > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Foam::sigWriteNow::signalNumber()
|
||||||
|
{
|
||||||
|
return signal_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::sigWriteNow::set(bool verbose)
|
||||||
|
{
|
||||||
|
if (!active())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "sigWriteNow :"
|
||||||
|
<< " Enabling writing upon signal " << signal_ << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
setHandler("writeNow", signal_, sigHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
108
src/OSspecific/MSwindows/signals/sigWriteNow.H
Normal file
108
src/OSspecific/MSwindows/signals/sigWriteNow.H
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::sigWriteNow
|
||||||
|
|
||||||
|
Description
|
||||||
|
Signal handler to write once and continue.
|
||||||
|
The interrupt is defined by OptimisationSwitches::writeNowSignal
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
sigWriteNow.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef sigWriteNow_H
|
||||||
|
#define sigWriteNow_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
class Time;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class sigWriteNow Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class sigWriteNow
|
||||||
|
{
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- Signal number to use
|
||||||
|
static int signal_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Handler for caught signals
|
||||||
|
static void sigHandler(int);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Allow setter access to signal_
|
||||||
|
friend class addwriteNowSignalToOpt;
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
sigWriteNow();
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
sigWriteNow(Time& runTime, bool verbose=false);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~sigWriteNow();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Is active?
|
||||||
|
static bool active();
|
||||||
|
|
||||||
|
//- The signal number being used
|
||||||
|
static int signalNumber();
|
||||||
|
|
||||||
|
//- Set/reset signal handler
|
||||||
|
static void set(bool verbose=false);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
77
src/OSspecific/MSwindows/signals/signalMacros.C
Normal file
77
src/OSspecific/MSwindows/signals/signalMacros.C
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011 Symscape
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Description
|
||||||
|
File-local code for setting/resetting signal handlers.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
signalMacros.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "error.H"
|
||||||
|
#include <csignal>
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Saved old signal trapping setting (file-local variable)
|
||||||
|
static __p_sig_fn_t oldAction_ = SIG_DFL;
|
||||||
|
|
||||||
|
|
||||||
|
static void resetHandler(const char *what, int sigNum)
|
||||||
|
{
|
||||||
|
const __p_sig_fn_t prev = ::signal(sigNum, oldAction_);
|
||||||
|
oldAction_ = SIG_DFL;
|
||||||
|
|
||||||
|
if (SIG_ERR == prev)
|
||||||
|
{
|
||||||
|
FatalError
|
||||||
|
<< "Cannot unset " << what << " signal (" << sigNum
|
||||||
|
<< ") trapping" << endl
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void setHandler(const char *what, int sigNum, void (*handler)(int))
|
||||||
|
{
|
||||||
|
oldAction_ = ::signal(sigNum, handler);
|
||||||
|
|
||||||
|
if (SIG_ERR == oldAction_)
|
||||||
|
{
|
||||||
|
FatalError
|
||||||
|
<< "Could not set " << what << " signal (" << sigNum
|
||||||
|
<< ") trapping" << endl
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
156
src/OSspecific/MSwindows/signals/timer.C
Normal file
156
src/OSspecific/MSwindows/signals/timer.C
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2010, 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
| Copyright (C) 2011 Symscape
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "timer.H"
|
||||||
|
#include "error.H"
|
||||||
|
#include "MSwindows.H"
|
||||||
|
#undef DebugInfo // Windows name clash with OpenFOAM messageStream
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#undef WINVER
|
||||||
|
#define WINVER 0x0500 // To access CreateTimerQueueTimer
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
// File-local functions
|
||||||
|
#include "signalMacros.C"
|
||||||
|
|
||||||
|
#define SIGALRM 14
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(timer, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
jmp_buf Foam::timer::envAlarm;
|
||||||
|
|
||||||
|
unsigned int Foam::timer::oldTimeOut_ = 0;
|
||||||
|
|
||||||
|
static HANDLE hTimer_ = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
static VOID CALLBACK timerExpired(PVOID lpParam, BOOLEAN TimerOrWaitFired)
|
||||||
|
{
|
||||||
|
::raise(SIGALRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::timer::sigHandler(int)
|
||||||
|
{
|
||||||
|
DebugInFunction << "Timed out. Jumping." << endl;
|
||||||
|
|
||||||
|
longjmp(envAlarm, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::timer::timer(unsigned int seconds)
|
||||||
|
:
|
||||||
|
timeOut_(seconds)
|
||||||
|
{
|
||||||
|
if (!timeOut_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Singleton since handler is static function
|
||||||
|
if (hTimer_)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "timer already used."
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set alarm signal handler
|
||||||
|
setHandler("SIGALRM", SIGALRM, sigHandler);
|
||||||
|
|
||||||
|
// Set alarm timer
|
||||||
|
const bool ok = ::CreateTimerQueueTimer
|
||||||
|
(
|
||||||
|
&hTimer_,
|
||||||
|
nullptr,
|
||||||
|
static_cast<WAITORTIMERCALLBACK>(timerExpired),
|
||||||
|
nullptr,
|
||||||
|
timeOut_ * 1000,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
hTimer_ = nullptr;
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "CreateTimerQueueTimer, "
|
||||||
|
<< MSwindows::lastError() << nl
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugInFunction
|
||||||
|
<< "Installing timeout " << int(timeOut_) << " seconds"
|
||||||
|
<< " (overriding old timeout " << int(oldTimeOut_) << ")." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::timer::~timer()
|
||||||
|
{
|
||||||
|
if (!timeOut_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugInFunction
|
||||||
|
<< "timeOut=" << int(timeOut_)
|
||||||
|
<< " : resetting timeOut to " << int(oldTimeOut_) << endl;
|
||||||
|
|
||||||
|
// Reset alarm timer
|
||||||
|
const bool ok = ::DeleteTimerQueueTimer(nullptr, hTimer_, nullptr);
|
||||||
|
|
||||||
|
hTimer_ = nullptr;
|
||||||
|
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "DeleteTimerQueueTimer, "
|
||||||
|
<< MSwindows::lastError() << nl
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
resetHandler("SIGALRM", SIGALRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
130
src/OSspecific/MSwindows/signals/timer.H
Normal file
130
src/OSspecific/MSwindows/signals/timer.H
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2011, 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::timer
|
||||||
|
|
||||||
|
Description
|
||||||
|
Implements a timeout mechanism via sigalarm.
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
\code
|
||||||
|
timer myTimer(5); // 5 sec
|
||||||
|
..
|
||||||
|
if (timedOut(myTimer))
|
||||||
|
{
|
||||||
|
// timed out
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// do something possible blocking
|
||||||
|
}
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
Constructor set signal handler on sigalarm and alarm(). Destructor
|
||||||
|
clears these.
|
||||||
|
|
||||||
|
Warning
|
||||||
|
The setjmp restores complete register state so including local vars
|
||||||
|
held in regs. So if in blocking part something gets calced in a stack
|
||||||
|
based variable make sure it is declared 'volatile'.
|
||||||
|
|
||||||
|
Note
|
||||||
|
timedOut is macro because setjmp can't be in member function of timer.
|
||||||
|
?something to do with stack frames.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
timer.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef timer_H
|
||||||
|
#define timer_H
|
||||||
|
|
||||||
|
#include "className.H"
|
||||||
|
#include <csetjmp>
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//- Check if timeout has occurred
|
||||||
|
// keep setjmp in same stack frame so no function calls
|
||||||
|
#define timedOut(x) \
|
||||||
|
((x).timeOut_ ? setjmp(Foam::timer::envAlarm) : false)
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class timer Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class timer
|
||||||
|
{
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- Old alarm() value
|
||||||
|
static unsigned int oldTimeOut_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Alarm handler
|
||||||
|
static void sigHandler(int);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Public Data
|
||||||
|
|
||||||
|
//- Declare name of the class and its debug switch
|
||||||
|
ClassName("timer");
|
||||||
|
|
||||||
|
//- The time-out value (seconds). Needed by macro timedOut
|
||||||
|
unsigned int timeOut_;
|
||||||
|
|
||||||
|
//- State for setjmp. Needed by macro timedOut
|
||||||
|
static jmp_buf envAlarm;
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct with specified time-out, a value of 0 makes it a no-op.
|
||||||
|
timer(unsigned int seconds);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor. Restores the alarm and signal handler as required.
|
||||||
|
~timer();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user