From 287cc398984974c05063f35fd98cbe09c0bb6d75 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Sat, 17 Nov 2007 13:13:11 +0000 Subject: [PATCH] changed to get_physical_memory_size() and added an implementation for 2007-11-17 Sven Neumann * app/base/base-utils.[ch]: changed to get_physical_memory_size() and added an implementation for POSIX.2 platforms. svn path=/trunk/; revision=24180 --- ChangeLog | 5 +++++ app/base/base-utils.c | 16 +++++++++------- app/base/base-utils.h | 6 ++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf23a0f592..a2b98c8842 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-11-17 Sven Neumann + + * app/base/base-utils.[ch]: changed to get_physical_memory_size() + and added an implementation for POSIX.2 platforms. + 2007-11-17 Tor Lillqvist * tools/gimptool.c: Ignore --msvc-syntax unless on Windows. Put diff --git a/app/base/base-utils.c b/app/base/base-utils.c index cfb237f65f..c282915383 100644 --- a/app/base/base-utils.c +++ b/app/base/base-utils.c @@ -56,21 +56,23 @@ get_number_of_processors (void) return retval; } -gint -get_physical_memory_size_megabytes (void) +guint64 +get_physical_memory_size (void) { - gint retval = 0; - #ifdef G_OS_UNIX - /* ??? */ +#if defined(HAVE_UNISTD_H) && defined(_SC_PHYS_PAGES) && defined (_SC_PAGE_SIZE) + return sysconf (_SC_PHYS_PAGES) * sysconf (_SC_PAGE_SIZE); #endif +#endif + #ifdef G_OS_WIN32 MEMORYSTATUSEX memory_status; memory_status.dwLength = sizeof (memory_status); + if (GlobalMemoryStatusEx (&memory_status)) - retval = memory_status.ullTotalPhys / (1024*1024); + return memory_status.ullTotalPhys; #endif - return retval; + return 0; } diff --git a/app/base/base-utils.h b/app/base/base-utils.h index 578e4d2055..b9c86d5940 100644 --- a/app/base/base-utils.h +++ b/app/base/base-utils.h @@ -19,7 +19,9 @@ #ifndef __BASE_H__ #define __BASE_H__ -gint get_number_of_processors (void); -gint get_physical_memory_size_megabytes (void); + +gint get_number_of_processors (void); +guint64 get_physical_memory_size (void); + #endif /* __BASE_H__ */