1 /* msg.cc: XSI IPC interface for Cygwin.
3 This file is part of Cygwin.
5 This software is a copyrighted work licensed under the terms of the
6 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
15 #include "cygserver_msg.h"
18 * client_request_msg Constructors
21 client_request_msg::client_request_msg (int msqid
,
24 : client_request (CYGSERVER_REQUEST_MSG
, &_parameters
, sizeof (_parameters
))
26 _parameters
.in
.msgop
= MSGOP_msgctl
;
27 ipc_set_proc_info (_parameters
.in
.ipcblk
);
29 _parameters
.in
.ctlargs
.msqid
= msqid
;
30 _parameters
.in
.ctlargs
.cmd
= cmd
;
31 _parameters
.in
.ctlargs
.buf
= buf
;
33 msglen (sizeof (_parameters
.in
));
36 client_request_msg::client_request_msg (key_t key
,
38 : client_request (CYGSERVER_REQUEST_MSG
, &_parameters
, sizeof (_parameters
))
40 _parameters
.in
.msgop
= MSGOP_msgget
;
41 ipc_set_proc_info (_parameters
.in
.ipcblk
);
43 _parameters
.in
.getargs
.key
= key
;
44 _parameters
.in
.getargs
.msgflg
= msgflg
;
46 msglen (sizeof (_parameters
.in
));
49 client_request_msg::client_request_msg (int msqid
,
54 : client_request (CYGSERVER_REQUEST_MSG
, &_parameters
, sizeof (_parameters
))
56 _parameters
.in
.msgop
= MSGOP_msgrcv
;
57 ipc_set_proc_info (_parameters
.in
.ipcblk
);
59 _parameters
.in
.rcvargs
.msqid
= msqid
;
60 _parameters
.in
.rcvargs
.msgp
= msgp
;
61 _parameters
.in
.rcvargs
.msgsz
= msgsz
;
62 _parameters
.in
.rcvargs
.msgtyp
= msgtyp
;
63 _parameters
.in
.rcvargs
.msgflg
= msgflg
;
65 msglen (sizeof (_parameters
.in
));
68 client_request_msg::client_request_msg (int msqid
,
72 : client_request (CYGSERVER_REQUEST_MSG
, &_parameters
, sizeof (_parameters
))
74 _parameters
.in
.msgop
= MSGOP_msgsnd
;
75 ipc_set_proc_info (_parameters
.in
.ipcblk
);
77 _parameters
.in
.sndargs
.msqid
= msqid
;
78 _parameters
.in
.sndargs
.msgp
= msgp
;
79 _parameters
.in
.sndargs
.msgsz
= msgsz
;
80 _parameters
.in
.sndargs
.msgflg
= msgflg
;
82 msglen (sizeof (_parameters
.in
));
86 * XSI message queue API. These are exported by the DLL.
90 msgctl (int msqid
, int cmd
, struct msqid_ds
*buf
)
92 syscall_printf ("msgctl (msqid = %d, cmd = %y, buf = %p)", msqid
, cmd
, buf
);
108 syscall_printf ("-1 [%d] = msgctl ()", EINVAL
);
112 client_request_msg
request (msqid
, cmd
, buf
);
113 if (request
.make_request () == -1 || request
.retval () == -1)
115 syscall_printf ("-1 [%d] = msgctl ()", request
.error_code ());
116 set_errno (request
.error_code ());
119 return request
.retval ();
127 msgget (key_t key
, int msgflg
)
129 syscall_printf ("msgget (key = %U, msgflg = %y)", key
, msgflg
);
130 client_request_msg
request (key
, msgflg
);
131 if (request
.make_request () == -1 || request
.retval () == -1)
133 syscall_printf ("-1 [%d] = msgget ()", request
.error_code ());
134 set_errno (request
.error_code ());
137 return request
.retval ();
141 msgrcv (int msqid
, void *msgp
, size_t msgsz
, long msgtyp
, int msgflg
)
143 syscall_printf ("msgrcv (msqid = %d, msgp = %p, msgsz = %ld, "
144 "msgtyp = %d, msgflg = %y)",
145 msqid
, msgp
, msgsz
, msgtyp
, msgflg
);
148 client_request_msg
request (msqid
, msgp
, msgsz
, msgtyp
, msgflg
);
149 if (request
.make_request () == -1 || request
.rcvval () == -1)
151 syscall_printf ("-1 [%d] = msgrcv ()", request
.error_code ());
152 set_errno (request
.error_code ());
155 return request
.rcvval ();
163 msgsnd (int msqid
, const void *msgp
, size_t msgsz
, int msgflg
)
165 syscall_printf ("msgsnd (msqid = %d, msgp = %p, msgsz = %ld, msgflg = %y)",
166 msqid
, msgp
, msgsz
, msgflg
);
169 client_request_msg
request (msqid
, msgp
, msgsz
, msgflg
);
170 if (request
.make_request () == -1 || request
.retval () == -1)
172 syscall_printf ("-1 [%d] = msgsnd ()", request
.error_code ());
173 set_errno (request
.error_code ());
176 return request
.retval ();