diff options
Diffstat (limited to 'cpukit/score')
-rw-r--r-- | cpukit/score/include/rtems/score/basedefs.h | 10 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/mrspimpl.h | 2 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/rbtree.h | 14 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/scheduleredfimpl.h | 2 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/schedulerimpl.h | 2 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/threadimpl.h | 18 | ||||
-rw-r--r-- | cpukit/score/src/resourceiterate.c | 6 | ||||
-rw-r--r-- | cpukit/score/src/schedulerchangeroot.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/scheduleredf.c | 10 | ||||
-rw-r--r-- | cpukit/score/src/threadq.c | 12 | ||||
-rw-r--r-- | cpukit/score/src/threadqdequeue.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/threadqfirst.c | 5 |
12 files changed, 40 insertions, 45 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 diff --git a/cpukit/score/src/resourceiterate.c b/cpukit/score/src/resourceiterate.c index 26f923491d..ac8b8b037c 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 eba852ba5e..f731117b4c 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 01b5244cf6..6dfa288999 100644 --- a/cpukit/score/src/scheduleredf.c +++ b/cpukit/score/src/scheduleredf.c @@ -25,10 +25,12 @@ int _Scheduler_EDF_Compare( const RBTree_Node* n2 ) { - Priority_Control value1 = _RBTree_Container_of - (n1,Scheduler_EDF_Node,Node)->thread->current_priority; - Priority_Control value2 = _RBTree_Container_of - (n2,Scheduler_EDF_Node,Node)->thread->current_priority; + Scheduler_EDF_Node *edf1 = + RTEMS_CONTAINER_OF( n1, Scheduler_EDF_Node, Node ); + Scheduler_EDF_Node *edf2 = + RTEMS_CONTAINER_OF( n2, Scheduler_EDF_Node, Node ); + Priority_Control value1 = edf1->thread->current_priority; + Priority_Control value2 = edf2->thread->current_priority; /* * This function compares only numbers for the red-black tree, diff --git a/cpukit/score/src/threadq.c b/cpukit/score/src/threadq.c index 0ffbfada09..b146ad410c 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 d745ef29e3..e364aa91e8 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 39f7c3f5b3..5d97ae156d 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 ); |