summaryrefslogtreecommitdiff
path: root/graphics/osg/patches/patch-ad
blob: 90fe5595ecd2ad0baefbfa0f77fc4f83eef4196a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
$NetBSD: patch-ad,v 1.2 2012/03/07 16:27:35 adam Exp $

--- src/OpenThreads/pthreads/PThread.cpp.orig	2011-06-23 20:09:26.000000000 +0000
+++ src/OpenThreads/pthreads/PThread.cpp
@@ -135,6 +135,15 @@ private:
         {
 #if defined(__sgi)
             pthread_setrunon_np( pd->cpunum );
+#elif defined(__NetBSD__) && defined(HAVE_PTHREAD_SETAFFINITY_NP)
+            cpuset_t *cset;
+            cset = cpuset_create();
+            if (cset != NULL)
+            {
+                cpuset_set(pd->cpunum, cset);
+                pthread_setaffinity_np(pthread_self(), cpuset_size(cset), cset);
+                cpuset_destroy(cset);
+            }
 #elif defined(HAVE_PTHREAD_SETAFFINITY_NP) || defined(HAVE_THREE_PARAM_SCHED_SETAFFINITY) || defined(HAVE_TWO_PARAM_SCHED_SETAFFINITY)
             cpu_set_t cpumask;
             CPU_ZERO( &cpumask );
@@ -565,6 +574,18 @@ int Thread::setProcessorAffinity(unsigne
     status = pthread_attr_setscope( &thread_attr, PTHREAD_SCOPE_BOUND_NP );
     return status;
 
+#elif defined(__NetBSD__) && defined(HAVE_PTHREAD_SETAFFINITY_NP)
+    if (pd->isRunning && Thread::CurrentThread()==this)
+    {
+            cpuset_t *cset;
+            cset = cpuset_create();
+            if (cset != NULL)
+            {
+                cpuset_set(pd->cpunum, cset);
+                pthread_setaffinity_np(pthread_self(), cpuset_size(cset), cset);
+                cpuset_destroy(cset);
+            }
+    }
 #elif defined(HAVE_PTHREAD_SETAFFINITY_NP) || defined(HAVE_THREE_PARAM_SCHED_SETAFFINITY) || defined(HAVE_TWO_PARAM_SCHED_SETAFFINITY)
 
     if (pd->isRunning && Thread::CurrentThread()==this)
@@ -1030,7 +1051,16 @@ int OpenThreads::SetProcessorAffinityOfC
     }
     else
     {
-#if defined(HAVE_PTHREAD_SETAFFINITY_NP) || defined(HAVE_THREE_PARAM_SCHED_SETAFFINITY) || defined(HAVE_TWO_PARAM_SCHED_SETAFFINITY)
+#if defined(__NetBSD__) && defined(HAVE_PTHREAD_SETAFFINITY_NP)
+        cpuset_t *cset;
+        cset = cpuset_create();
+        if (cset != NULL)
+        {
+            cpuset_set(cpunum, cset);
+            pthread_setaffinity_np(pthread_self(), cpuset_size(cset), cset);
+            cpuset_destroy(cset);
+        }
+#elif defined(HAVE_PTHREAD_SETAFFINITY_NP) || defined(HAVE_THREE_PARAM_SCHED_SETAFFINITY) || defined(HAVE_TWO_PARAM_SCHED_SETAFFINITY)
         cpu_set_t cpumask;
         CPU_ZERO( &cpumask );
         CPU_SET( cpunum, &cpumask );