The Gaudi Framework  master (cc9a61f4)
Loading...
Searching...
No Matches
System Namespace Reference

Note: OS specific details for environment resolution. More...

Namespaces

namespace  Linux
 Namespace holding Linux specific functions.
namespace  MacOS
 Namespace holding MacOS specific functions.
namespace  Detail

Classes

class  PathResolver
class  ProcessTime
 Simple class to hold the time information of a process. More...
struct  PROCESS_BASIC_INFORMATION
struct  QUOTA_LIMITS
 Process Quotas NtQueryInformationProcess using ProcessQuotaLimits NtQueryInformationProcess using ProcessPooledQuotaLimits NtSetInformationProcess using ProcessQuotaLimits. More...
struct  IO_COUNTERS
 Process I/O Counters NtQueryInformationProcess using ProcessIoCounters. More...
struct  VM_COUNTERS
 Process Virtual Memory Counters NtQueryInformationProcess using ProcessVmCounters. More...
struct  POOLED_USAGE_AND_LIMITS
 Process Pooled Quota Usage and Limits NtQueryInformationProcess using ProcessPooledUsageAndLimits. More...
struct  KERNEL_USER_TIMES
 Process/Thread System and User Time NtQueryInformationProcess using ProcessTimes NtQueryInformationThread using ThreadTimes. More...
class  ProcessDescriptor
 Provides access to process information. More...

Typedefs

typedef void * ImageHandle
 Definition of an image handle.
typedef void * ProcessHandle
 Definition of the process handle.
typedef unsigned long(* EntryPoint) (const unsigned long iid, void **ppvObject)
 Definition of the "generic" DLL entry point function.
typedef void *(* Creator) ()
 Definition of the "generic" DLL entry point function.
typedef void * ThreadHandle
 A Thread handle.
typedef struct _PEB * PPEB
 Basic Process Information NtQueryInformationProcess using ProcessBasicInfo.

Enumerations

enum  MemoryUnit {
  Byte , kByte , MByte , GByte ,
  TByte , PByte , EByte
}
 Unit of memory. More...
enum  ModuleType { UNKNOWN , SHAREDLIB , EXECUTABLE }
enum  InfoType {
  NoFetch , RemainTime , Times , ProcessBasics ,
  PriorityBoost , Memory , Quota , System ,
  Modules , IO
}
 Enumeration for fetching information. More...
enum  TimeType {
  Year , Month , Day , Hour ,
  Min , Sec , milliSec , microSec ,
  nanoSec , Native
}
 Time type for conversion. More...
enum  PR_file_type { PR_regular_file , PR_directory }
enum  PR_search_type { PR_local , PR_recursive }
enum  ProcessInfoCommand {
  ProcessBasicInformation , ProcessQuotaLimits , ProcessIoCounters , ProcessVmCounters ,
  ProcessTimes , ProcessBasePriority , ProcessRaisePriority , ProcessDebugPort ,
  ProcessExceptionPort , ProcessAccessToken , ProcessLdtInformation , ProcessLdtSize ,
  ProcessDefaultHardErrorMode , ProcessIoPortHandlers , ProcessPooledUsageAndLimits , ProcessWorkingSetWatch ,
  ProcessUserModeIOPL , ProcessEnableAlignmentFaultFixup , ProcessPriorityClass , ProcessWx86Information ,
  ProcessHandleCount , ProcessAffinityMask , ProcessPriorityBoost , MaxProcessInfoClass ,
  ProcessEllapsedTime
}

Functions

GAUDI_API std::string homeDirectory ()
GAUDI_API std::string tempDirectory ()
GAUDI_API StatusCode resolveEnv (const std::string &var, std::string &res, int recusions=124)
GAUDI_API long adjustMemory (MemoryUnit typ, long value)
 Convert time from kByte to requested representation (Experts only).
GAUDI_API long procID ()
 Basic Process Information: Process ID.
GAUDI_API long parentID (InfoType fetch=ProcessBasics, long pid=-1)
 Basic Process Information: Parent's process ID.
GAUDI_API long affinityMask (InfoType fetch=ProcessBasics, long pid=-1)
 Basic Process Information: Affinity mask.
GAUDI_API long exitStatus (InfoType fetch=ProcessBasics, long pid=-1)
 Basic Process Information: Exit status (does not really make sense for the running process, but for others!).
GAUDI_API long basePriority (InfoType fetch=ProcessBasics, long pid=-1)
 Basic Process Information: Base priority.
GAUDI_API long priorityBoost (InfoType fetch=PriorityBoost, long pid=-1)
 Basic Process Information: priority boost.
GAUDI_API long numPageFault (InfoType fetch=Memory, long pid=-1)
 Basic Process Information: Number of page faults.
