This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Call for testers: libiberty/physmem.c


"Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu> writes:

> plus alpha-osf, hpux10, darwin and anywhere else you host gcc.

Here's what I've come up with for Tru64 UNIX.  I've learned the functions
to use from top sources and a quick peak at the sources for the collect
program.  Works on both Tru64 UNIX V4.0F and V5.1.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University


Fri Feb 21 14:32:29 2003  Rainer Orth  <ro at TechFak dot Uni-Bielefeld dot DE>

	* physmem.c (physmem_total) [HAVE_GETSYSINFO]: Use getsysinfo on
	Tru64 UNIX.
	(physmem_available) [HAVE_TABLE]: Use table on Tru64 UNIX.

	* configure.in (AC_CHECK_HEADERS): Check for sys/sysinfo.h,
	sys/table.h.
	(checkfuncs, AC_CHECKFUNCS): Check for getsysinfo, table.
	* configure, config.in: Regenerate.
	
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libiberty/configure.in,v
retrieving revision 1.59
diff -u -p -r1.59 configure.in
--- configure.in	21 Feb 2003 05:02:44 -0000	1.59
+++ configure.in	21 Feb 2003 19:03:12 -0000
@@ -142,7 +142,7 @@ AC_SUBST_FILE(host_makefile_frag)
 # It's OK to check for header files.  Although the compiler may not be
 # able to link anything, it had better be able to at least compile
 # something.
-AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h)
+AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysinfo.h sys/table.h)
 AC_HEADER_SYS_WAIT
 AC_HEADER_TIME
 
@@ -208,6 +208,7 @@ vars="sys_errlist sys_nerr sys_siglist"
 
 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
 checkfuncs="$checkfuncs realpath canonicalize_file_name pstat_getstatic pstat_getdynamic"
+checkfuncs="$checkfuncs getsysinfo table"
 
 # These are neither executed nor required, but they help keep
 # autoheader happy without adding a bunch of text to acconfig.h.
@@ -219,7 +220,7 @@ if test "x" = "y"; then
   AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf)
   AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal)
   AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs)
-  AC_CHECK_FUNCS(pstat_getstatic pstat_getdynamic)
+  AC_CHECK_FUNCS(pstat_getstatic pstat_getdynamic getsysinfo table)
   AC_CHECK_FUNCS(realpath canonicalize_file_name)
   AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
   AC_DEFINE(HAVE_SYS_NERR,    1, [Define if you have the sys_nerr variable.])
Index: physmem.c
===================================================================
RCS file: /cvs/gcc/gcc/libiberty/physmem.c,v
retrieving revision 1.3
diff -u -p -r1.3 physmem.c
--- physmem.c	21 Feb 2003 05:02:44 -0000	1.3
+++ physmem.c	21 Feb 2003 19:03:12 -0000
@@ -29,6 +29,15 @@
 # include <sys/pstat.h>
 #endif
 
+#if HAVE_SYS_SYSINFO_H
+#  include <sys/sysinfo.h>
+#  include <machine/hal_sysinfo.h>
+#endif
+
+#if HAVE_SYS_TABLE_H
+#  include <sys/table.h>
+#endif
+
 /* Return the total amount of physical memory.  */
 double
 physmem_total ()
@@ -55,6 +64,16 @@ physmem_total ()
   }
 #endif
 
+#if HAVE_GETSYSINFO
+  {
+    int physmem;
+
+    if (getsysinfo (GSI_PHYSMEM, (caddr_t) &physmem, sizeof (physmem),
+		    NULL, NULL, NULL) == 1)
+      return physmem * 1024;
+  }
+#endif
+
   /* Return 0 if we can't determine the value.  */
   return 0;
 }
@@ -84,6 +103,15 @@ physmem_available ()
 	if (0 <= pages && 0 <= pagesize)
 	  return pages * pagesize;
       }
+  }
+#endif
+
+#if HAVE_TABLE
+  {
+    struct tbl_vmstats vmstats;
+
+    if (table (TBL_VMSTATS, 0, &vmstats, 1, sizeof (vmstats)) == 1)
+      return vmstats.free_count * vmstats.pagesize;
   }
 #endif
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]