Author: cfinck
Date: Mon Aug 27 23:00:36 2007
New Revision: 28611
URL:
http://svn.reactos.org/svn/reactos?rev=28611&view=rev
Log:
Make the cpucount utility working on Mac OS X hosts, thanks to Alex for the fix
Modified:
trunk/tools/RosBE-Unix/tools/cpucount.c
Modified: trunk/tools/RosBE-Unix/tools/cpucount.c
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/RosBE-Unix/tools/cpucount.c?…
==============================================================================
--- trunk/tools/RosBE-Unix/tools/cpucount.c (original)
+++ trunk/tools/RosBE-Unix/tools/cpucount.c Mon Aug 27 23:00:36 2007
@@ -5,16 +5,27 @@
Released under GNU GPL v2 or any later version.
*/
-#include <stdio.h>
-#include <unistd.h>
-
-int
-main(int argc,
- char *argv[])
+#include <stdio.h>
+#include <unistd.h>
+#ifdef __APPLE__
+#include <sys/sysctl.h>
+#endif
+
+int
+main(int argc,
+ char *argv[])
{
- printf( "%u\n",
- sysconf(_SC_NPROCESSORS_ONLN) );
-
- return 0;
+ int cpuCount = 0;
+
+#ifdef __APPLE__
+ size_t countSize = sizeof(cpuCount);
+
+ sysctlbyname("hw.logicalcpu", &cpuCount, &countSize, NULL, 0);
+#else
+ cpuCount = sysconf(_SC_NPROCESSORS_ONLN);
+#endif
+
+ printf( "%u\n", cpuCount);
+
+ return 0;
}
-