25#include <sys/utsname.h>
108 errno =
static_cast<int>(0xAFFEDEAD);
125#if defined(__linux__)
128 errno =
static_cast<int>(0xAFFEDEAD);
131#elif defined(__APPLE__)
135 string sname =
"_" + name;
139 errno =
static_cast<int>(0xAFFEDEAD);
155 return static_cast<unsigned long>(
static_cast<unsigned int>(
errno));
169 if (error == 0xAFFEDEAD) {
175 cerrString =
const_cast<char*
>(
"Unknown error. No information found in strerror()!");
218 result =
"unsigned short";
236 result =
"unsigned long long";
242 result =
"unsigned __int128";
268 string::size_type
pos =
result.find(
", ");
269 while (string::npos !=
pos) {
270 result.replace(
pos,
static_cast<string::size_type
>(2),
",");
279 static string host{};
290 static string osname =
"";
302 static string osver =
"UNKNOWN";
314 static string mach =
"UNKNOWN";
338 char* env = ::getenv(
var.c_str());
339 if (env !=
nullptr) {
353#if defined(__APPLE__)
355#include "crt_externs.h"
358#if defined(__APPLE__)
380 return ::unsetenv(name.
c_str());
433 const char*
symbol = info.dli_sname && info.dli_sname[0] !=
'\0' ? info.dli_sname : 0;
435 lib = info.dli_fname;
436 addr = info.dli_saddr;
defines a Small helper function that allows the cast from void * to function pointer
OS specific details to access at run-time the module configuration of the process.
This file is intended to iron out all the differences between systems (currently Linux and MacOSX)
Macro to silence unused variables warnings from the compiler.
T emplace_back(T... args)
unsigned long(*)(const unsigned long iid, void **ppvObject) EntryPoint
Definition of the "generic" DLL entry point function.
ELEMENTS_API bool isEnvSet(const std::string &var)
Check if an environment variable is set or not.
const std::string SHLIB_SUFFIX
alias for LIB_SUFFIX
ELEMENTS_API const std::string getErrorString(unsigned long error)
Retrieve error code as string for a given error.
ELEMENTS_API int setEnv(const std::string &name, const std::string &value, bool overwrite=true)
set an environment variables.
ELEMENTS_API bool getStackLevel(ELEMENTS_UNUSED void *addresses, ELEMENTS_UNUSED void *&addr, ELEMENTS_UNUSED std::string &fnc, ELEMENTS_UNUSED std::string &lib)
ELEMENTS_API unsigned long unloadDynamicLib(ImageHandle handle)
unload dynamic link library
ELEMENTS_API int backTrace(ELEMENTS_UNUSED std::shared_ptr< void * > addresses, ELEMENTS_UNUSED const int depth)
ELEMENTS_API std::vector< std::string > getEnv()
get all environment variables
void * ImageHandle
Definition of an image handle.
ELEMENTS_API unsigned long getLastError()
Get last system known error.
ELEMENTS_API const std::string & osName()
OS name.
ELEMENTS_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.
ELEMENTS_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
ELEMENTS_API int unSetEnv(const std::string &name)
Simple wrap around unsetenv for strings.
ELEMENTS_API unsigned long getProcedureByName(ImageHandle handle, const std::string &name, EntryPoint *pFunction)
Get a specific function defined in the DLL.
ELEMENTS_API const std::string & osVersion()
OS version.
ELEMENTS_API const std::string getLastErrorString()
Get last system error as string.
ELEMENTS_API const std::string & machineType()
Machine type.
void *(*)() Creator
Definition of the "generic" DLL entry point function.
ELEMENTS_API const std::string & hostName()
Host name.