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

4.115
Last change on this file since be1b8a7 was 972a5c5f, checked in by Sebastian Huber <sebastian.huber@…>, on 07/18/13 at 13:12:05

posix: Create message queue implementation header

Move implementation specific parts of mqueue.h and mqueue.inl into new
header file mqueueimpl.h. The mqueue.h contains now only the
application visible API.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file
3 *
4 * @brief Set Message Queue Attributes
5 * @ingroup POSIX_MQUEUE
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
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/mqueueimpl.h>
33#include <rtems/posix/time.h>
34
35int mq_setattr(
36  mqd_t                 mqdes,
37  const struct mq_attr *mqstat,
38  struct mq_attr       *omqstat
39)
40{
41  POSIX_Message_queue_Control_fd *the_mq_fd;
42  CORE_message_queue_Control     *the_core_mq;
43  Objects_Locations               location;
44
45  if ( !mqstat )
46    rtems_set_errno_and_return_minus_one( EINVAL );
47
48  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
49  switch ( location ) {
50
51    case OBJECTS_LOCAL:
52
53      the_core_mq = &the_mq_fd->Queue->Message_queue;
54
55      /*
56       *  Return the old values.
57       */
58
59      if ( omqstat ) {
60        omqstat->mq_flags   = the_mq_fd->oflag;
61        omqstat->mq_msgsize = the_core_mq->maximum_message_size;
62        omqstat->mq_maxmsg  = the_core_mq->maximum_pending_messages;
63        omqstat->mq_curmsgs = the_core_mq->number_of_pending_messages;
64      }
65
66      the_mq_fd->oflag = mqstat->mq_flags;
67      _Objects_Put( &the_mq_fd->Object );
68      return 0;
69
70#if defined(RTEMS_MULTIPROCESSING)
71    case OBJECTS_REMOTE:
72#endif
73    case OBJECTS_ERROR:
74      break;
75  }
76
77  rtems_set_errno_and_return_minus_one( EBADF );
78}
Note: See TracBrowser for help on using the repository browser.