GAUDI_API long pagefileUsage (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: Current page file usage.
GAUDI_API long pagefileUsagePeak (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: Peak usage of page file.
GAUDI_API long pagefileUsageLimit (MemoryUnit unit=kByte, InfoType fetch=Quota, long pid=-1)
 Basic Process Information: Peak usage of page file.
GAUDI_API long nonPagedMemory (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: Current usage of non paged memory.
GAUDI_API long nonPagedMemoryPeak (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: Peak usage of non paged memory.
GAUDI_API long nonPagedMemoryLimit (MemoryUnit unit=kByte, InfoType fetch=Quota, long pid=-1)
 System Process Limits: Maximum amount of non-paged memory this process is allowed to use.
GAUDI_API long pagedMemory (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: Amount of paged memory currently occupied by the process 'pid'.
GAUDI_API long pagedMemoryPeak (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: Maximum of paged memory occupied by the process 'pid'.
GAUDI_API long pagedMemoryLimit (MemoryUnit unit=kByte, InfoType fetch=Quota, long pid=-1)
 Basic Process Information: Amount of paged memory that can be occupied by the process 'pid'.
GAUDI_API long minMemoryLimit (MemoryUnit unit=kByte, InfoType fetch=Quota, long pid=-1)
 System Process Limits: Minimum amount of virtual memory this process may use.
GAUDI_API long maxMemoryLimit (MemoryUnit unit=kByte, InfoType fetch=Quota, long pid=-1)
 System Process Limits: Maximum amount of virtual memory this process is allowed to use.
GAUDI_API long mappedMemory (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: priority boost.
GAUDI_API long mappedMemoryPeak (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: priority boost.
GAUDI_API long virtualMemory (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: priority boost.
GAUDI_API long virtualMemoryPeak (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: priority boost.
GAUDI_API long virtualMemoryLimit (MemoryUnit unit=kByte, InfoType fetch=Quota, long pid=-1)
 System Process Limits: Maximum amount of the page file this process is allowed to use.
GAUDI_API const std::string & moduleName ()
 Get the name of the (executable/DLL) file without file-type.
GAUDI_API const std::string & moduleNameFull ()
 Get the full name of the (executable/DLL) file.
GAUDI_API ModuleType moduleType ()
 Get type of the module.
GAUDI_API ProcessHandle processHandle ()
 Handle to running process.
GAUDI_API ImageHandle moduleHandle ()
 Handle to currently executed module.
GAUDI_API ImageHandle exeHandle ()
 Handle to the executable file running.
GAUDI_API const std::string & exeName ()
 Name of the executable file running.
GAUDI_API const std::vector< std::string > linkedModules ()
 Vector of names of linked modules.
GAUDI_API void setModuleHandle (ImageHandle handle)
 Attach module handle.
GAUDI_API std::string PathResolverFindXMLFile (const std::string &logical_file_name)
GAUDI_API std::string PathResolverFindDataFile (const std::string &logical_file_name)
GAUDI_API unsigned long loadDynamicLib (const std::string &name, ImageHandle *handle)
 Load dynamic link library.
GAUDI_API unsigned long unloadDynamicLib (ImageHandle handle)
 unload dynamic link library
GAUDI_API unsigned long getProcedureByName (ImageHandle handle, const std::string &name, EntryPoint *pFunction)
 Get a specific function defined in the DLL.
GAUDI_API unsigned long getProcedureByName (ImageHandle handle, const std::string &name, Creator *pFunction)
 Get a specific function defined in the DLL.
GAUDI_API unsigned long getLastError ()
 Get last system known error.
GAUDI_API const std::string getLastErrorString ()
 Get last system error as string.
GAUDI_API const std::string getErrorString (unsigned long error)
 Retrieve error code as string for a given error.
GAUDI_API const std::string typeinfoName (const std::type_info &)
 Get platform independent information about the class type.
GAUDI_API const std::string typeinfoName (const char *)
GAUDI_API const std::string & hostName ()
 Host name.
GAUDI_API const std::string & osName ()
 OS name.
GAUDI_API const std::string & osVersion ()
 OS version.
GAUDI_API const std::string & machineType ()
 Machine type.
GAUDI_API const std::string & accountName ()
 User login name.
GAUDI_API long numCmdLineArgs ()
 Number of arguments passed to the commandline.
GAUDI_API long argc ()
 Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call...
GAUDI_API const std::vector< std::string > cmdLineArgs ()
 Command line arguments including executable name as arg[0] as vector of strings.
GAUDI_API char ** argv ()
 char** command line arguments including executable name as arg[0]; You may not modify them!
GAUDI_API std::string getEnv (const char *var)
 get a particular environment variable (returning "UNKNOWN" if not set)
GAUDI_API bool getEnv (const char *var, std::string &value)
 get a particular environment variable, storing the value in the passed string if the variable is set.
bool getEnv (const std::string &var, std::string &value)
GAUDI_API std::vector< std::string > getEnv ()
 get all environment variables
GAUDI_API int setEnv (const std::string &name, const std::string &value, int overwrite=1)
 Set an environment variables.
GAUDI_API bool isEnvSet (const char *var)
 Check if an environment variable is set or not.
ThreadHandle threadSelf ()
 thread handle "accessor"
GAUDI_API int backTrace (void **addresses, const int depth)
GAUDI_API bool backTrace (std::string &btrace, const int depth, const int offset=0)
GAUDI_API bool getStackLevel (void *addresses, void *&addr, std::string &fnc, std::string &lib)
GAUDI_API long long adjustTime (TimeType typ, long long timevalue)
 Convert time from OS native time to requested representation (Experts only).
template<TimeType T>
long long adjustTime (long long timevalue)
 Convert the time from OS native time to requested representation (Experts only).
GAUDI_API long long ellapsedTime (TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
 Elapsed time since start of process in milliseconds.
GAUDI_API long long kernelTime (TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
 CPU kernel mode time of process in milliseconds.
GAUDI_API long long userTime (TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
 CPU user mode time of process in milliseconds.
GAUDI_API long long cpuTime (TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
 Consumed CPU time of process in milliseconds.
GAUDI_API long long remainingTime (TimeType typ=milliSec, InfoType fetch=Quota, long pid=-1)
 Maximum processing time left for this process.
GAUDI_API long long creationTime (TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
 Process Creation time.
GAUDI_API long long systemStart (TimeType typ=Sec)
 Maximum processing time left for this process.
GAUDI_API long long upTime (TimeType typ=Hour)
 Maximum processing time left for this process.
template<TimeType T>
GAUDI_API long long currentTime ()
 Retrieve absolute system time.
GAUDI_API long long currentTime (TimeType typ=milliSec)
 Get current time in specificed units.
GAUDI_API long long tickCount ()
 Retrieve the number of ticks since system startup.
GAUDI_API ProcessTime getProcessTime (long pid=-1)
 Retrieve the process time data for a process.
template<>
long long adjustTime< Year > (long long t)
template<>
long long adjustTime< Day > (long long t)
template<>
long long adjustTime< Hour > (long long t)
template<>
long long adjustTime< Min > (long long t)
template<>
long long adjustTime< Sec > (long long t)
template<>
long long adjustTime< milliSec > (long long t)
template<>
long long adjustTime< microSec > (long long t)
template<>
long long adjustTime< nanoSec > (long long t)
template<>
long long adjustTime< Month > (long long t)
template<>
long long adjustTime< Native > (long long t)
template<TimeType T>
long long currentTime ()
 Retrieve absolute system time.
template long long currentTime< Year > ()
template long long currentTime< Month > ()
template long long currentTime< Day > ()
template long long currentTime< Hour > ()
template long long currentTime< Min > ()
template long long currentTime< Sec > ()
template long long currentTime< milliSec > ()
template long long currentTime< microSec > ()
template long long currentTime< nanoSec > ()
template long long currentTime< Native > ()
ProcessDescriptorgetProcess ()
 Retrieve Process structure.

Detailed Description

Note: OS specific details for environment resolution.

Note: OS specific details for process timing.

Note: OS specific details as well as Gaudi details may not occur in this definition file, because this header is the used by both, the OS specific implementations and the gaudi specific implementation.

ModuleInfo: OS specific details to access at run-time the module configuration of the process.

Note: OS specific details for memory usage.

Entrypoints:

Author
: M.Frank
Version
: 1.0

Entrypoints:

  • basePriority Base priority
  • procID Process ID
  • parentID Parent's process ID
  • affinityMask Affinity mask
  • exitStatus Exit status
  • priorityBoost Priority boost
  • numPageFault Number of page faults
  • pagefileUsage Current page file usage
  • pagefileUsagePeak Peak usage of page file
  • nonPagedMemory Current usage of non paged memory
  • nonPagedMemoryPeak Peak usage of non paged memory
  • nonPagedMemoryLimit Maximum amount of non-paged memory this process is allowed to use
  • pagedMemory Amount of paged memory currently occupied
  • pagedMemoryPeak Maximum of paged memory occupied by the process
  • pagedMemoryLimit paged memory that can be occupied by the process
  • memorySize Size of currently occupied memory
  • memorySizePeak Maximum memory occupied by the process
  • memoryLimit Amount of memory that can be occupied by the process
  • virtualMemorySize Virtual memory size currenly occupied
  • peakVirtualMemorySize Maximum amount of virtual memory occupied
  • virtualMemoryLimit Amount of virtual memory that can be occupied by the process
  • minMemoryLimit Minimum amount of virtual memory this process may use
  • maxMemoryLimit Maximum amount of virtual memory this process is allowed to use
  • mappedMemorySize Currenly mapped virtual memory size
  • mappedMemorySizePeak Peak mapped virtual memory size
Author
: M.Frank
Version
: 1.0

M.Frank

Since e.g. IID is defined in both, this would lead automatically to complete comilation failures.....

Author
M.Frank

Entrypoints:

  • remainingTime returns the time the process could still execute
  • ellapsedTime: returns elapsed time since program start
  • kernelTime: returns the amount of time the process has spent in kernel mode
  • userTime: returns the amount of time the process has spent in user mode
  • cpuTime: returns kernel+user time

On Unix time is expressed as the amount of time that has elapsed since midnight on January 1, 1970 at Greenwich, England.

History :

+---------+----------------------------------------------+--------+
|    Date |                 Comment                      | Who    |
+---------+----------------------------------------------+--------+
| 11/11/00| Initial version.                             | MF     |
+---------+----------------------------------------------+--------+
Author
: M.Frank
Version
: 1.0

Typedef Documentation

◆ Creator

typedef void *(* System::Creator) ()

Definition of the "generic" DLL entry point function.

Definition at line 43 of file System.h.

◆ EntryPoint

typedef unsigned long(* System::EntryPoint) (const unsigned long iid, void **ppvObject)

Definition of the "generic" DLL entry point function.

Definition at line 41 of file System.h.

◆ ImageHandle

typedef void * System::ImageHandle

Definition of an image handle.

Definition at line 25 of file ModuleInfo.h.

◆ PPEB

typedef struct _PEB* System::PPEB

Basic Process Information NtQueryInformationProcess using ProcessBasicInfo.

Definition at line 26 of file ProcessDescriptor.h.

◆ ProcessHandle

typedef void * System::ProcessHandle

Definition of the process handle.

Definition at line 27 of file ModuleInfo.h.

◆ ThreadHandle

typedef void* System::ThreadHandle

A Thread handle.

Definition at line 102 of file System.h.

Enumeration Type Documentation

◆ InfoType

Enumeration for fetching information.

Enumerator
NoFetch 
RemainTime 
Times 
ProcessBasics 
PriorityBoost 
Memory 
Quota 
System 
Modules 
IO 

Definition at line 15 of file SystemBase.h.

Note: OS specific details for environment resolution.
Definition Environment.h:25
@ NoFetch
Definition SystemBase.h:15
@ PriorityBoost
Definition SystemBase.h:15
@ Modules
Definition SystemBase.h:15
@ ProcessBasics
Definition SystemBase.h:15
@ RemainTime
Definition SystemBase.h:15

◆ MemoryUnit

Unit of memory.

Enumerator
Byte 
kByte 
MByte 
GByte 
TByte 
PByte 
EByte 

Definition at line 50 of file Memory.h.

@ kByte
Definition Memory.h:50
@ MByte
Definition Memory.h:50
@ TByte
Definition Memory.h:50
@ GByte
Definition Memory.h:50
@ PByte
Definition Memory.h:50
@ EByte
Definition Memory.h:50
@ Byte
Definition Memory.h:50

◆ ModuleType

Enumerator
UNKNOWN 
SHAREDLIB 
EXECUTABLE 

Definition at line 23 of file ModuleInfo.h.

@ EXECUTABLE
Definition ModuleInfo.h:23
@ SHAREDLIB
Definition ModuleInfo.h:23
@ UNKNOWN
Definition ModuleInfo.h:23

◆ PR_file_type

Enumerator
PR_regular_file 
PR_directory 

Definition at line 27 of file PathResolver.cpp.

◆ PR_search_type

Enumerator
PR_local 
PR_recursive 

Definition at line 29 of file PathResolver.cpp.

◆ ProcessInfoCommand

Enumerator
ProcessBasicInformation 
ProcessQuotaLimits 
ProcessIoCounters 
ProcessVmCounters 
ProcessTimes 
ProcessBasePriority 
ProcessRaisePriority 
ProcessDebugPort 
ProcessExceptionPort 
ProcessAccessToken 
ProcessLdtInformation 
ProcessLdtSize 
ProcessDefaultHardErrorMode 
ProcessIoPortHandlers 
ProcessPooledUsageAndLimits 
ProcessWorkingSetWatch 
ProcessUserModeIOPL 
ProcessEnableAlignmentFaultFixup 
ProcessPriorityClass 
ProcessWx86Information 
ProcessHandleCount 
ProcessAffinityMask 
ProcessPriorityBoost 
MaxProcessInfoClass 
ProcessEllapsedTime 

Definition at line 16 of file ProcessDescriptor.cpp.

16 {
30 ProcessIoPortHandlers, // Note: this is kernel mode only
42 };
@ ProcessDefaultHardErrorMode
@ ProcessEnableAlignmentFaultFixup
@ ProcessPooledUsageAndLimits

◆ TimeType

Time type for conversion.

Enumerator
Year 
Month 
Day 
Hour 
Min 
Sec 
milliSec 
microSec 
nanoSec 
Native 

Definition at line 45 of file Timing.h.

@ milliSec
Definition Timing.h:45
@ Min
Definition Timing.h:45
@ Native
Definition Timing.h:45
@ Year
Definition Timing.h:45
@ Sec
Definition Timing.h:45
@ nanoSec
Definition Timing.h:45
@ Hour
Definition Timing.h:45
@ Month
Definition Timing.h:45
@ microSec
Definition Timing.h:45
@ Day
Definition Timing.h:45

Function Documentation

◆ accountName()

const std::string & System::accountName ( )

User login name.

Definition at line 283 of file System.cpp.

283 {
284 static const std::string account = Platform::accountName();
285 return account;
286}

◆ adjustMemory()

long System::adjustMemory ( MemoryUnit typ,
long value )

Convert time from kByte to requested representation (Experts only).

Convert requested memory value from kByte to requested value.

Definition at line 19 of file Memory.cpp.

19 {
20 if ( value != -1 ) {
21 switch ( unit ) {
22 case Byte:
23 break;
24 case kByte:
25 value = value / 1024;
26 break;
27 case MByte:
28 value = ( value / 1024 ) / 1024;
29 break;
30 case GByte:
31 value = ( ( value / 1024 ) / 1024 ) / 1024;
32 break;
33 case TByte:
34 value = ( ( ( value / 1024 ) / 1024 ) / 1024 ) / 1024;
35 break;
36 case PByte:
37 value = ( ( ( ( value / 1024 ) / 1024 ) / 1024 ) / 1024 ) / 1024;
38 break;
39 case EByte:
40 value = ( ( ( ( ( value / 1024 ) / 1024 ) / 1024 ) / 1024 ) / 1024 ) / 1024;
41 break;
42 default:
43 value = -1;
44 break;
45 }
46 }
47 return value;
48}

◆ adjustTime() [1/2]

template<TimeType T>
long long System::adjustTime ( long long timevalue)
inline

Convert the time from OS native time to requested representation (Experts only).

◆ adjustTime() [2/2]

long long System::adjustTime ( TimeType typ,
long long timevalue )

Convert time from OS native time to requested representation (Experts only).

unfortunately "-ansi" flag turn off the correct definition of CLK_TCK and forces it to be equal CLOCKS_PER_SEC, it is wrong!

t /= CLOCKS_PER_SEC; // needs division by clock tick unit

Definition at line 38 of file Timing.cpp.

38 {
39 if ( t != -1 ) {
41 // t /= CLK_TCK ; // needs division by clock tick unit
45
47 switch ( typ ) {
48 case Year:
49 return adjustTime<Year>( t );
50 case Month:
51 return adjustTime<Month>( t );
52 case Day:
53 return adjustTime<Day>( t );
54 case Hour:
55 return adjustTime<Hour>( t );
56 case Min:
57 return adjustTime<Min>( t );
58 case Sec:
59 return adjustTime<Sec>( t );
60 case milliSec:
61 return adjustTime<milliSec>( t );
62 case microSec:
63 return adjustTime<microSec>( t );
64 case nanoSec:
65 return adjustTime<nanoSec>( t );
66 case Native:
67 return adjustTime<Native>( t );
68 default:
69 return t;
70 }
71 }
72 return t;
73}
long long adjustTime< Day >(long long t)
Definition Timing.h:200
long long adjustTime< Native >(long long t)
Definition Timing.h:232
long long adjustTime< Year >(long long t)
Definition Timing.h:196
long long adjustTime< Hour >(long long t)
Definition Timing.h:204
long long adjustTime< nanoSec >(long long t)
Definition Timing.h:224
long long adjustTime< milliSec >(long long t)
Definition Timing.h:216
long long adjustTime< microSec >(long long t)
Definition Timing.h:220
long long adjustTime< Sec >(long long t)
Definition Timing.h:212
long long adjustTime< Month >(long long t)
Definition Timing.h:228
long long adjustTime< Min >(long long t)
Definition Timing.h:208

◆ adjustTime< Day >()

template<>
long long System::adjustTime< Day > ( long long t)
inline

Definition at line 200 of file Timing.h.

200 {
201 return ( t == -1 ) ? t : t /= ( 1LL * 24 * 60 * 60 * 1000 * 1000 * 10 );
202 }

◆ adjustTime< Hour >()

template<>
long long System::adjustTime< Hour > ( long long t)
inline

Definition at line 204 of file Timing.h.

204 {
205 return ( t == -1 ) ? t : t /= ( 1LL * 60 * 60 * 1000 * 1000 * 10 );
206 }

◆ adjustTime< microSec >()

template<>
long long System::adjustTime< microSec > ( long long t)
inline

Definition at line 220 of file Timing.h.

220 {
221 return ( t == -1 ) ? t : t /= ( 10LL );
222 }

◆ adjustTime< milliSec >()

template<>
long long System::adjustTime< milliSec > ( long long t)
inline

Definition at line 216 of file Timing.h.

216 {
217 return ( t == -1 ) ? t : t /= ( 1000 * 10 );
218 }

◆ adjustTime< Min >()

template<>
long long System::adjustTime< Min > ( long long t)
inline

Definition at line 208 of file Timing.h.

208 {
209 return ( t == -1 ) ? t : t /= ( 60 * 1000 * 1000 * 10 );
210 }

◆ adjustTime< Month >()

template<>
long long System::adjustTime< Month > ( long long t)
inline

Definition at line 228 of file Timing.h.

228 {
229 return ( t == -1 ) ? t : t /= ( 1LL * 30 * 24 * 60 * 60 * 1000 * 1000 * 10 );
230 }

◆ adjustTime< nanoSec >()

template<>
long long System::adjustTime< nanoSec > ( long long t)
inline

Definition at line 224 of file Timing.h.

224 {
225 return ( t == -1 ) ? t : t *= 100LL;
226 }

◆ adjustTime< Native >()

template<>
long long System::adjustTime< Native > ( long long t)
inline

Definition at line 232 of file Timing.h.

232 {
233 return t;
234 }

◆ adjustTime< Sec >()

template<>
long long System::adjustTime< Sec > ( long long t)
inline

Definition at line 212 of file Timing.h.

212 {
213 return ( t == -1 ) ? t : t /= ( 1000 * 1000 * 10 );
214 }

◆ adjustTime< Year >()

template<>
long long System::adjustTime< Year > ( long long t)
inline

Definition at line 196 of file Timing.h.

196 {
197 return ( t == -1 ) ? t : t /= ( 1LL * 365 * 24 * 60 * 60 * 1000 * 1000 * 10 );
198 }

◆ affinityMask()

long System::affinityMask ( InfoType fetch = ProcessBasics,
long pid = -1 )

Basic Process Information: Affinity mask.

Definition at line 71 of file Memory.cpp.

71 {
73 if ( fetch != NoFetch && getProcess()->query( pid, ProcessBasics, &info ) ) return info.AffinityMask;
74 return 0;
75}
ProcessDescriptor * getProcess()
Retrieve Process structure.

◆ argc()

long System::argc ( )

Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call...

Number of arguments passed to the commandline.

Definition at line 292 of file System.cpp.

292{ return cmdLineArgs().size(); }
GAUDI_API const std::vector< std::string > cmdLineArgs()
Command line arguments including executable name as arg[0] as vector of strings.
Definition System.cpp:295

◆ argv()

char ** System::argv ( )

char** command line arguments including executable name as arg[0]; You may not modify them!

Const char** command line arguments including executable name as arg[0].

Definition at line 301 of file System.cpp.

301 {
302 auto helperFunc = []( const std::vector<std::string>& args ) -> std::vector<const char*> {
303 std::vector<const char*> result;
304 std::transform( args.begin(), args.end(), std::back_inserter( result ),
305 []( const std::string& s ) { return s.c_str(); } );
306 return result;
307 };
308 static const std::vector<const char*> args = helperFunc( cmdLineArgs() );
309 // We rely here on the fact that a vector's allocation table is contiguous
310 return (char**)&( args[0] );
311}

◆ backTrace() [1/2]

bool System::backTrace ( std::string & btrace,
const int depth,
const int offset = 0 )

Definition at line 369 of file System.cpp.

369 {
370 try {
371 // Always hide the first two levels of the stack trace (that's us)
372 const size_t totalOffset = offset + 2;
373 const size_t totalDepth = depth + totalOffset;
374
375 std::string fnc, lib;
376
377 std::vector<void*> addresses( totalDepth, nullptr );
378 const size_t count = System::backTrace( addresses.data(), totalDepth );
379 for ( size_t i = totalOffset; i < count; ++i ) {
380 void* addr = nullptr;
381
382 if ( System::getStackLevel( addresses[i], addr, fnc, lib ) ) {
383 std::ostringstream ost;
384 ost << "#" << std::setw( 3 ) << std::setiosflags( std::ios::left ) << i - totalOffset + 1;
385 ost << std::hex << addr << std::dec << " " << fnc << " [" << lib << "]" << std::endl;
386 btrace += ost.str();
387 }
388 }
389 return true;
390 } catch ( const std::bad_alloc& e ) { return false; }
391}
GAUDI_API bool getStackLevel(void *addresses, void *&addr, std::string &fnc, std::string &lib)
Definition System.cpp:393
GAUDI_API int backTrace(void **addresses, const int depth)
Definition System.cpp:357

◆ backTrace() [2/2]

int System::backTrace ( void ** addresses,
const int depth )

Definition at line 357 of file System.cpp.

357 {
358
359#if defined( __linux ) || defined( __APPLE__ )
360
361 int count = backtrace( addresses, depth );
362 return count > 0 ? count : 0;
363
364#else
365 return 0;
366#endif
367}

◆ basePriority()

long System::basePriority ( InfoType fetch = ProcessBasics,
long pid = -1 )

Basic Process Information: Base priority.

Definition at line 51 of file Memory.cpp.

51 {
53 if ( fetch != NoFetch && getProcess()->query( pid, ProcessBasics, &info ) ) return info.BasePriority;
54 return 0;
55}

◆ cmdLineArgs()

const std::vector< std::string > System::cmdLineArgs ( )

Command line arguments including executable name as arg[0] as vector of strings.

Const char** command line arguments including executable name as arg[0].

Definition at line 295 of file System.cpp.

295 {
296 static const std::vector<std::string> args = Platform::cmdLineArgs();
297 return args;
298}

◆ cpuTime()

long long System::cpuTime ( TimeType typ = milliSec,
InfoType fetch = Times,
long pid = -1 )

Consumed CPU time of process in milliseconds.

CPU kernel time of process in milliseconds.

Parameters
typIndicator or the unit the time will be returned.
fetchIndicator of the information to be fetched. If Fetch_None, the information will not be updated.
pidProcess ID of which the information will be returned
Returns
Requested value in the indicated units.

Definition at line 182 of file Timing.cpp.

182 {
183 long long cputime = 0;
185 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) ) {
186 cputime = adjustTime( typ, info.KernelTime + info.UserTime );
187 }
188 return cputime;
189}
GAUDI_API long long adjustTime(TimeType typ, long long timevalue)
Convert time from OS native time to requested representation (Experts only).
Definition Timing.cpp:38
Process/Thread System and User Time NtQueryInformationProcess using ProcessTimes NtQueryInformationTh...

◆ creationTime()

long long System::creationTime ( TimeType typ = milliSec,
InfoType fetch = Times,
long pid = -1 )

Process Creation time.

Units of time between process creation and begin of epoche.

Parameters
typIndicator or the unit the time will be returned.
fetchIndicator of the information to be fetched. If Fetch_None, the information will not be updated.
pidProcess ID of which the information will be returned
Returns
Requested value in the indicated units.

Definition at line 130 of file Timing.cpp.

130 {
131 long long created = 0;
133 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) ) {
134 created = adjustTime( typ, info.CreateTime - UNIX_BASE_TIME );
135 }
136 return created;
137}

◆ currentTime() [1/3]

template<TimeType T>
long long System::currentTime ( )
inline

Retrieve absolute system time.

Parameters
typIndicator or the unit the time will be returned.
Returns
Requested value in the indicated units. Get current time in specificed units via template parameter (inlined)

Definition at line 238 of file Timing.h.

238 {
239 struct timeval tv;
240 ::gettimeofday( &tv, 0 );
241 return adjustTime<T>( ( tv.tv_sec * 1000000 + tv.tv_usec ) * 10 );
242 }

◆ currentTime() [2/3]

template<TimeType T>
GAUDI_API long long System::currentTime ( )
inline

Retrieve absolute system time.

Parameters
typIndicator or the unit the time will be returned.
Returns
Requested value in the indicated units. Get current time in specificed units via template parameter (inlined)

Definition at line 238 of file Timing.h.

238 {
239 struct timeval tv;
240 ::gettimeofday( &tv, 0 );
241 return adjustTime<T>( ( tv.tv_sec * 1000000 + tv.tv_usec ) * 10 );
242 }

◆ currentTime() [3/3]

long long System::currentTime ( TimeType typ = milliSec)

Get current time in specificed units.

Retrieve current system time.

Definition at line 86 of file Timing.cpp.

86 {
87 switch ( typ ) {
88 case Year:
89 return currentTime<Year>();
90 case Month:
91 return currentTime<Month>();
92 case Day:
93 return currentTime<Day>();
94 case Hour:
95 return currentTime<Hour>();
96 case Min:
97 return currentTime<Min>();
98 case Sec:
99 return currentTime<Sec>();
100 case milliSec:
101 return currentTime<milliSec>();
102 case microSec:
103 return currentTime<microSec>();
104 case nanoSec:
105 return currentTime<nanoSec>();
106 case Native:
107 return currentTime<Native>();
108 }
109 return currentTime<Native>();
110}
template long long currentTime< Month >()
template long long currentTime< Sec >()
template long long currentTime< milliSec >()
template long long currentTime< microSec >()
template long long currentTime< Day >()
template long long currentTime< Hour >()
template long long currentTime< nanoSec >()
template long long currentTime< Native >()
template long long currentTime< Min >()
template long long currentTime< Year >()

◆ currentTime< Day >()

template long long System::currentTime< Day > ( )

◆ currentTime< Hour >()

template long long System::currentTime< Hour > ( )

◆ currentTime< microSec >()

template long long System::currentTime< microSec > ( )

◆ currentTime< milliSec >()

template long long System::currentTime< milliSec > ( )

◆ currentTime< Min >()

template long long System::currentTime< Min > ( )

◆ currentTime< Month >()

template long long System::currentTime< Month > ( )

◆ currentTime< nanoSec >()

template long long System::currentTime< nanoSec > ( )

◆ currentTime< Native >()

template long long System::currentTime< Native > ( )

◆ currentTime< Sec >()

template long long System::currentTime< Sec > ( )

◆ currentTime< Year >()

template long long System::currentTime< Year > ( )

◆ ellapsedTime()

long long System::ellapsedTime ( TimeType typ = milliSec,
InfoType fetch = Times,
long pid = -1 )

Elapsed time since start of process in milliseconds.

Ellapsed time since start of process in milliseconds.

Parameters
typIndicator or the unit the time will be returned.
timevalueTime value to be converted.
Returns
Requested value in the indicated units.

Definition at line 154 of file Timing.cpp.

154 {
156 long long ellapsed = currentTime( microSec ) * 10;
157 if ( getProcess()->query( pid, fetch, &info ) ) {
158 ellapsed = adjustTime( typ, ellapsed + UNIX_BASE_TIME - info.CreateTime );
159 }
160 return ellapsed;
161}
GAUDI_API long long currentTime()
Retrieve absolute system time.
Definition Timing.h:238

◆ exeHandle()

System::ImageHandle System::exeHandle ( )

Handle to the executable file running.

Definition at line 102 of file ModuleInfo.cpp.

102 {
103#if defined( __linux ) || defined( __APPLE__ )
104 // This does NOT work!
105 static Dl_info infoBuf, *info = &infoBuf;
106 if ( !info ) {
107 void* handle = ::dlopen( nullptr, RTLD_LAZY );
108 // printf("Exe handle:%X\n", handle);
109 if ( handle ) {
110 void* func = ::dlsym( handle, "main" );
111 // printf("Exe:Func handle:%X\n", func);
112 if ( func ) {
113 if ( 0 != ::dladdr( func, &infoBuf ) ) {
114 // std::cout << "All OK" << std::endl;
115 info = &infoBuf;
116 }
117 }
118 }
119 }
120 return info;
121#elif __hpux
122 // Don't know how to solve this .....
123 return 0;
124#endif
125 return 0;
126}

◆ exeName()

const std::string & System::exeName ( )

Name of the executable file running.

Definition at line 128 of file ModuleInfo.cpp.

128 {
129 static std::string module( "" );
130 if ( module.length() == 0 ) {
131 char name[PATH_MAX] = { "Unknown.module" };
132 name[0] = 0;
133#if defined( __linux ) || defined( __APPLE__ )
134 char cmd[512];
135 ::snprintf( cmd, sizeof( cmd ), "/proc/%d/exe", ::getpid() );
136 module = "Unknown";
137 if ( ::readlink( cmd, name, sizeof( name ) ) >= 0 ) module = name;
138#elif __hpux
139 if ( ::realpath( ( (HMODULE*)exeHandle() )->dsc.filename, name ) ) module = name;
140#endif
141 }
142 return module;
143}
GAUDI_API ImageHandle exeHandle()
Handle to the executable file running.

◆ exitStatus()

long System::exitStatus ( InfoType fetch = ProcessBasics,
long pid = -1 )

Basic Process Information: Exit status (does not really make sense for the running process, but for others!).

Definition at line 78 of file Memory.cpp.

78 {
80 if ( fetch != NoFetch && getProcess()->query( pid, ProcessBasics, &info ) ) return info.ExitStatus;
81 return -2;
82}

◆ getEnv() [1/4]

std::vector< std::string > System::getEnv ( )

get all environment variables

get all defined environment vars

Definition at line 341 of file System.cpp.

341 {
342#if defined( __APPLE__ )
343 static char** environ = *_NSGetEnviron();
344#endif
345 std::vector<std::string> vars;
346 for ( int i = 0; environ[i] != nullptr; ++i ) { vars.push_back( environ[i] ); }
347 return vars;
348}

◆ getEnv() [2/4]

std::string System::getEnv ( const char * var)

get a particular environment variable (returning "UNKNOWN" if not set)

get a particular env var, return "UNKNOWN" if not defined

Definition at line 314 of file System.cpp.

314 {
315 char* env;
316 if ( ( env = getenv( var ) ) != nullptr ) {
317 return env;
318 } else {
319 return "UNKNOWN";
320 }
321}

◆ getEnv() [3/4]

bool System::getEnv ( const char * var,
std::string & value )

get a particular environment variable, storing the value in the passed string if the variable is set.

get a particular env var, storing the value in the passed string (if set)

Returns true if the variable is set, false otherwise.

Definition at line 324 of file System.cpp.

324 {
325 char* env;
326 if ( ( env = getenv( var ) ) != nullptr ) {
327 value = env;
328 return true;
329 } else {
330 return false;
331 }
332}

◆ getEnv() [4/4]

bool System::getEnv ( const std::string & var,
std::string & value )
inline

Definition at line 84 of file System.h.

84{ return getEnv( var.c_str(), value ); }
GAUDI_API std::vector< std::string > getEnv()
get all environment variables
Definition System.cpp:341

◆ getErrorString()

const std::string System::getErrorString ( unsigned long error)

Retrieve error code as string for a given error.

Definition at line 234 of file System.cpp.

234 {
235 std::string errString = "";
236 char* cerrString( nullptr );
237 // Remember: for linux dl* routines must be handled differently!
238 if ( error == 0xAFFEDEAD ) {
239 cerrString = ::dlerror();
240 if ( !cerrString ) cerrString = ::strerror( error );
241 if ( !cerrString ) {
242 cerrString = (char*)"Unknown error. No information found in strerror()!";
243 } else {
244 errString = std::string( cerrString );
245 }
246 errno = 0;
247 } else {
248 cerrString = ::strerror( error );
249 errString = std::string( cerrString );
250 }
251 return errString;
252}

◆ getLastError()

unsigned long System::getLastError ( )

Get last system known error.

Retrieve last error code.

Definition at line 222 of file System.cpp.

222 {
223 // convert errno (int) to unsigned long
224 return static_cast<unsigned long>( static_cast<unsigned int>( errno ) );
225}

◆ getLastErrorString()

const std::string System::getLastErrorString ( )

Get last system error as string.

Retrieve last error code as string.

Definition at line 228 of file System.cpp.

228 {
229 const std::string errString = getErrorString( getLastError() );
230 return errString;
231}
GAUDI_API unsigned long getLastError()
Get last system known error.
Definition System.cpp:222
GAUDI_API const std::string getErrorString(unsigned long error)
Retrieve error code as string for a given error.
Definition System.cpp:234

◆ getProcedureByName() [1/2]

unsigned long System::getProcedureByName ( ImageHandle handle,
const std::string & name,
Creator * pFunction )

Get a specific function defined in the DLL.

Definition at line 217 of file System.cpp.

217 {
218 return getProcedureByName( handle, name, (EntryPoint*)pFunction );
219}
unsigned long(* EntryPoint)(const unsigned long iid, void **ppvObject)
Definition of the "generic" DLL entry point function.
Definition System.h:41
GAUDI_API unsigned long getProcedureByName(ImageHandle handle, const std::string &name, EntryPoint *pFunction)
Get a specific function defined in the DLL.
Definition System.cpp:175

◆ getProcedureByName() [2/2]

unsigned long System::getProcedureByName ( ImageHandle handle,
const std::string & name,
EntryPoint * pFunction )

Get a specific function defined in the DLL.

Definition at line 175 of file System.cpp.

175 {
176#if defined( __linux )
177 *pFunction = reinterpret_cast<EntryPoint>( ::dlsym( handle, name.c_str() ) );
178 if ( !*pFunction ) {
179 errno = 0xAFFEDEAD;
180 // std::cout << "System::getProcedureByName>" << getLastErrorString() << std::endl;
181 return 0;
182 }
183 return 1;
184#elif defined( __APPLE__ )
185 *pFunction = ( EntryPoint )::dlsym( handle, name.c_str() );
186 if ( !( *pFunction ) ) {
187 // Try with an underscore :
188 std::string sname = "_" + name;
189 *pFunction = ( EntryPoint )::dlsym( handle, sname.c_str() );
190 }
191 if ( 0 == *pFunction ) {
192 errno = 0xAFFEDEAD;
193 std::cout << "System::getProcedureByName>" << getLastErrorString() << std::endl;
194 // std::cout << "System::getProcedureByName> failure" << std::endl;
195 return 0;
196 }
197 return 1;
198#elif __hpux
199 HMODULE* mod = (HMODULE*)handle;
200 if ( 0 != mod ) {
201 long ll1 = name.length();
202 for ( int i = 0; i < mod->numSym; i++ ) {
203 long ll2 = strlen( mod->sym[i].name );
204 if ( 0 != ::strncmp( mod->sym[i].name, name.c_str(), ( ll1 > ll2 ) ? ll1 : ll2 ) == 0 ) {
205 *pFunction = (EntryPoint)mod->sym[i].value;
206 return 1;
207 }
208 }
209 }
210 return 0;
211#else
212 return 0;
213#endif
214}
GAUDI_API const std::string getLastErrorString()
Get last system error as string.
Definition System.cpp:228

◆ getProcess()

ProcessDescriptor * System::getProcess ( )
inline

Retrieve Process structure.

Definition at line 141 of file ProcessDescriptor.h.

141 {
142 static ProcessDescriptor p;
143 return &p;
144 }
Provides access to process information.

◆ getProcessTime()

ProcessTime System::getProcessTime ( long pid = -1)

Retrieve the process time data for a process.

Get the process time data for a process (by default the current) as a ProcessTime object.

Definition at line 192 of file Timing.cpp.

192 {
194 if ( getProcess()->query( pid, Times, &info ) ) {
195 return ProcessTime( info.KernelTime, info.UserTime, currentTime<Native>() - info.CreateTime );
196 }
197 return ProcessTime(); // return 0s in case of problems
198 }
Simple class to hold the time information of a process.
Definition Timing.h:134

◆ getStackLevel()

bool System::getStackLevel ( void * addresses,
void *& addr,
std::string & fnc,
std::string & lib )

Definition at line 393 of file System.cpp.

394 {
395
396#if defined( __linux ) || defined( __APPLE__ )
397
398 Dl_info info;
399
400 if ( dladdr( addresses, &info ) && info.dli_fname && info.dli_fname[0] != '\0' ) {
401 const char* symbol = info.dli_sname && info.dli_sname[0] != '\0' ? info.dli_sname : nullptr;
402
403 lib = info.dli_fname;
404 addr = info.dli_saddr;
405
406 if ( symbol ) {
407 int stat = -1;
408 auto dmg =
409 std::unique_ptr<char, decltype( free )*>( abi::__cxa_demangle( symbol, nullptr, nullptr, &stat ), std::free );
410 fnc = ( stat == 0 ) ? dmg.get() : symbol;
411 } else {
412 fnc = "local";
413 }
414 return true;
415 } else {
416 return false;
417 }
418
419#else
420 return false;
421#endif
422}

◆ homeDirectory()

std::string System::homeDirectory ( )

Definition at line 64 of file Environment.cpp.

64 {
65 // Return the user's home directory.
66 std::string home_dir = "./";
67 // Try to replace the current value with the content of several
68 // environment variables
69 System::getEnv( "home", home_dir ) || System::getEnv( "HOME", home_dir );
70 return home_dir;
71}

◆ hostName()

const std::string & System::hostName ( )

Host name.

Definition at line 259 of file System.cpp.

259 {
260 static const std::string host = Platform::hostName();
261 return host;
262}

◆ isEnvSet()

bool System::isEnvSet ( const char * var)

Check if an environment variable is set or not.

Definition at line 334 of file System.cpp.

334{ return getenv( var ) != nullptr; }

◆ kernelTime()

long long System::kernelTime ( TimeType typ = milliSec,
InfoType fetch = Times,
long pid = -1 )

CPU kernel mode time of process in milliseconds.

CPU kernel time of process in milliseconds.

Parameters
typIndicator or the unit the time will be returned.
fetchIndicator of the information to be fetched. If Fetch_None, the information will not be updated.
pidProcess ID of which the information will be returned
Returns
Requested value in the indicated units.

Definition at line 164 of file Timing.cpp.

164 {
166 long long kerneltime = 0;
167 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) ) {
168 kerneltime = adjustTime( typ, info.KernelTime );
169 }
170 return kerneltime;
171}

◆ linkedModules()

const std::vector< std::string > System::linkedModules ( )

Vector of names of linked modules.

Definition at line 145 of file ModuleInfo.cpp.

145 {
146 if ( s_linkedModules.size() == 0 ) {
147#if defined( __linux ) || defined( __APPLE__ )
148 char ff[512], cmd[1024], fname[1024], buf1[64], buf2[64], buf3[64], buf4[64];
149 ::snprintf( ff, sizeof( ff ), "/proc/%d/maps", ::getpid() );
150 FILE* maps = ::fopen( ff, "r" );
151 while ( ::fgets( cmd, sizeof( cmd ), maps ) ) {
152 int len;
153 sscanf( cmd, "%s %s %s %s %d %s", buf1, buf2, buf3, buf4, &len, fname );
154 if ( len > 0 && strncmp( buf2, "r-xp", strlen( "r-xp" ) ) == 0 ) { s_linkedModules.push_back( fname ); }
155 }
156 ::fclose( maps );
157#endif
158 }
159 return s_linkedModules;
160}

◆ loadDynamicLib()

unsigned long System::loadDynamicLib ( const std::string & name,
ImageHandle * handle )

Load dynamic link library.

Definition at line 109 of file System.cpp.

109 {
110 unsigned long res = 0;
111 // if name is empty, just load it
112 if ( name.length() == 0 ) {
113 res = loadWithoutEnvironment( name, handle );
114 } else {
115 // If the name is a logical name (environment variable), the try
116 // to load the corresponding library from there.
117 std::string imgName;
118 if ( getEnv( name, imgName ) ) {
119 res = loadWithoutEnvironment( imgName, handle );
120 } else {
121 // build the dll name
122 std::string dllName = name;
123// Add a possible "lib" prefix to the name on unix platforms. But only if
124// it's not an absolute path name.
125#if defined( __linux ) || defined( __APPLE__ )
126 if ( ( dllName.find( '/' ) == std::string::npos ) && ( dllName.compare( 0, 3, "lib" ) != 0 ) ) {
127 dllName = "lib" + dllName;
128 }
129#endif // unix
130 // Now try loading the library with all possible suffixes supported by the
131 // platform.
132 for ( const char* suffix : SHLIB_SUFFIXES ) {
133 // Add the suffix if necessary.
134 std::string libName = dllName;
135 const size_t len = strlen( suffix );
136 if ( dllName.compare( dllName.length() - len, len, suffix ) != 0 ) { libName += suffix; }
137 // Try to load the library.
138 res = loadWithoutEnvironment( libName, handle );
139 // If the load succeeded, stop here.
140 if ( res == 1 ) { break; }
141 }
142 }
143 if ( res != 1 ) {
144#if defined( __linux ) || defined( __APPLE__ )
145 errno = 0xAFFEDEAD;
146#endif
147 // std::cout << "System::loadDynamicLib>" << getLastErrorString() << std::endl;
148 }
149 }
150 return res;
151}

◆ machineType()

const std::string & System::machineType ( )

Machine type.

Definition at line 277 of file System.cpp.

277 {
278 static const std::string mach = Platform::machineType();
279 return mach;
280}

◆ mappedMemory()

long System::mappedMemory ( MemoryUnit unit = kByte,
InfoType fetch = Memory,
long pid = -1 )

Basic Process Information: priority boost.

Definition at line 172 of file Memory.cpp.

172 {
173 VM_COUNTERS info;
174 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) ) return adjustMemory( unit, info.WorkingSetSize );
175 return -2;
176}
GAUDI_API long adjustMemory(MemoryUnit typ, long value)
Convert time from kByte to requested representation (Experts only).
Definition Memory.cpp:19
Process Virtual Memory Counters NtQueryInformationProcess using ProcessVmCounters.
unsigned long WorkingSetSize

◆ mappedMemoryPeak()

long System::mappedMemoryPeak ( MemoryUnit unit = kByte,
InfoType fetch = Memory,
long pid = -1 )

Basic Process Information: priority boost.

Definition at line 179 of file Memory.cpp.

179 {
180 VM_COUNTERS info;
181 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) )
182 return adjustMemory( unit, info.PeakWorkingSetSize );
183 return -2;
184}
unsigned long PeakWorkingSetSize

◆ maxMemoryLimit()

long System::maxMemoryLimit ( MemoryUnit unit = kByte,
InfoType fetch = Quota,
long pid = -1 )

System Process Limits: Maximum amount of virtual memory this process is allowed to use.

Definition at line 195 of file Memory.cpp.

195 {
196 QUOTA_LIMITS quota;
197 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &quota ) )
198 return adjustMemory( unit, quota.MaximumWorkingSetSize );
199 return 0;
200}
Process Quotas NtQueryInformationProcess using ProcessQuotaLimits NtQueryInformationProcess using Pro...
unsigned long MaximumWorkingSetSize

◆ minMemoryLimit()

long System::minMemoryLimit ( MemoryUnit unit = kByte,
InfoType fetch = Quota,
long pid = -1 )

System Process Limits: Minimum amount of virtual memory this process may use.

Definition at line 187 of file Memory.cpp.

187 {
188 QUOTA_LIMITS quota;
189 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &quota ) )
190 return adjustMemory( unit, quota.MinimumWorkingSetSize );
191 return 0;
192}
unsigned long MinimumWorkingSetSize

◆ moduleHandle()

System::ImageHandle System::moduleHandle ( )

Handle to currently executed module.

Definition at line 88 of file ModuleInfo.cpp.

88 {
89 if ( !ModuleHandle ) {
90 if ( processHandle() ) {
91#if defined( __linux ) || defined( __APPLE__ )
92 static Dl_info info;
93 if ( ::dladdr( reinterpret_cast<void*>( System::moduleHandle ), &info ) ) return &info;
94#elif __hpux
95 return 0; // Don't know how to solve this .....
96#endif
97 }
98 }
99 return ModuleHandle;
100}
GAUDI_API ProcessHandle processHandle()
Handle to running process.
GAUDI_API ImageHandle moduleHandle()
Handle to currently executed module.

◆ moduleName()

const std::string & System::moduleName ( )

Get the name of the (executable/DLL) file without file-type.

Retrieve base name of module.

Definition at line 28 of file ModuleInfo.cpp.

28 {
29 static std::string module( "" );
30 if ( module == "" ) {
31 if ( processHandle() && moduleHandle() ) {
32#if defined( __linux ) || defined( __APPLE__ )
33 std::string mod = ::basename( (char*)( (Dl_info*)moduleHandle() )->dli_fname );
34#elif __hpux
35 std::string mod = ::basename( ( (HMODULE*)moduleHandle() )->dsc.filename );
36#endif
37 module = mod.substr( 0, mod.rfind( '.' ) );
38 }
39 }
40 return module;
41}

◆ moduleNameFull()

const std::string & System::moduleNameFull ( )

Get the full name of the (executable/DLL) file.

Retrieve full name of module.

Definition at line 44 of file ModuleInfo.cpp.

44 {
45 static std::string module( "" );
46 if ( module == "" ) {
47 if ( processHandle() && moduleHandle() ) {
48 char name[PATH_MAX] = { "Unknown.module" };
49 name[0] = 0;
50#if defined( __linux ) || defined( __APPLE__ )
51 const char* path = ( (Dl_info*)moduleHandle() )->dli_fname;
52#elif __hpux
53 const char* path = ( (HMODULE*)moduleHandle() )->dsc.filename;
54#endif
55 if ( ::realpath( path, name ) ) module = name;
56 }
57 }
58 return module;
59}

◆ moduleType()

System::ModuleType System::moduleType ( )

Get type of the module.

Definition at line 62 of file ModuleInfo.cpp.

62 {
63 static ModuleType type = UNKNOWN;
64 if ( type == UNKNOWN ) {
65 const std::string& module = moduleNameFull();
66 size_t loc = module.rfind( '.' ) + 1;
67 if ( loc == 0 )
68 type = EXECUTABLE;
69 else if ( module[loc] == 'e' || module[loc] == 'E' )
70 type = EXECUTABLE;
71 else if ( module[loc] == 's' && module[loc + 1] == 'o' )
72 type = SHAREDLIB;
73 else
74 type = UNKNOWN;
75 }
76 return type;
77}
GAUDI_API const std::string & moduleNameFull()
Get the full name of the (executable/DLL) file.

◆ nonPagedMemory()

long System::nonPagedMemory ( MemoryUnit unit = kByte,
InfoType fetch = Memory,
long pid = -1 )

Basic Process Information: Current usage of non paged memory.

Basic Process Information: priority boost.

Definition at line 100 of file Memory.cpp.

100 {
101 VM_COUNTERS info;
102 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) )
103 return adjustMemory( unit, info.QuotaNonPagedPoolUsage );
104 return -2;
105}
unsigned long QuotaNonPagedPoolUsage

