source: rtems/cpukit/rtems/src/msgqreceive.c @ 63d229d6

4.115
Last change on this file since 63d229d6 was 63d229d6, checked in by Sebastian Huber <sebastian.huber@…>, on 07/23/13 at 09:12:52

rtems: Create attr implementation header

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

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