From c18578632fd3c9e513e613a86ba2b7c4ebee6c45 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Tue, 30 Sep 2014 18:22:48 +0400 Subject: Imported Upstream version 8.23 --- lib/physmem.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'lib/physmem.c') diff --git a/lib/physmem.c b/lib/physmem.c index 26299361..d0989aa8 100644 --- a/lib/physmem.c +++ b/lib/physmem.c @@ -1,6 +1,6 @@ /* Calculate the size of physical memory. - Copyright (C) 2000-2001, 2003, 2005-2006, 2009-2013 Free Software + Copyright (C) 2000-2001, 2003, 2005-2006, 2009-2014 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -32,8 +32,11 @@ # include #endif -#if HAVE_SYS_SYSINFO_H && HAVE_MACHINE_HAL_SYSINFO_H +#if HAVE_SYS_SYSINFO_H # include +#endif + +#if HAVE_MACHINE_HAL_SYSINFO_H # include #endif @@ -90,6 +93,14 @@ physmem_total (void) } #endif +#if HAVE_SYSINFO && HAVE_STRUCT_SYSINFO_MEM_UNIT + { /* This works on linux. */ + struct sysinfo si; + if (sysinfo(&si) == 0) + return (double) si.totalram * si.mem_unit; + } +#endif + #if HAVE_PSTAT_GETSTATIC { /* This works on hpux11. */ struct pst_static pss; @@ -194,6 +205,14 @@ physmem_available (void) } #endif +#if HAVE_SYSINFO && HAVE_STRUCT_SYSINFO_MEM_UNIT + { /* This works on linux. */ + struct sysinfo si; + if (sysinfo(&si) == 0) + return ((double) si.freeram + si.bufferram) * si.mem_unit; + } +#endif + #if HAVE_PSTAT_GETSTATIC && HAVE_PSTAT_GETDYNAMIC { /* This works on hpux11. */ struct pst_static pss; -- cgit v1.2.3