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