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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [posix/] [src/] [mqueuecreatesupp.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: mqueuecreatesupp.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
/*PAGE
32
 *
33
 *  _POSIX_Message_queue_Create_support
34
 *
35
 *  This routine does the actual creation and initialization of
36
 *  a poxix message queue.
37
 */
38
 
39
int _POSIX_Message_queue_Create_support(
40
  const char                    *name,
41
  int                            pshared,
42
  unsigned int                   oflag,
43
  struct mq_attr                *attr_ptr,
44
  POSIX_Message_queue_Control  **message_queue
45
)
46
{
47
  POSIX_Message_queue_Control   *the_mq;
48
  CORE_message_queue_Attributes *the_mq_attr;
49
  struct mq_attr                 attr;
50
 
51
  _Thread_Disable_dispatch();
52
 
53
  /*
54
   *  There is no real basis for the default values.  They will work
55
   *  but were not compared against any existing implementation for
56
   *  compatibility.  See README.mqueue for an example program we
57
   *  think will print out the defaults.  Report anything you find with it.
58
   */
59
 
60
  if ( attr_ptr == NULL ) {
61
    attr.mq_maxmsg  = 10;
62
    attr.mq_msgsize = 16;
63
  } else {
64
    if ( attr_ptr->mq_maxmsg < 0 ){
65
      _Thread_Enable_dispatch();
66
      set_errno_and_return_minus_one( EINVAL );
67
    }
68
 
69
    if ( attr_ptr->mq_msgsize < 0 ){
70
      _Thread_Enable_dispatch();
71
      set_errno_and_return_minus_one( EINVAL );
72
    }
73
 
74
    attr = *attr_ptr;
75
  }
76
 
77
#if 0 && defined(RTEMS_MULTIPROCESSING)
78
  if ( pshared == PTHREAD_PROCESS_SHARED &&
79
       !( _Objects_MP_Allocate_and_open( &_POSIX_Message_queue_Information, 0,
80
                            the_mq->Object.id, FALSE ) ) ) {
81
    _POSIX_Message_queue_Free( the_mq );
82
    _Thread_Enable_dispatch();
83
    set_errno_and_return_minus_one( ENFILE );
84
  }
85
#endif
86
 
87
  the_mq = _POSIX_Message_queue_Allocate();
88
  if ( !the_mq ) {
89
    _Thread_Enable_dispatch();
90
    set_errno_and_return_minus_one( ENFILE );
91
  }
92
 
93
  the_mq->process_shared  = pshared;
94
  the_mq->oflag = oflag;
95
  the_mq->named = TRUE;
96
  the_mq->open_count = 1;
97
  the_mq->linked = TRUE;
98
 
99
 
100
  /* XXX
101
   *
102
   *  Note that thread blocking discipline should be based on the
103
   *  current scheduling policy.
104
   */
105
 
106
  the_mq_attr = &the_mq->Message_queue.Attributes;
107
  the_mq_attr->discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
108
 
109
  if ( ! _CORE_message_queue_Initialize(
110
           &the_mq->Message_queue,
111
           OBJECTS_POSIX_MESSAGE_QUEUES,
112
           the_mq_attr,
113
           attr.mq_maxmsg,
114
           attr.mq_msgsize,
115
#if 0 && defined(RTEMS_MULTIPROCESSING)
116
           _POSIX_Message_queue_MP_Send_extract_proxy
117
#else
118
           NULL
119
#endif
120
      ) ) {
121
 
122
#if 0 && defined(RTEMS_MULTIPROCESSING)
123
    if ( pshared == PTHREAD_PROCESS_SHARED )
124
      _Objects_MP_Close( &_POSIX_Message_queue_Information, the_mq->Object.id );
125
#endif
126
 
127
    _POSIX_Message_queue_Free( the_mq );
128
    _Thread_Enable_dispatch();
129
    set_errno_and_return_minus_one( ENOSPC );
130
  }
131
 
132
  _Objects_Open(
133
    &_POSIX_Message_queue_Information,
134
    &the_mq->Object,
135
    (char *) name
136
  );
137
 
138
  *message_queue = the_mq;
139
 
140
#if 0 && defined(RTEMS_MULTIPROCESSING)
141
  if ( pshared == PTHREAD_PROCESS_SHARED )
142
    _POSIX_Message_queue_MP_Send_process_packet(
143
      POSIX_MESSAGE_QUEUE_MP_ANNOUNCE_CREATE,
144
      the_mq->Object.id,
145
      (char *) name,
146
 
147
    );
148
#endif
149
 
150
  _Thread_Enable_dispatch();
151
  return 0;
152
}
153
 
154
 
155
 
156
 
157
 

powered by: WebSVN 2.1.0

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