Skip to main content

kqueue_sys/constants/
darwin.rs

1use bitflags::bitflags;
2use libc::{c_uint, c_ushort};
3
4#[allow(non_camel_case_types)]
5#[derive(Clone, Copy, Debug, PartialEq)]
6#[repr(i16)]
7pub enum EventFilter {
8    EVFILT_READ = -1,
9    EVFILT_WRITE = -2,
10    EVFILT_AIO = -3,      /* attached to aio requests */
11    EVFILT_VNODE = -4,    /* attached to vnodes */
12    EVFILT_PROC = -5,     /* attached to struct proc */
13    EVFILT_SIGNAL = -6,   /* attached to struct proc */
14    EVFILT_TIMER = -7,    /* timers */
15    EVFILT_MACHPORT = -8, /* Mach portsets */
16    EVFILT_FS = -9,       /* Filesystem events */
17    EVFILT_USER = -10,    /* User events */
18    EVFILT_VM = -12,      /* Virtual memory events */
19    EVFILT_SYSCOUNT = 14,
20}
21
22bitflags! {
23    #[repr(transparent)]
24    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Ord, PartialOrd)]
25    pub struct EventFlag: c_ushort {
26        const EV_ADD            = 0x0001;   /* add event to kq (implies enable) */
27        const EV_DELETE         = 0x0002;   /* delete event from kq */
28        const EV_ENABLE         = 0x0004;   /* enable event */
29        const EV_DISABLE        = 0x0008;   /* disable event (not reported) */
30        const EV_UDATA_SPECIFIC = 0x0100;   /* unique kevent per udata value */
31                                            /* ... in combination with EV_DELETE */
32                                            /* will defer delete until udata-specific */
33                                            /* event enabled. EINPROGRESS will be */
34                                            /* returned to indicate the deferral */
35
36        const EV_ONESHOT        = 0x0010;   /* only report one occurrence */
37        const EV_CLEAR          = 0x0020;   /* clear event state after reporting */
38        const EV_RECEIPT        = 0x0040;   /* force EV_ERROR on success, data == 0 */
39        const EV_DISPATCH       = 0x0080;   /* disable event after reporting */
40
41        const EV_SYSFLAGS       = 0xF000;   /* reserved by system */
42        const EV_FLAG0          = 0x1000;   /* filter-specific flag */
43        const EV_FLAG1          = 0x2000;   /* filter-specific flag */
44        const EV_EOF            = 0x8000;   /* EOF detected */
45        const EV_ERROR          = 0x4000;   /* error, data contains errno */
46    }
47}
48
49impl EventFlag {
50    #[deprecated = "use the safe `from_bits_retain` method instead"]
51    pub const unsafe fn from_bits_unchecked(bits: c_ushort) -> Self {
52        Self::from_bits_retain(bits)
53    }
54}
55
56bitflags! {
57    #[repr(transparent)]
58    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Ord, PartialOrd)]
59    pub struct FilterFlag: c_uint {
60        const NOTE_FFNOP                        = 0x00000000;   /* ignore input fflags */
61        const NOTE_FFAND                        = 0x40000000;   /* and fflags */
62        const NOTE_FFOR                         = 0x80000000;   /* or fflags */
63        const NOTE_FFCOPY                       = 0xc0000000;   /* copy fflags */
64        const NOTE_FFCTRLMASK                   = 0xc0000000;   /* mask for operations */
65        const NOTE_FFLAGSMASK                   = 0x00ffffff;
66        const NOTE_LOWAT                        = 0x00000001;   /* low water mark */
67        const NOTE_DELETE                       = 0x00000001;   /* vnode was removed */
68        const NOTE_WRITE                        = 0x00000002;   /* data contents changed */
69        const NOTE_EXTEND                       = 0x00000004;   /* size increased */
70        const NOTE_ATTRIB                       = 0x00000008;   /* attributes changed */
71        const NOTE_LINK                         = 0x00000010;   /* link count changed */
72        const NOTE_RENAME                       = 0x00000020;   /* vnode was renamed */
73        const NOTE_REVOKE                       = 0x00000040;   /* vnode access was revoked */
74        const NOTE_NONE                         = 0x00000080;   /* No specific vnode event: to test for EVFILT_READ activation*/
75        const NOTE_EXIT                         = 0x80000000;   /* process exited */
76        const NOTE_FORK                         = 0x40000000;   /* process forked */
77        const NOTE_EXEC                         = 0x20000000;   /* process exec'd */
78        const NOTE_SIGNAL                       = 0x08000000;   /* shared with EVFILT_SIGNAL */
79        const NOTE_EXITSTATUS                   = 0x04000000;   /* exit status to be returned, valid for child process only */
80        const NOTE_EXIT_DETAIL                  = 0x02000000;   /* provide details on reasons for exit */
81        const NOTE_PDATAMASK                    = 0x000fffff;   /* mask for signal & exit status */
82        const NOTE_PCTRLMASK                    = 0xf0000000;
83        const NOTE_SECONDS                      = 0x00000001;   /* data is seconds         */
84        const NOTE_USECONDS                     = 0x00000002;   /* data is microseconds    */
85        const NOTE_NSECONDS                     = 0x00000004;   /* data is nanoseconds     */
86        const NOTE_ABSOLUTE                     = 0x00000008;   /* absolute timeout        */
87                                                                /* ... implicit EV_ONESHOT */
88        const NOTE_LEEWAY                       = 0x00000010;   /* ext[1] holds leeway for power aware timers */
89        const NOTE_CRITICAL                     = 0x00000020;   /* system does minimal timer coalescing */
90        const NOTE_BACKGROUND                   = 0x00000040;   /* system does maximum timer coalescing */
91        const NOTE_VM_PRESSURE                  = 0x80000000;   /* will react on memory pressure */
92        const NOTE_VM_PRESSURE_TERMINATE        = 0x40000000;   /* will quit on memory pressure, possibly after cleaning up dirty state */
93        const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000;   /* will quit immediately on memory pressure */
94        const NOTE_VM_ERROR                     = 0x10000000;   /* there was an error */
95        const NOTE_TRACK                        = 0x00000001;   /* follow across forks */
96        const NOTE_TRACKERR                     = 0x00000002;   /* could not track child */
97        const NOTE_CHILD                        = 0x00000004;   /* am a child process */
98    }
99}
100
101impl FilterFlag {
102    #[deprecated = "use the safe `from_bits_retain` method instead"]
103    pub const unsafe fn from_bits_unchecked(bits: c_uint) -> Self {
104        Self::from_bits_retain(bits)
105    }
106}