hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

types.ha (34301B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 export type off_t = i64;
      5 export type dev_t = u64;
      6 export type ino_t = u64;
      7 export type nlink_t = u64;
      8 export type mode_t = uint;
      9 export type id_t = uint;
     10 export type uid_t = uint;
     11 export type gid_t = uint;
     12 export type time_t = i64;
     13 export type suseconds_t = i64;
     14 export type nfds_t = u64;
     15 export type pid_t = int;
     16 export type timer_t = *opaque;
     17 export type clock_t = i64;
     18 export type si_band_t = i64;
     19 export type rlim_t = u64;
     20 
     21 export def NGROUPS_MAX: size = 32;
     22 export def NSIG: int = 64;
     23 
     24 export type sigset = struct {
     25 	__val: [1]u64,
     26 };
     27 
     28 export type timeval = struct {
     29 	tv_sec:  time_t,
     30 	tv_usec: suseconds_t,
     31 };
     32 
     33 export type timespec = struct {
     34 	tv_sec:  time_t,
     35 	tv_nsec: i64,
     36 };
     37 
     38 export def UTIME_OMIT = 0x3ffffffe;
     39 
     40 export type itimerspec = struct {
     41 	it_interval: timespec,
     42 	it_value: timespec,
     43 };
     44 
     45 export def AT_FDCWD: int		= -100;
     46 export def AT_SYMLINK_NOFOLLOW: int	= 0x100;
     47 export def AT_REMOVEDIR: int		= 0x200;
     48 export def AT_SYMLINK_FOLLOW: int	= 0x400;
     49 export def AT_EACCESS: int		= 0x200;
     50 export def AT_NO_AUTOMOUNT: int		= 0x800;
     51 export def AT_EMPTY_PATH: int		= 0x1000;
     52 export def AT_STATX_SYNC_TYPE: int	= 0x6000;
     53 export def AT_STATX_SYNC_AS_STAT: int	= 0x0000;
     54 export def AT_STATX_FORCE_SYNC: int	= 0x2000;
     55 export def AT_STATX_DONT_SYNC: int	= 0x4000;
     56 export def AT_RECURSIVE: int		= 0x8000;
     57 
     58 export def S_IFDIR: mode_t = 0o040000;
     59 export def S_IFCHR: mode_t = 0o020000;
     60 export def S_IFBLK: mode_t = 0o060000;
     61 export def S_IFREG: mode_t = 0o100000;
     62 export def S_IFIFO: mode_t = 0o010000;
     63 export def S_IFLNK: mode_t = 0o120000;
     64 export def S_IFSOCK: mode_t = 0o140000;
     65 
     66 // O_DIRECTORY is arch specific
     67 export def O_RDONLY: int	= 0o0;
     68 export def O_WRONLY: int	= 0o1;
     69 export def O_RDWR: int		= 0o2;
     70 export def O_ACCMODE: int	= 0o3;
     71 export def O_CREATE: int	= 0o100;
     72 export def O_EXCLUSIVE: int	= 0o200;
     73 export def O_NOCTTY: int	= 0o400;
     74 export def O_TRUNC: int		= 0o1000;
     75 export def O_APPEND: int	= 0o2000;
     76 export def O_NONBLOCK: int	= 0o4000;
     77 export def O_DSYNC: int		= 0o10000;
     78 export def O_SYNC: int		= 0o4010000;
     79 export def O_RSYNC: int		= 0o4010000;
     80 export def O_NOFOLLOW: int	= 0o400000;
     81 export def O_NOATIME: int	= 0o1000000;
     82 export def O_CLOEXEC: int	= 0o2000000;
     83 export def O_PATH: int		= 0o10000000;
     84 export def O_TMPFILE: int	= 0o20000000;
     85 
     86 type statx_timestamp = struct {
     87 	tv_sec:  i64,
     88 	tv_nsec: u32,
     89 };
     90 
     91 type stx = struct {
     92 	mask:       u32,
     93 	blksize:    u32,
     94 	attributes: u64,
     95 	nlink:      u32,
     96 	uid:        u32,
     97 	gid:        u32,
     98 	mode:       u16,
     99 	ino:        u64,
    100 	sz:         u64,
    101 	blocks:     u64,
    102 	attr_mask:  u64,
    103 	atime:      statx_timestamp,
    104 	btime:      statx_timestamp,
    105 	ctime:      statx_timestamp,
    106 	mtime:      statx_timestamp,
    107 	rdev_major: u32,
    108 	rdev_minor: u32,
    109 	dev_major:  u32,
    110 	dev_minor:  u32,
    111 	__reserved: [14]u64,
    112 };
    113 
    114 // Note: the st type does not match the kernel API. The kernel API has a stat
    115 // buffer which varies from arch to arch, but because we always use statx(2) and
    116 // copy the data from the stx type, we don't have to deal with that nonsense.
    117 export type st = struct {
    118 	dev:    dev_t,
    119 	ino:    ino_t,
    120 	mode:   mode_t,
    121 	nlink:  nlink_t,
    122 	uid:    uid_t,
    123 	gid:    gid_t,
    124 	rdev:   dev_t,
    125 	sz:     u64,
    126 	blksz:  u64,
    127 	blocks: u64,
    128 	atime:  timespec,
    129 	mtime:  timespec,
    130 	ctime:  timespec,
    131 };
    132 
    133 def STATX_TYPE: uint		= 0x00000001;
    134 def STATX_MODE: uint		= 0x00000002;
    135 def STATX_NLINK: uint		= 0x00000004;
    136 def STATX_UID: uint		= 0x00000008;
    137 def STATX_GID: uint		= 0x00000010;
    138 def STATX_ATIME: uint		= 0x00000020;
    139 def STATX_MTIME: uint		= 0x00000040;
    140 def STATX_CTIME: uint		= 0x00000080;
    141 def STATX_INO: uint		= 0x00000100;
    142 def STATX_SIZE: uint		= 0x00000200;
    143 def STATX_BLOCKS: uint		= 0x00000400;
    144 def STATX_BASIC_STATS: uint	= 0x000007FF;
    145 def STATX_BTIME: uint		= 0x00000800;
    146 def STATX_MNT_ID: uint		= 0x00001000;
    147 
    148 export def SIGHUP: int		= 1;
    149 export def SIGINT: int		= 2;
    150 export def SIGQUIT: int		= 3;
    151 export def SIGILL: int		= 4;
    152 export def SIGTRAP: int		= 5;
    153 export def SIGABRT: int		= 6;
    154 export def SIGBUS: int		= 7;
    155 export def SIGFPE: int		= 8;
    156 export def SIGKILL: int		= 9;
    157 export def SIGUSR1: int		= 10;
    158 export def SIGSEGV: int		= 11;
    159 export def SIGUSR2: int		= 12;
    160 export def SIGPIPE: int		= 13;
    161 export def SIGALRM: int		= 14;
    162 export def SIGTERM: int		= 15;
    163 export def SIGSTKFLT: int	= 16;
    164 export def SIGCHLD: int		= 17;
    165 export def SIGCONT: int		= 18;
    166 export def SIGSTOP: int		= 19;
    167 export def SIGTSTP: int		= 20;
    168 export def SIGTTIN: int		= 21;
    169 export def SIGTTOU: int		= 22;
    170 export def SIGURG: int		= 23;
    171 export def SIGXCPU: int		= 24;
    172 export def SIGXFSZ: int		= 25;
    173 export def SIGVTALRM: int	= 26;
    174 export def SIGPROF: int		= 27;
    175 export def SIGWINCH: int	= 28;
    176 export def SIGIO: int		= 29;
    177 export def SIGPOLL: int		= 29;
    178 export def SIGPWR: int		= 30;
    179 export def SIGSYS: int		= 31;
    180 
    181 export def MAP_SHARED: uint		= 0x01;
    182 export def MAP_PRIVATE: uint		= 0x02;
    183 export def MAP_SHARED_VALIDATE: uint	= 0x03;
    184 export def MAP_FIXED: uint		= 0x10;
    185 export def MAP_ANON: uint		= 0x20;
    186 export def MAP_NORESERVE: uint		= 0x4000;
    187 export def MAP_GROWSDOWN: uint		= 0x0100;
    188 export def MAP_DENYWRITE: uint		= 0x0800;
    189 export def MAP_EXECUTABLE: uint		= 0x1000;
    190 export def MAP_LOCKED: uint		= 0x2000;
    191 export def MAP_POPULATE: uint		= 0x8000;
    192 export def MAP_NONBLOCK: uint		= 0x10000;
    193 export def MAP_STACK: uint		= 0x20000;
    194 export def MAP_HUGETLB: uint		= 0x40000;
    195 export def MAP_SYNC: uint		= 0x80000;
    196 export def MAP_FIXED_NOREPLACE: uint	= 0x100000;
    197 export def MAP_FILE: uint		= 0;
    198 export def MAP_HUGE_SHIFT: uint		= 26;
    199 export def MAP_HUGE_MASK: uint		= 0x3F;
    200 export def MAP_HUGE_64KB: uint		= 16 << 26;
    201 export def MAP_HUGE_512KB: uint		= 19 << 26;
    202 export def MAP_HUGE_1MB: uint		= 20 << 26;
    203 export def MAP_HUGE_2MB: uint		= 21 << 26;
    204 export def MAP_HUGE_8MB: uint		= 23 << 26;
    205 export def MAP_HUGE_16MB: uint		= 24 << 26;
    206 export def MAP_HUGE_32MB: uint		= 25 << 26;
    207 export def MAP_HUGE_256MB: uint		= 28 << 26;
    208 export def MAP_HUGE_512MB: uint		= 29 << 26;
    209 export def MAP_HUGE_1GB: uint		= 30 << 26;
    210 export def MAP_HUGE_2GB: uint		= 31 << 26;
    211 export def MAP_HUGE_16GB: uint		= 34 << 26;
    212 
    213 export def PROT_NONE: uint	= 0;
    214 export def PROT_READ: uint	= 1;
    215 export def PROT_WRITE: uint	= 2;
    216 export def PROT_EXEC: uint	= 4;
    217 export def PROT_GROWSDOWN: uint	= 0x01000000;
    218 export def PROT_GROWSUP: uint	= 0x02000000;
    219 
    220 export def F_OK: int = 0;
    221 export def R_OK: int = 4;
    222 export def W_OK: int = 2;
    223 export def X_OK: int = 1;
    224 
    225 export def F_DUPFD: int = 0;
    226 export def F_DUPFD_CLOEXEC: int = 1030;
    227 export def F_GETFD: int = 1;
    228 export def F_SETFD: int = 2;
    229 export def F_GETFL: int = 3;
    230 export def F_SETFL: int = 4;
    231 export def F_SETOWN: int = 8;
    232 export def F_GETOWN: int = 9;
    233 export def F_SETSIG: int = 10;
    234 export def F_GETSIG: int = 11;
    235 export def F_GETLK: int = 12;
    236 export def F_SETLK: int = 13;
    237 export def F_SETLKW: int = 14;
    238 export def F_SETOWN_EX: int = 15;
    239 export def F_GETOWN_EX: int = 16;
    240 export def F_GETOWNER_UIDS: int = 17;
    241 
    242 export def F_RDLCK: i16 = 0;
    243 export def F_WRLCK: i16 = 1;
    244 export def F_UNLCK: i16 = 2;
    245 
    246 export def FD_CLOEXEC: int = 1;
    247 
    248 export type st_flock = struct {
    249 	l_type: i16,
    250 	l_whence: i16,
    251 	l_start: i64,
    252 	l_len: i64,
    253 	pid: int,
    254 };
    255 
    256 export type f_owner_ex = struct {
    257 	_type: int,
    258 	pid: int,
    259 };
    260 
    261 export def CLOCK_REALTIME: int			= 0;
    262 export def CLOCK_MONOTONIC: int			= 1;
    263 export def CLOCK_PROCESS_CPUTIME_ID: int	= 2;
    264 export def CLOCK_THREAD_CPUTIME_ID: int		= 3;
    265 export def CLOCK_MONOTONIC_RAW: int		= 4;
    266 export def CLOCK_REALTIME_COARSE: int		= 5;
    267 export def CLOCK_MONOTONIC_COARSE: int		= 6;
    268 export def CLOCK_BOOTTIME: int			= 7;
    269 export def CLOCK_REALTIME_ALARM: int		= 8;
    270 export def CLOCK_BOOTTIME_ALARM: int		= 9;
    271 export def CLOCK_SGI_CYCLE: int			= 10;
    272 export def CLOCK_TAI: int			= 11;
    273 
    274 export type open_how = struct {
    275 	flags: u64,
    276 	mode: u64,
    277 	resolve: u64,
    278 };
    279 
    280 export def RESOLVE_NO_XDEV: u64		= 0x01;
    281 export def RESOLVE_NO_MAGICLINKS: u64	= 0x02;
    282 export def RESOLVE_NO_SYMLINKS: u64	= 0x04;
    283 export def RESOLVE_BENEATH: u64		= 0x08;
    284 export def RESOLVE_IN_ROOT: u64		= 0x10;
    285 
    286 export def DT_UNKNOWN: u8	= 0;
    287 export def DT_FIFO: u8		= 1;
    288 export def DT_CHR: u8		= 2;
    289 export def DT_DIR: u8		= 4;
    290 export def DT_BLK: u8		= 6;
    291 export def DT_REG: u8		= 8;
    292 export def DT_LNK: u8		= 10;
    293 export def DT_SOCK: u8		= 12;
    294 
    295 export type dirent64 = struct {
    296 	d_ino: ino_t,
    297 	d_off: off_t,
    298 	d_reclen: u16,
    299 	d_type: u8,
    300 	d_name: [*]u8,
    301 };
    302 
    303 export def WNOHANG: int		= 1;
    304 export def WUNTRACED: int	= 2;
    305 export def WSTOPPED: int	= 2;
    306 export def WEXITED: int		= 4;
    307 export def WCONTINUED: int	= 8;
    308 export def WNOWAIT: int		= 0x1000000;
    309 
    310 export fn wexitstatus(s: int) int = (s & 0xff00) >> 8;
    311 export fn wtermsig(s: int) int = s & 0x7f;
    312 export fn wstopsig(s: int) int = wexitstatus(s);
    313 export fn wcoredump(s: int) int = s & 0x80;
    314 export fn wifexited(s: int) bool = wtermsig(s) <= 0;
    315 export fn wifstopped(s: int) bool = (((s & 0xFFFF) * 0x10001) >> 8) > 0x7f00;
    316 export fn wifsignaled(s: int) bool = (s & 0xFFFF) - 1 < 0xFF;
    317 export fn wifcontinued(s: int) bool = s == 0xFFFF;
    318 
    319 export type rusage = struct {
    320 	ru_utime: timeval,
    321 	ru_stime: timeval,
    322 	ru_maxrss: u64,
    323 	ru_ixrss: u64,
    324 	ru_idrss: u64,
    325 	ru_isrss: u64,
    326 	ru_minflt: u64,
    327 	ru_majflt: u64,
    328 	ru_nswap: u64,
    329 	ru_inblock: u64,
    330 	ru_oublock: u64,
    331 	ru_msgsnd: u64,
    332 	ru_msgrcv: u64,
    333 	ru_nsignals: u64,
    334 	ru_nvcsw: u64,
    335 	ru_nivcsw: u64,
    336 	__reserved: [16]u64,
    337 };
    338 
    339 export type utsname = struct {
    340 	sysname:    [65]u8,
    341 	nodename:   [65]u8,
    342 	release:    [65]u8,
    343 	version:    [65]u8,
    344 	machine:    [65]u8,
    345 	domainname: [65]u8,
    346 };
    347 
    348 export def POLLIN: i16 = 0x001;
    349 export def POLLPRI: i16 = 0x002;
    350 export def POLLOUT: i16 = 0x004;
    351 export def POLLERR: i16 = 0x008;
    352 export def POLLHUP: i16 = 0x010;
    353 export def POLLVAL: i16 = 0x020;
    354 
    355 export type pollfd = struct {
    356 	fd: int,
    357 	events: i16,
    358 	revents: i16,
    359 };
    360 
    361 export def EPOLL_CLOEXEC: int = O_CLOEXEC;
    362 
    363 // Valid opcodes to issue to sys_epoll_ctl()
    364 export def EPOLL_CTL_ADD: int = 1;
    365 export def EPOLL_CTL_DEL: int = 2;
    366 export def EPOLL_CTL_MOD: int = 3;
    367 
    368 // Epoll event masks
    369 export def EPOLLIN: u32 = 0x00000001;
    370 export def EPOLLPRI: u32 = 0x00000002;
    371 export def EPOLLOUT: u32 = 0x00000004;
    372 export def EPOLLERR: u32 = 0x00000008;
    373 export def EPOLLHUP: u32 = 0x00000010;
    374 export def EPOLLNVAL: u32 = 0x00000020;
    375 export def EPOLLRDNORM: u32 = 0x00000040;
    376 export def EPOLLRDBAND: u32 = 0x00000080;
    377 export def EPOLLWRNORM: u32 = 0x00000100;
    378 export def EPOLLWRBAND: u32 = 0x00000200;
    379 export def EPOLLMSG: u32 = 0x00000400;
    380 export def EPOLLRDHUP: u32 = 0x00002000;
    381 export def EPOLLWAKEUP: u32 = 1 << 29;
    382 export def EPOLLONESHOT: u32 = 1 << 30;
    383 export def EPOLLET: u32 = 1 << 31;
    384 
    385 export type epoll_data = union {
    386 	ptr: *opaque,
    387 	fd: int,
    388 	u32_: u32,
    389 	u64_: u64,
    390 };
    391 
    392 export def EFD_CLOEXEC: int = O_CLOEXEC;
    393 export def EFD_NONBLOCK: int = O_NONBLOCK;
    394 export def EFD_SEMAPHORE: int = 1;
    395 
    396 export def TFD_CLOEXEC: int = O_CLOEXEC;
    397 export def TFD_NONBLOCK: int = O_NONBLOCK;
    398 export def TFD_TIMER_ABSTIME: int = 1;
    399 export def TFD_TIMER_CANCEL_ON_SET: int = 2;
    400 
    401 export def SIG_BLOCK: int = 0;
    402 export def SIG_UNBLOCK: int = 1;
    403 export def SIG_SETMASK: int = 2;
    404 
    405 def SI_MAX_SIZE: size = 128;
    406 
    407 export type sigval = union {
    408 	sival_t: int,
    409 	sival_ptr: *opaque,
    410 };
    411 
    412 export type siginfo = union {
    413 	struct {
    414 		si_signo: int,
    415 		si_errno: int,
    416 		si_code: int,
    417 
    418 		union {
    419 			// kill()
    420 			struct {
    421 				si_pid: pid_t,
    422 				si_uid: u32,
    423 			},
    424 
    425 			// POSIX.1b timers
    426 			struct {
    427 				si_tid: timer_t,
    428 				si_overrun: int,
    429 				_sigval: sigval, // @ signals
    430 				si_sys_private: int,
    431 			},
    432 
    433 			// POSIX.1b signals
    434 			struct {
    435 				_sig_pid: pid_t, // @kill
    436 				_sig_uid: u32, // @ kill
    437 				union {
    438 					si_value: sigval,
    439 					si_int: int,
    440 					si_ptr: *opaque,
    441 				}
    442 			},
    443 
    444 			// SIGCHLD
    445 			struct {
    446 				_chld_pid: pid_t, // @ kill
    447 				_chld_uid: u32, // @ kill
    448 				si_status: int,
    449 				si_utime: clock_t,
    450 				si_stime: clock_t,
    451 			},
    452 
    453 			// SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT
    454 			struct {
    455 				si_addr: *opaque,
    456 
    457 				union {
    458 					// used when si_code=BUS_MCEERR_AR or
    459 					// used when si_code=BUS_MCEERR_AO
    460 					si_addr_lsb: i16,
    461 
    462 					struct {
    463 						_dummy_bnd: [__ADDR_BND_PKEY_PAD]u8,
    464 						si_lower: *opaque,
    465 						si_upper: *opaque,
    466 					},
    467 
    468 					struct {
    469 						_dummy_pkey: [__ADDR_BND_PKEY_PAD]u8,
    470 						si_pkey: u32,
    471 					},
    472 				},
    473 			},
    474 
    475 			// SIGPOLL
    476 			struct {
    477 				si_band: si_band_t,
    478 				si_fd: int,
    479 			},
    480 
    481 			// SIGSYS
    482 			struct {
    483 				si_call_addr: *opaque,
    484 				si_syscall: int,
    485 				si_arch: uint,
    486 			},
    487 		},
    488 	},
    489 	_si_pad: [SI_MAX_SIZE - 3 * size(int)]u8,
    490 };
    491 
    492 export def SA_NOCLDSTOP: u64 = 0x00000001;
    493 export def SA_NOCLDWAIT: u64 = 0x00000002;
    494 export def SA_SIGINFO: u64 = 0x00000004;
    495 export def SA_ONSTACK: u64 = 0x08000000;
    496 export def SA_RESTART: u64 = 0x10000000;
    497 export def SA_NODEFER: u64 = 0x40000000;
    498 export def SA_RESETHAND: u64 = 0x80000000;
    499 export def SA_NOMASK: u64 = SA_NODEFER;
    500 export def SA_ONESHOT: u64 = SA_RESETHAND;
    501 export def SA_RESTORER: u64 = 0x04000000;
    502 
    503 export def SIG_ERR: uintptr = -1;
    504 export def SIG_DFL: uintptr = 0;
    505 export def SIG_IGN: uintptr = 1;
    506 export def SIG_HOLD: uintptr = 2;
    507 
    508 export type sigact = struct {
    509 	union {
    510 		sa_handler: *fn (int) void,
    511 		sa_sigaction: *fn (int, *siginfo, *opaque) void,
    512 	},
    513 	sa_flags: u64,
    514 	sa_restorer: *fn () void,
    515 	sa_mask: sigset,
    516 };
    517 
    518 export type stack_t = struct {
    519 	ss_sp: *opaque,
    520 	ss_flags: int,
    521 	ss_size: size,
    522 };
    523 
    524 export def SFD_NONBLOCK: int = O_NONBLOCK;
    525 export def SFD_CLOEXEC: int = O_CLOEXEC;
    526 
    527 export type signalfd_siginfo = struct {
    528 	ssi_signo: u32,
    529 	ssi_errno: i32,
    530 	ssi_code: i32,
    531 	ssi_pid: u32,
    532 	ssi_uid: u32,
    533 	ssi_fd: i32 ,
    534 	ssi_tid: u32,
    535 	ssi_band: u32,
    536 	ssi_overrun: u32,
    537 	ssi_trapno: u32,
    538 	ssi_status: i32,
    539 	ssi_int: i32,
    540 	ssi_ptr: u64,
    541 	ssi_utime: u64,
    542 	ssi_stime: u64,
    543 	ssi_addr: u64,
    544 	ssi_addr_lsb: u16,
    545 	__pad2: u16,
    546 	ssi_syscall: i32,
    547 	ssi_call_addr: u64,
    548 	ssi_arch: u32,
    549 
    550 	__pad: [28]u8, // pad to 128 bytes
    551 };
    552 
    553 export type iovec = struct {
    554 	iov_base: *opaque,
    555 	iov_len: size
    556 };
    557 
    558 export def PRIO_PROCESS: int = 0;
    559 export def PRIO_PGRP: int = 1;
    560 export def PRIO_USER: int = 2;
    561 
    562 export type winsize = struct {
    563 	ws_row: u16,
    564 	ws_col: u16,
    565 	ws_xpixel: u16,
    566 	ws_ypixel: u16,
    567 };
    568 
    569 export type termios = struct {
    570 	c_iflag: tcflag,
    571 	c_oflag: tcflag,
    572 	c_cflag: tcflag,
    573 	c_lflag: tcflag,
    574 	c_line: cc,
    575 	c_cc: [NCCS]cc,
    576 };
    577 
    578 export def NCCS: size = 19;
    579 
    580 export type cc = enum u8 {
    581 	VINTR    = 0,
    582 	VQUIT    = 1,
    583 	VERASE   = 2,
    584 	VKILL    = 3,
    585 	VEOF     = 4,
    586 	VTIME    = 5,
    587 	VMIN     = 6,
    588 	VSWTC    = 7,
    589 	VSTART   = 8,
    590 	VSTOP    = 9,
    591 	VSUSP    = 10,
    592 	VEOL     = 11,
    593 	VREPRINT = 12,
    594 	VDISCARD = 13,
    595 	VWERASE  = 14,
    596 	VLNEXT   = 15,
    597 	VEOL2    = 16,
    598 };
    599 
    600 export type tcflag = enum uint {
    601 	// c_iflag bit meaning
    602 	IGNBRK  = 0o00001,
    603 	BRKINT  = 0o00002,
    604 	IGNPAR  = 0o00004,
    605 	PARMRK  = 0o00010,
    606 	INPCK   = 0o00020,
    607 	ISTRIP  = 0o00040,
    608 	INLCR   = 0o00100,
    609 	IGNCR   = 0o00200,
    610 	ICRNL   = 0o00400,
    611 	IUCLC   = 0o01000,
    612 	IXON    = 0o02000,
    613 	IXANY   = 0o04000,
    614 	IXOFF   = 0o10000,
    615 	IMAXBEL = 0o20000,
    616 	IUTF8   = 0o40000,
    617 
    618 	// c_oflag bit meaning
    619 	OPOST  = 0o000001,
    620 	OLCUC  = 0o000002,
    621 	ONLCR  = 0o000004,
    622 	OCRNL  = 0o000010,
    623 	ONOCR  = 0o000020,
    624 	ONLRET = 0o000040,
    625 	OFILL  = 0o000100,
    626 	OFDEL  = 0o000200,
    627 	NLDLY  = 0o000400,
    628 	NL0    = 0o000000,
    629 	NL1    = 0o000400,
    630 	CRDLY  = 0o003000,
    631 	CR0    = 0o000000,
    632 	CR1    = 0o001000,
    633 	CR2    = 0o002000,
    634 	CR3    = 0o003000,
    635 	TABDLY = 0o014000,
    636 	TAB0   = 0o000000,
    637 	TAB1   = 0o004000,
    638 	TAB2   = 0o010000,
    639 	TAB3   = 0o014000,
    640 	XTABS  = 0o014000,
    641 	BSDLY  = 0o020000,
    642 	BS0    = 0o000000,
    643 	BS1    = 0o020000,
    644 	VTDLY  = 0o040000,
    645 	VT0    = 0o000000,
    646 	VT1    = 0o040000,
    647 	FFDLY  = 0o100000,
    648 	FF0    = 0o000000,
    649 	FF1    = 0o100000,
    650 
    651 	// c_cflag bit meaning
    652 	CBAUD    = 0o010017,
    653 	B0       = 0o000000,
    654 	B50      = 0o000001,
    655 	B75      = 0o000002,
    656 	B110     = 0o000003,
    657 	B134     = 0o000004,
    658 	B150     = 0o000005,
    659 	B200     = 0o000006,
    660 	B300     = 0o000007,
    661 	B600     = 0o000010,
    662 	B1200    = 0o000011,
    663 	B1800    = 0o000012,
    664 	B2400    = 0o000013,
    665 	B4800    = 0o000014,
    666 	B9600    = 0o000015,
    667 	B19200   = 0o000016,
    668 	B38400   = 0o000017,
    669 	EXTA     = B19200,
    670 	EXTB     = B38400,
    671 	CSIZE    = 0o000060,
    672 	CS5      = 0o000000,
    673 	CS6      = 0o000020,
    674 	CS7      = 0o000040,
    675 	CS8      = 0o000060,
    676 	CSTOPB   = 0o000100,
    677 	CREAD    = 0o000200,
    678 	PARENB   = 0o000400,
    679 	PARODD   = 0o001000,
    680 	HUPCL    = 0o002000,
    681 	CLOCAL   = 0o004000,
    682 	CBAUDEX  = 0o010000,
    683 	BOTHER   = 0o010000,
    684 	B57600   = 0o010001,
    685 	B115200  = 0o010002,
    686 	B230400  = 0o010003,
    687 	B460800  = 0o010004,
    688 	B500000  = 0o010005,
    689 	B576000  = 0o010006,
    690 	B921600  = 0o010007,
    691 	B1000000 = 0o010010,
    692 	B1152000 = 0o010011,
    693 	B1500000 = 0o010012,
    694 	B2000000 = 0o010013,
    695 	B2500000 = 0o010014,
    696 	B3000000 = 0o010015,
    697 	B3500000 = 0o010016,
    698 	B4000000 = 0o010017,
    699 	CIBAUD   = 0o02003600000,
    700 	CMSPAR   = 0o10000000000,
    701 	CRTSCTS  = 0o20000000000,
    702 
    703 	// c_lflag bit meaning
    704 	ISIG    = 0o000001,
    705 	ICANON  = 0o000002,
    706 	XCASE   = 0o000004,
    707 	ECHO    = 0o000010,
    708 	ECHOE   = 0o000020,
    709 	ECHOK   = 0o000040,
    710 	ECHONL  = 0o000100,
    711 	NOFLSH  = 0o000200,
    712 	TOSTOP  = 0o000400,
    713 	ECHOCTL = 0o001000,
    714 	ECHOPRT = 0o002000,
    715 	ECHOKE  = 0o004000,
    716 	FLUSHO  = 0o010000,
    717 	PENDIN  = 0o040000,
    718 	IEXTEN  = 0o100000,
    719 	EXTPROC = 0o200000,
    720 };
    721 
    722 
    723 export def TIOCSPGRP: u64 = 0x5410;
    724 export def TIOCGWINSZ: u64 = 0x5413;
    725 export def TIOCSWINSZ: u64 = 0x5414;
    726 export def TIOCSCTTY: u64 = 0x540e;
    727 export def TIOCNOTTY: u64 = 0x5422;
    728 export def TIOCGPTN: u64 = 0x80045430;
    729 export def TIOCGPTPEER: u64 = 0x5441;
    730 export def TIOCSPTLCK: u64 = 0x40045431;
    731 export def TCGETS: u64 = 0x5401;
    732 export def TCSETS: u64 = 0x5402;
    733 
    734 export def MLOCK_ONFAULT: uint = 0x01;
    735 
    736 export def MCL_CURRENT: uint = 1;
    737 export def MCL_FUTURE: uint = 2;
    738 export def MCL_ONFAULT: uint = 4;
    739 
    740 export def PTRACE_TRACEME: int = 0;
    741 export def PTRACE_PEEKTEXT: int = 1;
    742 export def PTRACE_PEEKDATA: int = 2;
    743 export def PTRACE_PEEKUSER: int = 3;
    744 export def PTRACE_POKETEXT: int = 4;
    745 export def PTRACE_POKEDATA: int = 5;
    746 export def PTRACE_POKEUSER: int = 6;
    747 export def PTRACE_CONT: int = 7;
    748 export def PTRACE_KILL: int = 8;
    749 export def PTRACE_SINGLESTEP: int = 9;
    750 export def PTRACE_GETREGS: int = 12;
    751 export def PTRACE_SETREGS: int = 13;
    752 export def PTRACE_GETFPREGS: int = 14;
    753 export def PTRACE_SETFPREGS: int = 15;
    754 export def PTRACE_ATTACH: int = 16;
    755 export def PTRACE_DETACH: int = 17;
    756 export def PTRACE_GETFPXREGS: int = 18;
    757 export def PTRACE_SETFPXREGS: int = 19;
    758 export def PTRACE_SYSCALL: int = 24;
    759 export def PTRACE_SETOPTIONS: int = 0x4200;
    760 export def PTRACE_GETEVENTMSG: int = 0x4201;
    761 export def PTRACE_GETSIGINFO: int = 0x4202;
    762 export def PTRACE_SETSIGINFO: int = 0x4203;
    763 export def PTRACE_GETREGSET: int = 0x4204;
    764 export def PTRACE_SETREGSET: int = 0x4205;
    765 export def PTRACE_SEIZE: int = 0x4206;
    766 export def PTRACE_INTERRUPT: int = 0x4207;
    767 export def PTRACE_LISTEN: int = 0x4208;
    768 export def PTRACE_PEEKSIGINFO: int = 0x4209;
    769 export def PTRACE_GETSIGMASK: int = 0x420a;
    770 export def PTRACE_SETSIGMASK: int = 0x420b;
    771 export def PTRACE_SECCOMP_GET_FILTER: int = 0x420c;
    772 export def PTRACE_SECCOMP_GET_METADATA: int = 0x420d;
    773 export def PTRACE_GET_SYSCALL_INFO: int = 0x420e;
    774 export def PTRACE_GET_RSEQ_CONFIGURATION: int =	0x420f;
    775 
    776 export def PTRACE_O_TRACESYSGOOD: u64 = 0x00000001;
    777 export def PTRACE_O_TRACEFORK: u64 = 0x00000002;
    778 export def PTRACE_O_TRACEVFORK: u64 = 0x00000004;
    779 export def PTRACE_O_TRACECLONE: u64 = 0x00000008;
    780 export def PTRACE_O_TRACEEXEC: u64 = 0x00000010;
    781 export def PTRACE_O_TRACEVFORKDONE: u64 = 0x00000020;
    782 export def PTRACE_O_TRACEEXIT: u64 = 0x00000040;
    783 export def PTRACE_O_TRACESECCOMP: u64 = 0x00000080;
    784 export def PTRACE_O_EXITKILL: u64 = 0x00100000;
    785 export def PTRACE_O_SUSPEND_SECCOMP: u64 = 0x00200000;
    786 export def PTRACE_O_MASK: u64 = 0x003000ff;
    787 
    788 export def PTRACE_EVENT_FORK: int = 1;
    789 export def PTRACE_EVENT_VFORK: int = 2;
    790 export def PTRACE_EVENT_CLONE: int = 3;
    791 export def PTRACE_EVENT_EXEC: int = 4;
    792 export def PTRACE_EVENT_VFORK_DONE: int = 5;
    793 export def PTRACE_EVENT_EXIT: int = 6;
    794 export def PTRACE_EVENT_SECCOMP: int = 7;
    795 export def PTRACE_EVENT_STOP: int = 128;
    796 
    797 export def PTRACE_SYSCALL_INFO_NONE: u8 = 0;
    798 export def PTRACE_SYSCALL_INFO_ENTRY: u8 = 1;
    799 export def PTRACE_SYSCALL_INFO_EXIT: u8 = 2;
    800 export def PTRACE_SYSCALL_INFO_SECCOMP: u8 = 3;
    801 
    802 export def PTRACE_PEEKSIGINFO_SHARED: u32 = 1;
    803 
    804 export type ptrace_peeksiginfo_args = struct {
    805 	off: u64,
    806 	flags: u32,
    807 	nr: i32,
    808 };
    809 
    810 export type ptrace_syscall_info = struct {
    811 	op: u8,
    812 	arch: u32,
    813 	instruction_pointer: u64,
    814 	stack_pointer: u64,
    815 	union {
    816 		entry: struct {
    817 			nr: u64,
    818 			args: [6]u64,
    819 		},
    820 		exit: struct {
    821 			rval: i64,
    822 			is_error: u8,
    823 		},
    824 		seccomp: struct {
    825 			nr: u64,
    826 			args: [6]u64,
    827 			ret_data: u64,
    828 		},
    829 	},
    830 };
    831 
    832 export def STDIN_FILENO: int = 0;
    833 export def STDOUT_FILENO: int = 1;
    834 export def STDERR_FILENO: int = 2;
    835 
    836 export def MFD_CLOEXEC: uint = 1;
    837 export def MFD_ALLOW_SEALING: uint = 2;
    838 export def MFD_HUGETLB: uint = 4;
    839 
    840 export def SPLICE_F_MOVE: uint = 1;
    841 export def SPLICE_F_NONBLOCK: uint = 2;
    842 export def SPLICE_F_MORE: uint = 4;
    843 export def SPLICE_F_GIFT: uint = 8;
    844 
    845 export def SEEK_SET: int = 0;
    846 export def SEEK_CUR: int = 1;
    847 export def SEEK_END: int = 2;
    848 
    849 // Flock operations
    850 export def LOCK_SH: int = 1;
    851 export def LOCK_EX: int = 2;
    852 export def LOCK_NB: int = 4;
    853 export def LOCK_UN: int = 8;
    854 
    855 // Inotify init1 flags
    856 export def IN_NONBLOCK: int = O_NONBLOCK;
    857 export def IN_CLOEXEC: int = O_CLOEXEC;
    858 
    859 // Inotify event masks
    860 export def INACCESS: u32 = 0x00000001;
    861 export def INMODIFY: u32 = 0x00000002;
    862 export def INATTRIB: u32 = 0x00000004;
    863 export def INCLOSEWRITE: u32 = 0x00000008;
    864 export def INCLOSENOWRITE: u32 = 0x00000010;
    865 export def INOPEN: u32 = 0x00000020;
    866 export def INMOVEDFROM: u32 = 0x00000040;
    867 export def INMOVEDTO: u32 = 0x00000080;
    868 export def INCREATE: u32 = 0x00000100;
    869 export def INDELETE: u32 = 0x00000200;
    870 export def INDELETESELF: u32 = 0x00000400;
    871 export def INMOVESELF: u32 = 0x00000800;
    872 export def INONLYDIR: u32 = 0x01000000;
    873 export def INDONTFOLLOW: u32 = 0x02000000;
    874 export def INEXCLUNLINK: u32 = 0x04000000;
    875 export def INMASKCREATE: u32 = 0x10000000;
    876 export def INMASKADD: u32 = 0x20000000;
    877 export def INISDIR: u32 = 0x40000000;
    878 export def INONESHOT: u32 = 0x80000000;
    879 export def INUNMOUNT: u32 = 0x00002000;
    880 export def INQOVERFLOW: u32 = 0x00004000;
    881 export def INIGNORED: u32 = 0x00008000;
    882 export def INMOVE: u32 = INMOVEDFROM | INMOVEDTO;
    883 export def INCLOSE: u32 = INCLOSEWRITE | INCLOSENOWRITE;
    884 
    885 export type rlimit = struct {
    886 	rlim_cur: rlim_t,
    887 	rlim_max: rlim_t,
    888 };
    889 
    890 export def RLIM_INFINITY: rlim_t = -1;
    891 
    892 export def RLIMIT_CPU: int		= 0;
    893 export def RLIMIT_FSIZE: int		= 1;
    894 export def RLIMIT_DATA: int		= 2;
    895 export def RLIMIT_STACK: int		= 3;
    896 export def RLIMIT_CORE: int		= 4;
    897 export def RLIMIT_RSS: int		= 5;
    898 export def RLIMIT_NPROC: int		= 6;
    899 export def RLIMIT_NOFILE: int		= 7;
    900 export def RLIMIT_MEMLOCK: int		= 8;
    901 export def RLIMIT_AS: int		= 9;
    902 export def RLIMIT_LOCKS: int		= 10;
    903 export def RLIMIT_SIGPENDING: int	= 11;
    904 export def RLIMIT_MSGQUEUE: int		= 12;
    905 export def RLIMIT_NICE: int		= 13;
    906 export def RLIMIT_RTPRIO: int		= 14;
    907 export def RLIMIT_RTTIME: int		= 15;
    908 export def RLIMIT_NLIMITS: int		= 16;
    909 
    910 export def SHUT_RD: int = 0;
    911 export def SHUT_WR: int = 1;
    912 export def SHUT_RDWR: int = 2;
    913 
    914 export type io_uring_sqe = struct {
    915 	opcode: u8,
    916 	flags: u8,
    917 	ioprio: u16,
    918 	fd: i32,
    919 	union {
    920 		off: u64,
    921 		addr2: u64,
    922 		struct {
    923 			cmd_op: u32,
    924 			__pad1: u32,
    925 		},
    926 	},
    927 	union {
    928 		addr: u64,
    929 		splice_off_in: u64,
    930 	},
    931 	length: u32,
    932 	union {
    933 		rw_flags: int,
    934 		fsync_flags: u32,
    935 		poll_events: u32,
    936 		poll32_events: u32,
    937 		sync_range_flags: u32,
    938 		msg_flags: u32,
    939 		timeout_flags: u32,
    940 		accept_flags: u32,
    941 		cancel_flags: u32,
    942 		open_flags: u32,
    943 		statx_flags: u32,
    944 		fadvise_advice: u32,
    945 		splice_flags: u32,
    946 		rename_flags: u32,
    947 		unlink_flags: u32,
    948 		hardlink_flags: u32,
    949 		xattr_flags: u32,
    950 		msg_ring_flags: u32,
    951 		uring_cmd_flags: u32,
    952 	},
    953 	user_data: u64,
    954 	// TODO: use @packed once size() stop returning different sizes
    955 	union {
    956 		buf_index: u16,
    957 		buf_group: u16,
    958 	},
    959 	personality: u16,
    960 	union {
    961 		splice_fd_in: i32,
    962 		file_index: u32,
    963 		struct {
    964 			addr_len: u16,
    965 			__pad3: [1]u16,
    966 		},
    967 	},
    968 	union {
    969 		struct {
    970 			addr3: u64,
    971 			__pad2: [1]u64,
    972 		},
    973 		cmd: [*]u8,
    974 	},
    975 };
    976 
    977 export def IORING_FILE_INDEX_ALLOC: u32 = ~0;
    978 
    979 export def IOSQE_FIXED_FILE: u8 = 1 << 0;
    980 export def IOSQE_IO_DRAIN: u8 = 1 << 1;
    981 export def IOSQE_IO_LINK: u8 = 1 << 2;
    982 export def IOSQE_IO_HARDLINK: u8 = 1 << 3;
    983 export def IOSQE_ASYNC: u8 = 1 << 4;
    984 export def IOSQE_BUFFER_SELECT: u8 = 1 << 5;
    985 export def IOSQE_CQE_SKIP_SUCCESS: u8 = 1 << 6;
    986 
    987 export def IORING_SETUP_IOPOLL: u32 = 1 << 0;
    988 export def IORING_SETUP_SQPOLL: u32 = 1 << 1;
    989 export def IORING_SETUP_SQ_AFF: u32 = 1 << 2;
    990 export def IORING_SETUP_CQSIZE: u32 = 1 << 3;
    991 export def IORING_SETUP_CLAMP: u32 = 1 << 4;
    992 export def IORING_SETUP_ATTACH_WQ: u32 = 1 << 5;
    993 export def IORING_SETUP_R_DISABLED: u32 = 1 << 6;
    994 export def IORING_SETUP_SUBMIT_ALL: u32 = 1 << 7;
    995 export def IORING_SETUP_COOP_TASKRUN: u32 = 1 << 8;
    996 export def IORING_SETUP_TASKRUN_FLAG: u32 = 1 << 9;
    997 export def IORING_SETUP_SQE128: u32 = 1 << 10;
    998 export def IORING_SETUP_CQE32: u32 = 1 << 11;
    999 export def IORING_SETUP_SINGLE_ISSUER: u32 = 1 << 12;
   1000 export def IORING_SETUP_DEFER_TASKRUN: u32 = 1 << 13;
   1001 export def IORING_SETUP_NO_MMAP: u32 = 1 << 14;
   1002 export def IORING_SETUP_REGISTERED_FD_ONLY: u32 = 1 << 15;
   1003 
   1004 export def IORING_OP_NOP: u8 = 0;
   1005 export def IORING_OP_READV: u8 = 1;
   1006 export def IORING_OP_WRITEV: u8 = 2;
   1007 export def IORING_OP_FSYNC: u8 = 3;
   1008 export def IORING_OP_READ_FIXED: u8 = 4;
   1009 export def IORING_OP_WRITE_FIXED: u8 = 5;
   1010 export def IORING_OP_POLL_ADD: u8 = 6;
   1011 export def IORING_OP_POLL_REMOVE: u8 = 7;
   1012 export def IORING_OP_SYNC_FILE_RANGE: u8 = 8;
   1013 export def IORING_OP_SENDMSG: u8 = 9;
   1014 export def IORING_OP_RECVMSG: u8 = 10;
   1015 export def IORING_OP_TIMEOUT: u8 = 11;
   1016 export def IORING_OP_TIMEOUT_REMOVE: u8 = 12;
   1017 export def IORING_OP_ACCEPT: u8 = 13;
   1018 export def IORING_OP_ASYNC_CANCEL: u8 = 14;
   1019 export def IORING_OP_LINK_TIMEOUT: u8 = 15;
   1020 export def IORING_OP_CONNECT: u8 = 16;
   1021 export def IORING_OP_FALLOCATE: u8 = 17;
   1022 export def IORING_OP_OPENAT: u8 = 18;
   1023 export def IORING_OP_CLOSE: u8 = 19;
   1024 export def IORING_OP_FILES_UPDATE: u8 = 20;
   1025 export def IORING_OP_STATX: u8 = 21;
   1026 export def IORING_OP_READ: u8 = 22;
   1027 export def IORING_OP_WRITE: u8 = 23;
   1028 export def IORING_OP_FADVISE: u8 = 24;
   1029 export def IORING_OP_MADVISE: u8 = 25;
   1030 export def IORING_OP_SEND: u8 = 26;
   1031 export def IORING_OP_RECV: u8 = 27;
   1032 export def IORING_OP_OPENAT2: u8 = 28;
   1033 export def IORING_OP_EPOLL_CTL: u8 = 29;
   1034 export def IORING_OP_SPLICE: u8 = 30;
   1035 export def IORING_OP_PROVIDE_BUFFERS: u8 = 31;
   1036 export def IORING_OP_REMOVE_BUFFERS: u8 = 32;
   1037 export def IORING_OP_TEE: u8 = 33;
   1038 export def IORING_OP_SHUTDOWN: u8 = 34;
   1039 export def IORING_OP_RENAMEAT: u8 = 35;
   1040 export def IORING_OP_UNLINKAT: u8 = 36;
   1041 export def IORING_OP_MKDIRAT: u8 = 37;
   1042 export def IORING_OP_SYMLINKAT: u8 = 38;
   1043 export def IORING_OP_LINKAT: u8 = 39;
   1044 export def IORING_OP_MSG_RING: u8 = 40;
   1045 export def IORING_OP_FSETXATTR: u8 = 41;
   1046 export def IORING_OP_SETXATTR: u8 = 42;
   1047 export def IORING_OP_FGETXATTR: u8 = 43;
   1048 export def IORING_OP_GETXATTR: u8 = 44;
   1049 export def IORING_OP_SOCKET: u8 = 45;
   1050 export def IORING_OP_URING_CMD: u8 = 46;
   1051 export def IORING_OP_SEND_ZC: u8 = 47;
   1052 export def IORING_OP_SENDMSG_ZC: u8 = 48;
   1053 
   1054 export def IORING_URING_CMD_FIXED: u32 = 1 << 0;
   1055 export def IORING_URING_CMD_POLLED: u32 = 1 << 31;
   1056 
   1057 export def IORING_FSYNC_DATASYNC: u32 = 1 << 0;
   1058 
   1059 export def IORING_TIMEOUT_ABS: u32 = 1 << 0;
   1060 export def IORING_TIMEOUT_UPDATE: u32 = 1 << 1;
   1061 export def IORING_TIMEOUT_BOOTTIME: u32 = 1 << 2;
   1062 export def IORING_TIMEOUT_REALTIME: u32 = 1 << 3;
   1063 export def IORING_LINK_TIMEOUT_UPDATE: u32 = 1 << 4;
   1064 export def IORING_TIMEOUT_ETIME_SUCCESS: u32 = 1 << 5;
   1065 export def IORING_TIMEOUT_MULTISHOT: u32 = 1 << 6;
   1066 
   1067 export def SPLICE_F_FD_IN_FIXED: u32 = 1 << 31;
   1068 
   1069 export def IORING_POLL_ADD_MULTI: u32 = 1 << 0;
   1070 export def IORING_POLL_UPDATE_EVENTS: u32 = 1 << 1;
   1071 export def IORING_POLL_UPDATE_USER_DATA: u32 = 1 << 2;
   1072 export def IORING_POLL_ADD_LEVEL: u32 = 1 << 3;
   1073 
   1074 export def IORING_ASYNC_CANCEL_ALL: u32 = 1 << 0;
   1075 export def IORING_ASYNC_CANCEL_FD: u32 = 1 << 1;
   1076 export def IORING_ASYNC_CANCEL_ANY: u32 = 1 << 2;
   1077 export def IORING_ASYNC_CANCEL_FD_FIXED: u32 = 1 << 3;
   1078 
   1079 export def IORING_RECVSEND_POLL_FIRST: u16 = 1 << 0;
   1080 export def IORING_RECV_MULTISHOT: u16 = 1 << 1;
   1081 export def IORING_RECVSEND_FIXED_BUF: u16 = 1 << 2;
   1082 export def IORING_SEND_ZC_REPORT_USAGE: u16 = 1 << 3;
   1083 
   1084 // TODO: https://todo.sr.ht/~sircmpwn/hare/771
   1085 // export def IORING_NOTIF_USAGE_ZC_COPIED: i32 = 1 << 31;
   1086 
   1087 export def IORING_ACCEPT_MULTISHOT: u16 = 1 << 0;
   1088 
   1089 export def IORING_MSG_DATA: u64 = 0;
   1090 export def IORING_MSG_SEND_FD: u64 = 1;
   1091 
   1092 export def IORING_MSG_RING_CQE_SKIP: u32 = 1 << 0;
   1093 export def IORING_MSG_RING_FLAGS_PASS: u32 = 1 << 1;
   1094 
   1095 export type _io_uring_cqe = struct {
   1096 	user_data: u64,
   1097 	res: i32,
   1098 	flags: u32,
   1099 };
   1100 
   1101 export type io_uring_cqe = struct {
   1102 	_io_uring_cqe,
   1103 	big_cqe: [*]u64,
   1104 };
   1105 
   1106 export def IORING_CQE_F_BUFFER: u32 = 1 << 0;
   1107 export def IORING_CQE_F_MORE: u32 = 1 << 1;
   1108 export def IORING_CQE_F_SOCK_NONEMPTY: u32 = 1 << 2;
   1109 export def IORING_CQE_F_NOTIF: u32 = 1 << 3;
   1110 
   1111 export def IORING_CQE_BUFFER_SHIFT: u32 = 16;
   1112 
   1113 export def IORING_OFF_SQ_RING: u64 = 0;
   1114 export def IORING_OFF_CQ_RING: u64 = 0x8000000;
   1115 export def IORING_OFF_SQES: u64 = 0x10000000;
   1116 export def IORING_OFF_PBUF_RING: u64 = 0x80000000;
   1117 export def IORING_OFF_PBUF_SHIFT: u64 = 16;
   1118 export def IORING_OFF_MMAP_MASK: u64 = 0xf8000000;
   1119 
   1120 export type io_sqring_offsets = struct {
   1121 	head: u32,
   1122 	tail: u32,
   1123 	ring_mask: u32,
   1124 	ring_entries: u32,
   1125 	flags: u32,
   1126 	dropped: u32,
   1127 	array: u32,
   1128 	resv1: u32,
   1129 	user_addr: u64,
   1130 };
   1131 
   1132 export def IORING_SQ_NEED_WAKEUP: u32 = 1 << 0;
   1133 export def IORING_SQ_CQ_OVERFLOW: u32 = 1 << 1;
   1134 export def IORING_SQ_TASKRUN: u32 = 1 << 2;
   1135 
   1136 export type io_cqring_offsets = struct {
   1137 	head: u32,
   1138 	tail: u32,
   1139 	ring_mask: u32,
   1140 	ring_entries: u32,
   1141 	overflow: u32,
   1142 	cqes: u32,
   1143 	flags: u32,
   1144 	resv1: u32,
   1145 	user_addr: u64,
   1146 };
   1147 
   1148 export def IORING_CQ_EVENTFD_DISABLED: u32 = 1 << 0;
   1149 
   1150 export def IORING_ENTER_GETEVENTS: u32 = 1 << 0;
   1151 export def IORING_ENTER_SQ_WAKEUP: u32 = 1 << 1;
   1152 export def IORING_ENTER_SQ_WAIT: u32 = 1 << 2;
   1153 export def IORING_ENTER_EXT_ARG: u32 = 1 << 3;
   1154 export def IORING_ENTER_REGISTERED_RING: u32 = 1 << 4;
   1155 
   1156 export type io_uring_params = struct {
   1157 	sq_entries: u32,
   1158 	cq_entries: u32,
   1159 	flags: u32,
   1160 	sq_thread_cpu: u32,
   1161 	sq_thread_idle: u32,
   1162 	features: u32,
   1163 	wq_fd: u32,
   1164 	resv: [3]u32,
   1165 	sq_off: io_sqring_offsets,
   1166 	cq_off: io_cqring_offsets,
   1167 };
   1168 
   1169 export def IORING_FEAT_SINGLE_MMAP: u32 = 1 << 0;
   1170 export def IORING_FEAT_NODROP: u32 = 1 << 1;
   1171 export def IORING_FEAT_SUBMIT_STABLE: u32 = 1 << 2;
   1172 export def IORING_FEAT_RW_CUR_POS: u32 = 1 << 3;
   1173 export def IORING_FEAT_CUR_PERSONALITY: u32 = 1 << 4;
   1174 export def IORING_FEAT_FAST_POLL: u32 = 1 << 5;
   1175 export def IORING_FEAT_POLL_32BITS: u32 = 1 << 6;
   1176 export def IORING_FEAT_SQPOLL_NONFIXED: u32 = 1 << 7;
   1177 export def IORING_FEAT_EXT_ARG: u32 = 1 << 8;
   1178 export def IORING_FEAT_NATIVE_WORKERS: u32 = 1 << 9;
   1179 export def IORING_FEAT_RSRC_TAGS: u32 = 1 << 10;
   1180 export def IORING_FEAT_CQE_SKIP: u32 = 1 << 11;
   1181 export def IORING_FEAT_LINKED_FILE: u32 = 1 << 12;
   1182 export def IORING_FEAT_REG_REG_RING: u32 = 1 << 13;
   1183 
   1184 export def IORING_REGISTER_BUFFERS: uint = 0;
   1185 export def IORING_UNREGISTER_BUFFERS: uint = 1;
   1186 export def IORING_REGISTER_FILES: uint = 2;
   1187 export def IORING_UNREGISTER_FILES: uint = 3;
   1188 export def IORING_REGISTER_EVENTFD: uint = 4;
   1189 export def IORING_UNREGISTER_EVENTFD: uint = 5;
   1190 export def IORING_REGISTER_FILES_UPDATE: uint = 6;
   1191 export def IORING_REGISTER_EVENTFD_ASYNC: uint = 7;
   1192 export def IORING_REGISTER_PROBE: uint = 8;
   1193 export def IORING_REGISTER_PERSONALITY: uint = 9;
   1194 export def IORING_UNREGISTER_PERSONALITY: uint = 10;
   1195 export def IORING_REGISTER_RESTRICTIONS: uint = 11;
   1196 export def IORING_REGISTER_ENABLE_RINGS: uint = 12;
   1197 export def IORING_REGISTER_FILES2: uint = 13;
   1198 export def IORING_REGISTER_FILES_UPDATE2: uint = 14;
   1199 export def IORING_REGISTER_BUFFERS2: uint = 15;
   1200 export def IORING_REGISTER_BUFFERS_UPDATE: uint = 16;
   1201 export def IORING_REGISTER_IOWQ_AFF: uint = 17;
   1202 export def IORING_UNREGISTER_IOWQ_AFF: uint = 18;
   1203 export def IORING_REGISTER_IOWQ_MAX_WORKERS: uint = 19;
   1204 export def IORING_REGISTER_RING_FDS: uint = 20;
   1205 export def IORING_UNREGISTER_RING_FDS: uint = 21;
   1206 export def IORING_REGISTER_PBUF_RING: uint = 22;
   1207 export def IORING_UNREGISTER_PBUF_RING: uint = 23;
   1208 export def IORING_REGISTER_SYNC_CANCEL: uint = 24;
   1209 export def IORING_REGISTER_FILE_ALLOC_RANGE: uint = 25;
   1210 
   1211 export def IORING_REGISTER_USE_REGISTERED_RING: uint = 1 << 31;
   1212 
   1213 export type io_uring_files_update = struct {
   1214 	off: u32,
   1215 	resv: u32,
   1216 	fds: u64,
   1217 };
   1218 
   1219 export def IORING_RSRC_REGISTER_SPARSE: u32 = 1 << 0;
   1220 
   1221 export type io_uring_rsrc_register = struct {
   1222 	nr: u32,
   1223 	flags: u32,
   1224 	resv2: u64,
   1225 	data: u64,
   1226 	tags: u64,
   1227 };
   1228 
   1229 export type io_uring_rsrc_update = struct {
   1230 	off: u32,
   1231 	resv: u32,
   1232 	data: u64,
   1233 };
   1234 
   1235 export type io_uring_rsrc_update2 = struct {
   1236 	off: u32,
   1237 	resv: u32,
   1238 	data: u64,
   1239 	tags: u64,
   1240 	nr: u32,
   1241 	resv2: u32,
   1242 };
   1243 
   1244 export def IORING_REGISTER_FILES_SKIP: int = -2;
   1245 
   1246 export def IO_URING_OP_SUPPORTED: u16 = 1 << 0;
   1247 
   1248 export type io_uring_probe_op = struct {
   1249 	op: u8,
   1250 	resv: u8,
   1251 	flags: u16,
   1252 	resv2: u32,
   1253 };
   1254 
   1255 export type io_uring_probe = struct {
   1256 	last_op: u8,
   1257 	ops_len: u8,
   1258 	resv: u16,
   1259 	resv2: [3]u32,
   1260 	ops: [*]io_uring_probe_op,
   1261 };
   1262 
   1263 export type io_uring_restriction = struct {
   1264 	opcode: u16,
   1265 	union {
   1266 		register_op: u8,
   1267 		sqe_op: u8,
   1268 		sqe_flags: u8,
   1269 	},
   1270 	resv: u8,
   1271 	resv2: [3]u32,
   1272 };
   1273 
   1274 export type io_uring_buf = struct {
   1275 	addr: u64,
   1276 	length: u32,
   1277 	bid: u16,
   1278 	resv: u16,
   1279 };
   1280 
   1281 export type io_uring_buf_ring = struct {
   1282 	union {
   1283 		struct {
   1284 			resv1: u64,
   1285 			resv2: u32,
   1286 			resv3: u16,
   1287 			tail: u16,
   1288 		},
   1289 		bufs: [*]io_uring_buf,
   1290 	},
   1291 };
   1292 
   1293 export def IOU_PBUF_RING_MMAP: u16 = 1;
   1294 
   1295 export type io_uring_buf_reg = struct {
   1296 	ring_addr: u64,
   1297 	ring_entries: u32,
   1298 	bgid: u16,
   1299 	flags: u16,
   1300 	resv: [3]u64,
   1301 };
   1302 
   1303 export def IORING_RESTRICTION_REGISTER_OP: u16 = 0;
   1304 export def IORING_RESTRICTION_SQE_OP: u16 = 1;
   1305 export def IORING_RESTRICTION_SQE_FLAGS_ALLOWED: u16 = 2;
   1306 export def IORING_RESTRICTION_SQE_FLAGS_REQUIRED: u16 = 3;
   1307 
   1308 export type io_uring_getevents_arg = struct {
   1309 	sigmask: u64,
   1310 	sigmask_sz: u32,
   1311 	pad: u32,
   1312 	ts: u64,
   1313 };
   1314 
   1315 export type io_uring_sync_cancel_reg = struct {
   1316 	addr: u64,
   1317 	fd: i32,
   1318 	flags: u32,
   1319 	timeout: timespec,
   1320 	pad: [4]u64,
   1321 };
   1322 
   1323 export type io_uring_file_index_range = struct {
   1324 	off: u32,
   1325 	length: u32,
   1326 	resv: u64,
   1327 };
   1328 
   1329 export type io_uring_recvmsg_out = struct {
   1330 	namelen: u32,
   1331 	controllen: u32,
   1332 	payloadlen: u32,
   1333 	flags: u32,
   1334 };