The OpenD Programming Language

1 /**
2  * D header file for NetBSD.
3  *
4  * Copyright: Copyright Martin Nowak 2012.
5  * License:   $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
6  * Authors:   Martin Nowak
7  *
8  * http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/sys/event.h
9  */
10 
11 /*          Copyright Martin Nowak 2012.
12  * Distributed under the Boost Software License, Version 1.0.
13  *    (See accompanying file LICENSE or copy at
14  *          http://www.boost.org/LICENSE_1_0.txt)
15  */
16 module core.sys.netbsd.sys.event;
17 
18 version (NetBSD):
19 extern (C):
20 
21 import core.stdc.stdint;    // intptr_t, uintptr_t
22 import core.sys.posix.time; // timespec
23 
24 
25 enum
26 {
27     EVFILT_READ     =  0,
28     EVFILT_WRITE    =  1,
29     EVFILT_AIO      =  2,
30     EVFILT_VNODE    =  3,
31     EVFILT_PROC     =  4,
32     EVFILT_SIGNAL   =  5,
33     EVFILT_TIMER    =  6,
34     EVFILT_SYSCOUNT =  7
35 }
36 
37 extern(D) void EV_SET(kevent_t* kevp, typeof(kevent_t.tupleof) args)
38 {
39     *kevp = kevent_t(args);
40 }
41 
42 struct kevent_t
43 {
44     uintptr_t    ident;
45     uint        filter;
46     uint        flags;
47     uint        fflags;
48     ulong       data;
49     void        *udata;
50 }
51 
52 enum
53 {
54     /* actions */
55     EV_ADD      = 0x0001,
56     EV_DELETE   = 0x0002,
57     EV_ENABLE   = 0x0004,
58     EV_DISABLE  = 0x0008,
59 
60     /* flags */
61     EV_ONESHOT  = 0x0010,
62     EV_CLEAR    = 0x0020,
63 
64     EV_SYSFLAGS = 0xF000,
65     EV_FLAG1    = 0x2000,
66 
67     /* returned values */
68     EV_EOF      = 0x8000,
69     EV_ERROR    = 0x4000
70 }
71 
72 enum
73 {
74     /*
75      * data/hint flags for EVFILT_{READ|WRITE}, shared with userspace
76      */
77     NOTE_LOWAT      = 0x0001,
78 
79     /*
80      * data/hint flags for EVFILT_VNODE, shared with userspace
81      */
82     NOTE_DELETE     = 0x0001,
83     NOTE_WRITE      = 0x0002,
84     NOTE_EXTEND     = 0x0004,
85     NOTE_ATTRIB     = 0x0008,
86     NOTE_LINK       = 0x0010,
87     NOTE_RENAME     = 0x0020,
88     NOTE_REVOKE     = 0x0040,
89 
90     /*
91      * data/hint flags for EVFILT_PROC, shared with userspace
92      */
93     NOTE_EXIT       = 0x80000000,
94     NOTE_FORK       = 0x40000000,
95     NOTE_EXEC       = 0x20000000,
96     NOTE_PCTRLMASK  = 0xf0000000,
97     NOTE_PDATAMASK  = 0x000fffff,
98 
99     /* additional flags for EVFILT_PROC */
100     NOTE_TRACK      = 0x00000001,
101     NOTE_TRACKERR   = 0x00000002,
102     NOTE_CHILD      = 0x00000004
103 
104 }
105 
106 int kqueue();
107 int __kevent50(int kq, const kevent_t *changelist, int nchanges,
108            kevent_t *eventlist, int nevents,
109            const timespec *timeout);
110 alias kevent = __kevent50;