From 8f3b83863d58b292aff00a40892ff13b1faae8b6 Mon Sep 17 00:00:00 2001 From: ghazi Date: Fri, 21 Feb 2003 20:15:39 +0000 Subject: * configure.in: Check for sys/sysmp.h and sysmp. * physmem.c: Pull upstream copy, add support for irix6. * config.in, configure: Regenerated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@63237 138bc75d-0d04-0410-961f-82ee72b054a4 --- libiberty/physmem.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 4 deletions(-) (limited to 'libiberty/physmem.c') diff --git a/libiberty/physmem.c b/libiberty/physmem.c index 6954261a423..52b9c8adfc2 100644 --- a/libiberty/physmem.c +++ b/libiberty/physmem.c @@ -1,5 +1,5 @@ /* Calculate the size of physical memory. - Copyright 2000, 2001 Free Software Foundation, Inc. + Copyright 2000, 2001, 2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* Written by Paul Eggert. */ +/* Written by Paul Eggert and Jim Meyering. */ #if HAVE_CONFIG_H # include @@ -29,6 +29,12 @@ # include #endif +#if HAVE_SYS_SYSMP_H +#include +#endif + +#include "libiberty.h" + /* Return the total amount of physical memory. */ double physmem_total () @@ -43,7 +49,7 @@ physmem_total () #endif #if HAVE_PSTAT_GETSTATIC - { + { /* This works on hpux11. */ struct pst_static pss; if (0 <= pstat_getstatic (&pss, sizeof pss, 1, 0)) { @@ -55,6 +61,19 @@ physmem_total () } #endif +#if HAVE_SYSMP && defined MP_SAGET && defined MPSA_RMINFO && defined _SC_PAGESIZE + { /* This works on irix6. */ + struct rminfo realmem; + if (sysmp(MP_SAGET, MPSA_RMINFO, &realmem, sizeof(realmem)) == 0) + { + double pagesize = sysconf (_SC_PAGESIZE); + double pages = realmem.physmem; + if (0 <= pages && 0 <= pagesize) + return pages * pagesize; + } + } +#endif + /* Return 0 if we can't determine the value. */ return 0; } @@ -73,7 +92,7 @@ physmem_available () #endif #if HAVE_PSTAT_GETSTATIC && HAVE_PSTAT_GETDYNAMIC - { + { /* This works on hpux11. */ struct pst_static pss; struct pst_dynamic psd; if (0 <= pstat_getstatic (&pss, sizeof pss, 1, 0) @@ -87,6 +106,40 @@ physmem_available () } #endif +#if HAVE_SYSMP && defined MP_SAGET && defined MPSA_RMINFO && defined _SC_PAGESIZE + { /* This works on irix6. */ + struct rminfo realmem; + if (sysmp(MP_SAGET, MPSA_RMINFO, &realmem, sizeof(realmem)) == 0) + { + double pagesize = sysconf (_SC_PAGESIZE); + double pages = realmem.availrmem; + if (0 <= pages && 0 <= pagesize) + return pages * pagesize; + } + } +#endif + /* Guess 25% of physical memory. */ return physmem_total () / 4; } + + +#if DEBUG + +# include +# include + +int +main () +{ + printf ("%12.f %12.f\n", physmem_total (), physmem_available ()); + exit (0); +} + +#endif /* DEBUG */ + +/* +Local Variables: +compile-command: "gcc -DDEBUG -DHAVE_CONFIG_H -I.. -g -O -Wall -W physmem.c" +End: +*/ -- cgit v1.2.1