diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2016-09-23 08:13:28 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2016-09-23 11:59:59 +0000 |
commit | cc50515e57162d2ef740aa6e725e06f2b0c21293 (patch) | |
tree | b3e66666275982714809f1ab568cb42cd3d4abcd /ws_version_info.c | |
parent | 2fa327ae0ca84368086922e4869e4fa739b1f1f3 (diff) |
Show memory info on macOS and Linux
Added support for showing memory information (amount of physical memory)
in version information on macOS and Linux.
Moved CPU info and memory info right after OS version info.
Change-Id: I305d1b7d015d50ed137f2c80b31d698e9315d735
Reviewed-on: https://code.wireshark.org/review/17884
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ws_version_info.c')
-rw-r--r-- | ws_version_info.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/ws_version_info.c b/ws_version_info.c index 436d33248a..830e37175c 100644 --- a/ws_version_info.c +++ b/ws_version_info.c @@ -29,6 +29,11 @@ #ifdef _WIN32 #include <windows.h> +#elif __APPLE__ +#include <sys/types.h> +#include <sys/sysctl.h> +#elif __linux__ +#include <sys/sysinfo.h> #endif #include <glib.h> @@ -144,16 +149,28 @@ get_compiled_version_info(void (*prepend_info)(GString *), } static void -get_mem_info(GString *str _U_) +get_mem_info(GString *str) { + gint64 memsize = 0; + #ifdef _WIN32 MEMORYSTATUSEX statex; statex.dwLength = sizeof (statex); if (GlobalMemoryStatusEx(&statex)) - g_string_append_printf(str, ", with ""%" G_GINT64_MODIFIER "d" "MB of physical memory.\n", statex.ullTotalPhys/(1024*1024)); + memsize = statex.ullTotalPhys; +#elif __APPLE__ + size_t len = sizeof(memsize); + sysctlbyname("hw.memsize", &memsize, &len, NULL, 0); +#elif __linux__ + struct sysinfo info; + if (sysinfo(&info) == 0) + memsize = info.totalram * info.mem_unit; #endif + + if (memsize > 0) + g_string_append_printf(str, ", with ""%" G_GINT64_MODIFIER "d" " MB of physical memory", memsize/(1024*1024)); } /* @@ -290,6 +307,12 @@ get_runtime_version_info(void (*additional_info)(GString *)) get_os_version_info(str); + /* CPU Info */ + get_cpu_info(str); + + /* Get info about installed memory */ + get_mem_info(str); + /* * Locale. * @@ -320,13 +343,7 @@ get_runtime_version_info(void (*additional_info)(GString *)) g_string_append_printf(str, ", with zlib %s", zlibVersion()); #endif - g_string_append(str, ".\n"); - - /* CPU Info */ - get_cpu_info(str); - - /* Get info about installed memory Windows only */ - get_mem_info(str); + g_string_append(str, "."); /* Compiler info */ get_compiler_info(str); |