Retrieve memory size on apple.

This commit is contained in:
Bartosz Taudul 2019-02-20 13:52:55 +01:00
parent 9c966b6224
commit 34d24b16bb

View File

@ -30,6 +30,8 @@
#ifdef __APPLE__
# include <unistd.h>
# include <libproc.h>
# include <sys/types.h>
# include <sys/sysctl.h>
#endif
#include <atomic>
@ -383,6 +385,11 @@ static const char* GetHostInfo()
struct sysinfo sysInfo;
sysinfo( &sysInfo );
ptr += sprintf( ptr, "RAM: %lu MB\n", sysInfo.totalram / 1024 / 1024 );
#elif defined __APPLE__
size_t memSize;
size_t sz = sizeof( memSize );
sysctlbyname( "hw.memsize", &memSize, &sz, nullptr, 0 );
ptr += sprintf( ptr, "RAM: %zu MB\n", memSize / 1024 / 1024 );
#else
ptr += sprintf( ptr, "RAM: unknown\n" );
#endif