Changeset 2605a48 in rtems


Ignore:
Timestamp:
Dec 15, 2015, 8:32:55 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
529b08a7
Parents:
190169fe
git-author:
Sebastian Huber <sebastian.huber@…> (12/15/15 08:32:55)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/03/16 09:00:56)
Message:

Optional POSIX Keys initialization

Update #2408.

Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/Makefile.am

    r190169fe r2605a48  
    155155## KEY_C_FILES
    156156libposix_a_SOURCES += src/key.c src/keycreate.c src/keydelete.c \
    157     src/keygetspecific.c src/keyfreememory.c src/keyrundestructors.c \
     157    src/keygetspecific.c src/keyfreememory.c \
    158158    src/keysetspecific.c
    159159
  • cpukit/posix/include/rtems/posix/keyimpl.h

    r190169fe r2605a48  
    3939 * @brief The information control block used to manage this class of objects.
    4040 */
    41 POSIX_EXTERN Objects_Information _POSIX_Keys_Information;
     41extern Objects_Information _POSIX_Keys_Information;
    4242
    4343/**
     
    4949 * @brief This freechain is used as a memory pool for POSIX_Keys_Key_value_pair.
    5050 */
    51 POSIX_EXTERN Freechain_Control _POSIX_Keys_Keypool;
     51extern Freechain_Control _POSIX_Keys_Keypool;
    5252
    5353#define POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( node ) \
    5454  RTEMS_CONTAINER_OF( node, POSIX_Keys_Key_value_pair, Key_value_lookup_node )
    55 
    56 /**
    57  * @brief POSIX key manager initialization.
    58  *
    59  * This routine performs the initialization necessary for this manager.
    60  */
    61 void _POSIX_Key_Manager_initialization(void);
    6255
    6356/**
     
    6962  const RBTree_Node *node1,
    7063  const RBTree_Node *node2
    71 );
    72 
    73 /**
    74  * @brief Create thread-specific data POSIX key.
    75  *
    76  * This function executes all the destructors associated with the thread's
    77  * keys.  This function will execute until all values have been set to NULL.
    78  *
    79  * @param[in] thread is a pointer to the thread whose keys should have
    80  *            all their destructors run.
    81  *
    82  * NOTE: This is the routine executed when a thread exits to
    83  *       run through all the keys and do the destructor action.
    84  */
    85 void _POSIX_Keys_Run_destructors(
    86   Thread_Control *thread
    8764);
    8865
  • cpukit/posix/src/key.c

    r190169fe r2605a48  
    2121
    2222#include <rtems/config.h>
     23#include <rtems/sysinit.h>
    2324
    2425#include <rtems/posix/keyimpl.h>
    2526#include <rtems/score/chainimpl.h>
    2627#include <rtems/score/objectimpl.h>
     28#include <rtems/score/userextimpl.h>
    2729#include <rtems/score/wkspace.h>
    2830
     31Objects_Information _POSIX_Keys_Information;
     32
    2933RBTREE_DEFINE_EMPTY( _POSIX_Keys_Key_value_lookup_tree );
     34
     35Freechain_Control _POSIX_Keys_Keypool;
    3036
    3137/**
     
    113119}
    114120
     121static void _POSIX_Keys_Run_destructors( Thread_Control *thread )
     122{
     123  Chain_Control *chain;
     124  POSIX_Keys_Key_value_pair *iter, *next;
     125  void *value;
     126  void (*destructor) (void *);
     127  POSIX_Keys_Control *the_key;
     128  Objects_Locations location;
     129
     130  chain = &thread->Key_Chain;
     131  iter = (POSIX_Keys_Key_value_pair *) _Chain_First( chain );
     132  while ( !_Chain_Is_tail( chain, &iter->Key_values_per_thread_node ) ) {
     133    next = (POSIX_Keys_Key_value_pair *)
     134      _Chain_Next( &iter->Key_values_per_thread_node );
     135
     136    the_key = _POSIX_Keys_Get( iter->key, &location );
     137    _Assert( location == OBJECTS_LOCAL );
     138
     139    /**
     140     * remove key from rbtree and chain.
     141     * here Chain_Node *iter can be convert to POSIX_Keys_Key_value_pair *,
     142     * because Chain_Node is the first member of POSIX_Keys_Key_value_pair
     143     * structure.
     144     */
     145    _RBTree_Extract(
     146        &_POSIX_Keys_Key_value_lookup_tree,
     147        &iter->Key_value_lookup_node
     148    );
     149    _Chain_Extract_unprotected( &iter->Key_values_per_thread_node );
     150
     151    destructor = the_key->destructor;
     152    value = iter->value;
     153
     154    _POSIX_Keys_Key_value_pair_free( iter );
     155
     156    _Objects_Put( &the_key->Object );
     157
     158    /**
     159     * run key value's destructor if destructor and value are both non-null.
     160     */
     161    if ( destructor != NULL && value != NULL )
     162      (*destructor)( value );
     163
     164    iter = next;
     165  }
     166}
     167
     168static User_extensions_Control _POSIX_Keys_Extensions = {
     169  .Callouts = {
     170    .thread_terminate = _POSIX_Keys_Run_destructors
     171  }
     172};
     173
    115174/**
    116175 * @brief This routine performs the initialization necessary for this manager.
    117176 */
    118 void _POSIX_Key_Manager_initialization(void)
     177static void _POSIX_Keys_Manager_initialization(void)
    119178{
    120179  _Objects_Initialize_information(
     
    136195
    137196  _POSIX_Keys_Initialize_keypool();
    138 }
     197
     198  _User_extensions_Add_API_set( &_POSIX_Keys_Extensions );
     199}
     200
     201RTEMS_SYSINIT_ITEM(
     202  _POSIX_Keys_Manager_initialization,
     203  RTEMS_SYSINIT_POSIX_KEYS,
     204  RTEMS_SYSINIT_ORDER_MIDDLE
     205);
  • cpukit/rtems/src/tasks.c

    r190169fe r2605a48  
    2929#include <rtems/rtems/modes.h>
    3030#include <rtems/rtems/tasksimpl.h>
    31 #include <rtems/posix/keyimpl.h>
    3231#include <rtems/score/stack.h>
    3332#include <rtems/score/threadimpl.h>
     
    122121    #pragma GCC diagnostic pop
    123122  #endif
    124 
    125   /*
    126    *  Run all the key destructors
    127    */
    128   _POSIX_Keys_Run_destructors( executing );
    129123}
    130124
  • cpukit/sapi/src/posixapi.c

    r190169fe r2605a48  
    2525
    2626#include <rtems/config.h>
    27 #include <rtems/posix/keyimpl.h>
    2827#include <rtems/posix/posixapi.h>
    2928
     
    5251   * Currently, there are no none type size assumptions.
    5352   */
    54 
    55   _POSIX_Key_Manager_initialization();
    5653}
  • cpukit/score/include/rtems/sysinit.h

    r190169fe r2605a48  
    5555#define RTEMS_SYSINIT_POSIX_SPINLOCK             000369
    5656#define RTEMS_SYSINIT_POSIX_CLEANUP              00036a
     57#define RTEMS_SYSINIT_POSIX_KEYS                 00036b
    5758#define RTEMS_SYSINIT_IDLE_THREADS               000380
    5859#define RTEMS_SYSINIT_BSP_LIBC                   000400
  • testsuites/sptests/spsysinit01/init.c

    r190169fe r2605a48  
    4040#include <rtems/posix/timerimpl.h>
    4141#endif /* RTEMS_POSIX_API */
     42#include <rtems/posix/keyimpl.h>
    4243#include <rtems/rtems/barrierimpl.h>
    4344#include <rtems/rtems/dpmemimpl.h>
     
    116117  POSIX_CLEANUP_POST,
    117118#endif /* RTEMS_POSIX_API */
     119  POSIX_KEYS_PRE,
     120  POSIX_KEYS_POST,
    118121  IDLE_THREADS_PRE,
    119122  IDLE_THREADS_POST,
     
    516519#endif /* RTEMS_POSIX_API */
    517520
     521FIRST(RTEMS_SYSINIT_POSIX_KEYS)
     522{
     523  assert(_POSIX_Keys_Information.maximum == 0);
     524  next_step(POSIX_KEYS_PRE);
     525}
     526
     527LAST(RTEMS_SYSINIT_POSIX_KEYS)
     528{
     529  assert(_POSIX_Keys_Information.maximum != 0);
     530  next_step(POSIX_KEYS_POST);
     531}
     532
    518533FIRST(RTEMS_SYSINIT_IDLE_THREADS)
    519534{
     
    645660#endif /* RTEMS_POSIX_API */
    646661
     662#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
     663
    647664#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
    648665
Note: See TracChangeset for help on using the changeset viewer.