The Gaudi Framework  v40r0 (475e45c1)
System.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #pragma once
12 
13 #include <GaudiKernel/Kernel.h>
14 #include <GaudiKernel/ModuleInfo.h>
15 #include <GaudiKernel/Timing.h>
16 #include <string>
17 #include <typeinfo>
18 #include <vector>
19 
20 #ifdef __linux
21 # include <pthread.h>
22 # ifndef __APPLE__
23 # include <execinfo.h>
24 # endif
25 #endif
26 
35 namespace System {
37  typedef void* ImageHandle;
39  typedef void* ProcessHandle;
41  typedef unsigned long ( *EntryPoint )( const unsigned long iid, void** ppvObject );
43  typedef void* ( *Creator )();
45  GAUDI_API unsigned long loadDynamicLib( const std::string& name, ImageHandle* handle );
47  GAUDI_API unsigned long unloadDynamicLib( ImageHandle handle );
49  GAUDI_API unsigned long getProcedureByName( ImageHandle handle, const std::string& name, EntryPoint* pFunction );
51  GAUDI_API unsigned long getProcedureByName( ImageHandle handle, const std::string& name, Creator* pFunction );
53  GAUDI_API unsigned long getLastError();
55  GAUDI_API const std::string getLastErrorString();
57  GAUDI_API const std::string getErrorString( unsigned long error );
59  GAUDI_API const std::string typeinfoName( const std::type_info& );
60  GAUDI_API const std::string typeinfoName( const char* );
62  GAUDI_API const std::string& hostName();
64  GAUDI_API const std::string& osName();
66  GAUDI_API const std::string& osVersion();
68  GAUDI_API const std::string& machineType();
70  // 0 = 80386 instruction set
71  // 1 or above = SSE (XMM) supported by CPU (not testing for O.S. support)
72  // 2 or above = SSE2
73  // 3 or above = SSE3
74  // 4 or above = Supplementary SSE3 (SSSE3)
75  // 5 or above = SSE4.1
76  // 6 or above = SSE4.2
77  // 7 or above = AVX supported by CPU and operating system
78  // 8 or above = AVX2
79  // 9 or above = AVX512F
82  GAUDI_API const std::string& accountName();
86  GAUDI_API long argc();
88  GAUDI_API const std::vector<std::string> cmdLineArgs();
90  GAUDI_API char** argv();
92  GAUDI_API std::string getEnv( const char* var );
95  GAUDI_API bool getEnv( const char* var, std::string& value );
96  inline bool getEnv( const std::string& var, std::string& value ) { return getEnv( var.c_str(), value ); }
98  GAUDI_API std::vector<std::string> getEnv();
104  GAUDI_API int setEnv( const std::string& name, const std::string& value, int overwrite = 1 );
106  GAUDI_API bool isEnvSet( const char* var );
107 #ifdef __linux
108  typedef pthread_t ThreadHandle;
111  inline ThreadHandle threadSelf() { return pthread_self(); }
112 #else
113  typedef void* ThreadHandle;
116  inline ThreadHandle threadSelf() { return (void*)0; }
117 #endif
118  GAUDI_API int backTrace( void** addresses, const int depth );
119  GAUDI_API bool backTrace( std::string& btrace, const int depth, const int offset = 0 );
120  GAUDI_API bool getStackLevel( void* addresses, void*& addr, std::string& fnc, std::string& lib );
121 } // namespace System
System::getErrorString
GAUDI_API const std::string getErrorString(unsigned long error)
Retrieve error code as string for a given error.
Definition: System.cpp:271
System::loadDynamicLib
GAUDI_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.
Definition: System.cpp:136
System::argc
GAUDI_API long argc()
Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call....
Definition: System.cpp:348
System::getLastError
GAUDI_API unsigned long getLastError()
Get last system known error.
Definition: System.cpp:255
System::EntryPoint
unsigned long(* EntryPoint)(const unsigned long iid, void **ppvObject)
Definition of the "generic" DLL entry point function.
Definition: System.h:41
System::ThreadHandle
void * ThreadHandle
A Thread handle.
Definition: System.h:114
System::getEnv
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:376
System::setEnv
GAUDI_API int setEnv(const std::string &name, const std::string &value, int overwrite=1)
Set an environment variables.
Definition: System.cpp:489
System::instructionsetLevel
GAUDI_API int instructionsetLevel()
Instruction Set "Level".
Definition: System.cpp:329
System::ImageHandle
void * ImageHandle
Definition of an image handle.
Definition: ModuleInfo.h:25
System::getProcedureByName
GAUDI_API unsigned long getProcedureByName(ImageHandle handle, const std::string &name, EntryPoint *pFunction)
Get a specific function defined in the DLL.
Definition: System.cpp:204
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:301
System::getStackLevel
GAUDI_API bool getStackLevel(void *addresses, void *&addr, std::string &fnc, std::string &lib)
System::backTrace
GAUDI_API int backTrace(void **addresses, const int depth)
System::osName
GAUDI_API const std::string & osName()
OS name.
Definition: System.cpp:312
ModuleInfo.h
System::accountName
GAUDI_API const std::string & accountName()
User login name.
Definition: System.cpp:339
System::numCmdLineArgs
GAUDI_API long numCmdLineArgs()
Number of arguments passed to the commandline.
Definition: System.cpp:345
System::isEnvSet
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
Definition: System.cpp:396
Timing.h
System::Creator
void *(* Creator)()
Definition of the "generic" DLL entry point function.
Definition: System.h:43
System::unloadDynamicLib
GAUDI_API unsigned long unloadDynamicLib(ImageHandle handle)
unload dynamic link library
Definition: System.cpp:181
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
System::threadSelf
ThreadHandle threadSelf()
thread handle "accessor"
Definition: System.h:116
System::cmdLineArgs
GAUDI_API const std::vector< std::string > cmdLineArgs()
Command line arguments including executable name as arg[0] as vector of strings.
Definition: System.cpp:351
Kernel.h
System
Note: OS specific details for environment resolution.
Definition: Debugger.h:15
System::machineType
GAUDI_API const std::string & machineType()
Machine type.
Definition: System.cpp:324
System::ProcessHandle
void * ProcessHandle
Definition of the process handle.
Definition: ModuleInfo.h:27
System::hostName
GAUDI_API const std::string & hostName()
Host name.
Definition: System.cpp:306
System::getLastErrorString
GAUDI_API const std::string getLastErrorString()
Get last system error as string.
Definition: System.cpp:265
System::osVersion
GAUDI_API const std::string & osVersion()
OS version.
Definition: System.cpp:318
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:83
System::argv
GAUDI_API char ** argv()
char** command line arguments including executable name as arg[0]; You may not modify them!
Definition: System.cpp:357