Commit 6f766009 authored by Mark Andrews's avatar Mark Andrews

959. [port] freebsd: ncpus via sysctlbyname(). [RT #1584]

parent 63742a7f
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.
......
......@@ -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
......
......@@ -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
......
......@@ -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;
......
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