summaryrefslogtreecommitdiff
path: root/libiberty/physmem.c
diff options
context:
space:
mode:
Diffstat (limited to 'libiberty/physmem.c')
-rw-r--r--libiberty/physmem.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/libiberty/physmem.c b/libiberty/physmem.c
index 52b9c8adfc2..2011f0251bd 100644
--- a/libiberty/physmem.c
+++ b/libiberty/physmem.c
@@ -33,6 +33,15 @@
#include <sys/sysmp.h>
#endif
+#if HAVE_SYS_SYSINFO_H && HAVE_MACHINE_HAL_SYSINFO_H
+# include <sys/sysinfo.h>
+# include <machine/hal_sysinfo.h>
+#endif
+
+#if HAVE_SYS_TABLE_H
+# include <sys/table.h>
+#endif
+
#include "libiberty.h"
/* Return the total amount of physical memory. */
@@ -74,6 +83,21 @@ physmem_total ()
}
#endif
+#if HAVE_GETSYSINFO
+ { /* This works on Tru64 UNIX V4/5. */
+ int physmem;
+
+ if (getsysinfo (GSI_PHYSMEM, (caddr_t) &physmem, sizeof (physmem),
+ NULL, NULL, NULL) == 1)
+ {
+ double kbytes = physmem;
+
+ if (0 <= kbytes)
+ return kbytes * 1024.0;
+ }
+ }
+#endif
+
/* Return 0 if we can't determine the value. */
return 0;
}
@@ -119,6 +143,21 @@ physmem_available ()
}
#endif
+#if HAVE_TABLE && HAVE_SYS_TABLE_H
+ { /* This works on Tru64 UNIX V4/5. */
+ struct tbl_vmstats vmstats;
+
+ if (table (TBL_VMSTATS, 0, &vmstats, 1, sizeof (vmstats)) == 1)
+ {
+ double pages = vmstats.free_count;
+ double pagesize = vmstats.pagesize;
+
+ if (0 <= pages && 0 <= pagesize)
+ return pages * pagesize;
+ }
+ }
+#endif
+
/* Guess 25% of physical memory. */
return physmem_total () / 4;
}