Revision: 54961
          http://brlcad.svn.sourceforge.net/brlcad/?rev=54961&view=rev
Author:   brlcad
Date:     2013-03-29 05:26:26 +0000 (Fri, 29 Mar 2013)
Log Message:
-----------
expand support to freebsd, just a few changes needed

Modified Paths:
--------------
    brlcad/trunk/src/libbu/affinity.c

Modified: brlcad/trunk/src/libbu/affinity.c
===================================================================
--- brlcad/trunk/src/libbu/affinity.c   2013-03-29 05:22:50 UTC (rev 54960)
+++ brlcad/trunk/src/libbu/affinity.c   2013-03-29 05:26:26 UTC (rev 54961)
@@ -28,10 +28,18 @@
 #  include <sched.h>
 #endif
 
+#ifdef HAVE_SYS_CPUSET_H
+#  include <sys/cpuset.h>
+#endif
+
 #ifdef HAVE_PTHREAD_H
 #  include <pthread.h>
 #endif
 
+#ifdef HAVE_PTHREAD_NP_H
+#  include <pthread_np.h>
+#endif
+
 #include "bu.h"
 
 
@@ -40,23 +48,28 @@
 {
 #if defined(HAVE_PTHREAD_H)
 
-    int cpulim = bu_avail_cpus();    /* Max number of CPUs available for the 
process */
-    int status;                      /* Status of thread setting/getting */
-    int cpu = 0;                     /* Default CPU number */
-    int j;                           /* Variable for iteration. */
-
-    cpu_set_t cpuset;                          /* CPU set structure. Defined 
in sched.h */
     pthread_t curr_thread = pthread_self();    /* Get current thread */
+    int cpulim = bu_avail_cpus();              /* Max number of CPUs available 
for the process */
+    int status;                                        /* Status of thread 
setting/getting */
+    int cpu = 0;                               /* Default CPU number */
+    int j;                                     /* Variable for iteration. */
 
-    CPU_ZERO(&cpuset);
+#ifdef HAVE_CPU_SET_T
+    cpu_set_t set_of_cpus;
+#else
+    cpuset_t set_of_cpus;
+#endif
 
+
+    CPU_ZERO(&set_of_cpus);
+
     for(j = 0; j < cpulim; j++) {
        /* Set affinity mask to include CPUs 0 to max available CPU */
-       CPU_SET(j, &cpuset);
+       CPU_SET(j, &set_of_cpus);
     }
 
     /* Check current affinity mask assigned to thread */
-    status = pthread_getaffinity_np(curr_thread, sizeof(cpu_set_t), &cpuset);
+    status = pthread_getaffinity_np(curr_thread, sizeof(set_of_cpus), 
&set_of_cpus);
 
     if(status != 0) {
        /* Error in getting affinity mask */
@@ -65,7 +78,7 @@
 
     for(j = 0; j < CPU_SETSIZE; j++) {
        /* Check which set has been returned by pthread_get_affinity */
-       if(CPU_ISSET(j, &cpuset)) {
+       if(CPU_ISSET(j, &set_of_cpus)) {
            /* found affinity mask */
            cpu = j;
            break;
@@ -73,11 +86,11 @@
     }
 
     /* Clear CPU set and assign CPUs */
-    CPU_ZERO(&cpuset);
-    CPU_SET(cpu, &cpuset);
+    CPU_ZERO(&set_of_cpus);
+    CPU_SET(cpu, &set_of_cpus);
 
     /* set affinity mask of current thread */
-    status = pthread_setaffinity_np(curr_thread, sizeof(cpu_set_t), &cpuset);
+    status = pthread_setaffinity_np(curr_thread, sizeof(set_of_cpus), 
&set_of_cpus);
 
     if(status != 0) {
        /* Error in setting affinity mask */

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete 
for recognition, cash, and the chance to get your game on Steam. 
$5K grand prize plus 10 genre and skill prizes. Submit your demo 
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to