2 * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000, 2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: os.c,v 1.11.12.6 2005/10/14 02:13:07 marka Exp $ */
32 #if defined(_SC_NPROCESSORS_ONLN)
33 return sysconf((_SC_NPROCESSORS_ONLN
));
34 #elif defined(_SC_NPROC_ONLN)
35 return sysconf((_SC_NPROC_ONLN
));
41 #endif /* HAVE_SYSCONF */
46 #include <sys/pstat.h>
50 struct pst_dynamic psd
;
51 if (pstat_getdynamic(&psd
, sizeof(psd
), 1, 0) != -1)
52 return (psd
.psd_proc_cnt
);
59 #if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTLBYNAME)
60 #include <sys/types.h> /* for FreeBSD */
61 #include <sys/param.h> /* for NetBSD */
62 #include <sys/sysctl.h>
70 result
= sysctlbyname("hw.ncpu", &ncpu
, &len
, 0, 0);
83 #elif defined(HAVE_SYSCONF)
84 ncpus
= sysconf_ncpus();
86 #if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTLBYNAME)
88 ncpus
= sysctl_ncpus();
93 return ((unsigned int)ncpus
);