1:
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29:
30:
31: #ifndef _SYS_EVENT_H_
32: #define _SYS_EVENT_H_
33:
34: #define EVFILT_READ (-1)
35: #define EVFILT_WRITE (-2)
36: #define EVFILT_AIO (-3)
37: #define EVFILT_VNODE (-4)
38: #define EVFILT_PROC (-5)
39: #define EVFILT_SIGNAL (-6)
40: #define EVFILT_TIMER (-7)
41:
42: #define EVFILT_SYSCOUNT 7
43:
44: #define EV_SET(kevp, a, b, c, d, e, f) do { \
45: (kevp)->ident = (a); \
46: (kevp)->filter = (b); \
47: (kevp)->flags = (c); \
48: (kevp)->fflags = (d); \
49: (kevp)->data = (e); \
50: (kevp)->udata = (f); \
51: } while(0)
52:
53: struct kevent {
54: u_int ident;
55: short filter;
56: u_short flags;
57: u_int fflags;
58: int data;
59: void *udata;
60: };
61:
62:
63: #define EV_ADD 0x0001
64: #define EV_DELETE 0x0002
65: #define EV_ENABLE 0x0004
66: #define EV_DISABLE 0x0008
67:
68:
69: #define EV_ONESHOT 0x0010
70: #define EV_CLEAR 0x0020
71:
72: #define EV_SYSFLAGS 0xF000
73: #define EV_FLAG1 0x2000
74:
75:
76: #define EV_EOF 0x8000
77: #define EV_ERROR 0x4000
78:
79: 80: 81:
82: #define NOTE_LOWAT 0x0001
83: #define NOTE_EOF 0x0002
84:
85: 86: 87:
88: #define NOTE_DELETE 0x0001
89: #define NOTE_WRITE 0x0002
90: #define NOTE_EXTEND 0x0004
91: #define NOTE_ATTRIB 0x0008
92: #define NOTE_LINK 0x0010
93: #define NOTE_RENAME 0x0020
94: #define NOTE_REVOKE 0x0040
95: #define NOTE_TRUNCATE 0x0080
96:
97: 98: 99:
100: #define NOTE_EXIT 0x80000000
101: #define NOTE_FORK 0x40000000
102: #define NOTE_EXEC 0x20000000
103: #define NOTE_PCTRLMASK 0xf0000000
104: #define NOTE_PDATAMASK 0x000fffff
105:
106:
107: #define NOTE_TRACK 0x00000001
108: #define NOTE_TRACKERR 0x00000002
109: #define NOTE_CHILD 0x00000004
110:
111: 112: 113: 114:
115: #include <sys/queue.h>
116: struct knote;
117: SLIST_HEAD(klist, knote);
118:
119: #ifdef _KERNEL
120:
121: #define KNOTE(list, hint) do { \
122: if ((list) != NULL) \
123: knote((list), (hint)); \
124: } while (0)
125:
126: 127: 128: 129:
130: #define NOTE_SIGNAL 0x08000000
131:
132: struct filterops {
133: int f_isfd;
134: int (*f_attach)(struct knote *kn);
135: void (*f_detach)(struct knote *kn);
136: int (*f_event)(struct knote *kn, long hint);
137: };
138:
139: struct knote {
140: SLIST_ENTRY(knote) kn_link;
141: SLIST_ENTRY(knote) kn_selnext;
142: TAILQ_ENTRY(knote) kn_tqe;
143: struct kqueue *kn_kq;
144: struct kevent kn_kevent;
145: int kn_status;
146: int kn_sfflags;
147: int kn_sdata;
148: union {
149: struct file *p_fp;
150: struct proc *p_proc;
151: } kn_ptr;
152: const struct filterops *kn_fop;
153: void *kn_hook;
154: #define KN_ACTIVE 0x01
155: #define KN_QUEUED 0x02
156: #define KN_DISABLED 0x04
157: #define KN_DETACHED 0x08
158:
159: #define kn_id kn_kevent.ident
160: #define kn_filter kn_kevent.filter
161: #define kn_flags kn_kevent.flags
162: #define kn_fflags kn_kevent.fflags
163: #define kn_data kn_kevent.data
164: #define kn_fp kn_ptr.p_fp
165: };
166:
167: struct proc;
168:
169: extern void knote(struct klist *list, long hint);
170: extern void knote_remove(struct proc *p, struct klist *list);
171: extern void knote_fdclose(struct proc *p, int fd);
172: extern void knote_processexit(struct process *);
173: extern int kqueue_register(struct kqueue *kq,
174: struct kevent *kev, struct proc *p);
175: extern int filt_seltrue(struct knote *kn, long hint);
176: extern int seltrue_kqfilter(dev_t, struct knote *);
177: extern void klist_invalidate(struct klist *);
178:
179: #else
180:
181: #include <sys/cdefs.h>
182: struct timespec;
183:
184: __BEGIN_DECLS
185: int kqueue(void);
186: int kevent(int kq, const struct kevent *changelist, int nchanges,
187: struct kevent *eventlist, int nevents,
188: const struct timespec *timeout);
189: __END_DECLS
190:
191: #endif
192:
193: #endif