source: rtems/cpukit/posix/src/keygetspecific.c @ 64939bc

4.115
Last change on this file since 64939bc was 64939bc, checked in by Sebastian Huber <sebastian.huber@…>, on 07/12/14 at 19:22:22

rbtree: Reduce RBTree_Control size

Remove compare function and is unique indicator from the control
structure. Rename RBTree_Compare_function to RBTree_Compare. Rename
rtems_rbtree_compare_function to rtems_rbtree_compare. Provide C++
compatible initializers. Add compare function and is unique indicator
to _RBTree_Find(), _RBTree_Insert(), rtems_rbtree_find() and
rtems_rbtree_insert(). Remove _RBTree_Is_unique() and
rtems_rbtree_is_unique(). Remove compare function and is unique
indicator from _RBTree_Initialize_empty() and
rtems_rbtree_initialize_empty().

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[810ecf0]1/**
2 * @file
3 *
4 * @brief Thread-Specific Data Management
[5cb175bb]5 * @ingroup POSIXAPI
[810ecf0]6 */
7
[63edcf24]8/*
[b5c9064]9 * Copyright (c) 2012 Zhongwei Yao.
10 * COPYRIGHT (c) 1989-2007.
11 * On-Line Applications Research Corporation (OAR).
[feaa007]12 *
[b5c9064]13 * The license and distribution terms for this file may be
14 * found in the file LICENSE in this distribution or at
[c499856]15 * http://www.rtems.org/license/LICENSE.
[63edcf24]16 */
17
[f42b726]18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
[63edcf24]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>
[b5c9064]30#include <rtems/score/rbtree.h>
[2ad250e]31#include <rtems/posix/keyimpl.h>
[63edcf24]32
[64adc13]33/*
[63edcf24]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{
[b45b0ff7]41  POSIX_Keys_Control          *the_key;
[63edcf24]42  Objects_Locations            location;
[b5c9064]43  POSIX_Keys_Key_value_pair    search_node;
44  RBTree_Node                 *p;
[63edcf24]45  void                        *key_data;
[b5c9064]46  POSIX_Keys_Key_value_pair   *value_pair_p;
[874297f3]47
[b45b0ff7]48  the_key = _POSIX_Keys_Get( key, &location );
[63edcf24]49  switch ( location ) {
[860c34e]50
[63edcf24]51    case OBJECTS_LOCAL:
[64939bc]52      p = _POSIX_Keys_Find( key, _Thread_Executing->Object.id, &search_node );
53      if ( p != NULL ) {
[b5c9064]54        value_pair_p = _RBTree_Container_of( p,
55                                          POSIX_Keys_Key_value_pair,
56                                          Key_value_lookup_node );
57        key_data = value_pair_p->value;
[64939bc]58      } else {
59        key_data = NULL;
[b5c9064]60      }
[b45b0ff7]61
62      _Objects_Put( &the_key->Object );
63
[63edcf24]64      return key_data;
[860c34e]65
66#if defined(RTEMS_MULTIPROCESSING)
67    case OBJECTS_REMOTE:   /* should never happen */
68#endif
69    case OBJECTS_ERROR:
70      break;
[63edcf24]71  }
[860c34e]72
73  return NULL;
[63edcf24]74}
Note: See TracBrowser for help on using the repository browser.