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*2565Sudpa * Common Development and Distribution License (the "License"). 6*2565Sudpa * 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 */ 210Sstevel@tonic-gate /* 22*2565Sudpa * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_MSG_IMPL_H 270Sstevel@tonic-gate #define _SYS_MSG_IMPL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <sys/ipc_impl.h> 320Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER) 330Sstevel@tonic-gate #include <sys/msg.h> 340Sstevel@tonic-gate #include <sys/t_lock.h> 350Sstevel@tonic-gate #include <sys/list.h> 360Sstevel@tonic-gate #endif 370Sstevel@tonic-gate 380Sstevel@tonic-gate #ifdef __cplusplus 390Sstevel@tonic-gate extern "C" { 400Sstevel@tonic-gate #endif 410Sstevel@tonic-gate 420Sstevel@tonic-gate /* 430Sstevel@tonic-gate * Argument vectors for the various flavors of msgsys(). 440Sstevel@tonic-gate */ 450Sstevel@tonic-gate 460Sstevel@tonic-gate #define MSGGET 0 470Sstevel@tonic-gate #define MSGCTL 1 480Sstevel@tonic-gate #define MSGRCV 2 490Sstevel@tonic-gate #define MSGSND 3 500Sstevel@tonic-gate #define MSGIDS 4 510Sstevel@tonic-gate #define MSGSNAP 5 520Sstevel@tonic-gate 530Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER) 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* 560Sstevel@tonic-gate * There is one msg structure for each message in the system. 570Sstevel@tonic-gate */ 580Sstevel@tonic-gate struct msg { 590Sstevel@tonic-gate list_node_t msg_node; /* message list node */ 600Sstevel@tonic-gate long msg_type; /* message type */ 610Sstevel@tonic-gate size_t msg_size; /* message text size */ 620Sstevel@tonic-gate void *msg_addr; /* message text address */ 630Sstevel@tonic-gate long msg_flags; /* message flags */ 640Sstevel@tonic-gate long msg_copycnt; /* current # of copyouts on message */ 650Sstevel@tonic-gate }; 660Sstevel@tonic-gate 670Sstevel@tonic-gate /* 680Sstevel@tonic-gate * Per message flags 690Sstevel@tonic-gate */ 700Sstevel@tonic-gate #define MSG_RCVCOPY 00001 /* msgrcv is copying out this message */ 710Sstevel@tonic-gate #define MSG_UNLINKED 00002 /* msg has been unlinked from queue */ 720Sstevel@tonic-gate 73*2565Sudpa /* 74*2565Sudpa * msg_rcv_cv is now an array of kcondvar_t for performance reason. 75*2565Sudpa * We use multiple condition variables (kcondvar_t) to avoid needing 76*2565Sudpa * to wake all readers when sending a single message. 77*2565Sudpa */ 78*2565Sudpa #define MAX_QNUM 63 79*2565Sudpa #define MAX_QNUM_CV 64 80*2565Sudpa #define MSG_QNUM(x) ((x < 1) ? 0 : (x % MAX_QNUM) + 1) 81*2565Sudpa 820Sstevel@tonic-gate typedef struct kmsqid { 830Sstevel@tonic-gate kipc_perm_t msg_perm; /* operation permission struct */ 840Sstevel@tonic-gate list_t msg_list; /* list of messages on q */ 850Sstevel@tonic-gate msglen_t msg_cbytes; /* current # bytes on q */ 860Sstevel@tonic-gate msgqnum_t msg_qnum; /* # of messages on q */ 870Sstevel@tonic-gate msgqnum_t msg_qmax; /* max # of messages on q */ 880Sstevel@tonic-gate msglen_t msg_qbytes; /* max # of bytes on q */ 890Sstevel@tonic-gate pid_t msg_lspid; /* pid of last msgsnd */ 900Sstevel@tonic-gate pid_t msg_lrpid; /* pid of last msgrcv */ 910Sstevel@tonic-gate time_t msg_stime; /* last msgsnd time */ 920Sstevel@tonic-gate time_t msg_rtime; /* last msgrcv time */ 930Sstevel@tonic-gate time_t msg_ctime; /* last change time */ 940Sstevel@tonic-gate uint64_t msg_snd_cnt; /* # of waiting senders */ 95*2565Sudpa uint64_t msg_rcv_cnt[MAX_QNUM_CV]; /* # of waiting receivers */ 960Sstevel@tonic-gate kcondvar_t msg_snd_cv; 97*2565Sudpa kcondvar_t msg_rcv_cv[MAX_QNUM_CV]; 980Sstevel@tonic-gate } kmsqid_t; 990Sstevel@tonic-gate 1000Sstevel@tonic-gate #endif /* _KERNEL */ 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate #if defined(_SYSCALL32) 1030Sstevel@tonic-gate /* 1040Sstevel@tonic-gate * LP64 view of the ILP32 msgbuf structure 1050Sstevel@tonic-gate */ 1060Sstevel@tonic-gate struct ipcmsgbuf32 { 1070Sstevel@tonic-gate int32_t mtype; /* message type */ 1080Sstevel@tonic-gate char mtext[1]; /* message text */ 1090Sstevel@tonic-gate }; 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate /* 1120Sstevel@tonic-gate * LP64 view of the ILP32 msgsnap_head and msgsnap_mhead structures 1130Sstevel@tonic-gate */ 1140Sstevel@tonic-gate struct msgsnap_head32 { 1150Sstevel@tonic-gate size32_t msgsnap_size; /* bytes consumed/required in the buffer */ 1160Sstevel@tonic-gate size32_t msgsnap_nmsg; /* number of messages in the buffer */ 1170Sstevel@tonic-gate }; 1180Sstevel@tonic-gate 1190Sstevel@tonic-gate struct msgsnap_mhead32 { 1200Sstevel@tonic-gate size32_t msgsnap_mlen; /* number of bytes in message that follows */ 1210Sstevel@tonic-gate int32_t msgsnap_mtype; /* message type */ 1220Sstevel@tonic-gate }; 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate /* 1250Sstevel@tonic-gate * LP64 view of the ILP32 msqid_ds structure 1260Sstevel@tonic-gate */ 1270Sstevel@tonic-gate struct msqid_ds32 { 1280Sstevel@tonic-gate struct ipc_perm32 msg_perm; /* operation permission struct */ 1290Sstevel@tonic-gate caddr32_t msg_first; /* ptr to first message on q */ 1300Sstevel@tonic-gate caddr32_t msg_last; /* ptr to last message on q */ 1310Sstevel@tonic-gate uint32_t msg_cbytes; /* current # bytes on q */ 1320Sstevel@tonic-gate uint32_t msg_qnum; /* # of messages on q */ 1330Sstevel@tonic-gate uint32_t msg_qbytes; /* max # of bytes on q */ 1340Sstevel@tonic-gate pid32_t msg_lspid; /* pid of last msgsnd */ 1350Sstevel@tonic-gate pid32_t msg_lrpid; /* pid of last msgrcv */ 1360Sstevel@tonic-gate time32_t msg_stime; /* last msgsnd time */ 1370Sstevel@tonic-gate int32_t msg_pad1; /* reserved for time_t expansion */ 1380Sstevel@tonic-gate time32_t msg_rtime; /* last msgrcv time */ 1390Sstevel@tonic-gate int32_t msg_pad2; /* time_t expansion */ 1400Sstevel@tonic-gate time32_t msg_ctime; /* last change time */ 1410Sstevel@tonic-gate int32_t msg_pad3; /* time expansion */ 1420Sstevel@tonic-gate int16_t msg_cv; 1430Sstevel@tonic-gate int16_t msg_qnum_cv; 1440Sstevel@tonic-gate int32_t msg_pad4[3]; /* reserve area */ 1450Sstevel@tonic-gate }; 1460Sstevel@tonic-gate #endif /* _SYSCALL32 */ 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate #ifdef __cplusplus 1490Sstevel@tonic-gate } 1500Sstevel@tonic-gate #endif 1510Sstevel@tonic-gate 1520Sstevel@tonic-gate #endif /* _SYS_MSG_IMPL_H */ 153