◆ nonPagedMemoryLimit()

long System::nonPagedMemoryLimit ( MemoryUnit unit = kByte,
InfoType fetch = Quota,
long pid = -1 )

System Process Limits: Maximum amount of non-paged memory this process is allowed to use.

Definition at line 108 of file Memory.cpp.

108 {
110 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &quota ) )
111 return adjustMemory( unit, quota.NonPagedPoolLimit );
112 return 0;
113}
Process Pooled Quota Usage and Limits NtQueryInformationProcess using ProcessPooledUsageAndLimits.

◆ nonPagedMemoryPeak()

long System::nonPagedMemoryPeak ( MemoryUnit unit = kByte,
InfoType fetch = Memory,
long pid = -1 )

Basic Process Information: Peak usage of non paged memory.

Basic Process Information: priority boost.

Definition at line 92 of file Memory.cpp.

92 {
93 VM_COUNTERS info;
94 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) )
95 return adjustMemory( unit, info.QuotaPeakNonPagedPoolUsage );
96 return -2;
97}
unsigned long QuotaPeakNonPagedPoolUsage

◆ numCmdLineArgs()

long System::numCmdLineArgs ( )

Number of arguments passed to the commandline.

Definition at line 289 of file System.cpp.

289{ return cmdLineArgs().size(); }

