Skip to content

Commit 417c5ae

Browse files
committed
Fix crn_get_current_thread_id on BSD
1 parent fbd158b commit 417c5ae

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

crnlib/crn_threading_pthreads.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,15 @@ void crn_threading_init() {
3232
#endif
3333
}
3434

35-
crn_thread_id_t crn_get_current_thread_id() {
36-
// FIXME: Not portable
37-
return static_cast<crn_thread_id_t>(pthread_self());
35+
crn_thread_id_t crn_get_current_thread_id()
36+
{
37+
#if defined(CRN_OS_BSD4) || defined(CRN_OS_DARWIN)
38+
crn_thread_id_t id;
39+
pthread_threadid_np(pthread_self(), &id);
40+
return id;
41+
#else
42+
return static_cast<crn_thread_id_t>(pthread_self());
43+
#endif
3844
}
3945

4046
void crn_sleep(unsigned int milliseconds) {

0 commit comments

Comments
 (0)