diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-08-02 16:22:31 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-08-05 09:30:33 +0200 |
commit | 40dcafaf80a29c20d74594853a8ff04441eabd9c (patch) | |
tree | 1541f69ee011198bd995f38069a2b1300fc4de76 /cpukit/posix | |
parent | rbtree: Rename find header in find control (diff) | |
download | rtems-40dcafaf80a29c20d74594853a8ff04441eabd9c.tar.bz2 |
Add and use RTEMS_CONTAINER_OF()
Diffstat (limited to 'cpukit/posix')
-rw-r--r-- | cpukit/posix/include/rtems/posix/keyimpl.h | 3 | ||||
-rw-r--r-- | cpukit/posix/src/key.c | 4 | ||||
-rw-r--r-- | cpukit/posix/src/keyfreememory.c | 8 | ||||
-rw-r--r-- | cpukit/posix/src/keygetspecific.c | 4 | ||||
-rw-r--r-- | cpukit/posix/src/keysetspecific.c | 5 |
5 files changed, 11 insertions, 13 deletions
diff --git a/cpukit/posix/include/rtems/posix/keyimpl.h b/cpukit/posix/include/rtems/posix/keyimpl.h index b21c1d30fc..aff9749996 100644 --- a/cpukit/posix/include/rtems/posix/keyimpl.h +++ b/cpukit/posix/include/rtems/posix/keyimpl.h @@ -49,6 +49,9 @@ extern RBTree_Control _POSIX_Keys_Key_value_lookup_tree; */ POSIX_EXTERN Freechain_Control _POSIX_Keys_Keypool; +#define POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( node ) \ + RTEMS_CONTAINER_OF( node, POSIX_Keys_Key_value_pair, Key_value_lookup_node ) + /** * @brief POSIX key manager initialization. * diff --git a/cpukit/posix/src/key.c b/cpukit/posix/src/key.c index 105706a92c..e231299c22 100644 --- a/cpukit/posix/src/key.c +++ b/cpukit/posix/src/key.c @@ -54,8 +54,8 @@ int _POSIX_Keys_Key_value_compare( Objects_Id thread_id1, thread_id2; int diff; - n1 = _RBTree_Container_of( node1, POSIX_Keys_Key_value_pair, Key_value_lookup_node ); - n2 = _RBTree_Container_of( node2, POSIX_Keys_Key_value_pair, Key_value_lookup_node ); + n1 = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( node1 ); + n2 = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( node2 ); diff = n1->key - n2->key; if ( diff ) diff --git a/cpukit/posix/src/keyfreememory.c b/cpukit/posix/src/keyfreememory.c index b419f1fc95..4e19832827 100644 --- a/cpukit/posix/src/keyfreememory.c +++ b/cpukit/posix/src/keyfreememory.c @@ -39,17 +39,17 @@ void _POSIX_Keys_Free_memory( * find the smallest thread_id node in the rbtree. */ next = _RBTree_Next( iter, RBT_LEFT ); - p = _RBTree_Container_of( next, POSIX_Keys_Key_value_pair, Key_value_lookup_node ); + p = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( next ); while ( next != NULL && p->key == key_id) { iter = next; next = _RBTree_Next( iter, RBT_LEFT ); - p = _RBTree_Container_of( next, POSIX_Keys_Key_value_pair, Key_value_lookup_node ); + p = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( next ); } /** * delete all nodes belongs to the_key from the rbtree and chain. */ - p = _RBTree_Container_of( iter, POSIX_Keys_Key_value_pair, Key_value_lookup_node ); + p = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( iter ); while ( iter != NULL && p->key == key_id ) { next = _RBTree_Next( iter, RBT_RIGHT ); _RBTree_Extract( &_POSIX_Keys_Key_value_lookup_tree, iter ); @@ -57,6 +57,6 @@ void _POSIX_Keys_Free_memory( _POSIX_Keys_Key_value_pair_free( p ); iter = next; - p = _RBTree_Container_of( iter, POSIX_Keys_Key_value_pair, Key_value_lookup_node ); + p = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( iter ); } } diff --git a/cpukit/posix/src/keygetspecific.c b/cpukit/posix/src/keygetspecific.c index 9c54112fde..f7e7b71a2c 100644 --- a/cpukit/posix/src/keygetspecific.c +++ b/cpukit/posix/src/keygetspecific.c @@ -51,9 +51,7 @@ void *pthread_getspecific( case OBJECTS_LOCAL: p = _POSIX_Keys_Find( key, _Thread_Executing->Object.id, &search_node ); if ( p != NULL ) { - value_pair_p = _RBTree_Container_of( p, - POSIX_Keys_Key_value_pair, - Key_value_lookup_node ); + value_pair_p = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( p ); key_data = value_pair_p->value; } else { key_data = NULL; diff --git a/cpukit/posix/src/keysetspecific.c b/cpukit/posix/src/keysetspecific.c index 0f7c682506..ec17d47b8a 100644 --- a/cpukit/posix/src/keysetspecific.c +++ b/cpukit/posix/src/keysetspecific.c @@ -46,10 +46,7 @@ int pthread_setspecific( case OBJECTS_LOCAL: p = _POSIX_Keys_Find( key, _Thread_Executing->Object.id, &search_node ); if ( p != NULL ) { - value_pair_ptr = _RBTree_Container_of( p, - POSIX_Keys_Key_value_pair, - Key_value_lookup_node ); - + value_pair_ptr = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( p ); value_pair_ptr->value = value; } else { value_pair_ptr = _POSIX_Keys_Key_value_pair_allocate(); |