aboutsummaryrefslogtreecommitdiff
path: root/src/threading.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/threading.c')
-rw-r--r--src/threading.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/threading.c b/src/threading.c
index 8757207..84a6fcd 100644
--- a/src/threading.c
+++ b/src/threading.c
@@ -891,9 +891,16 @@ void THREAD_SET_PRIORITY( int prio)
891 891
892void THREAD_SET_AFFINITY( unsigned int aff) 892void THREAD_SET_AFFINITY( unsigned int aff)
893{ 893{
894 cpu_set_t cpuset;
895 int bit = 0; 894 int bit = 0;
895#ifdef __NetBSD__
896 cpuset_t *cpuset = cpuset_create();
897 if( cpuset == NULL)
898 _PT_FAIL( errno, "cpuset_create", __FILE__, __LINE__-2 );
899#define CPU_SET(b, s) cpuset_set(b, *(s))
900#else
901 cpu_set_t cpuset;
896 CPU_ZERO( &cpuset); 902 CPU_ZERO( &cpuset);
903#endif
897 while( aff != 0) 904 while( aff != 0)
898 { 905 {
899 if( aff & 1) 906 if( aff & 1)
@@ -905,6 +912,9 @@ void THREAD_SET_AFFINITY( unsigned int aff)
905 } 912 }
906#ifdef __ANDROID__ 913#ifdef __ANDROID__
907 PT_CALL( sched_setaffinity( pthread_self(), sizeof(cpu_set_t), &cpuset)); 914 PT_CALL( sched_setaffinity( pthread_self(), sizeof(cpu_set_t), &cpuset));
915#elif defined(__NetBSD__)
916 PT_CALL( pthread_setaffinity_np( pthread_self(), cpuset_size(cpuset), cpuset));
917 cpuset_destroy( cpuset);
908#else 918#else
909 PT_CALL( pthread_setaffinity_np( pthread_self(), sizeof(cpu_set_t), &cpuset)); 919 PT_CALL( pthread_setaffinity_np( pthread_self(), sizeof(cpu_set_t), &cpuset));
910#endif 920#endif
@@ -1001,8 +1011,10 @@ bool_t THREAD_WAIT( THREAD_T *ref, double secs , SIGNAL_T *signal_ref, MUTEX_T *
1001 { 1011 {
1002 // exact API to set the thread name is platform-dependant 1012 // exact API to set the thread name is platform-dependant
1003 // if you need to fix the build, or if you know how to fill a hole, tell me (bnt.germain@gmail.com) so that I can submit the fix in github. 1013 // if you need to fix the build, or if you know how to fill a hole, tell me (bnt.germain@gmail.com) so that I can submit the fix in github.
1004#if defined PLATFORM_BSD 1014#if defined PLATFORM_BSD && !defined __NetBSD__
1005 pthread_set_name_np( pthread_self(), _name); 1015 pthread_set_name_np( pthread_self(), _name);
1016#elif defined PLATFORM_BSD && defined __NetBSD__
1017 pthread_setname_np( pthread_self(), "%s", (void *)_name);
1006#elif defined PLATFORM_LINUX 1018#elif defined PLATFORM_LINUX
1007 #if LINUX_USE_PTHREAD_SETNAME_NP 1019 #if LINUX_USE_PTHREAD_SETNAME_NP
1008 pthread_setname_np( pthread_self(), _name); 1020 pthread_setname_np( pthread_self(), _name);