RTEMS CPU Kit with SuperCore  4.11.3
keyimpl.h
Go to the documentation of this file.
1 
10 /*
11  * COPYRIGHT (c) 1989-1999.
12  * On-Line Applications Research Corporation (OAR).
13  *
14  * The license and distribution terms for this file may be
15  * found in the file LICENSE in this distribution or at
16  * http://www.rtems.org/license/LICENSE.
17  */
18 
19 #include <rtems/posix/key.h>
20 #include <rtems/score/chainimpl.h>
21 #include <rtems/score/freechain.h>
22 #include <rtems/score/objectimpl.h>
23 #include <rtems/score/percpu.h>
24 
25 #ifndef _RTEMS_POSIX_KEYIMPL_H
26 #define _RTEMS_POSIX_KEYIMPL_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
42 
47 
52 
53 #define POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( node ) \
54  RTEMS_CONTAINER_OF( node, POSIX_Keys_Key_value_pair, Key_value_lookup_node )
55 
62 
69  const RBTree_Node *node1,
70  const RBTree_Node *node2
71 );
72 
86  Thread_Control *thread
87 );
88 
98  POSIX_Keys_Control *the_key
99 );
100 
110  POSIX_Keys_Control *the_key
111 );
112 
121 {
122  return (POSIX_Keys_Control *) _Objects_Allocate( &_POSIX_Keys_Information );
123 }
124 
132  POSIX_Keys_Control *the_key
133 )
134 {
135  _Objects_Free( &_POSIX_Keys_Information, &the_key->Object );
136 }
137 
151  pthread_key_t id,
152  Objects_Locations *location
153 )
154 {
155  return (POSIX_Keys_Control *)
156  _Objects_Get( &_POSIX_Keys_Information, (Objects_Id) id, location );
157 }
158 
159 POSIX_Keys_Key_value_pair * _POSIX_Keys_Key_value_pair_allocate( void );
160 
161 RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_pair_free(
162  POSIX_Keys_Key_value_pair *key_value_pair
163 )
164 {
165  _Freechain_Put( &_POSIX_Keys_Keypool, key_value_pair );
166 }
167 
168 RTEMS_INLINE_ROUTINE RBTree_Node *_POSIX_Keys_Find(
169  pthread_key_t key,
170  Thread_Control *thread
171 )
172 {
173  POSIX_Keys_Key_value_pair search_node;
174 
175  search_node.key = key;
176  search_node.thread = thread;
177 
178  return _RBTree_Find(
179  &_POSIX_Keys_Key_value_lookup_tree,
180  &search_node.Key_value_lookup_node,
182  true
183  );
184 }
185 
186 RTEMS_INLINE_ROUTINE void _POSIX_Keys_Free_key_value_pair(
187  POSIX_Keys_Key_value_pair *key_value_pair
188 )
189 {
191  &_POSIX_Keys_Key_value_lookup_tree,
192  &key_value_pair->Key_value_lookup_node
193  );
195  _POSIX_Keys_Key_value_pair_free( key_value_pair );
196 }
197 
200 #ifdef __cplusplus
201 }
202 #endif
203 
204 #endif
205 /* end of include file */
POSIX_EXTERN Objects_Information _POSIX_Keys_Information
The information control block used to manage this class of objects.
Definition: keyimpl.h:41
void _Objects_Free(Objects_Information *information, Objects_Control *the_object)
Frees an object.
Definition: objectfree.c:25
Objects_Control * _Objects_Allocate(Objects_Information *information)
Allocates an object.
Definition: objectallocate.c:101
#define RTEMS_INLINE_ROUTINE
The following (in conjunction with compiler arguments) are used to choose between the use of static i...
Definition: basedefs.h:135
void _POSIX_Keys_Run_destructors(Thread_Control *thread)
Create thread-specific data POSIX key.
Definition: keyrundestructors.c:37
void _POSIX_Key_Manager_initialization(void)
POSIX key manager initialization.
Definition: key.c:118
Represents POSIX key and value pair.
Definition: key.h:45
RBTree_Control _POSIX_Keys_Key_value_lookup_tree
The rbtree control block used to manage all key values.
RTEMS_INLINE_ROUTINE void _Chain_Extract_unprotected(Chain_Node *the_node)
Extract this node (unprotected).
Definition: chainimpl.h:639
RBTree_Compare_result _POSIX_Keys_Key_value_compare(const RBTree_Node *node1, const RBTree_Node *node2)
POSIX keys Red-Black tree node comparison.
Definition: key.c:47
long RBTree_Compare_result
Integer type for compare results.
Definition: rbtree.h:99
Objects_Control * _Objects_Get(Objects_Information *information, Objects_Id id, Objects_Locations *location)
Maps object ids to object control blocks.
Definition: objectget.c:23
This include file defines the per CPU information required by RTEMS.
This structure defines the Thread Control Block (TCB).
Definition: thread.h:671
RBTree_Node Key_value_lookup_node
The tree node for the lookup tree.
Definition: key.h:54
RTEMS_INLINE_ROUTINE POSIX_Keys_Control * _POSIX_Keys_Get(pthread_key_t id, Objects_Locations *location)
Get a keys control block.
Definition: keyimpl.h:150
void _Freechain_Put(Freechain_Control *freechain, void *node)
Puts a node back onto the freechain.
Definition: freechain.c:75
The following defines the structure for the information used to manage each class of objects...
Definition: objectimpl.h:136
RTEMS_INLINE_ROUTINE POSIX_Keys_Control * _POSIX_Keys_Allocate(void)
Allocate a keys control block.
Definition: keyimpl.h:120
Chain Handler API.
Chain_Node Key_values_per_thread_node
The chain node for the per-thread value chain.
Definition: key.h:49
This is used to manage a RBT.
Definition: rbtree.h:138
RTEMS_INLINE_ROUTINE void _POSIX_Keys_Free(POSIX_Keys_Control *the_key)
Free a POSIX keys control block.
Definition: keyimpl.h:131
Objects_Locations
This enumerated type lists the locations which may be returned by _Objects_Get.
Definition: objectimpl.h:117
Freechain Handler API.
Thread_Control * thread
The thread pointer used in combination with the POSIX key identifier as the tree key.
Definition: key.h:66
The data structure used to manage a POSIX key.
Definition: key.h:77
RBTree_Node * _RBTree_Find(const RBTree_Control *the_rbtree, const RBTree_Node *the_node, RBTree_Compare compare, bool is_unique)
Tries to find a node for the specified key in the tree.
Definition: rbtreefind.c:22
void _RBTree_Extract(RBTree_Control *the_rbtree, RBTree_Node *the_node)
Extracts (removes) the node from the red-black tree.
Definition: rbtreeextract.c:95
Inlined Routines in the Object Handler.
POSIX Key Private Support.
uint32_t Objects_Id
The following type defines the control block used to manage object IDs.
Definition: object.h:122
pthread_key_t key
The POSIX key identifier used in combination with the thread pointer as the tree key.
Definition: key.h:60
Objects_Control Object
This field is the Object control structure.
Definition: key.h:79
This is used to manage each element (node) which is placed on a RBT.
Definition: rbtree.h:75
void _POSIX_Keys_Free_memory(POSIX_Keys_Control *the_key)
Free a POSIX key table memory.
Definition: keyfreememory.c:25
#define POSIX_EXTERN
The following ensures that all data is declared in the space of the initialization routine for either...
Definition: basedefs.h:123
The freechain control.
Definition: freechain.h:46
POSIX_EXTERN Freechain_Control _POSIX_Keys_Keypool
This freechain is used as a memory pool for POSIX_Keys_Key_value_pair.
Definition: keyimpl.h:51