10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
230Sstevel@tonic-gate  * Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate /*      Copyright (c) 1984 AT&T */
280Sstevel@tonic-gate /*        All Rights Reserved   */
290Sstevel@tonic-gate 
30*722Smuffin #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include	<syscall.h>
33*722Smuffin #include 	<stdarg.h>
340Sstevel@tonic-gate #include	<sys/types.h>
350Sstevel@tonic-gate #include	<sys/ipc.h>
360Sstevel@tonic-gate #include	<sys/msg.h>
370Sstevel@tonic-gate 
380Sstevel@tonic-gate 
390Sstevel@tonic-gate /* msgsys dispatch argument */
400Sstevel@tonic-gate #define	MSGGET	0
410Sstevel@tonic-gate #define	MSGCTL	1
420Sstevel@tonic-gate #define	MSGRCV	2
430Sstevel@tonic-gate #define	MSGSND	3
440Sstevel@tonic-gate 
45*722Smuffin int
46*722Smuffin msgget(key_t key, int msgflg)
470Sstevel@tonic-gate {
48*722Smuffin 	return (_syscall(SYS_msgsys, MSGGET, key, msgflg));
490Sstevel@tonic-gate }
500Sstevel@tonic-gate 
51*722Smuffin int
52*722Smuffin msgctl(int msqid, int cmd, struct msqid_ds *buf)
530Sstevel@tonic-gate {
54*722Smuffin 	return (_syscall(SYS_msgsys, MSGCTL, msqid, cmd, buf));
550Sstevel@tonic-gate }
560Sstevel@tonic-gate 
57*722Smuffin int
58*722Smuffin msgrcv(int msqid, struct msgbuf *msgp, int msgsz, long msgtyp, int msgflg)
590Sstevel@tonic-gate {
60*722Smuffin 	return (_syscall(SYS_msgsys, MSGRCV, msqid, msgp, msgsz, msgtyp, msgflg));
610Sstevel@tonic-gate }
620Sstevel@tonic-gate 
63*722Smuffin int
64*722Smuffin msgsnd(int msqid, struct msgbuf *msgp, int msgsz, int msgflg)
650Sstevel@tonic-gate {
66*722Smuffin 	return (_syscall(SYS_msgsys, MSGSND, msqid, msgp, msgsz, msgflg));
670Sstevel@tonic-gate }
680Sstevel@tonic-gate 
69*722Smuffin int
70*722Smuffin msgsys(int sysnum, ...)
710Sstevel@tonic-gate {
720Sstevel@tonic-gate 	va_list ap;
730Sstevel@tonic-gate 	key_t key;
740Sstevel@tonic-gate 	int msgflg;
750Sstevel@tonic-gate 	int msgflag;
760Sstevel@tonic-gate 	int msqid, cmd;
770Sstevel@tonic-gate 	struct msqid_ds *buf;
780Sstevel@tonic-gate 	struct msgbuf *msgp;
790Sstevel@tonic-gate 	int msgsz;
800Sstevel@tonic-gate 	long msgtyp;
810Sstevel@tonic-gate 
820Sstevel@tonic-gate 
83*722Smuffin 	va_start(ap, sysnum);
840Sstevel@tonic-gate 	switch (sysnum) {
850Sstevel@tonic-gate 	case MSGGET:
860Sstevel@tonic-gate 		key=va_arg(ap, key_t);
870Sstevel@tonic-gate 		msgflag=va_arg(ap, int);
88*722Smuffin 		va_end(ap);
89*722Smuffin 		return (msgget(key, msgflag));
900Sstevel@tonic-gate 	case MSGCTL:
910Sstevel@tonic-gate 		msqid=va_arg(ap, int);
920Sstevel@tonic-gate 		cmd=va_arg(ap, int);
930Sstevel@tonic-gate 		buf=va_arg(ap, struct msqid_ds *);
94*722Smuffin 		va_end(ap);
95*722Smuffin 		return (msgctl(msqid, cmd, buf));
960Sstevel@tonic-gate 	case MSGRCV:
970Sstevel@tonic-gate 		msqid=va_arg(ap, int);
980Sstevel@tonic-gate 		msgp=va_arg(ap, struct msgbuf *);
990Sstevel@tonic-gate 		msgsz=va_arg(ap, int);
1000Sstevel@tonic-gate 		msgtyp=va_arg(ap, long);
1010Sstevel@tonic-gate 		msgflg=va_arg(ap, int);
102*722Smuffin 		va_end(ap);
103*722Smuffin 		return (msgrcv(msqid, msgp, msgsz, msgtyp, msgflg));
1040Sstevel@tonic-gate 	case MSGSND:
1050Sstevel@tonic-gate 		msqid=va_arg(ap, int);
1060Sstevel@tonic-gate 		msgp=va_arg(ap, struct msgbuf *);
1070Sstevel@tonic-gate 		msgsz=va_arg(ap, int);
1080Sstevel@tonic-gate 		msgflg=va_arg(ap, int);
109*722Smuffin 		va_end(ap);
110*722Smuffin 		return (msgsnd(msqid, msgp, msgsz, msgflg));
1110Sstevel@tonic-gate 	}
112*722Smuffin 	va_end(ap);
113*722Smuffin 	return (-1);
1140Sstevel@tonic-gate }
115