Go to the documentation of this file.
48 const string& globalFuncName,
57 if (libs().open(libPath,
false))
59 lib = libs().findLibrary(libPath);
67 loaderFunctionType
function =
68 reinterpret_cast<loaderFunctionType
>
70 dlSym(lib, globalFuncName)
82 ) <<
"Failed looking up symbol " << globalFuncName
91 ) <<
"Failed looking up symbol " << globalFuncName <<
nl
95 if (!libs().close(libPath,
false))
100 ) <<
"Failed unloading library "
116 const string& globalFuncName,
127 lib = libs().findLibrary(libPath);
137 loaderFunctionType
function =
138 reinterpret_cast<loaderFunctionType
>
140 dlSym(lib, globalFuncName)
152 ) <<
"Failed looking up symbol " << globalFuncName <<
nl
157 if (!libs().close(libPath,
false))
162 ) <<
"Failed unloading library " << libPath
178 || (regIOobject::fileModificationSkew <= 0);
186 dynCode.
reset(context);
188 this->prepare(dynCode, context);
195 ) <<
"Failed writing files for" <<
nl
213 if (regIOobject::fileModificationSkew > 0)
223 off_t masterSize = mySize;
224 Pstream::scatter(masterSize);
228 Pout<<
endl<<
"on processor " << Pstream::myProcNo()
229 <<
" have masterSize:" << masterSize
230 <<
" and localSize:" << mySize
235 if (mySize < masterSize)
239 Pout<<
"Local file " << libPath
240 <<
" not of same size (" << mySize
242 << masterSize <<
"). Waiting for "
243 << regIOobject::fileModificationSkew
244 <<
" seconds." <<
endl;
251 if (mySize < masterSize)
256 ) <<
"Cannot read (NFS mounted) library " <<
nl
258 <<
"on processor " << Pstream::myProcNo()
259 <<
" detected size " << mySize
260 <<
" whereas master size is " << masterSize
262 <<
"If your case is not NFS mounted"
263 <<
" (so distributed) set fileModificationSkew"
271 Pout<<
endl<<
"on processor " << Pstream::myProcNo()
272 <<
" after waiting: have masterSize:" << masterSize
273 <<
" and localSize:" << mySize
283 const word& redirectType
288 dynamicCode::checkSecurity
290 "codedBase::updateLibrary()",
300 redirectType + context.
sha1().
str(
true),
307 if (libs().findLibrary(libPath))
312 Info<<
"Using dynamicCode for " << this->description().c_str()
313 <<
" at line " <<
dict.startLineNumber()
318 this->clearRedirect();
324 dynamicCode::libraryBaseName(oldLibPath_),
329 if (!loadLibrary(libPath, dynCode.
codeName(), context.
dict()))
331 createLibrary(dynCode, context);
333 loadLibrary(libPath, dynCode.
codeName(), context.
dict());
337 oldLibPath_ = libPath;
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
void updateLibrary(const word &redirectType) const
Update library as required.
A class for handling words, derived from string.
A class for handling file names.
fileName libPath() const
Library path for specified code name.
bool copyOrCreateFiles(const bool verbose=false) const
Copy/create files prior to compilation.
Tools for handling dynamic code compilation.
void * dlSym(void *handle, const std::string &symbol)
Lookup a symbol in a dlopened library using handle to library.
bool wmakeLibso() const
Compile a libso.
const dictionary & dict() const
Return the parent dictionary context.
Encapsulation of dynamic code dictionaries.
virtual ~codedBase()
Destructor.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool dlSymFound(void *handle, const std::string &symbol)
Report if symbol in a dlopened library could be found.
unsigned int sleep(const unsigned int)
Sleep for the specified number of seconds.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
const word & codeName() const
Return the code-name.
void unloadLibrary(const fileName &libPath, const string &globalFuncName, const dictionary &contextDict) const
Execute globalFuncName(false) and unload specified library.
void * loadLibrary(const fileName &libPath, const string &globalFuncName, const dictionary &contextDict) const
Load specified library and execute globalFuncName(true)
fileName libRelPath() const
Library path for specified code name relative to $FOAM_CASE.
const SHA1Digest & sha1() const
Return SHA1 digest calculated from include, options, code.
A list of keyword definitions, which are a keyword followed by any number of values (e....
errorManipArg< error, int > exit(error &err, const int errNo=1)
void reset(const dynamicCodeContext &)
Clear files and reset variables to specified context.
bool upToDate(const dynamicCodeContext &context) const
Verify if the copied code is up-to-date, based on Make/SHA1Digest.
prefixOSstream Pout(cout, "Pout")
codedBase()
Construct null.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
void createLibrary(dynamicCode &, const dynamicCodeContext &) const
Create library based on the dynamicCodeContext.
defineTypeNameAndDebug(combustionModel, 0)
off_t fileSize(const fileName &)
Return size of file.
std::string str(const bool prefixed=false) const
Return (40-byte) text representation, optionally with '_' prefix.