All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
System.h
Go to the documentation of this file.
1 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/GaudiKernel/System.h,v 1.17 2008/10/28 10:40:19 marcocle Exp $
2 #ifndef GAUDIKERNEL_SYSTEM_H
3 #define GAUDIKERNEL_SYSTEM_H
4 
5 // Framework include files
6 #include "GaudiKernel/Kernel.h"
7 // STL include files
8 #include <string>
9 #include <vector>
10 #include <typeinfo>
11 
12 #include "GaudiKernel/Timing.h"
13 #include "GaudiKernel/ModuleInfo.h"
14 
15 #ifdef __linux
16 # include <pthread.h>
17 #ifndef __APPLE__
18 # include <execinfo.h>
19 #endif
20 #endif
21 
30 namespace System {
32  typedef void* ImageHandle;
34  typedef void* ProcessHandle;
36  typedef unsigned long (*EntryPoint)(const unsigned long iid, void** ppvObject);
38  typedef void* (*Creator)();
40  GAUDI_API unsigned long loadDynamicLib(const std::string& name, ImageHandle* handle);
42  GAUDI_API unsigned long unloadDynamicLib(ImageHandle handle);
44  GAUDI_API unsigned long getProcedureByName(ImageHandle handle, const std::string& name, EntryPoint* pFunction);
46  GAUDI_API unsigned long getProcedureByName(ImageHandle handle, const std::string& name, Creator* pFunction);
48  GAUDI_API unsigned long getLastError();
50  GAUDI_API const std::string getLastErrorString();
52  GAUDI_API const std::string getErrorString(unsigned long error);
54  GAUDI_API const std::string typeinfoName( const std::type_info& );
55  GAUDI_API const std::string typeinfoName( const char* );
57  GAUDI_API const std::string& hostName();
59  GAUDI_API const std::string& osName();
61  GAUDI_API const std::string& osVersion();
63  GAUDI_API const std::string& machineType();
65  // 0 = 80386 instruction set
66  // 1 or above = SSE (XMM) supported by CPU (not testing for O.S. support)
67  // 2 or above = SSE2
68  // 3 or above = SSE3
69  // 4 or above = Supplementary SSE3 (SSSE3)
70  // 5 or above = SSE4.1
71  // 6 or above = SSE4.2
72  // 7 or above = AVX supported by CPU and operating system
73  // 8 or above = AVX2
74  // 9 or above = AVX512F
77  GAUDI_API const std::string& accountName();
81  GAUDI_API long argc();
83  GAUDI_API const std::vector<std::string> cmdLineArgs();
85  GAUDI_API char** argv();
87  GAUDI_API std::string getEnv(const char* var);
90  GAUDI_API bool getEnv(const char* var, std::string &value);
91  inline bool getEnv(const std::string &var, std::string &value) {
92  return getEnv(var.c_str(), value);
93  }
95  GAUDI_API std::vector<std::string> getEnv();
101  GAUDI_API int setEnv(const std::string &name, const std::string &value, int overwrite = 1);
103  GAUDI_API bool isEnvSet(const char* var);
104 #ifdef __linux
105 
106  typedef pthread_t ThreadHandle;
108  inline ThreadHandle threadSelf() { return pthread_self(); }
109 #else
110 
111  typedef void* ThreadHandle;
113  inline ThreadHandle threadSelf() { return (void*)0; }
114 #endif
115  GAUDI_API int backTrace(void** addresses, const int depth);
116  GAUDI_API bool backTrace(std::string& btrace, const int depth, const int offset = 0);
117  GAUDI_API bool getStackLevel(void* addresses, void*& addr, std::string& fnc, std::string& lib) ;
118 
119 #if __GNUC__ >= 4
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
130 
131 
132  template <typename DESTPTR, typename SRCPTR>
133  inline DESTPTR FuncPtrCast(SRCPTR ptr) {
134  union {
135  SRCPTR src;
136  DESTPTR dst;
137  } p2p;
138  p2p.src = ptr;
139  return p2p.dst;
140  }
141 #endif
142 }
143 #endif // SYSTEM_SYSTEM_H