System RAM discovery on Linux.

This commit is contained in:
Bartosz Taudul 2018-08-19 18:52:04 +02:00
parent 790a3ae26f
commit e9170c862e

View File

@ -55,6 +55,9 @@ extern "C" typedef LONG (WINAPI *t_RtlGetVersion)( PRTL_OSVERSIONINFOW );
#if defined __APPLE__ #if defined __APPLE__
# include "TargetConditionals.h" # include "TargetConditionals.h"
#endif #endif
#if defined __linux__
# include <sys/sysinfo.h>
#endif
namespace tracy namespace tracy
{ {
@ -284,6 +287,10 @@ static const char* GetHostInfo()
statex.dwLength = sizeof( statex ); statex.dwLength = sizeof( statex );
GlobalMemoryStatusEx( &statex ); GlobalMemoryStatusEx( &statex );
ptr += sprintf( ptr, "RAM: %i MB\n", statex.ullTotalPhys / 1024 / 1024 ); ptr += sprintf( ptr, "RAM: %i MB\n", statex.ullTotalPhys / 1024 / 1024 );
#elif defined __linux__
struct sysinfo sysInfo;
sysinfo( &sysInfo );
ptr += sprintf( ptr, "RAM: %i MB\n", sysInfo.totalram / 1024 / 1024 );
#else #else
ptr += sprintf( ptr, "RAM: unknown\n" ); ptr += sprintf( ptr, "RAM: unknown\n" );
#endif #endif