aboutsummaryrefslogtreecommitdiff
path: root/libiberty/physmem.c
diff options
context:
space:
mode:
authorRainer Orth <ro@TechFak.Uni-Bielefeld.DE>2003-02-21 20:33:50 +0000
committerRainer Orth <ro@gcc.gnu.org>2003-02-21 20:33:50 +0000
commit4a06f7f2ec8474a1cc98952ca270adc81c422fc1 (patch)
tree6c552af30d13caf2270655116cccc34ae08607c6 /libiberty/physmem.c
parent5dc3a78ce076b29e9614a897dfdb41497fe5190d (diff)
downloadgcc-4a06f7f2ec8474a1cc98952ca270adc81c422fc1.zip
gcc-4a06f7f2ec8474a1cc98952ca270adc81c422fc1.tar.gz
gcc-4a06f7f2ec8474a1cc98952ca270adc81c422fc1.tar.bz2
physmem.c (physmem_total): Use getsysinfo on Tru64 UNIX.
* physmem.c (physmem_total) [HAVE_GETSYSINFO]: Use getsysinfo on Tru64 UNIX. (physmem_available) [HAVE_TABLE && HAVE_SYS_TABLE_H]: Use table on Tru64 UNIX. * configure.in (AC_CHECK_HEADERS): Check for sys/sysinfo.h, machine/hal_sysinfo.h, sys/table.h. (checkfuncs, AC_CHECKFUNCS): Check for getsysinfo, table. * configure, config.in: Regenerate. From-SVN: r63241
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 52b9c8a..2011f02 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;
}