kernel - Fix callout_stop/callout_reset rearm race
[dragonfly.git] / sys / sys / msg.h
blob7a60b9c76efc1ece0f7a8eb1ce994c48bac5fd22
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 $ */
4 /*
5 * SVID compatible msg.h file
7 * Author: Daniel Boulet
9 * Copyright 1993 Daniel Boulet and RTMX Inc.
11 * This system call was implemented by Daniel Boulet under contract from RTMX.
13 * Redistribution and use in source forms, with and without modification,
14 * are permitted provided that this entire comment appears intact.
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.
20 * This software is provided ``AS IS'' without any warranties of any kind.
23 #ifndef _SYS_MSG_H_
24 #define _SYS_MSG_H_
26 #include <sys/cdefs.h>
27 #include <sys/ipc.h>
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.
34 #define MSG_NOERROR 010000 /* don't complain about too long msgs */
36 typedef unsigned long msglen_t;
37 typedef unsigned long msgqnum_t;
39 #ifndef _PID_T_DECLARED
40 typedef __pid_t pid_t;
41 #define _PID_T_DECLARED
42 #endif
44 #ifndef _SIZE_T_DECLARED
45 typedef __size_t size_t;
46 #define _SIZE_T_DECLARED
47 #endif
49 #ifndef _SSIZE_T_DECLARED
50 typedef __ssize_t ssize_t;
51 #define _SSIZE_T_DECLARED
52 #endif
54 #ifndef _TIME_T_DECLARED
55 typedef __time_t time_t;
56 #define _TIME_T_DECLARED
57 #endif
59 /*!!! In the kernel implementation, both msg_first and msg_last
60 * have 'struct msg*' type.
61 * In the userland implementation, a pointer to a msg is useless
62 * because each message queue is mapped at different addresses in
63 * the process space address so my choice was to use indexes.
65 struct msg;
67 struct msqid_ds {
68 struct ipc_perm msg_perm; /* msg queue permission bits */
69 struct msg *msg_first; /* first message in the queue. */
70 struct msg *msg_last; /* last message in the queue. */
71 msglen_t msg_cbytes; /* number of bytes in use on the queue */
72 msgqnum_t msg_qnum; /* number of msgs in the queue */
73 msglen_t msg_qbytes; /* max # of bytes on the queue */
74 pid_t msg_lspid; /* pid of last msgsnd() */
75 pid_t msg_lrpid; /* pid of last msgrcv() */
76 time_t msg_stime; /* time of last msgsnd() */
77 long msg_pad1;
78 time_t msg_rtime; /* time of last msgrcv() */
79 long msg_pad2;
80 time_t msg_ctime; /* time of last msgctl() */
81 long msg_pad3;
82 long msg_pad4[4];
85 #if __BSD_VISIBLE
87 * Structure describing a message. The SVID doesn't suggest any
88 * particular name for this structure. There is a reference in the
89 * msgop man page that reads "The structure mymsg is an example of what
90 * this user defined buffer might look like, and includes the following
91 * members:". This sentence is followed by two lines equivalent
92 * to the mtype and mtext field declarations below. It isn't clear
93 * if "mymsg" refers to the naem of the structure type or the name of an
94 * instance of the structure...
96 struct mymsg {
97 long mtype; /* message type (+ve integer) */
98 char mtext[1]; /* message body */
100 #endif
102 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
105 * Based on the configuration parameters described in an SVR2 (yes, two)
106 * config(1m) man page.
108 * Each message is broken up and stored in segments that are msgssz bytes
109 * long. For efficiency reasons, this should be a power of two. Also,
110 * it doesn't make sense if it is less than 8 or greater than about 256.
111 * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of
112 * two between 8 and 1024 inclusive (and panic's if it isn't).
114 struct msginfo {
115 int msgmax, /* max chars in a message */
116 msgmni, /* max message queue identifiers */
117 msgmnb, /* max chars in a queue */
118 msgtql, /* max messages in system */
119 msgssz, /* size of a message segment (see notes above) */
120 msgseg; /* number of message segments */
122 #endif
124 #ifdef _KERNEL
125 extern struct msginfo msginfo;
126 #else
127 __BEGIN_DECLS
128 int msgctl(int, int, struct msqid_ds *);
129 int msgget(key_t, int);
130 int msgsnd(int, const void *, size_t, int);
131 int msgrcv(int, void *, size_t, long, int); /* XXX should return ssize_t */
132 __END_DECLS
133 #endif
135 #endif /* !_SYS_MSG_H_ */