Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:12

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @brief POSIX Key Private Support
0007  *
0008  * This include file contains all the private support information for
0009  * POSIX key.
0010  */
0011 
0012 /*
0013  * Copyright (c) 2012 Zhongwei Yao.
0014  * COPYRIGHT (c) 1989-2011.
0015  * On-Line Applications Research Corporation (OAR).
0016  * Copyright (c) 2016 embedded brains GmbH & Co. KG
0017  *
0018  * Redistribution and use in source and binary forms, with or without
0019  * modification, are permitted provided that the following conditions
0020  * are met:
0021  * 1. Redistributions of source code must retain the above copyright
0022  *    notice, this list of conditions and the following disclaimer.
0023  * 2. Redistributions in binary form must reproduce the above copyright
0024  *    notice, this list of conditions and the following disclaimer in the
0025  *    documentation and/or other materials provided with the distribution.
0026  *
0027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0028  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0029  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0030  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0031  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0032  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0033  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0034  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0035  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0036  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0037  * POSSIBILITY OF SUCH DAMAGE.
0038  */
0039 
0040 #ifndef _RTEMS_POSIX_KEY_H
0041 #define _RTEMS_POSIX_KEY_H
0042 
0043 #include <pthread.h>
0044 
0045 #include <rtems/score/chain.h>
0046 #include <rtems/score/object.h>
0047 #include <rtems/score/rbtree.h>
0048 #include <rtems/score/thread.h>
0049 
0050 #ifdef __cplusplus
0051 extern "C" {
0052 #endif
0053 
0054 /**
0055  * @defgroup POSIX_KEY POSIX Key
0056  *
0057  * @ingroup POSIXAPI
0058  *
0059  */
0060 /**@{**/
0061 
0062 /**
0063  * @brief Represents POSIX key and value pair.
0064  */
0065 typedef struct {
0066   /**
0067    * @brief The chain node for the key value pairs chain in POSIX_Keys_Control.
0068    */
0069   Chain_Node Key_node;
0070 
0071   /**
0072    * @brief The tree node for the lookup tree in Thread_Keys_information.
0073    */
0074   RBTree_Node Lookup_node;
0075 
0076   /**
0077    * @brief The POSIX key identifier used as the tree key.
0078    */
0079   pthread_key_t key;
0080 
0081   /**
0082    * @brief The corresponding thread.
0083    */
0084   Thread_Control *thread;
0085 
0086   /**
0087    * @brief The thread specific POSIX key value.
0088    */
0089   void *value;
0090 } POSIX_Keys_Key_value_pair;
0091 
0092 /**
0093  * @brief The initial set of POSIX key and value pairs.
0094  *
0095  * This array is provided via <rtems/confdefs.h> in case POSIX key and value
0096  * pairs are configured.  The POSIX key and value pair count in this array must
0097  * be equal to
0098  * _Objects_Maximum_per_allocation( _POSIX_Keys_Key_value_pair_maximum ).
0099  */
0100 extern POSIX_Keys_Key_value_pair _POSIX_Keys_Key_value_pairs[];
0101 
0102 /**
0103  * @brief The POSIX key and value pairs maximum.
0104  *
0105  * This value is provided via <rtems/confdefs.h> in case POSIX key and value
0106  * pairs are configured.  The OBJECTS_UNLIMITED_OBJECTS flag may be set.
0107  */
0108 extern const uint32_t _POSIX_Keys_Key_value_pair_maximum;
0109 
0110 /**
0111  * @brief The data structure used to manage a POSIX key.
0112  */
0113 typedef struct {
0114    /** This field is the Object control structure. */
0115    Objects_Control     Object;
0116    /** This field is the data destructor. */
0117    void (*destructor) (void *);
0118 
0119    /**
0120     * @brief Key value pairs of this key.
0121     */
0122    Chain_Control Key_value_pairs;
0123  }  POSIX_Keys_Control;
0124 
0125 /**
0126  * @brief The POSIX Key objects information.
0127  */
0128 extern Objects_Information _POSIX_Keys_Information;
0129 
0130 /**
0131  * @brief Macro to define the objects information for the POSIX Key objects.
0132  *
0133  * This macro should only be used by <rtems/confdefs.h>.
0134  *
0135  * @param max The configured object maximum (the OBJECTS_UNLIMITED_OBJECTS flag
0136  * may be set).
0137  */
0138 #define POSIX_KEYS_INFORMATION_DEFINE( max ) \
0139   OBJECTS_INFORMATION_DEFINE( \
0140     _POSIX_Keys, \
0141     OBJECTS_POSIX_API, \
0142     OBJECTS_POSIX_KEYS, \
0143     POSIX_Keys_Control, \
0144     max, \
0145     OBJECTS_NO_STRING_NAME, \
0146     NULL \
0147   )
0148 
0149 /** @} */
0150 
0151 #ifdef __cplusplus
0152 }
0153 #endif
0154 
0155 #endif
0156 /*  end of include file */