summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-08-02 16:22:31 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-08-05 09:30:33 +0200
commit40dcafaf80a29c20d74594853a8ff04441eabd9c (patch)
tree1541f69ee011198bd995f38069a2b1300fc4de76 /cpukit/score/include
parentrbtree: Rename find header in find control (diff)
downloadrtems-40dcafaf80a29c20d74594853a8ff04441eabd9c.tar.bz2
Add and use RTEMS_CONTAINER_OF()
Diffstat (limited to 'cpukit/score/include')
-rw-r--r--cpukit/score/include/rtems/score/basedefs.h10
-rw-r--r--cpukit/score/include/rtems/score/mrspimpl.h2
-rw-r--r--cpukit/score/include/rtems/score/rbtree.h14
-rw-r--r--cpukit/score/include/rtems/score/scheduleredfimpl.h2
-rw-r--r--cpukit/score/include/rtems/score/schedulerimpl.h2
-rw-r--r--cpukit/score/include/rtems/score/threadimpl.h18
6 files changed, 21 insertions, 27 deletions
diff --git a/cpukit/score/include/rtems/score/basedefs.h b/cpukit/score/include/rtems/score/basedefs.h
index 382a97ac10..ec93951a4f 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 4aaa50bc01..1571594b8d 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 c4effceb50..d23808ffd4 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 019c5449c9..50e40bc0eb 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 4f7140812e..45a2f8da9d 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 a527c8beca..9321c017b8 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