I'm growing tired of having to add #include lines for header files that
[dragonfly.git] / sys / sys / sysmsg.h
1 /*
2  * SYS/SYSMSG.H
3  *
4  * $DragonFly: src/sys/sys/sysmsg.h,v 1.8 2006/05/20 02:42:13 dillon Exp $
5  */
6
7 #ifndef _SYS_SYSMSG_H_
8 #define _SYS_SYSMSG_H_
9
10 #ifdef _KERNEL
11
12 #ifndef _SYS_MSGPORT_H_
13 #include <sys/msgport.h>
14 #endif
15 #ifndef _SYS_CALLOUT_H_
16 #include <sys/callout.h>        /* for struct callout */
17 #endif
18 #ifndef _SYS_TIME_H_
19 #include <sys/time.h>           /* for struct timespec */
20 #endif
21
22 /*
23  * The sysmsg holds the kernelland version of a system call.
24  * It typically preceeds the usrmsg and syscall arguments in sysunion
25  * (see sys/sysunion.h).  Note that msgq field is used by the governing
26  * process to record a system call that returns EASYNC in order to be able
27  * to properly abort and/or wait on it in exit1().  This is different from
28  * any localized queueing of the LWKT message that the syscall itself might
29  * do.
30  */
31 union sysunion;
32
33 struct sysmsg {
34         struct lwkt_msg lmsg;
35         void            (*copyout)(union sysunion *sysun);
36         TAILQ_ENTRY(sysmsg)     msgq;
37         union {
38             struct sysmsg_sleep {
39                 struct lwkt_msg lmsg;
40                 struct timespec rmt;
41                 struct timespec rqt;
42                 struct callout  timer;
43             } sleep;
44         } sm;
45 };
46
47 struct lwp;
48 union sysunion;
49
50 struct sysmsg *sysmsg_wait(struct lwp *lp, struct sysmsg *sysmsg, int nonblock);
51 void sysmsg_rundown(struct lwp *lp, int doabort);
52
53 #endif
54
55 /*
56  * The usrmsg holds the userland version of the system call message which
57  * typically preceeds the original user arguments.  This message structure
58  * is typically loaded by the copyin() and adjusted prior to copyout(), but
59  * not used in the nominal running of the system call.
60  */
61 union usrmsg {
62         struct lwkt_msg umsg;
63 };
64
65 #ifdef _KERNEL
66 typedef struct sysmsg *sysmsg_t;
67 #define sysmsg_copyout  sysmsg.copyout
68 #define sysmsg_lmsg     sysmsg.lmsg
69 #define sysmsg_result   sysmsg.lmsg.u.ms_result
70 #define sysmsg_lresult  sysmsg.lmsg.u.ms_lresult
71 #define sysmsg_resultp  sysmsg.lmsg.u.ms_resultp
72 #define sysmsg_fds      sysmsg.lmsg.u.ms_fds
73 #define sysmsg_offset   sysmsg.lmsg.u.ms_offset
74 #define sysmsg_result32 sysmsg.lmsg.u.ms_result32
75 #define sysmsg_result64 sysmsg.lmsg.u.ms_result64
76 #endif
77
78 typedef union usrmsg *usrmsg_t;
79 #define usrmsg_result   usrmsg.umsg.u.ms_result
80 #define usrmsg_lresult  usrmsg.umsg.u.ms_lresult
81 #define usrmsg_resultp  usrmsg.umsg.u.ms_resultp
82 #define usrmsg_fds      usrmsg.umsg.u.ms_fds
83 #define usrmsg_offset   usrmsg.umsg.u.ms_offset
84 #define usrmsg_result32 usrmsg.umsg.u.ms_result32
85 #define usrmsg_result64 usrmsg.umsg.u.ms_result64
86
87 #endif
88