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

4.104.114.84.95
Last change on this file since f4e0118 was f4e0118, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/06/07 at 04:46:56

Use size_t for sizes.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 *  Message Queue Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/score/sysstate.h>
21#include <rtems/score/chain.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/coremsg.h>
24#include <rtems/score/object.h>
25#include <rtems/score/states.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/attr.h>
33#include <rtems/rtems/message.h>
34#include <rtems/rtems/options.h>
35#include <rtems/rtems/support.h>
36
37/*PAGE
38 *
39 *  rtems_message_queue_receive
40 *
41 *  This directive dequeues a message from the designated message queue
42 *  and copies it into the requesting thread's buffer.
43 *
44 *  Input parameters:
45 *    id         - queue id
46 *    buffer     - pointer to message buffer
47 *    size       - size of message receive
48 *    option_set - options on receive
49 *    timeout    - number of ticks to wait
50 *
51 *  Output parameters:
52 *    RTEMS_SUCCESSFUL - if successful
53 *    error code       - if unsuccessful
54 */
55
56rtems_status_code rtems_message_queue_receive(
57  Objects_Id            id,
58  void                 *buffer,
59  size_t               *size,
60  uint32_t              option_set,
61  rtems_interval        timeout
62)
63{
64  register Message_queue_Control *the_message_queue;
65  Objects_Locations               location;
66  boolean                         wait;
67
68  if ( !buffer )
69    return RTEMS_INVALID_ADDRESS;
70
71  if ( !size )
72    return RTEMS_INVALID_ADDRESS;
73
74  the_message_queue = _Message_queue_Get( id, &location );
75  switch ( location ) {
76
77    case OBJECTS_REMOTE:
78#if defined(RTEMS_MULTIPROCESSING)
79      return _Message_queue_MP_Send_request_packet(
80          MESSAGE_QUEUE_MP_RECEIVE_REQUEST,
81          id,
82          buffer,
83          size,
84          option_set,
85          timeout
86        );
87#endif
88
89    case OBJECTS_ERROR:
90      return RTEMS_INVALID_ID;
91
92    case OBJECTS_LOCAL:
93      if ( _Options_Is_no_wait( option_set ) )
94        wait = FALSE;
95      else
96        wait = TRUE;
97
98      _CORE_message_queue_Seize(
99        &the_message_queue->message_queue,
100        the_message_queue->Object.id,
101        buffer,
102        size,
103        wait,
104        timeout
105      );
106      _Thread_Enable_dispatch();
107      return _Message_queue_Translate_core_message_queue_return_code(
108        _Thread_Executing->Wait.return_code
109      );
110
111  }
112
113  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
114}
Note: See TracBrowser for help on using the repository browser.