2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +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.
*/
/* $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 <isc/os.h>
#ifdef HAVE_SYSCONF
#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
isc_os_ncpus(void) {
long ncpus = 1;
long ncpus = 0;
#if defined(HAVE_SYSCONF)
#if defined(_SC_NPROCESSORS_ONLN)
ncpus = sysconf(_SC_NPROCESSORS_ONLN);
#elif defined(_SC_NPROC_ONLN)
ncpus = sysconf(_SC_NPROC_ONLN);
#ifdef __hpux
ncpus = hpux_ncpus();
#elif defined(HAVE_SYSCONF)
ncpus = sysconf_ncpus();
#endif
if (ncpus <= 0)
ncpus = 1;
#endif
return ((unsigned int)ncpus);
}