source: rtems/cpukit/posix/src/mqueuesetattr.c @ c55df85

4.104.114.84.95
Last change on this file since c55df85 was e180a77e, checked in by Joel Sherrill <joel.sherrill@…>, on 01/04/02 at 18:28:24

2002-01-04 Ralf Corsepius <corsepiu@…>

  • src/clockgetres.c: Apply rtems_set_errno_and_return_minus_one.
  • src/clockgettime.c: Apply rtems_set_errno_and_return_minus_one.
  • src/clocksettime.c: Apply rtems_set_errno_and_return_minus_one.
  • src/killinfo.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueueclose.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueuecreatesupp.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueuegetattr.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueuenotify.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueueopen.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueuerecvsupp.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueuesendsupp.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueuesetattr.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueueunlink.c: Apply rtems_set_errno_and_return_minus_one.
  • src/nanosleep.c: Apply rtems_set_errno_and_return_minus_one.
  • src/pthreadkill.c: Apply rtems_set_errno_and_return_minus_one.
  • src/pthreadsigmask.c: Apply rtems_set_errno_and_return_minus_one.
  • src/ptimer1.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sched.c: Apply rtems_set_errno_and_return_minus_one.
  • src/semaphorecreatesupp.c: Apply rtems_set_errno_and_return_minus_one.
  • src/semaphorewaitsupp.c: Apply rtems_set_errno_and_return_minus_one.
  • src/semclose.c: Apply rtems_set_errno_and_return_minus_one.
  • src/semdestroy.c: Apply rtems_set_errno_and_return_minus_one.
  • src/semgetvalue.c: Apply rtems_set_errno_and_return_minus_one.
  • src/seminit.c: Apply rtems_set_errno_and_return_minus_one.
  • src/semopen.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sempost.c: Apply rtems_set_errno_and_return_minus_one.
  • src/semunlink.c: Apply rtems_set_errno_and_return_minus_one.
  • src/setpgid.c: Apply rtems_set_errno_and_return_minus_one.
  • src/setsid.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigaction.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigaddset.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigdelset.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigemptyset.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigfillset.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigismember.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigpending.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigtimedwait.c: Apply rtems_set_errno_and_return_minus_one.
  • src/utsname.c: Apply rtems_set_errno_and_return_minus_one.
  • Property mode set to 100644
File size: 2.9 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 *  15.2.7 Set Message Queue Attributes, P1003.1b-1993, p. 281
38 */
39
40int mq_setattr(
41  mqd_t                 mqdes,
42  const struct mq_attr *mqstat,
43  struct mq_attr       *omqstat
44)
45{
46  register POSIX_Message_queue_Control *the_mq;
47  CORE_message_queue_Control           *the_core_mq;
48  Objects_Locations                     location;
49  CORE_message_queue_Attributes        *the_mq_attr;
50 
51  if ( !mqstat )
52    rtems_set_errno_and_return_minus_one( EINVAL );
53
54  the_mq = _POSIX_Message_queue_Get( mqdes, &location );
55  switch ( location ) {
56    case OBJECTS_ERROR:
57      rtems_set_errno_and_return_minus_one( EBADF );
58    case OBJECTS_REMOTE:
59      _Thread_Dispatch();
60      return POSIX_MP_NOT_IMPLEMENTED();
61      rtems_set_errno_and_return_minus_one( EINVAL );
62    case OBJECTS_LOCAL:
63
64      the_core_mq = &the_mq->Message_queue;
65
66      /*
67       *  Return the old values.
68       */
69
70      /* XXX this is the same stuff as is in mq_getattr... and probably */
71      /* XXX should be in an inlined private routine */
72
73      if ( omqstat ) {
74        omqstat->mq_flags   = the_mq->oflag;
75        omqstat->mq_msgsize = the_core_mq->maximum_message_size;
76        omqstat->mq_maxmsg  = the_core_mq->maximum_pending_messages;
77        omqstat->mq_curmsgs = the_core_mq->number_of_pending_messages;
78      }
79 
80      /*
81       *  If blocking was in effect and is not now, then there
82       *  may be threads blocked on this message queue which need
83       *  to be unblocked to make the state of the message queue
84       *  consistent for future use.
85       */
86 
87      the_mq_attr = &the_core_mq->Attributes;
88
89      if ( !(the_mq->oflag & O_NONBLOCK) &&         /* were blocking */
90           (mqstat->mq_flags & O_NONBLOCK) ) {      /* and now are not */
91        _CORE_message_queue_Flush_waiting_threads( the_core_mq );
92      }
93     
94      the_mq->oflag = mqstat->mq_flags;
95
96      _Thread_Enable_dispatch();
97      return 0;
98  }
99  return POSIX_BOTTOM_REACHED();
100}
101
Note: See TracBrowser for help on using the repository browser.