24 #define MESSAGE_SIZE_LIMIT \ 25 ( SIZE_MAX - sizeof( uintptr_t ) + 1 - sizeof( CORE_message_queue_Buffer ) ) 30 CORE_MESSAGE_QUEUE_BUFFER_OFFSET
36 uint32_t maximum_pending_messages,
37 size_t maximum_message_size,
45 if ( maximum_message_size > MESSAGE_SIZE_LIMIT ) {
46 return STATUS_MESSAGE_QUEUE_INVALID_SIZE;
49 buffer_size =
RTEMS_ALIGN_UP( maximum_message_size,
sizeof( uintptr_t ) );
50 _Assert( buffer_size >= maximum_message_size );
56 if ( maximum_pending_messages > SIZE_MAX / buffer_size ) {
57 return STATUS_MESSAGE_QUEUE_INVALID_NUMBER;
62 (size_t) maximum_pending_messages * buffer_size,
66 if ( the_message_queue->message_buffers == NULL ) {
67 return STATUS_MESSAGE_QUEUE_NO_MEMORY;
70 the_message_queue->maximum_pending_messages = maximum_pending_messages;
71 the_message_queue->number_of_pending_messages = 0;
72 the_message_queue->maximum_message_size = maximum_message_size;
79 the_message_queue->operations = &_Thread_queue_Operations_priority;
81 the_message_queue->operations = &_Thread_queue_Operations_FIFO;
85 &the_message_queue->Inactive_messages,
86 the_message_queue->message_buffers,
87 (
size_t) maximum_pending_messages,
91 return STATUS_SUCCESSFUL;
Inlined Routines in the Core Message Handler.
void *(* CORE_message_queue_Allocate_buffers)(CORE_message_queue_Control *the_message_queue, size_t size, const void *arg)
This handler shall allocate the message buffer storage area for a message queue.
#define _CORE_message_queue_Set_notify(the_message_queue, the_handler)
Initializes notification information.
void _Chain_Initialize(Chain_Control *the_chain, void *starting_address, size_t number_nodes, size_t node_size)
Initializes a chain header.
void _Thread_queue_Object_initialize(Thread_queue_Control *the_thread_queue)
Initializes a thread queue embedded in an object with identifier.
Information for the Assert Handler.
#define RTEMS_STATIC_ASSERT(_cond, _msg)
Asserts at compile time that the specified condition is satisfied.
The structure is used to organize message buffers of a message queue.
#define RTEMS_ALIGN_UP(_value, _alignment)
Returns the specified value aligned up to the specified alignment.
CORE_message_queue_Disciplines
The possible blocking disciplines for a message queue.
Status_Control _CORE_message_queue_Initialize(CORE_message_queue_Control *the_message_queue, CORE_message_queue_Disciplines discipline, uint32_t maximum_pending_messages, size_t maximum_message_size, CORE_message_queue_Allocate_buffers allocate_buffers, const void *arg)
Initializes a message queue.
static __inline__ void _Chain_Initialize_empty(Chain_Control *the_chain)
Initializes this chain as empty.
Control block used to manage each message queue.
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
CORE_message_queue_Buffer * message_buffers