cmake/Source/kwsys/SystemInformation.hxx.in

140 lines
4.6 KiB
C++
Raw Normal View History

2017-04-14 19:02:05 +02:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#ifndef @KWSYS_NAMESPACE@_SystemInformation_h
#define @KWSYS_NAMESPACE@_SystemInformation_h
2015-11-17 17:22:37 +01:00
#include <@KWSYS_NAMESPACE@/Configure.hxx>
2017-04-14 19:02:05 +02:00
2010-03-17 14:00:29 +02:00
#include <stddef.h> /* size_t */
2015-11-17 17:22:37 +01:00
#include <string>
2017-04-14 19:02:05 +02:00
namespace @KWSYS_NAMESPACE@ {
2013-03-16 19:13:01 +02:00
// forward declare the implementation class
class SystemInformationImplementation;
2013-03-16 19:13:01 +02:00
class @KWSYS_NAMESPACE@_EXPORT SystemInformation
{
#if @KWSYS_USE_LONG_LONG@
typedef long long LongLong;
#elif @KWSYS_USE___INT64@
typedef __int64 LongLong;
#else
2017-04-14 19:02:05 +02:00
#error "No Long Long"
2013-03-16 19:13:01 +02:00
#endif
friend class SystemInformationImplementation;
SystemInformationImplementation* Implementation;
2017-04-14 19:02:05 +02:00
public:
SystemInformation();
~SystemInformation();
2017-04-14 19:02:05 +02:00
const char* GetVendorString();
const char* GetVendorID();
2015-11-17 17:22:37 +01:00
std::string GetTypeID();
std::string GetFamilyID();
std::string GetModelID();
std::string GetModelName();
std::string GetSteppingCode();
2017-04-14 19:02:05 +02:00
const char* GetExtendedProcessorName();
const char* GetProcessorSerialNumber();
int GetProcessorCacheSize();
2009-10-04 10:30:41 +03:00
unsigned int GetLogicalProcessorsPerPhysical();
float GetProcessorClockFrequency();
int GetProcessorAPICID();
int GetProcessorCacheXSize(long int);
bool DoesCPUSupportFeature(long int);
2013-03-16 19:13:01 +02:00
// returns an informative general description of the cpu
// on this system.
2015-11-17 17:22:37 +01:00
std::string GetCPUDescription();
2013-03-16 19:13:01 +02:00
2017-04-14 19:02:05 +02:00
const char* GetHostname();
2015-11-17 17:22:37 +01:00
std::string GetFullyQualifiedDomainName();
2013-03-16 19:13:01 +02:00
2017-04-14 19:02:05 +02:00
const char* GetOSName();
const char* GetOSRelease();
const char* GetOSVersion();
const char* GetOSPlatform();
2013-03-16 19:13:01 +02:00
int GetOSIsWindows();
int GetOSIsLinux();
int GetOSIsApple();
// returns an informative general description of the os
// on this system.
2015-11-17 17:22:37 +01:00
std::string GetOSDescription();
2013-03-16 19:13:01 +02:00
bool Is64Bits();
unsigned int GetNumberOfLogicalCPU(); // per physical cpu
unsigned int GetNumberOfPhysicalCPU();
bool DoesCPUSupportCPUID();
2013-03-16 19:13:01 +02:00
// Retrieve id of the current running process
LongLong GetProcessId();
// Retrieve memory information in megabyte.
2010-03-17 14:00:29 +02:00
size_t GetTotalVirtualMemory();
size_t GetAvailableVirtualMemory();
size_t GetTotalPhysicalMemory();
2013-03-16 19:13:01 +02:00
size_t GetAvailablePhysicalMemory();
// returns an informative general description if the installed and
// available ram on this system. See the GetHostMmeoryTotal, and
// Get{Host,Proc}MemoryAvailable methods for more information.
2017-04-14 19:02:05 +02:00
std::string GetMemoryDescription(const char* hostLimitEnvVarName = NULL,
const char* procLimitEnvVarName = NULL);
2013-03-16 19:13:01 +02:00
// Retrieve amount of physical memory installed on the system in KiB
// units.
LongLong GetHostMemoryTotal();
// Get total system RAM in units of KiB available colectivley to all
// processes in a process group. An example of a process group
// are the processes comprising an mpi program which is running in
// parallel. The amount of memory reported may differ from the host
// total if a host wide resource limit is applied. Such reource limits
// are reported to us via an applicaiton specified environment variable.
2017-04-14 19:02:05 +02:00
LongLong GetHostMemoryAvailable(const char* hostLimitEnvVarName = NULL);
2013-03-16 19:13:01 +02:00
// Get total system RAM in units of KiB available to this process.
// This may differ from the host available if a per-process resource
// limit is applied. per-process memory limits are applied on unix
2013-11-03 12:27:13 +02:00
// system via rlimit API. Resource limits that are not imposed via
// rlimit API may be reported to us via an application specified
2013-03-16 19:13:01 +02:00
// environment variable.
2017-04-14 19:02:05 +02:00
LongLong GetProcMemoryAvailable(const char* hostLimitEnvVarName = NULL,
const char* procLimitEnvVarName = NULL);
2013-03-16 19:13:01 +02:00
// Get the system RAM used by all processes on the host, in units of KiB.
LongLong GetHostMemoryUsed();
// Get system RAM used by this process id in units of KiB.
LongLong GetProcMemoryUsed();
2015-11-17 17:22:37 +01:00
// Return the load average of the machine or -0.0 if it cannot
// be determined.
double GetLoadAverage();
2013-03-16 19:13:01 +02:00
// enable/disable stack trace signal handler. In order to
// produce an informative stack trace the application should
// be dynamically linked and compiled with debug symbols.
2017-04-14 19:02:05 +02:00
static void SetStackTraceOnError(int enable);
2013-11-03 12:27:13 +02:00
// format and return the current program stack in a string. In
// order to produce an informative stack trace the application
// should be dynamically linked and compiled with debug symbols.
2017-04-14 19:02:05 +02:00
static std::string GetProgramStack(int firstFrame, int wholePath);
2013-11-03 12:27:13 +02:00
/** Run the different checks */
void RunCPUCheck();
void RunOSCheck();
void RunMemoryCheck();
};
2013-03-16 19:13:01 +02:00
} // namespace @KWSYS_NAMESPACE@
#endif