Added
Link Here
|
1 |
--- src/cpHastySpace.c.orig 2015-01-13 01:54:11 UTC |
2 |
+++ src/cpHastySpace.c |
3 |
@@ -5,8 +5,11 @@ |
4 |
#include <stdio.h> |
5 |
|
6 |
#include <pthread.h> |
7 |
-//#include <sys/param.h > |
8 |
-#include <sys/sysctl.h> |
9 |
+#ifdef _WIN32 |
10 |
+#include <windows.h> |
11 |
+#else |
12 |
+#include <unistd.h> |
13 |
+#endif |
14 |
|
15 |
#include "chipmunk/chipmunk_private.h" |
16 |
#include "chipmunk/cpHastySpace.h" |
17 |
@@ -313,15 +316,18 @@ cpHastySpaceSetThreads(cpSpace *space, u |
18 |
|
19 |
cpHastySpace *hasty = (cpHastySpace *)space; |
20 |
HaltThreads(hasty); |
21 |
- |
22 |
-#ifdef __APPLE__ |
23 |
+ |
24 |
if(threads == 0){ |
25 |
- size_t size = sizeof(threads); |
26 |
- sysctlbyname("hw.ncpu", &threads, &size, NULL, 0); |
27 |
- } |
28 |
+#if defined(_SC_NPROCESSORS_CONF) |
29 |
+ threads = sysconf(_SC_NPROCESSORS_CONF); |
30 |
+#elif defined(_WIN32) |
31 |
+ SYSTEM_INFO siSysInfo; |
32 |
+ GetSystemInfo(&siSysInfo); |
33 |
+ threads = siSysInfo.dwNumberOfProcessors; |
34 |
#else |
35 |
- if(threads == 0) threads = 1; |
36 |
+ threads = 1; |
37 |
#endif |
38 |
+ } |
39 |
|
40 |
hasty->num_threads = (threads < MAX_THREADS ? threads : MAX_THREADS); |
41 |
hasty->num_working = hasty->num_threads - 1; |