OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [posix/] [src/] [mqueuesendsupp.c] - Blame information for rev 532

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: mqueuesendsupp.c,v 1.2 2001-09-27 11:59:17 chris Exp $
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
#ifndef MQ_PRIO_MAX
32
#define MQ_PRIO_MAX 32
33
#endif
34
 
35
/*PAGE
36
 *
37
 *  _POSIX_Message_queue_Send_support
38
 */
39
 
40
int _POSIX_Message_queue_Send_support(
41
  mqd_t               mqdes,
42
  const char         *msg_ptr,
43
  unsigned32          msg_len,
44
  unsigned32          msg_prio,
45
  Watchdog_Interval   timeout
46
)
47
{
48
  register POSIX_Message_queue_Control *the_mq;
49
  Objects_Locations                     location;
50
 
51
  /*
52
   * Validate the priority.
53
   * XXX - Do not validate msg_prio is not less than 0.
54
   */
55
 
56
  if ( msg_prio > MQ_PRIO_MAX )
57
    set_errno_and_return_minus_one( EINVAL );
58
 
59
  the_mq = _POSIX_Message_queue_Get( mqdes, &location );
60
 
61
  switch ( location ) {
62
    case OBJECTS_ERROR:
63
      set_errno_and_return_minus_one( EBADF );
64
 
65
    case OBJECTS_REMOTE:
66
      _Thread_Dispatch();
67
      return POSIX_MP_NOT_IMPLEMENTED();
68
      set_errno_and_return_minus_one( EINVAL );
69
 
70
    case OBJECTS_LOCAL:
71
      if ( (the_mq->oflag & O_ACCMODE) == O_RDONLY ) {
72
        _Thread_Enable_dispatch();
73
        set_errno_and_return_minus_one( EBADF );
74
      }
75
 
76
      _CORE_message_queue_Submit(
77
        &the_mq->Message_queue,
78
        (void *) msg_ptr,
79
        msg_len,
80
        mqdes,      /* mqd_t is an object id */
81
#if defined(RTEMS_MULTIPROCESSING)
82
        NULL,      /* XXX _POSIX_Message_queue_Core_message_queue_mp_support*/
83
#else
84
        NULL,
85
#endif
86
        _POSIX_Message_queue_Priority_to_core( msg_prio ),
87
         (the_mq->oflag & O_NONBLOCK) ? FALSE : TRUE,
88
        timeout    /* no timeout */
89
      );
90
 
91
      _Thread_Enable_dispatch();
92
      if ( !_Thread_Executing->Wait.return_code )
93
        return 0;
94
 
95
      set_errno_and_return_minus_one(
96
        _POSIX_Message_queue_Translate_core_message_queue_return_code(
97
          _Thread_Executing->Wait.return_code
98
        )
99
      );
100
  }
101
  return POSIX_BOTTOM_REACHED();
102
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.