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*b2eb1770Sudpa * Common Development and Distribution License (the "License"). 6*b2eb1770Sudpa * 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 */ 217c478bd9Sstevel@tonic-gate /* 22*b2eb1770Sudpa * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_MSG_IMPL_H 277c478bd9Sstevel@tonic-gate #define _SYS_MSG_IMPL_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <sys/ipc_impl.h> 327c478bd9Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER) 337c478bd9Sstevel@tonic-gate #include <sys/msg.h> 347c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 357c478bd9Sstevel@tonic-gate #include <sys/list.h> 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef __cplusplus 397c478bd9Sstevel@tonic-gate extern "C" { 407c478bd9Sstevel@tonic-gate #endif 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * Argument vectors for the various flavors of msgsys(). 447c478bd9Sstevel@tonic-gate */ 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #define MSGGET 0 477c478bd9Sstevel@tonic-gate #define MSGCTL 1 487c478bd9Sstevel@tonic-gate #define MSGRCV 2 497c478bd9Sstevel@tonic-gate #define MSGSND 3 507c478bd9Sstevel@tonic-gate #define MSGIDS 4 517c478bd9Sstevel@tonic-gate #define MSGSNAP 5 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER) 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* 567c478bd9Sstevel@tonic-gate * There is one msg structure for each message in the system. 577c478bd9Sstevel@tonic-gate */ 587c478bd9Sstevel@tonic-gate struct msg { 597c478bd9Sstevel@tonic-gate list_node_t msg_node; /* message list node */ 607c478bd9Sstevel@tonic-gate long msg_type; /* message type */ 617c478bd9Sstevel@tonic-gate size_t msg_size; /* message text size */ 627c478bd9Sstevel@tonic-gate void *msg_addr; /* message text address */ 637c478bd9Sstevel@tonic-gate long msg_flags; /* message flags */ 647c478bd9Sstevel@tonic-gate long msg_copycnt; /* current # of copyouts on message */ 657c478bd9Sstevel@tonic-gate }; 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate /* 687c478bd9Sstevel@tonic-gate * Per message flags 697c478bd9Sstevel@tonic-gate */ 707c478bd9Sstevel@tonic-gate #define MSG_RCVCOPY 00001 /* msgrcv is copying out this message */ 717c478bd9Sstevel@tonic-gate #define MSG_UNLINKED 00002 /* msg has been unlinked from queue */ 727c478bd9Sstevel@tonic-gate 73*b2eb1770Sudpa /* 74*b2eb1770Sudpa * msg_rcv_cv is now an array of kcondvar_t for performance reason. 75*b2eb1770Sudpa * We use multiple condition variables (kcondvar_t) to avoid needing 76*b2eb1770Sudpa * to wake all readers when sending a single message. 77*b2eb1770Sudpa */ 78*b2eb1770Sudpa #define MAX_QNUM 63 79*b2eb1770Sudpa #define MAX_QNUM_CV 64 80*b2eb1770Sudpa #define MSG_QNUM(x) ((x < 1) ? 0 : (x % MAX_QNUM) + 1) 81*b2eb1770Sudpa 827c478bd9Sstevel@tonic-gate typedef struct kmsqid { 837c478bd9Sstevel@tonic-gate kipc_perm_t msg_perm; /* operation permission struct */ 847c478bd9Sstevel@tonic-gate list_t msg_list; /* list of messages on q */ 857c478bd9Sstevel@tonic-gate msglen_t msg_cbytes; /* current # bytes on q */ 867c478bd9Sstevel@tonic-gate msgqnum_t msg_qnum; /* # of messages on q */ 877c478bd9Sstevel@tonic-gate msgqnum_t msg_qmax; /* max # of messages on q */ 887c478bd9Sstevel@tonic-gate msglen_t msg_qbytes; /* max # of bytes on q */ 897c478bd9Sstevel@tonic-gate pid_t msg_lspid; /* pid of last msgsnd */ 907c478bd9Sstevel@tonic-gate pid_t msg_lrpid; /* pid of last msgrcv */ 917c478bd9Sstevel@tonic-gate time_t msg_stime; /* last msgsnd time */ 927c478bd9Sstevel@tonic-gate time_t msg_rtime; /* last msgrcv time */ 937c478bd9Sstevel@tonic-gate time_t msg_ctime; /* last change time */ 947c478bd9Sstevel@tonic-gate uint64_t msg_snd_cnt; /* # of waiting senders */ 95*b2eb1770Sudpa uint64_t msg_rcv_cnt[MAX_QNUM_CV]; /* # of waiting receivers */ 967c478bd9Sstevel@tonic-gate kcondvar_t msg_snd_cv; 97*b2eb1770Sudpa kcondvar_t msg_rcv_cv[MAX_QNUM_CV]; 987c478bd9Sstevel@tonic-gate } kmsqid_t; 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 1037c478bd9Sstevel@tonic-gate /* 1047c478bd9Sstevel@tonic-gate * LP64 view of the ILP32 msgbuf structure 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate struct ipcmsgbuf32 { 1077c478bd9Sstevel@tonic-gate int32_t mtype; /* message type */ 1087c478bd9Sstevel@tonic-gate char mtext[1]; /* message text */ 1097c478bd9Sstevel@tonic-gate }; 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate /* 1127c478bd9Sstevel@tonic-gate * LP64 view of the ILP32 msgsnap_head and msgsnap_mhead structures 1137c478bd9Sstevel@tonic-gate */ 1147c478bd9Sstevel@tonic-gate struct msgsnap_head32 { 1157c478bd9Sstevel@tonic-gate size32_t msgsnap_size; /* bytes consumed/required in the buffer */ 1167c478bd9Sstevel@tonic-gate size32_t msgsnap_nmsg; /* number of messages in the buffer */ 1177c478bd9Sstevel@tonic-gate }; 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate struct msgsnap_mhead32 { 1207c478bd9Sstevel@tonic-gate size32_t msgsnap_mlen; /* number of bytes in message that follows */ 1217c478bd9Sstevel@tonic-gate int32_t msgsnap_mtype; /* message type */ 1227c478bd9Sstevel@tonic-gate }; 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * LP64 view of the ILP32 msqid_ds structure 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate struct msqid_ds32 { 1287c478bd9Sstevel@tonic-gate struct ipc_perm32 msg_perm; /* operation permission struct */ 1297c478bd9Sstevel@tonic-gate caddr32_t msg_first; /* ptr to first message on q */ 1307c478bd9Sstevel@tonic-gate caddr32_t msg_last; /* ptr to last message on q */ 1317c478bd9Sstevel@tonic-gate uint32_t msg_cbytes; /* current # bytes on q */ 1327c478bd9Sstevel@tonic-gate uint32_t msg_qnum; /* # of messages on q */ 1337c478bd9Sstevel@tonic-gate uint32_t msg_qbytes; /* max # of bytes on q */ 1347c478bd9Sstevel@tonic-gate pid32_t msg_lspid; /* pid of last msgsnd */ 1357c478bd9Sstevel@tonic-gate pid32_t msg_lrpid; /* pid of last msgrcv */ 1367c478bd9Sstevel@tonic-gate time32_t msg_stime; /* last msgsnd time */ 1377c478bd9Sstevel@tonic-gate int32_t msg_pad1; /* reserved for time_t expansion */ 1387c478bd9Sstevel@tonic-gate time32_t msg_rtime; /* last msgrcv time */ 1397c478bd9Sstevel@tonic-gate int32_t msg_pad2; /* time_t expansion */ 1407c478bd9Sstevel@tonic-gate time32_t msg_ctime; /* last change time */ 1417c478bd9Sstevel@tonic-gate int32_t msg_pad3; /* time expansion */ 1427c478bd9Sstevel@tonic-gate int16_t msg_cv; 1437c478bd9Sstevel@tonic-gate int16_t msg_qnum_cv; 1447c478bd9Sstevel@tonic-gate int32_t msg_pad4[3]; /* reserve area */ 1457c478bd9Sstevel@tonic-gate }; 1467c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1497c478bd9Sstevel@tonic-gate } 1507c478bd9Sstevel@tonic-gate #endif 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate #endif /* _SYS_MSG_IMPL_H */ 153