[PATCH 07/19] score: _CORE_message_queue_Insert_message()

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Apr 29 09:13:07 UTC 2016


Move common code into _CORE_message_queue_Insert_message().
---
 cpukit/score/include/rtems/score/coremsgimpl.h | 12 ++++++------
 cpukit/score/src/coremsginsert.c               | 10 ++++++++++
 cpukit/score/src/coremsgseize.c                | 10 +++-------
 cpukit/score/src/coremsgsubmit.c               | 14 +++++---------
 4 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/cpukit/score/include/rtems/score/coremsgimpl.h b/cpukit/score/include/rtems/score/coremsgimpl.h
index 7edca17..b610397 100644
--- a/cpukit/score/include/rtems/score/coremsgimpl.h
+++ b/cpukit/score/include/rtems/score/coremsgimpl.h
@@ -430,21 +430,21 @@ void _CORE_message_queue_Seize(
 /**
  *  @brief Insert a message into the message queue.
  *
- *  This kernel routine inserts the specified message into the
- *  message queue.  It is assumed that the message has been filled
- *  in before this routine is called.
+ *  Copies the specified content into the message storage space and then
+ *  inserts the message into the message queue according to the submit type.
  *
  *  @param[in] the_message_queue points to the message queue
  *  @param[in] the_message is the message to enqueue
+ *  @param[in] content_source the message content source
+ *  @param[in] content_size the message content size in bytes
  *  @param[in] submit_type determines whether the message is prepended,
  *         appended, or enqueued in priority order.
- *
- *  - INTERRUPT LATENCY:
- *    + insert
  */
 void _CORE_message_queue_Insert_message(
   CORE_message_queue_Control        *the_message_queue,
   CORE_message_queue_Buffer_control *the_message,
+  const void                        *content_source,
+  size_t                             content_size,
   CORE_message_queue_Submit_types    submit_type
 );
 
diff --git a/cpukit/score/src/coremsginsert.c b/cpukit/score/src/coremsginsert.c
index a58a451..8baea360 100644
--- a/cpukit/score/src/coremsginsert.c
+++ b/cpukit/score/src/coremsginsert.c
@@ -40,6 +40,8 @@ static bool _CORE_message_queue_Order(
 void _CORE_message_queue_Insert_message(
   CORE_message_queue_Control        *the_message_queue,
   CORE_message_queue_Buffer_control *the_message,
+  const void                        *content_source,
+  size_t                             content_size,
   CORE_message_queue_Submit_types    submit_type
 )
 {
@@ -48,6 +50,14 @@ void _CORE_message_queue_Insert_message(
   bool           notify;
 #endif
 
+  the_message->Contents.size = content_size;
+
+  _CORE_message_queue_Copy_buffer(
+    content_source,
+    the_message->Contents.buffer,
+    content_size
+  );
+
 #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
   the_message->priority = submit_type;
 #endif
diff --git a/cpukit/score/src/coremsgseize.c b/cpukit/score/src/coremsgseize.c
index 4c318bc..534dc0b 100644
--- a/cpukit/score/src/coremsgseize.c
+++ b/cpukit/score/src/coremsgseize.c
@@ -90,16 +90,12 @@ void _CORE_message_queue_Seize(
        *  puts the messages in the message queue on behalf of the
        *  waiting task.
        */
-      the_message->Contents.size = (size_t) the_thread->Wait.option;
-      _CORE_message_queue_Copy_buffer(
-        the_thread->Wait.return_argument_second.immutable_object,
-        the_message->Contents.buffer,
-        the_message->Contents.size
-      );
       _CORE_message_queue_Insert_message(
         the_message_queue,
         the_message,
-        the_thread->Wait.count
+        the_thread->Wait.return_argument_second.immutable_object,
+        (size_t) the_thread->Wait.option,
+        (CORE_message_queue_Submit_types) the_thread->Wait.count
       );
       _Thread_queue_Extract_critical(
         &the_message_queue->Wait_queue.Queue,
diff --git a/cpukit/score/src/coremsgsubmit.c b/cpukit/score/src/coremsgsubmit.c
index e899734..1d6d298 100644
--- a/cpukit/score/src/coremsgsubmit.c
+++ b/cpukit/score/src/coremsgsubmit.c
@@ -72,16 +72,12 @@ CORE_message_queue_Status _CORE_message_queue_Do_submit(
   the_message =
       _CORE_message_queue_Allocate_message_buffer( the_message_queue );
   if ( the_message ) {
-    the_message->Contents.size = size;
-    _CORE_message_queue_Copy_buffer(
-      buffer,
-      the_message->Contents.buffer,
-      size
-    );
     _CORE_message_queue_Insert_message(
-       the_message_queue,
-       the_message,
-       submit_type
+      the_message_queue,
+      the_message,
+      buffer,
+      size,
+      submit_type
     );
     _CORE_message_queue_Release( the_message_queue, lock_context );
     return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
-- 
1.8.4.5




More information about the devel mailing list