summaryrefslogtreecommitdiff
path: root/src/os/macosx/macos.mm
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2011-12-10 16:54:41 +0000
committermichi_cc <michi_cc@openttd.org>2011-12-10 16:54:41 +0000
commita0f3649c1abe7b831f083366e2fd91206bf23091 (patch)
tree5a352c430013c682e93d1a1b85960182cd18fbac /src/os/macosx/macos.mm
parent0ca25fb3af8fbf00607df120149b27aa7a763edb (diff)
downloadopenttd-a0f3649c1abe7b831f083366e2fd91206bf23091.tar.xz
(svn r23481) -Add: Function to get the CPU core count.
Diffstat (limited to 'src/os/macosx/macos.mm')
-rw-r--r--src/os/macosx/macos.mm17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/os/macosx/macos.mm b/src/os/macosx/macos.mm
index f6b2d4e89..7c5092403 100644
--- a/src/os/macosx/macos.mm
+++ b/src/os/macosx/macos.mm
@@ -172,3 +172,20 @@ bool GetClipboardContents(char *buffer, size_t buff_len)
return true;
}
#endif
+
+uint GetCPUCoreCount()
+{
+ uint count = 1;
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
+ if (MacOSVersionIsAtLeast(10, 5, 0)) {
+ count = [ [ NSProcessInfo processInfo ] activeProcessorCount ];
+ } else
+#endif
+ {
+#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
+ count = MPProcessorsScheduled();
+#endif
+ }
+
+ return count;
+}