[PATCH 1/3] Add and use RTEMS_CONTAINER_OF()

Sebastian Huber sebastian.huber at embedded-brains.de
Sun Aug 3 12:45:04 UTC 2014


---
 cpukit/libblock/src/bdbuf.c                        |  4 +-
 cpukit/posix/include/rtems/posix/keyimpl.h         |  3 ++
 cpukit/posix/src/key.c                             |  4 +-
 cpukit/posix/src/keyfreememory.c                   |  8 ++--
 cpukit/posix/src/keygetspecific.c                  |  4 +-
 cpukit/posix/src/keysetspecific.c                  |  5 +--
 cpukit/sapi/include/rtems/rbheap.h                 |  2 +-
 cpukit/sapi/include/rtems/rbtree.h                 | 10 -----
 cpukit/score/include/rtems/score/basedefs.h        | 10 +++++
 cpukit/score/include/rtems/score/mrspimpl.h        |  2 +-
 cpukit/score/include/rtems/score/rbtree.h          | 14 -------
 .../score/include/rtems/score/scheduleredfimpl.h   |  2 +-
 cpukit/score/include/rtems/score/schedulerimpl.h   |  2 +-
 cpukit/score/include/rtems/score/threadimpl.h      | 18 ++++-----
 cpukit/score/src/resourceiterate.c                 |  6 +--
 cpukit/score/src/schedulerchangeroot.c             |  2 +-
 cpukit/score/src/scheduleredf.c                    |  4 +-
 cpukit/score/src/threadq.c                         | 12 +++---
 cpukit/score/src/threadqdequeue.c                  |  2 +-
 cpukit/score/src/threadqfirst.c                    |  5 ++-
 testsuites/sptests/sprbtree01/init.c               | 44 +++++++++++-----------
 21 files changed, 72 insertions(+), 91 deletions(-)

