|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
  
 
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #include "EXTERN.h"  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #include "perl.h"  | 
| 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #include "XSUB.h"  | 
| 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #include   | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #include   | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #include   | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 static char cvs_id[] = "$Id: MQ.xs,v 1.8 2003/01/27 10:43:11 ilja Exp $";  | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
11
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 static int not_here(char *s)  | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 {  | 
| 
13
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     croak("POSIX::RT::MQ::%s not implemented on this architecture", s);  | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     return -1;  | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 MODULE = POSIX::RT::MQ		PACKAGE = POSIX::RT::MQ  | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 PROTOTYPES: ENABLE  | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 int   | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 MQ_OPEN_MAX()  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     PREINIT:  | 
| 
23
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         int val=-1;  | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     CODE:  | 
| 
25
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	errno = 0;  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #ifdef  _SC_MQ_OPEN_MAX  | 
| 
27
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         val = sysconf(_SC_MQ_OPEN_MAX);  | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #endif  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	/* if errno is still 0 the limit is indeterminate */  | 
| 
30
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         if (errno && val==-1) not_here("MQ_OPEN_MAX");   | 
| 
 
 | 
 
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
31
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL=val;  | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     OUTPUT:  | 
| 
33
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 int   | 
| 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 MQ_PRIO_MAX()  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     PREINIT:  | 
| 
38
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         int val=-1;  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     CODE:  | 
| 
40
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	errno = 0;  | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #ifdef _SC_MQ_PRIO_MAX  | 
| 
42
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         val = sysconf(_SC_MQ_PRIO_MAX);  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #endif  | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	/* if errno is still 0 the limit is indeterminate */  | 
| 
45
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         if (errno && val==-1) not_here("MQ_PRIO_MAX");  | 
| 
 
 | 
 
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
46
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL=val;  | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     OUTPUT:  | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL  | 
| 
49
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
50
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 mqd_t   | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 mq_open(name,oflag,mode,attr=NULL)  | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         char*  name   | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         int    oflag  | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         Mode_t mode  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         SV*    attr  | 
| 
58
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     PREINIT:  | 
| 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         mqd_t           mqdes;  | 
| 
60
 | 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         struct mq_attr* mqa_ptr = NULL;  | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         STRLEN          mqa_len;  | 
| 
62
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     CODE:  | 
| 
63
 | 
30
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         if (attr != NULL)  | 
| 
64
 | 
19
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             mqa_ptr = (struct mq_attr*) SvPV(attr, mqa_len);  | 
| 
65
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
          /* check mqa_len ? */  | 
| 
66
 | 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         mqdes = mq_open(name, oflag, mode, mqa_ptr);  | 
| 
67
 | 
30
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         if (mqdes == (mqd_t)-1) { XSRETURN_UNDEF; }  | 
| 
68
 | 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL = mqdes;  | 
| 
69
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     OUTPUT:  | 
| 
70
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL      | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 int  | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 mq_close(mqdes)  | 
| 
74
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         mqd_t mqdes  | 
| 
75
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     CODE:  | 
| 
76
 | 
28
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         if (mq_close(mqdes) == -1) { XSRETURN_UNDEF; }  | 
| 
77
 | 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL = 1;  | 
| 
78
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     OUTPUT:  | 
| 
79
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL      | 
| 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
81
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 int  | 
| 
82
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 mq_unlink(name)  | 
| 
83
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         char* name   | 
| 
84
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     CODE:  | 
| 
85
 | 
27
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         if (mq_unlink(name) == -1) { XSRETURN_UNDEF; }  | 
| 
86
 | 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL = 1;  | 
| 
87
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     OUTPUT:  | 
| 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL      | 
| 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
90
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 SV*  | 
| 
91
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 mq_attr(mqdes, new_attr=NULL)  | 
| 
92
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         mqd_t  mqdes  | 
| 
93
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         SV*    new_attr;  | 
| 
94
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     PREINIT:  | 
| 
95
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         struct mq_attr  old_mqa;  | 
| 
96
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         struct mq_attr* new_mqa_ptr;  | 
| 
97
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         STRLEN          new_mqa_len;  | 
| 
98
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     CODE:  | 
| 
99
 | 
43
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         if (new_attr == NULL)  | 
| 
100
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         {  | 
| 
101
 | 
39
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             if (mq_getattr(mqdes, &old_mqa) == -1) { XSRETURN_UNDEF; }  | 
| 
102
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
103
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         else  | 
| 
104
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         {  | 
| 
105
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             new_mqa_ptr = (struct mq_attr*) SvPV(new_attr, new_mqa_len);  | 
| 
106
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             /* check new_mqa_len ? */  | 
| 
107
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             if (mq_setattr(mqdes, new_mqa_ptr, &old_mqa) == -1) { XSRETURN_UNDEF; }  | 
| 
108
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
109
 | 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL = newSVpvn((char*)&old_mqa, sizeof(old_mqa));  | 
| 
110
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     OUTPUT:  | 
| 
111
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL  | 
| 
112
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
           | 
| 
113
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 int   | 
| 
114
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 mq_send(mqdes, msg, msg_prio)  | 
| 
115
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         mqd_t  mqdes  | 
| 
116
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         SV*    msg  | 
| 
117
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         unsigned int msg_prio  | 
| 
118
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     PREINIT:  | 
| 
119
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         char*  msg_ptr;  | 
| 
120
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         STRLEN msg_len;  | 
| 
121
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     CODE:  | 
| 
122
 | 
88
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         msg_ptr = SvPV(msg, msg_len);  | 
| 
123
 | 
88
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         if (mq_send(mqdes, msg_ptr, msg_len, msg_prio) == -1) { XSRETURN_UNDEF; }  | 
| 
124
 | 
86
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL = 1;  | 
| 
125
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     OUTPUT:  | 
| 
126
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL  | 
| 
127
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
128
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 void   | 
| 
129
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 mq_receive(mqdes, msg_max_len)  | 
| 
130
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         mqd_t        mqdes  | 
| 
131
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         size_t       msg_max_len  | 
| 
132
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     PREINIT:  | 
| 
133
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         char*        msg_ptr;  | 
| 
134
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         ssize_t      msg_len;  | 
| 
135
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         unsigned int msg_prio;  | 
| 
136
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     PPCODE:  | 
| 
137
 | 
67
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         if ((msg_ptr = malloc(msg_max_len)) == NULL) { XSRETURN_EMPTY; }          | 
| 
138
 | 
67
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         msg_len = mq_receive(mqdes, msg_ptr, msg_max_len, &msg_prio);  | 
| 
139
 | 
67
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         if (msg_len == -1)  | 
| 
140
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         {   | 
| 
141
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             free(msg_ptr);  | 
| 
142
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             XSRETURN_EMPTY;  | 
| 
143
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
144
 | 
65
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         XPUSHs(sv_2mortal(newSVpvn(msg_ptr, msg_len)));  | 
| 
145
 | 
65
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         XPUSHs(sv_2mortal(newSVuv(msg_prio)));  | 
| 
146
 | 
65
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         free(msg_ptr);  | 
| 
147
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
148
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 void  | 
| 
149
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 mq_timedreceive(mqdes, msg_max_len, seconds)  | 
| 
150
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         mqd_t        mqdes  | 
| 
151
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         size_t       msg_max_len  | 
| 
152
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         unsigned int seconds  | 
| 
153
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
154
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     PREINIT:  | 
| 
155
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         char*        msg_ptr;  | 
| 
156
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         ssize_t      msg_len;  | 
| 
157
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         unsigned int msg_prio;  | 
| 
158
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     PPCODE:  | 
| 
159
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         struct timespec abs_timeout;  | 
| 
160
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         clock_gettime(CLOCK_REALTIME, &abs_timeout);  | 
| 
161
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         abs_timeout.tv_sec += seconds;  | 
| 
162
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         if ((msg_ptr = malloc(msg_max_len)) == NULL) { XSRETURN_EMPTY; }  | 
| 
163
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         msg_len = mq_timedreceive(mqdes, msg_ptr, msg_max_len, &msg_prio,  | 
| 
164
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         &abs_timeout);  | 
| 
165
 | 
2
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         if (msg_len == -1)  | 
| 
166
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         {  | 
| 
167
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             free(msg_ptr);  | 
| 
168
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             XSRETURN_EMPTY;  | 
| 
169
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
170
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         XPUSHs(sv_2mortal(newSVpvn(msg_ptr, msg_len)));  | 
| 
171
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         XPUSHs(sv_2mortal(newSVuv(msg_prio)));  | 
| 
172
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         free(msg_ptr);  | 
| 
173
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
174
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 int   | 
| 
175
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 mq_notify(mqdes, ...)  | 
| 
176
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         mqd_t  mqdes  | 
| 
177
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     PREINIT:  | 
| 
178
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         struct sigevent  sigev;  | 
| 
179
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         struct sigevent* sigevp = NULL;  | 
| 
180
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     CODE:  | 
| 
181
 | 
5
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         if (items > 1)  | 
| 
182
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         {  | 
| 
183
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             sigev.sigev_notify = SIGEV_SIGNAL;  | 
| 
184
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             sigev.sigev_signo  = SvIV(ST(1));  | 
| 
185
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             sigev.sigev_value.sival_int = 0;  | 
| 
186
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             sigevp = &sigev;  | 
| 
187
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
188
 | 
5
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         if (mq_notify(mqdes, sigevp) == -1) { XSRETURN_UNDEF; }  | 
| 
189
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL = 1;  | 
| 
190
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     OUTPUT:  | 
| 
191
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL  | 
| 
192
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
193
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
194
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 SV*  | 
| 
195
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 mq_attr_pack(mq_flags, mq_maxmsg, mq_msgsize, mq_curmsgs)  | 
| 
196
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         long mq_flags  | 
| 
197
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         long mq_maxmsg  | 
| 
198
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         long mq_msgsize  | 
| 
199
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         long mq_curmsgs   | 
| 
200
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     PREINIT:  | 
| 
201
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         struct mq_attr mqa;  | 
| 
202
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     CODE:  | 
| 
203
 | 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         mqa.mq_flags   = mq_flags;  | 
| 
204
 | 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         mqa.mq_maxmsg  = mq_maxmsg;  | 
| 
205
 | 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         mqa.mq_msgsize = mq_msgsize;  | 
| 
206
 | 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         mqa.mq_curmsgs = mq_curmsgs;  | 
| 
207
 | 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL = newSVpvn((char*)&mqa, sizeof(mqa));  | 
| 
208
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     OUTPUT:  | 
| 
209
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         RETVAL  | 
| 
210
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
211
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 void  | 
| 
212
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 mq_attr_unpack(mqa)  | 
| 
213
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         SV* mqa  | 
| 
214
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     PREINIT:  | 
| 
215
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         struct mq_attr* mqa_ptr;  | 
| 
216
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         STRLEN          mqa_len;  | 
| 
217
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     PPCODE:  | 
| 
218
 | 
43
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         mqa_ptr = (struct mq_attr*) SvPV(mqa, mqa_len);   | 
| 
219
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         /* check mqa_len ? */  | 
| 
220
 | 
43
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         XPUSHs(sv_2mortal(newSViv(mqa_ptr->mq_flags)));  | 
| 
221
 | 
43
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         XPUSHs(sv_2mortal(newSViv(mqa_ptr->mq_maxmsg)));  | 
| 
222
 | 
43
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         XPUSHs(sv_2mortal(newSViv(mqa_ptr->mq_msgsize)));  | 
| 
223
 | 
43
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         XPUSHs(sv_2mortal(newSViv(mqa_ptr->mq_curmsgs)));  |