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