◆ numPageFault()

long System::numPageFault ( InfoType fetch = Memory,
long pid = -1 )

Basic Process Information: Number of page faults.

Basic Process Information: priority boost.

Definition at line 140 of file Memory.cpp.

140 {
141 VM_COUNTERS info;
142 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) ) return info.PageFaultCount;
143 return -2;
144}
unsigned long PageFaultCount

◆ osName()

const std::string & System::osName ( )

OS name.

Definition at line 265 of file System.cpp.

265 {
266 static const std::string osname = Platform::osName();
267 return osname;
268}

◆ osVersion()

const std::string & System::osVersion ( )

OS version.

Definition at line 271 of file System.cpp.

271 {
272 static const std::string osver = Platform::osVersion();
273 return osver;
274}

◆ pagedMemory()

long System::pagedMemory ( MemoryUnit unit = kByte,
InfoType fetch = Memory,
long pid = -1 )

Basic Process Information: Amount of paged memory currently occupied by the process 'pid'.

Definition at line 116 of file Memory.cpp.

116 {
117 VM_COUNTERS info;
118 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) )
119 return adjustMemory( unit, info.QuotaPagedPoolUsage );
120 return -2;
121}
unsigned long QuotaPagedPoolUsage

◆ pagedMemoryLimit()

long System::pagedMemoryLimit ( MemoryUnit unit = kByte,
InfoType fetch = Quota,
long pid = -1 )

