source: rtems/cpukit/rtems/src/msgqreceive.c @ 1d39e96

5
Last change on this file since 1d39e96 was 1d39e96, checked in by Sebastian Huber <sebastian.huber@…>, on 10/05/18 at 06:11:09

score: Fix legacy RTEMS_STATIC_ASSERT()

In standard C pointer operands are not allowed in integer constant
expressions. Avoid a static assertion based on an array typedef since
this could lead to warnings ("variably modified 'x' at file scope" and
"typedef 'x' locally defined but not used");

This implementation requires unique messages.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Message Queue Receive
5 *  @ingroup ClassicMessageQueue
6 */
7
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#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/messageimpl.h>
22#include <rtems/rtems/optionsimpl.h>
23#include <rtems/rtems/statusimpl.h>
24
25THREAD_QUEUE_OBJECT_ASSERT(
26  Message_queue_Control,
27  message_queue.Wait_queue,
28  MESSAGE_QUEUE_CONTROL
29);
30
31rtems_status_code rtems_message_queue_receive(
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
62  _CORE_message_queue_Acquire_critical(
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 );
69  status = _CORE_message_queue_Seize(
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}
Note: See TracBrowser for help on using the repository browser.