]> git.cameronkatri.com Git - apple_cmds.git/blob - system_cmds/lskq.tproj/common.h
Merge branch 'apple'
[apple_cmds.git] / system_cmds / lskq.tproj / common.h
1 /*
2 * Copyright (c) 2015 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef _LSKQ_COMMON_H_
25 #define _LSKQ_COMMON_H_
26
27 #include <stdint.h>
28
29 #ifndef __enum_open
30 #if __has_attribute(enum_extensibility)
31 #define __enum_open __attribute__((__enum_extensibility__(open)))
32 #define __enum_closed __attribute__((__enum_extensibility__(closed)))
33 #else
34 #define __enum_open
35 #define __enum_closed
36 #endif // __has_attribute(enum_extensibility)
37 #endif
38
39 #ifndef __enum_options
40 #if __has_attribute(flag_enum)
41 #define __enum_options __attribute__((__flag_enum__))
42 #else
43 #define __enum_options
44 #endif
45 #endif
46
47 #ifndef __enum_decl
48 #define __enum_decl(_name, _type, ...) \
49 typedef _type _name; enum __VA_ARGS__ __enum_open
50 #define __options_decl(_name, _type, ...) \
51 typedef _type _name; enum __VA_ARGS__ __enum_open __enum_options
52 #endif
53
54 /*
55 * This file must be kept in sync with xnu headers
56 */
57
58 /*
59 * bsd/sys/event.h
60 */
61 __options_decl(kn_status_t, uint16_t /* 12 bits really */, {
62 KN_ACTIVE = 0x001, /* event has been triggered */
63 KN_QUEUED = 0x002, /* event is on queue */
64 KN_DISABLED = 0x004, /* event is disabled */
65 KN_DROPPING = 0x008, /* knote is being dropped */
66 KN_LOCKED = 0x010, /* knote is locked (kq_knlocks) */
67 KN_POSTING = 0x020, /* f_event() in flight */
68 KN_STAYACTIVE = 0x040, /* force event to stay active */
69 KN_DEFERDELETE = 0x080, /* defer delete until re-enabled */
70 KN_MERGE_QOS = 0x100, /* f_event() / f_* ran concurrently and overrides must merge */
71 KN_REQVANISH = 0x200, /* requested EV_VANISH */
72 KN_VANISHED = 0x400, /* has vanished */
73 KN_SUPPRESSED = 0x800, /* event is suppressed during delivery */
74 });
75
76 /*
77 * bsd/sys/eventvar.h
78 */
79 __options_decl(kq_state_t, uint16_t, {
80 KQ_SEL = 0x0001, /* select was recorded for kq */
81 KQ_SLEEP = 0x0002, /* thread is waiting for events */
82 KQ_PROCWAIT = 0x0004, /* thread waiting for processing */
83 KQ_KEV32 = 0x0008, /* kq is used with 32-bit events */
84 KQ_KEV64 = 0x0010, /* kq is used with 64-bit events */
85 KQ_KEV_QOS = 0x0020, /* kq events carry QoS info */
86 KQ_WORKQ = 0x0040, /* KQ is bound to process workq */
87 KQ_WORKLOOP = 0x0080, /* KQ is part of a workloop */
88 KQ_PROCESSING = 0x0100, /* KQ is being processed */
89 KQ_DRAIN = 0x0200, /* kq is draining */
90 KQ_WAKEUP = 0x0400, /* kq awakened while processing */
91 KQ_DYNAMIC = 0x0800, /* kqueue is dynamically managed */
92 KQ_R2K_ARMED = 0x1000, /* ast notification armed */
93 KQ_HAS_TURNSTILE = 0x2000, /* this kqueue has a turnstile */
94 });
95
96 /*
97 * bsd/pthread/workqueue_internal.h
98 */
99 __enum_decl(workq_tr_state_t, uint8_t, {
100 WORKQ_TR_STATE_IDLE = 0, /* request isn't in flight */
101 WORKQ_TR_STATE_NEW = 1, /* request is being initiated */
102 WORKQ_TR_STATE_QUEUED = 2, /* request is being queued */
103 WORKQ_TR_STATE_CANCELED = 3, /* request is canceled */
104 WORKQ_TR_STATE_BINDING = 4, /* request is preposted for bind */
105 WORKQ_TR_STATE_BOUND = 5, /* request is bound to a thread */
106 });
107
108
109 /*
110 * bsd/sys/signal.h
111 */
112 static const char *
113 sig_strs[] = {
114 [0] = "<UNKN>",
115 [1] = "SIGHUP",
116 [2] = "SIGINT",
117 [3] = "SIGQUIT",
118 [4] = "SIGILL",
119 [5] = "SIGTRAP",
120 [6] = "SIGABRT",
121 [7] = "SIGEMT",
122 [8] = "SIGFPE",
123 [9] = "SIGKILL",
124 [10] = "SIGBUS",
125 [11] = "SIGSEGV",
126 [12] = "SIGSYS",
127 [13] = "SIGPIPE",
128 [14] = "SIGALRM",
129 [15] = "SIGTERM",
130 [16] = "SIGURG",
131 [17] = "SIGSTOP",
132 [18] = "SIGTSTP",
133 [19] = "SIGCONT",
134 [20] = "SIGCHLD",
135 [21] = "SIGTTIN",
136 [22] = "SIGTTOU",
137 [23] = "SIGIO",
138 [24] = "SIGXCPU",
139 [25] = "SIGXFSZ",
140 [26] = "SIGVTALRM",
141 [27] = "SIGPROF",
142 [28] = "SIGWINCH",
143 [29] = "SIGINFO",
144 [30] = "SIGUSR1",
145 [31] = "SIGUSR2"
146 };
147
148 /*
149 * bsd/sys/event.h: EVFILT_*
150 */
151 static const char *
152 filt_strs[] = {
153 NULL,
154 "READ",
155 "WRITE",
156 "AIO",
157 "VNODE",
158 "PROC",
159 "SIGNAL",
160 "TIMER",
161 "MACHPORT",
162 "FS",
163 "USER",
164 "<inval>",
165 "VM",
166 "SOCK",
167 "MEMSTATUS",
168 "EXCEPT",
169 "CHANNEL",
170 "WORKLOOP",
171 };
172
173 /*
174 * bsd/sys/proc_info.h: PROX_FDTYPE_*
175 */
176 static const char *
177 fdtype_strs[] = {
178 "ATALK",
179 "VNODE",
180 "SOCKET",
181 "PSHM",
182 "PSEM",
183 "KQUEUE",
184 "PIPE",
185 "FSEVENTS",
186 "ATALK",
187 "POLICY",
188 "CHANNEL",
189 "NEXUS",
190 };
191
192 #endif /* _LSKQ_COMMON_H_ */