Basic Process Information: Amount of paged memory that can be occupied by the process 'pid'.

Definition at line 132 of file Memory.cpp.

132 {
134 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &quota ) )
135 return adjustMemory( unit, quota.PagedPoolLimit );
136 return 0;
137}

◆ pagedMemoryPeak()

long System::pagedMemoryPeak ( MemoryUnit unit = kByte,
InfoType fetch = Memory,
long pid = -1 )

Basic Process Information: Maximum of paged memory occupied by the process 'pid'.

Definition at line 124 of file Memory.cpp.

124 {
125 VM_COUNTERS info;
126 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) )
127 return adjustMemory( unit, info.QuotaPeakPagedPoolUsage );
128 return -2;
129}
unsigned long QuotaPeakPagedPoolUsage

◆ pagefileUsage()

long System::pagefileUsage ( MemoryUnit unit = kByte,
InfoType fetch = Memory,
long pid = -1 )

Basic Process Information: Current page file usage.

Basic Process Information: priority boost.

Definition at line 147 of file Memory.cpp.

147 {
148 VM_COUNTERS info;
149 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) ) return adjustMemory( unit, info.PagefileUsage );
150 return -2;
151}
unsigned long PagefileUsage

◆ pagefileUsageLimit()

long System::pagefileUsageLimit ( MemoryUnit unit = kByte,
InfoType fetch = Quota,
long pid = -1 )

