2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-03 08:05:21 +00:00

Detect multiple CPUs on HP-UX.

This commit is contained in:
Brian Wellington
2001-01-06 01:10:04 +00:00
parent 23f7ed0b0c
commit f92f41acea

View File

@@ -15,27 +15,58 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: os.c,v 1.6 2001/01/04 02:52:13 bwelling Exp $ */ /* $Id: os.c,v 1.7 2001/01/06 01:10:04 bwelling Exp $ */
#include <config.h> #include <config.h>
#include <isc/os.h>
#ifdef HAVE_SYSCONF
#include <unistd.h> #include <unistd.h>
#include <isc/os.h> static inline long
sysconf_ncpus(void) {
#if defined(_SC_NPROCESSORS_ONLN)
return sysconf((_SC_NPROCESSORS_ONLN));
#elif defined(_SC_NPROC_ONLN)
return sysconf((_SC_NPROC_ONLN));
#endif
return (0);
}
#endif /* HAVE_SYSCONF */
#ifdef __hpux
#include <sys/pstat.h>
static inline int
hpux_ncpus(void) {
struct pst_dynamic psd;
if (pstat_getdynamic(&psd, sizeof(psd), 1, 0) != -1)
return (psd.psd_proc_cnt);
else
return (0);
}
#endif /* __hpux */
unsigned int unsigned int
isc_os_ncpus(void) { isc_os_ncpus(void) {
long ncpus = 1; long ncpus = 0;
#if defined(HAVE_SYSCONF) #ifdef __hpux
#if defined(_SC_NPROCESSORS_ONLN) ncpus = hpux_ncpus();
ncpus = sysconf(_SC_NPROCESSORS_ONLN); #elif defined(HAVE_SYSCONF)
#elif defined(_SC_NPROC_ONLN) ncpus = sysconf_ncpus();
ncpus = sysconf(_SC_NPROC_ONLN);
#endif #endif
if (ncpus <= 0) if (ncpus <= 0)
ncpus = 1; ncpus = 1;
#endif
return ((unsigned int)ncpus); return ((unsigned int)ncpus);
} }