source: rtems/c/src/exec/posix/src/mqueuecreatesupp.c @ f42b726

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