From 48ad3d9ece36f8f0404b431ebaf75557bb721ac8 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Mon, 25 May 2015 18:14:12 +0200 Subject: added system_phys_memory (implemented on Windows) --- src/biruda.c | 2 ++ src/system.c | 13 +++++++++++++ src/system.h | 3 +++ 3 files changed, 18 insertions(+) diff --git a/src/biruda.c b/src/biruda.c index e150627..ea1fce5 100644 --- a/src/biruda.c +++ b/src/biruda.c @@ -204,6 +204,8 @@ static void print_config( struct gengetopt_args_info *args_info, cfg_t *cfg ) unsigned int nofCpus = system_available_cpus( ); puts( "Environment:" ); printf( " Number of CPUs: %d\n", nofCpus ); + int physMem = system_phys_memory( ); + printf( " Physical memory available: %d MB\n", physMem ); char machine_arch[100]; system_arch( machine_arch, sizeof( machine_arch ) ); printf( " System architecture: %s\n", machine_arch ); diff --git a/src/system.c b/src/system.c index fede36c..b947ce2 100644 --- a/src/system.c +++ b/src/system.c @@ -382,3 +382,16 @@ void system_arch( char *name, size_t len ) snprintf( name, len, "%s", uts.machine ); #endif } + +int system_phys_memory( ) +{ +#ifdef _WIN32 + MEMORYSTATUSEX memState; + memset( &memState, 0, sizeof( MEMORYSTATUSEX ) ); + memState.dwLength = sizeof( MEMORYSTATUSEX ); + GlobalMemoryStatusEx( &memState ); + return memState.ullTotalPhys / 1024 / 1024; +#else +#endif +} + diff --git a/src/system.h b/src/system.h index 196b676..1b84c5a 100644 --- a/src/system.h +++ b/src/system.h @@ -9,4 +9,7 @@ void system_os( char *name, size_t len ); void system_arch( char *name, size_t len ); +/* in kilobytes */ +int system_phys_memory( ); + #endif -- cgit v1.2.3-54-g00ecf