File indexing completed on 2025-05-11 08:24:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 #include <rtems/posix/key.h>
0040 #include <rtems/score/chainimpl.h>
0041 #include <rtems/score/freechainimpl.h>
0042 #include <rtems/score/objectimpl.h>
0043 #include <rtems/score/percpu.h>
0044
0045 #ifndef _RTEMS_POSIX_KEYIMPL_H
0046 #define _RTEMS_POSIX_KEYIMPL_H
0047
0048 #ifdef __cplusplus
0049 extern "C" {
0050 #endif
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061 extern Freechain_Control _POSIX_Keys_Keypool;
0062
0063 #define POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( node ) \
0064 RTEMS_CONTAINER_OF( node, POSIX_Keys_Key_value_pair, Lookup_node )
0065
0066
0067
0068
0069
0070
0071
0072
0073 static inline POSIX_Keys_Control *_POSIX_Keys_Allocate( void )
0074 {
0075 return (POSIX_Keys_Control *) _Objects_Allocate( &_POSIX_Keys_Information );
0076 }
0077
0078
0079
0080
0081
0082
0083
0084 static inline void _POSIX_Keys_Free(
0085 POSIX_Keys_Control *the_key
0086 )
0087 {
0088 _Objects_Free( &_POSIX_Keys_Information, &the_key->Object );
0089 }
0090
0091 static inline POSIX_Keys_Control *_POSIX_Keys_Get( pthread_key_t key )
0092 {
0093 return (POSIX_Keys_Control *)
0094 _Objects_Get_no_protection( (Objects_Id) key, &_POSIX_Keys_Information );
0095 }
0096
0097 static inline void _POSIX_Keys_Key_value_acquire(
0098 Thread_Control *the_thread,
0099 ISR_lock_Context *lock_context
0100 )
0101 {
0102 _ISR_lock_ISR_disable_and_acquire( &the_thread->Keys.Lock, lock_context );
0103 }
0104
0105 static inline void _POSIX_Keys_Key_value_release(
0106 Thread_Control *the_thread,
0107 ISR_lock_Context *lock_context
0108 )
0109 {
0110 _ISR_lock_Release_and_ISR_enable( &the_thread->Keys.Lock, lock_context );
0111 }
0112
0113 POSIX_Keys_Key_value_pair * _POSIX_Keys_Key_value_allocate( void );
0114
0115 static inline void _POSIX_Keys_Key_value_free(
0116 POSIX_Keys_Key_value_pair *key_value_pair
0117 )
0118 {
0119 _Chain_Extract_unprotected( &key_value_pair->Key_node );
0120 _Freechain_Put( &_POSIX_Keys_Keypool, key_value_pair );
0121 }
0122
0123 static inline bool _POSIX_Keys_Key_value_equal(
0124 const void *left,
0125 const RBTree_Node *right
0126 )
0127 {
0128 const pthread_key_t *the_left;
0129 const POSIX_Keys_Key_value_pair *the_right;
0130
0131 the_left = left;
0132 the_right = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( right );
0133
0134 return *the_left == the_right->key;
0135 }
0136
0137 static inline bool _POSIX_Keys_Key_value_less(
0138 const void *left,
0139 const RBTree_Node *right
0140 )
0141 {
0142 const pthread_key_t *the_left;
0143 const POSIX_Keys_Key_value_pair *the_right;
0144
0145 the_left = left;
0146 the_right = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( right );
0147
0148 return *the_left < the_right->key;
0149 }
0150
0151 static inline void *_POSIX_Keys_Key_value_map( RBTree_Node *node )
0152 {
0153 return POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( node );
0154 }
0155
0156 static inline POSIX_Keys_Key_value_pair *_POSIX_Keys_Key_value_find(
0157 pthread_key_t key,
0158 const Thread_Control *the_thread
0159 )
0160 {
0161 return _RBTree_Find_inline(
0162 &the_thread->Keys.Key_value_pairs,
0163 &key,
0164 _POSIX_Keys_Key_value_equal,
0165 _POSIX_Keys_Key_value_less,
0166 _POSIX_Keys_Key_value_map
0167 );
0168 }
0169
0170 static inline void _POSIX_Keys_Key_value_insert(
0171 pthread_key_t key,
0172 POSIX_Keys_Key_value_pair *key_value_pair,
0173 Thread_Control *the_thread
0174 )
0175 {
0176 _RBTree_Insert_inline(
0177 &the_thread->Keys.Key_value_pairs,
0178 &key_value_pair->Lookup_node,
0179 &key,
0180 _POSIX_Keys_Key_value_less
0181 );
0182 }
0183
0184
0185
0186 #ifdef __cplusplus
0187 }
0188 #endif
0189
0190 #endif
0191