summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 01:21:09 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 01:21:09 +0000
commit4075c937997772e26dac372f6fbdec6100b95c99 (patch)
treeb2d09eba2bb84473872784e1eebe720cf8aff5cc /base
parent228ff746064f2d6ab77cf6802c651b2a6406d35d (diff)
downloadchromium_src-4075c937997772e26dac372f6fbdec6100b95c99.zip
chromium_src-4075c937997772e26dac372f6fbdec6100b95c99.tar.gz
chromium_src-4075c937997772e26dac372f6fbdec6100b95c99.tar.bz2
sysconf(_SC_NPROCESSORS_ONLN) is not available on some POSIX
systems, use sysctl(3) for OpenBSD Review URL: http://codereview.chromium.org/118289 Patch from Peter Valchev <pvalchev@google.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17695 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/sys_info_posix.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc
index 1d218ce..8a83f3c 100644
--- a/base/sys_info_posix.cc
+++ b/base/sys_info_posix.cc
@@ -16,12 +16,27 @@
#include <mach/mach_init.h>
#endif
+#if defined(OS_OPENBSD)
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#endif
+
#include "base/logging.h"
#include "base/string_util.h"
namespace base {
int SysInfo::NumberOfProcessors() {
+#if defined(OS_OPENBSD)
+ int mib[] = { CTL_HW, HW_NCPU };
+ int ncpu;
+ size_t size = sizeof(ncpu);
+ if (sysctl(mib, 2, &ncpu, &size, NULL, 0) == -1) {
+ NOTREACHED();
+ return 1;
+ }
+ return ncpu;
+#else
// It seems that sysconf returns the number of "logical" processors on both
// mac and linux. So we get the number of "online logical" processors.
static long res = sysconf(_SC_NPROCESSORS_ONLN);
@@ -31,6 +46,7 @@ int SysInfo::NumberOfProcessors() {
}
return static_cast<int>(res);
+#endif
}
// static