From 939ba8162fd32d4ce918b0b994adda8511641364 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Sun, 13 Sep 2009 16:05:14 +0000 Subject: 2009-09-13 Joel Sherrill * score/inline/rtems/score/coremsg.inl, score/src/coremsg.c, score/src/coremsgbroadcast.c, score/src/coremsginsert.c, score/src/coremsgseize.c, score/src/coremsgsubmit.c: Add wrappers for accessing message priority. Since these are empty when priority-based message queues are disabled, this eliminates some of the conditionals. --- cpukit/score/src/coremsg.c | 14 +++++--------- cpukit/score/src/coremsgbroadcast.c | 26 +++++++++++++------------- cpukit/score/src/coremsginsert.c | 11 +++++++---- cpukit/score/src/coremsgseize.c | 34 +++++++++++++++++++--------------- cpukit/score/src/coremsgsubmit.c | 23 +++++++++++------------ 5 files changed, 55 insertions(+), 53 deletions(-) (limited to 'cpukit/score/src') diff --git a/cpukit/score/src/coremsg.c b/cpukit/score/src/coremsg.c index b7448ab1fd..ca5dfcfbeb 100644 --- a/cpukit/score/src/coremsg.c +++ b/cpukit/score/src/coremsg.c @@ -7,7 +7,7 @@ * This core object provides task synchronization and communication functions * via messages passed to queue objects. * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -30,8 +30,7 @@ #include #include -/*PAGE - * +/* * _CORE_message_queue_Initialize * * This routine initializes a newly created message queue based on the @@ -62,19 +61,16 @@ bool _CORE_message_queue_Initialize( the_message_queue->maximum_pending_messages = maximum_pending_messages; the_message_queue->number_of_pending_messages = 0; the_message_queue->maximum_message_size = maximum_message_size; - #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION) - _CORE_message_queue_Set_notify( the_message_queue, NULL, NULL ); - #endif + _CORE_message_queue_Set_notify( the_message_queue, NULL, NULL ); /* * Round size up to multiple of a pointer for chain init and * check for overflow on adding overhead to each message. */ - allocated_message_size = maximum_message_size; if (allocated_message_size & (sizeof(uint32_t) - 1)) { - allocated_message_size += sizeof(uint32_t); - allocated_message_size &= ~(sizeof(uint32_t) - 1); + allocated_message_size += sizeof(uint32_t); + allocated_message_size &= ~(sizeof(uint32_t) - 1); } if (allocated_message_size < maximum_message_size) diff --git a/cpukit/score/src/coremsgbroadcast.c b/cpukit/score/src/coremsgbroadcast.c index 12cb0dd4f1..fc89a8ad5f 100644 --- a/cpukit/score/src/coremsgbroadcast.c +++ b/cpukit/score/src/coremsgbroadcast.c @@ -55,13 +55,13 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast( CORE_message_queue_Control *the_message_queue, const void *buffer, size_t size, -#if defined(RTEMS_MULTIPROCESSING) - Objects_Id id, - CORE_message_queue_API_mp_support_callout api_message_queue_mp_support, -#else - Objects_Id id __attribute__((unused)), - CORE_message_queue_API_mp_support_callout api_message_queue_mp_support __attribute__((unused)), -#endif + #if defined(RTEMS_MULTIPROCESSING) + Objects_Id id, + CORE_message_queue_API_mp_support_callout api_message_queue_mp_support, + #else + Objects_Id id __attribute__((unused)), + CORE_message_queue_API_mp_support_callout api_message_queue_mp_support __attribute__((unused)), + #endif uint32_t *count ) { @@ -91,9 +91,9 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast( * There must be no pending messages if there is a thread waiting to * receive a message. */ - number_broadcasted = 0; - while ((the_thread = _Thread_queue_Dequeue(&the_message_queue->Wait_queue))) { + while ((the_thread = + _Thread_queue_Dequeue(&the_message_queue->Wait_queue) != NULL)) { waitp = &the_thread->Wait; number_broadcasted += 1; @@ -105,10 +105,10 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast( *(size_t *) the_thread->Wait.return_argument = size; -#if defined(RTEMS_MULTIPROCESSING) - if ( !_Objects_Is_local_id( the_thread->Object.id ) ) - (*api_message_queue_mp_support) ( the_thread, id ); -#endif + #if defined(RTEMS_MULTIPROCESSING) + if ( !_Objects_Is_local_id( the_thread->Object.id ) ) + (*api_message_queue_mp_support) ( the_thread, id ); + #endif } *count = number_broadcasted; diff --git a/cpukit/score/src/coremsginsert.c b/cpukit/score/src/coremsginsert.c index 9b5dbdfeef..686118bb23 100644 --- a/cpukit/score/src/coremsginsert.c +++ b/cpukit/score/src/coremsginsert.c @@ -65,9 +65,7 @@ void _CORE_message_queue_Insert_message( #define SET_NOTIFY() #endif - #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY) - the_message->priority = submit_type; - #endif + _CORE_message_queue_Set_message_priority( the_message, submit_type ); #if !defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY) _ISR_Disable( level ); @@ -95,14 +93,19 @@ void _CORE_message_queue_Insert_message( CORE_message_queue_Buffer_control *this_message; Chain_Node *the_node; Chain_Control *the_header; + int the_priority; + the_priority = _CORE_message_queue_Get_message_priority(the_message); the_header = &the_message_queue->Pending_messages; the_node = the_header->first; while ( !_Chain_Is_tail( the_header, the_node ) ) { + int this_priority; this_message = (CORE_message_queue_Buffer_control *) the_node; - if ( this_message->priority <= the_message->priority ) { + this_priority = _CORE_message_queue_Get_message_priority(this_message); + + if ( this_priority <= the_priority ) { the_node = the_node->next; continue; } diff --git a/cpukit/score/src/coremsgseize.c b/cpukit/score/src/coremsgseize.c index 17a210c2ed..7b2294cb72 100644 --- a/cpukit/score/src/coremsgseize.c +++ b/cpukit/score/src/coremsgseize.c @@ -78,16 +78,20 @@ void _CORE_message_queue_Seize( _ISR_Enable( level ); *size_p = the_message->Contents.size; - #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY) - _Thread_Executing->Wait.count = the_message->priority; - #endif - _CORE_message_queue_Copy_buffer(the_message->Contents.buffer,buffer,*size_p); + _Thread_Executing->Wait.count = + _CORE_message_queue_Get_message_priority( the_message ); + _CORE_message_queue_Copy_buffer( + the_message->Contents.buffer, + buffer, + *size_p + ); #if !defined(RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND) /* - * There is not an API with blocking sends enabled. So return immediately. + * There is not an API with blocking sends enabled. + * So return immediately. */ - _CORE_message_queue_Free_message_buffer( the_message_queue, the_message ); + _CORE_message_queue_Free_message_buffer(the_message_queue, the_message); return; #else { @@ -102,7 +106,10 @@ void _CORE_message_queue_Seize( */ the_thread = _Thread_queue_Dequeue( &the_message_queue->Wait_queue ); if ( !the_thread ) { - _CORE_message_queue_Free_message_buffer( the_message_queue, the_message ); + _CORE_message_queue_Free_message_buffer( + the_message_queue, + the_message + ); return; } @@ -111,9 +118,10 @@ void _CORE_message_queue_Seize( * puts the messages in the message queue on behalf of the * waiting task. */ - #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY) - the_message->priority = the_thread->Wait.count; - #endif + _CORE_message_queue_Set_message_priority( + the_message, + the_thread->Wait.count + ); the_message->Contents.size = (size_t) the_thread->Wait.option; _CORE_message_queue_Copy_buffer( the_thread->Wait.return_argument_second.immutable_object, @@ -124,11 +132,7 @@ void _CORE_message_queue_Seize( _CORE_message_queue_Insert_message( the_message_queue, the_message, - #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY) - the_message->priority - #else - 0 - #endif + _CORE_message_queue_Get_message_priority( the_message ) ); return; } diff --git a/cpukit/score/src/coremsgsubmit.c b/cpukit/score/src/coremsgsubmit.c index d52746e9ac..def07005bd 100644 --- a/cpukit/score/src/coremsgsubmit.c +++ b/cpukit/score/src/coremsgsubmit.c @@ -59,11 +59,12 @@ CORE_message_queue_Status _CORE_message_queue_Submit( const void *buffer, size_t size, Objects_Id id, -#if defined(RTEMS_MULTIPROCESSING) - CORE_message_queue_API_mp_support_callout api_message_queue_mp_support, -#else - CORE_message_queue_API_mp_support_callout api_message_queue_mp_support __attribute__((unused)), -#endif + #if defined(RTEMS_MULTIPROCESSING) + CORE_message_queue_API_mp_support_callout api_message_queue_mp_support, + #else + CORE_message_queue_API_mp_support_callout api_message_queue_mp_support __attribute__((unused)), + #else + #endif CORE_message_queue_Submit_types submit_type, bool wait, Watchdog_Interval timeout @@ -90,10 +91,10 @@ CORE_message_queue_Status _CORE_message_queue_Submit( *(size_t *) the_thread->Wait.return_argument = size; the_thread->Wait.count = submit_type; -#if defined(RTEMS_MULTIPROCESSING) - if ( !_Objects_Is_local_id( the_thread->Object.id ) ) - (*api_message_queue_mp_support) ( the_thread, id ); -#endif + #if defined(RTEMS_MULTIPROCESSING) + if ( !_Objects_Is_local_id( the_thread->Object.id ) ) + (*api_message_queue_mp_support) ( the_thread, id ); + #endif return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL; } } @@ -123,9 +124,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit( size ); the_message->Contents.size = size; - #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY) - the_message->priority = submit_type; - #endif + _CORE_message_queue_Set_message_priority( the_message, submit_type ); _CORE_message_queue_Insert_message( the_message_queue, -- cgit v1.2.3