Basic Process Information: Peak usage of page file.

Basic Process Information: priority boost.

Definition at line 162 of file Memory.cpp.

162 {
164 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &quota ) ) {
165 if ( long( quota.PagefileLimit ) < 0 ) return -1; // LONG_MAX;
166 return adjustMemory( unit, quota.PagefileLimit );
167 }
168 return -2;
169}

◆ pagefileUsagePeak()

long System::pagefileUsagePeak ( MemoryUnit unit = kByte,
InfoType fetch = Memory,
long pid = -1 )

Basic Process Information: Peak usage of page file.

Basic Process Information: priority boost.

Definition at line 154 of file Memory.cpp.

154 {
155 VM_COUNTERS info;
156 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) )
157 return adjustMemory( unit, info.PeakPagefileUsage );
158 return -2;
159}
unsigned long PeakPagefileUsage

◆ parentID()

long System::parentID ( InfoType fetch = ProcessBasics,
long pid = -1 )

Basic Process Information: Parent's process ID.

Definition at line 64 of file Memory.cpp.

64 {
66 if ( fetch != NoFetch && getProcess()->query( pid, ProcessBasics, &info ) ) return info.InheritedFromUniqueProcessId;
67 return 0;
68}

◆ PathResolverFindDataFile()

std::string System::PathResolverFindDataFile ( const std::string & logical_file_name)

