xref: /titanic_50/usr/src/lib/libbc/libc/sys/common/msgsys.c (revision 554ff184129088135ad2643c1c9832174a17be88)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*      Copyright (c) 1984 AT&T */
28 /*        All Rights Reserved   */
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include	<syscall.h>
33 #include 	<varargs.h>
34 #include	<sys/types.h>
35 #include	<sys/ipc.h>
36 #include	<sys/msg.h>
37 
38 
39 /* msgsys dispatch argument */
40 #define	MSGGET	0
41 #define	MSGCTL	1
42 #define	MSGRCV	2
43 #define	MSGSND	3
44 
45 
46 msgget(key, msgflg)
47 key_t key;
48 int msgflg;
49 {
50 	return(_syscall(SYS_msgsys, MSGGET, key, msgflg));
51 }
52 
53 msgctl(msqid, cmd, buf)
54 int msqid, cmd;
55 struct msqid_ds *buf;
56 {
57 	return(_syscall(SYS_msgsys, MSGCTL, msqid, cmd, buf));
58 }
59 
60 msgrcv(msqid, msgp, msgsz, msgtyp, msgflg)
61 int msqid;
62 struct msgbuf *msgp;
63 int msgsz;
64 long msgtyp;
65 int msgflg;
66 {
67 	return(_syscall(SYS_msgsys, MSGRCV, msqid, msgp, msgsz, msgtyp, msgflg));
68 }
69 
70 msgsnd(msqid, msgp, msgsz, msgflg)
71 int msqid;
72 struct msgbuf *msgp;
73 int msgsz, msgflg;
74 {
75 	return(_syscall(SYS_msgsys, MSGSND, msqid, msgp, msgsz, msgflg));
76 }
77 
78 
79 msgsys(sysnum, va_alist)
80 int sysnum;
81 va_dcl
82 {
83 	va_list ap;
84 	key_t key;
85 	int msgflg;
86 	int msgflag;
87 	int msqid, cmd;
88 	struct msqid_ds *buf;
89 	struct msgbuf *msgp;
90 	int msgsz;
91 	long msgtyp;
92 
93 
94 	va_start(ap);
95 	switch (sysnum) {
96 	case MSGGET:
97 		key=va_arg(ap, key_t);
98 		msgflag=va_arg(ap, int);
99 		return(msgget(key, msgflag));
100 	case MSGCTL:
101 		msqid=va_arg(ap, int);
102 		cmd=va_arg(ap, int);
103 		buf=va_arg(ap, struct msqid_ds *);
104 		return(msgctl(msqid, cmd, buf));
105 	case MSGRCV:
106 		msqid=va_arg(ap, int);
107 		msgp=va_arg(ap, struct msgbuf *);
108 		msgsz=va_arg(ap, int);
109 		msgtyp=va_arg(ap, long);
110 		msgflg=va_arg(ap, int);
111 		return(msgrcv(msqid, msgp, msgsz, msgtyp, msgflg));
112 	case MSGSND:
113 		msqid=va_arg(ap, int);
114 		msgp=va_arg(ap, struct msgbuf *);
115 		msgsz=va_arg(ap, int);
116 		msgflg=va_arg(ap, int);
117 		return(msgsnd(msqid, msgp, msgsz, msgflg));
118 	}
119 }
120