1 /*============================================================================
2 KWSys - Kitware System Library
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #ifndef @KWSYS_NAMESPACE@_SystemInformation_h
13 #define @KWSYS_NAMESPACE@_SystemInformation_h
16 /* Define these macros temporarily to keep the code readable. */
17 #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
18 # define kwsys_stl @KWSYS_NAMESPACE@_stl
19 # define kwsys_ios @KWSYS_NAMESPACE@_ios
21 #include <@KWSYS_NAMESPACE@/stl/string>
22 #include <stddef.h> /* size_t */
24 namespace @KWSYS_NAMESPACE@
27 // forward declare the implementation class
28 class SystemInformationImplementation;
30 class @KWSYS_NAMESPACE@_EXPORT SystemInformation
32 #if @KWSYS_USE_LONG_LONG@
33 typedef long long LongLong;
34 #elif @KWSYS_USE___INT64@
35 typedef __int64 LongLong;
37 # error "No Long Long"
39 friend class SystemInformationImplementation;
40 SystemInformationImplementation* Implementation;
44 ~SystemInformation ();
46 const char * GetVendorString();
47 const char * GetVendorID();
48 kwsys_stl::string GetTypeID();
49 kwsys_stl::string GetFamilyID();
50 kwsys_stl::string GetModelID();
51 kwsys_stl::string GetModelName();
52 kwsys_stl::string GetSteppingCode();
53 const char * GetExtendedProcessorName();
54 const char * GetProcessorSerialNumber();
55 int GetProcessorCacheSize();
56 unsigned int GetLogicalProcessorsPerPhysical();
57 float GetProcessorClockFrequency();
58 int GetProcessorAPICID();
59 int GetProcessorCacheXSize(long int);
60 bool DoesCPUSupportFeature(long int);
62 // returns an informative general description of the cpu
64 kwsys_stl::string GetCPUDescription();
66 const char * GetHostname();
67 kwsys_stl::string GetFullyQualifiedDomainName();
69 const char * GetOSName();
70 const char * GetOSRelease();
71 const char * GetOSVersion();
72 const char * GetOSPlatform();
78 // returns an informative general description of the os
80 kwsys_stl::string GetOSDescription();
84 unsigned int GetNumberOfLogicalCPU(); // per physical cpu
85 unsigned int GetNumberOfPhysicalCPU();
87 bool DoesCPUSupportCPUID();
89 // Retrieve id of the current running process
90 LongLong GetProcessId();
92 // Retrieve memory information in megabyte.
93 size_t GetTotalVirtualMemory();
94 size_t GetAvailableVirtualMemory();
95 size_t GetTotalPhysicalMemory();
96 size_t GetAvailablePhysicalMemory();
98 // returns an informative general description if the installed and
99 // available ram on this system. See the GetHostMmeoryTotal, and
100 // Get{Host,Proc}MemoryAvailable methods for more information.
101 kwsys_stl::string GetMemoryDescription(
102 const char *hostLimitEnvVarName=NULL,
103 const char *procLimitEnvVarName=NULL);
105 // Retrieve amount of physical memory installed on the system in KiB
107 LongLong GetHostMemoryTotal();
109 // Get total system RAM in units of KiB available colectivley to all
110 // processes in a process group. An example of a process group
111 // are the processes comprising an mpi program which is running in
112 // parallel. The amount of memory reported may differ from the host
113 // total if a host wide resource limit is applied. Such reource limits
114 // are reported to us via an applicaiton specified environment variable.
115 LongLong GetHostMemoryAvailable(const char *hostLimitEnvVarName=NULL);
117 // Get total system RAM in units of KiB available to this process.
118 // This may differ from the host available if a per-process resource
119 // limit is applied. per-process memory limits are applied on unix
120 // system via rlimit api. Resource limits that are not imposed via
121 // rlimit api may be reported to us via an application specified
122 // environment variable.
123 LongLong GetProcMemoryAvailable(
124 const char *hostLimitEnvVarName=NULL,
125 const char *procLimitEnvVarName=NULL);
127 // Get the system RAM used by all processes on the host, in units of KiB.
128 LongLong GetHostMemoryUsed();
130 // Get system RAM used by this process id in units of KiB.
131 LongLong GetProcMemoryUsed();
133 // enable/disable stack trace signal handler. In order to
134 // produce an informative stack trace the application should
135 // be dynamically linked and compiled with debug symbols.
137 void SetStackTraceOnError(int enable);
139 /** Run the different checks */
142 void RunMemoryCheck();
145 } // namespace @KWSYS_NAMESPACE@
147 /* Undefine temporary macros. */
148 #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS