xref: /dragonfly/sys/sys/msg.h (revision 246dc83d)
1 /* $FreeBSD: src/sys/sys/msg.h,v 1.10.2.1 2000/08/04 22:31:10 peter Exp $ */
2 /* $DragonFly: src/sys/sys/msg.h,v 1.4 2003/08/27 02:03:22 dillon Exp $ */
3 /*	$NetBSD: msg.h,v 1.4 1994/06/29 06:44:43 cgd Exp $	*/
4 
5 /*
6  * SVID compatible msg.h file
7  *
8  * Author:  Daniel Boulet
9  *
10  * Copyright 1993 Daniel Boulet and RTMX Inc.
11  *
12  * This system call was implemented by Daniel Boulet under contract from RTMX.
13  *
14  * Redistribution and use in source forms, with and without modification,
15  * are permitted provided that this entire comment appears intact.
16  *
17  * Redistribution in binary form may occur without any restrictions.
18  * Obviously, it would be nice if you gave credit where credit is due
19  * but requiring it would be too onerous.
20  *
21  * This software is provided ``AS IS'' without any warranties of any kind.
22  */
23 
24 #ifndef _SYS_MSG_H_
25 #define _SYS_MSG_H_
26 
27 #include <sys/ipc.h>
28 
29 /*
30  * The MSG_NOERROR identifier value, the msqid_ds struct and the msg struct
31  * are as defined by the SV API Intel 386 Processor Supplement.
32  */
33 
34 #define MSG_NOERROR	010000		/* don't complain about too long msgs */
35 
36 /*!!! In the kernel implementation, both msg_first and msg_last
37  * have 'struct msg*' type.
38  * In the userland implementation, a pointer to a msg is useless
39  * because each message queue is mapped at different addresses in
40  * the process space address so my choice was to use indexes.
41  */
42 struct msg;
43 
44 struct msqid_ds {
45 	struct	ipc_perm msg_perm;	/* msg queue permission bits */
46 	struct	msg *msg_first;	/* first message in the queue. */
47 	struct	msg *msg_last;	/* last message in the queue. */
48 	u_long	msg_cbytes;	/* number of bytes in use on the queue */
49 	u_long	msg_qnum;	/* number of msgs in the queue */
50 	u_long	msg_qbytes;	/* max # of bytes on the queue */
51 	pid_t	msg_lspid;	/* pid of last msgsnd() */
52 	pid_t	msg_lrpid;	/* pid of last msgrcv() */
53 	time_t	msg_stime;	/* time of last msgsnd() */
54 	long	msg_pad1;
55 	time_t	msg_rtime;	/* time of last msgrcv() */
56 	long	msg_pad2;
57 	time_t	msg_ctime;	/* time of last msgctl() */
58 	long	msg_pad3;
59 	long	msg_pad4[4];
60 };
61 
62 /*
63  * Structure describing a message.  The SVID doesn't suggest any
64  * particular name for this structure.  There is a reference in the
65  * msgop man page that reads "The structure mymsg is an example of what
66  * this user defined buffer might look like, and includes the following
67  * members:".  This sentence is followed by two lines equivalent
68  * to the mtype and mtext field declarations below.  It isn't clear
69  * if "mymsg" refers to the naem of the structure type or the name of an
70  * instance of the structure...
71  */
72 struct mymsg {
73 	long	mtype;		/* message type (+ve integer) */
74 	char	mtext[1];	/* message body */
75 };
76 
77 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
78 
79 /*
80  * Based on the configuration parameters described in an SVR2 (yes, two)
81  * config(1m) man page.
82  *
83  * Each message is broken up and stored in segments that are msgssz bytes
84  * long.  For efficiency reasons, this should be a power of two.  Also,
85  * it doesn't make sense if it is less than 8 or greater than about 256.
86  * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of
87  * two between 8 and 1024 inclusive (and panic's if it isn't).
88  */
89 struct msginfo {
90 	int	msgmax,		/* max chars in a message */
91 		msgmni,		/* max message queue identifiers */
92 		msgmnb,		/* max chars in a queue */
93 		msgtql,		/* max messages in system */
94 		msgssz,		/* size of a message segment (see notes above) */
95 		msgseg;		/* number of message segments */
96 };
97 #endif
98 
99 #ifdef _KERNEL
100 extern struct msginfo	msginfo;
101 #endif
102 
103 #ifndef _KERNEL
104 
105 #include <sys/cdefs.h>
106 
107 __BEGIN_DECLS
108 int msgsys (int, ...);
109 int msgctl (int, int, struct msqid_ds *);
110 int msgget (key_t, int);
111 int msgsnd (int, void *, size_t, int);
112 int msgrcv (int, void*, size_t, long, int);
113 __END_DECLS
114 #endif
115 
116 #endif /* !_SYS_MSG_H_ */
117