Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-gnome
Path: blob/main/devel/ChipmunkPhysics/files/patch-src_cpHastySpace.c
16124 views
1
--- src/cpHastySpace.c.orig 2015-07-02 16:24:47 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
@@ -314,14 +317,20 @@ cpHastySpaceSetThreads(cpSpace *space, u
18
cpHastySpace *hasty = (cpHastySpace *)space;
19
HaltThreads(hasty);
20
21
-#ifdef __APPLE__
22
if(threads == 0){
23
+#ifdef __APPLE__
24
size_t size = sizeof(threads);
25
sysctlbyname("hw.ncpu", &threads, &size, NULL, 0);
26
- }
27
+#elif defined(_SC_NPROCESSORS_ONLN)
28
+ threads = sysconf(_SC_NPROCESSORS_ONLN);
29
+#elif defined(_WIN32)
30
+ SYSTEM_INFO siSysInfo;
31
+ GetSystemInfo(&siSysInfo);
32
+ threads = siSysInfo.dwNumberOfProcessors;
33
#else
34
- if(threads == 0) threads = 1;
35
+ threads = 1;
36
#endif
37
+ }
38
39
hasty->num_threads = (threads < MAX_THREADS ? threads : MAX_THREADS);
40
hasty->num_working = hasty->num_threads - 1;
41
42