Commit 4a06f7f2 by Rainer Orth Committed by Rainer Orth

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
parent 5dc3a78c
2003-02-21 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* 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.
2003-02-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* configure.in: Check for sys/sysmp.h and sysmp.
......
......@@ -81,6 +81,9 @@
/* Define if you have the getrusage function. */
#undef HAVE_GETRUSAGE
/* Define if you have the getsysinfo function. */
#undef HAVE_GETSYSINFO
/* Define if you have the gettimeofday function. */
#undef HAVE_GETTIMEOFDAY
......@@ -183,6 +186,9 @@
/* Define if you have the sysmp function. */
#undef HAVE_SYSMP
/* Define if you have the table function. */
#undef HAVE_TABLE
/* Define if you have the times function. */
#undef HAVE_TIMES
......@@ -213,6 +219,9 @@
/* Define if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define if you have the <machine/hal_sysinfo.h> header file. */
#undef HAVE_MACHINE_HAL_SYSINFO_H
/* Define if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
......@@ -240,9 +249,15 @@
/* Define if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define if you have the <sys/sysinfo.h> header file. */
#undef HAVE_SYS_SYSINFO_H
/* Define if you have the <sys/sysmp.h> header file. */
#undef HAVE_SYS_SYSMP_H
/* Define if you have the <sys/table.h> header file. */
#undef HAVE_SYS_TABLE_H
/* Define if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
......
......@@ -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 sys/sysmp.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/sysmp.h sys/sysinfo.h machine/hal_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 sysmp"
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 sysmp)
AC_CHECK_FUNCS(pstat_getstatic pstat_getdynamic sysmp 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.])
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment