summaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2014-04-27 13:21:30 +0000
committerfrosch <frosch@openttd.org>2014-04-27 13:21:30 +0000
commitcadfedd584694637c286c40404d1f36fae911ef9 (patch)
tree343e6050f287765b92167c633ba01d6159bc7139 /src/os
parent631e8b45fd7bbd95766ee294304fad38dda946dc (diff)
downloadopenttd-cadfedd584694637c286c40404d1f36fae911ef9.tar.xz
(svn r26523) -Fix [FS#5992]: OpenBSD compilation (MagisterQuis)
Diffstat (limited to 'src/os')
-rw-r--r--src/os/unix/unix.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp
index 4020aeba2..ebae5c244 100644
--- a/src/os/unix/unix.cpp
+++ b/src/os/unix/unix.cpp
@@ -340,9 +340,18 @@ uint GetCPUCoreCount()
int ncpu = 0;
size_t len = sizeof(ncpu);
+#ifdef OPENBSD
+ int name[2];
+ name[0] = CTL_HW;
+ name[1] = HW_NCPU;
+ if (sysctl(name, 2, &ncpu, &len, NULL, 0) < 0) {
+ ncpu = 0;
+ }
+#else
if (sysctlbyname("hw.availcpu", &ncpu, &len, NULL, 0) < 0) {
sysctlbyname("hw.ncpu", &ncpu, &len, NULL, 0);
}
+#endif /* #ifdef OPENBSD */
if (ncpu > 0) count = ncpu;
#elif defined(_SC_NPROCESSORS_ONLN)