Core/HardwareInfo: Added GetTotalMemory

Former-commit-id: 71289723115161dd253ccb65c1c91af65344c678
This commit is contained in:
Lynix 2015-05-19 14:13:48 +02:00
parent c3e5a7defc
commit 90e4a1ca52
7 changed files with 28 additions and 2 deletions

View File

@ -196,8 +196,7 @@ return {
{
Title = "Récupération d'informations sur le hardware",
Description = "Classe permettant, si la plateforme le supporte, de récupérer des informations utiles sur le matériel: nom et fabricant du processeur, nombre de coeurs, support d'un set d'extension (exemple: SSE), quantité de mémoire vive, exécution de l'instruction CPUID.",
Note = "Il manque de quoi récupérer la quantité de mémoire vive",
Progress = 90,
Progress = 100,
Portability = Feature.Windows + Feature.POSIX
}
}

View File

@ -20,6 +20,7 @@ class NAZARA_API NzHardwareInfo
static unsigned int GetProcessorCount();
static nzProcessorVendor GetProcessorVendor();
static NzString GetProcessorVendorName();
static nzUInt64 GetTotalMemory();
static bool HasCapability(nzProcessorCap capability);

View File

@ -116,6 +116,13 @@ NzString NzHardwareInfo::GetProcessorVendorName()
return vendorNames[s_vendorEnum+1];
}
nzUInt64 NzHardwareInfo::GetTotalMemory()
{
///DOC: Ne nécessite pas l'initialisation de HardwareInfo pour fonctionner
static nzUInt64 totalMemory = NzHardwareInfoImpl::GetTotalMemory();
return totalMemory;
}
bool NzHardwareInfo::HasCapability(nzProcessorCap capability)
{
#ifdef NAZARA_DEBUG

View File

@ -24,6 +24,14 @@ unsigned int NzHardwareInfoImpl::GetProcessorCount()
return sysconf(_SC_NPROCESSORS_CONF);
}
nzUInt64 NzHardwareInfoImpl::GetTotalMemory()
{
nzUInt64 pages = sysconf(_SC_PHYS_PAGES);
nzUInt64 page_size = sysconf(_SC_PAGE_SIZE);
return pages * page_size;
}
bool NzHardwareInfoImpl::IsCpuidSupported()
{
#ifdef NAZARA_PLATFORM_x64

View File

@ -15,6 +15,7 @@ class NzHardwareInfoImpl
public:
static void Cpuid(nzUInt32 functionId, nzUInt32 subFunctionId, nzUInt32 registers[4]);
static unsigned int GetProcessorCount();
static nzUInt64 GetTotalMemory();
static bool IsCpuidSupported();
};

View File

@ -38,6 +38,15 @@ unsigned int NzHardwareInfoImpl::GetProcessorCount()
return infos.dwNumberOfProcessors;
}
nzUInt64 NzHardwareInfoImpl::GetTotalMemory()
{
MEMORYSTATUSEX memStatus;
memStatus.dwLength = sizeof(memStatus);
GlobalMemoryStatusEx(&memStatus);
return memStatus.ullTotalPhys;
}
bool NzHardwareInfoImpl::IsCpuidSupported()
{
#ifdef NAZARA_PLATFORM_x64

View File

@ -14,6 +14,7 @@ class NzHardwareInfoImpl
public:
static void Cpuid(nzUInt32 functionId, nzUInt32 subFunctionId, nzUInt32 registers[4]);
static unsigned int GetProcessorCount();
static nzUInt64 GetTotalMemory();
static bool IsCpuidSupported();
};