diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-08-02 15:49:26 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-08-05 09:30:37 +0200 |
commit | 390cfcda71c5bb0d53493210bcf4a15ee29c0498 (patch) | |
tree | 52d5af466eef00d0fd8f441f130aeb05131a21c5 /cpukit/posix/src/key.c | |
parent | rbtree: Add and use RBTree_Compare_result (diff) | |
download | rtems-390cfcda71c5bb0d53493210bcf4a15ee29c0498.tar.bz2 |
posix: Simplify key implementation
Diffstat (limited to 'cpukit/posix/src/key.c')
-rw-r--r-- | cpukit/posix/src/key.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/cpukit/posix/src/key.c b/cpukit/posix/src/key.c index 67c6e27bc5..6753d57437 100644 --- a/cpukit/posix/src/key.c +++ b/cpukit/posix/src/key.c @@ -51,7 +51,8 @@ RBTree_Compare_result _POSIX_Keys_Key_value_compare( { POSIX_Keys_Key_value_pair *n1; POSIX_Keys_Key_value_pair *n2; - Objects_Id thread_id1, thread_id2; + Thread_Control *thread1; + Thread_Control *thread2; RBTree_Compare_result diff; n1 = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( node1 ); @@ -61,15 +62,18 @@ RBTree_Compare_result _POSIX_Keys_Key_value_compare( if ( diff ) return diff; - thread_id1 = n1->thread_id; - thread_id2 = n2->thread_id; + thread1 = n1->thread; + thread2 = n2->thread; - /** - * if thread_id1 or thread_id2 equals to 0, only key1 and key2 is valued. - * it enables us search node only by pthread_key_t type key. + /* + * If thread1 or thread2 equals to NULL, only key1 and key2 is valued. It + * enables us search node only by pthread_key_t type key. Exploit that the + * thread control alignment is at least two to avoid integer overflows. */ - if ( thread_id1 && thread_id2 ) - return thread_id1 - thread_id2; + if ( thread1 != NULL && thread2 != NULL ) + return (RBTree_Compare_result) ( (uintptr_t) thread1 >> 1 ) + - (RBTree_Compare_result) ( (uintptr_t) thread2 >> 1 ); + return 0; } |