[PATCH 11/15] rtems: _Message_queue_Get_interrupt_disable()

Sebastian Huber sebastian.huber at embedded-brains.de
Fri May 20 13:33:48 UTC 2016


Use _Objects_Get_local() for _Message_queue_Get_interrupt_disable() to
get rid of the location parameter.  Move remote object handling to
message queue MPCI support.
---
 cpukit/rtems/include/rtems/rtems/messageimpl.h |   8 +-
 cpukit/rtems/include/rtems/rtems/msgmp.h       |  69 +++++++++++++---
 cpukit/rtems/src/msgmp.c                       | 110 ++++++++++++++++++++++++-
 cpukit/rtems/src/msgqbroadcast.c               |  69 +++++-----------
 cpukit/rtems/src/msgqdelete.c                  |  85 +++++++++----------
 cpukit/rtems/src/msgqflush.c                   |  69 +++-------------
 cpukit/rtems/src/msgqgetnumberpending.c        |  47 ++++-------
 cpukit/rtems/src/msgqreceive.c                 |  88 +++++++-------------
 cpukit/rtems/src/msgqsend.c                    |  85 +++++++------------
 cpukit/rtems/src/msgqurgent.c                  |  83 +++++++------------
 10 files changed, 348 insertions(+), 365 deletions(-)

