diff options
Diffstat (limited to 'cpukit/posix/include/rtems/posix/keyimpl.h')
-rw-r--r-- | cpukit/posix/include/rtems/posix/keyimpl.h | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/cpukit/posix/include/rtems/posix/keyimpl.h b/cpukit/posix/include/rtems/posix/keyimpl.h new file mode 100644 index 0000000000..33059ffeb1 --- /dev/null +++ b/cpukit/posix/include/rtems/posix/keyimpl.h @@ -0,0 +1,177 @@ +/** + * @file + * + * @brief Private Inlined Routines for POSIX Key's + * + * This include file contains the static inline implementation of the private + * inlined routines for POSIX key's. + */ + +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#include <rtems/posix/key.h> +#include <rtems/score/freechain.h> +#include <rtems/score/objectimpl.h> + +#ifndef _RTEMS_POSIX_KEYIMPL_H +#define _RTEMS_POSIX_KEYIMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup POSIX_KEY + * + * @{ + */ + +/** + * @brief POSIX_Keys_Freechain is used in Freechain structure + */ +typedef struct { + Freechain_Control super_fc; + size_t bump_count; +} POSIX_Keys_Freechain; + +/** + * @brief The information control block used to manage this class of objects. + */ +POSIX_EXTERN Objects_Information _POSIX_Keys_Information; + +/** + * @brief The rbtree control block used to manage all key values + */ +POSIX_EXTERN RBTree_Control _POSIX_Keys_Key_value_lookup_tree; + +/** + * @brief This freechain is used as a memory pool for POSIX_Keys_Key_value_pair. + */ +POSIX_EXTERN POSIX_Keys_Freechain _POSIX_Keys_Keypool; + +/** + * @brief POSIX key manager initialization. + * + * This routine performs the initialization necessary for this manager. + */ +void _POSIX_Key_Manager_initialization(void); + +/** + * @brief POSIX key Freechain extend handle + * + * This routine extend freechain node, which is called in freechain_get + * automatically. + */ +bool _POSIX_Keys_Freechain_extend(Freechain_Control *freechain); + +/** + * @brief POSIX keys Red-Black tree node comparison. + * + * This routine compares the rbtree node + */ +int _POSIX_Keys_Key_value_lookup_tree_compare_function( + const RBTree_Node *node1, + const RBTree_Node *node2 +); + +/** + * @brief Create thread-specific data POSIX key. + * + * This function executes all the destructors associated with the thread's + * keys. This function will execute until all values have been set to NULL. + * + * @param[in] thread is a pointer to the thread whose keys should have + * all their destructors run. + * + * NOTE: This is the routine executed when a thread exits to + * run through all the keys and do the destructor action. + */ +void _POSIX_Keys_Run_destructors( + Thread_Control *thread +); + +/** + * @brief Free a POSIX key table memory. + * + * This memory frees the key table memory associated with @a the_key. + * + * @param[in] the_key is a pointer to the POSIX key to free + * the table memory of. + */ +void _POSIX_Keys_Free_memory( + POSIX_Keys_Control *the_key +); + +/** + * @brief Free a POSIX keys control block. + * + * This routine frees a keys control block to the + * inactive chain of free keys control blocks. + * + * @param[in] the_key is a pointer to the POSIX key to free. + */ +RTEMS_INLINE_ROUTINE void _POSIX_Keys_Free ( + POSIX_Keys_Control *the_key +); + +/** + * @brief Allocate a keys control block. + * + * This function allocates a keys control block from + * the inactive chain of free keys control blocks. + */ + +RTEMS_INLINE_ROUTINE POSIX_Keys_Control *_POSIX_Keys_Allocate( void ) +{ + return (POSIX_Keys_Control *) _Objects_Allocate( &_POSIX_Keys_Information ); +} + +/** + * @brief Free a keys control block. + * + * This routine frees a keys control block to the + * inactive chain of free keys control blocks. + */ +RTEMS_INLINE_ROUTINE void _POSIX_Keys_Free ( + POSIX_Keys_Control *the_key +) +{ + _Objects_Free( &_POSIX_Keys_Information, &the_key->Object ); +} + +/** + * @brief Get a keys control block. + * + * This function maps key IDs to key control blocks. + * If ID corresponds to a local keys, then it returns + * the_key control pointer which maps to ID and location + * is set to OBJECTS_LOCAL. if the keys ID is global and + * resides on a remote node, then location is set to OBJECTS_REMOTE, + * and the_key is undefined. Otherwise, location is set + * to OBJECTS_ERROR and the_key is undefined. + */ + +RTEMS_INLINE_ROUTINE POSIX_Keys_Control *_POSIX_Keys_Get ( + pthread_key_t id, + Objects_Locations *location +) +{ + return (POSIX_Keys_Control *) + _Objects_Get( &_POSIX_Keys_Information, (Objects_Id) id, location ); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ |