OSDN Git Service

install_headers.sh: make more user friendly
[uclinux-h8/uClibc.git] / libc / misc / sysvipc / msgq.c
1 #include <errno.h>
2 #include <sys/msg.h>
3 #include "ipc.h"
4
5
6 #ifdef L_msgctl
7
8 #ifdef __NR_msgctl
9 #define __NR___libc_msgctl __NR_msgctl
10 static __inline__ _syscall3(int, __libc_msgctl, int, msqid, int, cmd, struct msqid_ds *, buf);
11 #endif
12 /* Message queue control operation.  */
13 int msgctl(int msqid, int cmd, struct msqid_ds *buf)
14 {
15 #ifdef __NR_msgctl
16         return __libc_msgctl(msqid, cmd | __IPC_64, buf);
17 #else
18     return __syscall_ipc(IPCOP_msgctl, msqid, cmd | __IPC_64, 0, buf, 0);
19 #endif
20 }
21 #endif
22
23
24 #ifdef L_msgget
25 #ifdef __NR_msgget
26 _syscall2(int, msgget, key_t, key, int, msgflg)
27 #else
28 /* Get messages queue.  */
29 int msgget (key_t key, int msgflg)
30 {
31     return __syscall_ipc(IPCOP_msgget ,key ,msgflg ,0 ,0, 0);
32 }
33 #endif
34 #endif
35
36
37 struct new_msg_buf{
38     struct msgbuf * oldmsg;
39     long int r_msgtyp;       /* the fifth arg of __syscall_ipc */
40 };
41 /* Receive message from message queue.  */
42
43
44 #ifdef L_msgrcv
45 #ifdef __NR_msgrcv
46 _syscall5(ssize_t, msgrcv, int, msqid, void *, msgp, size_t, msgsz, long int, msgtyp, int, msgflg)
47 #else
48 ssize_t msgrcv (int msqid, void *msgp, size_t msgsz,
49         long int msgtyp, int msgflg)
50 {
51     struct new_msg_buf temp;
52
53     temp.r_msgtyp = msgtyp;
54     temp.oldmsg = msgp;
55     return __syscall_ipc(IPCOP_msgrcv ,msqid ,msgsz ,msgflg ,&temp, 0);
56 }
57 #endif
58 #endif
59
60
61
62 #ifdef L_msgsnd
63 #ifdef __NR_msgsnd
64 _syscall4(int, msgsnd, int, msqid, const void *, msgp, size_t, msgsz, int, msgflg)
65 #else
66 /* Send message to message queue.  */
67 int msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg)
68 {
69     return __syscall_ipc(IPCOP_msgsnd, msqid, msgsz, msgflg, (void *)msgp, 0);
70 }
71 #endif
72 #endif
73