1const std = @import("../std.zig");
2const builtin = @import("builtin");
3const maxInt = std.math.maxInt;
4const iovec = std.os.iovec;
5const iovec_const = std.os.iovec_const;
6const timezone = std.c.timezone;
7const rusage = std.c.rusage;
8
9extern "c" fn __errno() *c_int;
10pub const _errno = __errno;
11
12pub const dl_iterate_phdr_callback = fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int;
13pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*anyopaque) c_int;
14
15pub extern "c" fn _lwp_self() lwpid_t;
16
17pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int;
18pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;
19
20pub extern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_int;
21pub const fstat = __fstat50;
22
23pub extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int;
24pub const stat = __stat50;
25
26pub extern "c" fn __clock_gettime50(clk_id: c_int, tp: *timespec) c_int;
27pub const clock_gettime = __clock_gettime50;
28
29pub extern "c" fn __clock_getres50(clk_id: c_int, tp: *timespec) c_int;
30pub const clock_getres = __clock_getres50;
31
32pub extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int;
33pub const getdents = __getdents30;
34
35pub extern "c" fn __sigaltstack14(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
36pub const sigaltstack = __sigaltstack14;
37
38pub extern "c" fn __nanosleep50(rqtp: *const timespec, rmtp: ?*timespec) c_int;
39pub const nanosleep = __nanosleep50;
40
41pub extern "c" fn __sigaction14(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
42pub const sigaction = __sigaction14;
43
44pub extern "c" fn __sigprocmask14(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
45pub const sigprocmask = __sigaction14;
46
47pub extern "c" fn __socket30(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
48pub const socket = __socket30;
49
50pub extern "c" fn __gettimeofday50(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
51pub const gettimeofday = __gettimeofday50;
52
53pub extern "c" fn __getrusage50(who: c_int, usage: *rusage) c_int;
54pub const getrusage = __getrusage50;
55
56pub extern "c" fn __libc_thr_yield() c_int;
57pub const sched_yield = __libc_thr_yield;
58
59pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int;
60
61pub const pthread_mutex_t = extern struct {
62    magic: u32 = 0x33330003,
63    errorcheck: padded_pthread_spin_t = 0,
64    ceiling: padded_pthread_spin_t = 0,
65    owner: usize = 0,
66    waiters: ?*u8 = null,
67    recursed: u32 = 0,
68    spare2: ?*anyopaque = null,
69};
70
71pub const pthread_cond_t = extern struct {
72    magic: u32 = 0x55550005,
73    lock: pthread_spin_t = 0,
74    waiters_first: ?*u8 = null,
75    waiters_last: ?*u8 = null,
76    mutex: ?*pthread_mutex_t = null,
77    private: ?*anyopaque = null,
78};
79
80pub const pthread_rwlock_t = extern struct {
81    magic: c_uint = 0x99990009,
82    interlock: switch (builtin.cpu.arch) {
83        .aarch64, .sparc, .x86_64, .i386 => u8,
84        .arm, .powerpc => c_int,
85        else => unreachable,
86    } = 0,
87    rblocked_first: ?*u8 = null,
88    rblocked_last: ?*u8 = null,
89    wblocked_first: ?*u8 = null,
90    wblocked_last: ?*u8 = null,
91    nreaders: c_uint = 0,
92    owner: std.c.pthread_t = null,
93    private: ?*anyopaque = null,
94};
95
96const pthread_spin_t = switch (builtin.cpu.arch) {
97    .aarch64, .aarch64_be, .aarch64_32 => u8,
98    .mips, .mipsel, .mips64, .mips64el => u32,
99    .powerpc, .powerpc64, .powerpc64le => i32,
100    .i386, .x86_64 => u8,
101    .arm, .armeb, .thumb, .thumbeb => i32,
102    .sparc, .sparcel, .sparcv9 => u8,
103    .riscv32, .riscv64 => u32,
104    else => @compileError("undefined pthread_spin_t for this arch"),
105};
106
107const padded_pthread_spin_t = switch (builtin.cpu.arch) {
108    .i386, .x86_64 => u32,
109    .sparc, .sparcel, .sparcv9 => u32,
110    else => pthread_spin_t,
111};
112
113pub const pthread_attr_t = extern struct {
114    pta_magic: u32,
115    pta_flags: i32,
116    pta_private: ?*anyopaque,
117};
118
119pub const sem_t = ?*opaque {};
120
121pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*anyopaque) E;
122pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E;
123
124pub const blkcnt_t = i64;
125pub const blksize_t = i32;
126pub const clock_t = u32;
127pub const dev_t = u64;
128pub const fd_t = i32;
129pub const gid_t = u32;
130pub const ino_t = u64;
131pub const mode_t = u32;
132pub const nlink_t = u32;
133pub const off_t = i64;
134pub const pid_t = i32;
135pub const socklen_t = u32;
136pub const time_t = i64;
137pub const uid_t = u32;
138pub const lwpid_t = i32;
139pub const suseconds_t = c_int;
140
141/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
142pub const Kevent = extern struct {
143    ident: usize,
144    filter: i32,
145    flags: u32,
146    fflags: u32,
147    data: i64,
148    udata: usize,
149};
150
151pub const RTLD = struct {
152    pub const LAZY = 1;
153    pub const NOW = 2;
154    pub const GLOBAL = 0x100;
155    pub const LOCAL = 0x200;
156    pub const NODELETE = 0x01000;
157    pub const NOLOAD = 0x02000;
158
159    pub const NEXT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -1)));
160    pub const DEFAULT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -2)));
161    pub const SELF = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -3)));
162};
163
164pub const dl_phdr_info = extern struct {
165    dlpi_addr: usize,
166    dlpi_name: ?[*:0]const u8,
167    dlpi_phdr: [*]std.elf.Phdr,
168    dlpi_phnum: u16,
169};
170
171pub const Flock = extern struct {
172    l_start: off_t,
173    l_len: off_t,
174    l_pid: pid_t,
175    l_type: i16,
176    l_whence: i16,
177};
178
179pub const addrinfo = extern struct {
180    flags: i32,
181    family: i32,
182    socktype: i32,
183    protocol: i32,
184    addrlen: socklen_t,
185    canonname: ?[*:0]u8,
186    addr: ?*sockaddr,
187    next: ?*addrinfo,
188};
189
190pub const EAI = enum(c_int) {
191    /// address family for hostname not supported
192    ADDRFAMILY = 1,
193
194    /// name could not be resolved at this time
195    AGAIN = 2,
196
197    /// flags parameter had an invalid value
198    BADFLAGS = 3,
199
200    /// non-recoverable failure in name resolution
201    FAIL = 4,
202
203    /// address family not recognized
204    FAMILY = 5,
205
206    /// memory allocation failure
207    MEMORY = 6,
208
209    /// no address associated with hostname
210    NODATA = 7,
211
212    /// name does not resolve
213    NONAME = 8,
214
215    /// service not recognized for socket type
216    SERVICE = 9,
217
218    /// intended socket type was not recognized
219    SOCKTYPE = 10,
220
221    /// system error returned in errno
222    SYSTEM = 11,
223
224    /// invalid value for hints
225    BADHINTS = 12,
226
227    /// resolved protocol is unknown
228    PROTOCOL = 13,
229
230    /// argument buffer overflow
231    OVERFLOW = 14,
232
233    _,
234};
235
236pub const EAI_MAX = 15;
237
238pub const msghdr = extern struct {
239    /// optional address
240    msg_name: ?*sockaddr,
241
242    /// size of address
243    msg_namelen: socklen_t,
244
245    /// scatter/gather array
246    msg_iov: [*]iovec,
247
248    /// # elements in msg_iov
249    msg_iovlen: i32,
250
251    /// ancillary data
252    msg_control: ?*anyopaque,
253
254    /// ancillary data buffer len
255    msg_controllen: socklen_t,
256
257    /// flags on received message
258    msg_flags: i32,
259};
260
261pub const msghdr_const = extern struct {
262    /// optional address
263    msg_name: ?*const sockaddr,
264
265    /// size of address
266    msg_namelen: socklen_t,
267
268    /// scatter/gather array
269    msg_iov: [*]iovec_const,
270
271    /// # elements in msg_iov
272    msg_iovlen: i32,
273
274    /// ancillary data
275    msg_control: ?*anyopaque,
276
277    /// ancillary data buffer len
278    msg_controllen: socklen_t,
279
280    /// flags on received message
281    msg_flags: i32,
282};
283
284/// The stat structure used by libc.
285pub const Stat = extern struct {
286    dev: dev_t,
287    mode: mode_t,
288    ino: ino_t,
289    nlink: nlink_t,
290    uid: uid_t,
291    gid: gid_t,
292    rdev: dev_t,
293    atim: timespec,
294    mtim: timespec,
295    ctim: timespec,
296    birthtim: timespec,
297    size: off_t,
298    blocks: blkcnt_t,
299    blksize: blksize_t,
300    flags: u32,
301    gen: u32,
302    __spare: [2]u32,
303
304    pub fn atime(self: @This()) timespec {
305        return self.atim;
306    }
307
308    pub fn mtime(self: @This()) timespec {
309        return self.mtim;
310    }
311
312    pub fn ctime(self: @This()) timespec {
313        return self.ctim;
314    }
315};
316
317pub const timespec = extern struct {
318    tv_sec: i64,
319    tv_nsec: isize,
320};
321
322pub const timeval = extern struct {
323    /// seconds
324    tv_sec: time_t,
325    /// microseconds
326    tv_usec: suseconds_t,
327};
328
329pub const MAXNAMLEN = 511;
330
331pub const dirent = extern struct {
332    d_fileno: ino_t,
333    d_reclen: u16,
334    d_namlen: u16,
335    d_type: u8,
336    d_name: [MAXNAMLEN:0]u8,
337
338    pub fn reclen(self: dirent) u16 {
339        return self.d_reclen;
340    }
341};
342
343pub const SOCK = struct {
344    pub const STREAM = 1;
345    pub const DGRAM = 2;
346    pub const RAW = 3;
347    pub const RDM = 4;
348    pub const SEQPACKET = 5;
349    pub const CONN_DGRAM = 6;
350    pub const DCCP = CONN_DGRAM;
351
352    pub const CLOEXEC = 0x10000000;
353    pub const NONBLOCK = 0x20000000;
354    pub const NOSIGPIPE = 0x40000000;
355    pub const FLAGS_MASK = 0xf0000000;
356};
357
358pub const SO = struct {
359    pub const DEBUG = 0x0001;
360    pub const ACCEPTCONN = 0x0002;
361    pub const REUSEADDR = 0x0004;
362    pub const KEEPALIVE = 0x0008;
363    pub const DONTROUTE = 0x0010;
364    pub const BROADCAST = 0x0020;
365    pub const USELOOPBACK = 0x0040;
366    pub const LINGER = 0x0080;
367    pub const OOBINLINE = 0x0100;
368    pub const REUSEPORT = 0x0200;
369    pub const NOSIGPIPE = 0x0800;
370    pub const ACCEPTFILTER = 0x1000;
371    pub const TIMESTAMP = 0x2000;
372    pub const RERROR = 0x4000;
373
374    pub const SNDBUF = 0x1001;
375    pub const RCVBUF = 0x1002;
376    pub const SNDLOWAT = 0x1003;
377    pub const RCVLOWAT = 0x1004;
378    pub const ERROR = 0x1007;
379    pub const TYPE = 0x1008;
380    pub const OVERFLOWED = 0x1009;
381
382    pub const NOHEADER = 0x100a;
383    pub const SNDTIMEO = 0x100b;
384    pub const RCVTIMEO = 0x100c;
385};
386
387pub const SOL = struct {
388    pub const SOCKET = 0xffff;
389};
390
391pub const PF = struct {
392    pub const UNSPEC = AF.UNSPEC;
393    pub const LOCAL = AF.LOCAL;
394    pub const UNIX = PF.LOCAL;
395    pub const INET = AF.INET;
396    pub const IMPLINK = AF.IMPLINK;
397    pub const PUP = AF.PUP;
398    pub const CHAOS = AF.CHAOS;
399    pub const NS = AF.NS;
400    pub const ISO = AF.ISO;
401    pub const OSI = AF.ISO;
402    pub const ECMA = AF.ECMA;
403    pub const DATAKIT = AF.DATAKIT;
404    pub const CCITT = AF.CCITT;
405    pub const SNA = AF.SNA;
406    pub const DECnet = AF.DECnet;
407    pub const DLI = AF.DLI;
408    pub const LAT = AF.LAT;
409    pub const HYLINK = AF.HYLINK;
410    pub const APPLETALK = AF.APPLETALK;
411    pub const OROUTE = AF.OROUTE;
412    pub const LINK = AF.LINK;
413    pub const COIP = AF.COIP;
414    pub const CNT = AF.CNT;
415    pub const INET6 = AF.INET6;
416    pub const IPX = AF.IPX;
417    pub const ISDN = AF.ISDN;
418    pub const E164 = AF.E164;
419    pub const NATM = AF.NATM;
420    pub const ARP = AF.ARP;
421    pub const BLUETOOTH = AF.BLUETOOTH;
422    pub const MPLS = AF.MPLS;
423    pub const ROUTE = AF.ROUTE;
424    pub const CAN = AF.CAN;
425    pub const ETHER = AF.ETHER;
426    pub const MAX = AF.MAX;
427};
428
429pub const AF = struct {
430    pub const UNSPEC = 0;
431    pub const LOCAL = 1;
432    pub const UNIX = LOCAL;
433    pub const INET = 2;
434    pub const IMPLINK = 3;
435    pub const PUP = 4;
436    pub const CHAOS = 5;
437    pub const NS = 6;
438    pub const ISO = 7;
439    pub const OSI = ISO;
440    pub const ECMA = 8;
441    pub const DATAKIT = 9;
442    pub const CCITT = 10;
443    pub const SNA = 11;
444    pub const DECnet = 12;
445    pub const DLI = 13;
446    pub const LAT = 14;
447    pub const HYLINK = 15;
448    pub const APPLETALK = 16;
449    pub const OROUTE = 17;
450    pub const LINK = 18;
451    pub const COIP = 20;
452    pub const CNT = 21;
453    pub const IPX = 23;
454    pub const INET6 = 24;
455    pub const ISDN = 26;
456    pub const E164 = ISDN;
457    pub const NATM = 27;
458    pub const ARP = 28;
459    pub const BLUETOOTH = 31;
460    pub const IEEE80211 = 32;
461    pub const MPLS = 33;
462    pub const ROUTE = 34;
463    pub const CAN = 35;
464    pub const ETHER = 36;
465    pub const MAX = 37;
466};
467
468pub const in_port_t = u16;
469pub const sa_family_t = u8;
470
471pub const sockaddr = extern struct {
472    /// total length
473    len: u8,
474    /// address family
475    family: sa_family_t,
476    /// actually longer; address value
477    data: [14]u8,
478
479    pub const SS_MAXSIZE = 128;
480    pub const storage = std.x.os.Socket.Address.Native.Storage;
481
482    pub const in = extern struct {
483        len: u8 = @sizeOf(in),
484        family: sa_family_t = AF.INET,
485        port: in_port_t,
486        addr: u32,
487        zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
488    };
489
490    pub const in6 = extern struct {
491        len: u8 = @sizeOf(in6),
492        family: sa_family_t = AF.INET6,
493        port: in_port_t,
494        flowinfo: u32,
495        addr: [16]u8,
496        scope_id: u32,
497    };
498
499    /// Definitions for UNIX IPC domain.
500    pub const un = extern struct {
501        /// total sockaddr length
502        len: u8 = @sizeOf(un),
503
504        family: sa_family_t = AF.LOCAL,
505
506        /// path name
507        path: [104]u8,
508    };
509};
510
511pub const AI = struct {
512    /// get address to use bind()
513    pub const PASSIVE = 0x00000001;
514    /// fill ai_canonname
515    pub const CANONNAME = 0x00000002;
516    /// prevent host name resolution
517    pub const NUMERICHOST = 0x00000004;
518    /// prevent service name resolution
519    pub const NUMERICSERV = 0x00000008;
520    /// only if any address is assigned
521    pub const ADDRCONFIG = 0x00000400;
522};
523
524pub const CTL = struct {
525    pub const KERN = 1;
526    pub const DEBUG = 5;
527};
528
529pub const KERN = struct {
530    pub const PROC_ARGS = 48; // struct: process argv/env
531    pub const PROC_PATHNAME = 5; // path to executable
532    pub const IOV_MAX = 38;
533};
534
535pub const PATH_MAX = 1024;
536pub const IOV_MAX = KERN.IOV_MAX;
537
538pub const STDIN_FILENO = 0;
539pub const STDOUT_FILENO = 1;
540pub const STDERR_FILENO = 2;
541
542pub const PROT = struct {
543    pub const NONE = 0;
544    pub const READ = 1;
545    pub const WRITE = 2;
546    pub const EXEC = 4;
547};
548
549pub const CLOCK = struct {
550    pub const REALTIME = 0;
551    pub const VIRTUAL = 1;
552    pub const PROF = 2;
553    pub const MONOTONIC = 3;
554    pub const THREAD_CPUTIME_ID = 0x20000000;
555    pub const PROCESS_CPUTIME_ID = 0x40000000;
556};
557
558pub const MAP = struct {
559    pub const FAILED = @intToPtr(*anyopaque, maxInt(usize));
560    pub const SHARED = 0x0001;
561    pub const PRIVATE = 0x0002;
562    pub const REMAPDUP = 0x0004;
563    pub const FIXED = 0x0010;
564    pub const RENAME = 0x0020;
565    pub const NORESERVE = 0x0040;
566    pub const INHERIT = 0x0080;
567    pub const HASSEMAPHORE = 0x0200;
568    pub const TRYFIXED = 0x0400;
569    pub const WIRED = 0x0800;
570
571    pub const FILE = 0x0000;
572    pub const NOSYNC = 0x0800;
573    pub const ANON = 0x1000;
574    pub const ANONYMOUS = ANON;
575    pub const STACK = 0x2000;
576};
577
578pub const W = struct {
579    pub const NOHANG = 0x00000001;
580    pub const UNTRACED = 0x00000002;
581    pub const STOPPED = UNTRACED;
582    pub const CONTINUED = 0x00000010;
583    pub const NOWAIT = 0x00010000;
584    pub const EXITED = 0x00000020;
585    pub const TRAPPED = 0x00000040;
586
587    pub fn EXITSTATUS(s: u32) u8 {
588        return @intCast(u8, (s >> 8) & 0xff);
589    }
590    pub fn TERMSIG(s: u32) u32 {
591        return s & 0x7f;
592    }
593    pub fn STOPSIG(s: u32) u32 {
594        return EXITSTATUS(s);
595    }
596    pub fn IFEXITED(s: u32) bool {
597        return TERMSIG(s) == 0;
598    }
599
600    pub fn IFCONTINUED(s: u32) bool {
601        return ((s & 0x7f) == 0xffff);
602    }
603
604    pub fn IFSTOPPED(s: u32) bool {
605        return ((s & 0x7f != 0x7f) and !IFCONTINUED(s));
606    }
607
608    pub fn IFSIGNALED(s: u32) bool {
609        return !IFSTOPPED(s) and !IFCONTINUED(s) and !IFEXITED(s);
610    }
611};
612
613pub const SA = struct {
614    pub const ONSTACK = 0x0001;
615    pub const RESTART = 0x0002;
616    pub const RESETHAND = 0x0004;
617    pub const NOCLDSTOP = 0x0008;
618    pub const NODEFER = 0x0010;
619    pub const NOCLDWAIT = 0x0020;
620    pub const SIGINFO = 0x0040;
621};
622
623// access function
624pub const F_OK = 0; // test for existence of file
625pub const X_OK = 1; // test for execute or search permission
626pub const W_OK = 2; // test for write permission
627pub const R_OK = 4; // test for read permission
628
629pub const O = struct {
630    /// open for reading only
631    pub const RDONLY = 0x00000000;
632    /// open for writing only
633    pub const WRONLY = 0x00000001;
634    /// open for reading and writing
635    pub const RDWR = 0x00000002;
636    /// mask for above modes
637    pub const ACCMODE = 0x00000003;
638    /// no delay
639    pub const NONBLOCK = 0x00000004;
640    /// set append mode
641    pub const APPEND = 0x00000008;
642    /// open with shared file lock
643    pub const SHLOCK = 0x00000010;
644    /// open with exclusive file lock
645    pub const EXLOCK = 0x00000020;
646    /// signal pgrp when data ready
647    pub const ASYNC = 0x00000040;
648    /// synchronous writes
649    pub const SYNC = 0x00000080;
650    /// don't follow symlinks on the last
651    pub const NOFOLLOW = 0x00000100;
652    /// create if nonexistent
653    pub const CREAT = 0x00000200;
654    /// truncate to zero length
655    pub const TRUNC = 0x00000400;
656    /// error if already exists
657    pub const EXCL = 0x00000800;
658    /// don't assign controlling terminal
659    pub const NOCTTY = 0x00008000;
660    /// write: I/O data completion
661    pub const DSYNC = 0x00010000;
662    /// read: I/O completion as for write
663    pub const RSYNC = 0x00020000;
664    /// use alternate i/o semantics
665    pub const ALT_IO = 0x00040000;
666    /// direct I/O hint
667    pub const DIRECT = 0x00080000;
668    /// fail if not a directory
669    pub const DIRECTORY = 0x00200000;
670    /// set close on exec
671    pub const CLOEXEC = 0x00400000;
672    /// skip search permission checks
673    pub const SEARCH = 0x00800000;
674};
675
676pub const F = struct {
677    pub const DUPFD = 0;
678    pub const GETFD = 1;
679    pub const SETFD = 2;
680    pub const GETFL = 3;
681    pub const SETFL = 4;
682
683    pub const GETOWN = 5;
684    pub const SETOWN = 6;
685
686    pub const GETLK = 7;
687    pub const SETLK = 8;
688    pub const SETLKW = 9;
689
690    pub const RDLCK = 1;
691    pub const WRLCK = 3;
692    pub const UNLCK = 2;
693};
694
695pub const LOCK = struct {
696    pub const SH = 1;
697    pub const EX = 2;
698    pub const UN = 8;
699    pub const NB = 4;
700};
701
702pub const FD_CLOEXEC = 1;
703
704pub const SEEK = struct {
705    pub const SET = 0;
706    pub const CUR = 1;
707    pub const END = 2;
708};
709
710pub const DT = struct {
711    pub const UNKNOWN = 0;
712    pub const FIFO = 1;
713    pub const CHR = 2;
714    pub const DIR = 4;
715    pub const BLK = 6;
716    pub const REG = 8;
717    pub const LNK = 10;
718    pub const SOCK = 12;
719    pub const WHT = 14;
720};
721
722/// add event to kq (implies enable)
723pub const EV_ADD = 0x0001;
724
725/// delete event from kq
726pub const EV_DELETE = 0x0002;
727
728/// enable event
729pub const EV_ENABLE = 0x0004;
730
731/// disable event (not reported)
732pub const EV_DISABLE = 0x0008;
733
734/// only report one occurrence
735pub const EV_ONESHOT = 0x0010;
736
737/// clear event state after reporting
738pub const EV_CLEAR = 0x0020;
739
740/// force immediate event output
741/// ... with or without EV_ERROR
742/// ... use KEVENT_FLAG_ERROR_EVENTS
743///     on syscalls supporting flags
744pub const EV_RECEIPT = 0x0040;
745
746/// disable event after reporting
747pub const EV_DISPATCH = 0x0080;
748
749pub const EVFILT_READ = 0;
750pub const EVFILT_WRITE = 1;
751
752/// attached to aio requests
753pub const EVFILT_AIO = 2;
754
755/// attached to vnodes
756pub const EVFILT_VNODE = 3;
757
758/// attached to struct proc
759pub const EVFILT_PROC = 4;
760
761/// attached to struct proc
762pub const EVFILT_SIGNAL = 5;
763
764/// timers
765pub const EVFILT_TIMER = 6;
766
767/// Filesystem events
768pub const EVFILT_FS = 7;
769
770/// User events
771pub const EVFILT_USER = 1;
772
773/// On input, NOTE_TRIGGER causes the event to be triggered for output.
774pub const NOTE_TRIGGER = 0x08000000;
775
776/// low water mark
777pub const NOTE_LOWAT = 0x00000001;
778
779/// vnode was removed
780pub const NOTE_DELETE = 0x00000001;
781
782/// data contents changed
783pub const NOTE_WRITE = 0x00000002;
784
785/// size increased
786pub const NOTE_EXTEND = 0x00000004;
787
788/// attributes changed
789pub const NOTE_ATTRIB = 0x00000008;
790
791/// link count changed
792pub const NOTE_LINK = 0x00000010;
793
794/// vnode was renamed
795pub const NOTE_RENAME = 0x00000020;
796
797/// vnode access was revoked
798pub const NOTE_REVOKE = 0x00000040;
799
800/// process exited
801pub const NOTE_EXIT = 0x80000000;
802
803/// process forked
804pub const NOTE_FORK = 0x40000000;
805
806/// process exec'd
807pub const NOTE_EXEC = 0x20000000;
808
809/// mask for signal & exit status
810pub const NOTE_PDATAMASK = 0x000fffff;
811pub const NOTE_PCTRLMASK = 0xf0000000;
812
813pub const T = struct {
814    pub const IOCCBRK = 0x2000747a;
815    pub const IOCCDTR = 0x20007478;
816    pub const IOCCONS = 0x80047462;
817    pub const IOCDCDTIMESTAMP = 0x40107458;
818    pub const IOCDRAIN = 0x2000745e;
819    pub const IOCEXCL = 0x2000740d;
820    pub const IOCEXT = 0x80047460;
821    pub const IOCFLAG_CDTRCTS = 0x10;
822    pub const IOCFLAG_CLOCAL = 0x2;
823    pub const IOCFLAG_CRTSCTS = 0x4;
824    pub const IOCFLAG_MDMBUF = 0x8;
825    pub const IOCFLAG_SOFTCAR = 0x1;
826    pub const IOCFLUSH = 0x80047410;
827    pub const IOCGETA = 0x402c7413;
828    pub const IOCGETD = 0x4004741a;
829    pub const IOCGFLAGS = 0x4004745d;
830    pub const IOCGLINED = 0x40207442;
831    pub const IOCGPGRP = 0x40047477;
832    pub const IOCGQSIZE = 0x40047481;
833    pub const IOCGRANTPT = 0x20007447;
834    pub const IOCGSID = 0x40047463;
835    pub const IOCGSIZE = 0x40087468;
836    pub const IOCGWINSZ = 0x40087468;
837    pub const IOCMBIC = 0x8004746b;
838    pub const IOCMBIS = 0x8004746c;
839    pub const IOCMGET = 0x4004746a;
840    pub const IOCMSET = 0x8004746d;
841    pub const IOCM_CAR = 0x40;
842    pub const IOCM_CD = 0x40;
843    pub const IOCM_CTS = 0x20;
844    pub const IOCM_DSR = 0x100;
845    pub const IOCM_DTR = 0x2;
846    pub const IOCM_LE = 0x1;
847    pub const IOCM_RI = 0x80;
848    pub const IOCM_RNG = 0x80;
849    pub const IOCM_RTS = 0x4;
850    pub const IOCM_SR = 0x10;
851    pub const IOCM_ST = 0x8;
852    pub const IOCNOTTY = 0x20007471;
853    pub const IOCNXCL = 0x2000740e;
854    pub const IOCOUTQ = 0x40047473;
855    pub const IOCPKT = 0x80047470;
856    pub const IOCPKT_DATA = 0x0;
857    pub const IOCPKT_DOSTOP = 0x20;
858    pub const IOCPKT_FLUSHREAD = 0x1;
859    pub const IOCPKT_FLUSHWRITE = 0x2;
860    pub const IOCPKT_IOCTL = 0x40;
861    pub const IOCPKT_NOSTOP = 0x10;
862    pub const IOCPKT_START = 0x8;
863    pub const IOCPKT_STOP = 0x4;
864    pub const IOCPTMGET = 0x40287446;
865    pub const IOCPTSNAME = 0x40287448;
866    pub const IOCRCVFRAME = 0x80087445;
867    pub const IOCREMOTE = 0x80047469;
868    pub const IOCSBRK = 0x2000747b;
869    pub const IOCSCTTY = 0x20007461;
870    pub const IOCSDTR = 0x20007479;
871    pub const IOCSETA = 0x802c7414;
872    pub const IOCSETAF = 0x802c7416;
873    pub const IOCSETAW = 0x802c7415;
874    pub const IOCSETD = 0x8004741b;
875    pub const IOCSFLAGS = 0x8004745c;
876    pub const IOCSIG = 0x2000745f;
877    pub const IOCSLINED = 0x80207443;
878    pub const IOCSPGRP = 0x80047476;
879    pub const IOCSQSIZE = 0x80047480;
880    pub const IOCSSIZE = 0x80087467;
881    pub const IOCSTART = 0x2000746e;
882    pub const IOCSTAT = 0x80047465;
883    pub const IOCSTI = 0x80017472;
884    pub const IOCSTOP = 0x2000746f;
885    pub const IOCSWINSZ = 0x80087467;
886    pub const IOCUCNTL = 0x80047466;
887    pub const IOCXMTFRAME = 0x80087444;
888};
889
890pub const winsize = extern struct {
891    ws_row: u16,
892    ws_col: u16,
893    ws_xpixel: u16,
894    ws_ypixel: u16,
895};
896
897const NSIG = 32;
898
899pub const SIG = struct {
900    pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
901    pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
902    pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
903
904    pub const WORDS = 4;
905    pub const MAXSIG = 128;
906
907    pub const BLOCK = 1;
908    pub const UNBLOCK = 2;
909    pub const SETMASK = 3;
910
911    pub const HUP = 1;
912    pub const INT = 2;
913    pub const QUIT = 3;
914    pub const ILL = 4;
915    pub const TRAP = 5;
916    pub const ABRT = 6;
917    pub const IOT = ABRT;
918    pub const EMT = 7;
919    pub const FPE = 8;
920    pub const KILL = 9;
921    pub const BUS = 10;
922    pub const SEGV = 11;
923    pub const SYS = 12;
924    pub const PIPE = 13;
925    pub const ALRM = 14;
926    pub const TERM = 15;
927    pub const URG = 16;
928    pub const STOP = 17;
929    pub const TSTP = 18;
930    pub const CONT = 19;
931    pub const CHLD = 20;
932    pub const TTIN = 21;
933    pub const TTOU = 22;
934    pub const IO = 23;
935    pub const XCPU = 24;
936    pub const XFSZ = 25;
937    pub const VTALRM = 26;
938    pub const PROF = 27;
939    pub const WINCH = 28;
940    pub const INFO = 29;
941    pub const USR1 = 30;
942    pub const USR2 = 31;
943    pub const PWR = 32;
944
945    pub const RTMIN = 33;
946    pub const RTMAX = 63;
947
948    pub inline fn IDX(sig: usize) usize {
949        return sig - 1;
950    }
951    pub inline fn WORD(sig: usize) usize {
952        return IDX(sig) >> 5;
953    }
954    pub inline fn BIT(sig: usize) usize {
955        return 1 << (IDX(sig) & 31);
956    }
957    pub inline fn VALID(sig: usize) usize {
958        return sig <= MAXSIG and sig > 0;
959    }
960};
961
962/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
963pub const Sigaction = extern struct {
964    pub const handler_fn = fn (c_int) callconv(.C) void;
965    pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void;
966
967    /// signal handler
968    handler: extern union {
969        handler: ?handler_fn,
970        sigaction: ?sigaction_fn,
971    },
972    /// signal mask to apply
973    mask: sigset_t,
974    /// signal options
975    flags: c_uint,
976};
977
978pub const sigval_t = extern union {
979    int: i32,
980    ptr: ?*anyopaque,
981};
982
983pub const siginfo_t = extern union {
984    pad: [128]u8,
985    info: _ksiginfo,
986};
987
988pub const _ksiginfo = extern struct {
989    signo: i32,
990    code: i32,
991    errno: i32,
992    // 64bit architectures insert 4bytes of padding here, this is done by
993    // correctly aligning the reason field
994    reason: extern union {
995        rt: extern struct {
996            pid: pid_t,
997            uid: uid_t,
998            value: sigval_t,
999        },
1000        child: extern struct {
1001            pid: pid_t,
1002            uid: uid_t,
1003            status: i32,
1004            utime: clock_t,
1005            stime: clock_t,
1006        },
1007        fault: extern struct {
1008            addr: ?*anyopaque,
1009            trap: i32,
1010            trap2: i32,
1011            trap3: i32,
1012        },
1013        poll: extern struct {
1014            band: i32,
1015            fd: i32,
1016        },
1017        syscall: extern struct {
1018            sysnum: i32,
1019            retval: [2]i32,
1020            @"error": i32,
1021            args: [8]u64,
1022        },
1023        ptrace_state: extern struct {
1024            pe_report_event: i32,
1025            option: extern union {
1026                pe_other_pid: pid_t,
1027                pe_lwp: lwpid_t,
1028            },
1029        },
1030    } align(@sizeOf(usize)),
1031};
1032
1033pub const sigset_t = extern struct {
1034    __bits: [SIG.WORDS]u32,
1035};
1036
1037pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** SIG.WORDS };
1038
1039// XXX x86_64 specific
1040pub const mcontext_t = extern struct {
1041    gregs: [26]u64,
1042    mc_tlsbase: u64,
1043    fpregs: [512]u8 align(8),
1044};
1045
1046pub const REG = struct {
1047    pub const RBP = 12;
1048    pub const RIP = 21;
1049    pub const RSP = 24;
1050};
1051
1052pub const ucontext_t = extern struct {
1053    flags: u32,
1054    link: ?*ucontext_t,
1055    sigmask: sigset_t,
1056    stack: stack_t,
1057    mcontext: mcontext_t,
1058    __pad: [
1059        switch (builtin.cpu.arch) {
1060            .i386 => 4,
1061            .mips, .mipsel, .mips64, .mips64el => 14,
1062            .arm, .armeb, .thumb, .thumbeb => 1,
1063            .sparc, .sparcel, .sparcv9 => if (@sizeOf(usize) == 4) 43 else 8,
1064            else => 0,
1065        }
1066    ]u32,
1067};
1068
1069pub const E = enum(u16) {
1070    /// No error occurred.
1071    SUCCESS = 0,
1072    PERM = 1, // Operation not permitted
1073    NOENT = 2, // No such file or directory
1074    SRCH = 3, // No such process
1075    INTR = 4, // Interrupted system call
1076    IO = 5, // Input/output error
1077    NXIO = 6, // Device not configured
1078    @"2BIG" = 7, // Argument list too long
1079    NOEXEC = 8, // Exec format error
1080    BADF = 9, // Bad file descriptor
1081    CHILD = 10, // No child processes
1082    DEADLK = 11, // Resource deadlock avoided
1083    // 11 was AGAIN
1084    NOMEM = 12, // Cannot allocate memory
1085    ACCES = 13, // Permission denied
1086    FAULT = 14, // Bad address
1087    NOTBLK = 15, // Block device required
1088    BUSY = 16, // Device busy
1089    EXIST = 17, // File exists
1090    XDEV = 18, // Cross-device link
1091    NODEV = 19, // Operation not supported by device
1092    NOTDIR = 20, // Not a directory
1093    ISDIR = 21, // Is a directory
1094    INVAL = 22, // Invalid argument
1095    NFILE = 23, // Too many open files in system
1096    MFILE = 24, // Too many open files
1097    NOTTY = 25, // Inappropriate ioctl for device
1098    TXTBSY = 26, // Text file busy
1099    FBIG = 27, // File too large
1100    NOSPC = 28, // No space left on device
1101    SPIPE = 29, // Illegal seek
1102    ROFS = 30, // Read-only file system
1103    MLINK = 31, // Too many links
1104    PIPE = 32, // Broken pipe
1105
1106    // math software
1107    DOM = 33, // Numerical argument out of domain
1108    RANGE = 34, // Result too large or too small
1109
1110    // non-blocking and interrupt i/o
1111    // also: WOULDBLOCK: operation would block
1112    AGAIN = 35, // Resource temporarily unavailable
1113    INPROGRESS = 36, // Operation now in progress
1114    ALREADY = 37, // Operation already in progress
1115
1116    // ipc/network software -- argument errors
1117    NOTSOCK = 38, // Socket operation on non-socket
1118    DESTADDRREQ = 39, // Destination address required
1119    MSGSIZE = 40, // Message too long
1120    PROTOTYPE = 41, // Protocol wrong type for socket
1121    NOPROTOOPT = 42, // Protocol option not available
1122    PROTONOSUPPORT = 43, // Protocol not supported
1123    SOCKTNOSUPPORT = 44, // Socket type not supported
1124    OPNOTSUPP = 45, // Operation not supported
1125    PFNOSUPPORT = 46, // Protocol family not supported
1126    AFNOSUPPORT = 47, // Address family not supported by protocol family
1127    ADDRINUSE = 48, // Address already in use
1128    ADDRNOTAVAIL = 49, // Can't assign requested address
1129
1130    // ipc/network software -- operational errors
1131    NETDOWN = 50, // Network is down
1132    NETUNREACH = 51, // Network is unreachable
1133    NETRESET = 52, // Network dropped connection on reset
1134    CONNABORTED = 53, // Software caused connection abort
1135    CONNRESET = 54, // Connection reset by peer
1136    NOBUFS = 55, // No buffer space available
1137    ISCONN = 56, // Socket is already connected
1138    NOTCONN = 57, // Socket is not connected
1139    SHUTDOWN = 58, // Can't send after socket shutdown
1140    TOOMANYREFS = 59, // Too many references: can't splice
1141    TIMEDOUT = 60, // Operation timed out
1142    CONNREFUSED = 61, // Connection refused
1143
1144    LOOP = 62, // Too many levels of symbolic links
1145    NAMETOOLONG = 63, // File name too long
1146
1147    // should be rearranged
1148    HOSTDOWN = 64, // Host is down
1149    HOSTUNREACH = 65, // No route to host
1150    NOTEMPTY = 66, // Directory not empty
1151
1152    // quotas & mush
1153    PROCLIM = 67, // Too many processes
1154    USERS = 68, // Too many users
1155    DQUOT = 69, // Disc quota exceeded
1156
1157    // Network File System
1158    STALE = 70, // Stale NFS file handle
1159    REMOTE = 71, // Too many levels of remote in path
1160    BADRPC = 72, // RPC struct is bad
1161    RPCMISMATCH = 73, // RPC version wrong
1162    PROGUNAVAIL = 74, // RPC prog. not avail
1163    PROGMISMATCH = 75, // Program version wrong
1164    PROCUNAVAIL = 76, // Bad procedure for program
1165
1166    NOLCK = 77, // No locks available
1167    NOSYS = 78, // Function not implemented
1168
1169    FTYPE = 79, // Inappropriate file type or format
1170    AUTH = 80, // Authentication error
1171    NEEDAUTH = 81, // Need authenticator
1172
1173    // SystemV IPC
1174    IDRM = 82, // Identifier removed
1175    NOMSG = 83, // No message of desired type
1176    OVERFLOW = 84, // Value too large to be stored in data type
1177
1178    // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
1179    ILSEQ = 85, // Illegal byte sequence
1180
1181    // From IEEE Std 1003.1-2001
1182    // Base, Realtime, Threads or Thread Priority Scheduling option errors
1183    NOTSUP = 86, // Not supported
1184
1185    // Realtime option errors
1186    CANCELED = 87, // Operation canceled
1187
1188    // Realtime, XSI STREAMS option errors
1189    BADMSG = 88, // Bad or Corrupt message
1190
1191    // XSI STREAMS option errors
1192    NODATA = 89, // No message available
1193    NOSR = 90, // No STREAM resources
1194    NOSTR = 91, // Not a STREAM
1195    TIME = 92, // STREAM ioctl timeout
1196
1197    // File system extended attribute errors
1198    NOATTR = 93, // Attribute not found
1199
1200    // Realtime, XSI STREAMS option errors
1201    MULTIHOP = 94, // Multihop attempted
1202    NOLINK = 95, // Link has been severed
1203    PROTO = 96, // Protocol error
1204
1205    _,
1206};
1207
1208pub const MINSIGSTKSZ = 8192;
1209pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
1210
1211pub const SS_ONSTACK = 1;
1212pub const SS_DISABLE = 4;
1213
1214pub const stack_t = extern struct {
1215    sp: [*]u8,
1216    size: isize,
1217    flags: i32,
1218};
1219
1220pub const S = struct {
1221    pub const IFMT = 0o170000;
1222
1223    pub const IFIFO = 0o010000;
1224    pub const IFCHR = 0o020000;
1225    pub const IFDIR = 0o040000;
1226    pub const IFBLK = 0o060000;
1227    pub const IFREG = 0o100000;
1228    pub const IFLNK = 0o120000;
1229    pub const IFSOCK = 0o140000;
1230    pub const IFWHT = 0o160000;
1231
1232    pub const ISUID = 0o4000;
1233    pub const ISGID = 0o2000;
1234    pub const ISVTX = 0o1000;
1235    pub const IRWXU = 0o700;
1236    pub const IRUSR = 0o400;
1237    pub const IWUSR = 0o200;
1238    pub const IXUSR = 0o100;
1239    pub const IRWXG = 0o070;
1240    pub const IRGRP = 0o040;
1241    pub const IWGRP = 0o020;
1242    pub const IXGRP = 0o010;
1243    pub const IRWXO = 0o007;
1244    pub const IROTH = 0o004;
1245    pub const IWOTH = 0o002;
1246    pub const IXOTH = 0o001;
1247
1248    pub fn ISFIFO(m: u32) bool {
1249        return m & IFMT == IFIFO;
1250    }
1251
1252    pub fn ISCHR(m: u32) bool {
1253        return m & IFMT == IFCHR;
1254    }
1255
1256    pub fn ISDIR(m: u32) bool {
1257        return m & IFMT == IFDIR;
1258    }
1259
1260    pub fn ISBLK(m: u32) bool {
1261        return m & IFMT == IFBLK;
1262    }
1263
1264    pub fn ISREG(m: u32) bool {
1265        return m & IFMT == IFREG;
1266    }
1267
1268    pub fn ISLNK(m: u32) bool {
1269        return m & IFMT == IFLNK;
1270    }
1271
1272    pub fn ISSOCK(m: u32) bool {
1273        return m & IFMT == IFSOCK;
1274    }
1275
1276    pub fn IWHT(m: u32) bool {
1277        return m & IFMT == IFWHT;
1278    }
1279};
1280
1281pub const AT = struct {
1282    /// Magic value that specify the use of the current working directory
1283    /// to determine the target of relative file paths in the openat() and
1284    /// similar syscalls.
1285    pub const FDCWD = -100;
1286    /// Check access using effective user and group ID
1287    pub const EACCESS = 0x0100;
1288    /// Do not follow symbolic links
1289    pub const SYMLINK_NOFOLLOW = 0x0200;
1290    /// Follow symbolic link
1291    pub const SYMLINK_FOLLOW = 0x0400;
1292    /// Remove directory instead of file
1293    pub const REMOVEDIR = 0x0800;
1294};
1295
1296pub const HOST_NAME_MAX = 255;
1297
1298pub const IPPROTO = struct {
1299    /// dummy for IP
1300    pub const IP = 0;
1301    /// IP6 hop-by-hop options
1302    pub const HOPOPTS = 0;
1303    /// control message protocol
1304    pub const ICMP = 1;
1305    /// group mgmt protocol
1306    pub const IGMP = 2;
1307    /// gateway^2 (deprecated)
1308    pub const GGP = 3;
1309    /// IP header
1310    pub const IPV4 = 4;
1311    /// IP inside IP
1312    pub const IPIP = 4;
1313    /// tcp
1314    pub const TCP = 6;
1315    /// exterior gateway protocol
1316    pub const EGP = 8;
1317    /// pup
1318    pub const PUP = 12;
1319    /// user datagram protocol
1320    pub const UDP = 17;
1321    /// xns idp
1322    pub const IDP = 22;
1323    /// tp-4 w/ class negotiation
1324    pub const TP = 29;
1325    /// DCCP
1326    pub const DCCP = 33;
1327    /// IP6 header
1328    pub const IPV6 = 41;
1329    /// IP6 routing header
1330    pub const ROUTING = 43;
1331    /// IP6 fragmentation header
1332    pub const FRAGMENT = 44;
1333    /// resource reservation
1334    pub const RSVP = 46;
1335    /// GRE encaps RFC 1701
1336    pub const GRE = 47;
1337    /// encap. security payload
1338    pub const ESP = 50;
1339    /// authentication header
1340    pub const AH = 51;
1341    /// IP Mobility RFC 2004
1342    pub const MOBILE = 55;
1343    /// IPv6 ICMP
1344    pub const IPV6_ICMP = 58;
1345    /// ICMP6
1346    pub const ICMPV6 = 58;
1347    /// IP6 no next header
1348    pub const NONE = 59;
1349    /// IP6 destination option
1350    pub const DSTOPTS = 60;
1351    /// ISO cnlp
1352    pub const EON = 80;
1353    /// Ethernet-in-IP
1354    pub const ETHERIP = 97;
1355    /// encapsulation header
1356    pub const ENCAP = 98;
1357    /// Protocol indep. multicast
1358    pub const PIM = 103;
1359    /// IP Payload Comp. Protocol
1360    pub const IPCOMP = 108;
1361    /// VRRP RFC 2338
1362    pub const VRRP = 112;
1363    /// Common Address Resolution Protocol
1364    pub const CARP = 112;
1365    /// L2TPv3
1366    pub const L2TP = 115;
1367    /// SCTP
1368    pub const SCTP = 132;
1369    /// PFSYNC
1370    pub const PFSYNC = 240;
1371    /// raw IP packet
1372    pub const RAW = 255;
1373};
1374
1375pub const rlimit_resource = enum(c_int) {
1376    CPU = 0,
1377    FSIZE = 1,
1378    DATA = 2,
1379    STACK = 3,
1380    CORE = 4,
1381    RSS = 5,
1382    MEMLOCK = 6,
1383    NPROC = 7,
1384    NOFILE = 8,
1385    SBSIZE = 9,
1386    VMEM = 10,
1387    NTHR = 11,
1388    _,
1389
1390    pub const AS: rlimit_resource = .VMEM;
1391};
1392
1393pub const rlim_t = u64;
1394
1395pub const RLIM = struct {
1396    /// No limit
1397    pub const INFINITY: rlim_t = (1 << 63) - 1;
1398
1399    pub const SAVED_MAX = INFINITY;
1400    pub const SAVED_CUR = INFINITY;
1401};
1402
1403pub const rlimit = extern struct {
1404    /// Soft limit
1405    cur: rlim_t,
1406    /// Hard limit
1407    max: rlim_t,
1408};
1409
1410pub const SHUT = struct {
1411    pub const RD = 0;
1412    pub const WR = 1;
1413    pub const RDWR = 2;
1414};
1415
1416pub const nfds_t = u32;
1417
1418pub const pollfd = extern struct {
1419    fd: fd_t,
1420    events: i16,
1421    revents: i16,
1422};
1423
1424pub const POLL = struct {
1425    /// Testable events (may be specified in events field).
1426    pub const IN = 0x0001;
1427    pub const PRI = 0x0002;
1428    pub const OUT = 0x0004;
1429    pub const RDNORM = 0x0040;
1430    pub const WRNORM = OUT;
1431    pub const RDBAND = 0x0080;
1432    pub const WRBAND = 0x0100;
1433
1434    /// Non-testable events (may not be specified in events field).
1435    pub const ERR = 0x0008;
1436    pub const HUP = 0x0010;
1437    pub const NVAL = 0x0020;
1438};
1439