From 9c7b2520c22fd7dfd4c77b25ee73e1db294fef16 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 7 Nov 2009 08:19:24 +0000 Subject: [PATCH] Added get_pthread_thread_id() function returning the Haiku thread_id of a pthread. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33927 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/kernel/OS.h | 8 ++++++++ src/system/libroot/posix/pthread/pthread.c | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/headers/os/kernel/OS.h b/headers/os/kernel/OS.h index f23a86afb0..22647f36d2 100644 --- a/headers/os/kernel/OS.h +++ b/headers/os/kernel/OS.h @@ -7,6 +7,7 @@ //! Kernel specific structures and functions +#include #include #include @@ -350,6 +351,13 @@ extern status_t _get_next_thread_info(team_id team, int32 *cookie, #define get_next_thread_info(team, cookie, info) \ _get_next_thread_info((team), (cookie), (info), sizeof(*(info))) +/* bridge to the pthread API */ +extern thread_id get_pthread_thread_id(pthread_t thread); +/* TODO: Would be nice to have, but we use TLS to associate a thread with its + pthread object. So this is not trivial to implement. +extern status_t convert_to_pthread(thread_id thread, pthread_t *_thread); +*/ + /* Time */ diff --git a/src/system/libroot/posix/pthread/pthread.c b/src/system/libroot/posix/pthread/pthread.c index 27f85feb49..5a500c72a6 100644 --- a/src/system/libroot/posix/pthread/pthread.c +++ b/src/system/libroot/posix/pthread/pthread.c @@ -232,3 +232,13 @@ pthread_setconcurrency(int newLevel) sConcurrencyLevel = newLevel; return 0; } + + +// #pragma mark - Haiku thread API bridge + + +thread_id +get_pthread_thread_id(pthread_t thread) +{ + return thread->id; +}