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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
|
package linux
/*
Special file descriptor to pass to `*at` functions to specify
that relative paths are relative to current directory.
*/
AT_FDCWD :: Fd(-100)
/*
Special value to put into timespec for utimensat() to set timestamp to the current time.
*/
UTIME_NOW :: uint((1 << 30) - 1)
/*
Special value to put into the timespec for utimensat() to leave the corresponding field of the timestamp unchanged.
*/
UTIME_OMIT :: uint((1 << 30) - 2)
/*
For wait4: Pass this pid to wait for any process.
*/
WAIT_ANY :: Pid(-1)
/*
For wait4: Pass this pid to wait for any process in current process group.
*/
WAIT_MYPGRP :: Pid(0)
/*
Maximum priority (aka nice value) for the process.
*/
PRIO_MAX :: 20
/*
Minimum priority (aka nice value) for the process.
*/
PRIO_MIN :: -20
SIGRTMIN :: Signal(32)
SIGRTMAX :: Signal(64)
S_IFMT :: Mode{.IFREG, .IFDIR, .IFCHR, .IFFIFO}
S_IFSOCK :: Mode{.IFREG, .IFDIR}
S_IFLNK :: Mode{.IFREG, .IFCHR}
S_IFBLK :: Mode{.IFDIR, .IFCHR}
S_IFFIFO :: Mode{.IFFIFO}
S_IFCHR :: Mode{.IFCHR}
S_IFDIR :: Mode{.IFDIR}
S_IFREG :: Mode{.IFREG}
/*
Checks the Mode bits to see if the file is a named pipe (FIFO).
*/
S_ISFIFO :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFFIFO == (m & S_IFMT))}
/*
Check the Mode bits to see if the file is a character device.
*/
S_ISCHR :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFCHR == (m & S_IFMT))}
/*
Check the Mode bits to see if the file is a directory.
*/
S_ISDIR :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFDIR == (m & S_IFMT))}
/*
Check the Mode bits to see if the file is a register.
*/
S_ISREG :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFREG == (m & S_IFMT))}
/*
Check the Mode bits to see if the file is a socket.
*/
S_ISSOCK :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFSOCK == (m & S_IFMT))}
/*
Check the Mode bits to see if the file is a symlink.
*/
S_ISLNK :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFLNK == (m & S_IFMT))}
/*
Check the Mode bits to see if the file is a block device.
*/
S_ISBLK :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFBLK == (m & S_IFMT))}
/*
For access.2 syscall family: instruct to check if the file exists.
*/
F_OK :: Mode{}
/*
For access.2 syscall family: instruct to check if the file is executable.
*/
X_OK :: Mode{.IXOTH}
/*
For access.2 syscall family: instruct to check if the file is writeable.
*/
W_OK :: Mode{.IWOTH}
/*
For access.2 syscall family: instruct to check if the file is readable.
*/
R_OK :: Mode{.IROTH}
/*
The stats you get by calling `stat`.
*/
STATX_BASIC_STATS :: Statx_Mask {
.TYPE,
.MODE,
.NLINK,
.UID,
.GID,
.ATIME,
.MTIME,
.CTIME,
.INO,
.SIZE,
.BLOCKS,
}
/*
Tell `shmget` to create a new key
*/
IPC_PRIVATE :: Key(0)
FCntl_Command_DUPFD :: distinct FCntl_Command
FCntl_Command_GETFD :: distinct FCntl_Command
FCntl_Command_SETFD :: distinct FCntl_Command
FCntl_Command_GETFL :: distinct FCntl_Command
FCntl_Command_SETFL :: distinct FCntl_Command
FCntl_Command_GETLK :: distinct FCntl_Command
FCntl_Command_SETLK :: distinct FCntl_Command
FCntl_Command_SETLKW :: distinct FCntl_Command
FCntl_Command_DUPFD_CLOEXEC :: distinct FCntl_Command
FCntl_Command_SETOWN :: distinct FCntl_Command
FCntl_Command_GETOWN :: distinct FCntl_Command
FCntl_Command_SETSIG :: distinct FCntl_Command
FCntl_Command_GETSIG :: distinct FCntl_Command
FCntl_Command_SETOWN_EX :: distinct FCntl_Command
FCntl_Command_GETOWN_EX :: distinct FCntl_Command
FCntl_Command_SETLEASE :: distinct FCntl_Command
FCntl_Command_GETLEASE :: distinct FCntl_Command
FCntl_Command_NOTIFY :: distinct FCntl_Command
FCntl_Command_SETPIPE_SZ :: distinct FCntl_Command
FCntl_Command_GETPIPE_SZ :: distinct FCntl_Command
FCntl_Command_ADD_SEALS :: distinct FCntl_Command
FCntl_Command_GET_SEALS :: distinct FCntl_Command
FCntl_Command_GET_RW_HINT :: distinct FCntl_Command
FCntl_Command_SET_RW_HINT :: distinct FCntl_Command
FCntl_Command_GET_FILE_RW_HINT :: distinct FCntl_Command
FCntl_Command_SET_FILE_RW_HINT :: distinct FCntl_Command
F_DUPFD :: FCntl_Command_DUPFD(.DUPFD)
F_GETFD :: FCntl_Command_GETFD(.GETFD)
F_SETFD :: FCntl_Command_SETFD(.SETFD)
F_GETFL :: FCntl_Command_GETFL(.GETFL)
F_SETFL :: FCntl_Command_SETFL(.SETFL)
// F_GETLK64 :: FCntl_Command_GETLK64(.GETLK64)
// F_SETLK64 :: FCntl_Command_SETLK64(.SETLK64)
// F_SETLKW64 :: FCntl_Command_SETLKW64(.SETLKW64)
F_GETLK :: FCntl_Command_GETLK(.GETLK)
F_SETLK :: FCntl_Command_SETLK(.SETLK)
F_SETLKW :: FCntl_Command_SETLKW(.SETLKW)
F_DUPFD_CLOEXEC :: FCntl_Command_DUPFD_CLOEXEC(.DUPFD_CLOEXEC)
F_SETOWN :: FCntl_Command_SETOWN(.SETOWN)
F_GETOWN :: FCntl_Command_GETOWN(.GETOWN)
F_SETSIG :: FCntl_Command_SETSIG(.SETSIG)
F_GETSIG :: FCntl_Command_GETSIG(.GETSIG)
F_SETOWN_EX :: FCntl_Command_SETOWN_EX(.SETOWN_EX)
F_GETOWN_EX :: FCntl_Command_GETOWN_EX(.GETOWN_EX)
F_SETLEASE :: FCntl_Command_SETLEASE(.SETLEASE)
F_GETLEASE :: FCntl_Command_GETLEASE(.GETLEASE)
F_NOTIFY :: FCntl_Command_NOTIFY(.NOTIFY)
F_SETPIPE_SZ :: FCntl_Command_SETPIPE_SZ(.SETPIPE_SZ)
F_GETPIPE_SZ :: FCntl_Command_GETPIPE_SZ(.GETPIPE_SZ)
F_ADD_SEALS :: FCntl_Command_ADD_SEALS(.ADD_SEALS)
F_GET_SEALS :: FCntl_Command_GET_SEALS(.GET_SEALS)
F_GET_RW_HINT :: FCntl_Command_GET_RW_HINT(.GET_RW_HINT)
F_SET_RW_HINT :: FCntl_Command_SET_RW_HINT(.SET_RW_HINT)
F_GET_FILE_RW_HINT :: FCntl_Command_GET_FILE_RW_HINT(.GET_FILE_RW_HINT)
F_SET_FILE_RW_HINT :: FCntl_Command_SET_FILE_RW_HINT(.SET_FILE_RW_HINT)
Socket_API_Level_Sock :: distinct Socket_API_Level
Socket_API_Level_TCP :: distinct Socket_API_Level
Socket_API_Level_UDP :: distinct Socket_API_Level
Socket_API_Level_Raw :: distinct Socket_API_Level
SOL_SOCKET :: Socket_API_Level_Sock(.SOCKET)
SOL_TCP :: Socket_API_Level_TCP(.TCP)
SOL_UDP :: Socket_API_Level_UDP(.UDP)
SOL_RAW :: Socket_API_Level_Raw(.RAW)
Futex_Wait_Type :: distinct Futex_Op
Futex_Wake_Type :: distinct Futex_Op
Futex_Fd_Type :: distinct Futex_Op
Futex_Requeue_Type :: distinct Futex_Op
Futex_Cmp_Requeue_Type :: distinct Futex_Op
Futex_Wake_Op_Type :: distinct Futex_Op
Futex_Lock_Pi_Type :: distinct Futex_Op
Futex_Unlock_Pi_Type :: distinct Futex_Op
Futex_Trylock_Pi_Type :: distinct Futex_Op
Futex_Wait_Bitset_Type :: distinct Futex_Op
Futex_Wake_Bitset_Type :: distinct Futex_Op
Futex_Wait_requeue_Pi_Type :: distinct Futex_Op
Futex_Cmp_requeue_Pi_Type :: distinct Futex_Op
Futex_Lock_Pi2_Type :: distinct Futex_Op
/*
Wait on futex wakeup signal.
*/
FUTEX_WAIT :: Futex_Wait_Type(.WAIT)
/*
Wake up other processes waiting on the futex.
*/
FUTEX_WAKE :: Futex_Wake_Type(.WAKE)
/*
Not implemented. Basically, since.
*/
FUTEX_FD :: Futex_Fd_Type(.FD)
/*
Requeue waiters from one futex to another.
*/
FUTEX_REQUEUE :: Futex_Requeue_Type(.REQUEUE)
/*
Requeue waiters from one futex to another if the value at mutex matches.
*/
FUTEX_CMP_REQUEUE :: Futex_Cmp_Requeue_Type(.CMP_REQUEUE)
/*
See man pages, I'm not describing it here.
*/
FUTEX_WAKE_OP :: Futex_Wake_Op_Type(.WAKE_OP)
/*
Wait on a futex, but the value is a bitset.
*/
FUTEX_WAIT_BITSET :: Futex_Wait_Bitset_Type(.WAIT_BITSET)
/*
Wait on a futex, but the value is a bitset.
*/
FUTEX_WAKE_BITSET :: Futex_Wake_Bitset_Type(.WAKE_BITSET)
// TODO(flysand): Priority inversion futexes
FUTEX_LOCK_PI :: Futex_Lock_Pi_Type(.LOCK_PI)
FUTEX_UNLOCK_PI :: Futex_Unlock_Pi_Type(.UNLOCK_PI)
FUTEX_TRYLOCK_PI :: Futex_Trylock_Pi_Type(.TRYLOCK_PI)
FUTEX_WAIT_REQUEUE_PI :: Futex_Wait_requeue_Pi_Type(.WAIT_REQUEUE_PI)
FUTEX_CMP_REQUEUE_PI :: Futex_Cmp_requeue_Pi_Type(.CMP_REQUEUE_PI)
FUTEX_LOCK_PI2 :: Futex_Lock_Pi2_Type(.LOCK_PI2)
PTrace_Traceme_Type :: distinct PTrace_Request
PTrace_Peek_Type :: distinct PTrace_Request
PTrace_Poke_Type :: distinct PTrace_Request
PTrace_Cont_Type :: distinct PTrace_Request
PTrace_Kill_Type :: distinct PTrace_Request
PTrace_Singlestep_Type :: distinct PTrace_Request
PTrace_Getregs_Type :: distinct PTrace_Request
PTrace_Setregs_Type :: distinct PTrace_Request
PTrace_Getfpregs_Type :: distinct PTrace_Request
PTrace_Setfpregs_Type :: distinct PTrace_Request
PTrace_Attach_Type :: distinct PTrace_Request
PTrace_Detach_Type :: distinct PTrace_Request
PTrace_Getfpxregs_Type :: distinct PTrace_Request
PTrace_Setfpxregs_Type :: distinct PTrace_Request
PTrace_Syscall_Type :: distinct PTrace_Request
PTrace_Get_Thread_Area_Type :: distinct PTrace_Request
PTrace_Set_Thread_Area_Type :: distinct PTrace_Request
PTrace_Arch_Prctl_Type :: distinct PTrace_Request
PTrace_Sysemu_Type :: distinct PTrace_Request
PTrace_Sysemu_Singlestep_Type :: distinct PTrace_Request
PTrace_Singleblock_Type :: distinct PTrace_Request
PTrace_Setoptions_Type :: distinct PTrace_Request
PTrace_Geteventmsg_Type :: distinct PTrace_Request
PTrace_Getsiginfo_Type :: distinct PTrace_Request
PTrace_Setsiginfo_Type :: distinct PTrace_Request
PTrace_Getregset_Type :: distinct PTrace_Request
PTrace_Setregset_Type :: distinct PTrace_Request
PTrace_Seize_Type :: distinct PTrace_Request
PTrace_Interrupt_Type :: distinct PTrace_Request
PTrace_Listen_Type :: distinct PTrace_Request
PTrace_Peeksiginfo_Type :: distinct PTrace_Request
PTrace_Getsigmask_Type :: distinct PTrace_Request
PTrace_Setsigmask_Type :: distinct PTrace_Request
PTrace_Seccomp_Get_Filter_Type :: distinct PTrace_Request
PTrace_Seccomp_Get_Metadata_Type :: distinct PTrace_Request
PTrace_Get_Syscall_Info_Type :: distinct PTrace_Request
PTrace_Get_RSeq_Configuration_Type :: distinct PTrace_Request
PTRACE_TRACEME :: PTrace_Traceme_Type(.TRACEME)
PTRACE_PEEKTEXT :: PTrace_Peek_Type(.PEEKTEXT)
PTRACE_PEEKDATA :: PTrace_Peek_Type(.PEEKDATA)
PTRACE_PEEKUSER :: PTrace_Peek_Type(.PEEKUSER)
PTRACE_POKETEXT :: PTrace_Poke_Type(.POKETEXT)
PTRACE_POKEDATA :: PTrace_Poke_Type(.POKEDATA)
PTRACE_POKEUSER :: PTrace_Poke_Type(.POKEUSER)
PTRACE_CONT :: PTrace_Cont_Type(.CONT)
PTRACE_KILL :: PTrace_Kill_Type(.KILL)
PTRACE_SINGLESTEP :: PTrace_Singlestep_Type(.SINGLESTEP)
PTRACE_GETREGS :: PTrace_Getregs_Type(.GETREGS)
PTRACE_SETREGS :: PTrace_Setregs_Type(.SETREGS)
PTRACE_GETFPREGS :: PTrace_Getfpregs_Type(.GETFPREGS)
PTRACE_SETFPREGS :: PTrace_Setfpregs_Type(.SETFPREGS)
PTRACE_ATTACH :: PTrace_Attach_Type(.ATTACH)
PTRACE_DETACH :: PTrace_Detach_Type(.DETACH)
PTRACE_GETFPXREGS :: PTrace_Getfpxregs_Type(.GETFPXREGS)
PTRACE_SETFPXREGS :: PTrace_Setfpxregs_Type(.SETFPXREGS)
PTRACE_SYSCALL :: PTrace_Syscall_Type(.SYSCALL)
PTRACE_GET_THREAD_AREA :: PTrace_Get_Thread_Area_Type(.GET_THREAD_AREA)
PTRACE_SET_THREAD_AREA :: PTrace_Set_Thread_Area_Type(.SET_THREAD_AREA)
PTRACE_ARCH_PRCTL :: PTrace_Arch_Prctl_Type(.ARCH_PRCTL)
PTRACE_SYSEMU :: PTrace_Sysemu_Type(.SYSEMU)
PTRACE_SYSEMU_SINGLESTEP :: PTrace_Sysemu_Singlestep_Type(.SYSEMU_SINGLESTEP)
PTRACE_SINGLEBLOCK :: PTrace_Singleblock_Type(.SINGLEBLOCK)
PTRACE_SETOPTIONS :: PTrace_Setoptions_Type(.SETOPTIONS)
PTRACE_GETEVENTMSG :: PTrace_Geteventmsg_Type(.GETEVENTMSG)
PTRACE_GETSIGINFO :: PTrace_Getsiginfo_Type(.GETSIGINFO)
PTRACE_SETSIGINFO :: PTrace_Setsiginfo_Type(.SETSIGINFO)
PTRACE_GETREGSET :: PTrace_Getregset_Type(.GETREGSET)
PTRACE_SETREGSET :: PTrace_Setregset_Type(.SETREGSET)
PTRACE_SEIZE :: PTrace_Seize_Type(.SEIZE)
PTRACE_INTERRUPT :: PTrace_Interrupt_Type(.INTERRUPT)
PTRACE_LISTEN :: PTrace_Listen_Type(.LISTEN)
PTRACE_PEEKSIGINFO :: PTrace_Peeksiginfo_Type(.PEEKSIGINFO)
PTRACE_GETSIGMASK :: PTrace_Getsigmask_Type(.GETSIGMASK)
PTRACE_SETSIGMASK :: PTrace_Setsigmask_Type(.SETSIGMASK)
PTRACE_SECCOMP_GET_FILTER :: PTrace_Seccomp_Get_Filter_Type(.SECCOMP_GET_FILTER)
PTRACE_SECCOMP_GET_METADATA :: PTrace_Seccomp_Get_Metadata_Type(.SECCOMP_GET_METADATA)
PTRACE_GET_SYSCALL_INFO :: PTrace_Get_Syscall_Info_Type(.GET_SYSCALL_INFO)
PTRACE_GET_RSEQ_CONFIGURATION :: PTrace_Get_RSeq_Configuration_Type(.GET_RSEQ_CONFIGURATION)
|