openbsd-ports/games/openttd/patches/patch-src_os_unix_unix_cpp
bentley 46907ddd72 Update to openttd-1.2.3.
ok tobiasu@
2012-12-25 00:17:37 +00:00

29 lines
699 B
Plaintext

$OpenBSD: patch-src_os_unix_unix_cpp,v 1.1 2012/12/25 00:17:37 bentley Exp $
--- src/os/unix/unix.cpp.orig Sun Nov 18 01:13:52 2012
+++ src/os/unix/unix.cpp Sun Nov 18 23:04:04 2012
@@ -38,6 +38,7 @@
#endif
#ifdef HAS_SYSCTL
+#include <sys/param.h>
#include <sys/sysctl.h>
#endif
@@ -337,9 +338,16 @@ uint GetCPUCoreCount()
int ncpu = 0;
size_t len = sizeof(ncpu);
+#if defined(__OpenBSD__)
+ int mib[2];
+ mib[0] = CTL_HW;
+ mib[1] = HW_NCPU;
+ sysctl(mib, 2, &ncpu, &len, NULL, 0);
+#else
if (sysctlbyname("hw.availcpu", &ncpu, &len, NULL, 0) < 0) {
sysctlbyname("hw.ncpu", &ncpu, &len, NULL, 0);
}
+#endif
if (ncpu > 0) count = ncpu;
#elif defined(_SC_NPROCESSORS_ONLN)