xref: /illumos-gate/usr/src/uts/common/sys/msg_impl.h (revision 03831d35)
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 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_MSG_IMPL_H
28 #define	_SYS_MSG_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/ipc_impl.h>
33 #if defined(_KERNEL) || defined(_KMEMUSER)
34 #include <sys/msg.h>
35 #include <sys/t_lock.h>
36 #include <sys/list.h>
37 #endif
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 /*
44  * Argument vectors for the various flavors of msgsys().
45  */
46 
47 #define	MSGGET	0
48 #define	MSGCTL	1
49 #define	MSGRCV	2
50 #define	MSGSND	3
51 #define	MSGIDS	4
52 #define	MSGSNAP	5
53 
54 #if defined(_KERNEL) || defined(_KMEMUSER)
55 
56 /*
57  * There is one msg structure for each message in the system.
58  */
59 struct msg {
60 	list_node_t	msg_node;	/* message list node */
61 	long		msg_type;	/* message type */
62 	size_t		msg_size;	/* message text size */
63 	void		*msg_addr;	/* message text address */
64 	long		msg_flags;	/* message flags */
65 	long		msg_copycnt;	/* current # of copyouts on message */
66 };
67 
68 /*
69  * Per message flags
70  */
71 #define	MSG_RCVCOPY	00001	/* msgrcv is copying out this message */
72 #define	MSG_UNLINKED	00002	/* msg has been unlinked from queue */
73 
74 typedef struct kmsqid {
75 	kipc_perm_t	msg_perm;	/* operation permission struct */
76 	list_t		msg_list;	/* list of messages on q */
77 	msglen_t	msg_cbytes;	/* current # bytes on q */
78 	msgqnum_t	msg_qnum;	/* # of messages on q */
79 	msgqnum_t	msg_qmax;	/* max # of messages on q */
80 	msglen_t	msg_qbytes;	/* max # of bytes on q */
81 	pid_t		msg_lspid;	/* pid of last msgsnd */
82 	pid_t		msg_lrpid;	/* pid of last msgrcv */
83 	time_t		msg_stime;	/* last msgsnd time */
84 	time_t		msg_rtime;	/* last msgrcv time */
85 	time_t		msg_ctime;	/* last change time */
86 	uint64_t	msg_snd_cnt;	/* # of waiting senders */
87 	uint64_t	msg_rcv_cnt;	/* # of waiting receivers */
88 	kcondvar_t	msg_snd_cv;
89 	kcondvar_t	msg_rcv_cv;
90 } kmsqid_t;
91 
92 #endif	/* _KERNEL */
93 
94 #if defined(_SYSCALL32)
95 /*
96  * LP64 view of the ILP32 msgbuf structure
97  */
98 struct ipcmsgbuf32 {
99 	int32_t	mtype;		/* message type */
100 	char	mtext[1];	/* message text */
101 };
102 
103 /*
104  * LP64 view of the ILP32 msgsnap_head and msgsnap_mhead structures
105  */
106 struct msgsnap_head32 {
107 	size32_t msgsnap_size;	/* bytes consumed/required in the buffer */
108 	size32_t msgsnap_nmsg;	/* number of messages in the buffer */
109 };
110 
111 struct msgsnap_mhead32 {
112 	size32_t msgsnap_mlen;	/* number of bytes in message that follows */
113 	int32_t	msgsnap_mtype;	/* message type */
114 };
115 
116 /*
117  * LP64 view of the ILP32 msqid_ds structure
118  */
119 struct msqid_ds32 {
120 	struct ipc_perm32 msg_perm;	/* operation permission struct */
121 	caddr32_t	msg_first;	/* ptr to first message on q */
122 	caddr32_t	msg_last;	/* ptr to last message on q */
123 	uint32_t	msg_cbytes;	/* current # bytes on q */
124 	uint32_t	msg_qnum;	/* # of messages on q */
125 	uint32_t	msg_qbytes;	/* max # of bytes on q */
126 	pid32_t		msg_lspid;	/* pid of last msgsnd */
127 	pid32_t		msg_lrpid;	/* pid of last msgrcv */
128 	time32_t	msg_stime;	/* last msgsnd time */
129 	int32_t		msg_pad1;	/* reserved for time_t expansion */
130 	time32_t	msg_rtime;	/* last msgrcv time */
131 	int32_t		msg_pad2;	/* time_t expansion */
132 	time32_t	msg_ctime;	/* last change time */
133 	int32_t		msg_pad3;	/* time expansion */
134 	int16_t		msg_cv;
135 	int16_t		msg_qnum_cv;
136 	int32_t		msg_pad4[3];	/* reserve area */
137 };
138 #endif	/* _SYSCALL32 */
139 
140 #ifdef	__cplusplus
141 }
142 #endif
143 
144 #endif	/* _SYS_MSG_IMPL_H */
145