summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2015-05-25 18:27:08 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2015-05-25 18:27:08 +0200
commit135469a03d1a03903a57557decb99996aba835cb (patch)
treec139bcb7f5f0e0469e0e97a9a5486ee20af7397b
parent48ad3d9ece36f8f0404b431ebaf75557bb721ac8 (diff)
downloadbiruda-135469a03d1a03903a57557decb99996aba835cb.tar.gz
biruda-135469a03d1a03903a57557decb99996aba835cb.tar.bz2
memory on Linux
-rw-r--r--src/biruda.c2
-rw-r--r--src/system.c11
2 files changed, 11 insertions, 2 deletions
diff --git a/src/biruda.c b/src/biruda.c
index ea1fce5..091bbbf 100644
--- a/src/biruda.c
+++ b/src/biruda.c
@@ -205,7 +205,7 @@ static void print_config( struct gengetopt_args_info *args_info, cfg_t *cfg )
puts( "Environment:" );
printf( " Number of CPUs: %d\n", nofCpus );
int physMem = system_phys_memory( );
- printf( " Physical memory available: %d MB\n", physMem );
+ printf( " Physical memory available: %d kB\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 b947ce2..9e2256d 100644
--- a/src/system.c
+++ b/src/system.c
@@ -390,8 +390,17 @@ int system_phys_memory( )
memset( &memState, 0, sizeof( MEMORYSTATUSEX ) );
memState.dwLength = sizeof( MEMORYSTATUSEX );
GlobalMemoryStatusEx( &memState );
- return memState.ullTotalPhys / 1024 / 1024;
+ return memState.ullTotalPhys / 1024;
+#elif defined( linux ) || defined( __linux ) || defined( __linux__ )
+ size_t pageSize;
+ size_t nofPages;
+
+ pageSize = sysconf( _SC_PAGESIZE );
+ nofPages = sysconf( _SC_PHYS_PAGES );
+
+ return ( pageSize / 1024 ) * nofPages;
#else
+#error Not ported yet!
#endif
}