summaryrefslogtreecommitdiffstats
path: root/cpukit/include
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-09-23 10:33:51 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-09-28 06:19:52 +0200
commit69b4fe592fb26f3421add3c564677d78022bcf5a (patch)
treec77f799fdd0fc92795b98820009896c35b3dde97 /cpukit/include
parentscore: Improve _CORE_message_queue_Initialize() (diff)
downloadrtems-69b4fe592fb26f3421add3c564677d78022bcf5a.tar.bz2
score: Simplify CORE_message_queue_Buffer
Merge CORE_message_queue_Buffer structure into CORE_message_queue_Buffer_control. Use a zero-length array for the actual message buffer. This reduces the structure size on all targets. Update #4007.
Diffstat (limited to 'cpukit/include')
-rw-r--r--cpukit/include/rtems/confdefs/wkspace.h2
-rw-r--r--cpukit/include/rtems/rtems/msgmp.h7
-rw-r--r--cpukit/include/rtems/score/coremsg.h53
-rw-r--r--cpukit/include/rtems/score/coremsgimpl.h16
4 files changed, 37 insertions, 41 deletions
diff --git a/cpukit/include/rtems/confdefs/wkspace.h b/cpukit/include/rtems/confdefs/wkspace.h
index 3b464899dc..89d7c21b2a 100644
--- a/cpukit/include/rtems/confdefs/wkspace.h
+++ b/cpukit/include/rtems/confdefs/wkspace.h
@@ -71,7 +71,7 @@
#define CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE( _messages, _size ) \
_Configure_From_workspace( \
( _messages ) * ( _Configure_Align_up( _size, sizeof( uintptr_t ) ) \
- + sizeof( CORE_message_queue_Buffer_control ) ) )
+ + sizeof( CORE_message_queue_Buffer ) ) )
#ifndef CONFIGURE_MESSAGE_BUFFER_MEMORY
#define CONFIGURE_MESSAGE_BUFFER_MEMORY 0
diff --git a/cpukit/include/rtems/rtems/msgmp.h b/cpukit/include/rtems/rtems/msgmp.h
index 6b08c86971..8638e9748e 100644
--- a/cpukit/include/rtems/rtems/msgmp.h
+++ b/cpukit/include/rtems/rtems/msgmp.h
@@ -71,13 +71,12 @@ typedef struct {
rtems_option option_set;
Objects_Id proxy_id;
uint32_t count;
- size_t size;
- uint32_t pad0;
- CORE_message_queue_Buffer Buffer;
+ uint32_t size;
+ uint32_t buffer[ RTEMS_ZERO_LENGTH_ARRAY ];
} Message_queue_MP_Packet;
#define MESSAGE_QUEUE_MP_PACKET_SIZE \
- offsetof(Message_queue_MP_Packet, Buffer.buffer)
+ offsetof(Message_queue_MP_Packet, buffer)
RTEMS_INLINE_ROUTINE bool _Message_queue_MP_Is_remote( Objects_Id id )
{
diff --git a/cpukit/include/rtems/score/coremsg.h b/cpukit/include/rtems/score/coremsg.h
index cabf08b0ca..2131fa0765 100644
--- a/cpukit/include/rtems/score/coremsg.h
+++ b/cpukit/include/rtems/score/coremsg.h
@@ -68,37 +68,34 @@ extern "C" {
typedef struct CORE_message_queue_Control CORE_message_queue_Control;
/**
- * @brief Data types needed to manipulate the contents of message buffers.
- *
- * The following defines the data types needed to manipulate
- * the contents of message buffers.
- *
- * @note The buffer field is normally longer than a single uint32_t
- * but since messages are variable length we just make a ptr to 1.
+ * @brief The structure is used to organize message buffers of a message queue.
*/
typedef struct {
- /** This field is the size of this message. */
- size_t size;
- /** This field contains the actual message. */
- uint32_t buffer[1];
-} CORE_message_queue_Buffer;
+ /**
+ * @brief This member is used to enqueue the buffer in the pending or free
+ * buffer queue of a message queue.
+ */
+ Chain_Node Node;
-/**
- * @brief The organization of a message buffer.
- *
- * The following records define the organization of a message
- * buffer.
- */
-typedef struct {
- /** This element allows this structure to be placed on chains. */
- Chain_Node Node;
- #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
- /** This field is the priority of this message. */
- int priority;
- #endif
- /** This field points to the contents of the message. */
- CORE_message_queue_Buffer Contents;
-} CORE_message_queue_Buffer_control;
+ /** @brief This member defines the size of this message. */
+ size_t size;
+
+#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
+ /** @brief This member defines the priority of this message. */
+ int priority;
+#endif
+
+ /**
+ * @brief This member contains the actual message.
+ *
+ * This is a zero-length array since the maximum message size is defined by
+ * the user. Use a size_t array to make sure that the member offset is at
+ * the structure end. This enables a more efficient memcpy() on 64-bit
+ * targets and makes it easier to inspect the message buffers with a
+ * debugger.
+ */
+ size_t buffer[ RTEMS_ZERO_LENGTH_ARRAY ];
+} CORE_message_queue_Buffer;
/**
* @brief The possible blocking disciplines for a message queue.
diff --git a/cpukit/include/rtems/score/coremsgimpl.h b/cpukit/include/rtems/score/coremsgimpl.h
index 9403fb95fc..cb84bfb207 100644
--- a/cpukit/include/rtems/score/coremsgimpl.h
+++ b/cpukit/include/rtems/score/coremsgimpl.h
@@ -276,7 +276,7 @@ Status_Control _CORE_message_queue_Seize(
*/
void _CORE_message_queue_Insert_message(
CORE_message_queue_Control *the_message_queue,
- CORE_message_queue_Buffer_control *the_message,
+ CORE_message_queue_Buffer *the_message,
const void *content_source,
size_t content_size,
CORE_message_queue_Submit_types submit_type
@@ -426,12 +426,12 @@ RTEMS_INLINE_ROUTINE void _CORE_message_queue_Copy_buffer (
* @retval pointer The allocated message buffer.
* @retval NULL The inactive message buffer chain is empty.
*/
-RTEMS_INLINE_ROUTINE CORE_message_queue_Buffer_control *
+RTEMS_INLINE_ROUTINE CORE_message_queue_Buffer *
_CORE_message_queue_Allocate_message_buffer (
CORE_message_queue_Control *the_message_queue
)
{
- return (CORE_message_queue_Buffer_control *)
+ return (CORE_message_queue_Buffer *)
_Chain_Get_unprotected( &the_message_queue->Inactive_messages );
}
@@ -445,8 +445,8 @@ _CORE_message_queue_Allocate_message_buffer (
* @param[out] the_message The message to be freed.
*/
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Free_message_buffer (
- CORE_message_queue_Control *the_message_queue,
- CORE_message_queue_Buffer_control *the_message
+ CORE_message_queue_Control *the_message_queue,
+ CORE_message_queue_Buffer *the_message
)
{
_Chain_Append_unprotected( &the_message_queue->Inactive_messages, &the_message->Node );
@@ -466,7 +466,7 @@ RTEMS_INLINE_ROUTINE void _CORE_message_queue_Free_message_buffer (
* disabled if no API requires it.
*/
RTEMS_INLINE_ROUTINE int _CORE_message_queue_Get_message_priority (
- const CORE_message_queue_Buffer_control *the_message
+ const CORE_message_queue_Buffer *the_message
)
{
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
@@ -488,11 +488,11 @@ RTEMS_INLINE_ROUTINE int _CORE_message_queue_Get_message_priority (
* @retval NULL The message queue is empty.
*/
RTEMS_INLINE_ROUTINE
- CORE_message_queue_Buffer_control *_CORE_message_queue_Get_pending_message (
+ CORE_message_queue_Buffer *_CORE_message_queue_Get_pending_message (
CORE_message_queue_Control *the_message_queue
)
{
- return (CORE_message_queue_Buffer_control *)
+ return (CORE_message_queue_Buffer *)
_Chain_Get_unprotected( &the_message_queue->Pending_messages );
}