Definition at line 165 of file PathResolver.cpp.

165 {
166 return PathResolver::find_file( logical_file_name, "DATAPATH" );
167 }
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)

◆ PathResolverFindXMLFile()

std::string System::PathResolverFindXMLFile ( const std::string & logical_file_name)

Definition at line 161 of file PathResolver.cpp.

161 {
162 return PathResolver::find_file( logical_file_name, "XMLPATH" );
163 }

◆ priorityBoost()

long System::priorityBoost ( InfoType fetch = PriorityBoost,
long pid = -1 )

Basic Process Information: priority boost.

Definition at line 85 of file Memory.cpp.

85 {
86 long info;
87 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) ) return info;
88 return -2;
89}

◆ processHandle()

void * System::processHandle ( )

Handle to running process.

Retrieve processhandle.

Definition at line 80 of file ModuleInfo.cpp.

80 {
81 static long pid = ::getpid();
82 static void* hP = (void*)pid;
83 return hP;
84}

◆ procID()

long System::procID ( )

Basic Process Information: Process ID.

Definition at line 58 of file Memory.cpp.

58 {
59 static const long s_pid = ::getpid();
60 return s_pid;
61}

◆ remainingTime()

long long System::remainingTime ( TimeType typ = milliSec,
InfoType fetch = Quota,
long pid = -1 )

