source: rtems/cpukit/rtems/src/msgqreceive.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.1 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/system.h>
22#include <rtems/score/chain.h>
23#include <rtems/score/isr.h>
24#include <rtems/score/coremsgimpl.h>
25#include <rtems/score/thread.h>
26#include <rtems/score/wkspace.h>
27#include <rtems/rtems/status.h>
28#include <rtems/rtems/attrimpl.h>
29#include <rtems/rtems/messageimpl.h>
30#include <rtems/rtems/optionsimpl.h>
31#include <rtems/rtems/support.h>
32
33rtems_status_code rtems_message_queue_receive(
34  rtems_id        id,
35  void           *buffer,
36  size_t         *size,
37  rtems_option    option_set,
38  rtems_interval  timeout
39)
40{
41  Message_queue_Control          *the_message_queue;
42  Objects_Locations               location;
43  bool                            wait;
44  Thread_Control                 *executing;
45
46  if ( !buffer )
47    return RTEMS_INVALID_ADDRESS;
48
49  if ( !size )
50    return RTEMS_INVALID_ADDRESS;
51
52  the_message_queue = _Message_queue_Get( id, &location );
53  switch ( location ) {
54
55    case OBJECTS_LOCAL:
56      if ( _Options_Is_no_wait( option_set ) )
57        wait = false;
58      else
59        wait = true;
60
61      executing = _Thread_Executing;
62      _CORE_message_queue_Seize(
63        &the_message_queue->message_queue,
64        executing,
65        the_message_queue->Object.id,
66        buffer,
67        size,
68        wait,
69        timeout
70      );
71      _Objects_Put( &the_message_queue->Object );
72      return _Message_queue_Translate_core_message_queue_return_code(
73        executing->Wait.return_code
74      );
75
76#if defined(RTEMS_MULTIPROCESSING)
77    case OBJECTS_REMOTE:
78      return _Message_queue_MP_Send_request_packet(
79          MESSAGE_QUEUE_MP_RECEIVE_REQUEST,
80          id,
81          buffer,
82          size,
83          option_set,
84          timeout
85        );
86#endif
87
88    case OBJECTS_ERROR:
89      break;
90  }
91
92  return RTEMS_INVALID_ID;
93}
Note: See TracBrowser for help on using the repository browser.