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 5*3224Sraf * Common Development and Distribution License (the "License"). 6*3224Sraf * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 21*3224Sraf 220Sstevel@tonic-gate /* 23*3224Sraf * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 27*3224Sraf /* Copyright (c) 1984 AT&T */ 28*3224Sraf /* All Rights Reserved */ 290Sstevel@tonic-gate 30722Smuffin #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 32*3224Sraf #include <sys/syscall.h> 33*3224Sraf #include <stdarg.h> 34*3224Sraf #include <sys/types.h> 35*3224Sraf #include <sys/ipc.h> 36*3224Sraf #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 45722Smuffin int 46722Smuffin msgget(key_t key, int msgflg) 470Sstevel@tonic-gate { 48722Smuffin return (_syscall(SYS_msgsys, MSGGET, key, msgflg)); 490Sstevel@tonic-gate } 500Sstevel@tonic-gate 51722Smuffin int 52722Smuffin msgctl(int msqid, int cmd, struct msqid_ds *buf) 530Sstevel@tonic-gate { 54722Smuffin return (_syscall(SYS_msgsys, MSGCTL, msqid, cmd, buf)); 550Sstevel@tonic-gate } 560Sstevel@tonic-gate 57722Smuffin int 58722Smuffin msgrcv(int msqid, struct msgbuf *msgp, int msgsz, long msgtyp, int msgflg) 590Sstevel@tonic-gate { 60*3224Sraf return (_syscall(SYS_msgsys, MSGRCV, 61*3224Sraf msqid, msgp, msgsz, msgtyp, msgflg)); 620Sstevel@tonic-gate } 630Sstevel@tonic-gate 64722Smuffin int 65722Smuffin msgsnd(int msqid, struct msgbuf *msgp, int msgsz, int msgflg) 660Sstevel@tonic-gate { 67*3224Sraf return (_syscall(SYS_msgsys, MSGSND, 68*3224Sraf msqid, msgp, msgsz, msgflg)); 690Sstevel@tonic-gate } 700Sstevel@tonic-gate 71722Smuffin int 72722Smuffin msgsys(int sysnum, ...) 730Sstevel@tonic-gate { 740Sstevel@tonic-gate va_list ap; 750Sstevel@tonic-gate key_t key; 760Sstevel@tonic-gate int msgflg; 770Sstevel@tonic-gate int msgflag; 780Sstevel@tonic-gate int msqid, cmd; 790Sstevel@tonic-gate struct msqid_ds *buf; 800Sstevel@tonic-gate struct msgbuf *msgp; 810Sstevel@tonic-gate int msgsz; 820Sstevel@tonic-gate long msgtyp; 830Sstevel@tonic-gate 84722Smuffin va_start(ap, sysnum); 850Sstevel@tonic-gate switch (sysnum) { 860Sstevel@tonic-gate case MSGGET: 87*3224Sraf key = va_arg(ap, key_t); 88*3224Sraf msgflag = va_arg(ap, int); 89722Smuffin va_end(ap); 90722Smuffin return (msgget(key, msgflag)); 910Sstevel@tonic-gate case MSGCTL: 92*3224Sraf msqid = va_arg(ap, int); 93*3224Sraf cmd = va_arg(ap, int); 94*3224Sraf buf = va_arg(ap, struct msqid_ds *); 95722Smuffin va_end(ap); 96722Smuffin return (msgctl(msqid, cmd, buf)); 970Sstevel@tonic-gate case MSGRCV: 98*3224Sraf msqid = va_arg(ap, int); 99*3224Sraf msgp = va_arg(ap, struct msgbuf *); 100*3224Sraf msgsz = va_arg(ap, int); 101*3224Sraf msgtyp = va_arg(ap, long); 102*3224Sraf msgflg = va_arg(ap, int); 103722Smuffin va_end(ap); 104722Smuffin return (msgrcv(msqid, msgp, msgsz, msgtyp, msgflg)); 1050Sstevel@tonic-gate case MSGSND: 106*3224Sraf msqid = va_arg(ap, int); 107*3224Sraf msgp = va_arg(ap, struct msgbuf *); 108*3224Sraf msgsz = va_arg(ap, int); 109*3224Sraf msgflg = va_arg(ap, int); 110722Smuffin va_end(ap); 111722Smuffin return (msgsnd(msqid, msgp, msgsz, msgflg)); 1120Sstevel@tonic-gate } 113722Smuffin va_end(ap); 114722Smuffin return (-1); 1150Sstevel@tonic-gate } 116