diff --git a/cpukit/libblock/src/bdbuf.c b/cpukit/libblock/src/bdbuf.c
index 31dd289..f215911 100644
--- a/cpukit/libblock/src/bdbuf.c
+++ b/cpukit/libblock/src/bdbuf.c
@@ -3178,8 +3178,8 @@ rtems_bdbuf_read_ahead_task (rtems_task_argument arg)
 
     while ((node = rtems_chain_get_unprotected (chain)) != NULL)
     {
-      rtems_disk_device *dd = (rtems_disk_device *)
-        ((char *) node - offsetof (rtems_disk_device, read_ahead.node));
+      rtems_disk_device *dd =
+        RTEMS_CONTAINER_OF (node, rtems_disk_device, read_ahead.node);
       rtems_blkdev_bnum block = dd->read_ahead.next;
       rtems_blkdev_bnum media_block = 0;
       rtems_status_code sc =
diff --git a/cpukit/posix/include/rtems/posix/keyimpl.h b/cpukit/posix/include/rtems/posix/keyimpl.h
index b21c1d3..aff9749 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 105706a..e231299 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 b419f1f..4e19832 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 9c54112..f7e7b71 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 0f7c682..ec17d47 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();
diff --git a/cpukit/sapi/include/rtems/rbheap.h b/cpukit/sapi/include/rtems/rbheap.h
index 7c44f11..0848b69 100644
--- a/cpukit/sapi/include/rtems/rbheap.h
+++ b/cpukit/sapi/include/rtems/rbheap.h
@@ -254,7 +254,7 @@ void rtems_rbheap_extend_descriptors_with_malloc(
 /* Private API */
 
 #define rtems_rbheap_chunk_of_node(node) \
-  rtems_rbtree_container_of(node, rtems_rbheap_chunk, tree_node)
+  RTEMS_CONTAINER_OF(node, rtems_rbheap_chunk, tree_node)
 
 static inline bool rtems_rbheap_is_chunk_free(const rtems_rbheap_chunk *chunk)
 {
diff --git a/cpukit/sapi/include/rtems/rbtree.h b/cpukit/sapi/include/rtems/rbtree.h
index 4e6d852..eaf2b6e 100644
--- a/cpukit/sapi/include/rtems/rbtree.h
+++ b/cpukit/sapi/include/rtems/rbtree.h
@@ -74,16 +74,6 @@ typedef RBTree_Compare rtems_rbtree_compare;
   RBTREE_DEFINE_EMPTY(name)
 
 /**
-  * @brief macro to return the structure containing the @a node.
-  *
-  * This macro returns a pointer of type @a object_type that points 
-  * to the structure containing @a node, where @a object_member is the 
-  * field name of the rtems_rbtree_node structure in objects of @a object_type.
-  */
-#define rtems_rbtree_container_of(node,object_type, object_member) \
-  _RBTree_Container_of(node,object_type,object_member)
-
-/**
  * @brief Initialize a RBTree header.
  *
  * This routine initializes @a the_rbtree structure to manage the
diff --git a/cpukit/score/include/rtems/score/basedefs.h b/cpukit/score/include/rtems/score/basedefs.h
index 382a97a..ec93951 100644
--- a/cpukit/score/include/rtems/score/basedefs.h
+++ b/cpukit/score/include/rtems/score/basedefs.h
@@ -217,6 +217,16 @@
  */
 #define RTEMS_ZERO_LENGTH_ARRAY 0
 
+/**
+ * @brief Returns a pointer to the container of a specified member pointer.
+ *
+ * @param[in] _m The pointer to a member of the container.
+ * @param[in] _type The type of the container.
+ * @param[in] _member_name The designator name of the container member.
+ */
+#define RTEMS_CONTAINER_OF( _m, _type, _member_name ) \
+  ( (_type *) ( (uintptr_t) ( _m ) - offsetof( _type, _member_name ) ) )
+
 #ifndef ASM
   #ifdef RTEMS_DEPRECATED_TYPES
     typedef bool boolean;
diff --git a/cpukit/score/include/rtems/score/mrspimpl.h b/cpukit/score/include/rtems/score/mrspimpl.h
index 4aaa50b..1571594 100644
--- a/cpukit/score/include/rtems/score/mrspimpl.h
+++ b/cpukit/score/include/rtems/score/mrspimpl.h
@@ -181,7 +181,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Wait_for_ownership(
 
   _Scheduler_Thread_change_resource_root(
     executing,
-    _Thread_Resource_node_to_thread( _Resource_Node_get_root( owner ) )
+    THREAD_RESOURCE_NODE_TO_THREAD( _Resource_Node_get_root( owner ) )
   );
 
   if ( timeout > 0 ) {
diff --git a/cpukit/score/include/rtems/score/rbtree.h b/cpukit/score/include/rtems/score/rbtree.h
index c4effce..d23808f 100644
--- a/cpukit/score/include/rtems/score/rbtree.h
+++ b/cpukit/score/include/rtems/score/rbtree.h
@@ -82,20 +82,6 @@ struct RBTree_Node_struct {
 };
 
 /**
- * @brief Macro to return the structure containing the @a node.
- *
- * This macro returns a pointer of type @a container_type that points
- * to the structure containing @a node, where @a node_field_name is the
- * field name of the RBTree_Node structure in @a container_type.
- *
- */
-#define _RBTree_Container_of(node, container_type, node_field_name) \
-( \
-  (container_type*) \
-    ( (uintptr_t)(node) - offsetof(container_type, node_field_name) ) \
-)
-
-/**
  *  This type indicates the direction.
  */
 typedef enum {
diff --git a/cpukit/score/include/rtems/score/scheduleredfimpl.h b/cpukit/score/include/rtems/score/scheduleredfimpl.h
index 019c544..50e40bc 100644
--- a/cpukit/score/include/rtems/score/scheduleredfimpl.h
+++ b/cpukit/score/include/rtems/score/scheduleredfimpl.h
@@ -89,7 +89,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Schedule_body(
     _Scheduler_EDF_Get_context( scheduler );
   RBTree_Node *first = _RBTree_First( &context->Ready, RBT_LEFT );
   Scheduler_EDF_Node *node =
-    _RBTree_Container_of(first, Scheduler_EDF_Node, Node);
+    RTEMS_CONTAINER_OF( first, Scheduler_EDF_Node, Node );
   Thread_Control *heir = node->thread;
 
   ( void ) the_thread;
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index 4f71408..45a2f8d 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -164,7 +164,7 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_Ask_for_help_visitor(
   Thread_Control *previous_needs_help = help_context->needs_help;
   Thread_Control *next_needs_help;
   Thread_Control *offers_help =
-    _Thread_Resource_node_to_thread( resource_node );
+    THREAD_RESOURCE_NODE_TO_THREAD( resource_node );
   const Scheduler_Control *scheduler = _Scheduler_Get_own( offers_help );
 
   next_needs_help = ( *scheduler->Operations.ask_for_help )(
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index a527c8b..9321c01 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -76,6 +76,14 @@ SCORE_EXTERN Thread_Control *_Thread_Allocated_fp;
 SCORE_EXTERN struct _reent **_Thread_libc_reent;
 #endif
 
+#define THREAD_RBTREE_NODE_TO_THREAD( node ) \
+  RTEMS_CONTAINER_OF( node, Thread_Control, RBNode )
+
+#if defined(RTEMS_SMP)
+#define THREAD_RESOURCE_NODE_TO_THREAD( node ) \
+  RTEMS_CONTAINER_OF( node, Thread_Control, Resource_node )
+#endif
+
 /**
  *  @brief Initialize thread handler.
  *
@@ -846,16 +854,6 @@ RTEMS_INLINE_ROUTINE bool _Thread_Owns_resources(
   return owns_resources;
 }
 
-#if defined(RTEMS_SMP)
-RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Resource_node_to_thread(
-  Resource_Node *node
-)
-{
-  return (Thread_Control *)
-    ( (char *) node - offsetof( Thread_Control, Resource_node ) );
-}
-#endif
-
 RTEMS_INLINE_ROUTINE void _Thread_Debug_set_real_processor(
   Thread_Control  *the_thread,
   Per_CPU_Control *cpu
diff --git a/cpukit/score/src/resourceiterate.c b/cpukit/score/src/resourceiterate.c
index 26f9234..ac8b8b0 100644
--- a/cpukit/score/src/resourceiterate.c
+++ b/cpukit/score/src/resourceiterate.c
@@ -16,14 +16,12 @@
 
 static Resource_Control *_Resource_Rival_head_to_resource( Chain_Node *head )
 {
-  return (Resource_Control *)
-    ( (char *) head - offsetof( Resource_Control, Rivals.Head.Node ) );
+  return RTEMS_CONTAINER_OF( head, Resource_Control, Rivals.Head.Node );
 }
 
 static Resource_Node *_Resource_Resource_tail_to_rival( Chain_Node *tail )
 {
-  return (Resource_Node *)
-    ( (char *) tail - offsetof( Resource_Node, Resources.Tail.Node ) );
+  return RTEMS_CONTAINER_OF( tail, Resource_Node, Resources.Tail.Node );
 }
 
 void _Resource_Iterate(
diff --git a/cpukit/score/src/schedulerchangeroot.c b/cpukit/score/src/schedulerchangeroot.c
index eba852b..f731117 100644
--- a/cpukit/score/src/schedulerchangeroot.c
+++ b/cpukit/score/src/schedulerchangeroot.c
@@ -32,7 +32,7 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_Set_root_visitor(
   Thread_Control *root = ctx->root;
   Thread_Control *needs_help = root;
   Thread_Control *offers_help =
-    _Thread_Resource_node_to_thread( resource_node );
+    THREAD_RESOURCE_NODE_TO_THREAD( resource_node );
   const Scheduler_Control *scheduler = _Scheduler_Get_own( offers_help );
   Thread_Control *needs_help_too;
 
diff --git a/cpukit/score/src/scheduleredf.c b/cpukit/score/src/scheduleredf.c
index 01b5244..231bc04 100644
--- a/cpukit/score/src/scheduleredf.c
+++ b/cpukit/score/src/scheduleredf.c
@@ -25,9 +25,9 @@ int _Scheduler_EDF_Compare(
   const RBTree_Node* n2
 )
 {
-  Priority_Control value1 = _RBTree_Container_of
+  Priority_Control value1 = RTEMS_CONTAINER_OF
     (n1,Scheduler_EDF_Node,Node)->thread->current_priority;
-  Priority_Control value2 = _RBTree_Container_of
+  Priority_Control value2 = RTEMS_CONTAINER_OF
     (n2,Scheduler_EDF_Node,Node)->thread->current_priority;
 
   /*
diff --git a/cpukit/score/src/threadq.c b/cpukit/score/src/threadq.c
index 0ffbfad..b146ad4 100644
--- a/cpukit/score/src/threadq.c
+++ b/cpukit/score/src/threadq.c
@@ -20,19 +20,19 @@
 
 #include <rtems/score/threadqimpl.h>
 #include <rtems/score/chainimpl.h>
-#include <rtems/score/scheduler.h>
-
 #include <rtems/score/rbtreeimpl.h>
+#include <rtems/score/scheduler.h>
+#include <rtems/score/threadimpl.h>
 
 int _Thread_queue_Compare_priority(
   const RBTree_Node *left,
   const RBTree_Node *right
 )
 {
-  Priority_Control left_priority = _RBTree_Container_of
-    (left,Thread_Control,RBNode)->current_priority;
-  Priority_Control right_priority = _RBTree_Container_of
-    (right,Thread_Control,RBNode)->current_priority;
+  Priority_Control left_priority =
+    THREAD_RBTREE_NODE_TO_THREAD( left )->current_priority;
+  Priority_Control right_priority =
+    THREAD_RBTREE_NODE_TO_THREAD( right )->current_priority;
 
   /*
    * SuperCore priorities use lower numbers to indicate greater importance.
diff --git a/cpukit/score/src/threadqdequeue.c b/cpukit/score/src/threadqdequeue.c
index d745ef2..e364aa9 100644
--- a/cpukit/score/src/threadqdequeue.c
+++ b/cpukit/score/src/threadqdequeue.c
@@ -50,7 +50,7 @@ Thread_Control *_Thread_queue_Dequeue(
 
     first = _RBTree_Get( &the_thread_queue->Queues.Priority, RBT_LEFT );
     if ( first ) {
-      the_thread = _RBTree_Container_of( first, Thread_Control, RBNode );
+      the_thread = THREAD_RBTREE_NODE_TO_THREAD( first );
     }
   }
 
diff --git a/cpukit/score/src/threadqfirst.c b/cpukit/score/src/threadqfirst.c
index 39f7c3f..5d97ae1 100644
--- a/cpukit/score/src/threadqfirst.c
+++ b/cpukit/score/src/threadqfirst.c
@@ -18,9 +18,10 @@
 #include "config.h"
 #endif
 
+#include <rtems/score/threadqimpl.h>
 #include <rtems/score/chainimpl.h>
 #include <rtems/score/isrlevel.h>
-#include <rtems/score/threadqimpl.h>
+#include <rtems/score/threadimpl.h>
 
 Thread_Control *_Thread_queue_First(
   Thread_queue_Control *the_thread_queue
@@ -41,7 +42,7 @@ Thread_Control *_Thread_queue_First(
 
     first = _RBTree_First( &the_thread_queue->Queues.Priority, RBT_LEFT );
     if ( first )
-      thread = _RBTree_Container_of( first, Thread_Control, RBNode );
+      thread = THREAD_RBTREE_NODE_TO_THREAD( first );
   }
 
   _ISR_Enable( level );
diff --git a/testsuites/sptests/sprbtree01/init.c b/testsuites/sptests/sprbtree01/init.c
index c43871a..d78790f 100644
--- a/testsuites/sptests/sprbtree01/init.c
+++ b/testsuites/sptests/sprbtree01/init.c
@@ -38,8 +38,8 @@ static int test_compare_function (
   const rtems_rbtree_node *n2
 )
 {
-  int key1 = rtems_rbtree_container_of( n1, test_node, Node )->key;
-  int key2 = rtems_rbtree_container_of( n2, test_node, Node )->key;
+  int key1 = RTEMS_CONTAINER_OF( n1, test_node, Node )->key;
+  int key2 = RTEMS_CONTAINER_OF( n2, test_node, Node )->key;
 
   return key1 - key2;
 }
@@ -262,7 +262,7 @@ rtems_task Init( rtems_task_argument ignored )
 
   for ( p = rtems_rbtree_get_min(&rbtree1), id = 1 ; p ;
       p = rtems_rbtree_get_min(&rbtree1) , id++ ) {
-    test_node *t = rtems_rbtree_container_of(p,test_node,Node);
+    test_node *t = RTEMS_CONTAINER_OF(p,test_node,Node);
     if ( id > 2 ) {
       puts( "INIT - TOO MANY NODES ON RBTREE" );
       rtems_test_exit(0);
@@ -290,7 +290,7 @@ rtems_task Init( rtems_task_argument ignored )
 
   for ( p = rtems_rbtree_get_min(&rbtree1), id = 1 ; p ;
       p = rtems_rbtree_get_min(&rbtree1) , id++ ) {
-    test_node *t = rtems_rbtree_container_of(p,test_node,Node);
+    test_node *t = RTEMS_CONTAINER_OF(p,test_node,Node);
     if ( id > 1 ) {
       puts( "INIT - TOO MANY NODES ON RBTREE" );
       rtems_test_exit(0);
@@ -345,9 +345,9 @@ rtems_task Init( rtems_task_argument ignored )
   rb_insert_unique( &rbtree1, &node2.Node );
 
   puts( "INIT - Verify rtems_rbtree_peek_max/min, rtems_rbtree_extract" );
-  test_node *t1 = rtems_rbtree_container_of(rtems_rbtree_peek_max(&rbtree1),
+  test_node *t1 = RTEMS_CONTAINER_OF(rtems_rbtree_peek_max(&rbtree1),
          test_node,Node);
-  test_node *t2 = rtems_rbtree_container_of(rtems_rbtree_peek_min(&rbtree1),
+  test_node *t2 = RTEMS_CONTAINER_OF(rtems_rbtree_peek_min(&rbtree1),
          test_node,Node);
   if (t1->key - t2->key != 1) {
     puts( "INIT - Peek Min - Max failed" );
@@ -355,7 +355,7 @@ rtems_task Init( rtems_task_argument ignored )
   }
   p = rtems_rbtree_peek_max(&rbtree1);
   rtems_rbtree_extract(&rbtree1, p);
-  t1 = rtems_rbtree_container_of(p,test_node,Node);
+  t1 = RTEMS_CONTAINER_OF(p,test_node,Node);
   if (t1->key != 2) {
     puts( "INIT - rtems_rbtree_extract failed");
     rtems_test_exit(0);
@@ -365,7 +365,7 @@ rtems_task Init( rtems_task_argument ignored )
 
   for ( p = rtems_rbtree_get_min(&rbtree1), id = 1 ; p ;
       p = rtems_rbtree_get_min(&rbtree1) , id++ ) {
-    test_node *t = rtems_rbtree_container_of(p,test_node,Node);
+    test_node *t = RTEMS_CONTAINER_OF(p,test_node,Node);
     if ( id > 2 ) {
       puts( "INIT - TOO MANY NODES ON RBTREE" );
       rtems_test_exit(0);
@@ -390,7 +390,7 @@ rtems_task Init( rtems_task_argument ignored )
 
   for ( p = rtems_rbtree_get_min(&rbtree1), id = 0 ; p ;
       p = rtems_rbtree_get_min(&rbtree1) , id++ ) {
-    test_node *t = rtems_rbtree_container_of(p,test_node,Node);
+    test_node *t = RTEMS_CONTAINER_OF(p,test_node,Node);
     if ( id > 99 ) {
       puts( "INIT - TOO MANY NODES ON RBTREE" );
       rtems_test_exit(0);
@@ -423,7 +423,7 @@ rtems_task Init( rtems_task_argument ignored )
 
   for ( p = rtems_rbtree_get_min(&rbtree1), id = 0 ; p ;
       p = rtems_rbtree_get_min(&rbtree1) , id++ ) {
-    test_node *t = rtems_rbtree_container_of(p,test_node,Node);
+    test_node *t = RTEMS_CONTAINER_OF(p,test_node,Node);
     if ( id > 99 ) {
       puts( "INIT - TOO MANY NODES ON RBTREE" );
       rtems_test_exit(0);
@@ -467,7 +467,7 @@ rtems_task Init( rtems_task_argument ignored )
 
   for ( p = rtems_rbtree_get_min(&rbtree1), id = 0, i = 0 ; p ;
       p = rtems_rbtree_get_min(&rbtree1) , id++ ) {
-    test_node *t = rtems_rbtree_container_of(p, test_node, Node);
+    test_node *t = RTEMS_CONTAINER_OF(p, test_node, Node);
 
     while ( id == numbers_sorted[i] ) {
       /* skip if expected minimum (id) is in the set of extracted numbers */
@@ -529,7 +529,7 @@ rtems_task Init( rtems_task_argument ignored )
 
   for ( p = rtems_rbtree_get_max(&rbtree1), id = 0 ; p ;
       p = rtems_rbtree_get_max(&rbtree1) , id++ ) {
-    test_node *t = rtems_rbtree_container_of(p,test_node,Node);
+    test_node *t = RTEMS_CONTAINER_OF(p,test_node,Node);
     if ( id > 99 ) {
       puts( "INIT - TOO MANY NODES ON RBTREE" );
       rtems_test_exit(0);
@@ -561,20 +561,20 @@ rtems_task Init( rtems_task_argument ignored )
   puts( "INIT - Verify rtems_rbtree_find" );
   search_node.key = 30;
   p = rb_find_unique(&rbtree1, &search_node.Node);
-  if(rtems_rbtree_container_of(p,test_node,Node)->id != 30) {
+  if(RTEMS_CONTAINER_OF(p,test_node,Node)->id != 30) {
     puts ("INIT - ERROR ON RBTREE ID MISMATCH");
     rtems_test_exit(0);
   }
 
   puts( "INIT - Verify rtems_rbtree_predecessor/successor");
   p = rtems_rbtree_predecessor(p);
-  if(p && rtems_rbtree_container_of(p,test_node,Node)->id != 29) {
+  if(p && RTEMS_CONTAINER_OF(p,test_node,Node)->id != 29) {
     puts ("INIT - ERROR ON RBTREE ID MISMATCH");
     rtems_test_exit(0);
   }
   p = rb_find_unique(&rbtree1, &search_node.Node);
   p = rtems_rbtree_successor(p);
-  if(p && rtems_rbtree_container_of(p,test_node,Node)->id != 31) {
+  if(p && RTEMS_CONTAINER_OF(p,test_node,Node)->id != 31) {
     puts ("INIT - ERROR ON RBTREE ID MISMATCH");
     rtems_test_exit(0);
   }
@@ -601,7 +601,7 @@ rtems_task Init( rtems_task_argument ignored )
 
   for ( p = rtems_rbtree_get_max(&rbtree1), id = 99 ; p ;
       p = rtems_rbtree_get_max(&rbtree1) , id-- ) {
-    test_node *t = rtems_rbtree_container_of(p,test_node,Node);
+    test_node *t = RTEMS_CONTAINER_OF(p,test_node,Node);
     if ( id < 0 ) {
       puts( "INIT - TOO MANY NODES ON RBTREE" );
       rtems_test_exit(0);
@@ -634,7 +634,7 @@ rtems_task Init( rtems_task_argument ignored )
 
   for ( p = rtems_rbtree_get_min(&rbtree1), id = 0 ; p ;
       p = rtems_rbtree_get_min(&rbtree1) , id++ ) {
-    test_node *t = rtems_rbtree_container_of(p,test_node,Node);
+    test_node *t = RTEMS_CONTAINER_OF(p,test_node,Node);
     if ( id > 19 ) {
       puts( "INIT - TOO MANY NODES ON RBTREE" );
       rtems_test_exit(0);
@@ -666,7 +666,7 @@ rtems_task Init( rtems_task_argument ignored )
 
   for ( p = rtems_rbtree_get_min(&rbtree1), id = 0 ; p ;
       p = rtems_rbtree_get_min(&rbtree1) , id++ ) {
-    test_node *t = rtems_rbtree_container_of(p,test_node,Node);
+    test_node *t = RTEMS_CONTAINER_OF(p,test_node,Node);
     if ( id > 99 ) {
       puts( "INIT - TOO MANY NODES ON RBTREE" );
       rtems_test_exit(0);
@@ -703,7 +703,7 @@ rtems_task Init( rtems_task_argument ignored )
   puts( "INIT - Verify rtems_rbtree_find in a duplicate tree" );
   search_node.key = 2;
   p = rb_find_multi(&rbtree1, &search_node.Node);
-  if(rtems_rbtree_container_of(p,test_node,Node)->id != 2) {
+  if(RTEMS_CONTAINER_OF(p,test_node,Node)->id != 2) {
     puts ("INIT - ERROR ON RBTREE ID MISMATCH");
     rtems_test_exit(0);
   }
@@ -712,7 +712,7 @@ rtems_task Init( rtems_task_argument ignored )
 
   for ( p = rtems_rbtree_get_min(&rbtree1), id = 0 ; p ;
       p = rtems_rbtree_get_min(&rbtree1) , id++ ) {
-    test_node *t = rtems_rbtree_container_of(p,test_node,Node);
+    test_node *t = RTEMS_CONTAINER_OF(p,test_node,Node);
     if ( id > 99 ) {
       puts( "INIT - TOO MANY NODES ON RBTREE" );
       rtems_test_exit(0);
@@ -744,7 +744,7 @@ rtems_task Init( rtems_task_argument ignored )
   puts( "INIT - Verify rtems_rbtree_find in a duplicate tree" );
   search_node.key = 2;
   p = rb_find_multi(&rbtree1, &search_node.Node);
-  if(rtems_rbtree_container_of(p,test_node,Node)->id != 97) {
+  if(RTEMS_CONTAINER_OF(p,test_node,Node)->id != 97) {
     puts ("INIT - ERROR ON RBTREE ID MISMATCH");
     rtems_test_exit(0);
   }
@@ -753,7 +753,7 @@ rtems_task Init( rtems_task_argument ignored )
 
   for ( p = rtems_rbtree_get_min(&rbtree1), id = 0 ; p ;
       p = rtems_rbtree_get_min(&rbtree1) , id++ ) {
-    test_node *t = rtems_rbtree_container_of(p,test_node,Node);
+    test_node *t = RTEMS_CONTAINER_OF(p,test_node,Node);
     if ( id > 99 ) {
       puts( "INIT - TOO MANY NODES ON RBTREE" );
       rtems_test_exit(0);
-- 
1.8.1.4



More information about the devel mailing list