source: rtems/cpukit/itron/src/trcv_mbf.c @ 22d66ab

4.104.114.95
Last change on this file since 22d66ab was 22d66ab, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/04/08 at 16:04:00

Convert to "bool".

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 *  ITRON Message Buffer Manager
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/itron.h>
19
20#include <rtems/itron/msgbuffer.h>
21#include <rtems/itron/task.h>
22
23/*
24 *  trcv_mbf - Receive Message from MessageBuffer with Timeout
25 */
26
27ER trcv_mbf(
28  VP   msg,
29  INT *p_msgsz,
30  ID   mbfid,
31  TMO  tmout
32)
33{
34  ITRON_Message_buffer_Control   *the_message_buffer;
35  Objects_Locations               location;
36  CORE_message_queue_Status       status;
37  bool                            wait;
38  Watchdog_Interval               interval;
39  size_t                          msgsz;
40
41  interval = 0;
42  if (tmout == TMO_POL) {
43    wait = false;
44  } else {
45    wait = true;
46    if (tmout != TMO_FEVR)
47      interval = TOD_MILLISECONDS_TO_TICKS(tmout);
48  }
49
50  if (wait && _ITRON_Is_in_non_task_state() )
51    return E_CTX;
52
53  if (!p_msgsz || !msg || tmout <= -2)
54    return E_PAR;
55
56  the_message_buffer = _ITRON_Message_buffer_Get(mbfid, &location);
57  switch (location) {
58#if defined(RTEMS_MULTIPROCESSING)
59    case OBJECTS_REMOTE:
60#endif
61    case OBJECTS_ERROR:           /* Multiprocessing not supported */
62      return _ITRON_Message_buffer_Clarify_get_id_error(mbfid);
63
64    case OBJECTS_LOCAL:
65      _CORE_message_queue_Seize(
66          &the_message_buffer->message_queue,
67          the_message_buffer->Object.id,
68          msg,
69          &msgsz,
70          wait,
71          interval
72      );
73      _Thread_Enable_dispatch();
74      *p_msgsz = msgsz;
75      status = (CORE_message_queue_Status)_Thread_Executing->Wait.return_code;
76      return
77        _ITRON_Message_buffer_Translate_core_message_buffer_return_code(status);
78    }
79
80    /*
81     *  If multiprocessing were supported, this is where we would announce
82     *  the existence of the semaphore to the rest of the system.
83     */
84
85#if defined(RTEMS_MULTIPROCESSING)
86#endif
87    return E_OK;
88}
Note: See TracBrowser for help on using the repository browser.