RTEMS
msgqreceive.c
Go to the documentation of this file.
1 
8 /*
9  * COPYRIGHT (c) 1989-2014.
10  * On-Line Applications Research Corporation (OAR).
11  *
12  * The license and distribution terms for this file may be
13  * found in the file LICENSE in this distribution or at
14  * http://www.rtems.org/license/LICENSE.
15  */
16 
17 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
20 
23 #include <rtems/rtems/statusimpl.h>
24 
25 THREAD_QUEUE_OBJECT_ASSERT(
27  message_queue.Wait_queue,
28  MESSAGE_QUEUE_CONTROL
29 );
30 
32  rtems_id id,
33  void *buffer,
34  size_t *size,
35  rtems_option option_set,
36  rtems_interval timeout
37 )
38 {
39  Message_queue_Control *the_message_queue;
40  Thread_queue_Context queue_context;
41  Thread_Control *executing;
42  Status_Control status;
43 
44  if ( buffer == NULL ) {
45  return RTEMS_INVALID_ADDRESS;
46  }
47 
48  if ( size == NULL ) {
49  return RTEMS_INVALID_ADDRESS;
50  }
51 
52  the_message_queue = _Message_queue_Get( id, &queue_context );
53 
54  if ( the_message_queue == NULL ) {
55 #if defined(RTEMS_MULTIPROCESSING)
56  return _Message_queue_MP_Receive( id, buffer, size, option_set, timeout );
57 #else
58  return RTEMS_INVALID_ID;
59 #endif
60  }
61 
63  &the_message_queue->message_queue,
64  &queue_context
65  );
66 
67  executing = _Thread_Executing;
68  _Thread_queue_Context_set_enqueue_timeout_ticks( &queue_context, timeout );
70  &the_message_queue->message_queue,
71  executing,
72  buffer,
73  size,
74  !_Options_Is_no_wait( option_set ),
75  &queue_context
76  );
77  return _Status_Get( status );
78 }
Thread queue context for the thread queue methods.
Definition: threadq.h:198
Classic Message Queue Manager Implementation.
static __inline__ void _Thread_queue_Context_set_enqueue_timeout_ticks(Thread_queue_Context *queue_context, Watchdog_Interval ticks)
Sets the enqueue callout to add a relative monotonic timeout in ticks.
Definition: threadqimpl.h:262
uint32_t rtems_option
This type is used to represent an option set.
Definition: options.h:121
Status_Control _CORE_message_queue_Seize(CORE_message_queue_Control *the_message_queue, Thread_Control *executing, void *buffer, size_t *size_p, bool wait, Thread_queue_Context *queue_context)
Seizes a message from the message queue.
Definition: coremsgseize.c:27
Classic Options Implementation.
RTEMS_INLINE_ROUTINE bool _Options_Is_no_wait(rtems_option option_set)
Checks if the RTEMS_NO_WAIT option is enabled in option_set.
Definition: optionsimpl.h:40
rtems_status_code rtems_message_queue_receive(rtems_id id, void *buffer, size_t *size, rtems_option option_set, rtems_interval timeout)
%
Definition: msgqreceive.c:31
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:82
Classic Status Implementation.
CORE_message_queue_Control message_queue
Definition: messagedata.h:42
This status code indicates that a specified address was invalid.
Definition: status.h:133
Watchdog_Interval rtems_interval
This type is used to represent clock tick intervals.
Definition: types.h:90
This status code indicates that an object identifier was invalid.
Definition: status.h:106
Objects_Id rtems_id
Values of this type identify an RTEMS object.
Definition: types.h:99
static __inline__ void _CORE_message_queue_Acquire_critical(CORE_message_queue_Control *the_message_queue, Thread_queue_Context *queue_context)
Acquires the message queue critical.
Definition: coremsgimpl.h:432