diff options
author | Richard Braun <rbraun@sceen.net> | 2014-05-06 20:48:23 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2014-05-06 20:48:23 +0200 |
commit | 7dd4207f8052cd2516e55fd885b9198a35a65211 (patch) | |
tree | 043ee14a83dc8496c4d8fb07ceda113d7b5dd6c2 /kern/thread.h | |
parent | e447ec951660f8a55597758be7f6747ee772fe86 (diff) |
kern/thread: new thread_tsd_{set,get} functions
These functions allow accessing thread-local variables from a different
thread, typically before starting a thread.
Diffstat (limited to 'kern/thread.h')
-rw-r--r-- | kern/thread.h | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/kern/thread.h b/kern/thread.h index 97c4f041..a1f6ed14 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -450,15 +450,30 @@ typedef void (*thread_dtor_fn_t)(void *); void thread_key_create(unsigned int *keyp, thread_dtor_fn_t dtor); /* + * Set the pointer associated with a key for the given thread. + */ +static inline void +thread_tsd_set(struct thread *thread, unsigned int key, void *ptr) +{ + thread->tsd[key] = ptr; +} + +/* + * Return the pointer associated with a key for the given thread. + */ +static inline void * +thread_tsd_get(struct thread *thread, unsigned int key) +{ + return thread->tsd[key]; +} + +/* * Set the pointer associated with a key for the calling thread. */ static inline void thread_set_specific(unsigned int key, void *ptr) { - struct thread *self; - - self = thread_self(); - self->tsd[key] = ptr; + thread_tsd_set(thread_self(), key, ptr); } /* @@ -467,10 +482,7 @@ thread_set_specific(unsigned int key, void *ptr) static inline void * thread_get_specific(unsigned int key) { - struct thread *self; - - self = thread_self(); - return self->tsd[key]; + return thread_tsd_get(thread_self(), key); } #endif /* _KERN_THREAD_H */ |