source: rtems/cpukit/posix/src/mqueuetimedreceive.c @ 8f6b7b51

4.104.115
Last change on this file since 8f6b7b51 was 6805ac37, checked in by Joel Sherrill <joel.sherrill@…>, on 10/10/09 at 15:21:41

2009-10-10 Joel Sherrill <joel.sherrill@…>

  • posix/src/mqueuetimedreceive.c, posix/src/mqueuetimedsend.c, posix/src/mutextimedlock.c, posix/src/prwlocktimedrdlock.c, posix/src/prwlocktimedwrlock.c, posix/src/semtimedwait.c: Switch from switch to if's because only one value needed to be tested. This shrinks the code and makes it easier to do coverage analysis on.
  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  NOTE:  The structure of the routines is identical to that of POSIX
3 *         Message_queues to leave the option of having unnamed message
4 *         queues at a future date.  They are currently not part of the
5 *         POSIX standard but unnamed message_queues are.  This is also
6 *         the reason for the apparently unnecessary tracking of
7 *         the process_shared attribute.  [In addition to the fact that
8 *         it would be trivial to add pshared to the mq_attr structure
9 *         and have process private message queues.]
10 *
11 *         This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open
12 *         time.
13 */
14
15/*
16 *  COPYRIGHT (c) 1989-2008.
17 *  On-Line Applications Research Corporation (OAR).
18 *
19 *  The license and distribution terms for this file may be
20 *  found in the file LICENSE in this distribution or at
21 *  http://www.rtems.com/license/LICENSE.
22 *
23 *  $Id$
24 */
25
26#if HAVE_CONFIG_H
27#include "config.h"
28#endif
29
30#include <stdarg.h>
31
32#include <pthread.h>
33#include <limits.h>
34#include <errno.h>
35#include <fcntl.h>
36#include <mqueue.h>
37
38#include <rtems/system.h>
39#include <rtems/score/watchdog.h>
40#include <rtems/seterr.h>
41#include <rtems/posix/mqueue.h>
42#include <rtems/posix/time.h>
43
44/*PAGE
45 *
46 *  15.2.5 Receive a Message From a Message Queue, P1003.1b-1993, p. 279
47 *
48 *  NOTE: P1003.4b/D8, p. 45 adds mq_timedreceive().
49 */
50
51ssize_t mq_timedreceive(
52  mqd_t                  mqdes,
53  char                  *msg_ptr,
54  size_t                 msg_len,
55  unsigned int          *msg_prio,
56  const struct timespec *abstime
57)
58{
59  Watchdog_Interval                            ticks;
60  bool                                         do_wait = true;
61  POSIX_Absolute_timeout_conversion_results_t  status;
62
63  /*
64   *  POSIX requires that blocking calls with timeouts that take
65   *  an absolute timeout must ignore issues with the absolute
66   *  time provided if the operation would otherwise succeed.
67   *  So we check the abstime provided, and hold on to whether it
68   *  is valid or not.  If it isn't correct and in the future,
69   *  then we do a polling operation and convert the UNSATISFIED
70   *  status into the appropriate error.
71   *
72   *  If the status is POSIX_ABSOLUTE_TIMEOUT_INVALID,
73   *  POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST, or POSIX_ABSOLUTE_TIMEOUT_IS_NOW,
74   *  then we should not wait.
75   */
76  status = _POSIX_Absolute_timeout_to_ticks( abstime, &ticks );
77  if ( status != POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE )
78    do_wait = false;
79
80  return _POSIX_Message_queue_Receive_support(
81    mqdes,
82    msg_ptr,
83    msg_len,
84    msg_prio,
85    do_wait,
86    ticks
87  );
88}
Note: See TracBrowser for help on using the repository browser.