diff --git a/cpukit/rtems/include/rtems/rtems/messageimpl.h b/cpukit/rtems/include/rtems/rtems/messageimpl.h
index 46a4d9e..a40ace3 100644
--- a/cpukit/rtems/include/rtems/rtems/messageimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/messageimpl.h
@@ -104,15 +104,13 @@ RTEMS_INLINE_ROUTINE void _Message_queue_Free (
 RTEMS_INLINE_ROUTINE Message_queue_Control *
 _Message_queue_Get_interrupt_disable(
   Objects_Id         id,
-  Objects_Locations *location,
   ISR_lock_Context  *lock_context
 )
 {
-  return (Message_queue_Control *) _Objects_Get_isr_disable(
-    &_Message_queue_Information,
+  return (Message_queue_Control *) _Objects_Get_local(
     id,
-    location,
-    lock_context
+    lock_context,
+    &_Message_queue_Information
   );
 }
 
diff --git a/cpukit/rtems/include/rtems/rtems/msgmp.h b/cpukit/rtems/include/rtems/rtems/msgmp.h
index 0dc6bc5..3dabd8d 100644
--- a/cpukit/rtems/include/rtems/rtems/msgmp.h
+++ b/cpukit/rtems/include/rtems/rtems/msgmp.h
@@ -79,6 +79,11 @@ typedef struct {
 #define MESSAGE_QUEUE_MP_PACKET_SIZE \
   offsetof(Message_queue_MP_Packet, Buffer.buffer)
 
+RTEMS_INLINE_ROUTINE bool _Message_queue_MP_Is_remote( Objects_Id id )
+{
+  return _Objects_MP_Is_remote( id, &_Message_queue_Information );
+}
+
 /**
  *  @brief Message_queue_Core_message_queue_mp_support
  *
@@ -107,18 +112,58 @@ void _Message_queue_MP_Send_process_packet (
 );
 
 /**
- *  @brief _Message_queue_MP_Send_request_packet
- *
- *  This routine performs a remote procedure call so that a
- *  directive operation can be initiated on another node.
- */
-rtems_status_code _Message_queue_MP_Send_request_packet (
-  Message_queue_MP_Remote_operations  operation,
-  Objects_Id                          message_queue_id,
-  const void                         *buffer,
-  size_t                             *size_p,
-  rtems_option                        option_set,
-  rtems_interval                      timeout
+ * @brief Issues a remote rtems_message_queue_broadcast() request.
+ */
+rtems_status_code _Message_queue_MP_Broadcast(
+  rtems_id    id,
+  const void *buffer,
+  size_t      size,
+  uint32_t   *count
+);
+
+/**
+ * @brief Issues a remote rtems_message_queue_flush() request.
+ */
+rtems_status_code _Message_queue_MP_Flush(
+  rtems_id  id,
+  uint32_t *count
+);
+
+/**
+ * @brief Issues a remote rtems_message_queue_get_number_pending() request.
+ */
+rtems_status_code _Message_queue_MP_Get_number_pending(
+  rtems_id  id,
+  uint32_t *count
+);
+
+/**
+ * @brief Issues a remote rtems_message_queue_receive() request.
+ */
+rtems_status_code _Message_queue_MP_Receive(
+  rtems_id        id,
+  void           *buffer,
+  size_t         *size,
+  rtems_option    option_set,
+  rtems_interval  timeout
+);
+
+/**
+ * @brief Issues a remote rtems_message_queue_send() request.
+ */
+rtems_status_code _Message_queue_MP_Send(
+  rtems_id    id,
+  const void *buffer,
+  size_t      size
+);
+
+/**
+ * @brief Issues a remote rtems_message_queue_urgent() request.
+ */
+rtems_status_code _Message_queue_MP_Urgent(
+  rtems_id    id,
+  const void *buffer,
+  size_t      size
 );
 
 /**
diff --git a/cpukit/rtems/src/msgmp.c b/cpukit/rtems/src/msgmp.c
index d0ee419..c336ba4 100644
--- a/cpukit/rtems/src/msgmp.c
+++ b/cpukit/rtems/src/msgmp.c
@@ -95,17 +95,21 @@ void _Message_queue_MP_Send_process_packet (
  *
  */
 
-rtems_status_code _Message_queue_MP_Send_request_packet (
-  Message_queue_MP_Remote_operations  operation,
+static rtems_status_code _Message_queue_MP_Send_request_packet (
   Objects_Id                          message_queue_id,
   const void                         *buffer,
   size_t                             *size_p,
   rtems_option                        option_set,
-  rtems_interval                      timeout
+  rtems_interval                      timeout,
+  Message_queue_MP_Remote_operations  operation
 )
 {
   Message_queue_MP_Packet *the_packet;
 
+  if ( !_Message_queue_MP_Is_remote( message_queue_id ) ) {
+    return RTEMS_INVALID_ID;
+  }
+
   switch ( operation ) {
 
     case MESSAGE_QUEUE_MP_SEND_REQUEST:
@@ -200,6 +204,106 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
   return RTEMS_SUCCESSFUL;
 }
 
+rtems_status_code _Message_queue_MP_Broadcast(
+  rtems_id    id,
+  const void *buffer,
+  size_t      size,
+  uint32_t   *count
+)
+{
+  _Thread_Get_executing()->Wait.return_argument = count;
+  return _Message_queue_MP_Send_request_packet(
+    id,
+    buffer,
+    &size,
+    0,
+    MPCI_DEFAULT_TIMEOUT,
+    MESSAGE_QUEUE_MP_BROADCAST_REQUEST
+  );
+}
+
+rtems_status_code _Message_queue_MP_Flush(
+  rtems_id  id,
+  uint32_t *count
+)
+{
+  _Thread_Get_executing()->Wait.return_argument = count;
+  return _Message_queue_MP_Send_request_packet(
+    id,
+    NULL,
+    NULL,
+    0,
+    MPCI_DEFAULT_TIMEOUT,
+    MESSAGE_QUEUE_MP_FLUSH_REQUEST
+  );
+}
+
+rtems_status_code _Message_queue_MP_Get_number_pending(
+  rtems_id  id,
+  uint32_t *count
+)
+{
+  _Thread_Get_executing()->Wait.return_argument = count;
+  return _Message_queue_MP_Send_request_packet(
+    id,
+    NULL,
+    NULL,
+    0,
+    MPCI_DEFAULT_TIMEOUT,
+    MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST
+  );
+}
+
+rtems_status_code _Message_queue_MP_Receive(
+  rtems_id        id,
+  void           *buffer,
+  size_t         *size,
+  rtems_option    option_set,
+  rtems_interval  timeout
+)
+{
+  return _Message_queue_MP_Send_request_packet(
+    id,
+    buffer,
+    size,
+    option_set,
+    timeout,
+    MESSAGE_QUEUE_MP_RECEIVE_REQUEST
+  );
+}
+
+rtems_status_code _Message_queue_MP_Send(
+  rtems_id    id,
+  const void *buffer,
+  size_t      size
+)
+{
+  return _Message_queue_MP_Send_request_packet(
+    id,
+    buffer,
+    &size,
+    0,
+    MPCI_DEFAULT_TIMEOUT,
+    MESSAGE_QUEUE_MP_SEND_REQUEST
+  );
+}
+
+rtems_status_code _Message_queue_MP_Urgent(
+  rtems_id    id,
+  const void *buffer,
+  size_t      size
+)
+{
+  return _Message_queue_MP_Send_request_packet(
+    id,
+    buffer,
+    &size,
+    0,
+    MPCI_DEFAULT_TIMEOUT,
+    MESSAGE_QUEUE_MP_URGENT_REQUEST
+  );
+}
+
 /*
  *  _Message_queue_MP_Send_response_packet
  *
diff --git a/cpukit/rtems/src/msgqbroadcast.c b/cpukit/rtems/src/msgqbroadcast.c
index 7bd7e3b..5aab1b1 100644
--- a/cpukit/rtems/src/msgqbroadcast.c
+++ b/cpukit/rtems/src/msgqbroadcast.c
@@ -18,17 +18,7 @@
 #include "config.h"
 #endif
 
-#include <rtems/system.h>
-#include <rtems/score/chain.h>
-#include <rtems/score/isr.h>
-#include <rtems/score/coremsgimpl.h>
-#include <rtems/score/thread.h>
-#include <rtems/score/wkspace.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/attrimpl.h>
 #include <rtems/rtems/messageimpl.h>
-#include <rtems/rtems/options.h>
-#include <rtems/rtems/support.h>
 
 rtems_status_code rtems_message_queue_broadcast(
   rtems_id    id,
@@ -37,54 +27,39 @@ rtems_status_code rtems_message_queue_broadcast(
   uint32_t   *count
 )
 {
-  Message_queue_Control          *the_message_queue;
-  Objects_Locations               location;
-  CORE_message_queue_Status       core_status;
-  ISR_lock_Context                lock_context;
+  Message_queue_Control     *the_message_queue;
+  ISR_lock_Context           lock_context;
+  CORE_message_queue_Status  status;
 
-  if ( !buffer )
+  if ( buffer == NULL ) {
     return RTEMS_INVALID_ADDRESS;
+  }
 
-  if ( !count )
+  if ( count == NULL ) {
     return RTEMS_INVALID_ADDRESS;
+  }
 
   the_message_queue = _Message_queue_Get_interrupt_disable(
     id,
-    &location,
     &lock_context
   );
-  switch ( location ) {
-
-    case OBJECTS_LOCAL:
-      core_status = _CORE_message_queue_Broadcast(
-                      &the_message_queue->message_queue,
-                      buffer,
-                      size,
-                      _Message_queue_Core_message_queue_mp_support,
-                      id,
-                      count,
-                      &lock_context
-                    );
-      return
-        _Message_queue_Translate_core_message_queue_return_code( core_status );
 
+  if ( the_message_queue == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
-    case OBJECTS_REMOTE:
-      _Thread_Executing->Wait.return_argument = count;
-
-      return
-        _Message_queue_MP_Send_request_packet(
-          MESSAGE_QUEUE_MP_BROADCAST_REQUEST,
-          id,
-          buffer,
-          &size,
-          0,                               /* option_set not used */
-          MPCI_DEFAULT_TIMEOUT
-        );
+    _Message_queue_MP_Broadcast( id, buffer, size, count );
+#else
+    return RTEMS_INVALID_ID;
 #endif
-
-    case OBJECTS_ERROR:
-      break;
   }
-  return RTEMS_INVALID_ID;
+
+  status = _CORE_message_queue_Broadcast(
+    &the_message_queue->message_queue,
+    buffer,
+    size,
+    _Message_queue_Core_message_queue_mp_support,
+    id,
+    count,
+    &lock_context
+  );
+  return _Message_queue_Translate_core_message_queue_return_code( status );
 }
diff --git a/cpukit/rtems/src/msgqdelete.c b/cpukit/rtems/src/msgqdelete.c
index 506c069..810b741 100644
--- a/cpukit/rtems/src/msgqdelete.c
+++ b/cpukit/rtems/src/msgqdelete.c
@@ -25,64 +25,55 @@ rtems_status_code rtems_message_queue_delete(
   rtems_id id
 )
 {
-  Message_queue_Control          *the_message_queue;
-  Objects_Locations               location;
-  ISR_lock_Context                lock_context;
+  Message_queue_Control *the_message_queue;
+  ISR_lock_Context       lock_context;
 
   _Objects_Allocator_lock();
-  the_message_queue = _Message_queue_Get_interrupt_disable(
-    id,
-    &location,
-    &lock_context
-  );
-  switch ( location ) {
+  the_message_queue = _Message_queue_Get_interrupt_disable( id, &lock_context );
 
-    case OBJECTS_LOCAL:
-      _CORE_message_queue_Acquire_critical(
-        &the_message_queue->message_queue,
-        &lock_context
-      );
+  if ( the_message_queue == NULL ) {
+    _Objects_Allocator_unlock();
 
-      _Objects_Close( &_Message_queue_Information,
-                      &the_message_queue->Object );
+#if defined(RTEMS_MULTIPROCESSING)
+    if ( _Message_queue_MP_Is_remote( id ) ) {
+      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
+    }
+#endif
 
-      _CORE_message_queue_Close(
-        &the_message_queue->message_queue,
-        _Message_queue_MP_Send_object_was_deleted,
-        id,
-        &lock_context
-      );
+    return RTEMS_INVALID_ID;
+  }
 
-#if defined(RTEMS_MULTIPROCESSING)
-      if ( _Attributes_Is_global( the_message_queue->attribute_set ) ) {
-        _Objects_MP_Close(
-          &_Message_queue_Information,
-          the_message_queue->Object.id
-        );
+  _CORE_message_queue_Acquire_critical(
+    &the_message_queue->message_queue,
+    &lock_context
+  );
 
-        _Message_queue_MP_Send_process_packet(
-          MESSAGE_QUEUE_MP_ANNOUNCE_DELETE,
-          the_message_queue->Object.id,
-          0,                                 /* Not used */
-          0
-        );
-      }
-#endif
-      _Message_queue_Free( the_message_queue );
-      _Objects_Allocator_unlock();
-      return RTEMS_SUCCESSFUL;
+  _Objects_Close( &_Message_queue_Information, &the_message_queue->Object );
+
+  _CORE_message_queue_Close(
+    &the_message_queue->message_queue,
+    _Message_queue_MP_Send_object_was_deleted,
+    id,
+    &lock_context
+  );
 
 #if defined(RTEMS_MULTIPROCESSING)
-    case OBJECTS_REMOTE:
-      _Objects_Allocator_unlock();
-      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
-#endif
+  if ( _Attributes_Is_global( the_message_queue->attribute_set ) ) {
+    _Objects_MP_Close(
+      &_Message_queue_Information,
+      the_message_queue->Object.id
+    );
 
-    case OBJECTS_ERROR:
-      break;
+    _Message_queue_MP_Send_process_packet(
+      MESSAGE_QUEUE_MP_ANNOUNCE_DELETE,
+      the_message_queue->Object.id,
+      0,                         /* Not used */
+      0
+    );
   }
+#endif
 
+  _Message_queue_Free( the_message_queue );
   _Objects_Allocator_unlock();
-
-  return RTEMS_INVALID_ID;
+  return RTEMS_SUCCESSFUL;
 }
diff --git a/cpukit/rtems/src/msgqflush.c b/cpukit/rtems/src/msgqflush.c
index 809c243..5cd09b6 100644
--- a/cpukit/rtems/src/msgqflush.c
+++ b/cpukit/rtems/src/msgqflush.c
@@ -18,79 +18,36 @@
 #include "config.h"
 #endif
 
-#include <rtems/system.h>
-#include <rtems/score/chain.h>
-#include <rtems/score/isr.h>
-#include <rtems/score/coremsgimpl.h>
-#include <rtems/score/thread.h>
-#include <rtems/score/wkspace.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/attrimpl.h>
 #include <rtems/rtems/messageimpl.h>
-#include <rtems/rtems/options.h>
-#include <rtems/rtems/support.h>
-
-/*
- *  rtems_message_queue_flush
- *
- *  This directive removes all pending messages from a queue and returns
- *  the number of messages removed.  If no messages were present then
- *  a count of zero is returned.
- *
- *  Input parameters:
- *    id    - queue id
- *    count - return area for count
- *
- *  Output parameters:
- *    count             - number of messages removed ( 0 = empty queue )
- *    RTEMS_SUCCESSFUL - if successful
- *    error code        - if unsuccessful
- */
 
 rtems_status_code rtems_message_queue_flush(
   rtems_id  id,
   uint32_t *count
 )
 {
-  Message_queue_Control          *the_message_queue;
-  Objects_Locations               location;
-  ISR_lock_Context                lock_context;
+  Message_queue_Control *the_message_queue;
+  ISR_lock_Context       lock_context;
 
-  if ( !count )
+  if ( count == NULL ) {
     return RTEMS_INVALID_ADDRESS;
+  }
 
   the_message_queue = _Message_queue_Get_interrupt_disable(
     id,
-    &location,
     &lock_context
   );
-  switch ( location ) {
-
-    case OBJECTS_LOCAL:
-      *count = _CORE_message_queue_Flush(
-        &the_message_queue->message_queue,
-        &lock_context
-      );
-      return RTEMS_SUCCESSFUL;
 
+  if ( the_message_queue == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
-    case OBJECTS_REMOTE:
-      _Thread_Executing->Wait.return_argument = count;
-
-      return
-        _Message_queue_MP_Send_request_packet(
-          MESSAGE_QUEUE_MP_FLUSH_REQUEST,
-          id,
-          0,                               /* buffer not used */
-          0,                               /* size */
-          0,                               /* option_set not used */
-          MPCI_DEFAULT_TIMEOUT
-        );
+    _Message_queue_MP_Flush( id, count );
+#else
+    return RTEMS_INVALID_ID;
 #endif
-
-    case OBJECTS_ERROR:
-      break;
   }
 
-  return RTEMS_INVALID_ID;
+  *count = _CORE_message_queue_Flush(
+    &the_message_queue->message_queue,
+    &lock_context
+  );
+  return RTEMS_SUCCESSFUL;
 }
diff --git a/cpukit/rtems/src/msgqgetnumberpending.c b/cpukit/rtems/src/msgqgetnumberpending.c
index 756e8fe..6fa0e4f 100644
--- a/cpukit/rtems/src/msgqgetnumberpending.c
+++ b/cpukit/rtems/src/msgqgetnumberpending.c
@@ -26,48 +26,33 @@ rtems_status_code rtems_message_queue_get_number_pending(
 )
 {
   Message_queue_Control *the_message_queue;
-  Objects_Locations      location;
   ISR_lock_Context       lock_context;
 
-  if ( !count )
+  if ( count == NULL ) {
     return RTEMS_INVALID_ADDRESS;
+  }
 
   the_message_queue = _Message_queue_Get_interrupt_disable(
     id,
-    &location,
     &lock_context
   );
-  switch ( location ) {
-
-    case OBJECTS_LOCAL:
-      _CORE_message_queue_Acquire_critical(
-        &the_message_queue->message_queue,
-        &lock_context
-      );
-      *count = the_message_queue->message_queue.number_of_pending_messages;
-      _CORE_message_queue_Release(
-        &the_message_queue->message_queue,
-        &lock_context
-      );
-      return RTEMS_SUCCESSFUL;
 
+  if ( the_message_queue == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
-    case OBJECTS_REMOTE:
-      _Thread_Get_executing()->Wait.return_argument = count;
-
-      return _Message_queue_MP_Send_request_packet(
-          MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST,
-          id,
-          0,                               /* buffer not used */
-          0,                               /* size */
-          0,                               /* option_set not used */
-          MPCI_DEFAULT_TIMEOUT
-        );
+    _Message_queue_MP_Get_number_pending( id, count );
+#else
+    return RTEMS_INVALID_ID;
 #endif
-
-    case OBJECTS_ERROR:
-      break;
   }
 
-  return RTEMS_INVALID_ID;
+  _CORE_message_queue_Acquire_critical(
+    &the_message_queue->message_queue,
+    &lock_context
+  );
+  *count = the_message_queue->message_queue.number_of_pending_messages;
+  _CORE_message_queue_Release(
+    &the_message_queue->message_queue,
+    &lock_context
+  );
+  return RTEMS_SUCCESSFUL;
 }
diff --git a/cpukit/rtems/src/msgqreceive.c b/cpukit/rtems/src/msgqreceive.c
index e3b3466..2c8b90e 100644
--- a/cpukit/rtems/src/msgqreceive.c
+++ b/cpukit/rtems/src/msgqreceive.c
@@ -18,17 +18,9 @@
 #include "config.h"
 #endif
 
-#include <rtems/system.h>
-#include <rtems/score/chain.h>
-#include <rtems/score/isr.h>
-#include <rtems/score/coremsgimpl.h>
-#include <rtems/score/threadimpl.h>
-#include <rtems/score/wkspace.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/attrimpl.h>
 #include <rtems/rtems/messageimpl.h>
+#include <rtems/score/threadimpl.h>
 #include <rtems/rtems/optionsimpl.h>
-#include <rtems/rtems/support.h>
 
 THREAD_WAIT_QUEUE_OBJECT_ASSERT(
   Message_queue_Control,
@@ -43,66 +35,48 @@ rtems_status_code rtems_message_queue_receive(
   rtems_interval  timeout
 )
 {
-  Message_queue_Control          *the_message_queue;
-  Objects_Locations               location;
-  bool                            wait;
-  Thread_Control                 *executing;
-  ISR_lock_Context                lock_context;
+  Message_queue_Control *the_message_queue;
+  ISR_lock_Context       lock_context;
+  Thread_Control        *executing;
 
-  if ( !buffer )
+  if ( buffer == NULL ) {
     return RTEMS_INVALID_ADDRESS;
+  }
 
-  if ( !size )
+  if ( size == NULL ) {
     return RTEMS_INVALID_ADDRESS;
+  }
 
   the_message_queue = _Message_queue_Get_interrupt_disable(
     id,
-    &location,
     &lock_context
   );
-  switch ( location ) {
-
-    case OBJECTS_LOCAL:
-      if ( _Options_Is_no_wait( option_set ) )
-        wait = false;
-      else
-        wait = true;
-
-      _CORE_message_queue_Acquire_critical(
-        &the_message_queue->message_queue,
-        &lock_context
-      );
-
-      executing = _Thread_Executing;
-      _CORE_message_queue_Seize(
-        &the_message_queue->message_queue,
-        executing,
-        the_message_queue->Object.id,
-        buffer,
-        size,
-        wait,
-        timeout,
-        &lock_context
-      );
-      return _Message_queue_Translate_core_message_queue_return_code(
-        executing->Wait.return_code
-      );
 
+  if ( the_message_queue == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
-    case OBJECTS_REMOTE:
-      return _Message_queue_MP_Send_request_packet(
-          MESSAGE_QUEUE_MP_RECEIVE_REQUEST,
-          id,
-          buffer,
-          size,
-          option_set,
-          timeout
-        );
+    _Message_queue_MP_Receive( id, buffer, size, option_set, timeout );
+#else
+    return RTEMS_INVALID_ID;
 #endif
-
-    case OBJECTS_ERROR:
-      break;
   }
 
-  return RTEMS_INVALID_ID;
+  _CORE_message_queue_Acquire_critical(
+    &the_message_queue->message_queue,
+    &lock_context
+  );
+
+  executing = _Thread_Executing;
+  _CORE_message_queue_Seize(
+    &the_message_queue->message_queue,
+    executing,
+    the_message_queue->Object.id,
+    buffer,
+    size,
+    !_Options_Is_no_wait( option_set ),
+    timeout,
+    &lock_context
+  );
+  return _Message_queue_Translate_core_message_queue_return_code(
+    executing->Wait.return_code
+  );
 }
diff --git a/cpukit/rtems/src/msgqsend.c b/cpukit/rtems/src/msgqsend.c
index 355475c..af8f3c9 100644
--- a/cpukit/rtems/src/msgqsend.c
+++ b/cpukit/rtems/src/msgqsend.c
@@ -18,17 +18,7 @@
 #include "config.h"
 #endif
 
-#include <rtems/system.h>
-#include <rtems/score/chain.h>
-#include <rtems/score/isr.h>
-#include <rtems/score/coremsgimpl.h>
-#include <rtems/score/thread.h>
-#include <rtems/score/wkspace.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/attrimpl.h>
 #include <rtems/rtems/messageimpl.h>
-#include <rtems/rtems/options.h>
-#include <rtems/rtems/support.h>
 
 rtems_status_code rtems_message_queue_send(
   rtems_id    id,
@@ -36,59 +26,46 @@ rtems_status_code rtems_message_queue_send(
   size_t      size
 )
 {
-  Message_queue_Control           *the_message_queue;
-  Objects_Locations                location;
-  CORE_message_queue_Status        status;
-  ISR_lock_Context                 lock_context;
+  Message_queue_Control     *the_message_queue;
+  ISR_lock_Context           lock_context;
+  CORE_message_queue_Status  status;
 
-  if ( !buffer )
+  if ( buffer == NULL ) {
     return RTEMS_INVALID_ADDRESS;
+  }
 
   the_message_queue = _Message_queue_Get_interrupt_disable(
     id,
-    &location,
     &lock_context
   );
-  switch ( location ) {
-
-    case OBJECTS_LOCAL:
-      _CORE_message_queue_Acquire_critical(
-        &the_message_queue->message_queue,
-        &lock_context
-      );
-      status = _CORE_message_queue_Send(
-        &the_message_queue->message_queue,
-        buffer,
-        size,
-        _Message_queue_Core_message_queue_mp_support,
-        id,
-        false,   /* sender does not block */
-        0,       /* no timeout */
-        &lock_context
-      );
-
-      /*
-       *  Since this API does not allow for blocking sends, we can directly
-       *  return the returned status.
-       */
-
-      return _Message_queue_Translate_core_message_queue_return_code(status);
 
+  if ( the_message_queue == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
-    case OBJECTS_REMOTE:
-      return _Message_queue_MP_Send_request_packet(
-        MESSAGE_QUEUE_MP_SEND_REQUEST,
-        id,
-        buffer,
-        &size,
-        0,                               /* option_set */
-        MPCI_DEFAULT_TIMEOUT
-      );
-      break;
+    _Message_queue_MP_Send( id, buffer, size );
+#else
+    return RTEMS_INVALID_ID;
 #endif
-
-    case OBJECTS_ERROR:
-      break;
   }
-  return RTEMS_INVALID_ID;
+
+  _CORE_message_queue_Acquire_critical(
+    &the_message_queue->message_queue,
+    &lock_context
+  );
+  status = _CORE_message_queue_Send(
+    &the_message_queue->message_queue,
+    buffer,
+    size,
+    _Message_queue_Core_message_queue_mp_support,
+    id,
+    false,   /* sender does not block */
+    0,       /* no timeout */
+    &lock_context
+  );
+
+  /*
+   *  Since this API does not allow for blocking sends, we can directly
+   *  return the returned status.
+   */
+
+  return _Message_queue_Translate_core_message_queue_return_code( status );
 }
diff --git a/cpukit/rtems/src/msgqurgent.c b/cpukit/rtems/src/msgqurgent.c
index 430f9a1..5220ce8 100644
--- a/cpukit/rtems/src/msgqurgent.c
+++ b/cpukit/rtems/src/msgqurgent.c
@@ -18,17 +18,7 @@
 #include "config.h"
 #endif
 
-#include <rtems/system.h>
-#include <rtems/score/chain.h>
-#include <rtems/score/isr.h>
-#include <rtems/score/coremsgimpl.h>
-#include <rtems/score/thread.h>
-#include <rtems/score/wkspace.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/attrimpl.h>
 #include <rtems/rtems/messageimpl.h>
-#include <rtems/rtems/options.h>
-#include <rtems/rtems/support.h>
 
 rtems_status_code rtems_message_queue_urgent(
   rtems_id    id,
@@ -36,59 +26,46 @@ rtems_status_code rtems_message_queue_urgent(
   size_t      size
 )
 {
-  Message_queue_Control           *the_message_queue;
-  Objects_Locations                location;
-  CORE_message_queue_Status        status;
-  ISR_lock_Context                 lock_context;
+  Message_queue_Control     *the_message_queue;
+  ISR_lock_Context           lock_context;
+  CORE_message_queue_Status  status;
 
-  if ( !buffer )
+  if ( buffer == NULL ) {
     return RTEMS_INVALID_ADDRESS;
+  }
 
   the_message_queue = _Message_queue_Get_interrupt_disable(
     id,
-    &location,
     &lock_context
   );
-  switch ( location ) {
-
-    case OBJECTS_LOCAL:
-      _CORE_message_queue_Acquire_critical(
-        &the_message_queue->message_queue,
-        &lock_context
-      );
-      status = _CORE_message_queue_Urgent(
-        &the_message_queue->message_queue,
-        buffer,
-        size,
-        _Message_queue_Core_message_queue_mp_support,
-        id,
-        false,   /* sender does not block */
-        0,       /* no timeout */
-        &lock_context
-      );
-
-      /*
-       *  Since this API does not allow for blocking sends, we can directly
-       *  return the returned status.
-       */
-
-      return _Message_queue_Translate_core_message_queue_return_code(status);
 
+  if ( the_message_queue == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
-    case OBJECTS_REMOTE:
-      return _Message_queue_MP_Send_request_packet(
-        MESSAGE_QUEUE_MP_URGENT_REQUEST,
-        id,
-        buffer,
-        &size,
-        0,                               /* option_set */
-        MPCI_DEFAULT_TIMEOUT
-      );
+    _Message_queue_MP_Urgent( id, buffer, size );
+#else
+    return RTEMS_INVALID_ID;
 #endif
-
-    case OBJECTS_ERROR:
-      break;
   }
 
-  return RTEMS_INVALID_ID;
+  _CORE_message_queue_Acquire_critical(
+    &the_message_queue->message_queue,
+    &lock_context
+  );
+  status = _CORE_message_queue_Urgent(
+    &the_message_queue->message_queue,
+    buffer,
+    size,
+    _Message_queue_Core_message_queue_mp_support,
+    id,
+    false,   /* sender does not block */
+    0,       /* no timeout */
+    &lock_context
+  );
+
+  /*
+   *  Since this API does not allow for blocking sends, we can directly
+   *  return the returned status.
+   */
+
+  return _Message_queue_Translate_core_message_queue_return_code( status );
 }
-- 
1.8.4.5




More information about the devel mailing list