The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
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>
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
35namespace 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
80 [[deprecated]] GAUDI_API int instructionsetLevel();
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
109 typedef pthread_t ThreadHandle;
111 inline ThreadHandle threadSelf() { return pthread_self(); }
112#else
114 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
#define GAUDI_API
Definition Kernel.h:49
Note: OS specific details for environment resolution.
Definition Environment.h:25
GAUDI_API bool getStackLevel(void *addresses, void *&addr, std::string &fnc, std::string &lib)
Definition System.cpp:408
GAUDI_API const std::string & osName()
OS name.
Definition System.cpp:271
GAUDI_API int backTrace(void **addresses, const int depth)
Definition System.cpp:372
void *(* Creator)()
Definition of the "generic" DLL entry point function.
Definition System.h:43
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
Definition System.cpp:349
unsigned long(* EntryPoint)(const unsigned long iid, void **ppvObject)
Definition of the "generic" DLL entry point function.
Definition System.h:41
GAUDI_API const std::string & machineType()
Machine type.
Definition System.cpp:283
GAUDI_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.
Definition System.cpp:115
ThreadHandle threadSelf()
thread handle "accessor"
Definition System.h:116
GAUDI_API long numCmdLineArgs()
Number of arguments passed to the commandline.
Definition System.cpp:304
GAUDI_API const std::string getLastErrorString()
Get last system error as string.
Definition System.cpp:234
GAUDI_API unsigned long unloadDynamicLib(ImageHandle handle)
unload dynamic link library
Definition System.cpp:160
GAUDI_API unsigned long getProcedureByName(ImageHandle handle, const std::string &name, EntryPoint *pFunction)
Get a specific function defined in the DLL.
Definition System.cpp:181
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:260
void * ImageHandle
Definition of an image handle.
Definition ModuleInfo.h:25
GAUDI_API std::vector< std::string > getEnv()
get all environment variables
Definition System.cpp:356
GAUDI_API const std::string & hostName()
Host name.
Definition System.cpp:265
GAUDI_API const std::string & accountName()
User login name.
Definition System.cpp:298
GAUDI_API unsigned long getLastError()
Get last system known error.
Definition System.cpp:228
GAUDI_API long argc()
Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call....
Definition System.cpp:307
void * ProcessHandle
Definition of the process handle.
Definition ModuleInfo.h:27
GAUDI_API const std::string getErrorString(unsigned long error)
Retrieve error code as string for a given error.
Definition System.cpp:240
GAUDI_API const std::vector< std::string > cmdLineArgs()
Command line arguments including executable name as arg[0] as vector of strings.
Definition System.cpp:310
GAUDI_API int setEnv(const std::string &name, const std::string &value, int overwrite=1)
Set an environment variables.
Definition System.cpp:440
void * ThreadHandle
A Thread handle.
Definition System.h:114
GAUDI_API char ** argv()
char** command line arguments including executable name as arg[0]; You may not modify them!
Definition System.cpp:316
GAUDI_API const std::string & osVersion()
OS version.
Definition System.cpp:277
GAUDI_API int instructionsetLevel()
Instruction Set "Level".
Definition System.cpp:288