[4dc89814] | 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 |
---|
[874297f3] | 5 | * POSIX standard but unnamed message_queues are. This is also |
---|
| 6 | * the reason for the apparently unnecessary tracking of |
---|
[4dc89814] | 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. |
---|
[412dbff6] | 13 | */ |
---|
| 14 | |
---|
| 15 | /* |
---|
[6a0898b] | 16 | * COPYRIGHT (c) 1989-2008. |
---|
[412dbff6] | 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. |
---|
[4dc89814] | 22 | * |
---|
| 23 | * $Id$ |
---|
| 24 | */ |
---|
| 25 | |
---|
[f42b726] | 26 | #if HAVE_CONFIG_H |
---|
| 27 | #include "config.h" |
---|
| 28 | #endif |
---|
| 29 | |
---|
[4dc89814] | 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> |
---|
[188c82b] | 40 | #include <rtems/seterr.h> |
---|
[4dc89814] | 41 | #include <rtems/posix/mqueue.h> |
---|
| 42 | #include <rtems/posix/time.h> |
---|
| 43 | |
---|
| 44 | /*PAGE |
---|
| 45 | * |
---|
| 46 | * 15.2.4 Send a Message to a Message Queue, P1003.1b-1993, p. 277 |
---|
| 47 | * |
---|
| 48 | * NOTE: P1003.4b/D8, p. 45 adds mq_timedsend(). |
---|
| 49 | */ |
---|
| 50 | |
---|
| 51 | int mq_timedsend( |
---|
| 52 | mqd_t mqdes, |
---|
| 53 | const char *msg_ptr, |
---|
| 54 | size_t msg_len, |
---|
| 55 | unsigned int msg_prio, |
---|
[6a0898b] | 56 | const struct timespec *abstime |
---|
[4dc89814] | 57 | ) |
---|
| 58 | { |
---|
[6a0898b] | 59 | Watchdog_Interval ticks; |
---|
| 60 | boolean do_wait; |
---|
| 61 | |
---|
| 62 | /* |
---|
| 63 | * POSIX requires that blocking calls with timeouts that take |
---|
| 64 | * an absolute timeout must ignore issues with the absolute |
---|
| 65 | * time provided if the operation would otherwise succeed. |
---|
| 66 | * So we check the abstime provided, and hold on to whether it |
---|
| 67 | * is valid or not. If it isn't correct and in the future, |
---|
| 68 | * then we do a polling operation and convert the UNSATISFIED |
---|
| 69 | * status into the appropriate error. |
---|
| 70 | */ |
---|
| 71 | switch ( _POSIX_Absolute_timeout_to_ticks( abstime, &ticks ) ) { |
---|
| 72 | case POSIX_ABSOLUTE_TIMEOUT_INVALID: |
---|
| 73 | case POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST: |
---|
| 74 | case POSIX_ABSOLUTE_TIMEOUT_IS_NOW: |
---|
| 75 | do_wait = FALSE; |
---|
| 76 | break; |
---|
| 77 | case POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE: |
---|
| 78 | do_wait = TRUE; |
---|
| 79 | break; |
---|
| 80 | } |
---|
| 81 | |
---|
[4dc89814] | 82 | return _POSIX_Message_queue_Send_support( |
---|
| 83 | mqdes, |
---|
| 84 | msg_ptr, |
---|
| 85 | msg_len, |
---|
| 86 | msg_prio, |
---|
[6a0898b] | 87 | do_wait, |
---|
| 88 | ticks |
---|
[4dc89814] | 89 | ); |
---|
| 90 | } |
---|