4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #pragma weak _msgctl = msgctl
33 #pragma weak _msgget = msgget
34 #pragma weak _msgids = msgids
35 #pragma weak _msgsnap = msgsnap
38 #include <sys/types.h>
40 #include <sys/ipc_impl.h>
42 #include <sys/msg_impl.h>
43 #include <sys/syscall.h>
48 msgget(key_t key
, int msgflg
)
50 return (syscall(SYS_msgsys
, MSGGET
, key
, msgflg
));
54 msgctl(int msqid
, int cmd
, struct msqid_ds
*buf
)
56 if (cmd
== IPC_SET64
|| cmd
== IPC_STAT64
) {
57 (void) __set_errno(EINVAL
);
61 return (syscall(SYS_msgsys
, MSGCTL
, msqid
, cmd
, buf
));
65 msgctl64(int msqid
, int cmd
, struct msqid_ds64
*buf
)
67 if (cmd
!= IPC_SET64
&& cmd
!= IPC_STAT64
) {
68 (void) __set_errno(EINVAL
);
72 return (syscall(SYS_msgsys
, MSGCTL
, msqid
, cmd
, buf
));
76 __msgrcv(int msqid
, void *msgp
, size_t msgsz
, long msgtyp
, int msgflg
)
78 if (msgsz
> INT_MAX
) {
83 * We have to use __systemcall here because in the
84 * 64-bit case, we need to return a long, while
85 * syscall() is doomed to return an int
87 error
= __systemcall(&rval
, SYS_msgsys
, MSGRCV
, msqid
,
88 msgp
, msgsz
, msgtyp
, msgflg
);
90 (void) __set_errno(error
);
91 return ((ssize_t
)rval
.sys_rval1
);
93 return ((ssize_t
)syscall(SYS_msgsys
, MSGRCV
, msqid
,
94 msgp
, msgsz
, msgtyp
, msgflg
));
98 __msgsnd(int msqid
, const void *msgp
, size_t msgsz
, int msgflg
)
100 if (msgsz
> INT_MAX
) {
104 error
= __systemcall(&rval
, SYS_msgsys
, MSGSND
, msqid
,
105 msgp
, msgsz
, msgflg
);
107 (void) __set_errno(error
);
108 return ((int)rval
.sys_rval1
);
110 return (syscall(SYS_msgsys
, MSGSND
, msqid
, msgp
, msgsz
, msgflg
));
114 msgids(int *buf
, uint_t nids
, uint_t
*pnids
)
116 return (syscall(SYS_msgsys
, MSGIDS
, buf
, nids
, pnids
));
120 msgsnap(int msqid
, void *buf
, size_t bufsz
, long msgtyp
)
122 return (syscall(SYS_msgsys
, MSGSNAP
, msqid
, buf
, bufsz
, msgtyp
));