17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*d4188195Sraf * Common Development and Distribution License (the "License"). 6*d4188195Sraf * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*d4188195Sraf 227c478bd9Sstevel@tonic-gate /* 23*d4188195Sraf * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate /* Copyright (c) 1984 AT&T */ 287c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 32*d4188195Sraf #include <sys/syscall.h> 335d54f3d8Smuffin #include <stdarg.h> 347c478bd9Sstevel@tonic-gate #include <sys/types.h> 357c478bd9Sstevel@tonic-gate #include <sys/ipc.h> 367c478bd9Sstevel@tonic-gate #include <sys/msg.h> 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate /* msgsys dispatch argument */ 407c478bd9Sstevel@tonic-gate #define MSGGET 0 417c478bd9Sstevel@tonic-gate #define MSGCTL 1 427c478bd9Sstevel@tonic-gate #define MSGRCV 2 437c478bd9Sstevel@tonic-gate #define MSGSND 3 447c478bd9Sstevel@tonic-gate 455d54f3d8Smuffin int 465d54f3d8Smuffin msgget(key_t key, int msgflg) 477c478bd9Sstevel@tonic-gate { 487c478bd9Sstevel@tonic-gate return (_syscall(SYS_msgsys, MSGGET, key, msgflg)); 497c478bd9Sstevel@tonic-gate } 507c478bd9Sstevel@tonic-gate 515d54f3d8Smuffin int 525d54f3d8Smuffin msgctl(int msqid, int cmd, struct msqid_ds *buf) 537c478bd9Sstevel@tonic-gate { 547c478bd9Sstevel@tonic-gate return (_syscall(SYS_msgsys, MSGCTL, msqid, cmd, buf)); 557c478bd9Sstevel@tonic-gate } 567c478bd9Sstevel@tonic-gate 575d54f3d8Smuffin int 585d54f3d8Smuffin msgrcv(int msqid, struct msgbuf *msgp, int msgsz, long msgtyp, int msgflg) 597c478bd9Sstevel@tonic-gate { 60*d4188195Sraf return (_syscall(SYS_msgsys, MSGRCV, 61*d4188195Sraf msqid, msgp, msgsz, msgtyp, msgflg)); 627c478bd9Sstevel@tonic-gate } 637c478bd9Sstevel@tonic-gate 645d54f3d8Smuffin int 655d54f3d8Smuffin msgsnd(int msqid, struct msgbuf *msgp, int msgsz, int msgflg) 667c478bd9Sstevel@tonic-gate { 67*d4188195Sraf return (_syscall(SYS_msgsys, MSGSND, 68*d4188195Sraf msqid, msgp, msgsz, msgflg)); 697c478bd9Sstevel@tonic-gate } 707c478bd9Sstevel@tonic-gate 715d54f3d8Smuffin int 725d54f3d8Smuffin msgsys(int sysnum, ...) 737c478bd9Sstevel@tonic-gate { 747c478bd9Sstevel@tonic-gate va_list ap; 757c478bd9Sstevel@tonic-gate key_t key; 767c478bd9Sstevel@tonic-gate int msgflg; 777c478bd9Sstevel@tonic-gate int msgflag; 787c478bd9Sstevel@tonic-gate int msqid, cmd; 797c478bd9Sstevel@tonic-gate struct msqid_ds *buf; 807c478bd9Sstevel@tonic-gate struct msgbuf *msgp; 817c478bd9Sstevel@tonic-gate int msgsz; 827c478bd9Sstevel@tonic-gate long msgtyp; 837c478bd9Sstevel@tonic-gate 845d54f3d8Smuffin va_start(ap, sysnum); 857c478bd9Sstevel@tonic-gate switch (sysnum) { 867c478bd9Sstevel@tonic-gate case MSGGET: 877c478bd9Sstevel@tonic-gate key = va_arg(ap, key_t); 887c478bd9Sstevel@tonic-gate msgflag = va_arg(ap, int); 895d54f3d8Smuffin va_end(ap); 907c478bd9Sstevel@tonic-gate return (msgget(key, msgflag)); 917c478bd9Sstevel@tonic-gate case MSGCTL: 927c478bd9Sstevel@tonic-gate msqid = va_arg(ap, int); 937c478bd9Sstevel@tonic-gate cmd = va_arg(ap, int); 947c478bd9Sstevel@tonic-gate buf = va_arg(ap, struct msqid_ds *); 955d54f3d8Smuffin va_end(ap); 967c478bd9Sstevel@tonic-gate return (msgctl(msqid, cmd, buf)); 977c478bd9Sstevel@tonic-gate case MSGRCV: 987c478bd9Sstevel@tonic-gate msqid = va_arg(ap, int); 997c478bd9Sstevel@tonic-gate msgp = va_arg(ap, struct msgbuf *); 1007c478bd9Sstevel@tonic-gate msgsz = va_arg(ap, int); 1017c478bd9Sstevel@tonic-gate msgtyp = va_arg(ap, long); 1027c478bd9Sstevel@tonic-gate msgflg = va_arg(ap, int); 1035d54f3d8Smuffin va_end(ap); 1047c478bd9Sstevel@tonic-gate return (msgrcv(msqid, msgp, msgsz, msgtyp, msgflg)); 1057c478bd9Sstevel@tonic-gate case MSGSND: 1067c478bd9Sstevel@tonic-gate msqid = va_arg(ap, int); 1077c478bd9Sstevel@tonic-gate msgp = va_arg(ap, struct msgbuf *); 1087c478bd9Sstevel@tonic-gate msgsz = va_arg(ap, int); 1097c478bd9Sstevel@tonic-gate msgflg = va_arg(ap, int); 1105d54f3d8Smuffin va_end(ap); 1117c478bd9Sstevel@tonic-gate return (msgsnd(msqid, msgp, msgsz, msgflg)); 1127c478bd9Sstevel@tonic-gate } 1135d54f3d8Smuffin va_end(ap); 1145d54f3d8Smuffin return (-1); 1157c478bd9Sstevel@tonic-gate } 116