Commit 170230b7 by Kaveh R. Ghazi Committed by Kaveh Ghazi

configure.in: Check for sys/sysctl.h and sysctl.

	* configure.in: Check for sys/sysctl.h and sysctl.
	* physmem.c: Add support for *bsd and darwin.
	* Makefile.in: Generate depedency for physmem.o.

Co-Authored-By: Geoffrey Keating <geoffk@apple.com>
Co-Authored-By: Richard Earnshaw <rearnsha@arm.com>

From-SVN: r63285
parent 514e19c9
2003-02-22 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
Richard Earnshaw <rearnsha@arm.com>
Geoffrey Keating <geoffk@apple.com>
* configure.in: Check for sys/sysctl.h and sysctl.
* physmem.c: Add support for *bsd and darwin.
* Makefile.in: Generate depedency for physmem.o.
2003-02-21 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> 2003-02-21 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* physmem.c (physmem_total) [HAVE_GETSYSINFO]: Use getsysinfo on * physmem.c (physmem_total) [HAVE_GETSYSINFO]: Use getsysinfo on
......
...@@ -466,6 +466,7 @@ pex-msdos.o: config.h pex-common.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \ ...@@ -466,6 +466,7 @@ pex-msdos.o: config.h pex-common.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
pex-os2.o: config.h pex-common.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h pex-os2.o: config.h pex-common.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
pex-unix.o: config.h pex-common.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h pex-unix.o: config.h pex-common.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
pex-win32.o: config.h pex-common.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h pex-win32.o: config.h pex-common.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
physmem.o: config.h $(INCDIR)/libiberty.h
putenv.o: config.h $(INCDIR)/ansidecl.h putenv.o: config.h $(INCDIR)/ansidecl.h
random.o: $(INCDIR)/ansidecl.h random.o: $(INCDIR)/ansidecl.h
regex.o: config.h $(INCDIR)/xregex.h $(INCDIR)/xregex2.h regex.o: config.h $(INCDIR)/xregex.h $(INCDIR)/xregex2.h
......
...@@ -183,6 +183,9 @@ ...@@ -183,6 +183,9 @@
/* Define if you have the sysconf function. */ /* Define if you have the sysconf function. */
#undef HAVE_SYSCONF #undef HAVE_SYSCONF
/* Define if you have the sysctl function. */
#undef HAVE_SYSCTL
/* Define if you have the sysmp function. */ /* Define if you have the sysmp function. */
#undef HAVE_SYSMP #undef HAVE_SYSMP
...@@ -249,6 +252,9 @@ ...@@ -249,6 +252,9 @@
/* Define if you have the <sys/stat.h> header file. */ /* Define if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H #undef HAVE_SYS_STAT_H
/* Define if you have the <sys/sysctl.h> header file. */
#undef HAVE_SYS_SYSCTL_H
/* Define if you have the <sys/sysinfo.h> header file. */ /* Define if you have the <sys/sysinfo.h> header file. */
#undef HAVE_SYS_SYSINFO_H #undef HAVE_SYS_SYSINFO_H
......
...@@ -1356,7 +1356,7 @@ else ...@@ -1356,7 +1356,7 @@ else
fi fi
echo "$ac_t""$CPP" 1>&6 echo "$ac_t""$CPP" 1>&6
for ac_hdr in 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 for ac_hdr in 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 sys/sysctl.h
do do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
...@@ -1739,7 +1739,7 @@ vars="sys_errlist sys_nerr sys_siglist" ...@@ -1739,7 +1739,7 @@ vars="sys_errlist sys_nerr sys_siglist"
checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday" checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
checkfuncs="$checkfuncs realpath canonicalize_file_name pstat_getstatic pstat_getdynamic sysmp" checkfuncs="$checkfuncs realpath canonicalize_file_name pstat_getstatic pstat_getdynamic sysmp"
checkfuncs="$checkfuncs getsysinfo table" checkfuncs="$checkfuncs getsysinfo table sysctl"
# These are neither executed nor required, but they help keep # These are neither executed nor required, but they help keep
# autoheader happy without adding a bunch of text to acconfig.h. # autoheader happy without adding a bunch of text to acconfig.h.
...@@ -2129,7 +2129,7 @@ else ...@@ -2129,7 +2129,7 @@ else
fi fi
done done
for ac_func in pstat_getstatic pstat_getdynamic sysmp getsysinfo table for ac_func in pstat_getstatic pstat_getdynamic sysmp getsysinfo table sysctl
do do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:2136: checking for $ac_func" >&5 echo "configure:2136: checking for $ac_func" >&5
......
...@@ -142,7 +142,7 @@ AC_SUBST_FILE(host_makefile_frag) ...@@ -142,7 +142,7 @@ AC_SUBST_FILE(host_makefile_frag)
# It's OK to check for header files. Although the compiler may not be # 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 # able to link anything, it had better be able to at least compile
# something. # 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 sys/sysinfo.h machine/hal_sysinfo.h sys/table.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 sys/sysctl.h)
AC_HEADER_SYS_WAIT AC_HEADER_SYS_WAIT
AC_HEADER_TIME AC_HEADER_TIME
...@@ -208,7 +208,7 @@ vars="sys_errlist sys_nerr sys_siglist" ...@@ -208,7 +208,7 @@ vars="sys_errlist sys_nerr sys_siglist"
checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday" checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
checkfuncs="$checkfuncs realpath canonicalize_file_name pstat_getstatic pstat_getdynamic sysmp" checkfuncs="$checkfuncs realpath canonicalize_file_name pstat_getstatic pstat_getdynamic sysmp"
checkfuncs="$checkfuncs getsysinfo table" checkfuncs="$checkfuncs getsysinfo table sysctl"
# These are neither executed nor required, but they help keep # These are neither executed nor required, but they help keep
# autoheader happy without adding a bunch of text to acconfig.h. # autoheader happy without adding a bunch of text to acconfig.h.
...@@ -220,7 +220,7 @@ if test "x" = "y"; then ...@@ -220,7 +220,7 @@ if test "x" = "y"; then
AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf) AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf)
AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal) AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal)
AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs) AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs)
AC_CHECK_FUNCS(pstat_getstatic pstat_getdynamic sysmp getsysinfo table) AC_CHECK_FUNCS(pstat_getstatic pstat_getdynamic sysmp getsysinfo table sysctl)
AC_CHECK_FUNCS(realpath canonicalize_file_name) 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_ERRLIST, 1, [Define if you have the sys_errlist variable.])
AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.]) AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
......
...@@ -42,6 +42,16 @@ ...@@ -42,6 +42,16 @@
# include <sys/table.h> # include <sys/table.h>
#endif #endif
#include <sys/types.h>
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#if HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
#endif
#include "libiberty.h" #include "libiberty.h"
/* Return the total amount of physical memory. */ /* Return the total amount of physical memory. */
...@@ -98,6 +108,18 @@ physmem_total () ...@@ -98,6 +108,18 @@ physmem_total ()
} }
#endif #endif
#if HAVE_SYSCTL && defined HW_PHYSMEM
{ /* This works on *bsd and darwin. */
unsigned int physmem;
size_t len = sizeof(physmem);
static int mib[2] = {CTL_HW, HW_PHYSMEM};
if (sysctl(mib, ARRAY_SIZE(mib), &physmem, &len, NULL, 0) == 0
&& len == sizeof (physmem))
return (double)physmem;
}
#endif
/* Return 0 if we can't determine the value. */ /* Return 0 if we can't determine the value. */
return 0; return 0;
} }
...@@ -158,6 +180,18 @@ physmem_available () ...@@ -158,6 +180,18 @@ physmem_available ()
} }
#endif #endif
#if HAVE_SYSCTL && defined HW_USERMEM
{ /* This works on *bsd and darwin. */
unsigned int usermem;
size_t len = sizeof(usermem);
static int mib[2] = {CTL_HW, HW_USERMEM};
if (sysctl(mib, ARRAY_SIZE(mib), &usermem, &len, NULL, 0) == 0
&& len == sizeof (usermem))
return (double)usermem;
}
#endif
/* Guess 25% of physical memory. */ /* Guess 25% of physical memory. */
return physmem_total () / 4; 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