Report physical memory size on BSD.

This commit is contained in:
Bartosz Taudul 2019-11-21 02:14:08 +01:00
parent 3282360382
commit 7940977dba

View File

@ -11,6 +11,7 @@
# include <intrin.h>
#else
# include <sys/time.h>
# include <sys/param.h>
#endif
#ifdef __CYGWIN__
@ -31,7 +32,7 @@
# include <sys/syscall.h>
#endif
#ifdef __APPLE__
#if defined __APPLE__ || defined BSD
# include <sys/types.h>
# include <sys/sysctl.h>
#endif
@ -494,6 +495,11 @@ static const char* GetHostInfo()
size_t sz = sizeof( memSize );
sysctlbyname( "hw.memsize", &memSize, &sz, nullptr, 0 );
ptr += sprintf( ptr, "RAM: %zu MB\n", memSize / 1024 / 1024 );
#elif defined BSD
size_t memSize;
size_t sz = sizeof( memSize );
sysctlbyname( "hw.physmem", &memSize, &sz, nullptr, 0 );
ptr += sprintf( ptr, "RAM: %zu MB\n", memSize / 1024 / 1024 );
#else
ptr += sprintf( ptr, "RAM: unknown\n" );
#endif