source: rtems/cpukit/posix/src/mqueuenotify.c @ 21789a21

5
Last change on this file since 21789a21 was 21789a21, checked in by Sebastian Huber <sebastian.huber@…>, on 07/28/15 at 12:45:42

score: Rename _POSIX_Absolute_timeout_to_ticks()

Rename _POSIX_Absolute_timeout_to_ticks() to
_TOD_Absolute_timeout_to_ticks() and move it to the score directory.
Delete empty <rtems/posix/time.h>.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/**
2 * @file
3 *
4 * @brief Notify Process that a Message is Available on a Queue
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.org/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#include <sys/types.h>
29#include <signal.h>
30
31#include <rtems/system.h>
32#include <rtems/score/watchdog.h>
33#include <rtems/seterr.h>
34#include <rtems/posix/mqueueimpl.h>
35
36/*
37 *  _POSIX_Message_queue_Notify_handler
38 *
39 */
40
41static void _POSIX_Message_queue_Notify_handler(
42  void    *user_data
43)
44{
45  POSIX_Message_queue_Control *the_mq;
46
47  the_mq = user_data;
48
49  kill( getpid(), the_mq->notification.sigev_signo );
50
51  _CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
52}
53
54int mq_notify(
55  mqd_t                  mqdes,
56  const struct sigevent *notification
57)
58{
59  POSIX_Message_queue_Control    *the_mq;
60  POSIX_Message_queue_Control_fd *the_mq_fd;
61  Objects_Locations               location;
62
63  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
64  switch ( location ) {
65
66    case OBJECTS_LOCAL:
67      the_mq = the_mq_fd->Queue;
68
69      if ( notification ) {
70        if ( _CORE_message_queue_Is_notify_enabled( &the_mq->Message_queue ) ) {
71          _Objects_Put( &the_mq_fd->Object );
72          rtems_set_errno_and_return_minus_one( EBUSY );
73        }
74
75        _CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
76
77        the_mq->notification = *notification;
78
79        _CORE_message_queue_Set_notify(
80          &the_mq->Message_queue,
81          _POSIX_Message_queue_Notify_handler,
82          the_mq
83        );
84      } else {
85
86        _CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
87
88      }
89
90      _Objects_Put( &the_mq_fd->Object );
91      return 0;
92
93#if defined(RTEMS_MULTIPROCESSING)
94    case OBJECTS_REMOTE:
95#endif
96    case OBJECTS_ERROR:
97      break;
98  }
99
100  rtems_set_errno_and_return_minus_one( EBADF );
101}
Note: See TracBrowser for help on using the repository browser.