Maximum processing time left for this process.

System Process Limits: Maximum processing time left for this process.

Parameters
typIndicator or the unit the time will be returned.
fetchIndicator of the information to be fetched. If Fetch_None, the information will not be updated.
pidProcess ID of which the information will be returned
Returns
Requested value in the indicated units.

Definition at line 140 of file Timing.cpp.

140 {
141 long long left = 0;
142 QUOTA_LIMITS quota;
143 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &quota ) ) {
144 if ( left == -1 ) {
145 // left = _I64_MAX;
146 } else {
147 left = adjustTime( typ, quota.TimeLimit );
148 }
149 }
150 return left;
151}

◆ resolveEnv()

StatusCode System::resolveEnv ( const std::string & var,
std::string & res,
int recusions = 124 )

Definition at line 57 of file Environment.cpp.

57 {
58 std::string source = var;
59 res = i_resolve( source, recursions );
60 if ( res.find( "${" ) == std::string::npos ) { return StatusCode::SUCCESS; }
62}
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ setEnv()

int System::setEnv ( const std::string & name,
const std::string & value,
int overwrite = 1 )

Set an environment variables.

set an environment variables.

If value is empty, the variable is removed from the environment. When overwrite is 0, the variable is not set if already present. Returns 0 on success, -1 on failure. See man 3 setenv.

Returns
0 if successful, -1 if not

Definition at line 425 of file System.cpp.

425 {
426 return value.empty() ?
427 // remove if set to nothing (and return success)
428 ::unsetenv( name.c_str() ),
429 0 :
430 // set the value
431 ::setenv( name.c_str(), value.c_str(), overwrite );
432}

◆ setModuleHandle()

void System::setModuleHandle ( System::ImageHandle handle)

Attach module handle.

Definition at line 86 of file ModuleInfo.cpp.

86{ ModuleHandle = handle; }

◆ systemStart()

long long System::systemStart ( TimeType typ = Sec)

Maximum processing time left for this process.

Units of time since system startup and begin of epoche.

Parameters
typIndicator or the unit the time will be returned.
Returns
Requested value in the indicated units.

Definition at line 113 of file Timing.cpp.

113 {
114 static long long sys_start = 0;
115 if ( 0 == sys_start ) {
116 long long c = currentTime( microSec );
117 long long t = tickCount();
118 sys_start = 10 * c - t;
119 }
120 return adjustTime( typ, sys_start );
121}
GAUDI_API long long tickCount()
Retrieve the number of ticks since system startup.
Definition Timing.cpp:76

◆ tempDirectory()

std::string System::tempDirectory ( )

Definition at line 73 of file Environment.cpp.

73 {
74 // Return a user configured or systemwide directory to create
75 // temporary files in.
76 std::string dir;
77 if ( System::getEnv( "TEMP", dir ) || System::getEnv( "TEMPDIR", dir ) || System::getEnv( "TEMP_DIR", dir ) ||
78 System::getEnv( "TMP", dir ) || System::getEnv( "TMPDIR", dir ) || System::getEnv( "TMP_DIR", dir ) )
79 return dir;
80 else
81 return homeDirectory();
82}
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition System.cpp:314
GAUDI_API std::string homeDirectory()

◆ threadSelf()

ThreadHandle System::threadSelf ( )
inline

thread handle "accessor"

Definition at line 104 of file System.h.

104{ return (void*)0; }

◆ tickCount()

long long System::tickCount ( )

Retrieve the number of ticks since system startup.

Returns
Requested value in the indicated units.

Definition at line 76 of file Timing.cpp.

76 {
77 long long count = 10000;
78 struct tms buf;
79 count *= 10 * times( &buf );
80 return count;
81}

◆ typeinfoName() [1/2]

const std::string System::typeinfoName ( const char * class_name)

Definition at line 256 of file System.cpp.

256{ return Platform::typeinfoName( class_name ); }

◆ typeinfoName() [2/2]

const std::string System::typeinfoName ( const std::type_info & tinfo)

Get platform independent information about the class type.

Definition at line 254 of file System.cpp.

254{ return typeinfoName( tinfo.name() ); }
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:254

◆ unloadDynamicLib()

unsigned long System::unloadDynamicLib ( ImageHandle handle)

unload dynamic link library

Definition at line 154 of file System.cpp.

154 {
155#if defined( __linux ) || defined( __APPLE__ )
156 ::dlclose( handle );
157 if ( 0 ) {
158#elif __hpux
159 // On HP we have to run finalization ourselves.....
160 Creator pFinalize = 0;
161 if ( getProcedureByName( handle, "_fini", &pFinalize ) ) { pFinalize(); }
162 HMODULE* mod = (HMODULE*)handle;
163 if ( 0 == ::shl_unload( mod->dsc.handle ) ) {
164 delete mod;
165 } else {
166#else
167 if ( false ) {
168#endif
169 return getLastError();
170 }
171 return 1;
172}
void *(* Creator)()
Definition of the "generic" DLL entry point function.
Definition System.h:43

◆ upTime()

long long System::upTime ( TimeType typ = Hour)

Maximum processing time left for this process.

Units of time since system startup in requested units.

Parameters
typIndicator or the unit the time will be returned.
Returns
Requested value in the indicated units.

Definition at line 124 of file Timing.cpp.

124 {
125 static long long sys_start = 10 * systemStart( microSec );
126 return adjustTime( typ, 10 * currentTime( microSec ) - sys_start );
127}
GAUDI_API long long systemStart(TimeType typ=Sec)
Maximum processing time left for this process.
Definition Timing.cpp:113

◆ userTime()

long long System::userTime ( TimeType typ = milliSec,
InfoType fetch = Times,
long pid = -1 )

CPU user mode time of process in milliseconds.

CPU kernel time of process in milliseconds.

Parameters
typIndicator or the unit the time will be returned.
fetchIndicator of the information to be fetched. If Fetch_None, the information will not be updated.
pidProcess ID of which the information will be returned
Returns
Requested value in the indicated units.

Definition at line 174 of file Timing.cpp.

174 {
175 long long usertime = 0;
177 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) ) { usertime = adjustTime( typ, info.UserTime ); }
178 return usertime;
179}

◆ virtualMemory()

long System::virtualMemory ( MemoryUnit unit = kByte,
InfoType fetch = Memory,
long pid = -1 )

Basic Process Information: priority boost.

Definition at line 203 of file Memory.cpp.

203 {
204 VM_COUNTERS info;
205 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) ) return adjustMemory( unit, info.VirtualSize );
206 return -2;
207}
unsigned long VirtualSize

◆ virtualMemoryLimit()

long System::virtualMemoryLimit ( MemoryUnit unit = kByte,
InfoType fetch = Quota,
long pid = -1 )

System Process Limits: Maximum amount of the page file this process is allowed to use.

Definition at line 217 of file Memory.cpp.

217 {
218 QUOTA_LIMITS quota;
219 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &quota ) ) {
220 if ( long( quota.PagefileLimit ) == -1 ) return -1; // LONG_MAX;
221 return adjustMemory( unit, quota.PagefileLimit );
222 }
223 return 0;
224}
unsigned long PagefileLimit

◆ virtualMemoryPeak()

long System::virtualMemoryPeak ( MemoryUnit unit = kByte,
InfoType fetch = Memory,
long pid = -1 )

Basic Process Information: priority boost.

Definition at line 210 of file Memory.cpp.

210 {
211 VM_COUNTERS info;
212 if ( fetch != NoFetch && getProcess()->query( pid, fetch, &info ) ) return adjustMemory( unit, info.PeakVirtualSize );
213 return -2;
214}
unsigned long PeakVirtualSize