source: rtems/cpukit/posix/include/rtems/posix/keyimpl.h @ df40cc9

4.115
Last change on this file since df40cc9 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

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

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Private Inlined Routines for POSIX Key's
5 *
6 * This include file contains the static inline implementation of the private
7 * inlined routines for POSIX key's.
8 */
9
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/freechain.h>
21#include <rtems/score/objectimpl.h>
22#include <rtems/score/percpu.h>
23
24#ifndef _RTEMS_POSIX_KEYIMPL_H
25#define _RTEMS_POSIX_KEYIMPL_H
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/**
32 * @addtogroup POSIX_KEY
33 *
34 * @{
35 */
36
37/**
38 * @brief The information control block used to manage this class of objects.
39 */
40POSIX_EXTERN Objects_Information  _POSIX_Keys_Information;
41
42/**
43 * @brief The rbtree control block used to manage all key values
44 */
45POSIX_EXTERN RBTree_Control _POSIX_Keys_Key_value_lookup_tree;
46
47/**
48 * @brief This freechain is used as a memory pool for POSIX_Keys_Key_value_pair.
49 */
50POSIX_EXTERN Freechain_Control _POSIX_Keys_Keypool;
51
52/**
53 * @brief POSIX key manager initialization.
54 *
55 * This routine performs the initialization necessary for this manager.
56 */
57void _POSIX_Key_Manager_initialization(void);
58
59/**
60 * @brief POSIX keys Red-Black tree node comparison.
61 *
62 * This routine compares the rbtree node
63 */
64int _POSIX_Keys_Key_value_lookup_tree_compare_function(
65  const RBTree_Node *node1,
66  const RBTree_Node *node2
67);
68
69/**
70 * @brief Create thread-specific data POSIX key.
71 *
72 * This function executes all the destructors associated with the thread's
73 * keys.  This function will execute until all values have been set to NULL.
74 *
75 * @param[in] thread is a pointer to the thread whose keys should have
76 *            all their destructors run.
77 *
78 * NOTE: This is the routine executed when a thread exits to
79 *       run through all the keys and do the destructor action.
80 */
81void _POSIX_Keys_Run_destructors(
82  Thread_Control *thread
83);
84
85/**
86 * @brief Free a POSIX key table memory.
87 *
88 * This memory frees the key table memory associated with @a the_key.
89 *
90 * @param[in] the_key is a pointer to the POSIX key to free
91 * the table memory of.
92 */
93void _POSIX_Keys_Free_memory(
94  POSIX_Keys_Control *the_key
95);
96
97/**
98 * @brief Free a POSIX keys control block.
99 *
100 * This routine frees a keys control block to the
101 * inactive chain of free keys control blocks.
102 *
103 * @param[in] the_key is a pointer to the POSIX key to free.
104 */
105RTEMS_INLINE_ROUTINE void _POSIX_Keys_Free (
106  POSIX_Keys_Control *the_key
107);
108
109/**
110 * @brief Allocate a keys control block.
111 *
112 * This function allocates a keys control block from
113 * the inactive chain of free keys control blocks.
114 */
115
116RTEMS_INLINE_ROUTINE POSIX_Keys_Control *_POSIX_Keys_Allocate( void )
117{
118  return (POSIX_Keys_Control *) _Objects_Allocate( &_POSIX_Keys_Information );
119}
120
121/**
122 * @brief Free a keys control block.
123 *
124 * This routine frees a keys control block to the
125 * inactive chain of free keys control blocks.
126 */
127RTEMS_INLINE_ROUTINE void _POSIX_Keys_Free (
128  POSIX_Keys_Control *the_key
129)
130{
131  _Objects_Free( &_POSIX_Keys_Information, &the_key->Object );
132}
133
134/**
135 * @brief Get a keys control block.
136 *
137 * This function maps key IDs to key control blocks.
138 * If ID corresponds to a local keys, then it returns
139 * the_key control pointer which maps to ID and location
140 * is set to OBJECTS_LOCAL.  if the keys ID is global and
141 * resides on a remote node, then location is set to OBJECTS_REMOTE,
142 * and the_key is undefined.  Otherwise, location is set
143 * to OBJECTS_ERROR and the_key is undefined.
144 */
145
146RTEMS_INLINE_ROUTINE POSIX_Keys_Control *_POSIX_Keys_Get (
147  pthread_key_t      id,
148  Objects_Locations *location
149)
150{
151  return (POSIX_Keys_Control *)
152    _Objects_Get( &_POSIX_Keys_Information, (Objects_Id) id, location );
153}
154
155RTEMS_INLINE_ROUTINE POSIX_Keys_Key_value_pair *
156_POSIX_Keys_Key_value_pair_allocate( void )
157{
158  return (POSIX_Keys_Key_value_pair *) _Freechain_Get( &_POSIX_Keys_Keypool );
159}
160
161RTEMS_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/** @} */
169
170#ifdef __cplusplus
171}
172#endif
173
174#endif
175/*  end of include file */
Note: See TracBrowser for help on using the repository browser.