source: rtems/cpukit/posix/src/keygetspecific.c @ c499856

4.11
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/**
2 * @file
3 *
4 * @brief Thread-Specific Data Management
5 * @ingroup POSIXAPI
6 */
7
8/*
9 * Copyright (c) 2012 Zhongwei Yao.
10 * COPYRIGHT (c) 1989-2007.
11 * On-Line Applications Research Corporation (OAR).
12 *
13 * The license and distribution terms for this file may be
14 * found in the file LICENSE in this distribution or at
15 * http://www.rtems.org/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <errno.h>
23#include <limits.h>
24#include <pthread.h>
25#include <string.h>
26
27#include <rtems/system.h>
28#include <rtems/score/thread.h>
29#include <rtems/score/wkspace.h>
30#include <rtems/score/rbtree.h>
31#include <rtems/posix/keyimpl.h>
32
33/*
34 *  17.1.2 Thread-Specific Data Management, P1003.1c/Draft 10, p. 165
35 */
36
37void *pthread_getspecific(
38  pthread_key_t  key
39)
40{
41  POSIX_Keys_Control          *the_key;
42  Objects_Locations            location;
43  POSIX_Keys_Key_value_pair    search_node;
44  RBTree_Node                 *p;
45  void                        *key_data;
46  POSIX_Keys_Key_value_pair   *value_pair_p;
47
48  the_key = _POSIX_Keys_Get( key, &location );
49  switch ( location ) {
50
51    case OBJECTS_LOCAL:
52      search_node.key = key;
53      search_node.thread_id = _Thread_Executing->Object.id;
54      p = _RBTree_Find( &_POSIX_Keys_Key_value_lookup_tree,
55                                    &search_node.Key_value_lookup_node );
56      key_data = NULL;
57      if ( p ) {
58        value_pair_p = _RBTree_Container_of( p,
59                                          POSIX_Keys_Key_value_pair,
60                                          Key_value_lookup_node );
61        /* key_data = _RBTree_Container_of( p, */
62        /*                                  POSIX_Keys_Key_value_pair, */
63        /*                                  Key_value_lookup_node )->value; */
64        key_data = value_pair_p->value;
65      }
66
67      _Objects_Put( &the_key->Object );
68
69      return key_data;
70
71#if defined(RTEMS_MULTIPROCESSING)
72    case OBJECTS_REMOTE:   /* should never happen */
73#endif
74    case OBJECTS_ERROR:
75      break;
76  }
77
78  return NULL;
79}
Note: See TracBrowser for help on using the repository browser.