]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
959. [port] freebsd: ncpus via sysctlbyname(). [RT #1584]
authorMark Andrews <marka@isc.org>
Thu, 16 Aug 2001 06:19:58 +0000 (06:19 +0000)
committerMark Andrews <marka@isc.org>
Thu, 16 Aug 2001 06:19:58 +0000 (06:19 +0000)
CHANGES
config.h.in
configure.in
lib/isc/unix/os.c

diff --git a/CHANGES b/CHANGES
index 0c836b2af40824346f7ff0313bd8b898d55b1a63..833142a5fa14e76fc58569fb647790318e1e78bf 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+ 959.  [port]          freebsd: ncpus via sysctlbyname().  [RT #1584]
+
  958.  [port]          ssize_t is not available on all platforms.  [RT #1607]
 
  957.  [bug]           sys/select.h inclusion was broken on older platforms.
index d1c3aed39e9873dfc6862d1fbb721c51c390be97..ef1ea35db14fb89a976e2f1d018b6cfc5b60358b 100644 (file)
@@ -16,7 +16,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: config.h.in,v 1.46 2001/08/15 06:03:39 marka Exp $ */
+/* $Id: config.h.in,v 1.47 2001/08/16 06:19:56 marka Exp $ */
 
 /***
  *** This file is not to be included by any public header files, because
@@ -66,6 +66,9 @@
 /* define if sysconf() is available */
 #undef HAVE_SYSCONF
 
+/* define if sysctlbyname() is available */
+#undef HAVE_SYSCTLBYNAME
+
 /* define if catgets() is available */
 #undef HAVE_CATGETS
 
@@ -150,6 +153,9 @@ int sigwait(const unsigned int *set, int *sig);
 /* Define if you have the <sys/select.h> header file.  */
 #undef HAVE_SYS_SELECT_H
 
+/* Define if you have the <sys/sysctl.h> header file.  */
+#undef HAVE_SYS_SYSCTL_H
+
 /* Define if you have the <sys/sockio.h> header file.  */
 #undef HAVE_SYS_SOCKIO_H
 
index 724da726c5091cc00d5ac12363af8002538ba8bc..9b2c1b55e5aecb167943fc7614d3f7362823c69a 100644 (file)
@@ -18,7 +18,7 @@ AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
 esyscmd([sed "s/^/# /" COPYRIGHT])dnl
 AC_DIVERT_POP()dnl
 
-AC_REVISION($Revision: 1.289 $)
+AC_REVISION($Revision: 1.290 $)
 
 AC_INIT(lib/dns/name.c)
 AC_PREREQ(2.13)
@@ -194,10 +194,11 @@ AC_PROG_CC
 
 AC_HEADER_STDC
 
-AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h sys/sockio.h sys/select.h)
+AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h sys/sockio.h sys/select.h sys/sysctl.h)
 
 AC_C_CONST
 AC_C_INLINE
+AC_CHECK_FUNC(sysctlbyname, AC_DEFINE(HAVE_SYSCTLBYNAME),)
 
 #
 # UnixWare 7.1.1 with the feature supplement to the UDK compiler
index b474bfc61ef5f95615db38606cf75359e1fc2397..3398f85ece11093864510b6710acbe9c33113962 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: os.c,v 1.10 2001/02/17 01:23:43 gson Exp $ */
+/* $Id: os.c,v 1.11 2001/08/16 06:19:58 marka Exp $ */
 
 #include <config.h>
 
@@ -54,6 +54,22 @@ hpux_ncpus(void) {
 
 #endif /* __hpux */
 
+#if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTLBYNAME)
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+static int
+sysctl_ncpus(void) {
+       int ncpu, result;
+       size_t len;
+
+       len = sizeof ncpu;
+       result = sysctlbyname("hw.ncpu", &ncpu, &len , 0, 0);
+       if (result != -1)
+               return (ncpu);
+       return (0);
+}
+#endif
 
 unsigned int
 isc_os_ncpus(void) {
@@ -64,7 +80,10 @@ isc_os_ncpus(void) {
 #elif defined(HAVE_SYSCONF)
        ncpus = sysconf_ncpus();
 #endif
-
+#if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTLBYNAME)
+       if (ncpus <= 0)
+               ncpus = sysctl_ncpus();
+#endif
        if (ncpus <= 0)
                ncpus = 1;