diff options
Diffstat (limited to 'lib/physmem.c')
-rw-r--r-- | lib/physmem.c | 23 |
1 files changed, 21 insertions, 2 deletions
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 <sys/sysmp.h> #endif -#if HAVE_SYS_SYSINFO_H && HAVE_MACHINE_HAL_SYSINFO_H +#if HAVE_SYS_SYSINFO_H # include <sys/sysinfo.h> +#endif + +#if HAVE_MACHINE_HAL_SYSINFO_H # include <machine/hal_sysinfo.h> #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; |