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

4.115
Last change on this file since fe6c170c was fe6c170c, checked in by Sebastian Huber <sebastian.huber@…>, on 07/24/13 at 14:19:52

score: Create states implementation header

Move implementation specific parts of states.h and states.inl into new
header file statesimpl.h. The states.h contains now only the
application visible API.

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