aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2021-06-16 14:15:13 +0200
committerGitHub <noreply@github.com>2021-06-16 14:15:13 +0200
commite3cabe58aa63ef648e04dde1b634b3654d0df9ae (patch)
treed1760c1d11f26cdef877990391cffc0d980cc283
parent203790a68020186bf668b2787968aa0d901fc518 (diff)
parent1a678810b20c65dcc29f5310161ec9ce2be1cd65 (diff)
downloadlanes-e3cabe58aa63ef648e04dde1b634b3654d0df9ae.tar.gz
lanes-e3cabe58aa63ef648e04dde1b634b3654d0df9ae.tar.bz2
lanes-e3cabe58aa63ef648e04dde1b634b3654d0df9ae.zip
Merge pull request #186 from alarixbsd/master
NetBSD support
-rw-r--r--src/threading.c16
-rw-r--r--src/threading.h2
2 files changed, 15 insertions, 3 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);
diff --git a/src/threading.h b/src/threading.h
index 063cc82..9761f82 100644
--- a/src/threading.h
+++ b/src/threading.h
@@ -143,7 +143,7 @@ enum e_status { PENDING, RUNNING, WAITING, DONE, ERROR_ST, CANCELLED };
143 // 143 //
144 #if defined( PLATFORM_OSX) 144 #if defined( PLATFORM_OSX)
145 #define YIELD() pthread_yield_np() 145 #define YIELD() pthread_yield_np()
146#elif defined( PLATFORM_WIN32) || defined( PLATFORM_POCKETPC) || defined(__ANDROID__) // no PTHREAD for PLATFORM_XBOX 146#elif defined( PLATFORM_WIN32) || defined( PLATFORM_POCKETPC) || defined(__ANDROID__) || defined(__NetBSD__) // no PTHREAD for PLATFORM_XBOX
147 // for some reason win32-pthread doesn't have pthread_yield(), but sched_yield() 147 // for some reason win32-pthread doesn't have pthread_yield(), but sched_yield()
148 #define YIELD() sched_yield() 148 #define YIELD() sched_yield()
149 #else 149 #else