![]() |
|
|
Generated: 18 Jul 2008 |
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include "GaudiKernel/System.h"
#include <errno.h>
#include <string.h>
#include "sys/times.h"
#include "unistd.h"
#include "libgen.h"
#include <cstdio>
#include <cxxabi.h>
Include dependency graph for System.cpp:

Go to the source code of this file.
Defines | |
| #define | SYSTEM_SYSTEM_CPP |
| #define | __attribute__(x) |
Functions | |
| static unsigned long | doLoad (const std::string &name, System::ImageHandle *handle) |
| static unsigned long | loadWithoutEnvironment (const std::string &name, System::ImageHandle *handle) |
| unsigned long | System::loadDynamicLib (const std::string &name, ImageHandle *handle) |
| Load dynamic link library. | |
| unsigned long | System::unloadDynamicLib (ImageHandle handle) |
| unload dynamic link library | |
| unsigned long | System::getProcedureByName (ImageHandle handle, const std::string &name, EntryPoint *pFunction) |
| Get a specific function defined in the DLL. | |
| unsigned long | System::getProcedureByName (ImageHandle handle, const std::string &name, Creator *pFunction) |
| Get a specific function defined in the DLL. | |
| unsigned long | System::getLastError () |
| Get last system known error. | |
| const std::string | System::getLastErrorString () |
| Get last system error as string. | |
| const std::string | System::getErrorString (unsigned long error) |
| Retrieve error code as string for a given error. | |
| std::string | __typeName (char *&name) |
| std::string | __className (char *&name) |
| const std::string | System::typeinfoName (const std::type_info &tinfo) |
| Get platform independent information about the class type. | |
| const std::string | System::typeinfoName (const char *class_name) |
| const std::string & | System::hostName () |
| Host name. | |
| const std::string & | System::osName () |
| OS name. | |
| const std::string & | System::osVersion () |
| OS version. | |
| const std::string & | System::machineType () |
| Machine type. | |
| const std::string & | System::accountName () |
| User login name. | |
| long | System::numCmdLineArgs () |
| Number of arguments passed to the commandline. | |
| long | System::argc () |
| Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call... | |
| const std::vector< std::string > | System::cmdLineArgs () |
| Command line arguments including executable name as arg[0] as vector of strings. | |
| char ** | System::argv () |
| char** command line arguments including executable name as arg[0]; You may not modify them! | |
| const std::string | System::getEnv (const char *var) |
| get a particular environment variable | |
| const std::vector< std::string > | System::getEnv () |
| get all environment variables | |
| bool | System::backTrace (void **addresses __attribute__((unused)), const size_t depth __attribute__((unused))) |
| bool | System::getStackLevel (void *addresses __attribute__((unused)), void *&addr __attribute__((unused)), std::string &fnc __attribute__((unused)), std::string &lib __attribute__((unused))) |
| int | System::setEnv (const std::string &name, const std::string &value, int overwrite) |
| Set an environment variables. | |
Variables | |
| static const char * | SHLIB_SUFFIX = ".so" |
| static std::vector< std::string > | s_argvStrings |
| static std::vector< const char * > | s_argvChars |
| return | |
| #define __attribute__ | ( | x | ) |
Definition at line 67 of file System.cpp.
| #define SYSTEM_SYSTEM_CPP |
Definition at line 14 of file System.cpp.
| std::string __className | ( | char *& | name | ) |
Definition at line 291 of file System.cpp.
References __typeName(), and std::basic_string< _CharT, _Traits, _Alloc >::append().
Referenced by __typeName().
00291 { 00292 std::string result; 00293 int j = 0, k, i; 00294 if ( 't' == *name ) { 00295 goto Template; 00296 } 00297 for ( i = ::strtol(name, &name, 10); i > 0; i = ::strtol(name, &name, 10) ) { 00298 if ( j++ != 0 ) result.append("::",2); 00299 result.append(name, i); 00300 if ( *(name+=i) == 't' ) { 00301 result.append("::",2); 00302 Template: 00303 result.append(name, (i=::strtol(++name, &name, 10))); 00304 result.append("<"); 00305 for (k = 0, i=::strtol(name+i, &name, 10); k < i; k++ ) { 00306 result += __typeName( ++name ); 00307 if ( k+1 < i ) result += ","; 00308 } 00309 result.append(">"); 00310 } 00311 } 00312 return result; 00313 }
| std::string __typeName | ( | char *& | name | ) |
Definition at line 315 of file System.cpp.
References __className().
Referenced by __className().
00315 { 00316 if ( *name == 'Q' ) { // Handle name spaces 00317 if ( *(++name) == '_' ) // >= 10 nested name spaces 00318 ::strtol(++name, &name, 10); // type Q_##_... 00319 return __className(++name); 00320 } 00321 else if ( 't' == *name ) { 00322 return __className(name); 00323 } 00324 else { 00325 std::string result; 00326 char* ptr; 00327 int i = ::strtol(name, &ptr, 10); 00328 if ( i <= 0 ) { 00329 name = ptr; 00330 while ( *name != 0 && *name != 'Z' ) { 00331 if ( *name == 'U' ) { 00332 result += "unsigned "; 00333 name++; 00334 } 00335 switch( *name++ ) { 00336 case 'c': result += "char"; break; 00337 case 's': result += "short"; break; 00338 case 'i': result += "int"; break; 00339 case 'l': result += "long"; break; 00340 case 'f': result += "float"; break; 00341 case 'd': result += "double"; break; 00342 default: result += *(name-1); 00343 } 00344 } 00345 return result; 00346 } 00347 else { 00348 return __className(name); 00349 } 00350 } 00351 }
| static unsigned long doLoad | ( | const std::string & | name, | |
| System::ImageHandle * | handle | |||
| ) | [static] |
Definition at line 73 of file System.cpp.
References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), std::cout, std::endl(), System::exeName(), System::getLastError(), std::basic_string< _CharT, _Traits, _Alloc >::length(), name, and Gaudi::Utils::Histos::path().
Referenced by loadWithoutEnvironment().
00073 { 00074 #ifdef _WIN32 00075 void* mh = ::LoadLibrary( name.length() == 0 ? System::exeName().c_str() : name.c_str()); 00076 *handle = mh; 00077 #else 00078 const char* path = name.c_str(); 00079 #if defined(linux) || defined(__APPLE__) 00080 void *mh = ::dlopen(name.length() == 0 ? 0 : path, RTLD_LAZY | RTLD_GLOBAL); 00081 *handle = mh; 00082 #elif __hpux 00083 shl_t mh = ::shl_load(name.length() == 0 ? 0 : path, BIND_IMMEDIATE | BIND_VERBOSE, 0); 00084 HMODULE* mod = new HMODULE; 00085 if ( 0 != mh ) { 00086 if ( 0 != ::shl_gethandle_r(mh, &mod->dsc) ) { 00087 std::cout << "System::loadDynamicLib>" << ::strerror(getLastError()) << std::endl; 00088 } 00089 else { 00090 typedef void* (*___all)(); 00091 ___all _alloc = (___all)malloc; 00092 mod->numSym = ::shl_getsymbols(mod->dsc.handle, TYPE_PROCEDURE, EXPORT_SYMBOLS, malloc, &mod->sym); 00093 *handle = mod; 00094 } 00095 } 00096 #endif 00097 #endif 00098 if ( 0 == *handle ) { 00099 return System::getLastError(); 00100 } 00101 return 1; 00102 }
| static unsigned long loadWithoutEnvironment | ( | const std::string & | name, | |
| System::ImageHandle * | handle | |||
| ) | [static] |
Definition at line 104 of file System.cpp.
References std::basic_string< _CharT, _Traits, _Alloc >::data(), dllName, doLoad(), std::basic_string< _CharT, _Traits, _Alloc >::length(), name, and SHLIB_SUFFIX.
Referenced by System::loadDynamicLib().
00104 { 00105 00106 std::string dllName = name; 00107 long len = strlen(SHLIB_SUFFIX); 00108 00109 // Add the suffix at the end of the library name only if necessary 00110 // FIXME: cure the logic 00111 if ((dllName.length() != 0) && 00112 ::strncasecmp(dllName.data()+dllName.length()-len, SHLIB_SUFFIX, len) != 0) { 00113 dllName += SHLIB_SUFFIX; 00114 } 00115 00116 // Load the library 00117 return doLoad(dllName, handle); 00118 }
Definition at line 174 of file System.cpp.
Referenced by GFALDataStreamTool::addBlock(), JobOptionsSvc::dump(), ServiceManager::getFactory(), DataOnDemandSvc::handle(), TimingAuditor::i_afterExecute(), TimingAuditor::i_afterInitialize(), TimingAuditor::i_beforeExecute(), TimingAuditor::i_beforeInitialize(), Genfun::GaudiMathImplementation::SplineBase::initialize(), Gaudi::Parsers::Parser::setIsPrint(), GFALStageBlock::updateFillStatus(), GFALStageBlock::updateStatus(), Property::useReadHandler(), and Property::useUpdateHandler().
std::vector<const char*> s_argvChars [static] |
std::vector<std::string> s_argvStrings [static] |
const char* SHLIB_SUFFIX = ".so" [static] |
Definition at line 35 of file System.cpp.
Referenced by System::loadDynamicLib(), and loadWithoutEnvironment().