source: rtems/c/src/exec/posix/src/mqueuesendsupp.c @ b3a6713

Last change on this file since b3a6713 was b3a6713, checked in by Joel Sherrill <joel.sherrill@…>, on 08/16/01 at 21:36:15

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

  • src/mqueuesendsupp.c: Account for possibly blocking during the core send operation.

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

  • src/msgqsubmit.c: Add a comment indicating that we do not have to account for possibly blocking during the core send operation because Classic API message queue send is always non-blocking.

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

  • include/rtems/score/coremsg.h, src/coremsgsubmit.c: Add a new return status to account for blocking sends. Otherwise, the caller will think that the returned message status will have the ultimate results of the operation. If the send times out, the final status will be in the return_code of the thread.

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

  • src/coremutexsurrender.c: Use holder thread not executing thread because even though they may and often are the same it is not guaranteed unless the proper attribute is set.

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

  • startup/linkcmds: Modified to work better with gcc 2.8.1 and gnat 3.13p.

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

  • tools/runtest.in: Recognize debug variant of monitor test.

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

  • sp13/sp13.scn: Id in screen had wrong class field value.
  • sp13/system.h: Account for message buffer memory.
  • sp13/task2.c: Remove unnecessary check for failure.

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

  • sp20/system.h: Account for extra task stacks properly.

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

  • include/tmacros.h: Attempt to print errno as further information.
  • Property mode set to 100644
File size: 3.0 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#include <stdarg.h>
18
19#include <pthread.h>
20#include <limits.h>
21#include <errno.h>
22#include <fcntl.h>
23#include <mqueue.h>
24
25#include <rtems/system.h>
26#include <rtems/score/watchdog.h>
27#include <rtems/posix/seterr.h>
28#include <rtems/posix/mqueue.h>
29#include <rtems/posix/time.h>
30
31
32/*PAGE
33 *
34 *  _POSIX_Message_queue_Send_support
35 */
36 
37int _POSIX_Message_queue_Send_support(
38  mqd_t               mqdes,
39  const char         *msg_ptr,
40  unsigned32          msg_len,
41  unsigned32          msg_prio,
42  Watchdog_Interval   timeout
43)
44{
45  register POSIX_Message_queue_Control *the_mq;
46  Objects_Locations                     location;
47  CORE_message_queue_Status             msg_status;
48
49  /*
50   * Validate the priority.
51   * XXX - Do not validate msg_prio is not less than 0.
52   */
53
54  if ( msg_prio > MQ_PRIO_MAX )
55    set_errno_and_return_minus_one( EINVAL );
56
57  the_mq = _POSIX_Message_queue_Get( mqdes, &location );
58
59  switch ( location ) {
60    case OBJECTS_ERROR:
61      set_errno_and_return_minus_one( EBADF );
62
63    case OBJECTS_REMOTE:
64      _Thread_Dispatch();
65      return POSIX_MP_NOT_IMPLEMENTED();
66      set_errno_and_return_minus_one( EINVAL );
67
68    case OBJECTS_LOCAL:
69      if ( (the_mq->oflag & O_ACCMODE) == O_RDONLY ) {
70        _Thread_Enable_dispatch();
71        set_errno_and_return_minus_one( EBADF );
72      }
73
74      msg_status = _CORE_message_queue_Submit(
75        &the_mq->Message_queue,
76        (void *) msg_ptr,
77        msg_len,
78        mqdes,      /* mqd_t is an object id */
79#if defined(RTEMS_MULTIPROCESSING)
80        NULL,      /* XXX _POSIX_Message_queue_Core_message_queue_mp_support*/
81#else
82        NULL,
83#endif
84        _POSIX_Message_queue_Priority_to_core( msg_prio ),
85         (the_mq->oflag & O_NONBLOCK) ? FALSE : TRUE,
86        timeout    /* no timeout */
87      );
88
89      _Thread_Enable_dispatch();
90
91      /*
92       *  If we had to block, then this is where the task returns
93       *  after it wakes up.  The returned status is correct for
94       *  non-blocking operations but if we blocked, then we need
95       *  to look at the status in our TCB.
96       */
97
98      if ( msg_status == CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT )
99        msg_status = _Thread_Executing->Wait.return_code;
100
101      if ( !msg_status )
102        return msg_status;
103
104      set_errno_and_return_minus_one(
105        _POSIX_Message_queue_Translate_core_message_queue_return_code(
106          msg_status
107        )
108      );
109  }
110  return POSIX_BOTTOM_REACHED();
111}
Note: See TracBrowser for help on using the repository browser.