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

4.104.114.84.95
Last change on this file since aaf6063 was f42b726, checked in by Joel Sherrill <joel.sherrill@…>, on 01/24/01 at 14:17:28

2001-01-24 Ralf Corsepius <corsepiu@…>

  • configure.in: Add src/config.h
  • src/Makefile.am: Add INCLUDES += -I. to pickup config.h
  • src/.cvsignore: Add config.h and stamp-h
  • src/*.c: Add config.h support.
  • 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
52  /*
53   * Validate the priority.
54   * XXX - Do not validate msg_prio is not less than 0.
55   */
56
57  if ( msg_prio > MQ_PRIO_MAX )
58    set_errno_and_return_minus_one( EINVAL );
59
60  the_mq = _POSIX_Message_queue_Get( mqdes, &location );
61
62  switch ( location ) {
63    case OBJECTS_ERROR:
64      set_errno_and_return_minus_one( EBADF );
65
66    case OBJECTS_REMOTE:
67      _Thread_Dispatch();
68      return POSIX_MP_NOT_IMPLEMENTED();
69      set_errno_and_return_minus_one( EINVAL );
70
71    case OBJECTS_LOCAL:
72      if ( (the_mq->oflag & O_ACCMODE) == O_RDONLY ) {
73        _Thread_Enable_dispatch();
74        set_errno_and_return_minus_one( EBADF );
75      }
76
77      _CORE_message_queue_Submit(
78        &the_mq->Message_queue,
79        (void *) msg_ptr,
80        msg_len,
81        mqdes,      /* mqd_t is an object id */
82#if defined(RTEMS_MULTIPROCESSING)
83        NULL,      /* XXX _POSIX_Message_queue_Core_message_queue_mp_support*/
84#else
85        NULL,
86#endif
87        _POSIX_Message_queue_Priority_to_core( msg_prio ),
88         (the_mq->oflag & O_NONBLOCK) ? FALSE : TRUE,
89        timeout    /* no timeout */
90      );
91
92      _Thread_Enable_dispatch();
93      if ( !_Thread_Executing->Wait.return_code )
94        return 0;
95
96      set_errno_and_return_minus_one(
97        _POSIX_Message_queue_Translate_core_message_queue_return_code(
98          _Thread_Executing->Wait.return_code
99        )
100      );
101  }
102  return POSIX_BOTTOM_REACHED();
103}
Note: See TracBrowser for help on using the repository browser.