summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/keygetspecific.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/posix/src/keygetspecific.c')
-rw-r--r--cpukit/posix/src/keygetspecific.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/cpukit/posix/src/keygetspecific.c b/cpukit/posix/src/keygetspecific.c
index 0e8bbcdec8..88e084ee96 100644
--- a/cpukit/posix/src/keygetspecific.c
+++ b/cpukit/posix/src/keygetspecific.c
@@ -6,12 +6,13 @@
*/
/*
- * COPYRIGHT (c) 1989-2007.
- * On-Line Applications Research Corporation (OAR).
+ * Copyright (c) 2012 Zhongwei Yao.
+ * COPYRIGHT (c) 1989-2007.
+ * On-Line Applications Research Corporation (OAR).
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
*/
#if HAVE_CONFIG_H
@@ -26,6 +27,7 @@
#include <rtems/system.h>
#include <rtems/score/thread.h>
#include <rtems/score/wkspace.h>
+#include <rtems/score/rbtree.h>
#include <rtems/posix/key.h>
/*
@@ -36,20 +38,31 @@ void *pthread_getspecific(
pthread_key_t key
)
{
- register POSIX_Keys_Control *the_key;
- uint32_t api;
- uint32_t index;
Objects_Locations location;
+ POSIX_Keys_Key_value_pair search_node;
+ RBTree_Node *p;
void *key_data;
+ POSIX_Keys_Key_value_pair *value_pair_p;
- the_key = _POSIX_Keys_Get( key, &location );
+ _POSIX_Keys_Get( key, &location );
switch ( location ) {
case OBJECTS_LOCAL:
- api = _Objects_Get_API( _Thread_Executing->Object.id );
- index = _Objects_Get_index( _Thread_Executing->Object.id );
- key_data = (void *) the_key->Values[ api ][ index ];
- _Objects_Put( &the_key->Object );
+ search_node.key = key;
+ search_node.thread_id = _Thread_Executing->Object.id;
+ p = _RBTree_Find_unprotected( &_POSIX_Keys_Key_value_lookup_tree,
+ &search_node.Key_value_lookup_node );
+ key_data = NULL;
+ if ( p ) {
+ value_pair_p = _RBTree_Container_of( p,
+ POSIX_Keys_Key_value_pair,
+ Key_value_lookup_node );
+ /* key_data = _RBTree_Container_of( p, */
+ /* POSIX_Keys_Key_value_pair, */
+ /* Key_value_lookup_node )->value; */
+ key_data = value_pair_p->value;
+ }
+ _Thread_Enable_dispatch();
return key_data;
#if defined(RTEMS_MULTIPROCESSING)