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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [posix/] [src/] [mqueuenotify.c] - Blame information for rev 609

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: mqueuenotify.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
#include <sys/types.h>
25
#include <signal.h>
26
 
27
#include <rtems/system.h>
28
#include <rtems/score/watchdog.h>
29
#include <rtems/posix/seterr.h>
30
#include <rtems/posix/mqueue.h>
31
#include <rtems/posix/time.h>
32
 
33
/*PAGE
34
 *
35
 *  _POSIX_Message_queue_Notify_handler
36
 *
37
 */
38
 
39
void _POSIX_Message_queue_Notify_handler(
40
  void    *user_data
41
)
42
{
43
  POSIX_Message_queue_Control *the_mq;
44
 
45
  the_mq = user_data;
46
 
47
  kill( getpid(), the_mq->notification.sigev_signo );
48
 
49
  _CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
50
}
51
 
52
/*PAGE
53
 *
54
 *  15.2.6 Notify Process that a Message is Available on a Queue,
55
 *         P1003.1b-1993, p. 280
56
 */
57
 
58
int mq_notify(
59
  mqd_t                  mqdes,
60
  const struct sigevent *notification
61
)
62
{
63
  register POSIX_Message_queue_Control *the_mq;
64
  Objects_Locations                     location;
65
 
66
  the_mq = _POSIX_Message_queue_Get( mqdes, &location );
67
  switch ( location ) {
68
    case OBJECTS_ERROR:
69
      set_errno_and_return_minus_one( EBADF );
70
    case OBJECTS_REMOTE:
71
      _Thread_Dispatch();
72
      return POSIX_MP_NOT_IMPLEMENTED();
73
      set_errno_and_return_minus_one( EINVAL );
74
    case OBJECTS_LOCAL:
75
      if ( notification ) {
76
        if ( _CORE_message_queue_Is_notify_enabled( &the_mq->Message_queue ) ) {
77
          _Thread_Enable_dispatch();
78
          set_errno_and_return_minus_one( EBUSY );
79
        }
80
 
81
        _CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
82
 
83
        the_mq->notification = *notification;
84
 
85
        _CORE_message_queue_Set_notify(
86
          &the_mq->Message_queue,
87
          _POSIX_Message_queue_Notify_handler,
88
          the_mq
89
        );
90
      } else {
91
 
92
        _CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
93
 
94
      }
95
 
96
      _Thread_Enable_dispatch();
97
      return 0;
98
  }
99
  return POSIX_BOTTOM_REACHED();
100
}
101
 

powered by: WebSVN 2.1.0

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