source: rtems/cpukit/posix/src/mqueuesendsupp.c @ a781bbff

4.104.114.84.95
Last change on this file since a781bbff was a781bbff, checked in by Joel Sherrill <joel.sherrill@…>, on 08/09/01 at 20:48:20

2001-08-09 Joel Sherrill <joel@…>

  • src/mqueuesendsupp.c: Unblocking message queue operations should NOT use _Thread_Executing for return status since it is permissible to invoke message send operations from an ISR. This was reported by Suvrat Gupta <suvrat@…>.
  • Property mode set to 100644
File size: 2.7 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 *  $Id$
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <stdarg.h>
22
23#include <pthread.h>
24#include <limits.h>
25#include <errno.h>
26#include <fcntl.h>
27#include <mqueue.h>
28
29#include <rtems/system.h>
30#include <rtems/score/watchdog.h>
31#include <rtems/seterr.h>
32#include <rtems/posix/mqueue.h>
33#include <rtems/posix/time.h>
34
35
36/*PAGE
37 *
38 *  _POSIX_Message_queue_Send_support
39 */
40 
41int _POSIX_Message_queue_Send_support(
42  mqd_t               mqdes,
43  const char         *msg_ptr,
44  unsigned32          msg_len,
45  unsigned32          msg_prio,
46  Watchdog_Interval   timeout
47)
48{
49  register POSIX_Message_queue_Control *the_mq;
50  Objects_Locations                     location;
51  CORE_message_queue_Status             msg_status;
52
53  /*
54   * Validate the priority.
55   * XXX - Do not validate msg_prio is not less than 0.
56   */
57
58  if ( msg_prio > MQ_PRIO_MAX )
59    set_errno_and_return_minus_one( EINVAL );
60
61  the_mq = _POSIX_Message_queue_Get( mqdes, &location );
62
63  switch ( location ) {
64    case OBJECTS_ERROR:
65      set_errno_and_return_minus_one( EBADF );
66
67    case OBJECTS_REMOTE:
68      _Thread_Dispatch();
69      return POSIX_MP_NOT_IMPLEMENTED();
70      set_errno_and_return_minus_one( EINVAL );
71
72    case OBJECTS_LOCAL:
73      if ( (the_mq->oflag & O_ACCMODE) == O_RDONLY ) {
74        _Thread_Enable_dispatch();
75        set_errno_and_return_minus_one( EBADF );
76      }
77
78      msg_status = _CORE_message_queue_Submit(
79        &the_mq->Message_queue,
80        (void *) msg_ptr,
81        msg_len,
82        mqdes,      /* mqd_t is an object id */
83#if defined(RTEMS_MULTIPROCESSING)
84        NULL,      /* XXX _POSIX_Message_queue_Core_message_queue_mp_support*/
85#else
86        NULL,
87#endif
88        _POSIX_Message_queue_Priority_to_core( msg_prio ),
89         (the_mq->oflag & O_NONBLOCK) ? FALSE : TRUE,
90        timeout    /* no timeout */
91      );
92
93      _Thread_Enable_dispatch();
94      if ( !msg_status )
95        return 0;
96
97      set_errno_and_return_minus_one(
98        _POSIX_Message_queue_Translate_core_message_queue_return_code(
99          msg_status
100        )
101      );
102  }
103  return POSIX_BOTTOM_REACHED();
104}
Note: See TracBrowser for help on using the repository browser.