Skip to content
Standard libraryZig 0.17.1Official documentation
Sourcestd/os/linux.zig

Source line 1

This file provides the system interface functions for Linux matching those that are provided by libc, whether or not libc is linked. The following abstractions are made:

  • Implement all the syscalls in the same way that libc functions will provide rename when only the renameat syscall exists.

std.os.linux.accept

function

Source line 2919

pub fn accept(fd: fd_t, noalias addr: ?*sockaddr, noalias len: ?*socklen_t) usize

Parameters

fd: fd_t
addr: ?*sockaddr
len: ?*socklen_t

std.os.linux.accept4

function

Source line 2926

pub fn accept4(fd: fd_t, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flags: u32) usize

Parameters

fd: fd_t
addr: ?*sockaddr
len: ?*socklen_t
flags: u32

std.os.linux.access

function

Source line 1876

pub fn access(path: [*:0]const u8, mode: mode_t) usize

Parameters

path: [*:0]const u8
mode: mode_t

std.os.linux.ACCMODE

alias

Source line 25

Alias of std.posix.ACCMODE

std.os.linux.acct

function

Source line 1891

pub fn acct(path: [*:0]const u8) usize

Parameters

path: [*:0]const u8

std.os.linux.addrinfo

container

Source line 8327

Fields

flags: AI
family: i32
socktype: i32
protocol: i32
addrlen: socklen_t
addr: ?*sockaddr
canonname: ?[*:0]u8
next: ?*addrinfo

std.os.linux.AF

namespace

Source line 5170

std.os.linux.AF.ALG

alias

Source line 5212

Alias of std.os.linux.PF.ALG

std.os.linux.AF.APPLETALK

alias

Source line 5178

Alias of std.os.linux.PF.APPLETALK

std.os.linux.AF.ASH

alias

Source line 5192

Alias of std.os.linux.PF.ASH

std.os.linux.AF.ATMPVC

alias

Source line 5181

Alias of std.os.linux.PF.ATMPVC

std.os.linux.AF.ATMSVC

alias

Source line 5194

Alias of std.os.linux.PF.ATMSVC

std.os.linux.AF.AX25

alias

Source line 5176

Alias of std.os.linux.PF.AX25

std.os.linux.AF.BLUETOOTH

alias

Source line 5205

Alias of std.os.linux.PF.BLUETOOTH

std.os.linux.AF.BRIDGE

alias

Source line 5180

Alias of std.os.linux.PF.BRIDGE

std.os.linux.AF.CAIF

alias

Source line 5211

Alias of std.os.linux.PF.CAIF

std.os.linux.AF.CAN

alias

Source line 5203

Alias of std.os.linux.PF.CAN

std.os.linux.AF.DECnet

alias

Source line 5185

Alias of std.os.linux.PF.DECnet

std.os.linux.AF.ECONET

alias

Source line 5193

Alias of std.os.linux.PF.ECONET

std.os.linux.AF.FILE

alias

Source line 5174

Alias of std.os.linux.AF.LOCAL

std.os.linux.AF.IB

alias

Source line 5201

Alias of std.os.linux.PF.IB

std.os.linux.AF.IEEE802154

alias

Source line 5210

Alias of std.os.linux.PF.IEEE802154

std.os.linux.AF.INET

alias

Source line 5175

Alias of std.os.linux.PF.INET

std.os.linux.AF.INET6

alias

Source line 5183

Alias of std.os.linux.PF.INET6

std.os.linux.AF.IPX

alias

Source line 5177

Alias of std.os.linux.PF.IPX

std.os.linux.AF.IRDA

alias

Source line 5197

Alias of std.os.linux.PF.IRDA

std.os.linux.AF.ISDN

alias

Source line 5208

Alias of std.os.linux.PF.ISDN

std.os.linux.AF.IUCV

alias

Source line 5206

Alias of std.os.linux.PF.IUCV

std.os.linux.AF.KCM

alias

Source line 5215

Alias of std.os.linux.PF.KCM

std.os.linux.AF.KEY

alias

Source line 5188

Alias of std.os.linux.PF.KEY

std.os.linux.AF.LLC

alias

Source line 5200

Alias of std.os.linux.PF.LLC

std.os.linux.AF.LOCAL

alias

Source line 5172

Alias of std.os.linux.PF.LOCAL

std.os.linux.AF.MAX

alias

Source line 5219

Alias of std.os.linux.PF.MAX

std.os.linux.AF.MPLS

alias

Source line 5202

Alias of std.os.linux.PF.MPLS

std.os.linux.AF.NETBEUI

alias

Source line 5186

Alias of std.os.linux.PF.NETBEUI

std.os.linux.AF.NETLINK

alias

Source line 5189

Alias of std.os.linux.PF.NETLINK

std.os.linux.AF.NETROM

alias

Source line 5179

Alias of std.os.linux.PF.NETROM

std.os.linux.AF.NFC

alias

Source line 5213

Alias of std.os.linux.PF.NFC

std.os.linux.AF.PACKET

alias

Source line 5191

Alias of std.os.linux.PF.PACKET

std.os.linux.AF.PHONET

alias

Source line 5209

Alias of std.os.linux.PF.PHONET

std.os.linux.AF.PPPOX

alias

Source line 5198

Alias of std.os.linux.PF.PPPOX

std.os.linux.AF.QIPCRTR

alias

Source line 5216

Alias of std.os.linux.PF.QIPCRTR

std.os.linux.AF.RDS

alias

Source line 5195

Alias of std.os.linux.PF.RDS

std.os.linux.AF.ROSE

alias

Source line 5184

Alias of std.os.linux.PF.ROSE

std.os.linux.AF.ROUTE

alias

Source line 5190

Alias of std.os.linux.PF.ROUTE

std.os.linux.AF.RXRPC

alias

Source line 5207

Alias of std.os.linux.PF.RXRPC

std.os.linux.AF.SECURITY

alias

Source line 5187

Alias of std.os.linux.PF.SECURITY

std.os.linux.AF.SMC

alias

Source line 5217

Alias of std.os.linux.PF.SMC

std.os.linux.AF.SNA

alias

Source line 5196

Alias of std.os.linux.PF.SNA

std.os.linux.AF.TIPC

alias

Source line 5204

Alias of std.os.linux.PF.TIPC

std.os.linux.AF.UNIX

alias

Source line 5173

Alias of std.os.linux.AF.LOCAL

std.os.linux.AF.UNSPEC

alias

Source line 5171

Alias of std.os.linux.PF.UNSPEC

std.os.linux.AF.VSOCK

alias

Source line 5214

Alias of std.os.linux.PF.VSOCK

std.os.linux.AF.WANPIPE

alias

Source line 5199

Alias of std.os.linux.PF.WANPIPE

std.os.linux.AF.X25

alias

Source line 5182

Alias of std.os.linux.PF.X25

std.os.linux.AF.XDP

alias

Source line 5218

Alias of std.os.linux.PF.XDP

std.os.linux.AI

container

Source line 8338

Fields

PASSIVE: bool = false
CANONNAME: bool = false
NUMERICHOST: bool = false
V4MAPPED: bool = false
ALL: bool = false
ADDRCONFIG: bool = false
_6: u4 = 0
NUMERICSERV: bool = false
_: u21 = 0

std.os.linux.ARCH

constant

Source line 106

std.os.linux.arch_bits

type

Source line 33

std.os.linux.assert

alias

Source line 8

Alias of std.debug.assert

std.os.linux.AT

namespace

Source line 4479

std.os.linux.AT.EMPTY_PATH

constant

Source line 4496

Allow empty relative pathname

std.os.linux.AT.FDCWD

constant

Source line 4481

Special value used to indicate openat should use the current working directory

std.os.linux.AT.HANDLE_FID

alias

Source line 4513

Alias of std.os.linux.AT.REMOVEDIR

std.os.linux.AT.NO_AUTOMOUNT

constant

Source line 4493

Suppress terminal automount traversal

std.os.linux.AT.RECURSIVE

constant

Source line 4511

Apply to the entire subtree

std.os.linux.AT.REMOVEDIR

constant

Source line 4487

Remove directory instead of unlinking file

std.os.linux.AT.STATX_DONT_SYNC

constant

Source line 4508

  • Don't sync attributes with the server

std.os.linux.AT.STATX_FORCE_SYNC

constant

Source line 4505

  • Force the attributes to be sync'd with the server

std.os.linux.AT.STATX_SYNC_AS_STAT

constant

Source line 4502

  • Do whatever stat() does

std.os.linux.AT.STATX_SYNC_TYPE

constant

Source line 4499

Type of synchronisation required from statx()

std.os.linux.AT.SYMLINK_FOLLOW

constant

Source line 4490

Follow symbolic links.

std.os.linux.AT.SYMLINK_NOFOLLOW

constant

Source line 4484

Do not follow symbolic links

std.os.linux.AUDIT

namespace

Source line 11009

std.os.linux.AUDIT.ARCH

container

Source line 11010

Fields

AARCH64 = toAudit(.AARCH64, @"64BIT" | LE)
ALPHA = toAudit(.ALPHA, @"64BIT" | LE)
ARCOMPACT = toAudit(.ARC_COMPACT, LE)
ARCOMPACTBE = toAudit(.ARC_COMPACT, 0)
ARCV2 = toAudit(.ARC_COMPACT2, LE)
ARCV2BE = toAudit(.ARC_COMPACT2, 0)
ARM = toAudit(.ARM, LE)
ARMEB = toAudit(.ARM, 0)
C6X = toAudit(.TI_C6000, LE)
C6XBE = toAudit(.TI_C6000, 0)
CRIS = toAudit(.CRIS, LE)
CSKY = toAudit(.CSKY, LE)
FRV = toAudit(.FRV, 0)
H8300 = toAudit(.H8_300, 0)
HEXAGON = toAudit(.HEXAGON, 0)
I386 = toAudit(.@"386", LE)
IA64 = toAudit(.IA_64, @"64BIT" | LE)
M32R = toAudit(.M32R, 0)
M68K = toAudit(.@"68K", 0)
MICROBLAZE = toAudit(.MICROBLAZE, 0)
MIPS = toAudit(.MIPS, 0)
MIPSEL = toAudit(.MIPS, LE)
MIPS64 = toAudit(.MIPS, @"64BIT")
MIPS64N32 = toAudit(.MIPS, @"64BIT" | CONVENTION_MIPS64_N32)
MIPSEL64 = toAudit(.MIPS, @"64BIT" | LE)
MIPSEL64N32 = toAudit(.MIPS, @"64BIT" | LE | CONVENTION_MIPS64_N32)
NDS32 = toAudit(.NDS32, LE)
NDS32BE = toAudit(.NDS32, 0)
NIOS2 = toAudit(.ALTERA_NIOS2, LE)
OPENRISC = toAudit(.OPENRISC, 0)
PARISC = toAudit(.PARISC, 0)
PARISC64 = toAudit(.PARISC, @"64BIT")
PPC = toAudit(.PPC, 0)
PPC64 = toAudit(.PPC64, @"64BIT")
PPC64LE = toAudit(.PPC64, @"64BIT" | LE)
RISCV32 = toAudit(.RISCV, LE)
RISCV64 = toAudit(.RISCV, @"64BIT" | LE)
S390 = toAudit(.S390, 0)
S390X = toAudit(.S390, @"64BIT")
SH = toAudit(.SH, 0)
SHEL = toAudit(.SH, LE)
SH64 = toAudit(.SH, @"64BIT")
SHEL64 = toAudit(.SH, @"64BIT" | LE)
SPARC = toAudit(.SPARC, 0)
SPARC64 = toAudit(.SPARCV9, @"64BIT")
TILEGX = toAudit(.TILEGX, @"64BIT" | LE)
TILEGX32 = toAudit(.TILEGX, LE)
TILEPRO = toAudit(.TILEPRO, LE)
UNICORE = toAudit(.UNICORE, LE)
X86_64 = toAudit(.X86_64, @"64BIT" | LE)
XTENSA = toAudit(.XTENSA, 0)
LOONGARCH32 = toAudit(.LOONGARCH, LE)
LOONGARCH64 = toAudit(.LOONGARCH, @"64BIT" | LE)

std.os.linux.AUDIT.ARCH.@"64BIT"

constant

Source line 11012

std.os.linux.AUDIT.ARCH.CONVENTION_MIPS64_N32

constant

Source line 11011

std.os.linux.AUDIT.ARCH.current

constant

Source line 11073

AUDIT.ARCH

std.os.linux.AUDIT.ARCH.LE

constant

Source line 11013

std.os.linux.AUDIT.ARCH.toAudit

function

Source line 11069

fn toAudit(em: elf.EM, flags: u32) u32

Parameters

em: elf.EM
flags: u32

std.os.linux.bind

function

Source line 2881

pub fn bind(fd: fd_t, addr: *const sockaddr, len: socklen_t) usize

Parameters

fd: fd_t
addr: *const sockaddr
len: socklen_t

std.os.linux.blkcnt_t

type

Source line 111

std.os.linux.blksize_t

type

Source line 112

std.os.linux.bpf

function

Source line 3253

pub fn bpf(cmd: BPF.Cmd, attr: *BPF.Attr, size: u32) usize

Parameters

cmd: BPF.Cmd
attr: *BPF.Attr
size: u32

std.os.linux.BPF

alias

Source line 127

Alias of std.os.linux.bpf

std.os.linux.brk

function

Source line 1047

pub fn brk(addr: usize) usize

Parameters

addr: usize

std.os.linux.BSDLY

container

Source line 8692

Fields

BS0 = 0
BS1 = 1

std.os.linux.builtin

constant

Source line 7

std.os.linux.cache_stat

container

Source line 11196

Fields

cache: u64

Number of cached pages.

dirty: u64

Number of dirty pages.

writeback: u64

Number of pages marked for writeback.

evicted: u64

Number of pages evicted from the cache.

recently_evicted: u64

Number of recently evicted pages. A page is recently evicted if its last eviction was recent enough that its reentry to the cache would indicate that it is actively being used by the system, and that there is memory pressure on the system.

std.os.linux.cache_stat_range

container

Source line 11191

Fields

off: u64
len: u64

std.os.linux.cachestat

function

Source line 3446

Query the page cache statistics of a file.

pub fn cachestat( fd: fd_t, cstat_range: *const cache_stat_range, cstat: *cache_stat, flags: u32, ) usize

Parameters

fd: fd_t

The open file descriptor to retrieve statistics from.

cstat_range: *const cache_stat_range

The byte range in fd to query. When len > 0, the range is [off..off + len]. When len == 0, the range is from off to the end of fd.

cstat: *cache_stat

The structure where page cache statistics are stored.

flags: u32

Currently unused, and must be set to 0.

std.os.linux.CAP

namespace

Source line 7205

std.os.linux.cap_t

container

Source line 7262

Fields

std.os.linux.cap_user_data_t

container

Source line 7272

Fields

effective: u32
permitted: u32
inheritable: u32

std.os.linux.cap_user_header_t

container

Source line 7267

Fields

version: u32
pid: usize

std.os.linux.CAP.AUDIT_CONTROL

constant

Source line 7236

std.os.linux.CAP.AUDIT_READ

constant

Source line 7243

std.os.linux.CAP.AUDIT_WRITE

constant

Source line 7235

std.os.linux.CAP.BLOCK_SUSPEND

constant

Source line 7242

std.os.linux.CAP.BPF

constant

Source line 7245

std.os.linux.CAP.CHECKPOINT_RESTORE

constant

Source line 7246

std.os.linux.CAP.CHOWN

constant

Source line 7206

std.os.linux.CAP.DAC_OVERRIDE

constant

Source line 7207

std.os.linux.CAP.DAC_READ_SEARCH

constant

Source line 7208

std.os.linux.CAP.FOWNER

constant

Source line 7209

std.os.linux.CAP.FSETID

constant

Source line 7210

std.os.linux.CAP.IPC_LOCK

constant

Source line 7220

std.os.linux.CAP.IPC_OWNER

constant

Source line 7221

std.os.linux.CAP.KILL

constant

Source line 7211

std.os.linux.CAP.LAST_CAP

alias

Source line 7247

Alias of std.os.linux.CAP.CHECKPOINT_RESTORE

std.os.linux.CAP.LEASE

constant

Source line 7234

std.os.linux.CAP.LINUX_IMMUTABLE

constant

Source line 7215

std.os.linux.CAP.MAC_ADMIN

constant

Source line 7239

std.os.linux.CAP.MAC_OVERRIDE

constant

Source line 7238

std.os.linux.CAP.MKNOD

constant

Source line 7233

std.os.linux.CAP.NET_ADMIN

constant

Source line 7218

std.os.linux.CAP.NET_BIND_SERVICE

constant

Source line 7216

std.os.linux.CAP.NET_BROADCAST

constant

Source line 7217

std.os.linux.CAP.NET_RAW

constant

Source line 7219

std.os.linux.CAP.PERFMON

constant

Source line 7244

std.os.linux.CAP.SETFCAP

constant

Source line 7237

std.os.linux.CAP.SETGID

constant

Source line 7212

std.os.linux.CAP.SETPCAP

constant

Source line 7214

std.os.linux.CAP.SETUID

constant

Source line 7213

std.os.linux.CAP.SYS_ADMIN

constant

Source line 7227

std.os.linux.CAP.SYS_BOOT

constant

Source line 7228

std.os.linux.CAP.SYS_CHROOT

constant

Source line 7224

std.os.linux.CAP.SYS_MODULE

constant

Source line 7222

std.os.linux.CAP.SYS_NICE

constant

Source line 7229

std.os.linux.CAP.SYS_PACCT

constant

Source line 7226

std.os.linux.CAP.SYS_PTRACE

constant

Source line 7225

std.os.linux.CAP.SYS_RAWIO

constant

Source line 7223

std.os.linux.CAP.SYS_RESOURCE

constant

Source line 7230

std.os.linux.CAP.SYS_TIME

constant

Source line 7231

std.os.linux.CAP.SYS_TTY_CONFIG

constant

Source line 7232

std.os.linux.CAP.SYSLOG

constant

Source line 7240

std.os.linux.CAP.TO_INDEX

function

Source line 7257

pub fn TO_INDEX(cap: u8) u8

Parameters

cap: u8

std.os.linux.CAP.TO_MASK

function

Source line 7253

pub fn TO_MASK(cap: u8) u32

Parameters

cap: u8

std.os.linux.CAP.valid

function

Source line 7249

pub fn valid(x: u8) bool

Parameters

x: u8

std.os.linux.CAP.WAKE_ALARM

constant

Source line 7241

std.os.linux.capget

function

Source line 3177

pub fn capget(hdrp: *cap_user_header_t, datap: *cap_user_data_t) usize

Parameters

std.os.linux.capset

function

Source line 3181

pub fn capset(hdrp: *cap_user_header_t, datap: *const cap_user_data_t) usize

Parameters

hdrp: *cap_user_header_t
datap: *const cap_user_data_t

std.os.linux.cc_t

type

Source line 8875

std.os.linux.chdir

function

Source line 1075

pub fn chdir(path: [*:0]const u8) usize

Parameters

path: [*:0]const u8

std.os.linux.chmod

function

Source line 2051

pub fn chmod(path: [*:0]const u8, mode: mode_t) usize

Parameters

path: [*:0]const u8
mode: mode_t

std.os.linux.chown

function

Source line 2071

pub fn chown(path: [*:0]const u8, owner: uid_t, group: gid_t) usize

Parameters

path: [*:0]const u8
owner: uid_t
group: gid_t

std.os.linux.chroot

function

Source line 1083

pub fn chroot(path: [*:0]const u8) usize

Parameters

path: [*:0]const u8

std.os.linux.CLD

container

Source line 7474

Fields

EXITED = 1
KILLED = 2
DUMPED = 3
TRAPPED = 4
STOPPED = 5
CONTINUED = 6
_

std.os.linux.CLOCK

alias

Source line 6552

Alias of std.os.linux.clockid_t

std.os.linux.clock_getres

function

Source line 2461

pub fn clock_getres(clk_id: clockid_t, tp: *timespec) usize

Parameters

clk_id: clockid_t
tp: *timespec

std.os.linux.clock_gettime

function

Source line 2433

pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize

Parameters

clk_id: clockid_t
tp: *timespec

std.os.linux.clock_nanosleep

function

Source line 2477

pub fn clock_nanosleep(clockid: clockid_t, flags: TIMER, request: *const timespec, remain: ?*timespec) usize

Parameters

clockid: clockid_t
flags: TIMER
request: *const timespec
remain: ?*timespec

std.os.linux.clock_settime

function

Source line 2469

pub fn clock_settime(clk_id: clockid_t, tp: *const timespec) usize

Parameters

clk_id: clockid_t
tp: *const timespec

std.os.linux.clock_t

type

Source line 123

std.os.linux.clockid_t

container

Source line 6554

Fields

REALTIME = 0
MONOTONIC = 1
PROCESS_CPUTIME_ID = 2
THREAD_CPUTIME_ID = 3
MONOTONIC_RAW = 4
REALTIME_COARSE = 5
MONOTONIC_COARSE = 6
BOOTTIME = 7
REALTIME_ALARM = 8
BOOTTIME_ALARM = 9
_

std.os.linux.clone

function

Source line 85

pub fn clone( func: *const fn (arg: usize) callconv(.c) u8, stack: usize, flags: u32, arg: usize, ptid: ?*pid_t, tp: usize,ctid: ?*pid_t, ) usize

Parameters

func: *const fn (arg: usize) callconv(.c) u8
stack: usize
flags: u32
arg: usize
ptid: ?*pid_t
tp: usize
ctid: ?*pid_t

std.os.linux.CLONE

namespace

Source line 6604

std.os.linux.CLONE.CHILD_CLEARTID

constant

Source line 6618

std.os.linux.CLONE.CHILD_SETTID

constant

Source line 6621

std.os.linux.CLONE.CLEAR_SIGHAND

constant

Source line 6633

Clear any signal handler and reset to SIG_DFL.

std.os.linux.CLONE.DETACHED

constant

Source line 6619

std.os.linux.CLONE.FILES

constant

Source line 6607

std.os.linux.CLONE.FS

constant

Source line 6606

std.os.linux.CLONE.INTO_CGROUP

constant

Source line 6635

Clone into a specific cgroup given the right permissions.

std.os.linux.CLONE.IO

constant

Source line 6628

std.os.linux.CLONE.NEWCGROUP

constant

Source line 6622

std.os.linux.CLONE.NEWIPC

constant

Source line 6624

std.os.linux.CLONE.NEWNET

constant

Source line 6627

std.os.linux.CLONE.NEWNS

constant

Source line 6614

std.os.linux.CLONE.NEWPID

constant

Source line 6626

std.os.linux.CLONE.NEWTIME

constant

Source line 6640

New time namespace

std.os.linux.CLONE.NEWUSER

constant

Source line 6625

std.os.linux.CLONE.NEWUTS

constant

Source line 6623

std.os.linux.CLONE.PARENT

constant

Source line 6612

std.os.linux.CLONE.PARENT_SETTID

constant

Source line 6617

std.os.linux.CLONE.PIDFD

constant

Source line 6609

std.os.linux.CLONE.PTRACE

constant

Source line 6610

std.os.linux.CLONE.SETTLS

constant

Source line 6616

std.os.linux.CLONE.SIGHAND

constant

Source line 6608

std.os.linux.CLONE.SYSVSEM

constant

Source line 6615

std.os.linux.CLONE.THREAD

constant

Source line 6613

std.os.linux.CLONE.UNTRACED

constant

Source line 6620

std.os.linux.CLONE.VFORK

constant

Source line 6611

std.os.linux.CLONE.VM

constant

Source line 6605

std.os.linux.clone2

function

Source line 2021

See also clone (from the arch-specific include)

pub fn clone2(flags: u32, child_stack_ptr: usize) usize

Parameters

flags: u32
child_stack_ptr: usize

std.os.linux.clone5

function

Source line 2016

See also clone (from the arch-specific include)

pub fn clone5(flags: usize, child_stack_ptr: usize, parent_tid: *pid_t, child_tid: *pid_t, newtls: usize) usize

Parameters

flags: usize
child_stack_ptr: usize
parent_tid: *pid_t
child_tid: *pid_t
newtls: usize

std.os.linux.close

function

Source line 2030

pub fn close(fd: fd_t) usize

Parameters

fd: fd_t

std.os.linux.close_range

function

Source line 2043

pub fn close_range(first: fd_t, last: fd_t, flags: CLOSE_RANGE) usize

Parameters

first: fd_t
last: fd_t
flags: CLOSE_RANGE

std.os.linux.CLOSE_RANGE

container

Source line 2034

Fields

_0: u1 = 0
UNSHARE: bool

Unshare the file descriptor table before closing file descriptors.

CLOEXEC: bool

Set the FD_CLOEXEC bit instead of closing the file descriptor.

_: u29 = 0

std.os.linux.cmsg_align

constant

Source line 11248

std.os.linux.cmsghdr

container

Source line 11240

Fields

len: usize

The kernel and glibc use usize for this field; musl uses socklen_t.

level: i32
type: i32

std.os.linux.connect

function

Source line 2832

pub fn connect(fd: fd_t, addr: *const anyopaque, len: socklen_t) usize

Parameters

fd: fd_t
addr: *const anyopaque
len: socklen_t

std.os.linux.copy_file_range

function

Source line 3241

pub fn copy_file_range(fd_in: fd_t, off_in: ?*off_t, fd_out: fd_t, off_out: ?*off_t, len: usize, flags: u32) usize

Parameters

fd_in: fd_t
off_in: ?*off_t
fd_out: fd_t
off_out: ?*off_t
len: usize
flags: u32

std.os.linux.CPU_COUNT

function

Source line 7313

pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t

Parameters

set: cpu_set_t

std.os.linux.cpu_count_t

constant

Source line 7311

std.os.linux.cpu_set_t

type

Source line 7310

std.os.linux.CPU_SETSIZE

constant

Source line 7309

std.os.linux.CRDLY

container

Source line 8676

Fields

CR0 = 0
CR1 = 1
CR2 = 2
CR3 = 3

std.os.linux.create

function

Source line 2006

pub fn create(path: [*:0]const u8, perm: mode_t) usize

Parameters

path: [*:0]const u8
perm: mode_t

std.os.linux.CSIGNAL

constant

Source line 6602

std.os.linux.CSIZE

container

Source line 8759

Fields

CS5 = 0
CS6 = 1
CS7 = 2
CS8 = 3

std.os.linux.dev_t

type

Source line 113

std.os.linux.dirent64

container

Source line 7294

Fields

ino: u64
off: u64
reclen: u16
type: u8
name: [0]u8

std.os.linux.dl

alias

Source line 12

Alias of std.dynamic_library

std.os.linux.dl_phdr_info

container

Source line 7302

Fields

addr: usize
name: ?[*:0]const u8
phdr: [*]std.elf.ElfN.Phdr
phnum: u16

std.os.linux.DT

namespace

Source line 6067

std.os.linux.DT.BLK

constant

Source line 6072

std.os.linux.DT.CHR

constant

Source line 6070

std.os.linux.DT.DIR

constant

Source line 6071

std.os.linux.DT.FIFO

constant

Source line 6069

std.os.linux.DT.LNK

constant

Source line 6074

std.os.linux.DT.REG

constant

Source line 6073

std.os.linux.DT.SOCK

constant

Source line 6075

std.os.linux.DT.UNKNOWN

constant

Source line 6068

std.os.linux.DT.WHT

constant

Source line 6076

std.os.linux.dup

function

Source line 1051

pub fn dup(old: fd_t) usize

Parameters

old: fd_t

std.os.linux.dup2

function

Source line 1055

pub fn dup2(old: fd_t, new: fd_t) usize

Parameters

old: fd_t
new: fd_t

std.os.linux.dup3

function

Source line 1071

pub fn dup3(old: fd_t, new: fd_t, flags: u32) usize

Parameters

old: fd_t
new: fd_t
flags: u32

std.os.linux.E

type

Source line 3584

std.os.linux.EFD

namespace

Source line 6643

std.os.linux.EFD.CLOEXEC

constant

Source line 6645

std.os.linux.EFD.NONBLOCK

constant

Source line 6646

std.os.linux.EFD.SEMAPHORE

constant

Source line 6644

std.os.linux.elf

alias

Source line 10

Alias of std.elf

std.os.linux.elf_aux_maybe

variable

Source line 964

Set by startup code, used by getauxval.

?[*]std.elf.Auxv

std.os.linux.Elf_Symndx

type

Source line 2424

std.os.linux.EPOLL

namespace

Source line 6528

std.os.linux.epoll_create

function

Source line 3091

pub fn epoll_create() usize

std.os.linux.epoll_create1

function

Source line 3095

pub fn epoll_create1(flags: u32) usize

Parameters

flags: u32

std.os.linux.epoll_ctl

function

Source line 3099

pub fn epoll_ctl(epoll_fd: fd_t, op: u32, fd: fd_t, ev: ?*epoll_event) usize

Parameters

epoll_fd: fd_t
op: u32
fd: fd_t
ev: ?*epoll_event

std.os.linux.epoll_data

container

Source line 7161

Fields

ptr: usize
fd: i32
u32: u32
u64: u64

std.os.linux.epoll_event

container

Source line 7168

Fields

events: u32
data: epoll_data align(switch (native_arch) {
    .x86_64 => 4,
    else => @alignOf(epoll_data),
})

std.os.linux.epoll_pwait

function

Source line 3107

pub fn epoll_pwait(epoll_fd: fd_t, events: [*]epoll_event, maxevents: u32, timeout: i32, sigmask: ?*const sigset_t) usize

Parameters

epoll_fd: fd_t
events: [*]epoll_event
maxevents: u32
timeout: i32
sigmask: ?*const sigset_t

std.os.linux.epoll_wait

function

Source line 3103

pub fn epoll_wait(epoll_fd: fd_t, events: [*]epoll_event, maxevents: u32, timeout: i32) usize

Parameters

epoll_fd: fd_t
events: [*]epoll_event
maxevents: u32
timeout: i32

std.os.linux.EPOLL.CLOEXEC

constant

Source line 6529

std.os.linux.EPOLL.CTL_ADD

constant

Source line 6531

std.os.linux.EPOLL.CTL_DEL

constant

Source line 6532

std.os.linux.EPOLL.CTL_MOD

constant

Source line 6533

std.os.linux.EPOLL.ERR

constant

Source line 6543

std.os.linux.EPOLL.ET

constant

Source line 6549

std.os.linux.EPOLL.EXCLUSIVE

constant

Source line 6546

std.os.linux.EPOLL.HUP

constant

Source line 6544

std.os.linux.EPOLL.IN

constant

Source line 6535

std.os.linux.EPOLL.MSG

constant

Source line 6542

std.os.linux.EPOLL.ONESHOT

constant

Source line 6548

std.os.linux.EPOLL.OUT

constant

Source line 6537

std.os.linux.EPOLL.PRI

constant

Source line 6536

std.os.linux.EPOLL.RDBAND

constant

Source line 6539

std.os.linux.EPOLL.RDHUP

constant

Source line 6545

std.os.linux.EPOLL.RDNORM

constant

Source line 6538

std.os.linux.EPOLL.WAKEUP

constant

Source line 6547

std.os.linux.EPOLL.WRBAND

constant

Source line 6541

std.os.linux.EPOLL.WRNORM

constant

Source line 6540

std.os.linux.errno

function

Source line 1042

Get the errno from a syscall return value. SUCCESS means no error.

pub fn errno(r: anytype) E

std.os.linux.ETH

namespace

Source line 5812

IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble and FCS/CRC (frame check sequence).

std.os.linux.ETH.ALEN

constant

Source line 5814

Octets in one ethernet addr

std.os.linux.ETH.DATA_LEN

constant

Source line 5822

Max. octets in payload

std.os.linux.ETH.FCS_LEN

constant

Source line 5826

Octets in the FCS

std.os.linux.ETH.FRAME_LEN

constant

Source line 5824

Max. octets in frame sans FCS

std.os.linux.ETH.HLEN

constant

Source line 5818

Total octets in header

std.os.linux.ETH.MAX_MTU

constant

Source line 5831

65535, same as IP_MAX_MTU

std.os.linux.ETH.MIN_MTU

constant

Source line 5829

Min IPv4 MTU per RFC791

std.os.linux.ETH.P

namespace

Source line 5834

These are the defined Ethernet Protocol ID's.

std.os.linux.ETH.P.@"1588"

constant

Source line 5940

IEEE 1588 Timesync

std.os.linux.ETH.P.@"802_2"

constant

Source line 5991

802.2 frames

std.os.linux.ETH.P.@"802_3_MIN"

constant

Source line 5980

If the value in the ethernet type is more than this value then the frame is Ethernet II. Else it is 802.3

std.os.linux.ETH.P.@"802_3"

constant

Source line 5985

Dummy type for 802.3 frames

std.os.linux.ETH.P.@"802_EX1"

constant

Source line 5924

802.1 Local Experimental 1.

std.os.linux.ETH.P.@"8021AD"

constant

Source line 5922

802.1ad Service VLAN

std.os.linux.ETH.P.@"8021AH"

constant

Source line 5936

802.1ah Backbone Service Tag

std.os.linux.ETH.P.@"80221"

constant

Source line 5956

IEEE 802.21 Media Independent Handover Protocol

std.os.linux.ETH.P.AARP

constant

Source line 5882

Appletalk AARP

std.os.linux.ETH.P.AF_IUCV

constant

Source line 5978

IBM af_iucv [ NOT AN OFFICIALLY REGISTERED ID ]

std.os.linux.ETH.P.ALL

constant

Source line 5989

Every packet (be careful!!!)

std.os.linux.ETH.P.AOE

constant

Source line 5918

ATA over Ethernet

std.os.linux.ETH.P.ARCNET

constant

Source line 6023

1A for ArcNet :-)

std.os.linux.ETH.P.ARP

constant

Source line 5850

Address Resolution packet

std.os.linux.ETH.P.ATALK

constant

Source line 5880

Appletalk DDP

std.os.linux.ETH.P.ATMFATE

constant

Source line 5910

Frame-based ATM Transport over Ethernet

std.os.linux.ETH.P.ATMMPOA

constant

Source line 5902

MultiProtocol Over ATM

std.os.linux.ETH.P.AX25

constant

Source line 5987

Dummy protocol id for AX.25

std.os.linux.ETH.P.BATMAN

constant

Source line 5858

B.A.T.M.A.N.-Advanced packet [ NOT AN OFFICIALLY REGISTERED ID ]

std.os.linux.ETH.P.BPQ

constant

Source line 5852

G8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ]

std.os.linux.ETH.P.CAIF

constant

Source line 6033

ST-Ericsson CAIF protocol

std.os.linux.ETH.P.CAN

constant

Source line 6003

CAN: Controller Area Network

std.os.linux.ETH.P.CANFD

constant

Source line 6005

CANFD: CAN flexible data rate

std.os.linux.ETH.P.CANXL

constant

Source line 6007

CANXL: eXtended frame Length

std.os.linux.ETH.P.CFM

constant

Source line 5946

Connectivity Fault Management

std.os.linux.ETH.P.CONTROL

constant

Source line 6015

Card specific control frames

std.os.linux.ETH.P.CUST

constant

Source line 5872

DEC Customer use

std.os.linux.ETH.P.DDCMP

constant

Source line 5995

DEC DDCMP: Internal only

std.os.linux.ETH.P.DEC

constant

Source line 5860

DEC Assigned proto

std.os.linux.ETH.P.DIAG

constant

Source line 5870

DEC Diagnostics

std.os.linux.ETH.P.DNA_DL

constant

Source line 5862

DEC DNA Dump/Load

std.os.linux.ETH.P.DNA_RC

constant

Source line 5864

DEC DNA Remote Console

std.os.linux.ETH.P.DNA_RT

constant

Source line 5866

DEC DNA Routing

std.os.linux.ETH.P.DSA

constant

Source line 6025

Distributed Switch Arch.

std.os.linux.ETH.P.DSA_8021Q

constant

Source line 5972

Fake VLAN Header for DSA [ NOT AN OFFICIALLY REGISTERED ID ]

std.os.linux.ETH.P.DSA_A5PSW

constant

Source line 5974

A5PSW Tag Value [ NOT AN OFFICIALLY REGISTERED ID ]

std.os.linux.ETH.P.ECONET

constant

Source line 6019

Acorn Econet

std.os.linux.ETH.P.EDSA

constant

Source line 5970

Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ]

std.os.linux.ETH.P.ERSPAN

constant

Source line 5886

ERSPAN type II

std.os.linux.ETH.P.ERSPAN2

constant

Source line 5844

ERSPAN version 2 (type III)

std.os.linux.ETH.P.ETHERCAT

constant

Source line 5920

EtherCAT

std.os.linux.ETH.P.FCOE

constant

Source line 5948

Fibre Channel over Ethernet

std.os.linux.ETH.P.FIP

constant

Source line 5954

FCoE Initialization Protocol

std.os.linux.ETH.P.HDLC

constant

Source line 6021

HDLC frames

std.os.linux.ETH.P.HSR

constant

Source line 5958

IEC 62439-3 HSRv1

std.os.linux.ETH.P.IBOE

constant

Source line 5950

Infiniband over Ethernet

std.os.linux.ETH.P.IEEE802154

constant

Source line 6031

IEEE802.15.4 frame

std.os.linux.ETH.P.IEEEPUP

constant

Source line 5854

Xerox IEEE802.3 PUP packet

std.os.linux.ETH.P.IEEEPUPAT

constant

Source line 5856

Xerox IEEE802.3 PUP Addr Trans packet

std.os.linux.ETH.P.IFE

constant

Source line 5976

ForCES inter-FE LFB type

std.os.linux.ETH.P.IP

constant

Source line 5846

Internet Protocol packet

std.os.linux.ETH.P.IPV6

constant

Source line 5890

IPv6 over bluebook

std.os.linux.ETH.P.IPX

constant

Source line 5888

IPX over DIX

std.os.linux.ETH.P.IRDA

constant

Source line 6017

Linux-IrDA

std.os.linux.ETH.P.LAT

constant

Source line 5868

DEC LAT

std.os.linux.ETH.P.LINK_CTL

constant

Source line 5908

HPNA, wlan link local tunnel

std.os.linux.ETH.P.LLDP

constant

Source line 5930

Link Layer Discovery Protocol

std.os.linux.ETH.P.LOCALTALK

constant

Source line 6001

Localtalk pseudo type

std.os.linux.ETH.P.LOOP

constant

Source line 5836

Ethernet Loopback packet

std.os.linux.ETH.P.LOOPBACK

constant

Source line 5962

Ethernet loopback packet, per IEEE 802.3

std.os.linux.ETH.P.MACSEC

constant

Source line 5934

802.1ae MACsec

std.os.linux.ETH.P.MAP

constant

Source line 6037

Qualcomm multiplexing and aggregation protocol

std.os.linux.ETH.P.MCTP

constant

Source line 6039

Management component transport protocol packets

std.os.linux.ETH.P.MOBITEX

constant

Source line 6013

Mobitex (kaz@cafe.net)

std.os.linux.ETH.P.MPLS_MC

constant

Source line 5900

MPLS Multicast traffic

std.os.linux.ETH.P.MPLS_UC

constant

Source line 5898

MPLS Unicast traffic

std.os.linux.ETH.P.MRP

constant

Source line 5932

Media Redundancy Protocol

std.os.linux.ETH.P.MVRP

constant

Source line 5938

802.1Q MVRP

std.os.linux.ETH.P.NCSI

constant

Source line 5942

NCSI protocol

std.os.linux.ETH.P.NSH

constant

Source line 5960

Network Service Header

std.os.linux.ETH.P.P_8021Q

constant

Source line 5884

802.1Q VLAN Extended Header

std.os.linux.ETH.P.PAE

constant

Source line 5912

Port Access Entity (IEEE 802.1X)

std.os.linux.ETH.P.PAUSE

constant

Source line 5892

IEEE Pause frames. See 802.3 31B

std.os.linux.ETH.P.PHONET

constant

Source line 6029

Nokia Phonet frames

std.os.linux.ETH.P.PPP_DISC

constant

Source line 5904

PPPoE discovery messages

std.os.linux.ETH.P.PPP_MP

constant

Source line 5999

Dummy type for PPP MP frames

std.os.linux.ETH.P.PPP_SES

constant

Source line 5906

PPPoE session messages

std.os.linux.ETH.P.PPPTALK

constant

Source line 6009

Dummy type for Atalk over PPP

std.os.linux.ETH.P.PREAUTH

constant

Source line 5926

802.11 Preauthentication

std.os.linux.ETH.P.PROFINET

constant

Source line 5914

PROFINET

std.os.linux.ETH.P.PRP

constant

Source line 5944

IEC 62439-3 PRP/HSRv0

std.os.linux.ETH.P.PUP

constant

Source line 5838

Xerox PUP packet

std.os.linux.ETH.P.PUPAT

constant

Source line 5840

Xerox PUP Addr Trans packet

std.os.linux.ETH.P.QINQ1

constant

Source line 5964

deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ]

std.os.linux.ETH.P.QINQ2

constant

Source line 5966

deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ]

std.os.linux.ETH.P.QINQ3

constant

Source line 5968

deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ]

std.os.linux.ETH.P.RARP

constant

Source line 5878

Reverse Addr Res packet

std.os.linux.ETH.P.REALTEK

constant

Source line 5916

Multiple proprietary protocols

std.os.linux.ETH.P.SCA

constant

Source line 5874

DEC Systems Comms Arch

std.os.linux.ETH.P.SLOW

constant

Source line 5894

Slow Protocol. See 802.3ad 43B

std.os.linux.ETH.P.SNAP

constant

Source line 5993

Internal only

std.os.linux.ETH.P.TDLS

constant

Source line 5952

TDLS

std.os.linux.ETH.P.TEB

constant

Source line 5876

Trans Ether Bridging

std.os.linux.ETH.P.TIPC

constant

Source line 5928

TIPC

std.os.linux.ETH.P.TR_802_2

constant

Source line 6011

802.2 frames

std.os.linux.ETH.P.TRAILER

constant

Source line 6027

Trailer switch tagging

std.os.linux.ETH.P.TSN

constant

Source line 5842

TSN (IEEE 1722) packet

std.os.linux.ETH.P.WAN_PPP

constant

Source line 5997

Dummy type for WAN PPP frames

std.os.linux.ETH.P.WCCP

constant

Source line 5896

Web-cache coordination protocol defined in draft-wilson-wrec-wccp-v2-00.txt

std.os.linux.ETH.P.X25

constant

Source line 5848

CCITT X.25

std.os.linux.ETH.P.XDSA

constant

Source line 6035

Multiplexed DSA protocol

std.os.linux.ETH.TLEN

constant

Source line 5816

Octets in ethernet type field

std.os.linux.ETH.ZLEN

constant

Source line 5820

Min. octets in frame sans FC

std.os.linux.eventfd

function

Source line 3119

pub fn eventfd(count: u32, flags: u32) usize

Parameters

count: u32
flags: u32

std.os.linux.execve

function

Source line 1087

pub fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) usize

Parameters

path: [*:0]const u8
argv: [*:null]const ?[*:0]const u8
envp: [*:null]const ?[*:0]const u8

std.os.linux.execveat

function

Source line 1101

pub fn execveat(dirfd: fd_t, path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8, flags: EXECVEAT) usize

Parameters

dirfd: fd_t
path: [*:0]const u8
argv: [*:null]const ?[*:0]const u8
envp: [*:null]const ?[*:0]const u8
flags: EXECVEAT

std.os.linux.EXECVEAT

container

Source line 1091

Fields

_1: u8 = 0
SYMLINK_NOFOLLOW: bool

Do not follow symbolic links.

_200: u3 = 0
EMPTY_PATH: bool

Allow empty relative pathname.

_: u19 = 0

std.os.linux.exit

function

Source line 2127

pub fn exit(status: i32) noreturn

Parameters

status: i32

std.os.linux.exit_group

function

Source line 2132

pub fn exit_group(status: i32) noreturn

Parameters

status: i32

std.os.linux.extern_getauxval

constant

Source line 967

Whether an external or internal getauxval implementation is used.

std.os.linux.F

namespace

Source line 2277

std.os.linux.F_OK

constant

Source line 4660

std.os.linux.F_OWNER

container

Source line 2391

Fields

TID = 0
PID = 1
PGRP = 2
_

std.os.linux.f_owner_ex

container

Source line 2398

Fields

type: F_OWNER
pid: pid_t

std.os.linux.F.ADD_SEALS

constant

Source line 2375

std.os.linux.F.CANCELLK

constant

Source line 2371

std.os.linux.F.CREATED_QUERY

constant

Source line 2370

std.os.linux.F.DUPFD

constant

Source line 2278

std.os.linux.F.DUPFD_CLOEXEC

constant

Source line 2372

std.os.linux.F.DUPFD_QUERY

constant

Source line 2369

std.os.linux.F.GET_FILE_RW_HINT

constant

Source line 2387

std.os.linux.F.GET_RW_HINT

constant

Source line 2385

std.os.linux.F.GET_SEALS

constant

Source line 2376

std.os.linux.F.GET_SET_LK

type

Source line 2291

std.os.linux.F.GET_SET_LK.GETLK

constant

Source line 2293

std.os.linux.F.GET_SET_LK.GETLK

constant

Source line 2299

std.os.linux.F.GET_SET_LK.GETLK

constant

Source line 2304

std.os.linux.F.GET_SET_LK.GETLK

constant

Source line 2310

std.os.linux.F.GET_SET_LK.GETLK

constant

Source line 2315

std.os.linux.F.GET_SET_LK.GETLK

constant

Source line 2320

std.os.linux.F.GET_SET_LK.GETLK

constant

Source line 2324

std.os.linux.F.GET_SET_LK.SETLK

constant

Source line 2294

std.os.linux.F.GET_SET_LK.SETLK

constant

Source line 2300

std.os.linux.F.GET_SET_LK.SETLK

constant

Source line 2305

std.os.linux.F.GET_SET_LK.SETLK

constant

Source line 2311

std.os.linux.F.GET_SET_LK.SETLK

constant

Source line 2316

std.os.linux.F.GET_SET_LK.SETLK

constant

Source line 2321

std.os.linux.F.GET_SET_LK.SETLK

constant

Source line 2325

std.os.linux.F.GET_SET_LK.SETLKW

constant

Source line 2295

std.os.linux.F.GET_SET_LK.SETLKW

constant

Source line 2301

std.os.linux.F.GET_SET_LK.SETLKW

constant

Source line 2306

std.os.linux.F.GET_SET_LK.SETLKW

constant

Source line 2312

std.os.linux.F.GET_SET_LK.SETLKW

constant

Source line 2317

std.os.linux.F.GET_SET_LK.SETLKW

constant

Source line 2322

std.os.linux.F.GET_SET_LK.SETLKW

constant

Source line 2326

std.os.linux.F.GET_SET_OWN

type

Source line 2329

std.os.linux.F.GET_SET_OWN.GETOWN

constant

Source line 2331

std.os.linux.F.GET_SET_OWN.GETOWN

constant

Source line 2335

std.os.linux.F.GET_SET_OWN.GETOWN

constant

Source line 2339

std.os.linux.F.GET_SET_OWN.GETOWN

constant

Source line 2343

std.os.linux.F.GET_SET_OWN.SETOWN

constant

Source line 2332

std.os.linux.F.GET_SET_OWN.SETOWN

constant

Source line 2336

std.os.linux.F.GET_SET_OWN.SETOWN

constant

Source line 2340

std.os.linux.F.GET_SET_OWN.SETOWN

constant

Source line 2344

std.os.linux.F.GETFD

constant

Source line 2279

std.os.linux.F.GETFL

constant

Source line 2281

std.os.linux.F.GETLEASE

constant

Source line 2367

std.os.linux.F.GETLK

constant

Source line 2284

std.os.linux.F.GETOWN

constant

Source line 2289

std.os.linux.F.GETOWN_EX

constant

Source line 2352

std.os.linux.F.GETOWNER_UIDS

constant

Source line 2354

std.os.linux.F.GETPIPE_SZ

constant

Source line 2374

std.os.linux.F.GETSIG

constant

Source line 2349

std.os.linux.F.LINUX_SPECIFIC_BASE

constant

Source line 2364

std.os.linux.F.NOTIFY

constant

Source line 2368

std.os.linux.F.OFD_GETLK

constant

Source line 2356

std.os.linux.F.OFD_SETLK

constant

Source line 2357

std.os.linux.F.OFD_SETLKW

constant

Source line 2358

std.os.linux.F.RDLCK

constant

Source line 2360

std.os.linux.F.SEAL_EXEC

constant

Source line 2383

std.os.linux.F.SEAL_FUTURE_WRITE

constant

Source line 2382

std.os.linux.F.SEAL_GROW

constant

Source line 2380

std.os.linux.F.SEAL_SEAL

constant

Source line 2378

std.os.linux.F.SEAL_SHRINK

constant

Source line 2379

std.os.linux.F.SEAL_WRITE

constant

Source line 2381

std.os.linux.F.SET_FILE_RW_HINT

constant

Source line 2388

std.os.linux.F.SET_RW_HINT

constant

Source line 2386

std.os.linux.F.SETFD

constant

Source line 2280

std.os.linux.F.SETFL

constant

Source line 2282

std.os.linux.F.SETLEASE

constant

Source line 2366

std.os.linux.F.SETLK

constant

Source line 2285

std.os.linux.F.SETLKW

constant

Source line 2286

std.os.linux.F.SETOWN

constant

Source line 2288

std.os.linux.F.SETOWN_EX

constant

Source line 2351

std.os.linux.F.SETPIPE_SZ

constant

Source line 2373

std.os.linux.F.SETSIG

constant

Source line 2348

std.os.linux.F.UNLCK

constant

Source line 2362

std.os.linux.F.WRLCK

constant

Source line 2361

std.os.linux.faccessat

function

Source line 1884

pub fn faccessat(dirfd: fd_t, path: [*:0]const u8, mode: mode_t, flags: u32) usize

Parameters

dirfd: fd_t
path: [*:0]const u8
mode: mode_t
flags: u32

std.os.linux.fadvise

function

Source line 3352

pub fn fadvise(fd: fd_t, offset: i64, len: i64, advice: usize) usize

Parameters

fd: fd_t
offset: i64
len: i64
advice: usize

std.os.linux.FALLOC

namespace

Source line 4516

std.os.linux.FALLOC.FL_COLLAPSE_RANGE

constant

Source line 4527

Removes a range of a file without leaving a hole in the file

std.os.linux.FALLOC.FL_INSERT_RANGE

constant

Source line 4533

Inserts space within the file size without overwriting any existing data

std.os.linux.FALLOC.FL_KEEP_SIZE

constant

Source line 4518

Default is extend size

std.os.linux.FALLOC.FL_NO_HIDE_STALE

constant

Source line 4524

Reserved codepoint

std.os.linux.FALLOC.FL_PUNCH_HOLE

constant

Source line 4521

De-allocates range

std.os.linux.FALLOC.FL_UNSHARE_RANGE

constant

Source line 4536

Unshares shared blocks within the file size without overwriting any existing data

std.os.linux.FALLOC.FL_ZERO_RANGE

constant

Source line 4530

Converts a range of file to zeros preferably without issuing data IO

std.os.linux.fallocate

function

Source line 1129

pub fn fallocate(fd: fd_t, mode: mode_t, offset: off_t, length: off_t) usize

Parameters

fd: fd_t
mode: mode_t
offset: off_t
length: off_t

std.os.linux.fanotify

namespace

Source line 6728

std.os.linux.fanotify_init

function

Source line 1347

pub fn fanotify_init(flags: fanotify.InitFlags, event_f_flags: u32) usize

Parameters

flags: fanotify.InitFlags
event_f_flags: u32

std.os.linux.fanotify_mark

function

Source line 1351

pub fn fanotify_mark( fd: fd_t, flags: fanotify.MarkFlags, mask: fanotify.MarkMask, dirfd: fd_t, pathname: ?[*:0]const u8, ) usize

Parameters

fd: fd_t
flags: fanotify.MarkFlags
mask: fanotify.MarkMask
dirfd: fd_t
pathname: ?[*:0]const u8

std.os.linux.fanotify.event_info_fid

container

Source line 6841

Unique file identifier info record.

This structure is used for records of types EVENT_INFO_TYPE.FID. EVENT_INFO_TYPE.DFID and EVENT_INFO_TYPE.DFID_NAME.

For EVENT_INFO_TYPE.DFID_NAME there is additionally a null terminated name immediately after the file handle.

Fields

hdr: event_info_header
fsid: kernel_fsid_t
handle: [0]u8

Following is an opaque struct file_handle that can be passed as an argument to open_by_handle_at(2).

std.os.linux.fanotify.event_info_header

container

Source line 6850

Variable length info record following event metadata.

Fields

info_type: EVENT_INFO_TYPE
pad: u8
len: u16

std.os.linux.fanotify.EVENT_INFO_TYPE

container

Source line 6856

Fields

FID = 1
DFID_NAME = 2
DFID = 3
PIDFD = 4
ERROR = 5
OLD_DFID_NAME = 10
OLD_DFID = 11
NEW_DFID_NAME = 12
NEW_DFID = 13

std.os.linux.fanotify.event_metadata

container

Source line 6817

Fields

event_len: u32
vers: u8
reserved: u8
metadata_len: u16
mask: MarkMask align(8)
fd: i32
pid: i32

std.os.linux.fanotify.event_metadata.VERSION

constant

Source line 6826

std.os.linux.fanotify.InitFlags

container

Source line 6729

Fields

CLOEXEC: bool = false
NONBLOCK: bool = false
CLASS: enum(u2) {
    NOTIF = 0,
    CONTENT = 1,
    PRE_CONTENT = 2,
} = .NOTIF
UNLIMITED_QUEUE: bool = false
UNLIMITED_MARKS: bool = false
ENABLE_AUDIT: bool = false
REPORT_PIDFD: bool = false
REPORT_TID: bool = false
REPORT_FID: bool = false
REPORT_DIR_FID: bool = false
REPORT_NAME: bool = false
REPORT_TARGET_FID: bool = false
_: u19 = 0

std.os.linux.fanotify.MarkFlags

container

Source line 6749

Fields

ADD: bool = false
REMOVE: bool = false
DONT_FOLLOW: bool = false
ONLYDIR: bool = false
MOUNT: bool = false
IGNORED_MASK: bool = false

Mutually exclusive with IGNORE

IGNORED_SURV_MODIFY: bool = false
FLUSH: bool = false
FILESYSTEM: bool = false
EVICTABLE: bool = false
IGNORE: bool = false

Mutually exclusive with IGNORED_MASK

_: u21 = 0

std.os.linux.fanotify.MarkMask

container

Source line 6766

Fields

ACCESS: bool = false

File was accessed

MODIFY: bool = false

File was modified

ATTRIB: bool = false

Metadata changed

CLOSE_WRITE: bool = false

Writtable file closed

CLOSE_NOWRITE: bool = false

Unwrittable file closed

OPEN: bool = false

File was opened

MOVED_FROM: bool = false

File was moved from X

MOVED_TO: bool = false

File was moved to Y

CREATE: bool = false

Subfile was created

DELETE: bool = false

Subfile was deleted

DELETE_SELF: bool = false

Self was deleted

MOVE_SELF: bool = false

Self was moved

OPEN_EXEC: bool = false

File was opened for exec

reserved13: u1 = 0
Q_OVERFLOW: bool = false

Event queued overflowed

FS_ERROR: bool = false

Filesystem error

OPEN_PERM: bool = false

File open in perm check

ACCESS_PERM: bool = false

File accessed in perm check

OPEN_EXEC_PERM: bool = false

File open/exec in perm check

reserved19: u8 = 0
EVENT_ON_CHILD: bool = false

Interested in child events

RENAME: bool = false

File was renamed

reserved30: u1 = 0
ONDIR: bool = false

Event occurred against dir

reserved31: u33 = 0

std.os.linux.fanotify.response

container

Source line 6829

Fields

fd: i32
response: u32

std.os.linux.fchdir

function

Source line 1079

pub fn fchdir(fd: fd_t) usize

Parameters

fd: fd_t

std.os.linux.fchmod

function

Source line 2047

pub fn fchmod(fd: fd_t, mode: mode_t) usize

Parameters

fd: fd_t
mode: mode_t

std.os.linux.fchmodat

function

Source line 2091

pub fn fchmodat(fd: fd_t, path: [*:0]const u8, mode: mode_t) usize

Parameters

fd: fd_t
path: [*:0]const u8
mode: mode_t

std.os.linux.fchmodat2

function

Source line 2095

pub fn fchmodat2(fd: fd_t, path: [*:0]const u8, mode: mode_t, flags: u32) usize

Parameters

fd: fd_t
path: [*:0]const u8
mode: mode_t
flags: u32

std.os.linux.fchown

function

Source line 2059

pub fn fchown(fd: fd_t, owner: uid_t, group: gid_t) usize

Parameters

fd: fd_t
owner: uid_t
group: gid_t

std.os.linux.fchownat

function

Source line 2067

pub fn fchownat(fd: fd_t, path: [*:0]const u8, owner: uid_t, group: gid_t, flags: u32) usize

Parameters

fd: fd_t
path: [*:0]const u8
owner: uid_t
group: gid_t
flags: u32

std.os.linux.fcntl

function

Source line 2412

pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) usize

Parameters

fd: fd_t
cmd: i32
arg: usize

std.os.linux.FD_CLOEXEC

constant

Source line 4658

std.os.linux.fd_t

type

Source line 119

std.os.linux.fdatasync

function

Source line 3269

pub fn fdatasync(fd: fd_t) usize

Parameters

fd: fd_t

std.os.linux.FFDLY

container

Source line 8702

Fields

FF0 = 0
FF1 = 1

std.os.linux.fgetxattr

function

Source line 2964

pub fn fgetxattr(fd: fd_t, name: [*:0]const u8, value: [*]u8, size: usize) usize

Parameters

fd: fd_t
name: [*:0]const u8
value: [*]u8
size: usize

std.os.linux.file_handle

container

Source line 6869

Fields

handle_bytes: u32
handle_type: i32
f_handle: [0]u8

std.os.linux.flistxattr

function

Source line 2952

pub fn flistxattr(fd: fd_t, list: [*]u8, size: usize) usize

Parameters

fd: fd_t
list: [*]u8
size: usize

std.os.linux.flock

function

Source line 2420

pub fn flock(fd: fd_t, operation: i32) usize

Parameters

fd: fd_t
operation: i32

std.os.linux.Flock

container

Source line 2403

Fields

type: i16
whence: i16
start: off_t
len: off_t
pid: pid_t
_unused: if (is_sparc) i16 else void

std.os.linux.fork

function

Source line 1105

pub fn fork() usize

std.os.linux.fremovexattr

function

Source line 2988

pub fn fremovexattr(fd: fd_t, name: [*:0]const u8) usize

Parameters

fd: fd_t
name: [*:0]const u8

std.os.linux.fsconfig

function

Source line 1538

pub fn fsconfig(fd: fd_t, cmd: FSCONFIG_CMD, key: ?[*:0]const u8, value: ?[*:0]const u8, aux: u32) usize

Parameters

fd: fd_t
cmd: FSCONFIG_CMD
key: ?[*:0]const u8
value: ?[*:0]const u8
aux: u32

std.os.linux.FSCONFIG_CMD

container

Source line 1519

Fields

SET_FLAG

Set parameter, supplying no value.

SET_STRING

Set parameter, supplying a string value.

SET_BINARY

Set parameter, supplying a binary blob value.

SET_PATH

Set parameter, supplying an object by path.

SET_PATH_EMPTY

Set parameter, supplying an object by (empty) path.

SET_FD

Set parameter, supplying an object by fd.

CREATE

Invoke superblock creation.

RECONFIGURE

Invoke superblock reconfiguration.

std.os.linux.fsetxattr

function

Source line 2976

pub fn fsetxattr(fd: fd_t, name: [*:0]const u8, value: [*]const u8, size: usize, flags: usize) usize

Parameters

fd: fd_t
name: [*:0]const u8
value: [*]const u8
size: usize
flags: usize

std.os.linux.fsid_t

type

Source line 6876

std.os.linux.fsmount

function

Source line 1548

pub fn fsmount(fsfd: fd_t, flags: FSMOUNT, attr_flags: MOUNT_ATTR) usize

Parameters

fsfd: fd_t
flags: FSMOUNT
attr_flags: MOUNT_ATTR

std.os.linux.FSMOUNT

container

Source line 1542

Fields

CLOEXEC: bool

Set CLOEXEC on the fd.

_31: u31 = 0

std.os.linux.fsopen

function

Source line 1515

pub fn fsopen(fsname: [*:0]const u8, flags: FSOPEN) usize

Parameters

fsname: [*:0]const u8
flags: FSOPEN

std.os.linux.FSOPEN

container

Source line 1509

Fields

CLOEXEC: bool

Set CLOEXEC on the new fd.

_: u31 = 0

std.os.linux.fspick

function

Source line 1561

pub fn fspick(dirfd: fd_t, path: [*:0]const u8, flags: FSPICK) usize

Parameters

dirfd: fd_t
path: [*:0]const u8
flags: FSPICK

std.os.linux.FSPICK

container

Source line 1552

Fields

CLOEXEC: bool

Set CLOEXEC on the new fd.

SYMLINK_NOFOLLOW: bool
NO_AUTOMOUNT: bool
EMPTY_PATH: bool
_28: u28 = 0

std.os.linux.fsync

function

Source line 3265

pub fn fsync(fd: fd_t) usize

Parameters

fd: fd_t

std.os.linux.ftruncate

function

Source line 1909

pub fn ftruncate(fd: fd_t, length: off_t) usize

Parameters

fd: fd_t
length: off_t

std.os.linux.futex

function

Source line 1167

The futex v1 syscall, see also the newer the futex2_{wait,wakeup,requeue,waitv} syscalls.

The futex_op parameter is a sub-command and flags. The sub-command defines which of the subsequent paramters are relevant.

pub fn futex(uaddr: *const anyopaque, futex_op: FUTEX_OP, val: u32, val2timeout: futex_param4, uaddr2: ?*const anyopaque, val3: u32) usize

Parameters

uaddr: *const anyopaque
futex_op: FUTEX_OP
val: u32
val2timeout: futex_param4
uaddr2: ?*const anyopaque
val3: u32

std.os.linux.futex_3arg

function

Source line 1181

Three-argument variation of the v1 futex call. Only suitable for a futex_op that ignores the remaining arguments (e.g., FUTUX_OP.WAKE).

pub fn futex_3arg(uaddr: *const anyopaque, futex_op: FUTEX_OP, val: u32) usize

Parameters

uaddr: *const anyopaque
futex_op: FUTEX_OP
val: u32

std.os.linux.futex_4arg

function

Source line 1192

Four-argument variation on the v1 futex call. Only suitable for futex_op that ignores the remaining arguments (e.g., FUTEX_OP.WAIT).

pub fn futex_4arg(uaddr: *const anyopaque, futex_op: FUTEX_OP, val: u32, timeout: ?*const timespec) usize

Parameters

uaddr: *const anyopaque
futex_op: FUTEX_OP
val: u32
timeout: ?*const timespec

std.os.linux.FUTEX_COMMAND

container

Source line 4541

Fields

WAIT = 0
WAKE = 1
FD = 2
REQUEUE = 3
CMP_REQUEUE = 4
WAKE_OP = 5
LOCK_PI = 6
UNLOCK_PI = 7
TRYLOCK_PI = 8
WAIT_BITSET = 9
WAKE_BITSET = 10
WAIT_REQUEUE_PI = 11
CMP_REQUEUE_PI = 12

std.os.linux.FUTEX_OP

container

Source line 4558

Futex v1 API command and flags for the futex_op parameter

Fields

cmd: FUTEX_COMMAND
private: bool
realtime: bool = false
_reserved: u23 = 0

std.os.linux.futex_param4

container

Source line 1156

Fields

timeout: ?*const timespec
val2: usize

On all platforms only the bottom 32-bits of val2 are relevant. This is 64-bit to match the pointer in the union.

std.os.linux.FUTEX_WAKE_OP

container

Source line 4566

Futex v1 FUTEX_WAKE_OP val3 operation:

Fields

cmd: FUTEX_WAKE_OP_CMD
arg_shift: bool = false

From C API FUTEX_OP_ARG_SHIFT: Use (1 << oparg) as operand

cmp: FUTEX_WAKE_OP_CMP
oparg: u12
cmdarg: u12

std.os.linux.FUTEX_WAKE_OP_CMD

container

Source line 4576

Futex v1 cmd for FUTEX_WAKE_OP val3 command.

Fields

SET = 0

uaddr2 = oparg

ADD = 1

uaddr2 += oparg

OR = 2

uaddr2 |= oparg

ANDN = 3

uaddr2 &= ~oparg

XOR = 4

uaddr2 ^= oparg

std.os.linux.FUTEX_WAKE_OP_CMP

container

Source line 4590

Futex v1 comparison op for FUTEX_WAKE_OP val3 cmp

Fields

EQ = 0
NE = 1
LT = 2
LE = 3
GT = 4
GE = 5

std.os.linux.FUTEX2_FLAGS

container

Source line 4624

Flags for futex v2 APIs (futex2_wait, futex2_wake, futex2_requeue, but not the futex2_waitv syscall, but also used in the futex2_waitone struct).

Fields

size: FUTEX2_SIZE
numa: bool = false
_reserved: u4 = 0
private: bool
_undefined: u24 = 0

std.os.linux.FUTEX2_FLAGS_REQUEUE

container

Source line 4618

As of kernel 6.14 there are no defined flags to futex2_requeue.

Fields

_reserved: u32 = 0

std.os.linux.FUTEX2_FLAGS_WAITV

container

Source line 4613

As of kernel 6.14 there are no defined flags to futex2_waitv.

Fields

_reserved: u32 = 0

std.os.linux.futex2_requeue

function

Source line 1294

Wake and/or requeue waiter(s) from one futex to another. Identical to FUTEX.CMP_REQUEUE, except it is part of the futex2 family of calls.

Requires at least kernel v6.7.

pub fn futex2_requeue( waiters: [*]const futex2_waitone, flags: FUTEX2_FLAGS_REQUEUE, nr_wake: i32, nr_requeue: i32, ) usize

Parameters

waiters: [*]const futex2_waitone

The source and destination futexes. Must be a 2-element array.

flags: FUTEX2_FLAGS_REQUEUE

Currently unused.

nr_wake: i32

Maximum number of waiters to wake on the source futex.

nr_requeue: i32

Maximum number of waiters to transfer to the destination futex.

std.os.linux.FUTEX2_SIZE

container

Source line 4605

For futex v2 API, the size of the futex at the uaddr. v1 futex are always implicitly U32. As of kernel v6.14, only U32 is implemented for v2 futexes.

Fields

U8 = 0
U16 = 1
U32 = 2
U64 = 3

std.os.linux.futex2_wait

function

Source line 1243

Wait on a single futex. Identical to the futex v1 FUTEX.FUTEX_WAIT_BITSET op, except it is part of the futex2 family of calls.

Requires at least kernel v6.7.

pub fn futex2_wait( uaddr: *const anyopaque, val: usize, mask: usize, flags: FUTEX2_FLAGS, timeout: ?*const kernel_timespec, clockid: clockid_t, ) usize

Parameters

uaddr: *const anyopaque

Address of the futex to wait on.

val: usize

Value of uaddr.

mask: usize

Bitmask to match against incoming wakeup masks. Must not be zero.

flags: FUTEX2_FLAGS
timeout: ?*const kernel_timespec

Optional absolute timeout. Always 64-bit, even on 32-bit platforms.

clockid: clockid_t

Clock to be used for the timeout, realtime or monotonic.

std.os.linux.futex2_waitone

container

Source line 11180

For futex2_waitv and futex2_requeue. Arrays of futex2_waitone allow waiting on multiple futexes in one call.

Fields

val: u64

Expected value at uaddr, should match size of futex.

uaddr: u64

User address to wait on. Top-bits must be 0 on 32-bit.

flags: FUTEX2_FLAGS

Flags for this waiter.

__reserved: u32 = 0

Reserved member to preserve alignment.

std.os.linux.FUTEX2_WAITONE_MAX

constant

Source line 4600

Max numbers of elements in a futex2_waitone array.

std.os.linux.futex2_waitv

function

Source line 1218

Given an array of futex2_waitone, wait on each uaddr. The thread wakes if a futex_wake() is performed at any uaddr. The syscall returns immediately if any futex has *uaddr != val. timeout is an optional, absolute timeout value for the operation. The flags argument is for future use and currently should be .{}. Flags for private futexes, sizes, etc. should be set on the individual flags of each futex2_waitone.

Returns the array index of one of the woken futexes. No further information is provided: any number of other futexes may also have been woken by the same event, and if more than one futex was woken, the returned index may refer to any one of them. (It is not necessaryily the futex with the smallest index, nor the one most recently woken, nor...)

Requires at least kernel v5.16.

pub fn futex2_waitv( futexes: [*]const futex2_waitone, nr_futexes: u32, flags: FUTEX2_FLAGS_WAITV, timeout: ?*const kernel_timespec, clockid: clockid_t, ) usize

Parameters

futexes: [*]const futex2_waitone
nr_futexes: u32

Length of futexes. Max of FUTEX2_WAITONE_MAX.

flags: FUTEX2_FLAGS_WAITV
timeout: ?*const kernel_timespec

Optional absolute timeout. Always 64-bit, even on 32-bit platforms.

clockid: clockid_t

Clock to be used for the timeout, realtime or monotonic.

std.os.linux.futex2_wake

function

Source line 1272

Wake (subset of) waiters on given futex. Identical to the traditional FUTEX.FUTEX_WAKE_BITSET op, except it is part of the futex2 family of calls.

Requires at least kernel v6.7.

pub fn futex2_wake( uaddr: *const anyopaque, mask: usize, nr_wake: i32, flags: FUTEX2_FLAGS, ) usize

Parameters

uaddr: *const anyopaque

Futex to wake

mask: usize

Bitmask to match against waiters.

nr_wake: i32

Maximum number of waiters on the futex to wake.

flags: FUTEX2_FLAGS

std.os.linux.futimens

function

Source line 1115

pub fn futimens(fd: fd_t, times: ?*const [2]timespec) usize

Parameters

fd: fd_t
times: ?*const [2]timespec

std.os.linux.getauxval

constant

Source line 978

std.os.linux.getauxval.getauxval

function

Source line 987

extern fn getauxval(index: usize) usize

Parameters

index: usize

std.os.linux.getauxvalImpl

function

Source line 990

fn getauxvalImpl(index: usize) callconv(.c) usize

Parameters

index: usize

std.os.linux.getcpu

function

Source line 3042

pub fn getcpu(cpu: ?*usize, node: ?*usize) usize

Parameters

cpu: ?*usize
node: ?*usize

std.os.linux.getcwd

function

Source line 1313

pub fn getcwd(buf: [*]u8, size: usize) usize

Parameters

buf: [*]u8
size: usize

std.os.linux.getdents

function

Source line 1317

pub fn getdents(fd: fd_t, dirp: [*]u8, len: c_uint) usize

Parameters

fd: fd_t
dirp: [*]u8
len: c_uint

std.os.linux.getdents64

function

Source line 1326

pub fn getdents64(fd: fd_t, dirp: [*]u8, len: c_uint) usize

Parameters

fd: fd_t
dirp: [*]u8
len: c_uint

std.os.linux.getegid

function

Source line 2563

pub fn getegid() gid_t

std.os.linux.geteuid

function

Source line 2555

pub fn geteuid() uid_t

std.os.linux.getgid

function

Source line 2547

pub fn getgid() gid_t

std.os.linux.getgroups

function

Source line 2633

pub fn getgroups(size: usize, list: ?[*]gid_t) usize

Parameters

size: usize
list: ?[*]gid_t

std.os.linux.getitimer

function

Source line 3161

pub fn getitimer(which: i32, curr_value: *itimerspec) usize

Parameters

which: i32
curr_value: *itimerspec

std.os.linux.getpeername

function

Source line 2792

pub fn getpeername(fd: fd_t, noalias addr: *sockaddr, noalias len: *socklen_t) usize

Parameters

fd: fd_t
addr: *sockaddr
len: *socklen_t

std.os.linux.getpgid

function

Source line 2629

pub fn getpgid(pid: pid_t) usize

Parameters

pid: pid_t

std.os.linux.getpid

function

Source line 2657

pub fn getpid() pid_t

std.os.linux.getppid

function

Source line 2662

pub fn getppid() pid_t

std.os.linux.getrandom

function

Source line 2194

pub fn getrandom(buf: [*]u8, count: usize, flags: u32) usize

Parameters

buf: [*]u8
count: usize
flags: u32

std.os.linux.getresgid

function

Source line 2601

pub fn getresgid(rgid: *gid_t, egid: *gid_t, sgid: *gid_t) usize

Parameters

rgid: *gid_t
egid: *gid_t
sgid: *gid_t

std.os.linux.getresuid

function

Source line 2593

pub fn getresuid(ruid: *uid_t, euid: *uid_t, suid: *uid_t) usize

Parameters

ruid: *uid_t
euid: *uid_t
suid: *uid_t

std.os.linux.getrlimit

function

Source line 3277

pub fn getrlimit(resource: rlimit_resource, rlim: *rlimit) usize

Parameters

resource: rlimit_resource
rlim: *rlimit

std.os.linux.getrusage

function

Source line 3209

pub fn getrusage(who: i32, usage: *rusage) usize

Parameters

who: i32
usage: *rusage

std.os.linux.getsid

function

Source line 2653

pub fn getsid(pid: pid_t) usize

Parameters

pid: pid_t

std.os.linux.getsockname

function

Source line 2785

pub fn getsockname(fd: fd_t, noalias addr: *sockaddr, noalias len: *socklen_t) usize

Parameters

fd: fd_t
addr: *sockaddr
len: *socklen_t

std.os.linux.getsockopt

function

Source line 2813

pub fn getsockopt(fd: fd_t, level: i32, optname: u32, noalias optval: [*]u8, noalias optlen: *socklen_t) usize

Parameters

fd: fd_t
level: i32
optname: u32
optval: [*]u8
optlen: *socklen_t

std.os.linux.gettid

function

Source line 2667

pub fn gettid() pid_t

std.os.linux.gettimeofday

function

Source line 2487

pub fn gettimeofday(tv: ?*timeval, tz: ?*timezone) usize

Parameters

tv: ?*timeval
tz: ?*timezone

std.os.linux.getuid

function

Source line 2539

pub fn getuid() uid_t

std.os.linux.getxattr

function

Source line 2956

pub fn getxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]u8, size: usize) usize

Parameters

path: [*:0]const u8
name: [*:0]const u8
value: [*]u8
size: usize

std.os.linux.gid_t

type

Source line 122

std.os.linux.HOST_NAME_MAX

constant

Source line 8171

std.os.linux.HUGETLB_FLAG_ENCODE_16GB

constant

Source line 8462

std.os.linux.HUGETLB_FLAG_ENCODE_16MB

constant

Source line 8456

std.os.linux.HUGETLB_FLAG_ENCODE_1GB

constant

Source line 8460

std.os.linux.HUGETLB_FLAG_ENCODE_1MB

constant

Source line 8453

std.os.linux.HUGETLB_FLAG_ENCODE_256MB

constant

Source line 8458

std.os.linux.HUGETLB_FLAG_ENCODE_2GB

constant

Source line 8461

std.os.linux.HUGETLB_FLAG_ENCODE_2MB

constant

Source line 8454

std.os.linux.HUGETLB_FLAG_ENCODE_32MB

constant

Source line 8457

std.os.linux.HUGETLB_FLAG_ENCODE_512KB

constant

Source line 8452

std.os.linux.HUGETLB_FLAG_ENCODE_512MB

constant

Source line 8459

std.os.linux.HUGETLB_FLAG_ENCODE_64KB

constant

Source line 8451

std.os.linux.HUGETLB_FLAG_ENCODE_8MB

constant

Source line 8455

std.os.linux.HUGETLB_FLAG_ENCODE_MASK

constant

Source line 8450

std.os.linux.HUGETLB_FLAG_ENCODE_SHIFT

constant

Source line 8449

std.os.linux.HWCAP

type

Source line 621

std.os.linux.HWCAP.@"2"

namespace

Source line 672

std.os.linux.HWCAP.@"2"

namespace

Source line 785

std.os.linux.HWCAP.@"2"

namespace

Source line 861

std.os.linux.HWCAP.@"2"

namespace

Source line 946

std.os.linux.HWCAP.@"2".AES

constant

Source line 786

std.os.linux.HWCAP.@"2".AFP

constant

Source line 693

std.os.linux.HWCAP.@"2".ARCH_2_07

constant

Source line 878

std.os.linux.HWCAP.@"2".ARCH_3_00

constant

Source line 870

std.os.linux.HWCAP.@"2".ARCH_3_1

constant

Source line 865

std.os.linux.HWCAP.@"2".ARCH_3_2

constant

Source line 863

std.os.linux.HWCAP.@"2".BF16

constant

Source line 687

std.os.linux.HWCAP.@"2".BTI

constant

Source line 690

std.os.linux.HWCAP.@"2".CRC32

constant

Source line 790

std.os.linux.HWCAP.@"2".CSSC

constant

Source line 707

std.os.linux.HWCAP.@"2".DARN

constant

Source line 868

std.os.linux.HWCAP.@"2".DCPODP

constant

Source line 673

std.os.linux.HWCAP.@"2".DGH

constant

Source line 688

std.os.linux.HWCAP.@"2".DMF

constant

Source line 862

std.os.linux.HWCAP.@"2".DSCR

constant

Source line 876

std.os.linux.HWCAP.@"2".EBB

constant

Source line 875

std.os.linux.HWCAP.@"2".EBF16

constant

Source line 705

std.os.linux.HWCAP.@"2".ECV

constant

Source line 692

std.os.linux.HWCAP.@"2".F8CVT

constant

Source line 724

std.os.linux.HWCAP.@"2".F8DP2

constant

Source line 727

std.os.linux.HWCAP.@"2".F8DP4

constant

Source line 726

std.os.linux.HWCAP.@"2".F8E4M3

constant

Source line 728

std.os.linux.HWCAP.@"2".F8E5M2

constant

Source line 729

std.os.linux.HWCAP.@"2".F8FMA

constant

Source line 725

std.os.linux.HWCAP.@"2".FAMINMAX

constant

Source line 723

std.os.linux.HWCAP.@"2".FLAGM2

constant

Source line 680

std.os.linux.HWCAP.@"2".FPMR

constant

Source line 721

std.os.linux.HWCAP.@"2".FRINT

constant

Source line 681

std.os.linux.HWCAP.@"2".FSGSBASE

constant

Source line 948

std.os.linux.HWCAP.@"2".HAS_IEEE128

constant

Source line 869

std.os.linux.HWCAP.@"2".HBC

constant

Source line 717

std.os.linux.HWCAP.@"2".HTM

constant

Source line 877

std.os.linux.HWCAP.@"2".HTM_NO_SUSPEND

constant

Source line 866

std.os.linux.HWCAP.@"2".HTM_NOSC

constant

Source line 871

std.os.linux.HWCAP.@"2".I8MM

constant

Source line 686

std.os.linux.HWCAP.@"2".ISEL

constant

Source line 874

std.os.linux.HWCAP.@"2".LRCPC3

constant

Source line 719

std.os.linux.HWCAP.@"2".LSE128

constant

Source line 720

std.os.linux.HWCAP.@"2".LUT

constant

Source line 722

std.os.linux.HWCAP.@"2".MMA

constant

Source line 864

std.os.linux.HWCAP.@"2".MOPS

constant

Source line 716

std.os.linux.HWCAP.@"2".MTE

constant

Source line 691

std.os.linux.HWCAP.@"2".MTE3

constant

Source line 695

std.os.linux.HWCAP.@"2".PMULL

constant

Source line 787

std.os.linux.HWCAP.@"2".POE

constant

Source line 736

std.os.linux.HWCAP.@"2".RING3MWAIT

constant

Source line 947

std.os.linux.HWCAP.@"2".RNG

constant

Source line 689

std.os.linux.HWCAP.@"2".RPRES

constant

Source line 694

std.os.linux.HWCAP.@"2".RPRFM

constant

Source line 708

std.os.linux.HWCAP.@"2".SB

constant

Source line 791

std.os.linux.HWCAP.@"2".SCV

constant

Source line 867

std.os.linux.HWCAP.@"2".SHA1

constant

Source line 788

std.os.linux.HWCAP.@"2".SHA2

constant

Source line 789

std.os.linux.HWCAP.@"2".SME

constant

Source line 696

std.os.linux.HWCAP.@"2".SME_B16B16

constant

Source line 714

std.os.linux.HWCAP.@"2".SME_B16F32

constant

Source line 701

std.os.linux.HWCAP.@"2".SME_BI32I32

constant

Source line 713

std.os.linux.HWCAP.@"2".SME_F16F16

constant

Source line 715

std.os.linux.HWCAP.@"2".SME_F16F32

constant

Source line 700

std.os.linux.HWCAP.@"2".SME_F32F32

constant

Source line 702

std.os.linux.HWCAP.@"2".SME_F64F64

constant

Source line 698

std.os.linux.HWCAP.@"2".SME_F8F16

constant

Source line 731

std.os.linux.HWCAP.@"2".SME_F8F32

constant

Source line 732

std.os.linux.HWCAP.@"2".SME_FA64

constant

Source line 703

std.os.linux.HWCAP.@"2".SME_I16I32

constant

Source line 712

std.os.linux.HWCAP.@"2".SME_I16I64

constant

Source line 697

std.os.linux.HWCAP.@"2".SME_I8I32

constant

Source line 699

std.os.linux.HWCAP.@"2".SME_LUTV2

constant

Source line 730

std.os.linux.HWCAP.@"2".SME_SF8DP2

constant

Source line 735

std.os.linux.HWCAP.@"2".SME_SF8DP4

constant

Source line 734

std.os.linux.HWCAP.@"2".SME_SF8FMA

constant

Source line 733

std.os.linux.HWCAP.@"2".SME2

constant

Source line 710

std.os.linux.HWCAP.@"2".SME2P1

constant

Source line 711

std.os.linux.HWCAP.@"2".SSBS

constant

Source line 792

std.os.linux.HWCAP.@"2".SVE_B16B16

constant

Source line 718

std.os.linux.HWCAP.@"2".SVE_EBF16

constant

Source line 706

std.os.linux.HWCAP.@"2".SVE2

constant

Source line 674

std.os.linux.HWCAP.@"2".SVE2P1

constant

Source line 709

std.os.linux.HWCAP.@"2".SVEAES

constant

Source line 675

std.os.linux.HWCAP.@"2".SVEBF16

constant

Source line 685

std.os.linux.HWCAP.@"2".SVEBITPERM

constant

Source line 677

std.os.linux.HWCAP.@"2".SVEF32MM

constant

Source line 683

std.os.linux.HWCAP.@"2".SVEF64MM

constant

Source line 684

std.os.linux.HWCAP.@"2".SVEI8MM

constant

Source line 682

std.os.linux.HWCAP.@"2".SVEPMULL

constant

Source line 676

std.os.linux.HWCAP.@"2".SVESHA3

constant

Source line 678

std.os.linux.HWCAP.@"2".SVESM4

constant

Source line 679

std.os.linux.HWCAP.@"2".TAR

constant

Source line 873

std.os.linux.HWCAP.@"2".VEC_CRYPTO

constant

Source line 872

std.os.linux.HWCAP.@"2".WFXT

constant

Source line 704

std.os.linux.HWCAP.@"26BIT"

constant

Source line 758

std.os.linux.HWCAP.@"3"

namespace

Source line 739

std.os.linux.HWCAP.@"3".F16F32DOT

constant

Source line 749

std.os.linux.HWCAP.@"3".F16F32MM

constant

Source line 750

std.os.linux.HWCAP.@"3".F16MM

constant

Source line 748

std.os.linux.HWCAP.@"3".LS64

constant

Source line 743

std.os.linux.HWCAP.@"3".LSFE

constant

Source line 742

std.os.linux.HWCAP.@"3".MTE_FAR

constant

Source line 740

std.os.linux.HWCAP.@"3".MTE_STORE_ONLY

constant

Source line 741

std.os.linux.HWCAP.@"3".SME_LUT6

constant

Source line 746

std.os.linux.HWCAP.@"3".SME2P3

constant

Source line 747

std.os.linux.HWCAP.@"3".SVE_B16MM

constant

Source line 744

std.os.linux.HWCAP.@"3".SVE_LUT6

constant

Source line 751

std.os.linux.HWCAP.@"3".SVE2P3

constant

Source line 745

std.os.linux.HWCAP.@"32"

constant

Source line 859

std.os.linux.HWCAP.@"601_INSTR"

constant

Source line 857

std.os.linux.HWCAP.@"64"

constant

Source line 858

std.os.linux.HWCAP.ADI

constant

Source line 943

std.os.linux.HWCAP.AES

constant

Source line 626

std.os.linux.HWCAP.ARCH_2_05

constant

Source line 840

std.os.linux.HWCAP.ARCH_2_06

constant

Source line 836

std.os.linux.HWCAP.ASI_BLK_INIT

constant

Source line 931

std.os.linux.HWCAP.ASI_CACHE_SPARING

constant

Source line 939

std.os.linux.HWCAP.ASIMD

constant

Source line 624

std.os.linux.HWCAP.ASIMDBF16

constant

Source line 782

std.os.linux.HWCAP.ASIMDDP

constant

Source line 643

std.os.linux.HWCAP.ASIMDDP

constant

Source line 780

std.os.linux.HWCAP.ASIMDFHM

constant

Source line 646

std.os.linux.HWCAP.ASIMDFHM

constant

Source line 781

std.os.linux.HWCAP.ASIMDHP

constant

Source line 633

std.os.linux.HWCAP.ASIMDHP

constant

Source line 779

std.os.linux.HWCAP.ASIMDRDM

constant

Source line 635

std.os.linux.HWCAP.ATOMICS

constant

Source line 631

std.os.linux.HWCAP.BLKINIT

constant

Source line 922

std.os.linux.HWCAP.BOOKE

constant

Source line 843

std.os.linux.HWCAP.CBCOND

constant

Source line 941

std.os.linux.HWCAP.CELL

constant

Source line 844

std.os.linux.HWCAP.CMPBR

constant

Source line 656

std.os.linux.HWCAP.COMPLEX

constant

Source line 803

std.os.linux.HWCAP.CPUCFG

constant

Source line 796

std.os.linux.HWCAP.CPUID

constant

Source line 634

std.os.linux.HWCAP.CRC32

constant

Source line 630

std.os.linux.HWCAP.CRC32

constant

Source line 802

std.os.linux.HWCAP.CRC32

constant

Source line 817

std.os.linux.HWCAP.CRUNCH

constant

Source line 765

std.os.linux.HWCAP.CRYPTO

constant

Source line 804

std.os.linux.HWCAP.CRYPTO

constant

Source line 942

std.os.linux.HWCAP.DCPOP

constant

Source line 639

std.os.linux.HWCAP.DFLT

constant

Source line 909

std.os.linux.HWCAP.DFP

constant

Source line 897

std.os.linux.HWCAP.DIT

constant

Source line 647

std.os.linux.HWCAP.DIV32

constant

Source line 925

std.os.linux.HWCAP.DSP

constant

Source line 822

std.os.linux.HWCAP.DSP2

constant

Source line 823

std.os.linux.HWCAP.DSP3

constant

Source line 824

std.os.linux.HWCAP.EDSP

constant

Source line 762

std.os.linux.HWCAP.EIMM

constant

Source line 896

std.os.linux.HWCAP.ESAN3

constant

Source line 891

std.os.linux.HWCAP.ETF3EH

constant

Source line 899

std.os.linux.HWCAP.EVTSTRM

constant

Source line 625

std.os.linux.HWCAP.EVTSTRM

constant

Source line 777

std.os.linux.HWCAP.F8MM4

constant

Source line 659

std.os.linux.HWCAP.F8MM8

constant

Source line 658

std.os.linux.HWCAP.FAST_MULT

constant

Source line 759

std.os.linux.HWCAP.FCMA

constant

Source line 637

std.os.linux.HWCAP.FJFMAU

constant

Source line 937

std.os.linux.HWCAP.FLAGM

constant

Source line 650

std.os.linux.HWCAP.FLUSH

constant

Source line 916

std.os.linux.HWCAP.FMAF

constant

Source line 932

std.os.linux.HWCAP.FP

constant

Source line 623

std.os.linux.HWCAP.FPA

constant

Source line 760

std.os.linux.HWCAP.FPHP

constant

Source line 632

std.os.linux.HWCAP.FPHP

constant

Source line 778

std.os.linux.HWCAP.FPRCVT

constant

Source line 657

std.os.linux.HWCAP.FPU

constant

Source line 799

std.os.linux.HWCAP.FSMULD

constant

Source line 926

std.os.linux.HWCAP.GCS

constant

Source line 655

std.os.linux.HWCAP.GS

constant

Source line 905

std.os.linux.HWCAP.HALF

constant

Source line 756

std.os.linux.HWCAP.HAS_4xxMAC

constant

Source line 853

std.os.linux.HWCAP.HAS_ALTIVEC

constant

Source line 856

std.os.linux.HWCAP.HAS_DFP

constant

Source line 838

std.os.linux.HWCAP.HAS_EFP_DOUBLE

constant

Source line 849

std.os.linux.HWCAP.HAS_EFP_SINGLE

constant

Source line 850

std.os.linux.HWCAP.HAS_FPU

constant

Source line 855

std.os.linux.HWCAP.HAS_MMU

constant

Source line 854

std.os.linux.HWCAP.HAS_SPE

constant

Source line 851

std.os.linux.HWCAP.HAS_VSX

constant

Source line 835

std.os.linux.HWCAP.HIGH_GPRS

constant

Source line 900

std.os.linux.HWCAP.HPAGE

constant

Source line 898

std.os.linux.HWCAP.HPC

constant

Source line 934

std.os.linux.HWCAP.I8MM

constant

Source line 783

std.os.linux.HWCAP.ICACHE_SNOOP

constant

Source line 841

std.os.linux.HWCAP.IDIV

constant

Source line 775

std.os.linux.HWCAP.IDIVA

constant

Source line 772

std.os.linux.HWCAP.IDIVT

constant

Source line 773

std.os.linux.HWCAP.ILRCPC

constant

Source line 649

std.os.linux.HWCAP.IMA

constant

Source line 938

std.os.linux.HWCAP.ISA_A

constant

Source line 882

std.os.linux.HWCAP.ISA_C

constant

Source line 883

std.os.linux.HWCAP.ISA_D

constant

Source line 884

std.os.linux.HWCAP.ISA_F

constant

Source line 885

std.os.linux.HWCAP.ISA_I

constant

Source line 886

std.os.linux.HWCAP.ISA_M

constant

Source line 887

std.os.linux.HWCAP.ISA_V

constant

Source line 888

std.os.linux.HWCAP.IWMMXT

constant

Source line 764

std.os.linux.HWCAP.JAVA

constant

Source line 763

std.os.linux.HWCAP.JSCVT

constant

Source line 636

std.os.linux.HWCAP.LAM

constant

Source line 797

std.os.linux.HWCAP.LAM_BH

constant

Source line 812

std.os.linux.HWCAP.LASX

constant

Source line 801

std.os.linux.HWCAP.LBT_ARM

constant

Source line 807

std.os.linux.HWCAP.LBT_MIPS

constant

Source line 808

std.os.linux.HWCAP.LBT_X86

constant

Source line 806

std.os.linux.HWCAP.LDISP

constant

Source line 895

std.os.linux.HWCAP.LOONGSON_CPUCFG

constant

Source line 829

std.os.linux.HWCAP.LOONGSON_EXT

constant

Source line 827

std.os.linux.HWCAP.LOONGSON_EXT2

constant

Source line 828

std.os.linux.HWCAP.LOONGSON_MMI

constant

Source line 826

std.os.linux.HWCAP.LPAE

constant

Source line 776

std.os.linux.HWCAP.LRCPC

constant

Source line 638

std.os.linux.HWCAP.LSPW

constant

Source line 810

std.os.linux.HWCAP.LSX

constant

Source line 800

std.os.linux.HWCAP.LVZ

constant

Source line 805

std.os.linux.HWCAP.MDMX

constant

Source line 819

std.os.linux.HWCAP.MIPS16

constant

Source line 818

std.os.linux.HWCAP.MIPS16E2

constant

Source line 825

std.os.linux.HWCAP.MIPS3D

constant

Source line 820

std.os.linux.HWCAP.MSA

constant

Source line 816

std.os.linux.HWCAP.MSA

constant

Source line 894

std.os.linux.HWCAP.MUL32

constant

Source line 924

std.os.linux.HWCAP.MULDIV

constant

Source line 919

std.os.linux.HWCAP.N2

constant

Source line 923

std.os.linux.HWCAP.NEON

constant

Source line 767

std.os.linux.HWCAP.NNPA

constant

Source line 911

std.os.linux.HWCAP.NO_TB

constant

Source line 848

std.os.linux.HWCAP.PA6T

constant

Source line 839

std.os.linux.HWCAP.PACA

constant

Source line 653

std.os.linux.HWCAP.PACG

constant

Source line 654

std.os.linux.HWCAP.PAUSE

constant

Source line 940

std.os.linux.HWCAP.PCI_MIO

constant

Source line 912

std.os.linux.HWCAP.PMULL

constant

Source line 627

std.os.linux.HWCAP.POPC

constant

Source line 928

std.os.linux.HWCAP.POWER4

constant

Source line 847

std.os.linux.HWCAP.POWER5

constant

Source line 846

std.os.linux.HWCAP.POWER5_PLUS

constant

Source line 845

std.os.linux.HWCAP.POWER6_EXT

constant

Source line 837

std.os.linux.HWCAP.PPC_LE

constant

Source line 832

std.os.linux.HWCAP.PSERIES_PERFMON_COMPAT

constant

Source line 834

std.os.linux.HWCAP.PTW

constant

Source line 809

std.os.linux.HWCAP.R6

constant

Source line 815

std.os.linux.HWCAP.RANDOM

constant

Source line 935

std.os.linux.HWCAP.SB

constant

Source line 652

std.os.linux.HWCAP.SCQ

constant

Source line 811

std.os.linux.HWCAP.SHA1

constant

Source line 628

std.os.linux.HWCAP.SHA2

constant

Source line 629

std.os.linux.HWCAP.SHA3

constant

Source line 640

std.os.linux.HWCAP.SHA512

constant

Source line 644

std.os.linux.HWCAP.SIE

constant

Source line 913

std.os.linux.HWCAP.SM3

constant

Source line 641

std.os.linux.HWCAP.SM4

constant

Source line 642

std.os.linux.HWCAP.SMARTMIPS

constant

Source line 821

std.os.linux.HWCAP.SME_AES

constant

Source line 667

std.os.linux.HWCAP.SME_SBITPERM

constant

Source line 666

std.os.linux.HWCAP.SME_SFEXPA

constant

Source line 668

std.os.linux.HWCAP.SME_SMOP4

constant

Source line 670

std.os.linux.HWCAP.SME_STMOP

constant

Source line 669

std.os.linux.HWCAP.SME2P2

constant

Source line 665

std.os.linux.HWCAP.SMT

constant

Source line 842

std.os.linux.HWCAP.SORT

constant

Source line 908

std.os.linux.HWCAP.SSBS

constant

Source line 651

std.os.linux.HWCAP.STBAR

constant

Source line 917

std.os.linux.HWCAP.STFLE

constant

Source line 893

std.os.linux.HWCAP.SVE

constant

Source line 645

std.os.linux.HWCAP.SVE_AES2

constant

Source line 662

std.os.linux.HWCAP.SVE_BFSCALE

constant

Source line 663

std.os.linux.HWCAP.SVE_ELTPERM

constant

Source line 661

std.os.linux.HWCAP.SVE_F16MM

constant

Source line 660

std.os.linux.HWCAP.SVE2P2

constant

Source line 664

std.os.linux.HWCAP.SWAP

constant

Source line 918

std.os.linux.HWCAP.SWP

constant

Source line 755

std.os.linux.HWCAP.TE

constant

Source line 901

std.os.linux.HWCAP.THUMB

constant

Source line 757

std.os.linux.HWCAP.THUMBEE

constant

Source line 766

std.os.linux.HWCAP.TLS

constant

Source line 770

std.os.linux.HWCAP.TRANS

constant

Source line 936

std.os.linux.HWCAP.TRUE_LE

constant

Source line 833

std.os.linux.HWCAP.UAL

constant

Source line 798

std.os.linux.HWCAP.ULTRA3

constant

Source line 921

std.os.linux.HWCAP.UNIFIED_CACHE

constant

Source line 852

std.os.linux.HWCAP.USCAT

constant

Source line 648

std.os.linux.HWCAP.V8PLUS

constant

Source line 927

std.os.linux.HWCAP.V9

constant

Source line 920

std.os.linux.HWCAP.VFP

constant

Source line 761

std.os.linux.HWCAP.VFPD32

constant

Source line 774

std.os.linux.HWCAP.VFPv3

constant

Source line 768

std.os.linux.HWCAP.VFPv3D16

constant

Source line 769

std.os.linux.HWCAP.VFPv4

constant

Source line 771

std.os.linux.HWCAP.VIS

constant

Source line 929

std.os.linux.HWCAP.VIS2

constant

Source line 930

std.os.linux.HWCAP.VIS3

constant

Source line 933

std.os.linux.HWCAP.VXRS

constant

Source line 902

std.os.linux.HWCAP.VXRS_BCD

constant

Source line 903

std.os.linux.HWCAP.VXRS_EXT

constant

Source line 904

std.os.linux.HWCAP.VXRS_EXT2

constant

Source line 906

std.os.linux.HWCAP.VXRS_PDE

constant

Source line 907

std.os.linux.HWCAP.VXRS_PDE2

constant

Source line 910

std.os.linux.HWCAP.ZARCH

constant

Source line 892

std.os.linux.IFA

container

Source line 10348

Fields

UNSPEC
ADDRESS
LOCAL
LABEL
BROADCAST
ANYCAST
CACHEINFO
MULTICAST
FLAGS
RT_PRIORITY
TARGET_NETNSID
PROTO
_

std.os.linux.IFF

container

Source line 9290

Fields

UP: bool = false
BROADCAST: bool = false
DEBUG: bool = false
LOOPBACK: bool = false
POINTOPOINT: bool = false
NOTRAILERS: bool = false
RUNNING: bool = false
NOARP: bool = false
PROMISC: bool = false
_9: u7 = 0

std.os.linux.ifinfomsg

container

Source line 10316

Fields

family: u8
__pad1: u8 = 0
type: c_ushort

ARPHRD_*

index: c_int

Link index

flags: c_uint

IFF_* flags

change: c_uint

IFF_* change mask

std.os.linux.IFLA

container

Source line 10365

Fields

UNSPEC
ADDRESS
BROADCAST
IFNAME
MTU
LINK
QDISC
STATS
COST
PRIORITY
MASTER
WIRELESS

Wireless Extension event

PROTINFO

Protocol specific information for a link

TXQLEN
MAP
WEIGHT
OPERSTATE
LINKMODE
LINKINFO
NET_NS_PID
IFALIAS
NUM_VF

Number of VFs if device is SR-IOV PF

VFINFO_LIST
STATS64
VF_PORTS
PORT_SELF
AF_SPEC
GROUP

Group the device belongs to

NET_NS_FD
EXT_MASK

Extended info mask, VFs, etc

PROMISCUITY

Promiscuity count: > 0 means acts PROMISC

NUM_TX_QUEUES
NUM_RX_QUEUES
CARRIER
PHYS_PORT_ID
CARRIER_CHANGES
PHYS_SWITCH_ID
LINK_NETNSID
PHYS_PORT_NAME
PROTO_DOWN
GSO_MAX_SEGS
GSO_MAX_SIZE
PAD
XDP
EVENT
NEW_NETNSID
IF_NETNSID
CARRIER_UP_COUNT
CARRIER_DOWN_COUNT
NEW_IFINDEX
MIN_MTU
MAX_MTU
_

std.os.linux.IFLA.TARGET_NETNSID

constant

Source line 10439

IFLA

std.os.linux.ifmap

container

Source line 9303

Fields

mem_start: usize
mem_end: usize
base_addr: u16
irq: u8
dma: u8
port: u8

std.os.linux.IFNAMESIZE

constant

Source line 9288

std.os.linux.ifreq

container

Source line 9312

Fields

ifrn: extern union {
    name: [IFNAMESIZE]u8,
}
ifru: extern union {
    addr: sockaddr,
    dstaddr: sockaddr,
    broadaddr: sockaddr,
    netmask: sockaddr,
    hwaddr: sockaddr,
    flags: IFF,
    ivalue: i32,
    mtu: i32,
    map: ifmap,
    slave: [IFNAMESIZE - 1:0]u8,
    newname: [IFNAMESIZE - 1:0]u8,
    data: ?[*]u8,
}

std.os.linux.IN

namespace

Source line 6694

std.os.linux.in_pktinfo

container

Source line 5798

Fields

ifindex: i32
spec_dst: u32
addr: u32

std.os.linux.in_port_t

type

Source line 7067

std.os.linux.IN.ACCESS

constant

Source line 6698

std.os.linux.IN.ALL_EVENTS

constant

Source line 6712

std.os.linux.IN.ATTRIB

constant

Source line 6700

std.os.linux.IN.CLOEXEC

constant

Source line 6695

std.os.linux.IN.CLOSE

constant

Source line 6703

std.os.linux.IN.CLOSE_NOWRITE

constant

Source line 6702

std.os.linux.IN.CLOSE_WRITE

constant

Source line 6701

std.os.linux.IN.CREATE

constant

Source line 6708

std.os.linux.IN.DELETE

constant

Source line 6709

std.os.linux.IN.DELETE_SELF

constant

Source line 6710

std.os.linux.IN.DONT_FOLLOW

constant

Source line 6719

std.os.linux.IN.EXCL_UNLINK

constant

Source line 6720

std.os.linux.IN.IGNORED

constant

Source line 6716

std.os.linux.IN.ISDIR

constant

Source line 6724

std.os.linux.IN.MASK_ADD

constant

Source line 6722

std.os.linux.IN.MASK_CREATE

constant

Source line 6721

std.os.linux.IN.MODIFY

constant

Source line 6699

std.os.linux.IN.MOVE

constant

Source line 6707

std.os.linux.IN.MOVE_SELF

constant

Source line 6711

std.os.linux.IN.MOVED_FROM

constant

Source line 6705

std.os.linux.IN.MOVED_TO

constant

Source line 6706

std.os.linux.IN.NONBLOCK

constant

Source line 6696

std.os.linux.IN.ONESHOT

constant

Source line 6725

std.os.linux.IN.ONLYDIR

constant

Source line 6718

std.os.linux.IN.OPEN

constant

Source line 6704

std.os.linux.IN.Q_OVERFLOW

constant

Source line 6715

std.os.linux.IN.UNMOUNT

constant

Source line 6714

std.os.linux.in6_pktinfo

container

Source line 5805

Fields

addr: [16]u8
ifindex: i32

std.os.linux.init_vdso_clock_gettime

function

Source line 2451

fn init_vdso_clock_gettime(clk: clockid_t, ts: *timespec) callconv(.c) usize

Parameters

clk: clockid_t
ts: *timespec

std.os.linux.init_vdso_sys_riscv_hwprobe

function

Source line 3555

fn init_vdso_sys_riscv_hwprobe( pairs: [*]riscv_hwprobe, pair_count: usize, cpusetsize: usize, cpus: ?[*]cpu_set_t, flags: u32, ) callconv(.c) usize

Parameters

pairs: [*]riscv_hwprobe
pair_count: usize
cpusetsize: usize
cpus: ?[*]cpu_set_t
flags: u32

std.os.linux.ino_t

type

Source line 114

std.os.linux.inotify_add_watch

function

Source line 1339

pub fn inotify_add_watch(fd: fd_t, pathname: [*:0]const u8, mask: u32) usize

Parameters

fd: fd_t
pathname: [*:0]const u8
mask: u32

std.os.linux.inotify_event

container

Source line 7278

Fields

wd: i32
mask: u32
cookie: u32
len: u32

std.os.linux.inotify_event.getName

function

Source line 7288

pub fn getName(self: *const inotify_event) ?[:0]const u8

Parameters

self: *const inotify_event

std.os.linux.inotify_init1

function

Source line 1335

pub fn inotify_init1(flags: u32) usize

Parameters

flags: u32

std.os.linux.inotify_rm_watch

function

Source line 1343

pub fn inotify_rm_watch(fd: fd_t, wd: fd_t) usize

Parameters

fd: fd_t
wd: fd_t

std.os.linux.io_cqring_offsets

container

Source line 7843

Fields

head: u32
tail: u32
ring_mask: u32
ring_entries: u32
overflow: u32
cqes: u32
flags: u32
resv: u32
user_addr: u64

std.os.linux.io_sqring_offsets

container

Source line 7808

Filled with the offset for mmap(2)

Fields

head: u32

offset of ring head

tail: u32

offset of ring tail

ring_mask: u32

ring mask value

ring_entries: u32

entries in ring

flags: u32

ring flags

dropped: u32

number of sqes not submitted

array: u32

sqe index array

resv1: u32
user_addr: u64

std.os.linux.io_uring_buf

container

Source line 8102

Fields

addr: u64
len: u32
bid: u16
resv: u16

std.os.linux.io_uring_buf_reg

container

Source line 8117

argument for IORING_(UN)REGISTER_PBUF_RING

Fields

ring_addr: u64
ring_entries: u32
bgid: u16
flags: Flags
resv: [3]u64

std.os.linux.io_uring_buf_reg.Flags

container

Source line 8124

Fields

_0: u1 = 0
inc: bool

Incremental buffer consumption.

_: u14 = 0

std.os.linux.io_uring_buf_ring

container

Source line 8109

Fields

resv1: u64
resv2: u32
resv3: u16
tail: u16

std.os.linux.io_uring_cqe

container

Source line 7756

Fields

user_data: u64

io_uring_sqe.data submission passed back

res: i32

result code for this event

flags: u32

std.os.linux.io_uring_cqe.buffer_id

function

Source line 7776

pub fn buffer_id(self: io_uring_cqe) !u16

Parameters

self: io_uring_cqe

std.os.linux.io_uring_cqe.err

function

Source line 7766

pub fn err(self: io_uring_cqe) E

Parameters

self: io_uring_cqe

std.os.linux.io_uring_enter

function

Source line 3197

pub fn io_uring_enter(fd: fd_t, to_submit: u32, min_complete: u32, flags: u32, sig: ?*sigset_t) usize

Parameters

fd: fd_t
to_submit: u32
min_complete: u32
flags: u32
sig: ?*sigset_t

std.os.linux.io_uring_file_index_range

container

Source line 8150

Argument for IORING_REGISTER_FILE_ALLOC_RANGE The range is specified as [off, off + len)

Fields

off: u32
len: u32
resv: u64

std.os.linux.io_uring_files_update

container

Source line 7975

deprecated, see struct io_uring_rsrc_update

Fields

offset: u32
resv: u32
fds: u64

std.os.linux.io_uring_getevents_arg

container

Source line 8132

Fields

sigmask: u64
sigmask_sz: u32
pad: u32
ts: u64

std.os.linux.io_uring_napi

container

Source line 8020

Fields

busy_poll_to: u32
prefer_busy_poll: u8
_pad: [3]u8
resv: u64

std.os.linux.io_uring_notification_register

container

Source line 8012

Fields

nr_slots: u32
resv: u32
resv2: u64
data: u64
resv3: u64

std.os.linux.io_uring_notification_slot

container

Source line 8007

Fields

tag: u64
resv: [3]u64

std.os.linux.IO_URING_OP_SUPPORTED

constant

Source line 8030

std.os.linux.io_uring_params

container

Source line 7867

Fields

sq_entries: u32
cq_entries: u32
flags: u32
sq_thread_cpu: u32
sq_thread_idle: u32
features: u32
wq_fd: u32
resv: [3]u32
sq_off: io_sqring_offsets
cq_off: io_cqring_offsets

std.os.linux.io_uring_probe

container

Source line 8044

Fields

last_op: IORING_OP

Last opcode supported

ops_len: u8

Length of ops[] array below

resv: u16
resv2: [3]u32
ops: [256]io_uring_probe_op

std.os.linux.io_uring_probe_op

container

Source line 8032

Fields

op: IORING_OP
resv: u8
flags: u16

IO_URING_OP_* flags

resv2: u32

std.os.linux.io_uring_probe_op.is_supported

function

Source line 8039

pub fn is_supported(self: @This()) bool

Parameters

self: @This()

std.os.linux.io_uring_probe.is_supported

function

Source line 8054

Is the operation supported on the running kernel.

pub fn is_supported(self: @This(), op: IORING_OP) bool

Parameters

self: @This()
op: IORING_OP

std.os.linux.io_uring_recvmsg_out

container

Source line 8156

Fields

namelen: u32
controllen: u32
payloadlen: u32
flags: u32

std.os.linux.io_uring_register

function

Source line 3201

pub fn io_uring_register(fd: fd_t, opcode: IORING_REGISTER, arg: ?*const anyopaque, nr_args: u32) usize

Parameters

fd: fd_t
opcode: IORING_REGISTER
arg: ?*const anyopaque
nr_args: u32

std.os.linux.io_uring_restriction

container

Source line 8062

Fields

opcode: IORING_RESTRICTION
arg: extern union {
    /// IORING_RESTRICTION_REGISTER_OP
    register_op: IORING_REGISTER,

    /// IORING_RESTRICTION_SQE_OP
    sqe_op: IORING_OP,

    /// IORING_RESTRICTION_SQE_FLAGS_*
    sqe_flags: u8,
}
resv: u8
resv2: [3]u32

std.os.linux.io_uring_rsrc_register

container

Source line 7984

Fields

nr: u32
flags: u32
resv2: u64
data: u64
tags: u64

std.os.linux.io_uring_rsrc_update

container

Source line 7992

Fields

offset: u32
resv: u32
data: u64

std.os.linux.io_uring_rsrc_update2

container

Source line 7998

Fields

offset: u32
resv: u32
data: u64
tags: u64
nr: u32
resv2: u32

std.os.linux.io_uring_setup

function

Source line 3193

pub fn io_uring_setup(entries: u32, p: *io_uring_params) usize

Parameters

entries: u32
p: *io_uring_params

std.os.linux.IO_URING_SOCKET_OP

container

Source line 8095

Fields

SIOCIN = 0
SIOCOUTQ = 1
GETSOCKOPT = 2
SETSOCKOPT = 3

std.os.linux.io_uring_sqe

alias

Source line 7562

IO submission data structure (Submission Queue Entry)

Alias of std.os.linux.io_uring_sqe.io_uring_sqe

std.os.linux.io_uring_sync_cancel_reg

container

Source line 8140

Argument for IORING_REGISTER_SYNC_CANCEL

Fields

addr: u64
fd: i32
flags: u32
timeout: kernel_timespec
pad: [4]u64

std.os.linux.ioctl

function

Source line 3233

pub fn ioctl(fd: fd_t, request: u32, arg: usize) usize

Parameters

fd: fd_t
request: u32
arg: usize

std.os.linux.IOCTL

alias

Source line 128

Alias of std.os.linux.ioctl

std.os.linux.IORING_ACCEPT_MULTISHOT

constant

Source line 7736

accept flags stored in sqe->iopri

std.os.linux.IORING_ASYNC_CANCEL_ALL

constant

Source line 7708

Cancel all requests that match the given key

std.os.linux.IORING_ASYNC_CANCEL_ANY

constant

Source line 7712

Match any request

std.os.linux.IORING_ASYNC_CANCEL_FD

constant

Source line 7710

Key off 'fd' for cancelation rather than the request 'user_data'.

std.os.linux.IORING_ASYNC_CANCEL_FD_FIXED

constant

Source line 7714

'fd' passed in is a fixed descriptor. Available since Linux 6.0

std.os.linux.IORING_CQ_EVENTFD_DISABLED

constant

Source line 7858

disable eventfd notifications

std.os.linux.IORING_CQE_BUFFER_SHIFT

constant

Source line 7800

std.os.linux.IORING_CQE_F_32

constant

Source line 7798

std.os.linux.IORING_CQE_F_BUF_MORE

constant

Source line 7796

If set, the buffer ID set in the completion will get more completions.

std.os.linux.IORING_CQE_F_BUFFER

constant

Source line 7787

If set, the upper 16 bits are the buffer ID

std.os.linux.IORING_CQE_F_MORE

constant

Source line 7790

If set, parent SQE will generate more CQE entries. Available since Linux 5.13.

std.os.linux.IORING_CQE_F_NOTIF

constant

Source line 7794

Set for notification CQEs. Can be used to distinct them from sends.

std.os.linux.IORING_CQE_F_SKIP

constant

Source line 7797

std.os.linux.IORING_CQE_F_SOCK_NONEMPTY

constant

Source line 7792

If set, more data to read after socket recv

std.os.linux.IORING_ENTER_EXT_ARG

constant

Source line 7864

std.os.linux.IORING_ENTER_GETEVENTS

constant

Source line 7861

std.os.linux.IORING_ENTER_REGISTERED_RING

constant

Source line 7865

std.os.linux.IORING_ENTER_SQ_WAIT

constant

Source line 7863

std.os.linux.IORING_ENTER_SQ_WAKEUP

constant

Source line 7862

std.os.linux.IORING_FEAT_CQE_SKIP

constant

Source line 7893

std.os.linux.IORING_FEAT_CUR_PERSONALITY

constant

Source line 7886

std.os.linux.IORING_FEAT_EXT_ARG

constant

Source line 7890

std.os.linux.IORING_FEAT_FAST_POLL

constant

Source line 7887

std.os.linux.IORING_FEAT_LINKED_FILE

constant

Source line 7894

std.os.linux.IORING_FEAT_NATIVE_WORKERS

constant

Source line 7891

std.os.linux.IORING_FEAT_NODROP

constant

Source line 7883

std.os.linux.IORING_FEAT_POLL_32BITS

constant

Source line 7888

std.os.linux.IORING_FEAT_RSRC_TAGS

constant

Source line 7892

std.os.linux.IORING_FEAT_RW_CUR_POS

constant

Source line 7885

std.os.linux.IORING_FEAT_SINGLE_MMAP

constant

Source line 7882

std.os.linux.IORING_FEAT_SQPOLL_NONFIXED

constant

Source line 7889

std.os.linux.IORING_FEAT_SUBMIT_STABLE

constant

Source line 7884

std.os.linux.IORING_FILE_INDEX_ALLOC

constant

Source line 7572

If sqe->file_index is set to this for opcodes that instantiate a new direct descriptor (like openat/openat2/accept), then io_uring will allocate an available direct descriptor instead of having the application pass one in. The picked direct descriptor will be returned in cqe->res, or -ENFILE if the space is full. Available since Linux 5.19

std.os.linux.IORING_FSYNC_DATASYNC

constant

Source line 7679

std.os.linux.IORING_LINK_TIMEOUT_UPDATE

constant

Source line 7686

std.os.linux.IORING_MSG_RING_COMMAND

container

Source line 7739

IORING_OP_MSG_RING command types, stored in sqe->addr

Fields

DATA = 0

pass sqe->len as 'res' and off as user_data

SEND_FD = 1

send a registered fd to another ring

_

std.os.linux.IORING_MSG_RING_CQE_SKIP

constant

Source line 7750

Don't post a CQE to the target ring. Not applicable for IORING_MSG_DATA, obviously.

std.os.linux.IORING_MSG_RING_FLAGS_PASS

constant

Source line 7753

Pass through the flags from sqe->file_index (splice_fd_in in the zig struct) to cqe->flags */

std.os.linux.IORING_NOTIF_USAGE_ZC_COPIED

constant

Source line 7733

CQE.RES FOR IORING_CQE_F_NOTIF if IORING_SEND_ZC_REPORT_USAGE was requested

std.os.linux.IORING_OFF_CQ_RING

constant

Source line 7804

std.os.linux.IORING_OFF_SQ_RING

constant

Source line 7803

Magic offsets for the application to mmap the data it needs

std.os.linux.IORING_OFF_SQES

constant

Source line 7805

std.os.linux.IORING_OP

container

Source line 7610

Fields

NOP
READV
WRITEV
FSYNC
READ_FIXED
WRITE_FIXED
POLL_ADD
POLL_REMOVE
SYNC_FILE_RANGE
SENDMSG
RECVMSG
TIMEOUT
TIMEOUT_REMOVE
ACCEPT
ASYNC_CANCEL
LINK_TIMEOUT
CONNECT
FALLOCATE
OPENAT
CLOSE
FILES_UPDATE
STATX
READ
WRITE
FADVISE
MADVISE
SEND
RECV
OPENAT2
EPOLL_CTL
SPLICE
PROVIDE_BUFFERS
REMOVE_BUFFERS
TEE
SHUTDOWN
RENAMEAT
UNLINKAT
MKDIRAT
SYMLINKAT
LINKAT
MSG_RING
FSETXATTR
SETXATTR
FGETXATTR
GETXATTR
SOCKET
URING_CMD
SEND_ZC
SENDMSG_ZC
READ_MULTISHOT
WAITID
FUTEX_WAIT
FUTEX_WAKE
FUTEX_WAITV
FIXED_FD_INSTALL
FTRUNCATE
BIND
LISTEN
RECV_ZC
_

std.os.linux.IORING_POLL_ADD_LEVEL

constant

Source line 7703

std.os.linux.IORING_POLL_ADD_MULTI

constant

Source line 7699

Multishot poll. Sets IORING_CQE_F_MORE if the poll handler will continue to report CQEs on behalf of the same SQE.

std.os.linux.IORING_POLL_UPDATE_EVENTS

constant

Source line 7701

Update existing poll request, matching sqe->addr as the old user_data field.

std.os.linux.IORING_POLL_UPDATE_USER_DATA

constant

Source line 7702

std.os.linux.IORING_RECV_MULTISHOT

constant

Source line 7722

Multishot recv. Sets IORING_CQE_F_MORE if the handler will continue to report CQEs on behalf of the same SQE.

std.os.linux.IORING_RECVSEND_BUNDLE

constant

Source line 7731

If set, send or recv will grab as many buffers from the buffer group ID given and send them all. The completion result will be the number of buffers send, with the starting buffer ID in cqe as per usual. The buffers be contigious from the starting buffer ID. Used with IOSQE_BUFFER_SELECT.

std.os.linux.IORING_RECVSEND_FIXED_BUF

constant

Source line 7724

Use registered buffers, the index is stored in the buf_index field.

std.os.linux.IORING_RECVSEND_POLL_FIRST

constant

Source line 7720

If set, instead of first attempting to send or receive and arm poll if that yields an -EAGAIN result, arm poll upfront and skip the initial transfer attempt.

std.os.linux.IORING_REGISTER

container

Source line 7897

Fields

REGISTER_BUFFERS
UNREGISTER_BUFFERS
REGISTER_FILES
UNREGISTER_FILES
REGISTER_EVENTFD
UNREGISTER_EVENTFD
REGISTER_FILES_UPDATE
REGISTER_EVENTFD_ASYNC
REGISTER_PROBE
REGISTER_PERSONALITY
UNREGISTER_PERSONALITY
REGISTER_RESTRICTIONS
REGISTER_ENABLE_RINGS
REGISTER_FILES2
REGISTER_FILES_UPDATE2
REGISTER_BUFFERS2
REGISTER_BUFFERS_UPDATE
REGISTER_IOWQ_AFF
UNREGISTER_IOWQ_AFF
REGISTER_IOWQ_MAX_WORKERS
REGISTER_RING_FDS
UNREGISTER_RING_FDS
REGISTER_PBUF_RING
UNREGISTER_PBUF_RING
REGISTER_SYNC_CANCEL
REGISTER_FILE_ALLOC_RANGE
REGISTER_PBUF_STATUS
REGISTER_NAPI
UNREGISTER_NAPI
REGISTER_CLOCK
REGISTER_CLONE_BUFFERS
REGISTER_SEND_MSG_RING
REGISTER_ZCRX_IFQ
REGISTER_RESIZE_RINGS
REGISTER_MEM_REGION
REGISTER_USE_REGISTERED_RING = 1 << 31
_

std.os.linux.IORING_REGISTER_FILES_SKIP

constant

Source line 8028

Skip updating fd indexes set to this value in the fd table */

std.os.linux.IORING_RESTRICTION

container

Source line 8079

io_uring_restriction->opcode values

Fields

REGISTER_OP = 0

Allow an io_uring_register(2) opcode

SQE_OP = 1

Allow an sqe opcode

SQE_FLAGS_ALLOWED = 2

Allow sqe flags

SQE_FLAGS_REQUIRED = 3

Require sqe flags (these flags must be set on each submission)

_

std.os.linux.IORING_RSRC_REGISTER_SPARSE

constant

Source line 7982

Register a fully sparse file space, rather than pass in an array of all -1 file descriptors.

std.os.linux.IORING_SEND_ZC_REPORT_USAGE

constant

Source line 7726

If set, SEND[MSG]_ZC should report the zerocopy usage in cqe.res for the IORING_CQE_F_NOTIF cqe.

std.os.linux.IORING_SETUP_ATTACH_WQ

constant

Source line 7517

attach to existing wq

std.os.linux.IORING_SETUP_CLAMP

constant

Source line 7514

clamp SQ/CQ ring sizes

std.os.linux.IORING_SETUP_COOP_TASKRUN

constant

Source line 7530

Cooperative task running. When requests complete, they often require forcing the submitter to transition to the kernel to complete. If this flag is set, work will be done when the task transitions anyway, rather than force an inter-processor interrupt reschedule. This avoids interrupting a task running in userspace, and saves an IPI.

std.os.linux.IORING_SETUP_CQE32

constant

Source line 7540

CQEs are 32 byte

std.os.linux.IORING_SETUP_CQSIZE

constant

Source line 7511

app defines CQ size

std.os.linux.IORING_SETUP_DEFER_TASKRUN

constant

Source line 7548

Defer running task work to get events. Rather than running bits of task work whenever the task transitions try to do it just before it is needed.

std.os.linux.IORING_SETUP_IOPOLL

constant

Source line 7502

io_context is polled

std.os.linux.IORING_SETUP_NO_MMAP

constant

Source line 7551

Application provides ring memory

std.os.linux.IORING_SETUP_NO_SQARRAY

constant

Source line 7559

Removes indirection through the SQ index array.

std.os.linux.IORING_SETUP_R_DISABLED

constant

Source line 7520

start with ring disabled

std.os.linux.IORING_SETUP_REGISTERED_FD_ONLY

constant

Source line 7556

Register the ring fd in itself for use with IORING_REGISTER_USE_REGISTERED_RING; return a registered fd index rather than an fd.

std.os.linux.IORING_SETUP_SINGLE_ISSUER

constant

Source line 7543

Only one task is allowed to submit requests

std.os.linux.IORING_SETUP_SQ_AFF

constant

Source line 7508

sq_thread_cpu is valid

std.os.linux.IORING_SETUP_SQE128

constant

Source line 7538

SQEs are 128 byte

std.os.linux.IORING_SETUP_SQPOLL

constant

Source line 7505

SQ poll thread

std.os.linux.IORING_SETUP_SUBMIT_ALL

constant

Source line 7523

continue submit on error

std.os.linux.IORING_SETUP_TASKRUN_FLAG

constant

Source line 7535

If COOP_TASKRUN is set, get notified if task work is available for running and a kernel transition would be needed to run it. This sets IORING_SQ_TASKRUN in the sq ring flags. Not valid with COOP_TASKRUN.

std.os.linux.IORING_SPLICE_F_FD_IN_FIXED

constant

Source line 7693

std.os.linux.IORING_SQ_CQ_OVERFLOW

constant

Source line 7839

kernel has cqes waiting beyond the cq ring

std.os.linux.IORING_SQ_NEED_WAKEUP

constant

Source line 7837

needs io_uring_enter wakeup

std.os.linux.IORING_SQ_TASKRUN

constant

Source line 7841

task should enter the kernel

std.os.linux.IORING_TIMEOUT_ABS

constant

Source line 7682

std.os.linux.IORING_TIMEOUT_BOOTTIME

constant

Source line 7684

std.os.linux.IORING_TIMEOUT_CLOCK_MASK

constant

Source line 7688

std.os.linux.IORING_TIMEOUT_ETIME_SUCCESS

constant

Source line 7687

std.os.linux.IORING_TIMEOUT_REALTIME

constant

Source line 7685

std.os.linux.IORING_TIMEOUT_UPDATE

constant

Source line 7683

std.os.linux.IORING_TIMEOUT_UPDATE_MASK

constant

Source line 7689

std.os.linux.IORING_URING_CMD_FIXED

constant

Source line 7676

use registered buffer; pass thig flag along with setting sqe->buf_index.

std.os.linux.IOSQE_ASYNC

constant

Source line 7601

always go async

std.os.linux.IOSQE_BIT

container

Source line 7574

Fields

FIXED_FILE
IO_DRAIN
IO_LINK
IO_HARDLINK
ASYNC
BUFFER_SELECT
CQE_SKIP_SUCCESS
_

std.os.linux.IOSQE_BUFFER_SELECT

constant

Source line 7604

select buffer from buf_group

std.os.linux.IOSQE_CQE_SKIP_SUCCESS

constant

Source line 7608

don't post CQE if request succeeded Available since Linux 5.17

std.os.linux.IOSQE_FIXED_FILE

constant

Source line 7589

use fixed fileset

std.os.linux.IOSQE_IO_DRAIN

constant

Source line 7592

issue after inflight IO

std.os.linux.IOSQE_IO_HARDLINK

constant

Source line 7598

like LINK, but stronger

std.os.linux.IOSQE_IO_LINK

constant

Source line 7595

links next sqe

std.os.linux.IoUring

alias

Source line 7564

Alias of std.os.linux.IoUring

std.os.linux.IOV_MAX

constant

Source line 4469

std.os.linux.iovec

alias

Source line 22

Alias of std.posix.iovec

std.os.linux.iovec_const

alias

Source line 23

Alias of std.posix.iovec_const

std.os.linux.IOWQ_CATEGORIES

container

Source line 7969

io_uring_restriction->opcode values

Fields

BOUND
UNBOUND

std.os.linux.IP

namespace

Source line 5622

std.os.linux.IP.ADD_MEMBERSHIP

constant

Source line 5653

std.os.linux.IP.ADD_SOURCE_MEMBERSHIP

constant

Source line 5657

std.os.linux.IP.BIND_ADDRESS_NO_PORT

constant

Source line 5648

std.os.linux.IP.BLOCK_SOURCE

constant

Source line 5656

std.os.linux.IP.CHECKSUM

constant

Source line 5647

std.os.linux.IP.DEFAULT_MULTICAST_LOOP

constant

Source line 5673

std.os.linux.IP.DEFAULT_MULTICAST_TTL

constant

Source line 5672

std.os.linux.IP.DROP_MEMBERSHIP

constant

Source line 5654

std.os.linux.IP.DROP_SOURCE_MEMBERSHIP

constant

Source line 5658

std.os.linux.IP.FREEBIND

constant

Source line 5638

std.os.linux.IP.HDRINCL

constant

Source line 5625

std.os.linux.IP.IPSEC_POLICY

constant

Source line 5639

std.os.linux.IP.MAX_MEMBERSHIPS

constant

Source line 5674

std.os.linux.IP.MINTTL

constant

Source line 5645

std.os.linux.IP.MSFILTER

constant

Source line 5659

std.os.linux.IP.MTU

constant

Source line 5637

std.os.linux.IP.MTU_DISCOVER

constant

Source line 5633

std.os.linux.IP.MULTICAST_ALL

constant

Source line 5660

std.os.linux.IP.MULTICAST_IF

constant

Source line 5650

std.os.linux.IP.MULTICAST_LOOP

constant

Source line 5652

std.os.linux.IP.MULTICAST_TTL

constant

Source line 5651

std.os.linux.IP.NODEFRAG

constant

Source line 5646

std.os.linux.IP.OPTIONS

constant

Source line 5626

std.os.linux.IP.ORIGDSTADDR

constant

Source line 5643

std.os.linux.IP.PASSSEC

constant

Source line 5641

std.os.linux.IP.PKTINFO

constant

Source line 5630

std.os.linux.IP.PKTOPTIONS

constant

Source line 5631

std.os.linux.IP.PMTUDISC

constant

Source line 5632

std.os.linux.IP.PMTUDISC_DO

constant

Source line 5667

std.os.linux.IP.PMTUDISC_DONT

constant

Source line 5665

std.os.linux.IP.PMTUDISC_INTERFACE

constant

Source line 5669

std.os.linux.IP.PMTUDISC_OMIT

constant

Source line 5670

std.os.linux.IP.PMTUDISC_PROBE

constant

Source line 5668

std.os.linux.IP.PMTUDISC_WANT

constant

Source line 5666

std.os.linux.IP.RECVERR

constant

Source line 5634

std.os.linux.IP.RECVFRAGSIZE

constant

Source line 5649

std.os.linux.IP.RECVOPTS

constant

Source line 5628

std.os.linux.IP.RECVORIGDSTADDR

alias

Source line 5644

Alias of std.os.linux.IP.ORIGDSTADDR

std.os.linux.IP.RECVRETOPTS

alias

Source line 5663

Alias of std.os.linux.IP.RETOPTS

std.os.linux.IP.RECVTOS

constant

Source line 5636

std.os.linux.IP.RECVTTL

constant

Source line 5635

std.os.linux.IP.RETOPTS

constant

Source line 5629

std.os.linux.IP.ROUTER_ALERT

constant

Source line 5627

std.os.linux.IP.TOS

constant

Source line 5623

std.os.linux.IP.TRANSPARENT

constant

Source line 5642

std.os.linux.IP.TTL

constant

Source line 5624

std.os.linux.IP.UNBLOCK_SOURCE

constant

Source line 5655

std.os.linux.IP.UNICAST_IF

constant

Source line 5661

std.os.linux.IP.XFRM_POLICY

constant

Source line 5640

std.os.linux.IPPORT_RESERVED

constant

Source line 8350

std.os.linux.IPPROTO

namespace

Source line 8352

std.os.linux.IPPROTO.AH

constant

Source line 8371

std.os.linux.IPPROTO.BEETPH

constant

Source line 8376

std.os.linux.IPPROTO.COMP

constant

Source line 8379

std.os.linux.IPPROTO.DCCP

constant

Source line 8364

std.os.linux.IPPROTO.DSTOPTS

constant

Source line 8374

std.os.linux.IPPROTO.EGP

constant

Source line 8359

std.os.linux.IPPROTO.ENCAP

constant

Source line 8377

std.os.linux.IPPROTO.ESP

constant

Source line 8370

std.os.linux.IPPROTO.FRAGMENT

constant

Source line 8367

std.os.linux.IPPROTO.GRE

constant

Source line 8369

std.os.linux.IPPROTO.HOPOPTS

constant

Source line 8354

std.os.linux.IPPROTO.ICMP

constant

Source line 8355

std.os.linux.IPPROTO.ICMPV6

constant

Source line 8372

std.os.linux.IPPROTO.IDP

constant

Source line 8362

std.os.linux.IPPROTO.IGMP

constant

Source line 8356

std.os.linux.IPPROTO.IP

constant

Source line 8353

std.os.linux.IPPROTO.IPIP

constant

Source line 8357

std.os.linux.IPPROTO.IPV6

constant

Source line 8365

std.os.linux.IPPROTO.MAX

constant

Source line 8385

std.os.linux.IPPROTO.MH

constant

Source line 8381

std.os.linux.IPPROTO.MPLS

constant

Source line 8383

std.os.linux.IPPROTO.MTP

constant

Source line 8375

std.os.linux.IPPROTO.NONE

constant

Source line 8373

std.os.linux.IPPROTO.PIM

constant

Source line 8378

std.os.linux.IPPROTO.PUP

constant

Source line 8360

std.os.linux.IPPROTO.RAW

constant

Source line 8384

std.os.linux.IPPROTO.ROUTING

constant

Source line 8366

std.os.linux.IPPROTO.RSVP

constant

Source line 8368

std.os.linux.IPPROTO.SCTP

constant

Source line 8380

std.os.linux.IPPROTO.TCP

constant

Source line 8358

std.os.linux.IPPROTO.TP

constant

Source line 8363

std.os.linux.IPPROTO.UDP

constant

Source line 8361

std.os.linux.IPPROTO.UDPLITE

constant

Source line 8382

std.os.linux.IPTOS

namespace

Source line 5765

std.os.linux.IPTOS.LOWDELAY

constant

Source line 5774

std.os.linux.IPTOS.MINCOST

constant

Source line 5771

std.os.linux.IPTOS.PREC

function

Source line 5777

pub fn PREC(t: anytype) @TypeOf(t)

std.os.linux.IPTOS.PREC_CRITIC_ECP

constant

Source line 5786

std.os.linux.IPTOS.PREC_FLASH

constant

Source line 5784

std.os.linux.IPTOS.PREC_FLASHOVERRIDE

constant

Source line 5785

std.os.linux.IPTOS.PREC_IMMEDIATE

constant

Source line 5783

std.os.linux.IPTOS.PREC_INTERNETCONTROL

constant

Source line 5787

std.os.linux.IPTOS.PREC_MASK

constant

Source line 5776

std.os.linux.IPTOS.PREC_NETCONTROL

constant

Source line 5788

std.os.linux.IPTOS.PREC_PRIORITY

constant

Source line 5782

std.os.linux.IPTOS.PREC_ROUTINE

constant

Source line 5781

std.os.linux.IPTOS.RELIABILITY

constant

Source line 5772

std.os.linux.IPTOS.THROUGHPUT

constant

Source line 5773

std.os.linux.IPTOS.TOS

function

Source line 5767

pub fn TOS(t: anytype) @TypeOf(t)

std.os.linux.IPTOS.TOS_MASK

constant

Source line 5766

std.os.linux.IPV6

namespace

Source line 5678

IPv6 socket options

std.os.linux.IPV6.@"2292DSTOPTS"

constant

Source line 5682

std.os.linux.IPV6.@"2292HOPLIMIT"

constant

Source line 5686

std.os.linux.IPV6.@"2292HOPOPTS"

constant

Source line 5681

std.os.linux.IPV6.@"2292PKTINFO"

constant

Source line 5680

std.os.linux.IPV6.@"2292PKTOPTIONS"

constant

Source line 5684

std.os.linux.IPV6.@"2292RTHDR"

constant

Source line 5683

std.os.linux.IPV6.ADD_MEMBERSHIP

constant

Source line 5695

std.os.linux.IPV6.ADDR_PREFERENCES

constant

Source line 5743

std.os.linux.IPV6.ADDRFORM

constant

Source line 5679

std.os.linux.IPV6.AUTHHDR

constant

Source line 5688

std.os.linux.IPV6.AUTOFLOWLABEL

constant

Source line 5740

std.os.linux.IPV6.CHECKSUM

constant

Source line 5685

std.os.linux.IPV6.DONTFRAG

constant

Source line 5734

std.os.linux.IPV6.DROP_MEMBERSHIP

constant

Source line 5696

std.os.linux.IPV6.DSTOPTS

constant

Source line 5731

std.os.linux.IPV6.FLOWINFO

constant

Source line 5689

std.os.linux.IPV6.FLOWINFO_SEND

constant

Source line 5715

std.os.linux.IPV6.FLOWLABEL_MGR

constant

Source line 5714

std.os.linux.IPV6.FREEBIND

constant

Source line 5761

std.os.linux.IPV6.HDRINCL

constant

Source line 5718

std.os.linux.IPV6.HOPLIMIT

constant

Source line 5724

std.os.linux.IPV6.HOPOPTS

constant

Source line 5726

std.os.linux.IPV6.IPSEC_POLICY

constant

Source line 5716

std.os.linux.IPV6.JOIN_ANYCAST

constant

Source line 5702

std.os.linux.IPV6.LEAVE_ANYCAST

constant

Source line 5703

std.os.linux.IPV6.MINHOPCOUNT

constant

Source line 5754

std.os.linux.IPV6.MTU

constant

Source line 5699

std.os.linux.IPV6.MTU_DISCOVER

constant

Source line 5698

std.os.linux.IPV6.MULTICAST_HOPS

constant

Source line 5693

std.os.linux.IPV6.MULTICAST_IF

constant

Source line 5692

std.os.linux.IPV6.MULTICAST_LOOP

constant

Source line 5694

std.os.linux.IPV6.NEXTHOP

constant

Source line 5687

std.os.linux.IPV6.ORIGDSTADDR

constant

Source line 5756

std.os.linux.IPV6.PATHMTU

constant

Source line 5733

std.os.linux.IPV6.PKTINFO

constant

Source line 5722

std.os.linux.IPV6.PMTUDISC_DO

constant

Source line 5708

std.os.linux.IPV6.PMTUDISC_DONT

constant

Source line 5706

std.os.linux.IPV6.PMTUDISC_INTERFACE

constant

Source line 5710

std.os.linux.IPV6.PMTUDISC_OMIT

constant

Source line 5711

std.os.linux.IPV6.PMTUDISC_PROBE

constant

Source line 5709

std.os.linux.IPV6.PMTUDISC_WANT

constant

Source line 5707

std.os.linux.IPV6.PREFER_SRC_CGA

constant

Source line 5750

std.os.linux.IPV6.PREFER_SRC_COA

constant

Source line 5748

std.os.linux.IPV6.PREFER_SRC_HOME

constant

Source line 5749

std.os.linux.IPV6.PREFER_SRC_NONCGA

constant

Source line 5751

std.os.linux.IPV6.PREFER_SRC_PUBLIC

constant

Source line 5746

std.os.linux.IPV6.PREFER_SRC_PUBTMP_DEFAULT

constant

Source line 5747

std.os.linux.IPV6.PREFER_SRC_TMP

constant

Source line 5745

std.os.linux.IPV6.RECVDSTOPTS

constant

Source line 5730

std.os.linux.IPV6.RECVERR

constant

Source line 5700

std.os.linux.IPV6.RECVFRAGSIZE

constant

Source line 5760

std.os.linux.IPV6.RECVHOPLIMIT

constant

Source line 5723

std.os.linux.IPV6.RECVHOPOPTS

constant

Source line 5725

std.os.linux.IPV6.RECVORIGDSTADDR

alias

Source line 5757

Alias of std.os.linux.IPV6.ORIGDSTADDR

std.os.linux.IPV6.RECVPATHMTU

constant

Source line 5732

std.os.linux.IPV6.RECVPKTINFO

constant

Source line 5721

std.os.linux.IPV6.RECVRTHDR

constant

Source line 5728

std.os.linux.IPV6.RECVTCLASS

constant

Source line 5737

std.os.linux.IPV6.ROUTER_ALERT

constant

Source line 5697

std.os.linux.IPV6.RTHDR

constant

Source line 5729

std.os.linux.IPV6.RTHDRDSTOPTS

constant

Source line 5727

std.os.linux.IPV6.TCLASS

constant

Source line 5738

std.os.linux.IPV6.TRANSPARENT

constant

Source line 5758

std.os.linux.IPV6.UNICAST_HOPS

constant

Source line 5691

std.os.linux.IPV6.UNICAST_IF

constant

Source line 5759

std.os.linux.IPV6.V6ONLY

constant

Source line 5701

std.os.linux.IPV6.XFRM_POLICY

constant

Source line 5717

std.os.linux.is_hppa

constant

Source line 21

std.os.linux.is_loongarch

constant

Source line 16

std.os.linux.is_mips

constant

Source line 17

std.os.linux.is_ppc

constant

Source line 18

std.os.linux.is_riscv

constant

Source line 19

std.os.linux.is_sparc

constant

Source line 20

std.os.linux.issecure_mask

function

Source line 9866

fn issecure_mask(comptime x: comptime_int) comptime_int

Parameters

x: comptime_int

std.os.linux.ITIMER

container

Source line 3155

Fields

REAL = 0
VIRTUAL = 1
PROF = 2

std.os.linux.itimerspec

container

Source line 3131

Fields

it_interval: timespec
it_value: timespec

std.os.linux.k_sigaction

type

Source line 6986

Kernel sigaction struct, as expected by the rt_sigaction syscall. Includes restorer on targets where userspace is responsible for hooking up rt_sigreturn.

std.os.linux.k_sigaction_funcs

namespace

Source line 6979

std.os.linux.k_sigaction_funcs.handler

type

Source line 6980

std.os.linux.k_sigaction_funcs.restorer

type

Source line 6981

std.os.linux.kernel_fsid_t

alias

Source line 6875

Alias of std.os.linux.fsid_t

std.os.linux.kernel_rwf

type

Source line 4972

std.os.linux.kernel_timespec

container

Source line 9765

The timespec struct used by the kernel.

Fields

sec: i64
nsec: i64

std.os.linux.kernel_timespec.NOW

constant

Source line 9770

For use with utimensat and futimens.

timespec

std.os.linux.kernel_timespec.OMIT

constant

Source line 9776

For use with utimensat and futimens.

timespec

std.os.linux.kill

function

Source line 2198

pub fn kill(pid: pid_t, sig: SIG) usize

Parameters

pid: pid_t
sig: SIG

std.os.linux.lchown

function

Source line 2081

pub fn lchown(path: [*:0]const u8, owner: uid_t, group: gid_t) usize

Parameters

path: [*:0]const u8
owner: uid_t
group: gid_t

std.os.linux.lgetxattr

function

Source line 2960

pub fn lgetxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]u8, size: usize) usize

Parameters

path: [*:0]const u8
name: [*:0]const u8
value: [*]u8
size: usize

std.os.linux.linger

container

Source line 5792

Fields

onoff: i32
linger: i32

std.os.linux.link

function

Source line 2210

pub fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8) usize

Parameters

oldpath: [*:0]const u8
newpath: [*:0]const u8

std.os.linux.linkat

function

Source line 2229

pub fn linkat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8, flags: u32) usize

Parameters

oldfd: fd_t
oldpath: [*:0]const u8
newfd: fd_t
newpath: [*:0]const u8
flags: u32

std.os.linux.LINUX_REBOOT

namespace

Source line 2138

flags for the reboot' system call.

std.os.linux.LINUX_REBOOT.CMD

container

Source line 2155

Commands accepted by the _reboot() system call.

Fields

RESTART = 0x01234567

Restart system using default command and mode.

HALT = 0xCDEF0123

Stop OS and give system control to ROM monitor, if any.

CAD_ON = 0x89ABCDEF

Ctrl-Alt-Del sequence causes RESTART command.

CAD_OFF = 0x00000000

Ctrl-Alt-Del sequence sends SIGINT to init task.

POWER_OFF = 0x4321FEDC

Stop OS and remove all power from system, if possible.

RESTART2 = 0xA1B2C3D4

Restart system using given command string.

SW_SUSPEND = 0xD000FCE2

Suspend system using software suspend if compiled in.

KEXEC = 0x45584543

Restart system using a previously loaded Linux kernel

_

std.os.linux.LINUX_REBOOT.MAGIC1

container

Source line 2140

First magic value required to use _reboot() system call.

Fields

MAGIC1 = 0xfee1dead
_

std.os.linux.LINUX_REBOOT.MAGIC2

container

Source line 2146

Second magic value required to use _reboot() system call.

Fields

MAGIC2 = 672274793
MAGIC2A = 85072278
MAGIC2B = 369367448
MAGIC2C = 537993216
_

std.os.linux.listen

function

Source line 2888

pub fn listen(fd: fd_t, backlog: u32) usize

Parameters

fd: fd_t
backlog: u32

std.os.linux.listxattr

function

Source line 2944

pub fn listxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize

Parameters

path: [*:0]const u8
list: [*]u8
size: usize

std.os.linux.llistxattr

function

Source line 2948

pub fn llistxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize

Parameters

path: [*:0]const u8
list: [*]u8
size: usize

std.os.linux.llseek

function

Source line 2100

Can only be called on 32 bit systems. For 64 bit see lseek.

pub fn llseek(fd: fd_t, offset: off_t, result: ?*off_t, whence: u32) u32

Parameters

fd: fd_t
offset: off_t
result: ?*off_t
whence: u32

std.os.linux.lremovexattr

function

Source line 2984

pub fn lremovexattr(path: [*:0]const u8, name: [*:0]const u8) usize

Parameters

path: [*:0]const u8
name: [*:0]const u8

std.os.linux.lseek

function

Source line 2114

Can only be called on 64 bit systems. For 32 bit see llseek.

pub fn lseek(fd: fd_t, offset: off_t, whence: u32) u64

Parameters

fd: fd_t
offset: off_t
whence: u32

std.os.linux.lsetxattr

function

Source line 2972

pub fn lsetxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]const u8, size: usize, flags: usize) usize

Parameters

path: [*:0]const u8
name: [*:0]const u8
value: [*]const u8
size: usize
flags: usize

std.os.linux.ltchars

type

Source line 8971

std.os.linux.MADV

namespace

Source line 9704

std.os.linux.MADV.COLD

constant

Source line 9722

std.os.linux.MADV.DODUMP

constant

Source line 9719

std.os.linux.MADV.DOFORK

constant

Source line 9713

std.os.linux.MADV.DONTDUMP

constant

Source line 9718

std.os.linux.MADV.DONTFORK

constant

Source line 9712

std.os.linux.MADV.DONTNEED

constant

Source line 9709

std.os.linux.MADV.FREE

constant

Source line 9710

std.os.linux.MADV.HUGEPAGE

constant

Source line 9716

std.os.linux.MADV.HWPOISON

constant

Source line 9724

std.os.linux.MADV.KEEPONFORK

constant

Source line 9721

std.os.linux.MADV.MERGEABLE

constant

Source line 9714

std.os.linux.MADV.NOHUGEPAGE

constant

Source line 9717

std.os.linux.MADV.NORMAL

constant

Source line 9705

std.os.linux.MADV.PAGEOUT

constant

Source line 9723

std.os.linux.MADV.RANDOM

constant

Source line 9706

std.os.linux.MADV.REMOVE

constant

Source line 9711

std.os.linux.MADV.SEQUENTIAL

constant

Source line 9707

std.os.linux.MADV.SOFT_OFFLINE

constant

Source line 9725

std.os.linux.MADV.UNMERGEABLE

constant

Source line 9715

std.os.linux.MADV.WILLNEED

constant

Source line 9708

std.os.linux.MADV.WIPEONFORK

constant

Source line 9720

std.os.linux.madvise

function

Source line 3301

pub fn madvise(address: [*]u8, len: usize, advice: u32) usize

Parameters

address: [*]u8
len: usize
advice: u32

std.os.linux.MAP

type

Source line 175

std.os.linux.map_shadow_stack

function

Source line 3467

pub fn map_shadow_stack(addr: usize, size: usize, flags: u32) usize

Parameters

addr: usize
size: usize
flags: u32

std.os.linux.MAP_TYPE

container

Source line 168

Fields

SHARED = 0x01
PRIVATE = 0x02
SHARED_VALIDATE = 0x03
DROPPABLE = 0x08

std.os.linux.MAX_ADDR_LEN

constant

Source line 4473

Largest hardware address length e.g. a mac address is a type of hardware address

std.os.linux.maxInt

alias

Source line 9

Alias of std.math.maxInt

std.os.linux.MCL

type

Source line 1664

std.os.linux.memfd_create

function

Source line 3205

pub fn memfd_create(name: [*:0]const u8, flags: u32) usize

Parameters

name: [*:0]const u8
flags: u32

std.os.linux.MFD

namespace

Source line 8464

std.os.linux.MFD.ALL_FLAGS

constant

Source line 8468

std.os.linux.MFD.ALLOW_SEALING

constant

Source line 8466

std.os.linux.MFD.CLOEXEC

constant

Source line 8465

std.os.linux.MFD.HUGE_16GB

alias

Source line 8483

Alias of std.os.linux.HUGETLB_FLAG_ENCODE_16GB

std.os.linux.MFD.HUGE_16MB

alias

Source line 8477

Alias of std.os.linux.HUGETLB_FLAG_ENCODE_16MB

std.os.linux.MFD.HUGE_1GB

alias

Source line 8481

Alias of std.os.linux.HUGETLB_FLAG_ENCODE_1GB

std.os.linux.MFD.HUGE_1MB

alias

Source line 8474

Alias of std.os.linux.HUGETLB_FLAG_ENCODE_1MB

std.os.linux.MFD.HUGE_256MB

alias

Source line 8479

Alias of std.os.linux.HUGETLB_FLAG_ENCODE_256MB

std.os.linux.MFD.HUGE_2GB

alias

Source line 8482

Alias of std.os.linux.HUGETLB_FLAG_ENCODE_2GB

std.os.linux.MFD.HUGE_2MB

alias

Source line 8475

Alias of std.os.linux.HUGETLB_FLAG_ENCODE_2MB

std.os.linux.MFD.HUGE_32MB

alias

Source line 8478

Alias of std.os.linux.HUGETLB_FLAG_ENCODE_32MB

std.os.linux.MFD.HUGE_512KB

alias

Source line 8473

Alias of std.os.linux.HUGETLB_FLAG_ENCODE_512KB

std.os.linux.MFD.HUGE_512MB

alias

Source line 8480

Alias of std.os.linux.HUGETLB_FLAG_ENCODE_512MB

std.os.linux.MFD.HUGE_64KB

alias

Source line 8472

Alias of std.os.linux.HUGETLB_FLAG_ENCODE_64KB

std.os.linux.MFD.HUGE_8MB

alias

Source line 8476

Alias of std.os.linux.HUGETLB_FLAG_ENCODE_8MB

std.os.linux.MFD.HUGE_MASK

alias

Source line 8471

Alias of std.os.linux.HUGETLB_FLAG_ENCODE_MASK

std.os.linux.MFD.HUGE_SHIFT

alias

Source line 8470

Alias of std.os.linux.HUGETLB_FLAG_ENCODE_SHIFT

std.os.linux.MFD.HUGETLB

constant

Source line 8467

std.os.linux.mincore

function

Source line 3297

pub fn mincore(address: [*]u8, len: usize, vec: [*]u8) usize

Parameters

address: [*]u8
len: usize
vec: [*]u8

std.os.linux.MINSIGSTKSZ

constant

Source line 7321

std.os.linux.mkdir

function

Source line 1410

pub fn mkdir(path: [*:0]const u8, mode: mode_t) usize

Parameters

path: [*:0]const u8
mode: mode_t

std.os.linux.mkdirat

function

Source line 1418

pub fn mkdirat(dirfd: fd_t, path: [*:0]const u8, mode: mode_t) usize

Parameters

dirfd: fd_t
path: [*:0]const u8
mode: mode_t

std.os.linux.mknod

function

Source line 1422

pub fn mknod(path: [*:0]const u8, mode: mode_t, dev: dev_t) usize

Parameters

path: [*:0]const u8
mode: mode_t
dev: dev_t

std.os.linux.mknodat

function

Source line 1430

pub fn mknodat(dirfd: fd_t, path: [*:0]const u8, mode: mode_t, dev: dev_t) usize

Parameters

dirfd: fd_t
path: [*:0]const u8
mode: mode_t
dev: dev_t

std.os.linux.mlock

function

Source line 1647

pub fn mlock(address: [*]const u8, length: usize) usize

Parameters

address: [*]const u8
length: usize

std.os.linux.MLOCK

container

Source line 1655

Fields

ONFAULT: bool = false
_1: u31 = 0

std.os.linux.mlock2

function

Source line 1660

pub fn mlock2(address: [*]const u8, length: usize, flags: MLOCK) usize

Parameters

address: [*]const u8
length: usize
flags: MLOCK

std.os.linux.mlockall

function

Source line 1677

pub fn mlockall(flags: MCL) usize

Parameters

flags: MCL

std.os.linux.mmap

function

Source line 1577

pub fn mmap(address: ?[*]u8, length: usize, prot: PROT, flags: MAP, fd: fd_t, offset: off_t) usize

Parameters

address: ?[*]u8
length: usize
prot: PROT
flags: MAP
fd: fd_t
offset: off_t

std.os.linux.mmap2Unit

function

Source line 1569

fn mmap2Unit() u64

std.os.linux.mmsghdr

container

Source line 7156

Fields

hdr: msghdr
len: u32

std.os.linux.MNT

namespace

Source line 6686

std.os.linux.MNT.DETACH

constant

Source line 6688

std.os.linux.MNT.EXPIRE

constant

Source line 6689

std.os.linux.MNT.FORCE

constant

Source line 6687

std.os.linux.mode_t

type

Source line 115

std.os.linux.mount

function

Source line 1434

pub fn mount(special: ?[*:0]const u8, dir: [*:0]const u8, fstype: ?[*:0]const u8, flags: u32, data: usize) usize

Parameters

special: ?[*:0]const u8
dir: [*:0]const u8
fstype: ?[*:0]const u8
flags: u32
data: usize

std.os.linux.MOUNT_ATTR

container

Source line 1477

Fields

RELATIME: u0

Update atime relative to mtime/ctime.

RDONLY: bool

Mount read-only.

NOSUID: bool

Ignore suid and sgid bits.

NODEV: bool

Disallow access to device special files.

NOEXEC: bool

Disallow program execution.

NOATIME: bool

Do not update access times.

STRICTATIME: bool

Always perform atime updates.

_40: bool = false
NODIRATIME: bool

Do not update directory access times.

_100: u12 = 0
IDMAP: bool

Idmap mount to @userns_fd in struct mount_attr.

NOSYMFOLLOW: bool

Do not follow symlinks.

_: u10 = 0

std.os.linux.mount_setattr

function

Source line 1505

pub fn mount_setattr(dirfd: fd_t, path: [*:0]const u8, flags: MOUNT_ATTR) usize

Parameters

dirfd: fd_t
path: [*:0]const u8
flags: MOUNT_ATTR

std.os.linux.move_mount

function

Source line 1466

pub fn move_mount(from_dirfd: fd_t, from_path: [*:0]const u8, to_dirfd: fd_t, to_path: [*:0]const u8, flags: MOVE_MOUNT) usize

Parameters

from_dirfd: fd_t
from_path: [*:0]const u8
to_dirfd: fd_t
to_path: [*:0]const u8
flags: MOVE_MOUNT

std.os.linux.MOVE_MOUNT

container

Source line 1446

Fields

F_SYMLINKS: bool

Follow symlinks on from path.

F_AUTOMOUNTS: bool

Follow automounts on from path.

F_EMPTY_PATH: bool

Empty from path permitted.

_8: bool = false
T_SYMLINKS: bool

Follow symlinks on to path.

T_AUTOMOUNTS: bool

Follow automounts on to path.

T_EMPTY_PATH: bool

Empty to path permitted.

_80: bool = false
SET_GROUP: bool

Set sharing group instead.

_: u23 = 0

std.os.linux.mprotect

function

Source line 1613

pub fn mprotect(address: [*]const u8, length: usize, protection: PROT) usize

Parameters

address: [*]const u8
length: usize
protection: PROT

std.os.linux.mremap

function

Source line 1617

pub fn mremap(old_addr: ?[*]const u8, old_len: usize, new_len: usize, flags: MREMAP, new_addr: ?[*]const u8) usize

Parameters

old_addr: ?[*]const u8
old_len: usize
new_len: usize
flags: MREMAP
new_addr: ?[*]const u8

std.os.linux.MREMAP

container

Source line 382

Fields

MAYMOVE: bool = false
FIXED: bool = false
DONTUNMAP: bool = false
_: u29 = 0

std.os.linux.MS

namespace

Source line 6649

std.os.linux.MS.ACTIVE

constant

Source line 6677

std.os.linux.MS.BIND

constant

Source line 6660

std.os.linux.MS.BORN

constant

Source line 6676

std.os.linux.MS.DIRSYNC

constant

Source line 6657

std.os.linux.MS.I_VERSION

constant

Source line 6671

std.os.linux.MS.KERNMOUNT

constant

Source line 6670

std.os.linux.MS.LAZYTIME

constant

Source line 6673

std.os.linux.MS.MANDLOCK

constant

Source line 6656

std.os.linux.MS.MGC_MSK

constant

Source line 6683

std.os.linux.MS.MGC_VAL

constant

Source line 6682

std.os.linux.MS.MOVE

constant

Source line 6661

std.os.linux.MS.NOATIME

constant

Source line 6658

std.os.linux.MS.NODEV

constant

Source line 6652

std.os.linux.MS.NODIRATIME

constant

Source line 6659

std.os.linux.MS.NOEXEC

constant

Source line 6653

std.os.linux.MS.NOREMOTELOCK

constant

Source line 6674

std.os.linux.MS.NOSEC

constant

Source line 6675

std.os.linux.MS.NOSUID

constant

Source line 6651

std.os.linux.MS.NOUSER

constant

Source line 6678

std.os.linux.MS.POSIXACL

constant

Source line 6664

std.os.linux.MS.PRIVATE

constant

Source line 6666

std.os.linux.MS.RDONLY

constant

Source line 6650

std.os.linux.MS.REC

constant

Source line 6662

std.os.linux.MS.RELATIME

constant

Source line 6669

std.os.linux.MS.REMOUNT

constant

Source line 6655

std.os.linux.MS.RMT_MASK

constant

Source line 6680

std.os.linux.MS.SHARED

constant

Source line 6668

std.os.linux.MS.SILENT

constant

Source line 6663

std.os.linux.MS.SLAVE

constant

Source line 6667

std.os.linux.MS.STRICTATIME

constant

Source line 6672

std.os.linux.MS.SYNCHRONOUS

constant

Source line 6654

std.os.linux.MS.UNBINDABLE

constant

Source line 6665

std.os.linux.mseal

function

Source line 1635

Can only be called on 64 bit systems.

pub fn mseal(address: [*]const u8, length: usize, flags: usize) usize

Parameters

address: [*]const u8
length: usize
flags: usize

std.os.linux.MSF

namespace

Source line 1628

std.os.linux.MSF.ASYNC

constant

Source line 1629

std.os.linux.MSF.INVALIDATE

constant

Source line 1630

std.os.linux.MSF.SYNC

constant

Source line 1631

std.os.linux.MSG

namespace

Source line 6043

std.os.linux.MSG.BATCH

constant

Source line 6061

std.os.linux.MSG.CMSG_CLOEXEC

constant

Source line 6064

std.os.linux.MSG.CONFIRM

constant

Source line 6055

std.os.linux.MSG.CTRUNC

constant

Source line 6047

std.os.linux.MSG.DONTROUTE

constant

Source line 6046

std.os.linux.MSG.DONTWAIT

constant

Source line 6050

std.os.linux.MSG.EOR

constant

Source line 6051

std.os.linux.MSG.ERRQUEUE

constant

Source line 6057

std.os.linux.MSG.FASTOPEN

constant

Source line 6063

std.os.linux.MSG.FIN

constant

Source line 6053

std.os.linux.MSG.MORE

constant

Source line 6059

std.os.linux.MSG.NOSIGNAL

constant

Source line 6058

std.os.linux.MSG.OOB

constant

Source line 6044

std.os.linux.MSG.PEEK

constant

Source line 6045

std.os.linux.MSG.PROXY

constant

Source line 6048

std.os.linux.MSG.RST

constant

Source line 6056

std.os.linux.MSG.SYN

constant

Source line 6054

std.os.linux.MSG.TRUNC

constant

Source line 6049

std.os.linux.MSG.WAITALL

constant

Source line 6052

std.os.linux.MSG.WAITFORONE

constant

Source line 6060

std.os.linux.MSG.ZEROCOPY

constant

Source line 6062

std.os.linux.msghdr

container

Source line 11217

Fields

name: ?*sockaddr
namelen: socklen_t
iov: [*]iovec
iovlen: usize

The kernel and glibc use usize for this field; POSIX and musl use c_int.

control: ?*anyopaque
controllen: usize

The kernel and glibc use usize for this field; POSIX and musl use socklen_t.

flags: u32

std.os.linux.msghdr_const

container

Source line 11229

Fields

name: ?*const sockaddr
namelen: socklen_t
iov: [*]const iovec_const
iovlen: usize
control: ?*const anyopaque
controllen: usize
flags: u32

std.os.linux.msync

function

Source line 1639

pub fn msync(address: [*]const u8, length: usize, flags: i32) usize

Parameters

address: [*]const u8
length: usize
flags: i32

std.os.linux.munlock

function

Source line 1651

pub fn munlock(address: [*]const u8, length: usize) usize

Parameters

address: [*]const u8
length: usize

std.os.linux.munlockall

function

Source line 1681

pub fn munlockall() usize

std.os.linux.munmap

function

Source line 1643

pub fn munmap(address: [*]const u8, length: usize) usize

Parameters

address: [*]const u8
length: usize

std.os.linux.NAME_MAX

constant

Source line 4467

std.os.linux.name_to_handle_at

function

Source line 1381

pub fn name_to_handle_at( dirfd: fd_t, pathname: [*:0]const u8, handle: *file_handle, mount_id: *i32, flags: u32, ) usize

Parameters

dirfd: fd_t
pathname: [*:0]const u8
handle: *file_handle
mount_id: *i32
flags: u32

std.os.linux.nanosleep

function

Source line 2495

pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize

Parameters

req: *const timespec
rem: ?*timespec

std.os.linux.native_abi

constant

Source line 14

std.os.linux.native_arch

constant

Source line 13

std.os.linux.native_endian

constant

Source line 15

std.os.linux.NCC

constant

Source line 8510

std.os.linux.NCCS

constant

Source line 8511

std.os.linux.NETLINK

namespace

Source line 10072

std.os.linux.NETLINK.AUDIT

constant

Source line 10101

auditing

std.os.linux.NETLINK.CONNECTOR

constant

Source line 10105

std.os.linux.NETLINK.CRYPTO

constant

Source line 10130

Crypto layer

std.os.linux.NETLINK.DNRTMSG

constant

Source line 10113

DECnet routing messages

std.os.linux.NETLINK.ECRYPTFS

constant

Source line 10125

std.os.linux.NETLINK.FIB_LOOKUP

constant

Source line 10103

std.os.linux.NETLINK.FIREWALL

constant

Source line 10083

Unused number, formerly ip_queue

std.os.linux.NETLINK.GENERIC

constant

Source line 10118

std.os.linux.NETLINK.IP6_FW

constant

Source line 10110

std.os.linux.NETLINK.ISCSI

constant

Source line 10098

Open-iSCSI

std.os.linux.NETLINK.KOBJECT_UEVENT

constant

Source line 10116

Kernel messages to userspace

std.os.linux.NETLINK.NETFILTER

constant

Source line 10108

netfilter subsystem

std.os.linux.NETLINK.NFLOG

constant

Source line 10089

netfilter/iptables ULOG

std.os.linux.NETLINK.RDMA

constant

Source line 10127

std.os.linux.NETLINK.ROUTE

constant

Source line 10074

Routing/device hook

std.os.linux.NETLINK.SCSITRANSPORT

constant

Source line 10123

SCSI Transports

std.os.linux.NETLINK.SELINUX

constant

Source line 10095

SELinux event notifications

std.os.linux.NETLINK.SMC

constant

Source line 10133

SMC monitoring

std.os.linux.NETLINK.SOCK_DIAG

constant

Source line 10086

socket monitoring

std.os.linux.NETLINK.UNUSED

constant

Source line 10077

Unused number

std.os.linux.NETLINK.USERSOCK

constant

Source line 10080

Reserved for user mode socket protocols

std.os.linux.NETLINK.XFRM

constant

Source line 10092

ipsec

std.os.linux.NetlinkMessageType

container

Source line 10195

Fields

NOOP = 0x1

Nothing.

ERROR = 0x2

Error

DONE = 0x3

End of a dump

OVERRUN = 0x4

Data lost

RTM_NEWLINK = 16
RTM_DELLINK
RTM_GETLINK
RTM_SETLINK
RTM_NEWADDR = 20
RTM_DELADDR
RTM_GETADDR
RTM_NEWROUTE = 24
RTM_DELROUTE
RTM_GETROUTE
RTM_NEWNEIGH = 28
RTM_DELNEIGH
RTM_GETNEIGH
RTM_NEWRULE = 32
RTM_DELRULE
RTM_GETRULE
RTM_NEWQDISC = 36
RTM_DELQDISC
RTM_GETQDISC
RTM_NEWTCLASS = 40
RTM_DELTCLASS
RTM_GETTCLASS
RTM_NEWTFILTER = 44
RTM_DELTFILTER
RTM_GETTFILTER
RTM_NEWACTION = 48
RTM_DELACTION
RTM_GETACTION
RTM_NEWPREFIX = 52
RTM_GETMULTICAST = 58
RTM_GETANYCAST = 62
RTM_NEWNEIGHTBL = 64
RTM_GETNEIGHTBL = 66
RTM_SETNEIGHTBL
RTM_NEWNDUSEROPT = 68
RTM_NEWADDRLABEL = 72
RTM_DELADDRLABEL
RTM_GETADDRLABEL
RTM_GETDCB = 78
RTM_SETDCB
RTM_NEWNETCONF = 80
RTM_DELNETCONF
RTM_GETNETCONF = 82
RTM_NEWMDB = 84
RTM_DELMDB = 85
RTM_GETMDB = 86
RTM_NEWNSID = 88
RTM_DELNSID = 89
RTM_GETNSID = 90
RTM_NEWSTATS = 92
RTM_GETSTATS = 94
RTM_NEWCACHEREPORT = 96
RTM_NEWCHAIN = 100
RTM_DELCHAIN
RTM_GETCHAIN
RTM_NEWNEXTHOP = 104
RTM_DELNEXTHOP
RTM_GETNEXTHOP
_

std.os.linux.NetlinkMessageType.MIN_TYPE

constant

Source line 10197

< 0x10: reserved control messages

std.os.linux.nfds_t

type

Source line 8431

std.os.linux.NLDLY

type

Source line 8666

std.os.linux.nlink_t

type

Source line 116

std.os.linux.NLM_F_ACK

constant

Source line 10145

Reply with ack, with zero or error code

std.os.linux.NLM_F_ACK_TLVS

constant

Source line 10193

extended ACK TVLs were included

std.os.linux.NLM_F_APPEND

constant

Source line 10180

Add to end of list

std.os.linux.NLM_F_ATOMIC

constant

Source line 10165

atomic GET

std.os.linux.NLM_F_CAPPED

constant

Source line 10190

request was capped

std.os.linux.NLM_F_CREATE

constant

Source line 10177

Create, if it does not exist

std.os.linux.NLM_F_DUMP

constant

Source line 10166

std.os.linux.NLM_F_DUMP_FILTERED

constant

Source line 10154

Dump was filtered as requested

std.os.linux.NLM_F_DUMP_INTR

constant

Source line 10151

Dump was inconsistent due to sequence change

std.os.linux.NLM_F_ECHO

constant

Source line 10148

Echo this request

std.os.linux.NLM_F_EXCL

constant

Source line 10174

Do not touch, if it exists

std.os.linux.NLM_F_MATCH

constant

Source line 10162

return all matching

std.os.linux.NLM_F_MULTI

constant

Source line 10142

Multipart message, terminated by NLMSG_DONE

std.os.linux.NLM_F_NONREC

constant

Source line 10185

Do not delete recursively

std.os.linux.NLM_F_REPLACE

constant

Source line 10171

Override existing

std.os.linux.NLM_F_REQUEST

constant

Source line 10139

It is request message.

std.os.linux.NLM_F_ROOT

constant

Source line 10159

specify tree root

std.os.linux.nlmsghdr

container

Source line 10299

Netlink message header Specified in RFC 3549 Section 2.3.2

Fields

len: u32

Length of message including header

type: NetlinkMessageType

Message content

flags: u16

Additional flags

seq: u32

Sequence number

pid: u32

Sending process port ID

std.os.linux.NSIG

constant

Source line 2726

Defined as one greater than the largest defined signal number.

std.os.linux.O

type

Source line 389

std.os.linux.off_t

type

Source line 117

std.os.linux.open

function

Source line 1992

pub fn open(path: [*:0]const u8, flags: O, perm: mode_t) usize

Parameters

path: [*:0]const u8
flags: O
perm: mode_t

std.os.linux.openat

function

Source line 2010

pub fn openat(dirfd: fd_t, path: [*:0]const u8, flags: O, mode: mode_t) usize

Parameters

dirfd: fd_t
path: [*:0]const u8
flags: O
mode: mode_t

std.os.linux.P

container

Source line 4694

Fields

ALL = 0
PID = 1
PGID = 2
PIDFD = 3
_

std.os.linux.PACKET

namespace

Source line 9332

std.os.linux.PACKET.ADD_MEMBERSHIP

constant

Source line 9342

std.os.linux.PACKET.AUXDATA

constant

Source line 9348

std.os.linux.PACKET.BROADCAST

constant

Source line 9334

std.os.linux.PACKET.COPY_THRESH

constant

Source line 9347

std.os.linux.PACKET.DROP_MEMBERSHIP

constant

Source line 9343

std.os.linux.PACKET.FANOUT

constant

Source line 9358

std.os.linux.PACKET.FANOUT_CBPF

constant

Source line 9372

std.os.linux.PACKET.FANOUT_CPU

constant

Source line 9368

std.os.linux.PACKET.FANOUT_DATA

constant

Source line 9362

std.os.linux.PACKET.FANOUT_EBPF

constant

Source line 9373

std.os.linux.PACKET.FANOUT_FLAG_DEFRAG

constant

Source line 9377

std.os.linux.PACKET.FANOUT_FLAG_IGNORE_OUTGOING

constant

Source line 9376

std.os.linux.PACKET.FANOUT_FLAG_ROLLOVER

constant

Source line 9374

std.os.linux.PACKET.FANOUT_FLAG_UNIQUEID

constant

Source line 9375

std.os.linux.PACKET.FANOUT_HASH

constant

Source line 9366

std.os.linux.PACKET.FANOUT_LB

constant

Source line 9367

std.os.linux.PACKET.FANOUT_QM

constant

Source line 9371

std.os.linux.PACKET.FANOUT_RND

constant

Source line 9370

std.os.linux.PACKET.FANOUT_ROLLOVER

constant

Source line 9369

std.os.linux.PACKET.HDRLEN

constant

Source line 9351

std.os.linux.PACKET.HOST

constant

Source line 9333

std.os.linux.PACKET.IGNORE_OUTGOING

constant

Source line 9363

std.os.linux.PACKET.KERNEL

constant

Source line 9340

std.os.linux.PACKET.LOOPBACK

constant

Source line 9338

std.os.linux.PACKET.LOSS

constant

Source line 9354

std.os.linux.PACKET.MULTICAST

constant

Source line 9335

std.os.linux.PACKET.ORIGDEV

constant

Source line 9349

std.os.linux.PACKET.OTHERHOST

constant

Source line 9336

std.os.linux.PACKET.OUTGOING

constant

Source line 9337

std.os.linux.PACKET.QDISC_BYPASS

constant

Source line 9360

std.os.linux.PACKET.RECV_OUTPUT

constant

Source line 9344

std.os.linux.PACKET.RESERVE

constant

Source line 9352

std.os.linux.PACKET.ROLLOVER_STATS

constant

Source line 9361

std.os.linux.PACKET.RX_RING

constant

Source line 9345

std.os.linux.PACKET.STATISTICS

constant

Source line 9346

std.os.linux.PACKET.TIMESTAMP

constant

Source line 9357

std.os.linux.PACKET.TX_HAS_OFF

constant

Source line 9359

std.os.linux.PACKET.TX_RING

constant

Source line 9353

std.os.linux.PACKET.TX_TIMESTAMP

constant

Source line 9356

std.os.linux.PACKET.USER

constant

Source line 9339

std.os.linux.PACKET.VERSION

constant

Source line 9350

std.os.linux.PACKET.VNET_HDR

constant

Source line 9355

std.os.linux.PACKET.VNET_HDR_SZ

constant

Source line 9364

std.os.linux.PATH_MAX

constant

Source line 4468

std.os.linux.pause

function

Source line 2499

pub fn pause() usize

std.os.linux.PERF

namespace

Source line 10836

std.os.linux.perf_event_attr

container

Source line 10581

Fields

type: PERF.TYPE = undefined

Major type: hardware/software/tracepoint/etc.

size: u32 = @sizeOf(perf_event_attr)

Size of the attr structure, for fwd/bwd compat.

config: u64 = 0

Type specific configuration information.

sample_period_or_freq: u64 = 0
sample_type: u64 = 0
read_format: u64 = 0
flags: packed struct(u64) {
    /// off by default
    disabled: bool = false,
    /// children inherit it
    inherit: bool = false,
    /// must always be on PMU
    pinned: bool = false,
    /// only group on PMU
    exclusive: bool = false,
    /// don't count user
    exclude_user: bool = false,
    /// ditto kernel
    exclude_kernel: bool = false,
    /// ditto hypervisor
    exclude_hv: bool = false,
    /// don't count when idle
    exclude_idle: bool = false,
    /// include mmap data
    mmap: bool = false,
    /// include comm data
    comm: bool = false,
    /// use freq, not period
    freq: bool = false,
    /// per task counts
    inherit_stat: bool = false,
    /// next exec enables
    enable_on_exec: bool = false,
    /// trace fork/exit
    task: bool = false,
    /// wakeup_watermark
    watermark: bool = false,
    /// precise_ip:
    ///
    ///  0 - SAMPLE_IP can have arbitrary skid
    ///  1 - SAMPLE_IP must have constant skid
    ///  2 - SAMPLE_IP requested to have 0 skid
    ///  3 - SAMPLE_IP must have 0 skid
    ///
    ///  See also PERF_RECORD_MISC_EXACT_IP
    /// skid constraint
    precise_ip: u2 = 0,
    /// non-exec mmap data
    mmap_data: bool = false,
    /// sample_type all events
    sample_id_all: bool = false,

    /// don't count in host
    exclude_host: bool = false,
    /// don't count in guest
    exclude_guest: bool = false,

    /// exclude kernel callchains
    exclude_callchain_kernel: bool = false,
    /// exclude user callchains
    exclude_callchain_user: bool = false,
    /// include mmap with inode data
    mmap2: bool = false,
    /// flag comm events that are due to an exec
    comm_exec: bool = false,
    /// use @clockid for time fields
    use_clockid: bool = false,
    /// context switch data
    context_switch: bool = false,
    /// Write ring buffer from end to beginning
    write_backward: bool = false,
    /// include namespaces data
    namespaces: bool = false,
    /// include ksymbol events
    ksymbol: bool = false,
    /// include BPF events
    bpf_event: bool = false,
    /// generate AUX records instead of events
    aux_output: bool = false,
    /// include cgroup events
    cgroup: bool = false,
    /// include text poke events
    text_poke: bool = false,
    /// use build ID in mmap2 events
    build_id: bool = false,
    /// children only inherit if cloned with CLONE_THREAD
    inherit_thread: bool = false,
    /// event is removed from task on exec
    remove_on_exec: bool = false,
    /// send synchronous SIGTRAP on event
    sigtrap: bool = false,

    __reserved_1: u26 = 0,
} = .{}
wakeup_events_or_watermark: u32 = 0

wakeup every n events, or bytes before wakeup

bp_type: u32 = 0
config1: u64 = 0

This field is also used for: bp_addr kprobe_func for perf_kprobe uprobe_path for perf_uprobe

config2: u64 = 0

This field is also used for: bp_len kprobe_addr when kprobe_func == null probe_offset for perf_[k,u]probe

branch_sample_type: u64 = 0

enum perf_branch_sample_type

sample_regs_user: u64 = 0

Defines set of user regs to dump on samples. See asm/perf_regs.h for details.

sample_stack_user: u32 = 0

Defines size of the user stack to dump on samples.

clockid: clockid_t = .REALTIME
sample_regs_intr: u64 = 0

Defines set of regs to dump for each sample state captured on:

  • precise = 0: PMU interrupt
  • precise > 0: sampled instruction

See asm/perf_regs.h for details.

aux_watermark: u32 = 0

Wakeup watermark for AUX area

sample_max_stack: u16 = 0
__reserved_2: u16 = 0

Align to u64

aux_sample_size: u32 = 0
aux_action: packed struct(u32) {
    /// start AUX area tracing paused
    start_paused: bool = false,
    /// on overflow, pause AUX area tracing
    pause: bool = false,
    /// on overflow, resume AUX area tracing
    @"resume": bool = false,

    __reserved_3: u29 = 0,
} = .{}
sig_data: u64 = 0

User provided data if sigtrap == true

config3: u64 = 0

Extension of config2

std.os.linux.perf_event_header

container

Source line 10742

Fields

type: PERF.RECORD

Event type: sample/mmap/fork/etc.

misc: packed struct(u16) {
    cpu_mode: PERF.RECORD.MISC.CPU_MODE,
    _: u9,
    PROC_MAP_PARSE_TIMEOUT: bool,
    bit13: packed union {
        MMAP_DATA: bool,
        COMM_EXEC: bool,
        FORK_EXEC: bool,
        SWITCH_OUT: bool,
    },
    bit14: packed union {
        EXACT_IP: bool,
        SWITCH_OUT_PREEMPT: bool,
        MMAP_BUILD_ID: bool,
    },
    EXT_RESERVED: bool,
}

Additional informations on the event: kernel/user/hypervisor/etc.

size: u16

Size of the following record

std.os.linux.perf_event_mmap_page

container

Source line 10767

Fields

version: u32

Version number of this struct

compt_version: u32

Lowest version this is compatible with

lock: u32

Seqlock for synchronization

index: u32

Hardware counter identifier

offset: i64

Add to hardware counter value

time_enabled: u64

Time the event was active

time_running: u64

Time the event was running

capabilities: packed struct(u64) {
    /// If kernel version < 3.12
    /// this rapresents both user_rdpmc and user_time (user_rdpmc | user_time)
    /// otherwise deprecated.
    bit0: bool,
    /// Set if bit0 is deprecated
    bit0_is_deprecated: bool,
    /// Hardware support for userspace read of performance counters
    user_rdpmc: bool,
    /// Hardware support for a constant non stop timestamp counter (Eg. TSC on x86)
    user_time: bool,
    /// The time_zero field is used
    user_time_zero: bool,
    /// The time_{cycle,mask} fields are used
    user_time_short: bool,
    ____res: u58,
}
pcm_width: u16

If capabilities.user_rdpmc this field reports the bit-width of the value read with rdpmc() or equivalent

time_shift: u16

If capabilities.user_time the following fields can be used to compute the time delta since time_enabled (in ns) using RDTSC or similar

time_mult: u32
time_offset: u64
time_zero: u64

If capabilities.user_time_zero the hardware clock can be calculated from sample timestamps

size: u32

Header size

__reserved_1: u32
time_cycles: u64

The following fields are used to compute the timestamp when the hardware clock is less than 64bit wide

time_mask: u64
__reserved: [116 * 8]u8
data_head: u64

Head in the data section

data_tail: u64

Userspace written tail

data_offset: u64

Where the buffer starts

data_size: u64

Data buffer size

aux_head: u64
aux_tail: u64
aux_offset: u64
aux_size: u64

std.os.linux.perf_event_open

function

Source line 3407

pub fn perf_event_open( attr: *perf_event_attr, pid: pid_t, cpu: i32, group_fd: fd_t, flags: usize, ) usize

Parameters

attr: *perf_event_attr
pid: pid_t
cpu: i32
group_fd: fd_t
flags: usize

std.os.linux.PERF.COUNT

namespace

Source line 10848

std.os.linux.PERF.COUNT.HW

container

Source line 10849

Fields

CPU_CYCLES
INSTRUCTIONS
CACHE_REFERENCES
CACHE_MISSES
BRANCH_INSTRUCTIONS
BRANCH_MISSES
BUS_CYCLES
STALLED_CYCLES_FRONTEND
STALLED_CYCLES_BACKEND
REF_CPU_CYCLES
MAX

std.os.linux.PERF.COUNT.HW.CACHE

container

Source line 10862

Fields

L1D
L1I
LL
DTLB
ITLB
BPU
NODE
MAX

std.os.linux.PERF.COUNT.HW.CACHE.OP

container

Source line 10872

Fields

READ
WRITE
PREFETCH
MAX

std.os.linux.PERF.COUNT.HW.CACHE.RESULT

container

Source line 10879

Fields

ACCESS
MISS
MAX

std.os.linux.PERF.COUNT.SW

container

Source line 10887

Fields

CPU_CLOCK
TASK_CLOCK
PAGE_FAULTS
CONTEXT_SWITCHES
CPU_MIGRATIONS
PAGE_FAULTS_MIN
PAGE_FAULTS_MAJ
ALIGNMENT_FAULTS
EMULATION_FAULTS
DUMMY
BPF_OUTPUT
MAX

std.os.linux.PERF.EVENT_IOC

namespace

Source line 10990

std.os.linux.PERF.EVENT_IOC.DISABLE

constant

Source line 10992

std.os.linux.PERF.EVENT_IOC.ENABLE

constant

Source line 10991

std.os.linux.PERF.EVENT_IOC.ID

constant

Source line 10998

std.os.linux.PERF.EVENT_IOC.MODIFY_ATTRIBUTES

constant

Source line 11002

std.os.linux.PERF.EVENT_IOC.PAUSE_OUTPUT

constant

Source line 11000

std.os.linux.PERF.EVENT_IOC.PERIOD

constant

Source line 10995

std.os.linux.PERF.EVENT_IOC.QUERY_BPF

constant

Source line 11001

std.os.linux.PERF.EVENT_IOC.REFRESH

constant

Source line 10993

std.os.linux.PERF.EVENT_IOC.RESET

constant

Source line 10994

std.os.linux.PERF.EVENT_IOC.SET_BPF

constant

Source line 10999

std.os.linux.PERF.EVENT_IOC.SET_FILTER

constant

Source line 10997

std.os.linux.PERF.EVENT_IOC.SET_OUTPUT

constant

Source line 10996

std.os.linux.PERF.FLAG

namespace

Source line 10983

std.os.linux.PERF.FLAG.FD_CLOEXEC

constant

Source line 10987

std.os.linux.PERF.FLAG.FD_NO_GROUP

constant

Source line 10984

std.os.linux.PERF.FLAG.FD_OUTPUT

constant

Source line 10985

std.os.linux.PERF.FLAG.PID_CGROUP

constant

Source line 10986

std.os.linux.PERF.IOC_FLAG_GROUP

constant

Source line 11005

std.os.linux.PERF.RECORD

container

Source line 10948

Fields

MMAP = 1
LOST = 2
COMM = 3
EXIT = 4
THROTTLE = 5
UNTHROTTLE = 6
FORK = 7
READ = 8
SAMPLE = 9
MMAP2 = 10
AUX = 11
ITRACE_START = 12
LOST_SAMPLES = 13
SWITCH = 14
SWITCH_CPU_WIDE = 15
NAMESPACES = 16
KSYMBOL = 17
BPF_EVENT = 18
CGROUP = 19
TEXT_POKE = 20
AUX_OUTPUT_HW_ID = 21

std.os.linux.PERF.RECORD.MISC

namespace

Source line 10971

std.os.linux.PERF.RECORD.MISC.CPU_MODE

container

Source line 10972

Fields

UNKNOWN = 0
KERNEL = 1
USER = 2
HYPERVISOR = 3
GUEST_KERNEL = 4
GUEST_USER = 5

std.os.linux.PERF.SAMPLE

namespace

Source line 10903

std.os.linux.PERF.SAMPLE.ADDR

constant

Source line 10907

std.os.linux.PERF.SAMPLE.BRANCH

namespace

Source line 10926

std.os.linux.PERF.SAMPLE.BRANCH_STACK

constant

Source line 10915

std.os.linux.PERF.SAMPLE.BRANCH.ABORT_TX

constant

Source line 10934

std.os.linux.PERF.SAMPLE.BRANCH.ANY

constant

Source line 10930

std.os.linux.PERF.SAMPLE.BRANCH.ANY_CALL

constant

Source line 10931

std.os.linux.PERF.SAMPLE.BRANCH.ANY_RETURN

constant

Source line 10932

std.os.linux.PERF.SAMPLE.BRANCH.CALL

constant

Source line 10940

std.os.linux.PERF.SAMPLE.BRANCH.CALL_STACK

constant

Source line 10938

std.os.linux.PERF.SAMPLE.BRANCH.COND

constant

Source line 10937

std.os.linux.PERF.SAMPLE.BRANCH.HV

constant

Source line 10929

std.os.linux.PERF.SAMPLE.BRANCH.IN_TX

constant

Source line 10935

std.os.linux.PERF.SAMPLE.BRANCH.IND_CALL

constant

Source line 10933

std.os.linux.PERF.SAMPLE.BRANCH.IND_JUMP

constant

Source line 10939

std.os.linux.PERF.SAMPLE.BRANCH.KERNEL

constant

Source line 10928

std.os.linux.PERF.SAMPLE.BRANCH.MAX

constant

Source line 10944

std.os.linux.PERF.SAMPLE.BRANCH.NO_CYCLES

constant

Source line 10942

std.os.linux.PERF.SAMPLE.BRANCH.NO_FLAGS

constant

Source line 10941

std.os.linux.PERF.SAMPLE.BRANCH.NO_TX

constant

Source line 10936

std.os.linux.PERF.SAMPLE.BRANCH.TYPE_SAVE

constant

Source line 10943

std.os.linux.PERF.SAMPLE.BRANCH.USER

constant

Source line 10927

std.os.linux.PERF.SAMPLE.CALLCHAIN

constant

Source line 10909

std.os.linux.PERF.SAMPLE.CPU

constant

Source line 10911

std.os.linux.PERF.SAMPLE.DATA_SRC

constant

Source line 10919

std.os.linux.PERF.SAMPLE.ID

constant

Source line 10910

std.os.linux.PERF.SAMPLE.IDENTIFIER

constant

Source line 10920

std.os.linux.PERF.SAMPLE.IP

constant

Source line 10904

std.os.linux.PERF.SAMPLE.MAX

constant

Source line 10924

std.os.linux.PERF.SAMPLE.PERIOD

constant

Source line 10912

std.os.linux.PERF.SAMPLE.PHYS_ADDR

constant

Source line 10923

std.os.linux.PERF.SAMPLE.RAW

constant

Source line 10914

std.os.linux.PERF.SAMPLE.READ

constant

Source line 10908

std.os.linux.PERF.SAMPLE.REGS_INTR

constant

Source line 10922

std.os.linux.PERF.SAMPLE.REGS_USER

constant

Source line 10916

std.os.linux.PERF.SAMPLE.STACK_USER

constant

Source line 10917

std.os.linux.PERF.SAMPLE.STREAM_ID

constant

Source line 10913

std.os.linux.PERF.SAMPLE.TID

constant

Source line 10905

std.os.linux.PERF.SAMPLE.TIME

constant

Source line 10906

std.os.linux.PERF.SAMPLE.TRANSACTION

constant

Source line 10921

std.os.linux.PERF.SAMPLE.WEIGHT

constant

Source line 10918

std.os.linux.PERF.TYPE

container

Source line 10837

Fields

HARDWARE
SOFTWARE
TRACEPOINT
HW_CACHE
RAW
BREAKPOINT
MAX
_

std.os.linux.PF

namespace

Source line 5118

std.os.linux.PF.ALG

constant

Source line 5160

std.os.linux.PF.APPLETALK

constant

Source line 5126

std.os.linux.PF.ASH

constant

Source line 5140

std.os.linux.PF.ATMPVC

constant

Source line 5129

std.os.linux.PF.ATMSVC

constant

Source line 5142

std.os.linux.PF.AX25

constant

Source line 5124

std.os.linux.PF.BLUETOOTH

constant

Source line 5153

std.os.linux.PF.BRIDGE

constant

Source line 5128

std.os.linux.PF.CAIF

constant

Source line 5159

std.os.linux.PF.CAN

constant

Source line 5151

std.os.linux.PF.DECnet

constant

Source line 5133

std.os.linux.PF.ECONET

constant

Source line 5141

std.os.linux.PF.FILE

alias

Source line 5122

Alias of std.os.linux.PF.LOCAL

std.os.linux.PF.IB

constant

Source line 5149

std.os.linux.PF.IEEE802154

constant

Source line 5158

std.os.linux.PF.INET

constant

Source line 5123

std.os.linux.PF.INET6

constant

Source line 5131

std.os.linux.PF.IPX

constant

Source line 5125

std.os.linux.PF.IRDA

constant

Source line 5145

std.os.linux.PF.ISDN

constant

Source line 5156

std.os.linux.PF.IUCV

constant

Source line 5154

std.os.linux.PF.KCM

constant

Source line 5163

std.os.linux.PF.KEY

constant

Source line 5136

std.os.linux.PF.LLC

constant

Source line 5148

std.os.linux.PF.LOCAL

constant

Source line 5120

std.os.linux.PF.MAX

constant

Source line 5167

std.os.linux.PF.MPLS

constant

Source line 5150

std.os.linux.PF.NETBEUI

constant

Source line 5134

std.os.linux.PF.NETLINK

constant

Source line 5137

std.os.linux.PF.NETROM

constant

Source line 5127

std.os.linux.PF.NFC

constant

Source line 5161

std.os.linux.PF.PACKET

constant

Source line 5139

std.os.linux.PF.PHONET

constant

Source line 5157

std.os.linux.PF.PPPOX

constant

Source line 5146

std.os.linux.PF.QIPCRTR

constant

Source line 5164

std.os.linux.PF.RDS

constant

Source line 5143

std.os.linux.PF.ROSE

constant

Source line 5132

std.os.linux.PF.ROUTE

alias

Source line 5138

Alias of std.os.linux.PF.NETLINK

std.os.linux.PF.RXRPC

constant

Source line 5155

std.os.linux.PF.SECURITY

constant

Source line 5135

std.os.linux.PF.SMC

constant

Source line 5165

std.os.linux.PF.SNA

constant

Source line 5144

std.os.linux.PF.TIPC

constant

Source line 5152

std.os.linux.PF.UNIX

alias

Source line 5121

Alias of std.os.linux.PF.LOCAL

std.os.linux.PF.UNSPEC

constant

Source line 5119

std.os.linux.PF.VSOCK

constant

Source line 5162

std.os.linux.PF.WANPIPE

constant

Source line 5147

std.os.linux.PF.X25

constant

Source line 5130

std.os.linux.PF.XDP

constant

Source line 5166

std.os.linux.pid_t

type

Source line 118

std.os.linux.pidfd_getfd

function

Source line 3309

pub fn pidfd_getfd(pidfd: fd_t, targetfd: fd_t, flags: u32) usize

Parameters

pidfd: fd_t
targetfd: fd_t
flags: u32

std.os.linux.pidfd_open

function

Source line 3305

pub fn pidfd_open(pid: pid_t, flags: u32) usize

Parameters

pid: pid_t
flags: u32

std.os.linux.pidfd_send_signal

function

Source line 3318

pub fn pidfd_send_signal(pidfd: fd_t, sig: SIG, info: ?*siginfo_t, flags: u32) usize

Parameters

pidfd: fd_t
sig: SIG
info: ?*siginfo_t
flags: u32

std.os.linux.pipe

function

Source line 1895

pub fn pipe(fd: *[2]fd_t) usize

Parameters

fd: *[2]fd_t

std.os.linux.pipe2

function

Source line 1905

pub fn pipe2(fd: *[2]fd_t, flags: O) usize

Parameters

fd: *[2]fd_t
flags: O

std.os.linux.pivot_root

function

Source line 1565

pub fn pivot_root(new_root: [*:0]const u8, put_old: [*:0]const u8) usize

Parameters

new_root: [*:0]const u8
put_old: [*:0]const u8

std.os.linux.poll

function

Source line 1685

pub fn poll(fds: [*]pollfd, n: nfds_t, timeout: i32) usize

Parameters

fds: [*]pollfd
n: nfds_t
timeout: i32

std.os.linux.POLL

namespace

Source line 8438

std.os.linux.POLL.ERR

constant

Source line 8442

std.os.linux.POLL.HUP

constant

Source line 8443

std.os.linux.POLL.IN

constant

Source line 8439

std.os.linux.POLL.NVAL

constant

Source line 8444

std.os.linux.POLL.OUT

constant

Source line 8441

std.os.linux.POLL.PRI

constant

Source line 8440

std.os.linux.POLL.RDBAND

constant

Source line 8446

std.os.linux.POLL.RDNORM

constant

Source line 8445

std.os.linux.pollfd

container

Source line 8432

Fields

fd: fd_t
events: i16
revents: i16 = undefined

std.os.linux.POSIX_FADV

type

Source line 9728

std.os.linux.POSIX_FADV.DONTNEED

constant

Source line 9734

std.os.linux.POSIX_FADV.DONTNEED

constant

Source line 9741

std.os.linux.POSIX_FADV.DONTNEED

constant

Source line 9749

std.os.linux.POSIX_FADV.NOREUSE

constant

Source line 9735

std.os.linux.POSIX_FADV.NOREUSE

constant

Source line 9742

std.os.linux.POSIX_FADV.NOREUSE

constant

Source line 9750

std.os.linux.POSIX_FADV.NORMAL

constant

Source line 9730

std.os.linux.POSIX_FADV.NORMAL

constant

Source line 9737

std.os.linux.POSIX_FADV.NORMAL

constant

Source line 9745

std.os.linux.POSIX_FADV.RANDOM

constant

Source line 9731

std.os.linux.POSIX_FADV.RANDOM

constant

Source line 9738

std.os.linux.POSIX_FADV.RANDOM

constant

Source line 9746

std.os.linux.POSIX_FADV.SEQUENTIAL

constant

Source line 9732

std.os.linux.POSIX_FADV.SEQUENTIAL

constant

Source line 9739

std.os.linux.POSIX_FADV.SEQUENTIAL

constant

Source line 9747

std.os.linux.POSIX_FADV.WILLNEED

constant

Source line 9733

std.os.linux.POSIX_FADV.WILLNEED

constant

Source line 9740

std.os.linux.POSIX_FADV.WILLNEED

constant

Source line 9748

std.os.linux.ppoll

function

Source line 1705

pub fn ppoll(fds: [*]pollfd, n: nfds_t, timeout: ?*timespec, sigmask: ?*const sigset_t) usize

Parameters

fds: [*]pollfd
n: nfds_t
timeout: ?*timespec
sigmask: ?*const sigset_t

std.os.linux.PR

container

Source line 9902

Fields

SET_PDEATHSIG = 1
GET_PDEATHSIG = 2
GET_DUMPABLE = 3
SET_DUMPABLE = 4
GET_UNALIGN = 5
SET_UNALIGN = 6
GET_KEEPCAPS = 7
SET_KEEPCAPS = 8
GET_FPEMU = 9
SET_FPEMU = 10
GET_FPEXC = 11
SET_FPEXC = 12
GET_TIMING = 13
SET_TIMING = 14
SET_NAME = 15
GET_NAME = 16
GET_ENDIAN = 19
SET_ENDIAN = 20
GET_SECCOMP = 21
SET_SECCOMP = 22
CAPBSET_READ = 23
CAPBSET_DROP = 24
GET_TSC = 25
SET_TSC = 26
GET_SECUREBITS = 27
SET_SECUREBITS = 28
SET_TIMERSLACK = 29
GET_TIMERSLACK = 30
TASK_PERF_EVENTS_DISABLE = 31
TASK_PERF_EVENTS_ENABLE = 32
MCE_KILL = 33
MCE_KILL_GET = 34
SET_MM = 35
SET_PTRACER = 0x59616d61
SET_CHILD_SUBREAPER = 36
GET_CHILD_SUBREAPER = 37
SET_NO_NEW_PRIVS = 38
GET_NO_NEW_PRIVS = 39
GET_TID_ADDRESS = 40
SET_THP_DISABLE = 41
GET_THP_DISABLE = 42
MPX_ENABLE_MANAGEMENT = 43
MPX_DISABLE_MANAGEMENT = 44
SET_FP_MODE = 45
GET_FP_MODE = 46
CAP_AMBIENT = 47
SVE_SET_VL = 50
SVE_GET_VL = 51
GET_SPECULATION_CTRL = 52
SET_SPECULATION_CTRL = 53
_

std.os.linux.PR.CAP_AMBIENT_CLEAR_ALL

constant

Source line 10041

std.os.linux.PR.CAP_AMBIENT_IS_SET

constant

Source line 10038

std.os.linux.PR.CAP_AMBIENT_LOWER

constant

Source line 10040

std.os.linux.PR.CAP_AMBIENT_RAISE

constant

Source line 10039

std.os.linux.PR.ENDIAN_BIG

constant

Source line 10003

std.os.linux.PR.ENDIAN_LITTLE

constant

Source line 10004

std.os.linux.PR.ENDIAN_PPC_LITTLE

constant

Source line 10005

std.os.linux.PR.FP_EXC_ASYNC

constant

Source line 9997

std.os.linux.PR.FP_EXC_DISABLED

constant

Source line 9995

std.os.linux.PR.FP_EXC_DIV

constant

Source line 9990

std.os.linux.PR.FP_EXC_INV

constant

Source line 9994

std.os.linux.PR.FP_EXC_NONRECOV

constant

Source line 9996

std.os.linux.PR.FP_EXC_OVF

constant

Source line 9991

std.os.linux.PR.FP_EXC_PRECISE

constant

Source line 9998

std.os.linux.PR.FP_EXC_RES

constant

Source line 9993

std.os.linux.PR.FP_EXC_SW_ENABLE

constant

Source line 9989

std.os.linux.PR.FP_EXC_UND

constant

Source line 9992

std.os.linux.PR.FP_MODE_FR

constant

Source line 10035

std.os.linux.PR.FP_MODE_FRE

constant

Source line 10036

std.os.linux.PR.FPEMU_NOPRINT

constant

Source line 9986

std.os.linux.PR.FPEMU_SIGFPE

constant

Source line 9987

std.os.linux.PR.MCE_KILL_CLEAR

constant

Source line 10010

std.os.linux.PR.MCE_KILL_DEFAULT

constant

Source line 10015

std.os.linux.PR.MCE_KILL_EARLY

constant

Source line 10014

std.os.linux.PR.MCE_KILL_LATE

constant

Source line 10013

std.os.linux.PR.MCE_KILL_SET

constant

Source line 10011

std.os.linux.PR.SET_MM_ARG_END

constant

Source line 10025

std.os.linux.PR.SET_MM_ARG_START

constant

Source line 10024

std.os.linux.PR.SET_MM_AUXV

constant

Source line 10028

std.os.linux.PR.SET_MM_BRK

constant

Source line 10023

std.os.linux.PR.SET_MM_END_CODE

constant

Source line 10018

std.os.linux.PR.SET_MM_END_DATA

constant

Source line 10020

std.os.linux.PR.SET_MM_ENV_END

constant

Source line 10027

std.os.linux.PR.SET_MM_ENV_START

constant

Source line 10026

std.os.linux.PR.SET_MM_EXE_FILE

constant

Source line 10029

std.os.linux.PR.SET_MM_MAP

constant

Source line 10030

std.os.linux.PR.SET_MM_MAP_SIZE

constant

Source line 10031

std.os.linux.PR.SET_MM_START_BRK

constant

Source line 10022

std.os.linux.PR.SET_MM_START_CODE

constant

Source line 10017

std.os.linux.PR.SET_MM_START_DATA

constant

Source line 10019

std.os.linux.PR.SET_MM_START_STACK

constant

Source line 10021

std.os.linux.PR.SET_PTRACER_ANY

constant

Source line 10033

std.os.linux.PR.SPEC_DISABLE

constant

Source line 10051

std.os.linux.PR.SPEC_ENABLE

constant

Source line 10050

std.os.linux.PR.SPEC_FORCE_DISABLE

constant

Source line 10052

std.os.linux.PR.SPEC_NOT_AFFECTED

constant

Source line 10048

std.os.linux.PR.SPEC_PRCTL

constant

Source line 10049

std.os.linux.PR.SPEC_STORE_BYPASS

constant

Source line 10047

std.os.linux.PR.SVE_SET_VL_ONEXEC

constant

Source line 10043

std.os.linux.PR.SVE_VL_INHERIT

constant

Source line 10045

std.os.linux.PR.SVE_VL_LEN_MASK

constant

Source line 10044

std.os.linux.PR.TIMING_STATISTICAL

constant

Source line 10000

std.os.linux.PR.TIMING_TIMESTAMP

constant

Source line 10001

std.os.linux.PR.TSC_ENABLE

constant

Source line 10007

std.os.linux.PR.TSC_SIGSEGV

constant

Source line 10008

std.os.linux.PR.UNALIGN_NOPRINT

constant

Source line 9983

std.os.linux.PR.UNALIGN_SIGBUS

constant

Source line 9984

std.os.linux.prctl

function

Source line 3273

pub fn prctl(option: i32, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize

Parameters

option: i32
arg2: usize
arg3: usize
arg4: usize
arg5: usize

std.os.linux.prctl_mm_map

container

Source line 10055

Fields

start_code: u64
end_code: u64
start_data: u64
end_data: u64
start_brk: u64
brk: u64
start_stack: u64
arg_start: u64
arg_end: u64
env_start: u64
env_end: u64
auxv: *u64
auxv_size: u32
exe_fd: u32

std.os.linux.pread

function

Source line 1720

pub fn pread(fd: fd_t, buf: [*]u8, count: usize, offset: off_t) usize

Parameters

fd: fd_t
buf: [*]u8
count: usize
offset: off_t

std.os.linux.preadv

function

Source line 1758

pub fn preadv(fd: fd_t, iov: [*]const iovec, count: usize, offset: off_t) usize

Parameters

fd: fd_t
iov: [*]const iovec
count: usize
offset: off_t

std.os.linux.preadv2

function

Source line 1773

pub fn preadv2(fd: fd_t, iov: [*]const iovec, count: usize, offset: off_t, flags: kernel_rwf) usize

Parameters

fd: fd_t
iov: [*]const iovec
count: usize
offset: off_t
flags: kernel_rwf

std.os.linux.prlimit

function

Source line 3287

pub fn prlimit(pid: pid_t, resource: rlimit_resource, new_limit: ?*const rlimit, old_limit: ?*rlimit) usize

Parameters

pid: pid_t
resource: rlimit_resource
new_limit: ?*const rlimit
old_limit: ?*rlimit

std.os.linux.process_vm_readv

function

Source line 3328

pub fn process_vm_readv(pid: pid_t, local: []const iovec, remote: []const iovec_const, flags: usize) usize

Parameters

pid: pid_t
local: []const iovec
remote: []const iovec_const
flags: usize

std.os.linux.process_vm_writev

function

Source line 3340

pub fn process_vm_writev(pid: pid_t, local: []const iovec_const, remote: []const iovec_const, flags: usize) usize

Parameters

pid: pid_t
local: []const iovec_const
remote: []const iovec_const
flags: usize

std.os.linux.PROT

type

Source line 4632

std.os.linux.ptrace

function

Source line 3428

pub fn ptrace( req: u32, pid: pid_t, addr: usize, data: usize, addr2: usize, ) usize

Parameters

req: u32
pid: pid_t
addr: usize
data: usize
addr2: usize

std.os.linux.PTRACE

namespace

Source line 11114

std.os.linux.PTRACE.ATTACH

constant

Source line 11129

std.os.linux.PTRACE.CONT

constant

Source line 11122

std.os.linux.PTRACE.DETACH

constant

Source line 11130

std.os.linux.PTRACE.EVENT

namespace

Source line 11150

std.os.linux.PTRACE.EVENT.CLONE

constant

Source line 11153

std.os.linux.PTRACE.EVENT.EXEC

constant

Source line 11154

std.os.linux.PTRACE.EVENT.EXIT

constant

Source line 11156

std.os.linux.PTRACE.EVENT.FORK

constant

Source line 11151

std.os.linux.PTRACE.EVENT.SECCOMP

constant

Source line 11157

std.os.linux.PTRACE.EVENT.STOP

constant

Source line 11158

std.os.linux.PTRACE.EVENT.VFORK

constant

Source line 11152

std.os.linux.PTRACE.EVENT.VFORK_DONE

constant

Source line 11155

std.os.linux.PTRACE.GET_SYSCALL_INFO

constant

Source line 11148

std.os.linux.PTRACE.GETEVENTMSG

constant

Source line 11135

std.os.linux.PTRACE.GETFPREGS

constant

Source line 11127

std.os.linux.PTRACE.GETFPXREGS

constant

Source line 11131

std.os.linux.PTRACE.GETREGS

constant

Source line 11125

std.os.linux.PTRACE.GETREGSET

constant

Source line 11138

std.os.linux.PTRACE.GETSIGINFO

constant

Source line 11136

std.os.linux.PTRACE.GETSIGMASK

constant

Source line 11144

std.os.linux.PTRACE.INTERRUPT

constant

Source line 11141

std.os.linux.PTRACE.KILL

constant

Source line 11123

std.os.linux.PTRACE.LISTEN

constant

Source line 11142

std.os.linux.PTRACE.O

namespace

Source line 11161

std.os.linux.PTRACE.O.EXITKILL

constant

Source line 11171

std.os.linux.PTRACE.O.MASK

constant

Source line 11174

std.os.linux.PTRACE.O.SUSPEND_SECCOMP

constant

Source line 11172

std.os.linux.PTRACE.O.TRACECLONE

constant

Source line 11165

std.os.linux.PTRACE.O.TRACEEXEC

constant

Source line 11166

std.os.linux.PTRACE.O.TRACEEXIT

constant

Source line 11168

std.os.linux.PTRACE.O.TRACEFORK

constant

Source line 11163

std.os.linux.PTRACE.O.TRACESECCOMP

constant

Source line 11169

std.os.linux.PTRACE.O.TRACESYSGOOD

constant

Source line 11162

std.os.linux.PTRACE.O.TRACEVFORK

constant

Source line 11164

std.os.linux.PTRACE.O.TRACEVFORKDONE

constant

Source line 11167

std.os.linux.PTRACE.PEEKDATA

constant

Source line 11117

std.os.linux.PTRACE.PEEKSIGINFO

constant

Source line 11143

std.os.linux.PTRACE.PEEKTEXT

constant

Source line 11116

std.os.linux.PTRACE.PEEKUSER

constant

Source line 11118

std.os.linux.PTRACE.POKEDATA

constant

Source line 11120

std.os.linux.PTRACE.POKETEXT

constant

Source line 11119

std.os.linux.PTRACE.POKEUSER

constant

Source line 11121

std.os.linux.PTRACE.SECCOMP_GET_FILTER

constant

Source line 11146

std.os.linux.PTRACE.SECCOMP_GET_METADATA

constant

Source line 11147

std.os.linux.PTRACE.SEIZE

constant

Source line 11140

std.os.linux.PTRACE.SETFPREGS

constant

Source line 11128

std.os.linux.PTRACE.SETFPXREGS

constant

Source line 11132

std.os.linux.PTRACE.SETOPTIONS

constant

Source line 11134

std.os.linux.PTRACE.SETREGS

constant

Source line 11126

std.os.linux.PTRACE.SETREGSET

constant

Source line 11139

std.os.linux.PTRACE.SETSIGINFO

constant

Source line 11137

std.os.linux.PTRACE.SETSIGMASK

constant

Source line 11145

std.os.linux.PTRACE.SINGLESTEP

constant

Source line 11124

std.os.linux.PTRACE.SYSCALL

constant

Source line 11133

std.os.linux.PTRACE.TRACEME

constant

Source line 11115

std.os.linux.pwrite

function

Source line 1791

pub fn pwrite(fd: fd_t, buf: [*]const u8, count: usize, offset: off_t) usize

Parameters

fd: fd_t
buf: [*]const u8
count: usize
offset: off_t

std.os.linux.pwritev

function

Source line 1829

pub fn pwritev(fd: fd_t, iov: [*]const iovec_const, count: usize, offset: off_t) usize

Parameters

fd: fd_t
iov: [*]const iovec_const
count: usize
offset: off_t

std.os.linux.pwritev2

function

Source line 1842

pub fn pwritev2(fd: fd_t, iov: [*]const iovec_const, count: usize, offset: off_t, flags: kernel_rwf) usize

Parameters

fd: fd_t
iov: [*]const iovec_const
count: usize
offset: off_t
flags: kernel_rwf

std.os.linux.R_OK

constant

Source line 4663

std.os.linux.read

function

Source line 1716

pub fn read(fd: fd_t, buf: [*]u8, count: usize) usize

Parameters

fd: fd_t
buf: [*]u8
count: usize

std.os.linux.readlink

function

Source line 1398

pub fn readlink(noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize

Parameters

path: [*:0]const u8
buf_ptr: [*]u8
buf_len: usize

std.os.linux.readlinkat

function

Source line 1406

pub fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize

Parameters

dirfd: fd_t
path: [*:0]const u8
buf_ptr: [*]u8
buf_len: usize

std.os.linux.readv

function

Source line 1754

pub fn readv(fd: fd_t, iov: [*]const iovec, count: usize) usize

Parameters

fd: fd_t
iov: [*]const iovec
count: usize

std.os.linux.reboot

function

Source line 2184

pub fn reboot(magic: LINUX_REBOOT.MAGIC1, magic2: LINUX_REBOOT.MAGIC2, cmd: LINUX_REBOOT.CMD, arg: ?*const anyopaque) usize

Parameters

magic: LINUX_REBOOT.MAGIC1
magic2: LINUX_REBOOT.MAGIC2
cmd: LINUX_REBOOT.CMD
arg: ?*const anyopaque

std.os.linux.recvfrom

function

Source line 2859

pub fn recvfrom( fd: fd_t, noalias buf: [*]u8, len: usize, flags: u32, noalias addr: ?*sockaddr, noalias alen: ?*socklen_t, ) usize

Parameters

fd: fd_t
buf: [*]u8
len: usize
flags: u32
addr: ?*sockaddr
alen: ?*socklen_t

std.os.linux.recvmmsg

function

Source line 2848

pub fn recvmmsg(fd: fd_t, msgvec: ?[*]mmsghdr, vlen: u32, flags: u32, timeout: ?*timespec) usize

Parameters

fd: fd_t
msgvec: ?[*]mmsghdr
vlen: u32
flags: u32
timeout: ?*timespec

std.os.linux.recvmsg

function

Source line 2840

pub fn recvmsg(fd: fd_t, msg: *msghdr, flags: u32) usize

Parameters

fd: fd_t
msg: *msghdr
flags: u32

std.os.linux.removexattr

function

Source line 2980

pub fn removexattr(path: [*:0]const u8, name: [*:0]const u8) usize

Parameters

path: [*:0]const u8
name: [*:0]const u8

std.os.linux.rename

function

Source line 1937

pub fn rename(old: [*:0]const u8, new: [*:0]const u8) usize

Parameters

old: [*:0]const u8
new: [*:0]const u8

std.os.linux.RENAME

container

Source line 954

Fields

NOREPLACE: bool = false

Cannot be set together with EXCHANGE.

EXCHANGE: bool = false

Cannot be set together with NOREPLACE.

WHITEOUT: bool = false
_: u29 = 0

std.os.linux.renameat

function

Source line 1960

pub fn renameat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8) usize

Parameters

oldfd: fd_t
oldpath: [*:0]const u8
newfd: fd_t
newpath: [*:0]const u8

std.os.linux.renameat2

function

Source line 1981

pub fn renameat2(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8, flags: RENAME) usize

Parameters

oldfd: fd_t
oldpath: [*:0]const u8
newfd: fd_t
newpath: [*:0]const u8
flags: RENAME

std.os.linux.require_aligned_register_pair

constant

Source line 1003

std.os.linux.restore

constant

Source line 78

std.os.linux.restore_rt

constant

Source line 79

std.os.linux.riscv_hwprobe

container

Source line 11250

Fields

key: i64
value: u64

std.os.linux.RISCV_HWPROBE

namespace

Source line 11255

std.os.linux.RISCV_HWPROBE.BASE_BEHAVIOR_IMA

constant

Source line 11278

std.os.linux.RISCV_HWPROBE.FLAGS_WHICH_CPUS

constant

Source line 11276

std.os.linux.RISCV_HWPROBE.IMA_EXT_0

namespace

Source line 11280

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_SUPM

constant

Source line 11330

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZAAMO

constant

Source line 11337

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZABHA

constant

Source line 11339

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZACAS

constant

Source line 11315

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZALASR

constant

Source line 11340

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZALRSC

constant

Source line 11338

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZAWRS

constant

Source line 11329

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZBA

constant

Source line 11284

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZBB

constant

Source line 11285

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZBC

constant

Source line 11288

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZBKB

constant

Source line 11289

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZBKC

constant

Source line 11290

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZBKX

constant

Source line 11291

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZBS

constant

Source line 11286

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZCA

constant

Source line 11324

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZCB

constant

Source line 11325

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZCD

constant

Source line 11326

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZCF

constant

Source line 11327

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZCLSD

constant

Source line 11343

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZCMOP

constant

Source line 11328

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZFA

constant

Source line 11313

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZFBFMIN

constant

Source line 11333

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZFH

constant

Source line 11308

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZFHMIN

constant

Source line 11309

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZICBOM

constant

Source line 11336

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZICBOP

constant

Source line 11341

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZICBOZ

constant

Source line 11287

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZICFILP

constant

Source line 11344

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZICNTR

constant

Source line 11331

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZICOND

constant

Source line 11316

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZIHINTNTL

constant

Source line 11310

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZIHINTPAUSE

constant

Source line 11317

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZIHPM

constant

Source line 11332

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZILSD

constant

Source line 11342

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZIMOP

constant

Source line 11323

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZKND

constant

Source line 11292

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZKNE

constant

Source line 11293

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZKNH

constant

Source line 11294

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZKSED

constant

Source line 11295

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZKSH

constant

Source line 11296

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZKT

constant

Source line 11297

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZTSO

constant

Source line 11314

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVBB

constant

Source line 11298

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVBC

constant

Source line 11299

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVE32F

constant

Source line 11319

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVE32X

constant

Source line 11318

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVE64D

constant

Source line 11322

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVE64F

constant

Source line 11321

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVE64X

constant

Source line 11320

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVFBFMIN

constant

Source line 11334

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVFBFWMA

constant

Source line 11335

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVFH

constant

Source line 11311

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVFHMIN

constant

Source line 11312

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKB

constant

Source line 11300

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKG

constant

Source line 11301

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKNED

constant

Source line 11302

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKNHA

constant

Source line 11303

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKNHB

constant

Source line 11304

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKSED

constant

Source line 11305

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKSH

constant

Source line 11306

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKT

constant

Source line 11307

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.IMA_C

constant

Source line 11282

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.IMA_FD

constant

Source line 11281

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.IMA_V

constant

Source line 11283

std.os.linux.RISCV_HWPROBE.IMA_EXT_1_EXT_ZICFISS

constant

Source line 11347

std.os.linux.RISCV_HWPROBE.KEY

namespace

Source line 11256

std.os.linux.RISCV_HWPROBE.KEY.BASE_BEHAVIOR

constant

Source line 11260

std.os.linux.RISCV_HWPROBE.KEY.CPUPERF_0

constant

Source line 11262

std.os.linux.RISCV_HWPROBE.KEY.HIGHEST_VIRT_ADDRESS

constant

Source line 11264

std.os.linux.RISCV_HWPROBE.KEY.IMA_EXT_0

constant

Source line 11261

std.os.linux.RISCV_HWPROBE.KEY.IMA_EXT_1

constant

Source line 11273

std.os.linux.RISCV_HWPROBE.KEY.MARCHID

constant

Source line 11258

std.os.linux.RISCV_HWPROBE.KEY.MIMPID

constant

Source line 11259

std.os.linux.RISCV_HWPROBE.KEY.MISALIGNED_SCALAR_PERF

constant

Source line 11266

std.os.linux.RISCV_HWPROBE.KEY.MISALIGNED_VECTOR_PERF

constant

Source line 11267

std.os.linux.RISCV_HWPROBE.KEY.MVENDORID

constant

Source line 11257

std.os.linux.RISCV_HWPROBE.KEY.TIME_CSR_FREQ

constant

Source line 11265

std.os.linux.RISCV_HWPROBE.KEY.VENDOR_EXT_MIPS_0

constant

Source line 11271

std.os.linux.RISCV_HWPROBE.KEY.VENDOR_EXT_SIFIVE_0

constant

Source line 11270

std.os.linux.RISCV_HWPROBE.KEY.VENDOR_EXT_THEAD_0

constant

Source line 11268

std.os.linux.RISCV_HWPROBE.KEY.ZICBOM_BLOCK_SIZE

constant

Source line 11269

std.os.linux.RISCV_HWPROBE.KEY.ZICBOP_BLOCK_SIZE

constant

Source line 11272

std.os.linux.RISCV_HWPROBE.KEY.ZICBOZ_BLOCK_SIZE

constant

Source line 11263

std.os.linux.RISCV_HWPROBE.MIPS_VENDOR_EXT_XMIPSEXECTL

constant

Source line 11364

std.os.linux.RISCV_HWPROBE.MISALIGNED_SCALAR

namespace

Source line 11349

std.os.linux.RISCV_HWPROBE.MISALIGNED_SCALAR.EMULATED

constant

Source line 11351

std.os.linux.RISCV_HWPROBE.MISALIGNED_SCALAR.FAST

constant

Source line 11353

std.os.linux.RISCV_HWPROBE.MISALIGNED_SCALAR.SLOW

constant

Source line 11352

std.os.linux.RISCV_HWPROBE.MISALIGNED_SCALAR.UNKNOWN

constant

Source line 11350

std.os.linux.RISCV_HWPROBE.MISALIGNED_SCALAR.UNSUPPORTED

constant

Source line 11354

std.os.linux.RISCV_HWPROBE.MISALIGNED_VECTOR

namespace

Source line 11357

std.os.linux.RISCV_HWPROBE.MISALIGNED_VECTOR.FAST

constant

Source line 11360

std.os.linux.RISCV_HWPROBE.MISALIGNED_VECTOR.SLOW

constant

Source line 11359

std.os.linux.RISCV_HWPROBE.MISALIGNED_VECTOR.UNKNOWN

constant

Source line 11358

std.os.linux.RISCV_HWPROBE.MISALIGNED_VECTOR.UNSUPPORTED

constant

Source line 11361

std.os.linux.RISCV_HWPROBE.SIFIVE_VENDOR_EXT

namespace

Source line 11366

std.os.linux.RISCV_HWPROBE.SIFIVE_VENDOR_EXT.XSFVFNRCLIPXFQF

constant

Source line 11369

std.os.linux.RISCV_HWPROBE.SIFIVE_VENDOR_EXT.XSFVFWMACCQQQ

constant

Source line 11370

std.os.linux.RISCV_HWPROBE.SIFIVE_VENDOR_EXT.XSFVQMACCDOD

constant

Source line 11367

std.os.linux.RISCV_HWPROBE.SIFIVE_VENDOR_EXT.XSFVQMACCQOQ

constant

Source line 11368

std.os.linux.RLIM

namespace

Source line 9686

std.os.linux.rlim_t

type

Source line 9684

std.os.linux.RLIM.INFINITY

constant

Source line 9688

No limit

rlim_t

std.os.linux.RLIM.SAVED_CUR

alias

Source line 9694

Alias of std.os.linux.RLIM.INFINITY

std.os.linux.RLIM.SAVED_MAX

alias

Source line 9693

Alias of std.os.linux.RLIM.INFINITY

std.os.linux.rlimit

container

Source line 9697

Fields

cur: rlim_t

Soft limit

max: rlim_t

Hard limit

std.os.linux.rlimit_resource

type

Source line 9480

std.os.linux.rmdir

function

Source line 1856

pub fn rmdir(path: [*:0]const u8) usize

Parameters

path: [*:0]const u8

std.os.linux.rtattr

container

Source line 10333

Fields

len: c_ushort

Length of option

type: extern union {
    /// IFLA_* from linux/if_link.h
    link: IFLA,
    /// IFA_* from linux/if_addr.h
    addr: IFA,
}

Type of option

std.os.linux.rtattr.ALIGNTO

constant

Source line 10345

std.os.linux.rtnl_link_ifmap

container

Source line 10442

Fields

mem_start: u64
mem_end: u64
base_addr: u64
irq: u16
dma: u8
port: u8

std.os.linux.rtnl_link_stats

container

Source line 10451

Fields

rx_packets: u32

total packets received

tx_packets: u32

total packets transmitted

rx_bytes: u32

total bytes received

tx_bytes: u32

total bytes transmitted

rx_errors: u32

bad packets received

tx_errors: u32

packet transmit problems

rx_dropped: u32

no space in linux buffers

tx_dropped: u32

no space available in linux

multicast: u32

multicast packets received

collisions: u32
rx_length_errors: u32
rx_over_errors: u32

receiver ring buff overflow

rx_crc_errors: u32

recved pkt with crc error

rx_frame_errors: u32

recv'd frame alignment error

rx_fifo_errors: u32

recv'r fifo overrun

rx_missed_errors: u32

receiver missed packet

tx_aborted_errors: u32
tx_carrier_errors: u32
tx_fifo_errors: u32
tx_heartbeat_errors: u32
tx_window_errors: u32
rx_compressed: u32
tx_compressed: u32
rx_nohandler: u32

dropped, no handler found

std.os.linux.rtnl_link_stats64

container

Source line 10516

Fields

rx_packets: u64

total packets received

tx_packets: u64

total packets transmitted

rx_bytes: u64

total bytes received

tx_bytes: u64

total bytes transmitted

rx_errors: u64

bad packets received

tx_errors: u64

packet transmit problems

rx_dropped: u64

no space in linux buffers

tx_dropped: u64

no space available in linux

multicast: u64

multicast packets received

collisions: u64
rx_length_errors: u64
rx_over_errors: u64

receiver ring buff overflow

rx_crc_errors: u64

recved pkt with crc error

rx_frame_errors: u64

recv'd frame alignment error

rx_fifo_errors: u64

recv'r fifo overrun

rx_missed_errors: u64

receiver missed packet

tx_aborted_errors: u64
tx_carrier_errors: u64
tx_fifo_errors: u64
tx_heartbeat_errors: u64
tx_window_errors: u64
rx_compressed: u64
tx_compressed: u64
rx_nohandler: u64

dropped, no handler found

std.os.linux.rusage

container

Source line 8486

Fields

utime: timeval
stime: timeval
maxrss: isize
ixrss: isize
idrss: isize
isrss: isize
minflt: isize
majflt: isize
nswap: isize
inblock: isize
oublock: isize
msgsnd: isize
msgrcv: isize
nsignals: isize
nvcsw: isize
nivcsw: isize
__reserved: [16]isize = @splat(0)

std.os.linux.rusage.CHILDREN

constant

Source line 8506

std.os.linux.rusage.SELF

constant

Source line 8505

std.os.linux.rusage.THREAD

constant

Source line 8507

std.os.linux.RWF

namespace

Source line 4974

std.os.linux.RWF.APPEND

constant

Source line 4979

kernel_rwf

std.os.linux.RWF.DSYNC

constant

Source line 4976

kernel_rwf

std.os.linux.RWF.HIPRI

constant

Source line 4975

kernel_rwf

std.os.linux.RWF.NOWAIT

constant

Source line 4978

kernel_rwf

std.os.linux.RWF.SYNC

constant

Source line 4977

kernel_rwf

std.os.linux.S

namespace

Source line 6878

std.os.linux.S.IFBLK

constant

Source line 6883

std.os.linux.S.IFCHR

constant

Source line 6882

std.os.linux.S.IFDIR

constant

Source line 6881

std.os.linux.S.IFIFO

constant

Source line 6885

std.os.linux.S.IFLNK

constant

Source line 6886

std.os.linux.S.IFMT

constant

Source line 6879

std.os.linux.S.IFREG

constant

Source line 6884

std.os.linux.S.IFSOCK

constant

Source line 6887

std.os.linux.S.IRGRP

constant

Source line 6896

std.os.linux.S.IROTH

constant

Source line 6900

std.os.linux.S.IRUSR

constant

Source line 6892

std.os.linux.S.IRWXG

constant

Source line 6899

std.os.linux.S.IRWXO

constant

Source line 6903

std.os.linux.S.IRWXU

constant

Source line 6895

std.os.linux.S.ISBLK

function

Source line 6917

pub fn ISBLK(m: mode_t) bool

Parameters

m: mode_t

std.os.linux.S.ISCHR

function

Source line 6913

pub fn ISCHR(m: mode_t) bool

Parameters

m: mode_t

std.os.linux.S.ISDIR

function

Source line 6909

pub fn ISDIR(m: mode_t) bool

Parameters

m: mode_t

std.os.linux.S.ISFIFO

function

Source line 6921

pub fn ISFIFO(m: mode_t) bool

Parameters

m: mode_t

std.os.linux.S.ISGID

constant

Source line 6890

std.os.linux.S.ISLNK

function

Source line 6925

pub fn ISLNK(m: mode_t) bool

Parameters

m: mode_t

std.os.linux.S.ISREG

function

Source line 6905

pub fn ISREG(m: mode_t) bool

Parameters

m: mode_t

std.os.linux.S.ISSOCK

function

Source line 6929

pub fn ISSOCK(m: mode_t) bool

Parameters

m: mode_t

std.os.linux.S.ISUID

constant

Source line 6889

std.os.linux.S.ISVTX

constant

Source line 6891

std.os.linux.S.IWGRP

constant

Source line 6897

std.os.linux.S.IWOTH

constant

Source line 6901

std.os.linux.S.IWUSR

constant

Source line 6893

std.os.linux.S.IXGRP

constant

Source line 6898

std.os.linux.S.IXOTH

constant

Source line 6902

std.os.linux.S.IXUSR

constant

Source line 6894

std.os.linux.SA

type

Source line 4702

std.os.linux.sa_family_t

type

Source line 7068

std.os.linux.SA.NOCLDSTOP

constant

Source line 4703

std.os.linux.SA.NOCLDSTOP

constant

Source line 4711

std.os.linux.SA.NOCLDSTOP

constant

Source line 4720

std.os.linux.SA.NOCLDSTOP

constant

Source line 4730

std.os.linux.SA.NOCLDSTOP

constant

Source line 4736

std.os.linux.SA.NOCLDWAIT

constant

Source line 4704

std.os.linux.SA.NOCLDWAIT

constant

Source line 4712

std.os.linux.SA.NOCLDWAIT

constant

Source line 4721

std.os.linux.SA.NOCLDWAIT

constant

Source line 4733

std.os.linux.SA.NOCLDWAIT

constant

Source line 4737

std.os.linux.SA.NODEFER

constant

Source line 4709

std.os.linux.SA.NODEFER

constant

Source line 4717

std.os.linux.SA.NODEFER

constant

Source line 4726

std.os.linux.SA.NODEFER

constant

Source line 4731

std.os.linux.SA.NODEFER

constant

Source line 4742

std.os.linux.SA.ONSTACK

constant

Source line 4708

std.os.linux.SA.ONSTACK

constant

Source line 4716

std.os.linux.SA.ONSTACK

constant

Source line 4725

std.os.linux.SA.ONSTACK

constant

Source line 4728

std.os.linux.SA.ONSTACK

constant

Source line 4741

std.os.linux.SA.RESETHAND

constant

Source line 4707

std.os.linux.SA.RESETHAND

constant

Source line 4715

std.os.linux.SA.RESETHAND

constant

Source line 4724

std.os.linux.SA.RESETHAND

constant

Source line 4732

std.os.linux.SA.RESETHAND

constant

Source line 4740

std.os.linux.SA.RESTART

constant

Source line 4706

std.os.linux.SA.RESTART

constant

Source line 4714

std.os.linux.SA.RESTART

constant

Source line 4723

std.os.linux.SA.RESTART

constant

Source line 4729

std.os.linux.SA.RESTART

constant

Source line 4739

std.os.linux.SA.RESTORER

constant

Source line 4718

std.os.linux.SA.RESTORER

constant

Source line 4743

std.os.linux.SA.SIGINFO

constant

Source line 4705

std.os.linux.SA.SIGINFO

constant

Source line 4713

std.os.linux.SA.SIGINFO

constant

Source line 4722

std.os.linux.SA.SIGINFO

constant

Source line 4734

std.os.linux.SA.SIGINFO

constant

Source line 4738

std.os.linux.SC

constant

Source line 107

std.os.linux.SCHED

container

Source line 2996

Fields

mode: Mode
_3: u27 = 0
RESET_ON_FORK: bool = false

set to true to stop children from inheriting policies

_31: u1 = 0

std.os.linux.sched_attr

container

Source line 3046

Fields

size: u32 = 48
policy: u32 = 0
flags: u64 = 0
nice: u32 = 0
priority: u32 = 0
runtime: u64 = 0
deadline: u64 = 0
period: u64 = 0

std.os.linux.sched_get_priority_max

function

Source line 3034

pub fn sched_get_priority_max(policy: SCHED) usize

Parameters

policy: SCHED

std.os.linux.sched_get_priority_min

function

Source line 3038

pub fn sched_get_priority_min(policy: SCHED) usize

Parameters

policy: SCHED

std.os.linux.sched_getaffinity

function

Source line 3074

pub fn sched_getaffinity(pid: pid_t, size: u32, set: *cpu_set_t) usize

Parameters

pid: pid_t
size: u32
set: *cpu_set_t

std.os.linux.sched_getattr

function

Source line 3062

pub fn sched_getattr(pid: pid_t, attr: *sched_attr, size: u32, flags: u32) usize

Parameters

pid: pid_t
attr: *sched_attr
size: u32
flags: u32

std.os.linux.sched_getparam

function

Source line 3022

pub fn sched_getparam(pid: pid_t, param: *sched_param) usize

Parameters

pid: pid_t
param: *sched_param

std.os.linux.sched_getscheduler

function

Source line 3030

pub fn sched_getscheduler(pid: pid_t) usize

Parameters

pid: pid_t

std.os.linux.sched_param

container

Source line 2992

Fields

priority: i32

std.os.linux.sched_rr_get_interval

function

Source line 3066

pub fn sched_rr_get_interval(pid: pid_t, tp: *timespec) usize

Parameters

pid: pid_t
tp: *timespec

std.os.linux.sched_setaffinity

function

Source line 3081

pub fn sched_setaffinity(pid: pid_t, set: *const cpu_set_t) !void

Parameters

pid: pid_t
set: *const cpu_set_t

std.os.linux.sched_setattr

function

Source line 3058

pub fn sched_setattr(pid: pid_t, attr: *const sched_attr, flags: u32) usize

Parameters

pid: pid_t
attr: *const sched_attr
flags: u32

std.os.linux.sched_setparam

function

Source line 3018

pub fn sched_setparam(pid: pid_t, param: *const sched_param) usize

Parameters

pid: pid_t
param: *const sched_param

std.os.linux.sched_setscheduler

function

Source line 3026

pub fn sched_setscheduler(pid: pid_t, policy: SCHED, param: *const sched_param) usize

Parameters

pid: pid_t
policy: SCHED
param: *const sched_param

std.os.linux.sched_yield

function

Source line 3070

pub fn sched_yield() usize

std.os.linux.SCHED.Mode

container

Source line 2997

Fields

NORMAL = 0

normal multi-user scheduling

FIFO = 1

FIFO realtime scheduling

RR = 2

Round-robin realtime scheduling

BATCH = 3

For "batch" style execution of processes

IDLE = 5

Low latency scheduling

DEADLINE = 6

Sporadic task model deadline scheduling

std.os.linux.SCM

namespace

Source line 5571

std.os.linux.SCM.CREDENTIALS

constant

Source line 5574

std.os.linux.SCM.PIDFD

constant

Source line 5576

std.os.linux.SCM.RIGHTS

constant

Source line 5573

std.os.linux.SCM.SECURITY

constant

Source line 5575

std.os.linux.SCM.TIMESTAMPING_OPT_STATS

constant

Source line 5579

std.os.linux.SCM.TIMESTAMPING_PKTINFO

constant

Source line 5580

std.os.linux.SCM.TXTIME

constant

Source line 5581

std.os.linux.SCM.WIFI_STATUS

constant

Source line 5578

std.os.linux.SECBIT_KEEP_CAPS

constant

Source line 9887

std.os.linux.SECBIT_KEEP_CAPS_LOCKED

constant

Source line 9888

std.os.linux.SECBIT_NO_CAP_AMBIENT_RAISE

constant

Source line 9893

std.os.linux.SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED

constant

Source line 9894

std.os.linux.SECBIT_NO_SETUID_FIXUP

constant

Source line 9881

std.os.linux.SECBIT_NO_SETUID_FIXUP_LOCKED

constant

Source line 9882

std.os.linux.SECBIT_NOROOT

constant

Source line 9875

std.os.linux.SECBIT_NOROOT_LOCKED

constant

Source line 9876

std.os.linux.seccomp

function

Source line 3424

pub fn seccomp(operation: u32, flags: u32, args: ?*const anyopaque) usize

Parameters

operation: u32
flags: u32
args: ?*const anyopaque

std.os.linux.SECCOMP

alias

Source line 129

Alias of std.os.linux.seccomp

std.os.linux.SECURE_ALL_BITS

constant

Source line 9896

std.os.linux.SECURE_ALL_LOCKS

constant

Source line 9900

std.os.linux.SECURE_KEEP_CAPS

constant

Source line 9884

std.os.linux.SECURE_KEEP_CAPS_LOCKED

constant

Source line 9885

std.os.linux.SECURE_NO_CAP_AMBIENT_RAISE

constant

Source line 9890

std.os.linux.SECURE_NO_CAP_AMBIENT_RAISE_LOCKED

constant

Source line 9891

std.os.linux.SECURE_NO_SETUID_FIXUP

constant

Source line 9878

std.os.linux.SECURE_NO_SETUID_FIXUP_LOCKED

constant

Source line 9879

std.os.linux.SECURE_NOROOT

constant

Source line 9872

std.os.linux.SECURE_NOROOT_LOCKED

constant

Source line 9873

std.os.linux.SECUREBITS_DEFAULT

constant

Source line 9870

std.os.linux.SEEK

namespace

Source line 4982

std.os.linux.SEEK.CUR

constant

Source line 4984

std.os.linux.SEEK.END

constant

Source line 4985

std.os.linux.SEEK.SET

constant

Source line 4983

std.os.linux.sendfile

function

Source line 2902

pub fn sendfile(outfd: fd_t, infd: fd_t, offset: ?*off_t, count: usize) usize

Parameters

outfd: fd_t
infd: fd_t
offset: ?*off_t
count: usize

std.os.linux.sendmmsg

function

Source line 2828

pub fn sendmmsg(fd: fd_t, msgvec: [*]mmsghdr, vlen: u32, flags: u32) usize

Parameters

fd: fd_t
msgvec: [*]mmsghdr
vlen: u32
flags: u32

std.os.linux.sendmsg

function

Source line 2820

pub fn sendmsg(fd: fd_t, msg: *const msghdr_const, flags: u32) usize

Parameters

fd: fd_t
msg: *const msghdr_const
flags: u32

std.os.linux.sendto

function

Source line 2895

pub fn sendto(fd: i32, buf: [*]const u8, len: usize, flags: u32, addr: ?*const sockaddr, alen: socklen_t) usize

Parameters

fd: i32
buf: [*]const u8
len: usize
flags: u32
addr: ?*const sockaddr
alen: socklen_t

std.os.linux.SER

namespace

Source line 6506

std.os.linux.SER.ISO7816

namespace

Source line 6518

std.os.linux.SER.ISO7816.ENABLED

constant

Source line 6519

std.os.linux.SER.ISO7816.T

function

Source line 6522

pub fn T(t: anytype) @TypeOf(t)

std.os.linux.SER.ISO7816.T_PARAM

constant

Source line 6520

std.os.linux.SER.RS485

namespace

Source line 6507

std.os.linux.SER.RS485.ADDR_DEST

constant

Source line 6515

std.os.linux.SER.RS485.ADDR_RECV

constant

Source line 6514

std.os.linux.SER.RS485.ADDRB

constant

Source line 6513

std.os.linux.SER.RS485.ENABLED

constant

Source line 6508

std.os.linux.SER.RS485.RTS_AFTER_SEND

constant

Source line 6510

std.os.linux.SER.RS485.RTS_ON_SEND

constant

Source line 6509

std.os.linux.SER.RS485.RX_DURING_TX

constant

Source line 6511

std.os.linux.SER.RS485.TERMINATE_BUS

constant

Source line 6512

std.os.linux.serial_iso7816

container

Source line 6497

Fields

flags: u32
tg: u32
sc_fi: u32
sc_di: u32
clk: u32
_reserved: [5]u32

std.os.linux.serial_rs485

container

Source line 6482

Fields

flags: u32
delay_rts_before_send: u32
delay_rts_after_send: u32
extra: extern union {
    _pad1: [5]u32,
    s: extern struct {
        addr_recv: u8,
        addr_dest: u8,
        _pad2: [2]u8,
        _pad3: [4]u32,
    },
}

std.os.linux.set_tid_address

function

Source line 2026

This call cannot fail, and the return value is the caller's thread id

pub fn set_tid_address(tidptr: ?*pid_t) pid_t

Parameters

tidptr: ?*pid_t

std.os.linux.setegid

function

Source line 2582

pub fn setegid(egid: gid_t) usize

Parameters

egid: gid_t

std.os.linux.seteuid

function

Source line 2571

pub fn seteuid(euid: uid_t) usize

Parameters

euid: uid_t

std.os.linux.setgid

function

Source line 2515

pub fn setgid(gid: gid_t) usize

Parameters

gid: gid_t

std.os.linux.setgroups

function

Source line 2641

pub fn setgroups(size: usize, list: [*]const gid_t) usize

Parameters

size: usize
list: [*]const gid_t

std.os.linux.setitimer

function

Source line 3165

pub fn setitimer(which: i32, new_value: *const itimerspec, old_value: ?*itimerspec) usize

Parameters

which: i32
new_value: *const itimerspec
old_value: ?*itimerspec

std.os.linux.setns

function

Source line 3173

pub fn setns(fd: fd_t, flags: u32) usize

Parameters

fd: fd_t
flags: u32

std.os.linux.setpgid

function

Source line 2625

pub fn setpgid(pid: pid_t, pgid: pid_t) usize

Parameters

pid: pid_t
pgid: pid_t

std.os.linux.setregid

function

Source line 2531

pub fn setregid(rgid: gid_t, egid: gid_t) usize

Parameters

rgid: gid_t
egid: gid_t

std.os.linux.setresgid

function

Source line 2617

pub fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) usize

Parameters

rgid: gid_t
egid: gid_t
sgid: gid_t

std.os.linux.setresuid

function

Source line 2609

pub fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) usize

Parameters

ruid: uid_t
euid: uid_t
suid: uid_t

std.os.linux.setreuid

function

Source line 2523

pub fn setreuid(ruid: uid_t, euid: uid_t) usize

Parameters

ruid: uid_t
euid: uid_t

std.os.linux.setrlimit

function

Source line 3282

pub fn setrlimit(resource: rlimit_resource, rlim: *const rlimit) usize

Parameters

resource: rlimit_resource
rlim: *const rlimit

std.os.linux.setsid

function

Source line 2649

pub fn setsid() usize

std.os.linux.setsockopt

function

Source line 2806

pub fn setsockopt(fd: fd_t, level: i32, optname: u32, optval: [*]const u8, optlen: socklen_t) usize

Parameters

fd: fd_t
level: i32
optname: u32
optval: [*]const u8
optlen: socklen_t

std.os.linux.settimeofday

function

Source line 2491

pub fn settimeofday(tv: *const timeval, tz: *const timezone) usize

Parameters

tv: *const timeval
tz: *const timezone

std.os.linux.setuid

function

Source line 2507

pub fn setuid(uid: uid_t) usize

Parameters

uid: uid_t

std.os.linux.setxattr

function

Source line 2968

pub fn setxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]const u8, size: usize, flags: usize) usize

Parameters

path: [*:0]const u8
name: [*:0]const u8
value: [*]const u8
size: usize
flags: usize

std.os.linux.SFD

namespace

Source line 7037

std.os.linux.SFD.CLOEXEC

constant

Source line 7038

std.os.linux.SFD.NONBLOCK

constant

Source line 7039

std.os.linux.sgttyb

type

Source line 8954

std.os.linux.SHADOW_STACK

namespace

Source line 11212

std.os.linux.SHADOW_STACK.SET_TOKEN

constant

Source line 11214

Set up a restore token in the shadow stack.

u64

std.os.linux.SHUT

namespace

Source line 4988

std.os.linux.SHUT.RD

constant

Source line 4989

std.os.linux.SHUT.RDWR

constant

Source line 4991

std.os.linux.SHUT.WR

constant

Source line 4990

std.os.linux.shutdown

function

Source line 2874

pub fn shutdown(fd: fd_t, how: i32) usize

Parameters

fd: fd_t
how: i32

std.os.linux.SIG

type

Source line 4746

std.os.linux.SIG.BLOCK

constant

Source line 4747

std.os.linux.SIG.BLOCK

constant

Source line 4792

std.os.linux.SIG.BLOCK

constant

Source line 4838

std.os.linux.SIG.BLOCK

constant

Source line 4883

std.os.linux.SIG.BLOCK

constant

Source line 4927

std.os.linux.SIG.CLD

constant

Source line 4801

SIG

std.os.linux.SIG.DFL

constant

Source line 4752

?Sigaction.handler_fn

std.os.linux.SIG.DFL

constant

Source line 4797

?Sigaction.handler_fn

std.os.linux.SIG.DFL

constant

Source line 4843

?Sigaction.handler_fn

std.os.linux.SIG.DFL

constant

Source line 4888

?Sigaction.handler_fn

std.os.linux.SIG.DFL

constant

Source line 4932

?Sigaction.handler_fn

std.os.linux.SIG.ERR

constant

Source line 4751

?Sigaction.handler_fn

std.os.linux.SIG.ERR

constant

Source line 4796

?Sigaction.handler_fn

std.os.linux.SIG.ERR

constant

Source line 4842

?Sigaction.handler_fn

std.os.linux.SIG.ERR

constant

Source line 4887

?Sigaction.handler_fn

std.os.linux.SIG.ERR

constant

Source line 4931

?Sigaction.handler_fn

std.os.linux.SIG.IGN

constant

Source line 4753

?Sigaction.handler_fn

std.os.linux.SIG.IGN

constant

Source line 4798

?Sigaction.handler_fn

std.os.linux.SIG.IGN

constant

Source line 4844

?Sigaction.handler_fn

std.os.linux.SIG.IGN

constant

Source line 4889

?Sigaction.handler_fn

std.os.linux.SIG.IGN

constant

Source line 4933

?Sigaction.handler_fn

std.os.linux.SIG.IOT

constant

Source line 4755

SIG

std.os.linux.SIG.IOT

constant

Source line 4800

SIG

std.os.linux.SIG.IOT

constant

Source line 4848

SIG

std.os.linux.SIG.IOT

constant

Source line 4892

SIG

std.os.linux.SIG.IOT

constant

Source line 4936

SIG

std.os.linux.SIG.POLL

constant

Source line 4756

SIG

std.os.linux.SIG.POLL

constant

Source line 4803

SIG

std.os.linux.SIG.POLL

constant

Source line 4846

SIG

std.os.linux.SIG.POLL

constant

Source line 4891

SIG

std.os.linux.SIG.POLL

constant

Source line 4935

SIG

std.os.linux.SIG.PWR

constant

Source line 4802

SIG

std.os.linux.SIG.PWR

constant

Source line 4847

SIG

std.os.linux.SIG.SETMASK

constant

Source line 4749

std.os.linux.SIG.SETMASK

constant

Source line 4794

std.os.linux.SIG.SETMASK

constant

Source line 4840

std.os.linux.SIG.SETMASK

constant

Source line 4885

std.os.linux.SIG.SETMASK

constant

Source line 4929

std.os.linux.SIG.UNBLOCK

constant

Source line 4748

std.os.linux.SIG.UNBLOCK

constant

Source line 4793

std.os.linux.SIG.UNBLOCK

constant

Source line 4839

std.os.linux.SIG.UNBLOCK

constant

Source line 4884

std.os.linux.SIG.UNBLOCK

constant

Source line 4928

std.os.linux.sigaction

function

Source line 2676

pub fn sigaction(sig: SIG, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) usize

Parameters

sig: SIG
act: ?*const Sigaction
oact: ?*Sigaction

std.os.linux.Sigaction

container

Source line 7021

Kernel Sigaction wrapper for the actual ABI k_sigaction. The Zig linux.zig wrapper library still does some pre-processing on sigaction() calls (to add the restorer field).

Renamed from sigaction to Sigaction to avoid conflict with the syscall.

Fields

handler: extern union {
    handler: ?handler_fn,
    sigaction: ?sigaction_fn,
}
mask: sigset_t
flags: switch (native_arch) {
    .mips, .mipsel, .mips64, .mips64el => c_uint,
    .alpha => c_int,
    else => c_ulong,
}

std.os.linux.Sigaction.handler_fn

type

Source line 7022

std.os.linux.Sigaction.sigaction_fn

type

Source line 7023

std.os.linux.sigaddset

function

Source line 2770

pub fn sigaddset(set: *sigset_t, sig: SIG) void

Parameters

set: *sigset_t
sig: SIG

std.os.linux.sigaltstack

function

Source line 3185

pub fn sigaltstack(ss: ?*const stack_t, old_ss: ?*stack_t) usize

Parameters

ss: ?*const stack_t
old_ss: ?*stack_t

std.os.linux.sigdelset

function

Source line 2775

pub fn sigdelset(set: *sigset_t, sig: SIG) void

Parameters

set: *sigset_t
sig: SIG

std.os.linux.sigemptyset

function

Source line 2751

Zig's version of sigemptyset. Returns initialized sigset_t.

pub fn sigemptyset() sigset_t

std.os.linux.sigfillset

function

Source line 2756

Zig's version of sigfillset. Returns initalized sigset_t.

pub fn sigfillset() sigset_t

std.os.linux.siginfo_fields_union

container

Source line 7430

Fields

pad: [128 - 2 * @sizeOf(c_int) - @sizeOf(c_long)]u8
common: extern struct {
    first: extern union {
        piduid: extern struct {
            pid: pid_t,
            uid: uid_t,
        },
        timer: extern struct {
            timerid: i32,
            overrun: i32,
        },
    },
    second: extern union {
        value: sigval,
        sigchld: extern struct {
            status: i32,
            utime: clock_t,
            stime: clock_t,
        },
    },
}
sigfault: extern struct {
    addr: *allowzero anyopaque,
    addr_lsb: i16,
    first: extern union {
        addr_bnd: extern struct {
            lower: *anyopaque,
            upper: *anyopaque,
        },
        pkey: u32,
    },
}
sigpoll: extern struct {
    band: isize,
    fd: i32,
}
sigsys: extern struct {
    call_addr: *anyopaque,
    syscall: i32,
    native_arch: u32,
}

std.os.linux.siginfo_t

type

Source line 7484

std.os.linux.sigismember

function

Source line 2780

pub fn sigismember(set: *const sigset_t, sig: SIG) bool

Parameters

set: *const sigset_t
sig: SIG

std.os.linux.signalfd

function

Source line 3237

pub fn signalfd(fd: fd_t, mask: *const sigset_t, flags: u32) usize

Parameters

fd: fd_t
mask: *const sigset_t
flags: u32

std.os.linux.signalfd_siginfo

container

Source line 7042

Fields

signo: u32
errno: i32
code: i32
pid: u32
uid: uid_t
fd: i32
tid: u32
band: u32
overrun: u32
trapno: u32
status: i32
int: i32
ptr: u64
utime: u64
stime: u64
addr: u64
addr_lsb: u16
__pad2: u16
syscall: i32
call_addr: u64
native_arch: u32
__pad: [28]u8

std.os.linux.sigprocmask

function

Source line 2672

pub fn sigprocmask(flags: u32, noalias set: ?*const sigset_t, noalias oldset: ?*sigset_t) usize

Parameters

flags: u32
set: ?*const sigset_t
oldset: ?*sigset_t

std.os.linux.sigrtmax

function

Source line 2746

Zig's SIGRTMAX, but is a function for compatibility with glibc

pub fn sigrtmax() u8

std.os.linux.sigrtmin

function

Source line 2738

Zig's SIGRTMIN, but is a function for compatibility with glibc

pub fn sigrtmin() u8

std.os.linux.sigset_bit_index

type-function

Source line 2760

fn sigset_bit_index(sig: SIG) struct { word: usize, mask: SigsetElement }

Parameters

sig: SIG

std.os.linux.sigset_len

constant

Source line 2735

std.os.linux.sigset_t

type

Source line 2731

Linux kernel's sigset_t. This is logically 64-bit on most architectures, but 128-bit on MIPS. Contrast with the 1024-bit sigset_t exported by the glibc and musl library ABIs.

std.os.linux.SigsetElement

type

Source line 2733

std.os.linux.SIGSTKSZ

constant

Source line 7363

std.os.linux.sigval

container

Source line 7425

Fields

int: i32
ptr: *anyopaque

std.os.linux.SIOCADDDLCI

constant

Source line 9233

Create new DLCI device

std.os.linux.SIOCADDMULTI

constant

Source line 9147

Add to Multicast address lists

std.os.linux.SIOCADDRT

constant

Source line 9059

Add routing table entry

std.os.linux.SIOCBONDCHANGEACTIVE

constant

Source line 9261

Update to a new active slave

std.os.linux.SIOCBONDENSLAVE

constant

Source line 9246

Enslave a device to the bond

std.os.linux.SIOCBONDINFOQUERY

constant

Source line 9258

rtn info about bond state

std.os.linux.SIOCBONDRELEASE

constant

Source line 9249

Release a slave from the bond

std.os.linux.SIOCBONDSETHWADDR

constant

Source line 9252

Set the hw addr of the bond

std.os.linux.SIOCBONDSLAVEINFOQUERY

constant

Source line 9255

rtn info about slave state

std.os.linux.SIOCBRADDBR

constant

Source line 9265

Create new bridge device

std.os.linux.SIOCBRADDIF

constant

Source line 9271

Add interface to bridge

std.os.linux.SIOCBRDELBR

constant

Source line 9268

Remove bridge device

std.os.linux.SIOCBRDELIF

constant

Source line 9274

Remove interface from bridge

std.os.linux.SIOCDARP

constant

Source line 9206

Delete ARP table entry

std.os.linux.SIOCDELDLCI

constant

Source line 9236

Delete DLCI device

std.os.linux.SIOCDELMULTI

constant

Source line 9150

Delete from Multicast address lists

std.os.linux.SIOCDELRT

constant

Source line 9062

Delete routing table entry

std.os.linux.SIOCDEVPRIVATE

constant

Source line 9283

Device private ioctl calls

std.os.linux.SIOCDIFADDR

constant

Source line 9162

Delete PA address

std.os.linux.SIOCDRARP

constant

Source line 9216

Delete RARP table entry

std.os.linux.SIOCETHTOOL

constant

Source line 9183

Ethtool interface

std.os.linux.SIOCGARP

constant

Source line 9209

Get ARP table entry

std.os.linux.SIOCGHWTSTAMP

constant

Source line 9280

Set hardware time stamp config

std.os.linux.SIOCGIFADDR

constant

Source line 9084

Get PA address

std.os.linux.SIOCGIFBR

constant

Source line 9171

Bridging support

std.os.linux.SIOCGIFBRDADDR

constant

Source line 9096

Get broadcast PA address

std.os.linux.SIOCGIFCONF

constant

Source line 9075

Get iface list

std.os.linux.SIOCGIFCOUNT

constant

Source line 9168

Get number of devices

std.os.linux.SIOCGIFDSTADDR

constant

Source line 9090

Get remote PA address

std.os.linux.SIOCGIFENCAP

constant

Source line 9132

Get encapsulations

std.os.linux.SIOCGIFFLAGS

constant

Source line 9078

Get flags

std.os.linux.SIOCGIFHWADDR

constant

Source line 9138

Get hardware address

std.os.linux.SIOCGIFINDEX

constant

Source line 9153

name -> if_index mapping

std.os.linux.SIOCGIFMAP

constant

Source line 9226

Get device parameters

std.os.linux.SIOCGIFMEM

constant

Source line 9114

Get memory address (BSD)

std.os.linux.SIOCGIFMETRIC

constant

Source line 9108

Get metric

std.os.linux.SIOCGIFMTU

constant

Source line 9120

Get MTU size

std.os.linux.SIOCGIFNAME

constant

Source line 9069

Get iface name

std.os.linux.SIOCGIFNETMASK

constant

Source line 9102

Get network PA mask

std.os.linux.SIOCGIFPFLAGS

constant

Source line 9159

Get extended flags set

std.os.linux.SIOCGIFSLAVE

constant

Source line 9141

Driver slaving support

std.os.linux.SIOCGIFTXQLEN

constant

Source line 9177

Get the tx queue length

std.os.linux.SIOCGIFVLAN

constant

Source line 9239

802.1Q VLAN support

std.os.linux.SIOCGMIIPHY

constant

Source line 9186

Get address of MII PHY in use.

std.os.linux.SIOCGMIIREG

constant

Source line 9189

Read MII PHY register.

std.os.linux.SIOCGRARP

constant

Source line 9219

Get RARP table entry

std.os.linux.SIOCGSKNS

constant

Source line 9201

Get socket network namespace

std.os.linux.SIOCGSTAMP

constant

Source line 9049

Get stamp (timeval)

std.os.linux.SIOCGSTAMP_NEW

constant

Source line 9045

std.os.linux.SIOCGSTAMP_OLD

constant

Source line 9046

std.os.linux.SIOCGSTAMPNS

constant

Source line 9055

Get stamp (timespec)

std.os.linux.SIOCGSTAMPNS_NEW

constant

Source line 9051

std.os.linux.SIOCGSTAMPNS_OLD

constant

Source line 9052

std.os.linux.SIOCINQ

constant

Source line 9037

Linux-specific socket ioctls

std.os.linux.SIOCOUTQ

constant

Source line 9041

Linux-specific socket ioctls output queue size (not sent + not acked)

std.os.linux.SIOCOUTQNSD

constant

Source line 9198

Output queue size (not sent only)

std.os.linux.SIOCPROTOPRIVATE

constant

Source line 9286

These 16 ioctl calls are protocol private

std.os.linux.SIOCRTMSG

constant

Source line 9065

Unused

std.os.linux.SIOCSARP

constant

Source line 9212

Set ARP table entry

std.os.linux.SIOCSHWTSTAMP

constant

Source line 9277

Get hardware time stamp config

std.os.linux.SIOCSIFADDR

constant

Source line 9087

Set PA address

std.os.linux.SIOCSIFBR

constant

Source line 9174

Set bridging options

std.os.linux.SIOCSIFBRDADDR

constant

Source line 9099

Set broadcast PA address

std.os.linux.SIOCSIFDSTADDR

constant

Source line 9093

Set remote PA address

std.os.linux.SIOCSIFENCAP

constant

Source line 9135

Set encapsulations

std.os.linux.SIOCSIFFLAGS

constant

Source line 9081

Set flags

std.os.linux.SIOCSIFHWADDR

constant

Source line 9129

Set hardware address

std.os.linux.SIOCSIFHWBROADCAST

constant

Source line 9165

Set hardware broadcast addr

std.os.linux.SIOCSIFLINK

constant

Source line 9072

Set iface channel

std.os.linux.SIOCSIFMAP

constant

Source line 9229

Set device parameters

std.os.linux.SIOCSIFMEM

constant

Source line 9117

Set memory address (BSD)

std.os.linux.SIOCSIFMETRIC

constant

Source line 9111

Set metric

std.os.linux.SIOCSIFMTU

constant

Source line 9123

Set MTU size

std.os.linux.SIOCSIFNAME

constant

Source line 9126

Set interface name

std.os.linux.SIOCSIFNETMASK

constant

Source line 9105

Set network PA mask

std.os.linux.SIOCSIFPFLAGS

constant

Source line 9156

Set extended flags set

std.os.linux.SIOCSIFSLAVE

constant

Source line 9144

Driver slaving support

std.os.linux.SIOCSIFTXQLEN

constant

Source line 9180

Set the tx queue length

std.os.linux.SIOCSIFVLAN

constant

Source line 9242

Set 802.1Q VLAN options

std.os.linux.SIOCSMIIREG

constant

Source line 9192

Write MII PHY register.

std.os.linux.SIOCSRARP

constant

Source line 9222

Set RARP table entry

std.os.linux.SIOCWANDEV

constant

Source line 9195

Get / Set netdev parameters

std.os.linux.SO

type

Source line 5222

std.os.linux.SO.ACCEPTCONN

constant

Source line 5239

std.os.linux.SO.ACCEPTCONN

constant

Source line 5313

std.os.linux.SO.ACCEPTCONN

constant

Source line 5382

std.os.linux.SO.ACCEPTCONN

constant

Source line 5447

std.os.linux.SO.ACCEPTCONN

constant

Source line 5522

std.os.linux.SO.ATTACH_BPF

constant

Source line 5273

std.os.linux.SO.ATTACH_BPF

constant

Source line 5342

std.os.linux.SO.ATTACH_BPF

constant

Source line 5411

std.os.linux.SO.ATTACH_BPF

constant

Source line 5482

std.os.linux.SO.ATTACH_BPF

constant

Source line 5551

std.os.linux.SO.ATTACH_FILTER

constant

Source line 5254

std.os.linux.SO.ATTACH_FILTER

constant

Source line 5323

std.os.linux.SO.ATTACH_FILTER

constant

Source line 5392

std.os.linux.SO.ATTACH_FILTER

constant

Source line 5463

std.os.linux.SO.ATTACH_FILTER

constant

Source line 5532

std.os.linux.SO.ATTACH_REUSEPORT_CBPF

constant

Source line 5275

std.os.linux.SO.ATTACH_REUSEPORT_CBPF

constant

Source line 5344

std.os.linux.SO.ATTACH_REUSEPORT_CBPF

constant

Source line 5413

std.os.linux.SO.ATTACH_REUSEPORT_CBPF

constant

Source line 5484

std.os.linux.SO.ATTACH_REUSEPORT_CBPF

constant

Source line 5553

std.os.linux.SO.ATTACH_REUSEPORT_EBPF

constant

Source line 5276

std.os.linux.SO.ATTACH_REUSEPORT_EBPF

constant

Source line 5345

std.os.linux.SO.ATTACH_REUSEPORT_EBPF

constant

Source line 5414

std.os.linux.SO.ATTACH_REUSEPORT_EBPF

constant

Source line 5485

std.os.linux.SO.ATTACH_REUSEPORT_EBPF

constant

Source line 5554

std.os.linux.SO.BINDTODEVICE

constant

Source line 5253

std.os.linux.SO.BINDTODEVICE

constant

Source line 5322

std.os.linux.SO.BINDTODEVICE

constant

Source line 5391

std.os.linux.SO.BINDTODEVICE

constant

Source line 5462

std.os.linux.SO.BINDTODEVICE

constant

Source line 5531

std.os.linux.SO.BINDTOIFINDEX

constant

Source line 5284

std.os.linux.SO.BINDTOIFINDEX

constant

Source line 5353

std.os.linux.SO.BINDTOIFINDEX

constant

Source line 5422

std.os.linux.SO.BINDTOIFINDEX

constant

Source line 5493

std.os.linux.SO.BINDTOIFINDEX

constant

Source line 5562

std.os.linux.SO.BPF_EXTENSIONS

constant

Source line 5271

std.os.linux.SO.BPF_EXTENSIONS

constant

Source line 5340

std.os.linux.SO.BPF_EXTENSIONS

constant

Source line 5409

std.os.linux.SO.BPF_EXTENSIONS

constant

Source line 5480

std.os.linux.SO.BPF_EXTENSIONS

constant

Source line 5549

std.os.linux.SO.BROADCAST

constant

Source line 5227

std.os.linux.SO.BROADCAST

constant

Source line 5297

std.os.linux.SO.BROADCAST

constant

Source line 5366

std.os.linux.SO.BROADCAST

constant

Source line 5434

std.os.linux.SO.BROADCAST

constant

Source line 5506

std.os.linux.SO.BSDCOMPAT

constant

Source line 5244

std.os.linux.SO.BSDCOMPAT

constant

Source line 5305

std.os.linux.SO.BSDCOMPAT

constant

Source line 5374

std.os.linux.SO.BSDCOMPAT

constant

Source line 5453

std.os.linux.SO.BSDCOMPAT

constant

Source line 5514

std.os.linux.SO.BUSY_POLL

constant

Source line 5269

std.os.linux.SO.BUSY_POLL

constant

Source line 5338

std.os.linux.SO.BUSY_POLL

constant

Source line 5407

std.os.linux.SO.BUSY_POLL

constant

Source line 5478

std.os.linux.SO.BUSY_POLL

constant

Source line 5547

std.os.linux.SO.CNX_ADVICE

constant

Source line 5277

std.os.linux.SO.CNX_ADVICE

constant

Source line 5346

std.os.linux.SO.CNX_ADVICE

constant

Source line 5415

std.os.linux.SO.CNX_ADVICE

constant

Source line 5486

std.os.linux.SO.CNX_ADVICE

constant

Source line 5555

std.os.linux.SO.COOKIE

constant

Source line 5280

std.os.linux.SO.COOKIE

constant

Source line 5349

std.os.linux.SO.COOKIE

constant

Source line 5418

std.os.linux.SO.COOKIE

constant

Source line 5489

std.os.linux.SO.COOKIE

constant

Source line 5558

std.os.linux.SO.DEBUG

constant

Source line 5223

std.os.linux.SO.DEBUG

constant

Source line 5292

std.os.linux.SO.DEBUG

constant

Source line 5361

std.os.linux.SO.DEBUG

constant

Source line 5430

std.os.linux.SO.DEBUG

constant

Source line 5501

std.os.linux.SO.DETACH_BPF

alias

Source line 5274

Alias of std.os.linux.SO.DETACH_FILTER

std.os.linux.SO.DETACH_BPF

alias

Source line 5343

Alias of std.os.linux.SO.DETACH_FILTER

std.os.linux.SO.DETACH_BPF

constant

Source line 5412

std.os.linux.SO.DETACH_BPF

alias

Source line 5483

Alias of std.os.linux.SO.DETACH_FILTER

std.os.linux.SO.DETACH_BPF

alias

Source line 5552

Alias of std.os.linux.SO.DETACH_FILTER

std.os.linux.SO.DETACH_FILTER

constant

Source line 5255

std.os.linux.SO.DETACH_FILTER

constant

Source line 5324

std.os.linux.SO.DETACH_FILTER

constant

Source line 5393

std.os.linux.SO.DETACH_FILTER

constant

Source line 5464

std.os.linux.SO.DETACH_FILTER

constant

Source line 5533

std.os.linux.SO.DETACH_REUSEPORT_BPF

constant

Source line 5290

std.os.linux.SO.DETACH_REUSEPORT_BPF

constant

Source line 5359

std.os.linux.SO.DETACH_REUSEPORT_BPF

constant

Source line 5428

std.os.linux.SO.DETACH_REUSEPORT_BPF

constant

Source line 5499

std.os.linux.SO.DETACH_REUSEPORT_BPF

constant

Source line 5568

std.os.linux.SO.DOMAIN

constant

Source line 5241

std.os.linux.SO.DOMAIN

constant

Source line 5318

std.os.linux.SO.DOMAIN

constant

Source line 5387

std.os.linux.SO.DOMAIN

constant

Source line 5449

std.os.linux.SO.DOMAIN

constant

Source line 5527

std.os.linux.SO.DONTROUTE

constant

Source line 5226

std.os.linux.SO.DONTROUTE

constant

Source line 5296

std.os.linux.SO.DONTROUTE

constant

Source line 5365

std.os.linux.SO.DONTROUTE

constant

Source line 5433

std.os.linux.SO.DONTROUTE

constant

Source line 5505

std.os.linux.SO.ERROR

constant

Source line 5237

std.os.linux.SO.ERROR

constant

Source line 5295

std.os.linux.SO.ERROR

constant

Source line 5364

std.os.linux.SO.ERROR

constant

Source line 5445

std.os.linux.SO.ERROR

constant

Source line 5504

std.os.linux.SO.GET_FILTER

alias

Source line 5256

Alias of std.os.linux.SO.ATTACH_FILTER

std.os.linux.SO.GET_FILTER

alias

Source line 5325

Alias of std.os.linux.SO.ATTACH_FILTER

std.os.linux.SO.GET_FILTER

constant

Source line 5394

std.os.linux.SO.GET_FILTER

alias

Source line 5465

Alias of std.os.linux.SO.ATTACH_FILTER

std.os.linux.SO.GET_FILTER

alias

Source line 5534

Alias of std.os.linux.SO.ATTACH_FILTER

std.os.linux.SO.INCOMING_CPU

constant

Source line 5272

std.os.linux.SO.INCOMING_CPU

constant

Source line 5341

std.os.linux.SO.INCOMING_CPU

constant

Source line 5410

std.os.linux.SO.INCOMING_CPU

constant

Source line 5481

std.os.linux.SO.INCOMING_CPU

constant

Source line 5550

std.os.linux.SO.INCOMING_NAPI_ID

constant

Source line 5279

std.os.linux.SO.INCOMING_NAPI_ID

constant

Source line 5348

std.os.linux.SO.INCOMING_NAPI_ID

constant

Source line 5417

std.os.linux.SO.INCOMING_NAPI_ID

constant

Source line 5488

std.os.linux.SO.INCOMING_NAPI_ID

constant

Source line 5557

std.os.linux.SO.KEEPALIVE

constant

Source line 5225

std.os.linux.SO.KEEPALIVE

constant

Source line 5300

std.os.linux.SO.KEEPALIVE

constant

Source line 5369

std.os.linux.SO.KEEPALIVE

constant

Source line 5432

std.os.linux.SO.KEEPALIVE

constant

Source line 5509

std.os.linux.SO.LINGER

constant

Source line 5228

std.os.linux.SO.LINGER

constant

Source line 5304

std.os.linux.SO.LINGER

constant

Source line 5373

std.os.linux.SO.LINGER

constant

Source line 5435

std.os.linux.SO.LINGER

constant

Source line 5513

std.os.linux.SO.LOCK_FILTER

constant

Source line 5267

std.os.linux.SO.LOCK_FILTER

constant

Source line 5336

std.os.linux.SO.LOCK_FILTER

constant

Source line 5405

std.os.linux.SO.LOCK_FILTER

constant

Source line 5476

std.os.linux.SO.LOCK_FILTER

constant

Source line 5545

std.os.linux.SO.MARK

constant

Source line 5261

std.os.linux.SO.MARK

constant

Source line 5330

std.os.linux.SO.MARK

constant

Source line 5399

std.os.linux.SO.MARK

constant

Source line 5470

std.os.linux.SO.MARK

constant

Source line 5539

std.os.linux.SO.MAX_PACING_RATE

constant

Source line 5270

std.os.linux.SO.MAX_PACING_RATE

constant

Source line 5339

std.os.linux.SO.MAX_PACING_RATE

constant

Source line 5408

std.os.linux.SO.MAX_PACING_RATE

constant

Source line 5479

std.os.linux.SO.MAX_PACING_RATE

constant

Source line 5548

std.os.linux.SO.MEMINFO

constant

Source line 5278

std.os.linux.SO.MEMINFO

constant

Source line 5347

std.os.linux.SO.MEMINFO

constant

Source line 5416

std.os.linux.SO.MEMINFO

constant

Source line 5487

std.os.linux.SO.MEMINFO

constant

Source line 5556

std.os.linux.SO.NO_CHECK

constant

Source line 5242

std.os.linux.SO.NO_CHECK

constant

Source line 5302

std.os.linux.SO.NO_CHECK

constant

Source line 5371

std.os.linux.SO.NO_CHECK

constant

Source line 5451

std.os.linux.SO.NO_CHECK

constant

Source line 5511

std.os.linux.SO.NOFCS

constant

Source line 5266

std.os.linux.SO.NOFCS

constant

Source line 5335

std.os.linux.SO.NOFCS

constant

Source line 5404

std.os.linux.SO.NOFCS

constant

Source line 5475

std.os.linux.SO.NOFCS

constant

Source line 5544

std.os.linux.SO.OOBINLINE

constant

Source line 5229

std.os.linux.SO.OOBINLINE

constant

Source line 5301

std.os.linux.SO.OOBINLINE

constant

Source line 5370

std.os.linux.SO.OOBINLINE

constant

Source line 5436

std.os.linux.SO.OOBINLINE

constant

Source line 5510

std.os.linux.SO.PASSCRED

constant

Source line 5245

std.os.linux.SO.PASSCRED

constant

Source line 5311

std.os.linux.SO.PASSCRED

constant

Source line 5376

std.os.linux.SO.PASSCRED

constant

Source line 5454

std.os.linux.SO.PASSCRED

constant

Source line 5516

std.os.linux.SO.PASSSEC

constant

Source line 5259

std.os.linux.SO.PASSSEC

constant

Source line 5328

std.os.linux.SO.PASSSEC

constant

Source line 5397

std.os.linux.SO.PASSSEC

constant

Source line 5468

std.os.linux.SO.PASSSEC

constant

Source line 5537

std.os.linux.SO.PEEK_OFF

constant

Source line 5265

std.os.linux.SO.PEEK_OFF

constant

Source line 5334

std.os.linux.SO.PEEK_OFF

constant

Source line 5403

std.os.linux.SO.PEEK_OFF

constant

Source line 5474

std.os.linux.SO.PEEK_OFF

constant

Source line 5543

std.os.linux.SO.PEERCRED

constant

Source line 5246

std.os.linux.SO.PEERCRED

constant

Source line 5312

std.os.linux.SO.PEERCRED

constant

Source line 5377

std.os.linux.SO.PEERCRED

constant

Source line 5455

std.os.linux.SO.PEERCRED

constant

Source line 5517

std.os.linux.SO.PEERGROUPS

constant

Source line 5281

std.os.linux.SO.PEERGROUPS

constant

Source line 5350

std.os.linux.SO.PEERGROUPS

constant

Source line 5419

std.os.linux.SO.PEERGROUPS

constant

Source line 5490

std.os.linux.SO.PEERGROUPS

constant

Source line 5559

std.os.linux.SO.PEERNAME

constant

Source line 5257

std.os.linux.SO.PEERNAME

constant

Source line 5326

std.os.linux.SO.PEERNAME

constant

Source line 5395

std.os.linux.SO.PEERNAME

constant

Source line 5466

std.os.linux.SO.PEERNAME

constant

Source line 5535

std.os.linux.SO.PEERSEC

constant

Source line 5247

std.os.linux.SO.PEERSEC

constant

Source line 5314

std.os.linux.SO.PEERSEC

constant

Source line 5383

std.os.linux.SO.PEERSEC

constant

Source line 5456

std.os.linux.SO.PEERSEC

constant

Source line 5523

std.os.linux.SO.PRIORITY

constant

Source line 5243

std.os.linux.SO.PRIORITY

constant

Source line 5303

std.os.linux.SO.PRIORITY

constant

Source line 5372

std.os.linux.SO.PRIORITY

constant

Source line 5452

std.os.linux.SO.PRIORITY

constant

Source line 5512

std.os.linux.SO.PROTOCOL

constant

Source line 5240

std.os.linux.SO.PROTOCOL

constant

Source line 5317

std.os.linux.SO.PROTOCOL

constant

Source line 5386

std.os.linux.SO.PROTOCOL

constant

Source line 5448

std.os.linux.SO.PROTOCOL

constant

Source line 5526

std.os.linux.SO.RCVBUF

constant

Source line 5232

std.os.linux.SO.RCVBUF

constant

Source line 5299

std.os.linux.SO.RCVBUF

constant

Source line 5368

std.os.linux.SO.RCVBUF

constant

Source line 5440

std.os.linux.SO.RCVBUF

constant

Source line 5508

std.os.linux.SO.RCVBUFFORCE

constant

Source line 5249

std.os.linux.SO.RCVBUFFORCE

constant

Source line 5316

std.os.linux.SO.RCVBUFFORCE

constant

Source line 5385

std.os.linux.SO.RCVBUFFORCE

constant

Source line 5458

std.os.linux.SO.RCVBUFFORCE

constant

Source line 5525

std.os.linux.SO.RCVLOWAT

constant

Source line 5234

std.os.linux.SO.RCVLOWAT

constant

Source line 5307

std.os.linux.SO.RCVLOWAT

constant

Source line 5378

std.os.linux.SO.RCVLOWAT

constant

Source line 5442

std.os.linux.SO.RCVLOWAT

constant

Source line 5518

std.os.linux.SO.RCVTIMEO

constant

Source line 5235

std.os.linux.SO.RCVTIMEO

constant

Source line 5309

std.os.linux.SO.RCVTIMEO

constant

Source line 5380

std.os.linux.SO.RCVTIMEO

constant

Source line 5443

std.os.linux.SO.RCVTIMEO

constant

Source line 5520

std.os.linux.SO.RCVTIMEO_NEW

constant

Source line 5288

std.os.linux.SO.RCVTIMEO_NEW

constant

Source line 5357

std.os.linux.SO.RCVTIMEO_NEW

constant

Source line 5426

std.os.linux.SO.RCVTIMEO_NEW

constant

Source line 5497

std.os.linux.SO.RCVTIMEO_NEW

constant

Source line 5566

std.os.linux.SO.REUSEADDR

constant

Source line 5224

std.os.linux.SO.REUSEADDR

constant

Source line 5293

std.os.linux.SO.REUSEADDR

constant

Source line 5362

std.os.linux.SO.REUSEADDR

constant

Source line 5431

std.os.linux.SO.REUSEADDR

constant

Source line 5502

std.os.linux.SO.REUSEPORT

constant

Source line 5230

std.os.linux.SO.REUSEPORT

constant

Source line 5306

std.os.linux.SO.REUSEPORT

constant

Source line 5375

std.os.linux.SO.REUSEPORT

constant

Source line 5437

std.os.linux.SO.REUSEPORT

constant

Source line 5515

std.os.linux.SO.RXQ_OVFL

constant

Source line 5263

std.os.linux.SO.RXQ_OVFL

constant

Source line 5332

std.os.linux.SO.RXQ_OVFL

constant

Source line 5401

std.os.linux.SO.RXQ_OVFL

constant

Source line 5472

std.os.linux.SO.RXQ_OVFL

constant

Source line 5541

std.os.linux.SO.SECURITY_AUTHENTICATION

constant

Source line 5250

std.os.linux.SO.SECURITY_AUTHENTICATION

constant

Source line 5319

std.os.linux.SO.SECURITY_AUTHENTICATION

constant

Source line 5388

std.os.linux.SO.SECURITY_AUTHENTICATION

constant

Source line 5459

std.os.linux.SO.SECURITY_AUTHENTICATION

constant

Source line 5528

std.os.linux.SO.SECURITY_ENCRYPTION_NETWORK

constant

Source line 5252

std.os.linux.SO.SECURITY_ENCRYPTION_NETWORK

constant

Source line 5321

std.os.linux.SO.SECURITY_ENCRYPTION_NETWORK

constant

Source line 5390

std.os.linux.SO.SECURITY_ENCRYPTION_NETWORK

constant

Source line 5461

std.os.linux.SO.SECURITY_ENCRYPTION_NETWORK

constant

Source line 5530

std.os.linux.SO.SECURITY_ENCRYPTION_TRANSPORT

constant

Source line 5251

std.os.linux.SO.SECURITY_ENCRYPTION_TRANSPORT

constant

Source line 5320

std.os.linux.SO.SECURITY_ENCRYPTION_TRANSPORT

constant

Source line 5389

std.os.linux.SO.SECURITY_ENCRYPTION_TRANSPORT

constant

Source line 5460

std.os.linux.SO.SECURITY_ENCRYPTION_TRANSPORT

constant

Source line 5529

std.os.linux.SO.SELECT_ERR_QUEUE

constant

Source line 5268

std.os.linux.SO.SELECT_ERR_QUEUE

constant

Source line 5337

std.os.linux.SO.SELECT_ERR_QUEUE

constant

Source line 5406

std.os.linux.SO.SELECT_ERR_QUEUE

constant

Source line 5477

std.os.linux.SO.SELECT_ERR_QUEUE

constant

Source line 5546

std.os.linux.SO.SNDBUF

constant

Source line 5231

std.os.linux.SO.SNDBUF

constant

Source line 5298

std.os.linux.SO.SNDBUF

constant

Source line 5367

std.os.linux.SO.SNDBUF

constant

Source line 5439

std.os.linux.SO.SNDBUF

constant

Source line 5507

std.os.linux.SO.SNDBUFFORCE

constant

Source line 5248

std.os.linux.SO.SNDBUFFORCE

constant

Source line 5315

std.os.linux.SO.SNDBUFFORCE

constant

Source line 5384

std.os.linux.SO.SNDBUFFORCE

constant

Source line 5457

std.os.linux.SO.SNDBUFFORCE

constant

Source line 5524

std.os.linux.SO.SNDLOWAT

constant

Source line 5233

std.os.linux.SO.SNDLOWAT

constant

Source line 5308

std.os.linux.SO.SNDLOWAT

constant

Source line 5379

std.os.linux.SO.SNDLOWAT

constant

Source line 5441

std.os.linux.SO.SNDLOWAT

constant

Source line 5519

std.os.linux.SO.SNDTIMEO

constant

Source line 5236

std.os.linux.SO.SNDTIMEO

constant

Source line 5310

std.os.linux.SO.SNDTIMEO

constant

Source line 5381

std.os.linux.SO.SNDTIMEO

constant

Source line 5444

std.os.linux.SO.SNDTIMEO

constant

Source line 5521

std.os.linux.SO.SNDTIMEO_NEW

constant

Source line 5289

std.os.linux.SO.SNDTIMEO_NEW

constant

Source line 5358

std.os.linux.SO.SNDTIMEO_NEW

constant

Source line 5427

std.os.linux.SO.SNDTIMEO_NEW

constant

Source line 5498

std.os.linux.SO.SNDTIMEO_NEW

constant

Source line 5567

std.os.linux.SO.TIMESTAMP_NEW

constant

Source line 5285

std.os.linux.SO.TIMESTAMP_NEW

constant

Source line 5354

std.os.linux.SO.TIMESTAMP_NEW

constant

Source line 5423

std.os.linux.SO.TIMESTAMP_NEW

constant

Source line 5494

std.os.linux.SO.TIMESTAMP_NEW

constant

Source line 5563

std.os.linux.SO.TIMESTAMP_OLD

constant

Source line 5258

std.os.linux.SO.TIMESTAMP_OLD

constant

Source line 5327

std.os.linux.SO.TIMESTAMP_OLD

constant

Source line 5396

std.os.linux.SO.TIMESTAMP_OLD

constant

Source line 5467

std.os.linux.SO.TIMESTAMP_OLD

constant

Source line 5536

std.os.linux.SO.TIMESTAMPING_NEW

constant

Source line 5287

std.os.linux.SO.TIMESTAMPING_NEW

constant

Source line 5356

std.os.linux.SO.TIMESTAMPING_NEW

constant

Source line 5425

std.os.linux.SO.TIMESTAMPING_NEW

constant

Source line 5496

std.os.linux.SO.TIMESTAMPING_NEW

constant

Source line 5565

std.os.linux.SO.TIMESTAMPING_OLD

constant

Source line 5262

std.os.linux.SO.TIMESTAMPING_OLD

constant

Source line 5331

std.os.linux.SO.TIMESTAMPING_OLD

constant

Source line 5400

std.os.linux.SO.TIMESTAMPING_OLD

constant

Source line 5471

std.os.linux.SO.TIMESTAMPING_OLD

constant

Source line 5540

std.os.linux.SO.TIMESTAMPNS_NEW

constant

Source line 5286

std.os.linux.SO.TIMESTAMPNS_NEW

constant

Source line 5355

std.os.linux.SO.TIMESTAMPNS_NEW

constant

Source line 5424

std.os.linux.SO.TIMESTAMPNS_NEW

constant

Source line 5495

std.os.linux.SO.TIMESTAMPNS_NEW

constant

Source line 5564

std.os.linux.SO.TIMESTAMPNS_OLD

constant

Source line 5260

std.os.linux.SO.TIMESTAMPNS_OLD

constant

Source line 5329

std.os.linux.SO.TIMESTAMPNS_OLD

constant

Source line 5398

std.os.linux.SO.TIMESTAMPNS_OLD

constant

Source line 5469

std.os.linux.SO.TIMESTAMPNS_OLD

constant

Source line 5538

std.os.linux.SO.TXTIME

constant

Source line 5283

std.os.linux.SO.TXTIME

constant

Source line 5352

std.os.linux.SO.TXTIME

constant

Source line 5421

std.os.linux.SO.TXTIME

constant

Source line 5492

std.os.linux.SO.TXTIME

constant

Source line 5561

std.os.linux.SO.TYPE

constant

Source line 5238

std.os.linux.SO.TYPE

constant

Source line 5294

std.os.linux.SO.TYPE

constant

Source line 5363

std.os.linux.SO.TYPE

constant

Source line 5446

std.os.linux.SO.TYPE

constant

Source line 5503

std.os.linux.SO.WIFI_STATUS

constant

Source line 5264

std.os.linux.SO.WIFI_STATUS

constant

Source line 5333

std.os.linux.SO.WIFI_STATUS

constant

Source line 5402

std.os.linux.SO.WIFI_STATUS

constant

Source line 5473

std.os.linux.SO.WIFI_STATUS

constant

Source line 5542

std.os.linux.SO.ZEROCOPY

constant

Source line 5282

std.os.linux.SO.ZEROCOPY

constant

Source line 5351

std.os.linux.SO.ZEROCOPY

constant

Source line 5420

std.os.linux.SO.ZEROCOPY

constant

Source line 5491

std.os.linux.SO.ZEROCOPY

constant

Source line 5560

std.os.linux.SOCK

namespace

Source line 4994

std.os.linux.SOCK_IOC_TYPE

constant

Source line 9043

std.os.linux.SOCK.CLOEXEC

constant

Source line 5002

std.os.linux.SOCK.DCCP

constant

Source line 5000

std.os.linux.SOCK.DGRAM

constant

Source line 4996

std.os.linux.SOCK.NONBLOCK

constant

Source line 5008

std.os.linux.SOCK.PACKET

constant

Source line 5001

std.os.linux.SOCK.RAW

constant

Source line 4997

std.os.linux.SOCK.RDM

constant

Source line 4998

std.os.linux.SOCK.SEQPACKET

constant

Source line 4999

std.os.linux.SOCK.STREAM

constant

Source line 4995

std.os.linux.sockaddr

container

Source line 7071

Fields

family: sa_family_t
data: [14]u8

std.os.linux.sockaddr.in

container

Source line 7087

IPv4 socket address

Fields

family: sa_family_t = AF.INET
port: in_port_t
addr: u32
zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }

std.os.linux.sockaddr.in6

container

Source line 7095

IPv6 socket address

Fields

family: sa_family_t = AF.INET6
port: in_port_t
flowinfo: u32
addr: [16]u8
scope_id: u32

std.os.linux.sockaddr.ll

container

Source line 7110

Packet socket address

Fields

family: sa_family_t = AF.PACKET
protocol: u16
ifindex: i32
hatype: u16
pkttype: u8
halen: u8
addr: [8]u8

std.os.linux.sockaddr.nl

container

Source line 7121

Netlink socket address

Fields

family: sa_family_t = AF.NETLINK
__pad1: c_ushort = 0
pid: u32

port ID

groups: u32

multicast groups mask

std.os.linux.sockaddr.SS_MAXSIZE

constant

Source line 7075

std.os.linux.sockaddr.storage

container

Source line 7076

Fields

family: sa_family_t align(8)
padding: [SS_MAXSIZE - @sizeOf(sa_family_t)]u8 = undefined

std.os.linux.sockaddr.un

container

Source line 7104

UNIX domain socket address

Fields

family: sa_family_t = AF.UNIX
path: [108]u8

std.os.linux.sockaddr.vm

container

Source line 7141

Address structure for vSockets

Fields

family: sa_family_t = AF.VSOCK
reserved1: u16 = 0
port: u32
cid: u32
flags: u8
zero: [3]u8 = @splat(0)

The total size of this structure should be exactly the same as that of struct sockaddr.

std.os.linux.sockaddr.xdp

container

Source line 7132

Fields

family: u16 = AF.XDP
flags: u16
ifindex: u32
queue_id: u32
shared_umem_fd: u32

std.os.linux.socket

function

Source line 2799

pub fn socket(domain: u32, socket_type: u32, protocol: u32) usize

Parameters

domain: u32
socket_type: u32
protocol: u32

std.os.linux.socket_t

alias

Source line 120

Alias of std.os.linux.fd_t

std.os.linux.socketcall

constant

Source line 80

std.os.linux.socketpair

function

Source line 2912

pub fn socketpair(domain: u32, socket_type: u32, protocol: u32, fd: *[2]fd_t) usize

Parameters

domain: u32
socket_type: u32
protocol: u32
fd: *[2]fd_t

std.os.linux.socklen_t

type

Source line 7069

std.os.linux.SOL

namespace

Source line 5584

std.os.linux.SOL.AAL

constant

Source line 5599

std.os.linux.SOL.ALG

constant

Source line 5613

std.os.linux.SOL.ATM

constant

Source line 5598

std.os.linux.SOL.BLUETOOTH

constant

Source line 5608

std.os.linux.SOL.CAIF

constant

Source line 5612

std.os.linux.SOL.DCCP

constant

Source line 5603

std.os.linux.SOL.DECNET

constant

Source line 5595

std.os.linux.SOL.ICMPV6

constant

Source line 5592

std.os.linux.SOL.IP

constant

Source line 5590

std.os.linux.SOL.IPV6

constant

Source line 5591

std.os.linux.SOL.IRDA

constant

Source line 5600

std.os.linux.SOL.IUCV

constant

Source line 5611

std.os.linux.SOL.KCM

constant

Source line 5615

std.os.linux.SOL.LLC

constant

Source line 5602

std.os.linux.SOL.NETBEUI

constant

Source line 5601

std.os.linux.SOL.NETLINK

constant

Source line 5604

std.os.linux.SOL.NFC

constant

Source line 5614

std.os.linux.SOL.PACKET

constant

Source line 5597

std.os.linux.SOL.PNPIPE

constant

Source line 5609

std.os.linux.SOL.PPPOL2TP

constant

Source line 5607

std.os.linux.SOL.RAW

constant

Source line 5594

std.os.linux.SOL.RDS

constant

Source line 5610

std.os.linux.SOL.RXRPC

constant

Source line 5606

std.os.linux.SOL.SOCKET

constant

Source line 5585

std.os.linux.SOL.TIPC

constant

Source line 5605

std.os.linux.SOL.TLS

constant

Source line 5616

std.os.linux.SOL.X25

constant

Source line 5596

std.os.linux.SOL.XDP

constant

Source line 5617

std.os.linux.SOMAXCONN

constant

Source line 5620

std.os.linux.speed_t

type

Source line 8518

std.os.linux.speed_t.EXTA

constant

Source line 8552

std.os.linux.speed_t.EXTA

constant

Source line 8588

std.os.linux.speed_t.EXTA

constant

Source line 8624

std.os.linux.speed_t.EXTB

constant

Source line 8553

std.os.linux.speed_t.EXTB

constant

Source line 8589

std.os.linux.speed_t.EXTB

constant

Source line 8625

std.os.linux.splitValue64

function

Source line 1027

fn splitValue64(val: i64) [2]u32

Parameters

val: i64

std.os.linux.splitValueBE64

function

Source line 1020

fn splitValueBE64(val: i64) [2]u32

Parameters

val: i64

std.os.linux.splitValueLE64

function

Source line 1013

fn splitValueLE64(val: i64) [2]u32

Parameters

val: i64

std.os.linux.SS

namespace

Source line 7405

std.os.linux.SS.AUTODISARM

constant

Source line 7408

std.os.linux.SS.DISABLE

constant

Source line 7407

std.os.linux.SS.ONSTACK

constant

Source line 7406

std.os.linux.stack_t

type

Source line 7411

std.os.linux.statx

function

Source line 2933

pub fn statx(dirfd: fd_t, path: [*:0]const u8, flags: u32, mask: STATX, statx_buf: *Statx) usize

Parameters

dirfd: fd_t
path: [*:0]const u8
flags: u32
mask: STATX
statx_buf: *Statx

std.os.linux.Statx

container

Source line 8259

Renamed to Statx to not conflict with the statx function.

Fields

mask: STATX

Mask of bits indicating filled fields. Updated with what information the kernel returned. Callers must check this field since support varies by kernel version and filesystem.

blksize: u32

Block size for filesystem I/O.

attributes: STATX_ATTR

Extra file attribute indicators.

nlink: u32

Number of hard links.

uid: uid_t

User ID of owner.

gid: gid_t

Group ID of owner.

mode: u16

File type and mode.

__spare0: u16
ino: u64

Inode number.

size: u64

Total size in bytes.

blocks: u64

Number of 512B blocks allocated.

attributes_mask: STATX_ATTR

Mask to show what's supported in attributes.

atime: statx_timestamp

Last access file timestamp.

btime: statx_timestamp

Creation file timestamp.

ctime: statx_timestamp

Last status change file timestamp.

mtime: statx_timestamp

Last modification file timestamp.

rdev_major: u32

Major ID, if this file represents a device.

rdev_minor: u32

Minor ID, if this file represents a device.

dev_major: u32

Major ID of the device containing the filesystem where this file resides.

dev_minor: u32

Minor ID of the device containing the filesystem where this file resides.

mnt_id: u64

Mount ID

dio_mem_align: u32

Memory buffer alignment for direct I/O.

dio_offset_align: u32

File offset alignment for direct I/O.

subvol: u64

Subvolume identifier.

atomic_write_unit_min: u32

Min atomic write unit in bytes.

atomic_write_unit_max: u32

Max atomic write unit in bytes.

atomic_write_segments_max: u32

Max atomic write segment count.

dio_read_offset_align: u32

File offset alignment for direct I/O reads.

atomic_write_unit_max_opt: u32

Optimised max atomic write unit in bytes.

__spare2: [1]u32
__spare3: [8]u64

std.os.linux.STATX

container

Source line 8173

Fields

TYPE: bool = false

Want mode & S.IFMT.

MODE: bool = false

Want mode & ~S.IFMT.

NLINK: bool = false

Want the nlink member.

UID: bool = false

Want the uid member.

GID: bool = false

Want the gid member.

ATIME: bool = false

Want the atime member.

MTIME: bool = false

Want the mtime member.

CTIME: bool = false

Want the ctime member.

INO: bool = false

Want the ino member.

SIZE: bool = false

Want the size member.

BLOCKS: bool = false

Want the blocks member.

BTIME: bool = false

Want the btime member.

MNT_ID: bool = false

Want the mnt_id member.

DIOALIGN: bool = false

Want the dio_mem_align and dio_offset_align members.

MNT_ID_UNIQUE: bool = false

Want the stx_mnt_id member.

SUBVOL: bool = false

Want the sub member.

WRITE_ATOMIC: bool = false

Want the atomic_write_unit_min, atomic_write_unit_max and atomic_write_segments_max members.

DIO_READ_ALIGN: bool = false

Want the dio_read_offset_align member.

__pad: u13 = 0
__RESERVED: bool = false

Reserved for future expansion; must not be set.

std.os.linux.STATX_ATTR

container

Source line 8222

Attributes about the state or features of a file as a bitmask. Flags marked [I] correspond to the FS_IOC_SETFLAGS values semantically. See FS_IOC_SETFLAGS(2const) for more.

Fields

__pad1: u3 = 0
COMPRESSED: bool = false

[I] File is compressed by the fs.

__pad2: u1 = 0
IMMUTABLE: bool = false

[I] File is marked immutable.

APPEND: bool = false

[I] File is append-only.

NODUMP: bool = false

[I] File is not to be dumped.

ENCRYPTED: bool = false

[I] File requires a key to decrypt in the filesystem.

AUTOMOUNT: bool = false

File names a directory that triggers an automount.

MOUNT_ROOT: bool = false

File names the root of a mount.

VERITY: bool = false

[I] File is protected by the dm-verity device.

DAX: bool = false

File is currently in the CPU direct access state. Does not correspond to the per-inode DAX flag that some filesystems support.

WRITE_ATOMIC: bool = false

File supports atomic write operations.

__pad3: u50 = 0

std.os.linux.statx_timestamp

container

Source line 8249

Fields

sec: i64

Number of seconds before or after 1970-01-01T00:00:00Z.

nsec: u32

Number of nanoseconds (0..999,999,999) after sec.

__pad1: u32

std.os.linux.STATX.BASIC_STATS

constant

Source line 8215

STATX

std.os.linux.std

alias

Source line 6

Alias of std

std.os.linux.STDERR_FILENO

constant

Source line 4477

std.os.linux.STDIN_FILENO

constant

Source line 4475

std.os.linux.STDOUT_FILENO

constant

Source line 4476

std.os.linux.symlink

function

Source line 1864

pub fn symlink(existing: [*:0]const u8, new: [*:0]const u8) usize

Parameters

existing: [*:0]const u8
new: [*:0]const u8

std.os.linux.symlinkat

function

Source line 1872

pub fn symlinkat(existing: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8) usize

Parameters

existing: [*:0]const u8
newfd: fd_t
newpath: [*:0]const u8

std.os.linux.sync

function

Source line 3257

pub fn sync() void

std.os.linux.syncfs

function

Source line 3261

pub fn syncfs(fd: fd_t) usize

Parameters

fd: fd_t

std.os.linux.SYS

type

Source line 132

std.os.linux.sys_riscv_hwprobe

function

Source line 3568

pub fn sys_riscv_hwprobe( pairs: [*]riscv_hwprobe, pair_count: usize, cpusetsize: usize, cpus: ?[*]cpu_set_t, flags: u32, ) usize

Parameters

pairs: [*]riscv_hwprobe
pair_count: usize
cpusetsize: usize
cpus: ?[*]cpu_set_t
flags: u32

std.os.linux.syscall_arg_t

constant

Source line 69

std.os.linux.syscall_bits

type

Source line 67

std.os.linux.syscall_fork

constant

Source line 82

std.os.linux.syscall_lseek

constant

Source line 83

std.os.linux.syscall_pipe

constant

Source line 81

std.os.linux.syscall0

constant

Source line 70

std.os.linux.syscall1

constant

Source line 71

std.os.linux.syscall2

constant

Source line 72

std.os.linux.syscall3

constant

Source line 73

std.os.linux.syscall4

constant

Source line 74

std.os.linux.syscall5

constant

Source line 75

std.os.linux.syscall6

constant

Source line 76

std.os.linux.syscall7

constant

Source line 77

std.os.linux.syscalls

alias

Source line 131

Alias of std.os.linux.syscalls

std.os.linux.sysinfo

function

Source line 3542

pub fn sysinfo(info: *Sysinfo) usize

Parameters

info: *Sysinfo

std.os.linux.Sysinfo

type

Source line 3481

std.os.linux.T

type

Source line 6079

std.os.linux.T.CFLSH

constant

Source line 6087

std.os.linux.T.CFLSH

constant

Source line 6202

std.os.linux.T.CFLSH

constant

Source line 6298

std.os.linux.T.CFLSH

constant

Source line 6390

std.os.linux.T.CGETA

constant

Source line 6080

std.os.linux.T.CGETA

constant

Source line 6195

std.os.linux.T.CGETA

constant

Source line 6292

std.os.linux.T.CGETA

constant

Source line 6384

std.os.linux.T.CGETS

constant

Source line 6089

std.os.linux.T.CGETS

constant

Source line 6190

std.os.linux.T.CGETS

constant

Source line 6299

std.os.linux.T.CGETS

constant

Source line 6380

std.os.linux.T.CGETS2

constant

Source line 6139

std.os.linux.T.CGETS2

constant

Source line 6303

std.os.linux.T.CGETS2

constant

Source line 6421

std.os.linux.T.CGETX

constant

Source line 6430

std.os.linux.T.CSBRK

constant

Source line 6085

std.os.linux.T.CSBRK

constant

Source line 6200

std.os.linux.T.CSBRK

constant

Source line 6296

std.os.linux.T.CSBRK

constant

Source line 6388

std.os.linux.T.CSBRKP

constant

Source line 6163

std.os.linux.T.CSBRKP

constant

Source line 6258

std.os.linux.T.CSBRKP

constant

Source line 6358

std.os.linux.T.CSBRKP

constant

Source line 6417

std.os.linux.T.CSETA

constant

Source line 6081

std.os.linux.T.CSETA

constant

Source line 6196

std.os.linux.T.CSETA

constant

Source line 6293

std.os.linux.T.CSETA

constant

Source line 6385

std.os.linux.T.CSETAF

constant

Source line 6083

std.os.linux.T.CSETAF

constant

Source line 6198

std.os.linux.T.CSETAF

constant

Source line 6295

std.os.linux.T.CSETAF

constant

Source line 6387

std.os.linux.T.CSETAW

constant

Source line 6082

std.os.linux.T.CSETAW

constant

Source line 6197

std.os.linux.T.CSETAW

constant

Source line 6294

std.os.linux.T.CSETAW

constant

Source line 6386

std.os.linux.T.CSETS

constant

Source line 6090

std.os.linux.T.CSETS

constant

Source line 6191

std.os.linux.T.CSETS

constant

Source line 6300

std.os.linux.T.CSETS

constant

Source line 6381

std.os.linux.T.CSETS2

constant

Source line 6140

std.os.linux.T.CSETS2

constant

Source line 6304

std.os.linux.T.CSETS2

constant

Source line 6422

std.os.linux.T.CSETSF

constant

Source line 6092

std.os.linux.T.CSETSF

constant

Source line 6193

std.os.linux.T.CSETSF

constant

Source line 6302

std.os.linux.T.CSETSF

constant

Source line 6383

std.os.linux.T.CSETSF2

constant

Source line 6142

std.os.linux.T.CSETSF2

constant

Source line 6306

std.os.linux.T.CSETSF2

constant

Source line 6424

std.os.linux.T.CSETSW

constant

Source line 6091

std.os.linux.T.CSETSW

constant

Source line 6192

std.os.linux.T.CSETSW

constant

Source line 6301

std.os.linux.T.CSETSW

constant

Source line 6382

std.os.linux.T.CSETSW2

constant

Source line 6141

std.os.linux.T.CSETSW2

constant

Source line 6305

std.os.linux.T.CSETSW2

constant

Source line 6423

std.os.linux.T.CSETX

constant

Source line 6431

std.os.linux.T.CSETXF

constant

Source line 6432

std.os.linux.T.CSETXW

constant

Source line 6433

std.os.linux.T.CXONC

constant

Source line 6086

std.os.linux.T.CXONC

constant

Source line 6201

std.os.linux.T.CXONC

constant

Source line 6297

std.os.linux.T.CXONC

constant

Source line 6389

std.os.linux.T.FIOASYNC

constant

Source line 6119

std.os.linux.T.FIOASYNC

constant

Source line 6178

std.os.linux.T.FIOASYNC

constant

Source line 6349

std.os.linux.T.FIOASYNC

constant

Source line 6445

std.os.linux.T.FIOCLEX

constant

Source line 6117

std.os.linux.T.FIOCLEX

constant

Source line 6176

std.os.linux.T.FIOCLEX

constant

Source line 6347

std.os.linux.T.FIOCLEX

constant

Source line 6444

std.os.linux.T.FIONBIO

constant

Source line 6120

std.os.linux.T.FIONBIO

constant

Source line 6179

std.os.linux.T.FIONBIO

constant

Source line 6350

std.os.linux.T.FIONBIO

constant

Source line 6413

std.os.linux.T.FIONCLEX

constant

Source line 6118

std.os.linux.T.FIONCLEX

constant

Source line 6177

std.os.linux.T.FIONCLEX

constant

Source line 6348

std.os.linux.T.FIONCLEX

constant

Source line 6443

std.os.linux.T.FIONREAD

constant

Source line 6129

std.os.linux.T.FIONREAD

constant

Source line 6180

std.os.linux.T.FIONREAD

constant

Source line 6351

std.os.linux.T.FIONREAD

constant

Source line 6406

std.os.linux.T.FIOQSIZE

constant

Source line 6121

std.os.linux.T.FIOQSIZE

constant

Source line 6182

std.os.linux.T.FIOQSIZE

constant

Source line 6353

std.os.linux.T.FIOQSIZE

constant

Source line 6459

std.os.linux.T.IOCCBRK

constant

Source line 6137

std.os.linux.T.IOCCBRK

constant

Source line 6260

std.os.linux.T.IOCCBRK

constant

Source line 6336

std.os.linux.T.IOCCBRK

constant

Source line 6419

std.os.linux.T.IOCCONS

constant

Source line 6127

std.os.linux.T.IOCCONS

constant

Source line 6242

std.os.linux.T.IOCCONS

constant

Source line 6321

std.os.linux.T.IOCCONS

constant

Source line 6409

std.os.linux.T.IOCEXCL

constant

Source line 6094

std.os.linux.T.IOCEXCL

constant

Source line 6215

std.os.linux.T.IOCEXCL

constant

Source line 6319

std.os.linux.T.IOCEXCL

constant

Source line 6391

std.os.linux.T.IOCGDEV

constant

Source line 6147

std.os.linux.T.IOCGDEV

constant

Source line 6266

std.os.linux.T.IOCGDEV

constant

Source line 6307

std.os.linux.T.IOCGDEV

constant

Source line 6429

std.os.linux.T.IOCGETC

constant

Source line 6189

std.os.linux.T.IOCGETD

constant

Source line 6115

std.os.linux.T.IOCGETD

constant

Source line 6257

std.os.linux.T.IOCGETD

constant

Source line 6317

std.os.linux.T.IOCGETD

constant

Source line 6416

std.os.linux.T.IOCGETP

constant

Source line 6132

std.os.linux.T.IOCGETP

constant

Source line 6184

std.os.linux.T.IOCGEXCL

constant

Source line 6152

std.os.linux.T.IOCGEXCL

constant

Source line 6271

std.os.linux.T.IOCGEXCL

constant

Source line 6311

std.os.linux.T.IOCGEXCL

constant

Source line 6438

std.os.linux.T.IOCGICOUNT

constant

Source line 6174

std.os.linux.T.IOCGICOUNT

constant

Source line 6288

std.os.linux.T.IOCGICOUNT

constant

Source line 6369

std.os.linux.T.IOCGICOUNT

constant

Source line 6457

std.os.linux.T.IOCGISO7816

constant

Source line 6154

std.os.linux.T.IOCGISO7816

constant

Source line 6273

std.os.linux.T.IOCGISO7816

constant

Source line 6314

std.os.linux.T.IOCGISO7816

constant

Source line 6440

std.os.linux.T.IOCGLCKTRMIOS

constant

Source line 6167

std.os.linux.T.IOCGLCKTRMIOS

constant

Source line 6279

std.os.linux.T.IOCGLCKTRMIOS

constant

Source line 6362

std.os.linux.T.IOCGLCKTRMIOS

constant

Source line 6449

std.os.linux.T.IOCGLTC

constant

Source line 6123

std.os.linux.T.IOCGLTC

constant

Source line 6210

std.os.linux.T.IOCGPGRP

constant

Source line 6126

std.os.linux.T.IOCGPGRP

constant

Source line 6213

std.os.linux.T.IOCGPGRP

constant

Source line 6339

std.os.linux.T.IOCGPGRP

constant

Source line 6394

std.os.linux.T.IOCGPKT

constant

Source line 6150

std.os.linux.T.IOCGPKT

constant

Source line 6269

std.os.linux.T.IOCGPKT

constant

Source line 6309

std.os.linux.T.IOCGPKT

constant

Source line 6436

std.os.linux.T.IOCGPTLCK

constant

Source line 6151

std.os.linux.T.IOCGPTLCK

constant

Source line 6270

std.os.linux.T.IOCGPTLCK

constant

Source line 6310

std.os.linux.T.IOCGPTLCK

constant

Source line 6437

std.os.linux.T.IOCGPTN

constant

Source line 6145

std.os.linux.T.IOCGPTN

constant

Source line 6264

std.os.linux.T.IOCGPTN

constant

Source line 6342

std.os.linux.T.IOCGPTN

constant

Source line 6427

std.os.linux.T.IOCGPTPEER

constant

Source line 6153

std.os.linux.T.IOCGPTPEER

constant

Source line 6272

std.os.linux.T.IOCGPTPEER

constant

Source line 6345

std.os.linux.T.IOCGPTPEER

constant

Source line 6439

std.os.linux.T.IOCGRS485

constant

Source line 6143

std.os.linux.T.IOCGRS485

constant

Source line 6262

std.os.linux.T.IOCGRS485

constant

Source line 6312

std.os.linux.T.IOCGRS485

constant

Source line 6425

std.os.linux.T.IOCGSERIAL

constant

Source line 6161

std.os.linux.T.IOCGSERIAL

constant

Source line 6243

std.os.linux.T.IOCGSERIAL

constant

Source line 6356

std.os.linux.T.IOCGSERIAL

constant

Source line 6410

std.os.linux.T.IOCGSID

constant

Source line 6138

std.os.linux.T.IOCGSID

constant

Source line 6261

std.os.linux.T.IOCGSID

constant

Source line 6341

std.os.linux.T.IOCGSID

constant

Source line 6420

std.os.linux.T.IOCGSOFTCAR

constant

Source line 6158

std.os.linux.T.IOCGSOFTCAR

constant

Source line 6239

std.os.linux.T.IOCGSOFTCAR

constant

Source line 6322

std.os.linux.T.IOCGSOFTCAR

constant

Source line 6404

std.os.linux.T.IOCGWINSZ

constant

Source line 6112

std.os.linux.T.IOCGWINSZ

constant

Source line 6205

std.os.linux.T.IOCGWINSZ

constant

Source line 6325

std.os.linux.T.IOCGWINSZ

constant

Source line 6398

std.os.linux.T.IOCINQ

alias

Source line 6130

Alias of std.os.linux.T.FIONREAD

std.os.linux.T.IOCINQ

alias

Source line 6181

Alias of std.os.linux.T.FIONREAD

std.os.linux.T.IOCINQ

alias

Source line 6352

Alias of std.os.linux.T.FIONREAD

std.os.linux.T.IOCINQ

alias

Source line 6407

Alias of std.os.linux.T.FIONREAD

std.os.linux.T.IOCLINUX

constant

Source line 6160

std.os.linux.T.IOCLINUX

constant

Source line 6241

std.os.linux.T.IOCLINUX

constant

Source line 6355

std.os.linux.T.IOCLINUX

constant

Source line 6408

std.os.linux.T.IOCM_CAR

constant

Source line 6230

std.os.linux.T.IOCM_CD

alias

Source line 6233

Alias of std.os.linux.T.IOCM_CAR

std.os.linux.T.IOCM_CTS

constant

Source line 6229

std.os.linux.T.IOCM_DSR

constant

Source line 6232

std.os.linux.T.IOCM_DTR

constant

Source line 6225

std.os.linux.T.IOCM_LE

constant

Source line 6224

std.os.linux.T.IOCM_LOOP

constant

Source line 6237

std.os.linux.T.IOCM_OUT1

constant

Source line 6235

std.os.linux.T.IOCM_OUT2

constant

Source line 6236

std.os.linux.T.IOCM_RI

alias

Source line 6234

Alias of std.os.linux.T.IOCM_RNG

std.os.linux.T.IOCM_RNG

constant

Source line 6231

std.os.linux.T.IOCM_RTS

constant

Source line 6226

std.os.linux.T.IOCM_SR

constant

Source line 6228

std.os.linux.T.IOCM_ST

constant

Source line 6227

std.os.linux.T.IOCMBIC

constant

Source line 6100

std.os.linux.T.IOCMBIC

constant

Source line 6222

std.os.linux.T.IOCMBIC

constant

Source line 6327

std.os.linux.T.IOCMBIC

constant

Source line 6402

std.os.linux.T.IOCMBIS

constant

Source line 6099

std.os.linux.T.IOCMBIS

constant

Source line 6221

std.os.linux.T.IOCMBIS

constant

Source line 6328

std.os.linux.T.IOCMBIS

constant

Source line 6401

std.os.linux.T.IOCMGET

constant

Source line 6098

std.os.linux.T.IOCMGET

constant

Source line 6220

std.os.linux.T.IOCMGET

constant

Source line 6326

std.os.linux.T.IOCMGET

constant

Source line 6400

std.os.linux.T.IOCMIWAIT

constant

Source line 6173

std.os.linux.T.IOCMIWAIT

constant

Source line 6287

std.os.linux.T.IOCMIWAIT

constant

Source line 6368

std.os.linux.T.IOCMIWAIT

constant

Source line 6456

std.os.linux.T.IOCMSET

constant

Source line 6101

std.os.linux.T.IOCMSET

constant

Source line 6223

std.os.linux.T.IOCMSET

constant

Source line 6329

std.os.linux.T.IOCMSET

constant

Source line 6403

std.os.linux.T.IOCNOTTY

constant

Source line 6113

std.os.linux.T.IOCNOTTY

constant

Source line 6255

std.os.linux.T.IOCNOTTY

constant

Source line 6333

std.os.linux.T.IOCNOTTY

constant

Source line 6414

std.os.linux.T.IOCNXCL

constant

Source line 6095

std.os.linux.T.IOCNXCL

constant

Source line 6216

std.os.linux.T.IOCNXCL

constant

Source line 6320

std.os.linux.T.IOCNXCL

constant

Source line 6392

std.os.linux.T.IOCOUTQ

constant

Source line 6096

std.os.linux.T.IOCOUTQ

constant

Source line 6208

std.os.linux.T.IOCOUTQ

constant

Source line 6335

std.os.linux.T.IOCOUTQ

constant

Source line 6396

std.os.linux.T.IOCPKT

constant

Source line 6102

std.os.linux.T.IOCPKT

constant

Source line 6245

std.os.linux.T.IOCPKT

constant

Source line 6332

std.os.linux.T.IOCPKT

constant

Source line 6412

std.os.linux.T.IOCPKT_DATA

constant

Source line 6103

std.os.linux.T.IOCPKT_DATA

constant

Source line 6246

std.os.linux.T.IOCPKT_DATA

constant

Source line 6371

std.os.linux.T.IOCPKT_DATA

constant

Source line 6470

std.os.linux.T.IOCPKT_DOSTOP

constant

Source line 6109

std.os.linux.T.IOCPKT_DOSTOP

constant

Source line 6252

std.os.linux.T.IOCPKT_DOSTOP

constant

Source line 6377

std.os.linux.T.IOCPKT_DOSTOP

constant

Source line 6476

std.os.linux.T.IOCPKT_FLUSHREAD

constant

Source line 6104

std.os.linux.T.IOCPKT_FLUSHREAD

constant

Source line 6247

std.os.linux.T.IOCPKT_FLUSHREAD

constant

Source line 6372

std.os.linux.T.IOCPKT_FLUSHREAD

constant

Source line 6471

std.os.linux.T.IOCPKT_FLUSHWRITE

constant

Source line 6105

std.os.linux.T.IOCPKT_FLUSHWRITE

constant

Source line 6248

std.os.linux.T.IOCPKT_FLUSHWRITE

constant

Source line 6373

std.os.linux.T.IOCPKT_FLUSHWRITE

constant

Source line 6472

std.os.linux.T.IOCPKT_IOCTL

constant

Source line 6110

std.os.linux.T.IOCPKT_IOCTL

constant

Source line 6253

std.os.linux.T.IOCPKT_IOCTL

constant

Source line 6378

std.os.linux.T.IOCPKT_IOCTL

constant

Source line 6477

std.os.linux.T.IOCPKT_NOSTOP

constant

Source line 6108

std.os.linux.T.IOCPKT_NOSTOP

constant

Source line 6251

std.os.linux.T.IOCPKT_NOSTOP

constant

Source line 6376

std.os.linux.T.IOCPKT_NOSTOP

constant

Source line 6475

std.os.linux.T.IOCPKT_START

constant

Source line 6107

std.os.linux.T.IOCPKT_START

constant

Source line 6250

std.os.linux.T.IOCPKT_START

constant

Source line 6375

std.os.linux.T.IOCPKT_START

constant

Source line 6474

std.os.linux.T.IOCPKT_STOP

constant

Source line 6106

std.os.linux.T.IOCPKT_STOP

constant

Source line 6249

std.os.linux.T.IOCPKT_STOP

constant

Source line 6374

std.os.linux.T.IOCPKT_STOP

constant

Source line 6473

std.os.linux.T.IOCSBRK

constant

Source line 6136

std.os.linux.T.IOCSBRK

constant

Source line 6259

std.os.linux.T.IOCSBRK

constant

Source line 6337

std.os.linux.T.IOCSBRK

constant

Source line 6418

std.os.linux.T.IOCSCTTY

constant

Source line 6157

std.os.linux.T.IOCSCTTY

constant

Source line 6217

std.os.linux.T.IOCSCTTY

constant

Source line 6340

std.os.linux.T.IOCSCTTY

constant

Source line 6393

std.os.linux.T.IOCSER_TEMT

constant

Source line 6283

std.os.linux.T.IOCSER_TEMT

constant

Source line 6479

std.os.linux.T.IOCSERCONFIG

constant

Source line 6164

std.os.linux.T.IOCSERCONFIG

constant

Source line 6276

std.os.linux.T.IOCSERCONFIG

constant

Source line 6359

std.os.linux.T.IOCSERCONFIG

constant

Source line 6446

std.os.linux.T.IOCSERGETLSR

constant

Source line 6170

std.os.linux.T.IOCSERGETLSR

constant

Source line 6282

std.os.linux.T.IOCSERGETLSR

constant

Source line 6365

std.os.linux.T.IOCSERGETLSR

constant

Source line 6452

std.os.linux.T.IOCSERGETMULTI

constant

Source line 6171

std.os.linux.T.IOCSERGETMULTI

constant

Source line 6284

std.os.linux.T.IOCSERGETMULTI

constant

Source line 6366

std.os.linux.T.IOCSERGETMULTI

constant

Source line 6453

std.os.linux.T.IOCSERGSTRUCT

constant

Source line 6169

std.os.linux.T.IOCSERGSTRUCT

constant

Source line 6281

std.os.linux.T.IOCSERGSTRUCT

constant

Source line 6364

std.os.linux.T.IOCSERGSTRUCT

constant

Source line 6451

std.os.linux.T.IOCSERGWILD

constant

Source line 6165

std.os.linux.T.IOCSERGWILD

constant

Source line 6277

std.os.linux.T.IOCSERGWILD

constant

Source line 6360

std.os.linux.T.IOCSERGWILD

constant

Source line 6447

std.os.linux.T.IOCSERSETMULTI

constant

Source line 6172

std.os.linux.T.IOCSERSETMULTI

constant

Source line 6285

std.os.linux.T.IOCSERSETMULTI

constant

Source line 6367

std.os.linux.T.IOCSERSETMULTI

constant

Source line 6454

std.os.linux.T.IOCSERSWILD

constant

Source line 6166

std.os.linux.T.IOCSERSWILD

constant

Source line 6278

std.os.linux.T.IOCSERSWILD

constant

Source line 6361

std.os.linux.T.IOCSERSWILD

constant

Source line 6448

std.os.linux.T.IOCSETC

constant

Source line 6188

std.os.linux.T.IOCSETD

constant

Source line 6114

std.os.linux.T.IOCSETD

constant

Source line 6256

std.os.linux.T.IOCSETD

constant

Source line 6318

std.os.linux.T.IOCSETD

constant

Source line 6415

std.os.linux.T.IOCSETN

constant

Source line 6134

std.os.linux.T.IOCSETN

constant

Source line 6186

std.os.linux.T.IOCSETP

constant

Source line 6133

std.os.linux.T.IOCSETP

constant

Source line 6185

std.os.linux.T.IOCSIG

constant

Source line 6148

std.os.linux.T.IOCSIG

constant

Source line 6267

std.os.linux.T.IOCSIG

constant

Source line 6344

std.os.linux.T.IOCSIG

constant

Source line 6434

std.os.linux.T.IOCSISO7816

constant

Source line 6155

std.os.linux.T.IOCSISO7816

constant

Source line 6274

std.os.linux.T.IOCSISO7816

constant

Source line 6315

std.os.linux.T.IOCSISO7816

constant

Source line 6441

std.os.linux.T.IOCSLCKTRMIOS

constant

Source line 6168

std.os.linux.T.IOCSLCKTRMIOS

constant

Source line 6280

std.os.linux.T.IOCSLCKTRMIOS

constant

Source line 6363

std.os.linux.T.IOCSLCKTRMIOS

constant

Source line 6450

std.os.linux.T.IOCSLTC

constant

Source line 6124

std.os.linux.T.IOCSLTC

constant

Source line 6211

std.os.linux.T.IOCSPGRP

constant

Source line 6125

std.os.linux.T.IOCSPGRP

constant

Source line 6212

std.os.linux.T.IOCSPGRP

constant

Source line 6338

std.os.linux.T.IOCSPGRP

constant

Source line 6395

std.os.linux.T.IOCSPTLCK

constant

Source line 6146

std.os.linux.T.IOCSPTLCK

constant

Source line 6265

std.os.linux.T.IOCSPTLCK

constant

Source line 6343

std.os.linux.T.IOCSPTLCK

constant

Source line 6428

std.os.linux.T.IOCSRS485

constant

Source line 6144

std.os.linux.T.IOCSRS485

constant

Source line 6263

std.os.linux.T.IOCSRS485

constant

Source line 6313

std.os.linux.T.IOCSRS485

constant

Source line 6426

std.os.linux.T.IOCSSERIAL

constant

Source line 6162

std.os.linux.T.IOCSSERIAL

constant

Source line 6244

std.os.linux.T.IOCSSERIAL

constant

Source line 6357

std.os.linux.T.IOCSSERIAL

constant

Source line 6411

std.os.linux.T.IOCSSOFTCAR

constant

Source line 6159

std.os.linux.T.IOCSSOFTCAR

constant

Source line 6240

std.os.linux.T.IOCSSOFTCAR

constant

Source line 6323

std.os.linux.T.IOCSSOFTCAR

constant

Source line 6405

std.os.linux.T.IOCSTART

constant

Source line 6206

std.os.linux.T.IOCSTART

constant

Source line 6330

std.os.linux.T.IOCSTI

constant

Source line 6097

std.os.linux.T.IOCSTI

constant

Source line 6219

std.os.linux.T.IOCSTI

constant

Source line 6334

std.os.linux.T.IOCSTI

constant

Source line 6397

std.os.linux.T.IOCSTOP

constant

Source line 6207

std.os.linux.T.IOCSTOP

constant

Source line 6331

std.os.linux.T.IOCSWINSZ

constant

Source line 6111

std.os.linux.T.IOCSWINSZ

constant

Source line 6204

std.os.linux.T.IOCSWINSZ

constant

Source line 6324

std.os.linux.T.IOCSWINSZ

constant

Source line 6399

std.os.linux.T.IOCVHANGUP

constant

Source line 6149

std.os.linux.T.IOCVHANGUP

constant

Source line 6268

std.os.linux.T.IOCVHANGUP

constant

Source line 6308

std.os.linux.T.IOCVHANGUP

constant

Source line 6435

std.os.linux.TABDLY

container

Source line 8683

Fields

TAB0 = 0
TAB1 = 1
TAB2 = 2
TAB3 = 3

std.os.linux.TABDLY.XTABS

constant

Source line 8689

std.os.linux.tc_cflag_t

type

Source line 8766

std.os.linux.tc_iflag_t

type

Source line 8630

std.os.linux.tc_lflag_t

type

Source line 8794

std.os.linux.tc_oflag_t

type

Source line 8707

std.os.linux.tcdrain

function

Source line 3229

pub fn tcdrain(fd: fd_t) usize

Parameters

fd: fd_t

std.os.linux.tcflag_t

type

Source line 8628

std.os.linux.tcgetattr

function

Source line 3213

pub fn tcgetattr(fd: fd_t, termios_p: *termios) usize

Parameters

fd: fd_t
termios_p: *termios

std.os.linux.tcgetpgrp

function

Source line 3221

pub fn tcgetpgrp(fd: fd_t, pgrp: *pid_t) usize

Parameters

fd: fd_t
pgrp: *pid_t

std.os.linux.tchars

type

Source line 8962

std.os.linux.TCP

namespace

Source line 5018

std.os.linux.tcp_fastopen_client_fail

container

Source line 8409

why fastopen failed from client perspective

Fields

TFO_STATUS_UNSPEC

catch-all

TFO_COOKIE_UNAVAILABLE

if not in TFO_CLIENT_NO_COOKIE mode

TFO_DATA_NOT_ACKED

SYN-ACK did not ack SYN data

TFO_SYN_RETRANSMITTED

SYN-ACK did not ack SYN data after timeout

std.os.linux.tcp_repair_opt

container

Source line 8388

Fields

opt_code: u32
opt_val: u32

std.os.linux.tcp_repair_window

container

Source line 8393

Fields

snd_wl1: u32
snd_wnd: u32
max_window: u32
rcv_wnd: u32
rcv_wup: u32

std.os.linux.TCP.CC_INFO

constant

Source line 5064

Get Congestion Control (optional) info

std.os.linux.TCP.CM_INQ

alias

Source line 5084

Alias of std.os.linux.TCP.INQ

std.os.linux.TCP.CONGESTION

constant

Source line 5044

Congestion control algorithm

std.os.linux.TCP.CORK

constant

Source line 5024

Never send partially complete segments.

std.os.linux.TCP.DEFER_ACCEPT

constant

Source line 5036

Wake up listener only when data arrive

std.os.linux.TCP.FASTOPEN

constant

Source line 5059

Enable FastOpen on listeners

std.os.linux.TCP.FASTOPEN_CONNECT

constant

Source line 5072

Attempt FastOpen with connect

std.os.linux.TCP.FASTOPEN_KEY

constant

Source line 5078

Set the key for Fast Open (cookie)

std.os.linux.TCP.FASTOPEN_NO_COOKIE

constant

Source line 5080

Enable TFO without a TFO cookie

std.os.linux.TCP.INFO

constant

Source line 5040

Information about this connection.

std.os.linux.TCP.INQ

constant

Source line 5083

Notify bytes available to read as a cmsg on read

std.os.linux.TCP.KEEPCNT

constant

Source line 5030

Number of keepalives before death

std.os.linux.TCP.KEEPIDLE

constant

Source line 5026

Start keeplives after this period, in seconds

std.os.linux.TCP.KEEPINTVL

constant

Source line 5028

Interval between keepalives

std.os.linux.TCP.LINGER2

constant

Source line 5034

Life time of orphaned FIN-WAIT-2 state

std.os.linux.TCP.MAXSEG

constant

Source line 5022

Limit MSS

std.os.linux.TCP.MD5SIG

constant

Source line 5046

TCP MD5 Signature (RFC2385)

std.os.linux.TCP.MD5SIG_EXT

constant

Source line 5076

TCP MD5 Signature with extensions

std.os.linux.TCP.NODELAY

constant

Source line 5020

Turn off Nagle's algorithm

std.os.linux.TCP.NOTSENT_LOWAT

constant

Source line 5062

limit number of unsent bytes in write queue

std.os.linux.TCP.QUEUE_SEQ

constant

Source line 5056

std.os.linux.TCP.QUICKACK

constant

Source line 5042

Block/reenable quick acks

std.os.linux.TCP.REPAIR

constant

Source line 5054

TCP sock is under repair right now

std.os.linux.TCP.REPAIR_OFF

constant

Source line 5089

std.os.linux.TCP.REPAIR_OFF_NO_WP

constant

Source line 5091

Turn off without window probes

std.os.linux.TCP.REPAIR_ON

constant

Source line 5088

std.os.linux.TCP.REPAIR_OPTIONS

constant

Source line 5057

std.os.linux.TCP.REPAIR_QUEUE

constant

Source line 5055

std.os.linux.TCP.REPAIR_WINDOW

constant

Source line 5070

Get/set window parameters

std.os.linux.TCP.SAVE_SYN

constant

Source line 5066

Record SYN headers for new connections

std.os.linux.TCP.SAVED_SYN

constant

Source line 5068

Get SYN headers recorded for connection

std.os.linux.TCP.SYNCNT

constant

Source line 5032

Number of SYN retransmits

std.os.linux.TCP.THIN_DUPACK

constant

Source line 5050

Fast retrans. after 1 dupack

std.os.linux.TCP.THIN_LINEAR_TIMEOUTS

constant

Source line 5048

Use linear timeouts for thin streams

std.os.linux.TCP.TIMESTAMP

constant

Source line 5060

std.os.linux.TCP.TX_DELAY

constant

Source line 5086

delay outgoing packets by XX usec

std.os.linux.TCP.ULP

constant

Source line 5074

Attach a ULP to a TCP connection

std.os.linux.TCP.USER_TIMEOUT

constant

Source line 5052

How long for loss retry before timeout

std.os.linux.TCP.WINDOW_CLAMP

constant

Source line 5038

Bound advertised window

std.os.linux.TCP.ZEROCOPY_RECEIVE

constant

Source line 5081

std.os.linux.TCPI_OPT_ECN

constant

Source line 8425

ECN was negotiated at TCP session init

std.os.linux.TCPI_OPT_ECN_SEEN

constant

Source line 8427

we received at least one packet with ECT

std.os.linux.TCPI_OPT_SACK

constant

Source line 8422

std.os.linux.TCPI_OPT_SYN_DATA

constant

Source line 8429

SYN-ACK acked data in SYN sent or rcvd

std.os.linux.TCPI_OPT_TIMESTAMPS

constant

Source line 8421

for TCP_INFO socket option

std.os.linux.TCPI_OPT_WSCALE

constant

Source line 8423

std.os.linux.TcpRepairOption

container

Source line 8401

Fields

TCP_NO_QUEUE
TCP_RECV_QUEUE
TCP_SEND_QUEUE
TCP_QUEUES_NR

std.os.linux.TCSA

alias

Source line 8952

Alias of std.posix.TCSA

std.os.linux.tcsetattr

function

Source line 3217

pub fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) usize

Parameters

fd: fd_t
optional_action: TCSA
termios_p: *const termios

std.os.linux.tcsetpgrp

function

Source line 3225

pub fn tcsetpgrp(fd: fd_t, pgrp: *const pid_t) usize

Parameters

fd: fd_t
pgrp: *const pid_t

std.os.linux.tee

function

Source line 3471

pub fn tee(src: fd_t, dest: fd_t, len: usize, flags: u32) usize

Parameters

src: fd_t
dest: fd_t
len: usize
flags: u32

std.os.linux.termio

container

Source line 8980

Fields

iflag: c_ushort
oflag: c_ushort
cflag: c_ushort
lflag: c_ushort
line: if (is_mips) c_char else u8
cc: [if (is_mips) NCCS else NCC]u8

std.os.linux.termios

type

Source line 8989

std.os.linux.termios2

type

Source line 9016

std.os.linux.TFD

type

Source line 6940

std.os.linux.TFD_TIMER

container

Source line 6934

Fields

ABSTIME: bool = false
CANCEL_ON_SET: bool = false
_: u30 = 0

std.os.linux.TFD.TIMER

alias

Source line 6948

Alias of std.os.linux.TFD_TIMER

std.os.linux.TFD.TIMER

alias

Source line 6957

Alias of std.os.linux.TFD_TIMER

std.os.linux.TFD.TIMER

alias

Source line 6966

Alias of std.os.linux.TFD_TIMER

std.os.linux.TFD.TIMER

alias

Source line 6975

Alias of std.os.linux.TFD_TIMER

std.os.linux.tgkill

function

Source line 2206

pub fn tgkill(tgid: pid_t, tid: pid_t, sig: SIG) usize

Parameters

tgid: pid_t
tid: pid_t
sig: SIG

std.os.linux.time_t

constant

Source line 124

std.os.linux.TIMER

container

Source line 6597

Fields

ABSTIME: bool
_: u31 = 0

std.os.linux.TIMERFD_CLOCK

alias

Source line 6587

Alias of std.os.linux.timerfd_clockid_t

std.os.linux.timerfd_clockid_t

container

Source line 6588

Fields

REALTIME = 0
MONOTONIC = 1
BOOTTIME = 7
REALTIME_ALARM = 8
BOOTTIME_ALARM = 9
_

std.os.linux.timerfd_create

function

Source line 3123

pub fn timerfd_create(clockid: timerfd_clockid_t, flags: TFD) usize

Parameters

clockid: timerfd_clockid_t
flags: TFD

std.os.linux.timerfd_gettime

function

Source line 3136

pub fn timerfd_gettime(fd: fd_t, curr_value: *itimerspec) usize

Parameters

fd: fd_t
curr_value: *itimerspec

std.os.linux.timerfd_settime

function

Source line 3144

pub fn timerfd_settime(fd: fd_t, flags: TFD.TIMER, new_value: *const itimerspec, old_value: ?*itimerspec) usize

Parameters

fd: fd_t
flags: TFD.TIMER
new_value: *const itimerspec
old_value: ?*itimerspec

std.os.linux.timespec

type

Source line 9793

std.os.linux.timeval

container

Source line 9754

Fields

sec: isize
usec: i64

std.os.linux.timezone

container

Source line 9759

Fields

minuteswest: i32
dsttime: i32

std.os.linux.tkill

function

Source line 2202

pub fn tkill(tid: pid_t, sig: SIG) usize

Parameters

tid: pid_t
sig: SIG

std.os.linux.tls

alias

Source line 126

Alias of std.os.linux.tls

std.os.linux.TP_STATUS

container

Source line 9404

Fields

rx: packed struct(u32) {
    USER: bool,
    COPY: bool,
    LOSING: bool,
    CSUMNOTREADY: bool,
    VLAN_VALID: bool,
    BLK_TMO: bool,
    VLAN_TPID_VALID: bool,
    CSUM_VALID: bool,
    GSO_TCP: bool,
    _: u20,
    TS_SOFTWARE: bool,
    TS_SYS_HARDWARE: bool,
    TS_RAW_HARDWARE: bool,
}
tx: packed struct(u32) {
    SEND_REQUEST: bool,
    SENDING: bool,
    WRONG_FORMAT: bool,
    _: u26,
    TS_SOFTWARE: bool,
    TS_SYS_HARDWARE: bool,
    TS_RAW_HARDWARE: bool,
}

std.os.linux.tpacket_bd_header_u

container

Source line 9441

Fields

std.os.linux.tpacket_bd_ts

container

Source line 9396

Fields

sec: c_uint
frac: extern union {
    usec: c_uint,
    nsec: c_uint,
}

std.os.linux.tpacket_block_desc

container

Source line 9445

Fields

version: u32
offset_to_priv: u32
hdr: tpacket_bd_header_u

std.os.linux.tpacket_hdr_v1

container

Source line 9431

Fields

block_status: TP_STATUS
num_pkts: u32
offset_to_first_pkt: u32
blk_len: u32
seq_num: u64 align(8)
ts_first_pkt: tpacket_bd_ts
ts_last_pkt: tpacket_bd_ts

std.os.linux.tpacket_hdr_variant1

container

Source line 9451

Fields

rxhash: u32
vlan_tci: u32
vlan_tpid: u16
padding: u16

std.os.linux.tpacket_req3

container

Source line 9386

Fields

block_size: c_uint
block_nr: c_uint
frame_size: c_uint
frame_nr: c_uint
retire_blk_tov: c_uint
sizeof_priv: c_uint
feature_req_word: c_uint

std.os.linux.tpacket_stats_v3

container

Source line 9473

Fields

packets: c_uint
drops: c_uint
freeze_q_cnt: c_uint

std.os.linux.tpacket_versions

container

Source line 9380

Fields

V1 = 0
V2 = 1
V3 = 2

std.os.linux.tpacket3_hdr

container

Source line 9458

Fields

next_offset: u32
sec: u32
nsec: u32
snaplen: u32
len: u32
status: u32
mac: u16
net: u16
variant: extern union {
    hv1: tpacket_hdr_variant1,
}
padding: [8]u8

std.os.linux.UDP

namespace

Source line 5094

std.os.linux.UDP_ENCAP

namespace

Source line 5109

std.os.linux.UDP_ENCAP.ESPINUDP

constant

Source line 5111

std.os.linux.UDP_ENCAP.ESPINUDP_NON_IKE

constant

Source line 5110

std.os.linux.UDP_ENCAP.GTP0

constant

Source line 5113

std.os.linux.UDP_ENCAP.GTP1U

constant

Source line 5114

std.os.linux.UDP_ENCAP.L2TPINUDP

constant

Source line 5112

std.os.linux.UDP_ENCAP.RXRPC

constant

Source line 5115

std.os.linux.UDP.CORK

constant

Source line 5096

Never send partially complete segments

std.os.linux.UDP.ENCAP

constant

Source line 5098

Set the socket to accept encapsulated packets

std.os.linux.UDP.GRO

constant

Source line 5106

This socket can receive UDP GRO packets

std.os.linux.UDP.NO_CHECK6_RX

constant

Source line 5102

Disable accepting checksum for UDP6

std.os.linux.UDP.NO_CHECK6_TX

constant

Source line 5100

Disable sending checksum for UDP6X

std.os.linux.UDP.SEGMENT

constant

Source line 5104

Set GSO segmentation size

std.os.linux.uid_t

type

Source line 121

std.os.linux.umount

function

Source line 1438

pub fn umount(special: [*:0]const u8) usize

Parameters

special: [*:0]const u8

std.os.linux.UMOUNT_NOFOLLOW

constant

Source line 6692

std.os.linux.umount2

function

Source line 1442

pub fn umount2(special: [*:0]const u8, flags: u32) usize

Parameters

special: [*:0]const u8
flags: u32

std.os.linux.uname

function

Source line 3189

pub fn uname(uts: *utsname) usize

Parameters

uts: *utsname

std.os.linux.unlink

function

Source line 2240

pub fn unlink(path: [*:0]const u8) usize

Parameters

path: [*:0]const u8

std.os.linux.unlinkat

function

Source line 2248

pub fn unlinkat(dirfd: fd_t, path: [*:0]const u8, flags: u32) usize

Parameters

dirfd: fd_t
path: [*:0]const u8
flags: u32

std.os.linux.unshare

function

Source line 3169

pub fn unshare(flags: usize) usize

Parameters

flags: usize

std.os.linux.use_kernel_timespec

constant

Source line 9789

std.os.linux.user_desc

constant

Source line 109

std.os.linux.UTIME

namespace

Source line 9783

For use with utimensat and futimens.

std.os.linux.UTIME.NOW

constant

Source line 9784

timespec

std.os.linux.UTIME.OMIT

constant

Source line 9785

timespec

std.os.linux.utimensat

function

Source line 1119

pub fn utimensat(dirfd: fd_t, path: ?[*:0]const u8, times: ?*const [2]timespec, flags: u32) usize

Parameters

dirfd: fd_t
path: ?[*:0]const u8
times: ?*const [2]timespec
flags: u32

std.os.linux.utsname

container

Source line 8163

Fields

sysname: [64:0]u8
nodename: [64:0]u8
release: [64:0]u8
version: [64:0]u8
machine: [64:0]u8
domainname: [64:0]u8

std.os.linux.V

type

Source line 8878

Indices into the cc array in the termios struct.

std.os.linux.vdso

alias

Source line 11

Alias of std.os.linux.vdso

std.os.linux.VDSO

constant

Source line 108

std.os.linux.vdso_clock_gettime

variable

Source line 2431

?VdsoClockGettime

std.os.linux.vdso_sys_riscv_hwprobe

variable

Source line 3553

?VdsoSysRiscvHwprobe

std.os.linux.VdsoClockGettime

type

Source line 2430

std.os.linux.VdsoSysRiscvHwprobe

type

Source line 3546

std.os.linux.vfs_cap_data

container

Source line 7193

Fields

magic_etc: u32
data: [VFS_CAP_U32]Data

std.os.linux.vfs_cap_data.Data

container

Source line 7196

Fields

permitted: u32
inheritable: u32

std.os.linux.VFS_CAP_FLAGS_EFFECTIVE

constant

Source line 7179

std.os.linux.VFS_CAP_FLAGS_MASK

constant

Source line 7178

std.os.linux.VFS_CAP_REVISION

alias

Source line 7191

Alias of std.os.linux.VFS_CAP_REVISION_2

std.os.linux.VFS_CAP_REVISION_1

constant

Source line 7181

std.os.linux.VFS_CAP_REVISION_2

constant

Source line 7185

std.os.linux.VFS_CAP_REVISION_MASK

constant

Source line 7176

std.os.linux.VFS_CAP_REVISION_SHIFT

constant

Source line 7177

std.os.linux.VFS_CAP_U32

alias

Source line 7190

Alias of std.os.linux.VFS_CAP_U32_2

std.os.linux.VFS_CAP_U32_1

constant

Source line 7182

std.os.linux.VFS_CAP_U32_2

constant

Source line 7186

std.os.linux.VTDLY

container

Source line 8697

Fields

VT0 = 0
VT1 = 1

std.os.linux.W

namespace

Source line 4665

std.os.linux.W_OK

constant

Source line 4662

std.os.linux.W.CONTINUED

constant

Source line 4670

std.os.linux.W.EXITED

constant

Source line 4669

std.os.linux.W.EXITSTATUS

function

Source line 4673

pub fn EXITSTATUS(s: u32) u8

Parameters

s: u32

std.os.linux.W.IFEXITED

function

Source line 4682

pub fn IFEXITED(s: u32) bool

Parameters

s: u32

std.os.linux.W.IFSIGNALED

function

Source line 4688

pub fn IFSIGNALED(s: u32) bool

Parameters

s: u32

std.os.linux.W.IFSTOPPED

function

Source line 4685

pub fn IFSTOPPED(s: u32) bool

Parameters

s: u32

std.os.linux.W.NOHANG

constant

Source line 4666

std.os.linux.W.NOWAIT

constant

Source line 4671

std.os.linux.W.STOPPED

constant

Source line 4668

std.os.linux.W.STOPSIG

function

Source line 4679

pub fn STOPSIG(s: u32) SIG

Parameters

s: u32

std.os.linux.W.TERMSIG

function

Source line 4676

pub fn TERMSIG(s: u32) SIG

Parameters

s: u32

std.os.linux.W.UNTRACED

constant

Source line 4667

std.os.linux.wait4

function

Source line 2256

pub fn wait4(pid: pid_t, status: *i32, flags: u32, usage: ?*rusage) usize

Parameters

pid: pid_t
status: *i32
flags: u32
usage: ?*rusage

std.os.linux.waitid

function

Source line 2266

pub fn waitid(id_type: P, id: pid_t, infop: *siginfo_t, flags: u32, usage: ?*rusage) usize

Parameters

id_type: P
id: pid_t
infop: *siginfo_t
flags: u32
usage: ?*rusage

std.os.linux.waitpid

function

Source line 2252

pub fn waitpid(pid: pid_t, status: *i32, flags: u32) usize

Parameters

pid: pid_t
status: *i32
flags: u32

std.os.linux.winsize

alias

Source line 24

Alias of std.posix.winsize

std.os.linux.write

function

Source line 1787

pub fn write(fd: fd_t, buf: [*]const u8, count: usize) usize

Parameters

fd: fd_t
buf: [*]const u8
count: usize

std.os.linux.writev

function

Source line 1825

pub fn writev(fd: fd_t, iov: [*]const iovec_const, count: usize) usize

Parameters

fd: fd_t
iov: [*]const iovec_const
count: usize

std.os.linux.X_OK

constant

Source line 4661

std.os.linux.XATTR_CAPS_SZ

alias

Source line 7189

Alias of std.os.linux.XATTR_CAPS_SZ_2

std.os.linux.XATTR_CAPS_SZ_1

constant

Source line 7183

std.os.linux.XATTR_CAPS_SZ_2

constant

Source line 7187

std.os.linux.XDP

namespace

Source line 9798

std.os.linux.xdp_desc

container

Source line 9860

Fields

addr: u64
len: u32
options: u32

std.os.linux.xdp_mmap_offsets

container

Source line 9829

Fields

std.os.linux.xdp_options

container

Source line 9853

Fields

flags: u32

std.os.linux.xdp_ring_offset

container

Source line 9822

Fields

producer: u64
consumer: u64
desc: u64
flags: u64

std.os.linux.xdp_statistics

container

Source line 9844

Fields

rx_dropped: u64
rx_invalid_descs: u64
tx_invalid_descs: u64
rx_ring_full: u64
rx_fill_ring_empty_descs: u64
tx_ring_empty_descs: u64

std.os.linux.xdp_umem_reg

container

Source line 9836

Fields

addr: u64
len: u64
chunk_size: u32
headroom: u32
flags: u32

std.os.linux.XDP.COPY

constant

Source line 9800

std.os.linux.XDP.MMAP_OFFSETS

constant

Source line 9805

std.os.linux.XDP.OPTIONS

constant

Source line 9812

std.os.linux.XDP.OPTIONS_ZEROCOPY

constant

Source line 9814

std.os.linux.XDP.PGOFF_RX_RING

constant

Source line 9816

std.os.linux.XDP.PGOFF_TX_RING

constant

Source line 9817

std.os.linux.XDP.RX_RING

constant

Source line 9806

std.os.linux.XDP.SHARED_UMEM

constant

Source line 9799

std.os.linux.XDP.STATISTICS

constant

Source line 9811

std.os.linux.XDP.TX_RING

constant

Source line 9807

std.os.linux.XDP.UMEM_COMPLETION_RING

constant

Source line 9810

std.os.linux.XDP.UMEM_FILL_RING

constant

Source line 9809

std.os.linux.XDP.UMEM_PGOFF_COMPLETION_RING

constant

Source line 9819

std.os.linux.XDP.UMEM_PGOFF_FILL_RING

constant

Source line 9818

std.os.linux.XDP.UMEM_REG

constant

Source line 9808

std.os.linux.XDP.UMEM_UNALIGNED_CHUNK_FLAG

constant

Source line 9802

std.os.linux.XDP.USE_NEED_WAKEUP

constant

Source line 9803

std.os.linux.XDP.ZEROCOPY

constant

Source line 9801

std.os.linux.XSK_UNALIGNED_BUF_ADDR_MASK

constant

Source line 9858

std.os.linux.XSK_UNALIGNED_BUF_OFFSET_SHIFT

constant

Source line 9857

Source code

std/os/linux.zig

//! This file provides the system interface functions for Linux matching those
//! that are provided by libc, whether or not libc is linked. The following
//! abstractions are made:
//! * Implement all the syscalls in the same way that libc functions will
//!   provide `rename` when only the `renameat` syscall exists.
const std = @import("../std.zig");
const builtin = @import("builtin");
const assert = std.debug.assert;
const maxInt = std.math.maxInt;
const elf = std.elf;
const vdso = @import("linux/vdso.zig");
const dl = @import("../dynamic_library.zig");
const native_arch = builtin.cpu.arch;
const native_abi = builtin.abi;
const native_endian = native_arch.endian();
const is_loongarch = native_arch.isLoongArch();
const is_mips = native_arch.isMIPS();
const is_ppc = native_arch.isPowerPC();
const is_riscv = native_arch.isRISCV();
const is_sparc = native_arch.isSPARC();
const is_hppa = native_arch.isHppa();
const iovec = std.posix.iovec;
const iovec_const = std.posix.iovec_const;
const winsize = std.posix.winsize;
const ACCMODE = std.posix.ACCMODE;

test {
    if (builtin.os.tag == .linux) {
        _ = @import("linux/test.zig");
    }
}

const arch_bits = switch (native_arch) {
    .aarch64, .aarch64_be => @import("linux/aarch64.zig"),
    .alpha => @import("linux/alpha.zig"),
    .arc, .arceb => @import("linux/arc.zig"),
    .arm, .armeb, .thumb, .thumbeb => @import("linux/arm.zig"),
    .csky => @import("linux/csky.zig"),
    .hexagon => @import("linux/hexagon.zig"),
    .loongarch32 => @import("linux/loongarch32.zig"),
    .loongarch64 => @import("linux/loongarch64.zig"),
    .m68k => @import("linux/m68k.zig"),
    .microblaze, .microblazeel => @import("linux/microblaze.zig"),
    .mips, .mipsel => @import("linux/mips.zig"),
    .mips64, .mips64el => switch (builtin.abi) {
        .gnuabin32, .muslabin32, .abin32 => @import("linux/mipsn32.zig"),
        else => @import("linux/mips64.zig"),
    },
    .or1k => @import("linux/or1k.zig"),
    .powerpc, .powerpcle => @import("linux/powerpc.zig"),
    .powerpc64, .powerpc64le => @import("linux/powerpc64.zig"),
    .riscv32 => @import("linux/riscv32.zig"),
    .riscv64 => @import("linux/riscv64.zig"),
    .s390x => @import("linux/s390x.zig"),
    .sh, .sheb => @import("linux/sh.zig"),
    .sparc => @import("linux/sparc.zig"),
    .sparc64 => @import("linux/sparc64.zig"),
    .x86 => @import("linux/x86.zig"),
    .x86_64 => switch (builtin.abi) {
        .gnux32, .muslx32, .x32 => @import("linux/x32.zig"),
        else => @import("linux/x86_64.zig"),
    },
    .xtensa, .xtensaeb => @import("linux/xtensa.zig"),
    else => struct {},
};

const syscall_bits = if (native_arch.isThumb()) @import("linux/thumb.zig") else arch_bits;

pub const syscall_arg_t = syscall_bits.syscall_arg_t;
pub const syscall0 = syscall_bits.syscall0;
pub const syscall1 = syscall_bits.syscall1;
pub const syscall2 = syscall_bits.syscall2;
pub const syscall3 = syscall_bits.syscall3;
pub const syscall4 = syscall_bits.syscall4;
pub const syscall5 = syscall_bits.syscall5;
pub const syscall6 = syscall_bits.syscall6;
pub const syscall7 = syscall_bits.syscall7;
pub const restore = syscall_bits.restore;
pub const restore_rt = syscall_bits.restore_rt;
pub const socketcall = syscall_bits.socketcall;
pub const syscall_pipe = syscall_bits.syscall_pipe;
pub const syscall_fork = syscall_bits.syscall_fork;
pub const syscall_lseek = syscall_bits.syscall_lseek;

pub fn clone(
    func: *const fn (arg: usize) callconv(.c) u8,
    stack: usize,
    flags: u32,
    arg: usize,
    ptid: ?*pid_t,
    tp: usize, // aka tls
    ctid: ?*pid_t,
) usize {
    // Can't directly call a naked function; cast to C calling convention first.
    return @as(*const fn (
        *const fn (arg: usize) callconv(.c) u8,
        usize,
        u32,
        usize,
        ?*pid_t,
        usize,
        ?*pid_t,
    ) callconv(.c) usize, @ptrCast(&syscall_bits.clone))(func, stack, flags, arg, ptid, tp, ctid);
}

pub const ARCH = arch_bits.ARCH;
pub const SC = arch_bits.SC;
pub const VDSO = arch_bits.VDSO;
pub const user_desc = arch_bits.user_desc;

pub const blkcnt_t = u64;
pub const blksize_t = u32;
pub const dev_t = u32;
pub const ino_t = u64;
pub const mode_t = u32;
pub const nlink_t = u32;
pub const off_t = i64;
pub const pid_t = i32;
pub const fd_t = i32;
pub const socket_t = fd_t;
pub const uid_t = u32;
pub const gid_t = u32;
pub const clock_t = isize;
pub const time_t = arch_bits.time_t;

pub const tls = @import("linux/tls.zig");
pub const BPF = @import("linux/bpf.zig");
pub const IOCTL = @import("linux/ioctl.zig");
pub const SECCOMP = @import("linux/seccomp.zig");

pub const syscalls = @import("linux/syscalls.zig");
pub const SYS = switch (native_arch) {
    .arc, .arceb => syscalls.Arc,
    .aarch64, .aarch64_be => syscalls.Arm64,
    .alpha => syscalls.Alpha,
    .arm, .armeb, .thumb, .thumbeb => syscalls.Arm,
    .csky => syscalls.CSky,
    .hexagon => syscalls.Hexagon,
    .hppa => syscalls.Hppa,
    .hppa64 => syscalls.Hppa64,
    .loongarch32 => syscalls.LoongArch32,
    .loongarch64 => syscalls.LoongArch64,
    .m68k => syscalls.M68k,
    .microblaze, .microblazeel => syscalls.Microblaze,
    .mips, .mipsel => syscalls.MipsO32,
    .mips64, .mips64el => switch (builtin.abi) {
        .gnuabin32, .muslabin32, .abin32 => syscalls.MipsN32,
        else => syscalls.MipsN64,
    },
    .or1k => syscalls.OpenRisc,
    .powerpc, .powerpcle => syscalls.PowerPC,
    .powerpc64, .powerpc64le => syscalls.PowerPC64,
    .riscv32 => syscalls.RiscV32,
    .riscv64 => syscalls.RiscV64,
    .s390x => syscalls.S390x,
    .sh, .sheb => syscalls.Sh,
    .sparc => syscalls.Sparc,
    .sparc64 => syscalls.Sparc64,
    .x86 => syscalls.X86,
    .x86_64 => switch (builtin.abi) {
        .gnux32, .muslx32, .x32 => syscalls.X32,
        else => syscalls.X64,
    },
    .xtensa, .xtensaeb => syscalls.Xtensa,
    else => @compileError("The Zig Standard Library is missing syscall definitions for the target CPU architecture"),
};

pub const MAP_TYPE = enum(u4) {
    SHARED = 0x01,
    PRIVATE = 0x02,
    SHARED_VALIDATE = 0x03,
    DROPPABLE = 0x08,
};

pub const MAP = switch (native_arch) {
    .x86_64, .x86 => packed struct(u32) {
        TYPE: MAP_TYPE,
        FIXED: bool = false,
        ANONYMOUS: bool = false,
        @"32BIT": bool = false,
        _7: u1 = 0,
        GROWSDOWN: bool = false,
        _9: u2 = 0,
        DENYWRITE: bool = false,
        EXECUTABLE: bool = false,
        LOCKED: bool = false,
        NORESERVE: bool = false,
        POPULATE: bool = false,
        NONBLOCK: bool = false,
        STACK: bool = false,
        HUGETLB: bool = false,
        SYNC: bool = false,
        FIXED_NOREPLACE: bool = false,
        _21: u5 = 0,
        UNINITIALIZED: bool = false,
        _: u5 = 0,
    },
    .aarch64, .aarch64_be, .arm, .armeb, .thumb, .thumbeb => packed struct(u32) {
        TYPE: MAP_TYPE,
        FIXED: bool = false,
        ANONYMOUS: bool = false,
        _6: u2 = 0,
        GROWSDOWN: bool = false,
        _9: u2 = 0,
        DENYWRITE: bool = false,
        EXECUTABLE: bool = false,
        LOCKED: bool = false,
        NORESERVE: bool = false,
        POPULATE: bool = false,
        NONBLOCK: bool = false,
        STACK: bool = false,
        HUGETLB: bool = false,
        SYNC: bool = false,
        FIXED_NOREPLACE: bool = false,
        _21: u5 = 0,
        UNINITIALIZED: bool = false,
        _: u5 = 0,
    },
    .riscv32, .riscv64, .loongarch32, .loongarch64 => packed struct(u32) {
        TYPE: MAP_TYPE,
        FIXED: bool = false,
        ANONYMOUS: bool = false,
        _6: u9 = 0,
        POPULATE: bool = false,
        NONBLOCK: bool = false,
        STACK: bool = false,
        HUGETLB: bool = false,
        SYNC: bool = false,
        FIXED_NOREPLACE: bool = false,
        _21: u5 = 0,
        UNINITIALIZED: bool = false,
        _: u5 = 0,
    },
    .sparc, .sparc64 => packed struct(u32) {
        TYPE: MAP_TYPE,
        FIXED: bool = false,
        ANONYMOUS: bool = false,
        NORESERVE: bool = false,
        _7: u1 = 0,
        LOCKED: bool = false,
        GROWSDOWN: bool = false,
        _10: u1 = 0,
        DENYWRITE: bool = false,
        EXECUTABLE: bool = false,
        _13: u2 = 0,
        POPULATE: bool = false,
        NONBLOCK: bool = false,
        STACK: bool = false,
        HUGETLB: bool = false,
        SYNC: bool = false,
        FIXED_NOREPLACE: bool = false,
        _21: u5 = 0,
        UNINITIALIZED: bool = false,
        _: u5 = 0,
    },
    .mips, .mipsel, .mips64, .mips64el => packed struct(u32) {
        TYPE: MAP_TYPE,
        FIXED: bool = false,
        _5: u1 = 0,
        @"32BIT": bool = false,
        _7: u3 = 0,
        NORESERVE: bool = false,
        ANONYMOUS: bool = false,
        GROWSDOWN: bool = false,
        DENYWRITE: bool = false,
        EXECUTABLE: bool = false,
        LOCKED: bool = false,
        POPULATE: bool = false,
        NONBLOCK: bool = false,
        STACK: bool = false,
        HUGETLB: bool = false,
        FIXED_NOREPLACE: bool = false,
        _21: u5 = 0,
        UNINITIALIZED: bool = false,
        _: u5 = 0,
    },
    .powerpc, .powerpcle, .powerpc64, .powerpc64le => packed struct(u32) {
        TYPE: MAP_TYPE,
        FIXED: bool = false,
        ANONYMOUS: bool = false,
        NORESERVE: bool = false,
        LOCKED: bool = false,
        GROWSDOWN: bool = false,
        _9: u2 = 0,
        DENYWRITE: bool = false,
        EXECUTABLE: bool = false,
        _13: u2 = 0,
        POPULATE: bool = false,
        NONBLOCK: bool = false,
        STACK: bool = false,
        HUGETLB: bool = false,
        SYNC: bool = false,
        FIXED_NOREPLACE: bool = false,
        _21: u5 = 0,
        UNINITIALIZED: bool = false,
        _: u5 = 0,
    },
    .arc,
    .arceb,
    .csky,
    .hexagon,
    .m68k,
    .microblaze,
    .microblazeel,
    .or1k,
    .s390x,
    .sh,
    .sheb,
    => packed struct(u32) {
        TYPE: MAP_TYPE,
        FIXED: bool = false,
        ANONYMOUS: bool = false,
        _4: u1 = 0,
        _5: u1 = 0,
        GROWSDOWN: bool = false,
        _7: u1 = 0,
        _8: u1 = 0,
        DENYWRITE: bool = false,
        EXECUTABLE: bool = false,
        LOCKED: bool = false,
        NORESERVE: bool = false,
        POPULATE: bool = false,
        NONBLOCK: bool = false,
        STACK: bool = false,
        HUGETLB: bool = false,
        SYNC: bool = false,
        FIXED_NOREPLACE: bool = false,
        _19: u5 = 0,
        UNINITIALIZED: bool = false,
        _: u5 = 0,
    },
    .alpha => packed struct(u32) {
        TYPE: MAP_TYPE,
        ANONYMOUS: bool = false,
        _3: u1 = 0,
        _4: u1 = 0,
        _5: u1 = 0,
        FIXED: bool = false,
        _7: u1 = 0,
        _8: u1 = 0,
        _9: u1 = 0,
        GROWSDOWN: bool = false,
        DENYWRITE: bool = false,
        EXECUTABLE: bool = false,
        LOCKED: bool = false,
        NORESERVE: bool = false,
        POPULATE: bool = false,
        NONBLOCK: bool = false,
        STACK: bool = false,
        HUGHETLB: bool = false,
        FIXED_NOREPLACE: bool = false,
        _19: u4 = 0,
        _20: u1 = 0,
        _: u5 = 0,
    },
    .xtensa, .xtensaeb => packed struct(u32) {
        TYPE: MAP_TYPE,
        FIXED: bool = false,
        _RENAME: bool = false,
        _AUTOGROW: bool = false,
        _LOCAL: bool = false,
        _AUTORSRV: bool = false,
        _1: u1 = 0,
        NORESERVE: bool = false,
        ANONYMOUS: bool = false,
        GROWSDOWN: bool = false,
        DENYWRITE: bool = false,
        EXECUTABLE: bool = false,
        LOCKED: bool = false,
        POPULATE: bool = false,
        NONBLOCK: bool = false,
        STACK: bool = false,
        HUGETLB: bool = false,
        FIXED_NOREPLACE: bool = false,
        _2: u5 = 0,
        UNINITIALIZED: bool = false,
        _3: u5 = 0,
    },
    else => @compileError("missing std.os.linux.MAP constants for this architecture"),
};

pub const MREMAP = packed struct(u32) {
    MAYMOVE: bool = false,
    FIXED: bool = false,
    DONTUNMAP: bool = false,
    _: u29 = 0,
};

pub const O = switch (native_arch) {
    .x86_64 => packed struct(u32) {
        ACCMODE: ACCMODE = .RDONLY,
        _2: u4 = 0,
        CREAT: bool = false,
        EXCL: bool = false,
        NOCTTY: bool = false,
        TRUNC: bool = false,
        APPEND: bool = false,
        NONBLOCK: bool = false,
        DSYNC: bool = false,
        ASYNC: bool = false,
        DIRECT: bool = false,
        _15: u1 = 0,
        DIRECTORY: bool = false,
        NOFOLLOW: bool = false,
        NOATIME: bool = false,
        CLOEXEC: bool = false,
        SYNC: bool = false,
        PATH: bool = false,
        /// This is typically invalid without also setting `DIRECTORY`.
        TMPFILE: bool = false,
        _23: u9 = 0,
    },
    .x86, .riscv32, .riscv64, .loongarch32, .loongarch64 => packed struct(u32) {
        ACCMODE: ACCMODE = .RDONLY,
        _2: u4 = 0,
        CREAT: bool = false,
        EXCL: bool = false,
        NOCTTY: bool = false,
        TRUNC: bool = false,
        APPEND: bool = false,
        NONBLOCK: bool = false,
        DSYNC: bool = false,
        ASYNC: bool = false,
        DIRECT: bool = false,
        LARGEFILE: bool = false,
        DIRECTORY: bool = false,
        NOFOLLOW: bool = false,
        NOATIME: bool = false,
        CLOEXEC: bool = false,
        SYNC: bool = false,
        PATH: bool = false,
        /// This is typically invalid without also setting `DIRECTORY`.
        TMPFILE: bool = false,
        _23: u9 = 0,
    },
    .aarch64, .aarch64_be, .arm, .armeb, .thumb, .thumbeb => packed struct(u32) {
        ACCMODE: ACCMODE = .RDONLY,
        _2: u4 = 0,
        CREAT: bool = false,
        EXCL: bool = false,
        NOCTTY: bool = false,
        TRUNC: bool = false,
        APPEND: bool = false,
        NONBLOCK: bool = false,
        DSYNC: bool = false,
        ASYNC: bool = false,
        DIRECTORY: bool = false,
        NOFOLLOW: bool = false,
        DIRECT: bool = false,
        LARGEFILE: bool = false,
        NOATIME: bool = false,
        CLOEXEC: bool = false,
        SYNC: bool = false,
        PATH: bool = false,
        /// This is typically invalid without also setting `DIRECTORY`.
        TMPFILE: bool = false,
        _23: u9 = 0,
    },
    .sparc, .sparc64 => packed struct(u32) {
        ACCMODE: ACCMODE = .RDONLY,
        _2: u1 = 0,
        APPEND: bool = false,
        _4: u2 = 0,
        ASYNC: bool = false,
        _7: u2 = 0,
        CREAT: bool = false,
        TRUNC: bool = false,
        EXCL: bool = false,
        _12: u1 = 0,
        DSYNC: bool = false,
        NONBLOCK: bool = false,
        NOCTTY: bool = false,
        DIRECTORY: bool = false,
        NOFOLLOW: bool = false,
        _18: u2 = 0,
        DIRECT: bool = false,
        NOATIME: bool = false,
        CLOEXEC: bool = false,
        SYNC: bool = false,
        PATH: bool = false,
        /// This is typically invalid without also setting `DIRECTORY`.
        TMPFILE: bool = false,
        _27: u6 = 0,
    },
    .mips, .mipsel, .mips64, .mips64el => packed struct(u32) {
        ACCMODE: ACCMODE = .RDONLY,
        _2: u1 = 0,
        APPEND: bool = false,
        DSYNC: bool = false,
        _5: u2 = 0,
        NONBLOCK: bool = false,
        CREAT: bool = false,
        TRUNC: bool = false,
        EXCL: bool = false,
        NOCTTY: bool = false,
        ASYNC: bool = false,
        LARGEFILE: bool = false,
        SYNC: bool = false,
        DIRECT: bool = false,
        DIRECTORY: bool = false,
        NOFOLLOW: bool = false,
        NOATIME: bool = false,
        CLOEXEC: bool = false,
        _20: u1 = 0,
        PATH: bool = false,
        /// This is typically invalid without also setting `DIRECTORY`.
        TMPFILE: bool = false,
        _23: u9 = 0,
    },
    .powerpc, .powerpcle, .powerpc64, .powerpc64le => packed struct(u32) {
        ACCMODE: ACCMODE = .RDONLY,
        _2: u4 = 0,
        CREAT: bool = false,
        EXCL: bool = false,
        NOCTTY: bool = false,
        TRUNC: bool = false,
        APPEND: bool = false,
        NONBLOCK: bool = false,
        DSYNC: bool = false,
        ASYNC: bool = false,
        DIRECTORY: bool = false,
        NOFOLLOW: bool = false,
        LARGEFILE: bool = false,
        DIRECT: bool = false,
        NOATIME: bool = false,
        CLOEXEC: bool = false,
        SYNC: bool = false,
        PATH: bool = false,
        /// This is typically invalid without also setting `DIRECTORY`.
        TMPFILE: bool = false,
        _23: u9 = 0,
    },
    .arc,
    .arceb,
    .csky,
    .hexagon,
    .microblaze,
    .microblazeel,
    .or1k,
    .s390x,
    .sh,
    .sheb,
    .xtensa,
    .xtensaeb,
    => packed struct(u32) {
        ACCMODE: ACCMODE = .RDONLY,
        _2: u4 = 0,
        CREAT: bool = false,
        EXCL: bool = false,
        NOCTTY: bool = false,
        TRUNC: bool = false,
        APPEND: bool = false,
        NONBLOCK: bool = false,
        DSYNC: bool = false,
        ASYNC: bool = false,
        DIRECT: bool = false,
        LARGEFILE: bool = false,
        DIRECTORY: bool = false,
        NOFOLLOW: bool = false,
        NOATIME: bool = false,
        CLOEXEC: bool = false,
        /// This is typically invalid without also setting `TMPFILE1` and `DIRECTORY`.
        TMPFILE0: bool = false,
        PATH: bool = false,
        _22: u4 = 0,
        /// This is typically invalid without also setting `TMPFILE0` and `DIRECTORY`.
        TMPFILE1: bool = false,
        _27: u5 = 0,

        // #define O_RSYNC    04010000
        // #define O_SYNC     04010000
        // #define O_NDELAY O_NONBLOCK
    },
    .m68k => packed struct(u32) {
        ACCMODE: ACCMODE = .RDONLY,
        _2: u4 = 0,
        CREAT: bool = false,
        EXCL: bool = false,
        NOCTTY: bool = false,
        TRUNC: bool = false,
        APPEND: bool = false,
        NONBLOCK: bool = false,
        DSYNC: bool = false,
        ASYNC: bool = false,
        DIRECTORY: bool = false,
        NOFOLLOW: bool = false,
        DIRECT: bool = false,
        LARGEFILE: bool = false,
        NOATIME: bool = false,
        CLOEXEC: bool = false,
        _20: u1 = 0,
        PATH: bool = false,
        _22: u10 = 0,
    },
    .alpha => packed struct(u32) {
        ACCMODE: ACCMODE = .RDONLY,
        NONBLOCK: bool = false,
        APPEND: bool = false,
        _4: u5 = 0,
        CREAT: bool = false,
        TRUNC: bool = false,
        EXCL: bool = false,
        NOCTTY: bool = false,
        _9: u1 = 0,
        DSYNC: bool = false,
        DIRECTORY: bool = false,
        NOFOLLOW: bool = false,
        LARGEFILE: bool = false,
        _14: u1 = 0,
        DIRECT: bool = false,
        NOATIME: bool = false,
        CLOEXEC: bool = false,
        SYNC: bool = false,
        PATH: bool = false,
        TMPFILE: bool = false,
        _: u7 = 0,
    },
    else => @compileError("missing std.os.linux.O constants for this architecture"),
};

pub const HWCAP = switch (native_arch) {
    .aarch64, .aarch64_be => struct {
        pub const FP = 1 << 0;
        pub const ASIMD = 1 << 1;
        pub const EVTSTRM = 1 << 2;
        pub const AES = 1 << 3;
        pub const PMULL = 1 << 4;
        pub const SHA1 = 1 << 5;
        pub const SHA2 = 1 << 6;
        pub const CRC32 = 1 << 7;
        pub const ATOMICS = 1 << 8;
        pub const FPHP = 1 << 9;
        pub const ASIMDHP = 1 << 10;
        pub const CPUID = 1 << 11;
        pub const ASIMDRDM = 1 << 12;
        pub const JSCVT = 1 << 13;
        pub const FCMA = 1 << 14;
        pub const LRCPC = 1 << 15;
        pub const DCPOP = 1 << 16;
        pub const SHA3 = 1 << 17;
        pub const SM3 = 1 << 18;
        pub const SM4 = 1 << 19;
        pub const ASIMDDP = 1 << 20;
        pub const SHA512 = 1 << 21;
        pub const SVE = 1 << 22;
        pub const ASIMDFHM = 1 << 23;
        pub const DIT = 1 << 24;
        pub const USCAT = 1 << 25;
        pub const ILRCPC = 1 << 26;
        pub const FLAGM = 1 << 27;
        pub const SSBS = 1 << 28;
        pub const SB = 1 << 29;
        pub const PACA = 1 << 30;
        pub const PACG = 1 << 31;
        pub const GCS = 1 << 32;
        pub const CMPBR = 1 << 33;
        pub const FPRCVT = 1 << 34;
        pub const F8MM8 = 1 << 35;
        pub const F8MM4 = 1 << 36;
        pub const SVE_F16MM = 1 << 37;
        pub const SVE_ELTPERM = 1 << 38;
        pub const SVE_AES2 = 1 << 39;
        pub const SVE_BFSCALE = 1 << 40;
        pub const SVE2P2 = 1 << 41;
        pub const SME2P2 = 1 << 42;
        pub const SME_SBITPERM = 1 << 43;
        pub const SME_AES = 1 << 44;
        pub const SME_SFEXPA = 1 << 45;
        pub const SME_STMOP = 1 << 46;
        pub const SME_SMOP4 = 1 << 47;

        pub const @"2" = struct {
            pub const DCPODP = 1 << 0;
            pub const SVE2 = 1 << 1;
            pub const SVEAES = 1 << 2;
            pub const SVEPMULL = 1 << 3;
            pub const SVEBITPERM = 1 << 4;
            pub const SVESHA3 = 1 << 5;
            pub const SVESM4 = 1 << 6;
            pub const FLAGM2 = 1 << 7;
            pub const FRINT = 1 << 8;
            pub const SVEI8MM = 1 << 9;
            pub const SVEF32MM = 1 << 10;
            pub const SVEF64MM = 1 << 11;
            pub const SVEBF16 = 1 << 12;
            pub const I8MM = 1 << 13;
            pub const BF16 = 1 << 14;
            pub const DGH = 1 << 15;
            pub const RNG = 1 << 16;
            pub const BTI = 1 << 17;
            pub const MTE = 1 << 18;
            pub const ECV = 1 << 19;
            pub const AFP = 1 << 20;
            pub const RPRES = 1 << 21;
            pub const MTE3 = 1 << 22;
            pub const SME = 1 << 23;
            pub const SME_I16I64 = 1 << 24;
            pub const SME_F64F64 = 1 << 25;
            pub const SME_I8I32 = 1 << 26;
            pub const SME_F16F32 = 1 << 27;
            pub const SME_B16F32 = 1 << 28;
            pub const SME_F32F32 = 1 << 29;
            pub const SME_FA64 = 1 << 30;
            pub const WFXT = 1 << 31;
            pub const EBF16 = 1 << 32;
            pub const SVE_EBF16 = 1 << 33;
            pub const CSSC = 1 << 34;
            pub const RPRFM = 1 << 35;
            pub const SVE2P1 = 1 << 36;
            pub const SME2 = 1 << 37;
            pub const SME2P1 = 1 << 38;
            pub const SME_I16I32 = 1 << 39;
            pub const SME_BI32I32 = 1 << 40;
            pub const SME_B16B16 = 1 << 41;
            pub const SME_F16F16 = 1 << 42;
            pub const MOPS = 1 << 43;
            pub const HBC = 1 << 44;
            pub const SVE_B16B16 = 1 << 45;
            pub const LRCPC3 = 1 << 46;
            pub const LSE128 = 1 << 47;
            pub const FPMR = 1 << 48;
            pub const LUT = 1 << 49;
            pub const FAMINMAX = 1 << 50;
            pub const F8CVT = 1 << 51;
            pub const F8FMA = 1 << 52;
            pub const F8DP4 = 1 << 53;
            pub const F8DP2 = 1 << 54;
            pub const F8E4M3 = 1 << 55;
            pub const F8E5M2 = 1 << 56;
            pub const SME_LUTV2 = 1 << 57;
            pub const SME_F8F16 = 1 << 58;
            pub const SME_F8F32 = 1 << 59;
            pub const SME_SF8FMA = 1 << 60;
            pub const SME_SF8DP4 = 1 << 61;
            pub const SME_SF8DP2 = 1 << 62;
            pub const POE = 1 << 63;
        };

        pub const @"3" = struct {
            pub const MTE_FAR = 1 << 0;
            pub const MTE_STORE_ONLY = 1 << 1;
            pub const LSFE = 1 << 2;
            pub const LS64 = 1 << 3;
            pub const SVE_B16MM = 1 << 4;
            pub const SVE2P3 = 1 << 5;
            pub const SME_LUT6 = 1 << 6;
            pub const SME2P3 = 1 << 7;
            pub const F16MM = 1 << 8;
            pub const F16F32DOT = 1 << 9;
            pub const F16F32MM = 1 << 10;
            pub const SVE_LUT6 = 1 << 11;
        };
    },
    .arm, .armeb, .thumb, .thumbeb => struct {
        pub const SWP = 1 << 0;
        pub const HALF = 1 << 1;
        pub const THUMB = 1 << 2;
        pub const @"26BIT" = 1 << 3;
        pub const FAST_MULT = 1 << 4;
        pub const FPA = 1 << 5;
        pub const VFP = 1 << 6;
        pub const EDSP = 1 << 7;
        pub const JAVA = 1 << 8;
        pub const IWMMXT = 1 << 9;
        pub const CRUNCH = 1 << 10;
        pub const THUMBEE = 1 << 11;
        pub const NEON = 1 << 12;
        pub const VFPv3 = 1 << 13;
        pub const VFPv3D16 = 1 << 14;
        pub const TLS = 1 << 15;
        pub const VFPv4 = 1 << 16;
        pub const IDIVA = 1 << 17;
        pub const IDIVT = 1 << 18;
        pub const VFPD32 = 1 << 19;
        pub const IDIV = IDIVA | IDIVT;
        pub const LPAE = 1 << 20;
        pub const EVTSTRM = 1 << 21;
        pub const FPHP = 1 << 22;
        pub const ASIMDHP = 1 << 23;
        pub const ASIMDDP = 1 << 24;
        pub const ASIMDFHM = 1 << 25;
        pub const ASIMDBF16 = 1 << 26;
        pub const I8MM = 1 << 27;

        pub const @"2" = struct {
            pub const AES = 1 << 0;
            pub const PMULL = 1 << 1;
            pub const SHA1 = 1 << 2;
            pub const SHA2 = 1 << 3;
            pub const CRC32 = 1 << 4;
            pub const SB = 1 << 5;
            pub const SSBS = 1 << 6;
        };
    },
    .loongarch32, .loongarch64 => struct {
        pub const CPUCFG = 1 << 0;
        pub const LAM = 1 << 1;
        pub const UAL = 1 << 2;
        pub const FPU = 1 << 3;
        pub const LSX = 1 << 4;
        pub const LASX = 1 << 5;
        pub const CRC32 = 1 << 6;
        pub const COMPLEX = 1 << 7;
        pub const CRYPTO = 1 << 8;
        pub const LVZ = 1 << 9;
        pub const LBT_X86 = 1 << 10;
        pub const LBT_ARM = 1 << 11;
        pub const LBT_MIPS = 1 << 12;
        pub const PTW = 1 << 13;
        pub const LSPW = 1 << 14;
        pub const SCQ = 1 << 15;
        pub const LAM_BH = 1 << 16;
    },
    .mips, .mipsel, .mips64, .mips64el => struct {
        pub const R6 = 1 << 0;
        pub const MSA = 1 << 1;
        pub const CRC32 = 1 << 2;
        pub const MIPS16 = 1 << 3;
        pub const MDMX = 1 << 4;
        pub const MIPS3D = 1 << 5;
        pub const SMARTMIPS = 1 << 6;
        pub const DSP = 1 << 7;
        pub const DSP2 = 1 << 8;
        pub const DSP3 = 1 << 9;
        pub const MIPS16E2 = 1 << 10;
        pub const LOONGSON_MMI = 1 << 11;
        pub const LOONGSON_EXT = 1 << 12;
        pub const LOONGSON_EXT2 = 1 << 13;
        pub const LOONGSON_CPUCFG = 1 << 14;
    },
    .powerpc, .powerpcle, .powerpc64, .powerpc64le => struct {
        pub const PPC_LE = 1 << 0;
        pub const TRUE_LE = 1 << 1;
        pub const PSERIES_PERFMON_COMPAT = 1 << 6;
        pub const HAS_VSX = 1 << 7;
        pub const ARCH_2_06 = 1 << 8;
        pub const POWER6_EXT = 1 << 9;
        pub const HAS_DFP = 1 << 10;
        pub const PA6T = 1 << 11;
        pub const ARCH_2_05 = 1 << 12;
        pub const ICACHE_SNOOP = 1 << 13;
        pub const SMT = 1 << 14;
        pub const BOOKE = 1 << 15;
        pub const CELL = 1 << 16;
        pub const POWER5_PLUS = 1 << 17;
        pub const POWER5 = 1 << 18;
        pub const POWER4 = 1 << 19;
        pub const NO_TB = 1 << 20;
        pub const HAS_EFP_DOUBLE = 1 << 21;
        pub const HAS_EFP_SINGLE = 1 << 22;
        pub const HAS_SPE = 1 << 23;
        pub const UNIFIED_CACHE = 1 << 24;
        pub const HAS_4xxMAC = 1 << 25;
        pub const HAS_MMU = 1 << 26;
        pub const HAS_FPU = 1 << 27;
        pub const HAS_ALTIVEC = 1 << 28;
        pub const @"601_INSTR" = 1 << 29;
        pub const @"64" = 1 << 30;
        pub const @"32" = 1 << 31;

        pub const @"2" = struct {
            pub const DMF = 1 << 15;
            pub const ARCH_3_2 = 1 << 16;
            pub const MMA = 1 << 17;
            pub const ARCH_3_1 = 1 << 18;
            pub const HTM_NO_SUSPEND = 1 << 19;
            pub const SCV = 1 << 20;
            pub const DARN = 1 << 21;
            pub const HAS_IEEE128 = 1 << 22;
            pub const ARCH_3_00 = 1 << 23;
            pub const HTM_NOSC = 1 << 24;
            pub const VEC_CRYPTO = 1 << 25;
            pub const TAR = 1 << 26;
            pub const ISEL = 1 << 27;
            pub const EBB = 1 << 28;
            pub const DSCR = 1 << 29;
            pub const HTM = 1 << 30;
            pub const ARCH_2_07 = 1 << 31;
        };
    },
    .riscv32, .riscv64 => struct {
        pub const ISA_A = 1 << 0;
        pub const ISA_C = 1 << 2;
        pub const ISA_D = 1 << 3;
        pub const ISA_F = 1 << 5;
        pub const ISA_I = 1 << 8;
        pub const ISA_M = 1 << 12;
        pub const ISA_V = 1 << 21;
    },
    .s390x => struct {
        pub const ESAN3 = 1 << 0;
        pub const ZARCH = 1 << 1;
        pub const STFLE = 1 << 2;
        pub const MSA = 1 << 3;
        pub const LDISP = 1 << 4;
        pub const EIMM = 1 << 5;
        pub const DFP = 1 << 6;
        pub const HPAGE = 1 << 7;
        pub const ETF3EH = 1 << 8;
        pub const HIGH_GPRS = 1 << 9;
        pub const TE = 1 << 10;
        pub const VXRS = 1 << 11;
        pub const VXRS_BCD = 1 << 12;
        pub const VXRS_EXT = 1 << 13;
        pub const GS = 1 << 14;
        pub const VXRS_EXT2 = 1 << 15;
        pub const VXRS_PDE = 1 << 16;
        pub const SORT = 1 << 17;
        pub const DFLT = 1 << 18;
        pub const VXRS_PDE2 = 1 << 19;
        pub const NNPA = 1 << 20;
        pub const PCI_MIO = 1 << 21;
        pub const SIE = 1 << 22;
    },
    .sparc, .sparc64 => struct {
        pub const FLUSH = 1 << 0;
        pub const STBAR = 1 << 1;
        pub const SWAP = 1 << 2;
        pub const MULDIV = 1 << 3;
        pub const V9 = 1 << 4;
        pub const ULTRA3 = 1 << 5;
        pub const BLKINIT = 1 << 6;
        pub const N2 = 1 << 7;
        pub const MUL32 = 1 << 8;
        pub const DIV32 = 1 << 9;
        pub const FSMULD = 1 << 10;
        pub const V8PLUS = 1 << 11;
        pub const POPC = 1 << 12;
        pub const VIS = 1 << 13;
        pub const VIS2 = 1 << 14;
        pub const ASI_BLK_INIT = 1 << 15;
        pub const FMAF = 1 << 16;
        pub const VIS3 = 1 << 17;
        pub const HPC = 1 << 18;
        pub const RANDOM = 1 << 19;
        pub const TRANS = 1 << 20;
        pub const FJFMAU = 1 << 21;
        pub const IMA = 1 << 22;
        pub const ASI_CACHE_SPARING = 1 << 23;
        pub const PAUSE = 1 << 24;
        pub const CBCOND = 1 << 25;
        pub const CRYPTO = 1 << 26;
        pub const ADI = 1 << 27;
    },
    .x86, .x86_64 => struct {
        pub const @"2" = struct {
            pub const RING3MWAIT = 1 << 0;
            pub const FSGSBASE = 1 << 1;
        };
    },
    else => struct {},
};

pub const RENAME = packed struct(u32) {
    /// Cannot be set together with `EXCHANGE`.
    NOREPLACE: bool = false,
    /// Cannot be set together with `NOREPLACE`.
    EXCHANGE: bool = false,
    WHITEOUT: bool = false,
    _: u29 = 0,
};

/// Set by startup code, used by `getauxval`.
pub var elf_aux_maybe: ?[*]std.elf.Auxv = null;

/// Whether an external or internal getauxval implementation is used.
const extern_getauxval = switch (builtin.zig_backend) {
    // Calling extern functions is not yet supported with these backends
    .stage2_arm,
    .stage2_loongarch,
    .stage2_powerpc,
    .stage2_riscv64,
    .stage2_sparc64,
    => false,
    else => !builtin.link_libc,
};

pub const getauxval = if (extern_getauxval) struct {
    comptime {
        const root = @import("root");
        // Export this only when building an executable, otherwise it is overriding
        // the libc implementation
        if (builtin.output_mode == .Exe or @hasDecl(root, "main")) {
            @export(&getauxvalImpl, .{ .name = "getauxval", .linkage = .weak });
        }
    }
    extern fn getauxval(index: usize) usize;
}.getauxval else getauxvalImpl;

fn getauxvalImpl(index: usize) callconv(.c) usize {
    @disableInstrumentation();
    const auxv = elf_aux_maybe orelse return 0;
    var i: usize = 0;
    while (auxv[i].a_type != std.elf.AT.NULL) : (i += 1) {
        if (auxv[i].a_type == index)
            return auxv[i].a_un.a_val;
    }
    return 0;
}

// Some architectures (and some syscalls) require 64bit parameters to be passed
// in a even-aligned register pair.
const require_aligned_register_pair =
    builtin.cpu.arch.isArm() or
    builtin.cpu.arch == .csky or
    builtin.cpu.arch == .hexagon or
    builtin.cpu.arch.isMIPS32() or
    builtin.cpu.arch.isPowerPC32() or
    builtin.cpu.arch.isXtensa();

// Split a 64bit value into a {LSB,MSB} pair.
// The LE/BE variants specify the endianness to assume.
fn splitValueLE64(val: i64) [2]u32 {
    const u: u64 = @bitCast(val);
    return [2]u32{
        @as(u32, @truncate(u)),
        @as(u32, @truncate(u >> 32)),
    };
}
fn splitValueBE64(val: i64) [2]u32 {
    const u: u64 = @bitCast(val);
    return [2]u32{
        @as(u32, @truncate(u >> 32)),
        @as(u32, @truncate(u)),
    };
}
fn splitValue64(val: i64) [2]u32 {
    const u: u64 = @bitCast(val);
    switch (native_endian) {
        .little => return [2]u32{
            @as(u32, @truncate(u)),
            @as(u32, @truncate(u >> 32)),
        },
        .big => return [2]u32{
            @as(u32, @truncate(u >> 32)),
            @as(u32, @truncate(u)),
        },
    }
}

/// Get the errno from a syscall return value. SUCCESS means no error.
pub fn errno(r: anytype) E {
    const signed_r: @Int(.signed, @typeInfo(@TypeOf(r)).int.bits) = @bitCast(r);
    return @fromBackingInt(@intCast(if (signed_r > -4096 and signed_r < 0) -signed_r else 0));
}

pub fn brk(addr: usize) usize {
    return syscall1(.brk, addr);
}

pub fn dup(old: fd_t) usize {
    return syscall1(.dup, @as(u32, @bitCast(old)));
}

pub fn dup2(old: fd_t, new: fd_t) usize {
    if (@hasField(SYS, "dup2")) {
        return syscall2(.dup2, @as(u32, @bitCast(old)), @as(u32, @bitCast(new)));
    } else {
        if (old == new) {
            if (std.debug.runtime_safety) {
                const rc = fcntl(F.GETFD, @as(fd_t, old), 0);
                if (@as(isize, @bitCast(rc)) < 0) return rc;
            }
            return @as(usize, @intCast(old));
        } else {
            return syscall3(.dup3, @as(u32, @bitCast(old)), @as(u32, @bitCast(new)), 0);
        }
    }
}

pub fn dup3(old: fd_t, new: fd_t, flags: u32) usize {
    return syscall3(.dup3, @as(u32, @bitCast(old)), @as(u32, @bitCast(new)), flags);
}

pub fn chdir(path: [*:0]const u8) usize {
    return syscall1(.chdir, @intFromPtr(path));
}

pub fn fchdir(fd: fd_t) usize {
    return syscall1(.fchdir, @as(u32, @bitCast(fd)));
}

pub fn chroot(path: [*:0]const u8) usize {
    return syscall1(.chroot, @intFromPtr(path));
}

pub fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) usize {
    return syscall3(.execve, @intFromPtr(path), @intFromPtr(argv), @intFromPtr(envp));
}

pub const EXECVEAT = packed struct(u32) {
    _1: u8 = 0, // 0x00000001
    /// Do not follow symbolic links.
    SYMLINK_NOFOLLOW: bool, // 0x00000100
    _200: u3 = 0, // 0x00000200
    /// Allow empty relative pathname.
    EMPTY_PATH: bool, // 0x00001000
    _: u19 = 0,
};

pub fn execveat(dirfd: fd_t, path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8, flags: EXECVEAT) usize {
    return syscall5(.execveat, @as(u32, @bitCast(dirfd)), @intFromPtr(path), @intFromPtr(argv), @intFromPtr(envp), @as(u32, @bitCast(flags)));
}

pub fn fork() usize {
    if (comptime native_arch.isSPARC()) {
        return syscall_fork();
    } else if (@hasField(SYS, "fork")) {
        return syscall0(.fork);
    } else {
        return syscall2(.clone, @backingInt(SIG.CHLD), 0);
    }
}

pub fn futimens(fd: fd_t, times: ?*const [2]timespec) usize {
    return utimensat(fd, null, times, 0);
}

pub fn utimensat(dirfd: fd_t, path: ?[*:0]const u8, times: ?*const [2]timespec, flags: u32) usize {
    return syscall4(
        if (@hasField(SYS, "utimensat") and native_arch != .hexagon) .utimensat else .utimensat_time64,
        @as(u32, @bitCast(dirfd)),
        @intFromPtr(path),
        @intFromPtr(times),
        flags,
    );
}

pub fn fallocate(fd: fd_t, mode: mode_t, offset: off_t, length: off_t) usize {
    if (@sizeOf(syscall_arg_t) < @sizeOf(u64)) {
        const offset_halves = splitValue64(offset);
        const length_halves = splitValue64(length);
        return syscall6(
            .fallocate,
            @as(u32, @bitCast(fd)),
            mode,
            offset_halves[0],
            offset_halves[1],
            length_halves[0],
            length_halves[1],
        );
    } else {
        return syscall4(
            .fallocate,
            @as(u32, @bitCast(fd)),
            mode,
            @as(u64, @bitCast(offset)),
            @as(u64, @bitCast(length)),
        );
    }
}

// The 4th parameter to the v1 futex syscall can either be an optional
// pointer to a timespec, or a uint32, depending on which "op" is being
// performed.
pub const futex_param4 = extern union {
    timeout: ?*const timespec,
    /// On all platforms only the bottom 32-bits of `val2` are relevant.
    /// This is 64-bit to match the pointer in the union.
    val2: usize,
};

/// The futex v1 syscall, see also the newer the futex2_{wait,wakeup,requeue,waitv} syscalls.
///
/// The futex_op parameter is a sub-command and flags.  The sub-command
/// defines which of the subsequent paramters are relevant.
pub fn futex(uaddr: *const anyopaque, futex_op: FUTEX_OP, val: u32, val2timeout: futex_param4, uaddr2: ?*const anyopaque, val3: u32) usize {
    return syscall6(
        if (@hasField(SYS, "futex") and native_arch != .hexagon) .futex else .futex_time64,
        @intFromPtr(uaddr),
        @as(u32, @bitCast(futex_op)),
        val,
        @intFromPtr(val2timeout.timeout),
        @intFromPtr(uaddr2),
        val3,
    );
}

/// Three-argument variation of the v1 futex call.  Only suitable for a
/// futex_op that ignores the remaining arguments (e.g., FUTUX_OP.WAKE).
pub fn futex_3arg(uaddr: *const anyopaque, futex_op: FUTEX_OP, val: u32) usize {
    return syscall3(
        if (@hasField(SYS, "futex") and native_arch != .hexagon) .futex else .futex_time64,
        @intFromPtr(uaddr),
        @as(u32, @bitCast(futex_op)),
        val,
    );
}

/// Four-argument variation on the v1 futex call.  Only suitable for
/// futex_op that ignores the remaining arguments (e.g., FUTEX_OP.WAIT).
pub fn futex_4arg(uaddr: *const anyopaque, futex_op: FUTEX_OP, val: u32, timeout: ?*const timespec) usize {
    return syscall4(
        if (@hasField(SYS, "futex") and native_arch != .hexagon) .futex else .futex_time64,
        @intFromPtr(uaddr),
        @as(u32, @bitCast(futex_op)),
        val,
        @intFromPtr(timeout),
    );
}

/// Given an array of `futex2_waitone`, wait on each uaddr.
/// The thread wakes if a futex_wake() is performed at any uaddr.
/// The syscall returns immediately if any futex has *uaddr != val.
/// timeout is an optional, absolute timeout value for the operation.
/// The `flags` argument is for future use and currently should be `.{}`.
/// Flags for private futexes, sizes, etc. should be set on the
/// individual flags of each `futex2_waitone`.
///
/// Returns the array index of one of the woken futexes.
/// No further information is provided: any number of other futexes may also
/// have been woken by the same event, and if more than one futex was woken,
/// the returned index may refer to any one of them.
/// (It is not necessaryily the futex with the smallest index, nor the one
/// most recently woken, nor...)
///
/// Requires at least kernel v5.16.
pub fn futex2_waitv(
    futexes: [*]const futex2_waitone,
    /// Length of `futexes`.  Max of FUTEX2_WAITONE_MAX.
    nr_futexes: u32,
    flags: FUTEX2_FLAGS_WAITV,
    /// Optional absolute timeout.  Always 64-bit, even on 32-bit platforms.
    timeout: ?*const kernel_timespec,
    /// Clock to be used for the timeout, realtime or monotonic.
    clockid: clockid_t,
) usize {
    return syscall5(
        .futex_waitv,
        @intFromPtr(futexes),
        nr_futexes,
        @as(u32, @bitCast(flags)),
        @intFromPtr(timeout),
        @backingInt(clockid),
    );
}

/// Wait on a single futex.
/// Identical to the futex v1 `FUTEX.FUTEX_WAIT_BITSET` op, except it is part of the
/// futex2 family of calls.
///
/// Requires at least kernel v6.7.
pub fn futex2_wait(
    /// Address of the futex to wait on.
    uaddr: *const anyopaque,
    /// Value of `uaddr`.
    val: usize,
    /// Bitmask to match against incoming wakeup masks.  Must not be zero.
    mask: usize,
    flags: FUTEX2_FLAGS,
    /// Optional absolute timeout.  Always 64-bit, even on 32-bit platforms.
    timeout: ?*const kernel_timespec,
    /// Clock to be used for the timeout, realtime or monotonic.
    clockid: clockid_t,
) usize {
    return syscall6(
        .futex_wait,
        @intFromPtr(uaddr),
        val,
        mask,
        @as(u32, @bitCast(flags)),
        @intFromPtr(timeout),
        @backingInt(clockid),
    );
}

/// Wake (subset of) waiters on given futex.
/// Identical to the traditional `FUTEX.FUTEX_WAKE_BITSET` op, except it is part of the
/// futex2 family of calls.
///
/// Requires at least kernel v6.7.
pub fn futex2_wake(
    /// Futex to wake
    uaddr: *const anyopaque,
    /// Bitmask to match against waiters.
    mask: usize,
    /// Maximum number of waiters on the futex to wake.
    nr_wake: i32,
    flags: FUTEX2_FLAGS,
) usize {
    return syscall4(
        .futex_wake,
        @intFromPtr(uaddr),
        mask,
        @as(u32, @bitCast(nr_wake)),
        @as(u32, @bitCast(flags)),
    );
}

/// Wake and/or requeue waiter(s) from one futex to another.
/// Identical to `FUTEX.CMP_REQUEUE`, except it is part of the futex2 family of calls.
///
/// Requires at least kernel v6.7.
pub fn futex2_requeue(
    /// The source and destination futexes.  Must be a 2-element array.
    waiters: [*]const futex2_waitone,
    /// Currently unused.
    flags: FUTEX2_FLAGS_REQUEUE,
    /// Maximum number of waiters to wake on the source futex.
    nr_wake: i32,
    /// Maximum number of waiters to transfer to the destination futex.
    nr_requeue: i32,
) usize {
    return syscall4(
        .futex_requeue,
        @intFromPtr(waiters),
        @as(u32, @bitCast(flags)),
        @as(u32, @bitCast(nr_wake)),
        @as(u32, @bitCast(nr_requeue)),
    );
}

pub fn getcwd(buf: [*]u8, size: usize) usize {
    return syscall2(.getcwd, @intFromPtr(buf), size);
}

pub fn getdents(fd: fd_t, dirp: [*]u8, len: c_uint) usize {
    return syscall3(
        .getdents,
        @as(u32, @bitCast(fd)),
        @intFromPtr(dirp),
        len,
    );
}

pub fn getdents64(fd: fd_t, dirp: [*]u8, len: c_uint) usize {
    return syscall3(
        .getdents64,
        @as(u32, @bitCast(fd)),
        @intFromPtr(dirp),
        len,
    );
}

pub fn inotify_init1(flags: u32) usize {
    return syscall1(.inotify_init1, flags);
}

pub fn inotify_add_watch(fd: fd_t, pathname: [*:0]const u8, mask: u32) usize {
    return syscall3(.inotify_add_watch, @as(u32, @bitCast(fd)), @intFromPtr(pathname), mask);
}

pub fn inotify_rm_watch(fd: fd_t, wd: fd_t) usize {
    return syscall2(.inotify_rm_watch, @as(u32, @bitCast(fd)), @as(u32, @bitCast(wd)));
}

pub fn fanotify_init(flags: fanotify.InitFlags, event_f_flags: u32) usize {
    return syscall2(.fanotify_init, @as(u32, @bitCast(flags)), event_f_flags);
}

pub fn fanotify_mark(
    fd: fd_t,
    flags: fanotify.MarkFlags,
    mask: fanotify.MarkMask,
    dirfd: fd_t,
    pathname: ?[*:0]const u8,
) usize {
    if (@sizeOf(syscall_arg_t) < @sizeOf(u64)) {
        const mask_halves = splitValue64(@bitCast(mask));
        return syscall6(
            .fanotify_mark,
            @as(u32, @bitCast(fd)),
            @as(u32, @bitCast(flags)),
            mask_halves[0],
            mask_halves[1],
            @as(u32, @bitCast(dirfd)),
            @intFromPtr(pathname),
        );
    } else {
        return syscall5(
            .fanotify_mark,
            @as(u32, @bitCast(fd)),
            @as(u32, @bitCast(flags)),
            @as(u64, @bitCast(mask)),
            @as(u32, @bitCast(dirfd)),
            @intFromPtr(pathname),
        );
    }
}

pub fn name_to_handle_at(
    dirfd: fd_t,
    pathname: [*:0]const u8,
    handle: *file_handle,
    mount_id: *i32,
    flags: u32,
) usize {
    return syscall5(
        .name_to_handle_at,
        @as(u32, @bitCast(dirfd)),
        @intFromPtr(pathname),
        @intFromPtr(handle),
        @intFromPtr(mount_id),
        flags,
    );
}

pub fn readlink(noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize {
    if (@hasField(SYS, "readlink")) {
        return syscall3(.readlink, @intFromPtr(path), @intFromPtr(buf_ptr), buf_len);
    } else {
        return syscall4(.readlinkat, @as(u32, @bitCast(@as(i32, AT.FDCWD))), @intFromPtr(path), @intFromPtr(buf_ptr), buf_len);
    }
}

pub fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize {
    return syscall4(.readlinkat, @as(u32, @bitCast(dirfd)), @intFromPtr(path), @intFromPtr(buf_ptr), buf_len);
}

pub fn mkdir(path: [*:0]const u8, mode: mode_t) usize {
    if (@hasField(SYS, "mkdir")) {
        return syscall2(.mkdir, @intFromPtr(path), mode);
    } else {
        return syscall3(.mkdirat, @as(u32, @bitCast(@as(i32, AT.FDCWD))), @intFromPtr(path), mode);
    }
}

pub fn mkdirat(dirfd: fd_t, path: [*:0]const u8, mode: mode_t) usize {
    return syscall3(.mkdirat, @as(u32, @bitCast(dirfd)), @intFromPtr(path), mode);
}

pub fn mknod(path: [*:0]const u8, mode: mode_t, dev: dev_t) usize {
    if (@hasField(SYS, "mknod")) {
        return syscall3(.mknod, @intFromPtr(path), mode, dev);
    } else {
        return mknodat(AT.FDCWD, path, mode, dev);
    }
}

pub fn mknodat(dirfd: fd_t, path: [*:0]const u8, mode: mode_t, dev: dev_t) usize {
    return syscall4(.mknodat, @as(u32, @bitCast(dirfd)), @intFromPtr(path), mode, dev);
}

pub fn mount(special: ?[*:0]const u8, dir: [*:0]const u8, fstype: ?[*:0]const u8, flags: u32, data: usize) usize {
    return syscall5(.mount, @intFromPtr(special), @intFromPtr(dir), @intFromPtr(fstype), flags, data);
}

pub fn umount(special: [*:0]const u8) usize {
    return syscall2(.umount2, @intFromPtr(special), 0);
}

pub fn umount2(special: [*:0]const u8, flags: u32) usize {
    return syscall2(.umount2, @intFromPtr(special), flags);
}

pub const MOVE_MOUNT = packed struct(u32) {
    /// Follow symlinks on from path.
    F_SYMLINKS: bool, // 0x00000001
    /// Follow automounts on from path.
    F_AUTOMOUNTS: bool, // 0x00000002
    /// Empty from path permitted.
    F_EMPTY_PATH: bool, // 0x00000004
    _8: bool = false, // 0x00000008
    /// Follow symlinks on to path.
    T_SYMLINKS: bool, // 0x00000010
    /// Follow automounts on to path.
    T_AUTOMOUNTS: bool, // 0x00000020
    /// Empty to path permitted.
    T_EMPTY_PATH: bool, // 0x00000040
    _80: bool = false, // 0x00000080
    /// Set sharing group instead.
    SET_GROUP: bool, // 0x00000100
    _: u23 = 0,
};

pub fn move_mount(from_dirfd: fd_t, from_path: [*:0]const u8, to_dirfd: fd_t, to_path: [*:0]const u8, flags: MOVE_MOUNT) usize {
    return syscall5(
        .move_mount,
        @as(u32, @bitCast(from_dirfd)),
        @intFromPtr(from_path),
        @as(u32, @bitCast(to_dirfd)),
        @intFromPtr(to_path),
        @as(u32, @bitCast(flags)),
    );
}

pub const MOUNT_ATTR = packed struct(u32) {
    /// Update atime relative to mtime/ctime.
    RELATIME: u0, // This is the default ATIME, it's true unless a different ATIME is set.
    /// Mount read-only.
    RDONLY: bool, // 0x00000001
    /// Ignore suid and sgid bits.
    NOSUID: bool, // 0x00000002
    /// Disallow access to device special files.
    NODEV: bool, // 0x00000004
    /// Disallow program execution.
    NOEXEC: bool, // 0x00000008
    /// Do not update access times.
    NOATIME: bool, // 0x00000010
    /// Always perform atime updates.
    STRICTATIME: bool, // 0x00000020
    _40: bool = false, // 0x00000040
    /// Do not update directory access times.
    NODIRATIME: bool, // 0x00000080
    _100: u12 = 0, // 0x00000100
    /// Idmap mount to @userns_fd in struct mount_attr.
    IDMAP: bool, // 0x00100000
    /// Do not follow symlinks.
    NOSYMFOLLOW: bool, // 0x00200000
    _: u10 = 0,

    // ATIME: u32, // 0x00000070 This is a mask, not a flag.
};

pub fn mount_setattr(dirfd: fd_t, path: [*:0]const u8, flags: MOUNT_ATTR) usize {
    return syscall3(.mount_setattr, @as(u32, @bitCast(dirfd)), @intFromPtr(path), @as(u32, @bitCast(flags)));
}

pub const FSOPEN = packed struct(u32) {
    /// Set CLOEXEC on the new fd.
    CLOEXEC: bool, // 0x00000001
    _: u31 = 0,
};

pub fn fsopen(fsname: [*:0]const u8, flags: FSOPEN) usize {
    return syscall2(.fsopen, @intFromPtr(fsname), @as(u32, @bitCast(flags)));
}

pub const FSCONFIG_CMD = enum(u32) {
    /// Set parameter, supplying no value.
    SET_FLAG,
    /// Set parameter, supplying a string value.
    SET_STRING,
    /// Set parameter, supplying a binary blob value.
    SET_BINARY,
    /// Set parameter, supplying an object by path.
    SET_PATH,
    /// Set parameter, supplying an object by (empty) path.
    SET_PATH_EMPTY,
    /// Set parameter, supplying an object by fd.
    SET_FD,
    /// Invoke superblock creation.
    CREATE,
    /// Invoke superblock reconfiguration.
    RECONFIGURE,
};

pub fn fsconfig(fd: fd_t, cmd: FSCONFIG_CMD, key: ?[*:0]const u8, value: ?[*:0]const u8, aux: u32) usize {
    return syscall5(.fsconfig, @as(u32, @bitCast(fd)), @backingInt(cmd), @intFromPtr(key), @intFromPtr(value), aux);
}

pub const FSMOUNT = packed struct(u32) {
    /// Set CLOEXEC on the fd.
    CLOEXEC: bool, // 0x00000001
    _31: u31 = 0,
};

pub fn fsmount(fsfd: fd_t, flags: FSMOUNT, attr_flags: MOUNT_ATTR) usize {
    return syscall3(.fsmount, @as(u32, @bitCast(fsfd)), @as(u32, @bitCast(flags)), @as(u32, @bitCast(attr_flags)));
}

pub const FSPICK = packed struct(u32) {
    /// Set CLOEXEC on the new fd.
    CLOEXEC: bool, // 0x00000001
    SYMLINK_NOFOLLOW: bool, // 0x00000002
    NO_AUTOMOUNT: bool, // 0x00000004
    EMPTY_PATH: bool, // 0x00000008
    _28: u28 = 0,
};

pub fn fspick(dirfd: fd_t, path: [*:0]const u8, flags: FSPICK) usize {
    return syscall3(.fspick, @as(u32, @bitCast(dirfd)), @intFromPtr(path), @as(u32, @bitCast(flags)));
}

pub fn pivot_root(new_root: [*:0]const u8, put_old: [*:0]const u8) usize {
    return syscall2(.pivot_root, @intFromPtr(new_root), @intFromPtr(put_old));
}

fn mmap2Unit() u64 {
    return switch (native_arch) {
        .arc, .arceb, .m68k => std.heap.pageSize(),
        .or1k => 8 << 10,
        else => 4 << 10,
    };
}

pub fn mmap(address: ?[*]u8, length: usize, prot: PROT, flags: MAP, fd: fd_t, offset: off_t) usize {
    if (@hasField(SYS, "mmap2")) {
        return syscall6(
            .mmap2,
            @intFromPtr(address),
            length,
            @as(u32, @bitCast(prot)),
            @as(u32, @bitCast(flags)),
            @as(u32, @bitCast(fd)),
            @truncate(@as(u64, @bitCast(offset)) / mmap2Unit()),
        );
    } else {
        // The s390x mmap() syscall existed before Linux supported syscalls with 5+ parameters, so
        // it takes a single pointer to an array of arguments instead.
        return if (native_arch == .s390x) syscall1(
            .mmap,
            @intFromPtr(&[_]usize{
                @intFromPtr(address),
                length,
                @as(u32, @bitCast(prot)),
                @as(u32, @bitCast(flags)),
                @as(u32, @bitCast(fd)),
                @as(u64, @bitCast(offset)),
            }),
        ) else syscall6(
            .mmap,
            @intFromPtr(address),
            length,
            @as(u32, @bitCast(prot)),
            @as(u32, @bitCast(flags)),
            @as(u32, @bitCast(fd)),
            @as(u64, @bitCast(offset)),
        );
    }
}

pub fn mprotect(address: [*]const u8, length: usize, protection: PROT) usize {
    return syscall3(.mprotect, @intFromPtr(address), length, @as(u32, @bitCast(protection)));
}

pub fn mremap(old_addr: ?[*]const u8, old_len: usize, new_len: usize, flags: MREMAP, new_addr: ?[*]const u8) usize {
    return syscall5(
        .mremap,
        @intFromPtr(old_addr),
        old_len,
        new_len,
        @as(u32, @bitCast(flags)),
        @intFromPtr(new_addr),
    );
}

pub const MSF = struct {
    pub const ASYNC = 1;
    pub const INVALIDATE = 2;
    pub const SYNC = 4;
};

/// Can only be called on 64 bit systems.
pub fn mseal(address: [*]const u8, length: usize, flags: usize) usize {
    return syscall3(.mseal, @intFromPtr(address), length, flags);
}

pub fn msync(address: [*]const u8, length: usize, flags: i32) usize {
    return syscall3(.msync, @intFromPtr(address), length, @as(u32, @bitCast(flags)));
}

pub fn munmap(address: [*]const u8, length: usize) usize {
    return syscall2(.munmap, @intFromPtr(address), length);
}

pub fn mlock(address: [*]const u8, length: usize) usize {
    return syscall2(.mlock, @intFromPtr(address), length);
}

pub fn munlock(address: [*]const u8, length: usize) usize {
    return syscall2(.munlock, @intFromPtr(address), length);
}

pub const MLOCK = packed struct(u32) {
    ONFAULT: bool = false,
    _1: u31 = 0,
};

pub fn mlock2(address: [*]const u8, length: usize, flags: MLOCK) usize {
    return syscall3(.mlock2, @intFromPtr(address), length, @as(u32, @bitCast(flags)));
}

pub const MCL = if (native_arch.isSPARC() or native_arch.isPowerPC()) packed struct(u32) {
    _0: u13 = 0,
    CURRENT: bool = false,
    FUTURE: bool = false,
    ONFAULT: bool = false,
    _4: u16 = 0,
} else packed struct(u32) {
    CURRENT: bool = false,
    FUTURE: bool = false,
    ONFAULT: bool = false,
    _3: u29 = 0,
};

pub fn mlockall(flags: MCL) usize {
    return syscall1(.mlockall, @as(u32, @bitCast(flags)));
}

pub fn munlockall() usize {
    return syscall0(.munlockall);
}

pub fn poll(fds: [*]pollfd, n: nfds_t, timeout: i32) usize {
    if (@hasField(SYS, "poll")) {
        return syscall3(.poll, @intFromPtr(fds), n, @as(u32, @bitCast(timeout)));
    } else {
        var ts: timespec = if (timeout >= 0)
            .{
                .sec = @divTrunc(timeout, 1000),
                .nsec = @rem(timeout, 1000) * 1000000,
            }
        else
            undefined;
        return ppoll(
            fds,
            n,
            if (timeout >= 0) &ts else null,
            null,
        );
    }
}

pub fn ppoll(fds: [*]pollfd, n: nfds_t, timeout: ?*timespec, sigmask: ?*const sigset_t) usize {
    return syscall5(
        if (@hasField(SYS, "ppoll") and native_arch != .hexagon) .ppoll else .ppoll_time64,
        @intFromPtr(fds),
        n,
        @intFromPtr(timeout),
        @intFromPtr(sigmask),
        NSIG / 8,
    );
}

pub fn read(fd: fd_t, buf: [*]u8, count: usize) usize {
    return syscall3(.read, @as(u32, @bitCast(fd)), @intFromPtr(buf), count);
}

pub fn pread(fd: fd_t, buf: [*]u8, count: usize, offset: off_t) usize {
    if (@sizeOf(syscall_arg_t) < @sizeOf(u64)) {
        const offset_halves = splitValue64(offset);
        if (require_aligned_register_pair) {
            return syscall6(
                .pread64,
                @as(u32, @bitCast(fd)),
                @intFromPtr(buf),
                count,
                0,
                offset_halves[0],
                offset_halves[1],
            );
        } else {
            return syscall5(
                .pread64,
                @as(u32, @bitCast(fd)),
                @intFromPtr(buf),
                count,
                offset_halves[0],
                offset_halves[1],
            );
        }
    } else {
        return syscall4(
            .pread64,
            @as(u32, @bitCast(fd)),
            @intFromPtr(buf),
            count,
            @as(u64, @bitCast(offset)),
        );
    }
}

pub fn readv(fd: fd_t, iov: [*]const iovec, count: usize) usize {
    return syscall3(.readv, @as(u32, @bitCast(fd)), @intFromPtr(iov), count);
}

pub fn preadv(fd: fd_t, iov: [*]const iovec, count: usize, offset: off_t) usize {
    const offset_u: u64 = @bitCast(offset);
    return syscall5(
        .preadv,
        @as(u32, @bitCast(fd)),
        @intFromPtr(iov),
        count,
        // Kernel expects the offset is split into largest natural word-size.
        // See following link for detail:
        // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=601cc11d054ae4b5e9b5babec3d8e4667a2cb9b5
        @truncate(offset_u),
        if (@sizeOf(syscall_arg_t) < @sizeOf(u64)) @truncate(offset_u >> 32) else 0,
    );
}

pub fn preadv2(fd: fd_t, iov: [*]const iovec, count: usize, offset: off_t, flags: kernel_rwf) usize {
    const offset_u: u64 = @bitCast(offset);
    return syscall6(
        .preadv2,
        @as(u32, @bitCast(fd)),
        @intFromPtr(iov),
        count,
        // See comments in preadv
        @truncate(offset_u),
        if (@sizeOf(syscall_arg_t) < @sizeOf(u64)) @truncate(offset_u >> 32) else 0,
        flags,
    );
}

pub fn write(fd: fd_t, buf: [*]const u8, count: usize) usize {
    return syscall3(.write, @as(u32, @bitCast(fd)), @intFromPtr(buf), count);
}

pub fn pwrite(fd: fd_t, buf: [*]const u8, count: usize, offset: off_t) usize {
    if (@sizeOf(syscall_arg_t) < @sizeOf(u64)) {
        const offset_halves = splitValue64(offset);
        if (require_aligned_register_pair) {
            return syscall6(
                .pwrite64,
                @as(u32, @bitCast(fd)),
                @intFromPtr(buf),
                count,
                0,
                offset_halves[0],
                offset_halves[1],
            );
        } else {
            return syscall5(
                .pwrite64,
                @as(u32, @bitCast(fd)),
                @intFromPtr(buf),
                count,
                offset_halves[0],
                offset_halves[1],
            );
        }
    } else {
        return syscall4(
            .pwrite64,
            @as(u32, @bitCast(fd)),
            @intFromPtr(buf),
            count,
            @as(u64, @bitCast(offset)),
        );
    }
}

pub fn writev(fd: fd_t, iov: [*]const iovec_const, count: usize) usize {
    return syscall3(.writev, @as(u32, @bitCast(fd)), @intFromPtr(iov), count);
}

pub fn pwritev(fd: fd_t, iov: [*]const iovec_const, count: usize, offset: off_t) usize {
    const offset_u: u64 = @bitCast(offset);
    return syscall5(
        .pwritev,
        @as(u32, @bitCast(fd)),
        @intFromPtr(iov),
        count,
        // See comments in preadv
        @truncate(offset_u),
        if (@sizeOf(syscall_arg_t) < @sizeOf(u64)) @truncate(offset_u >> 32) else 0,
    );
}

pub fn pwritev2(fd: fd_t, iov: [*]const iovec_const, count: usize, offset: off_t, flags: kernel_rwf) usize {
    const offset_u: u64 = @bitCast(offset);
    return syscall6(
        .pwritev2,
        @as(u32, @bitCast(fd)),
        @intFromPtr(iov),
        count,
        // See comments in preadv
        @truncate(offset_u),
        if (@sizeOf(syscall_arg_t) < @sizeOf(u64)) @truncate(offset_u >> 32) else 0,
        flags,
    );
}

pub fn rmdir(path: [*:0]const u8) usize {
    if (@hasField(SYS, "rmdir")) {
        return syscall1(.rmdir, @intFromPtr(path));
    } else {
        return syscall3(.unlinkat, @as(u32, @bitCast(@as(i32, AT.FDCWD))), @intFromPtr(path), AT.REMOVEDIR);
    }
}

pub fn symlink(existing: [*:0]const u8, new: [*:0]const u8) usize {
    if (@hasField(SYS, "symlink")) {
        return syscall2(.symlink, @intFromPtr(existing), @intFromPtr(new));
    } else {
        return syscall3(.symlinkat, @intFromPtr(existing), @as(u32, @bitCast(@as(i32, AT.FDCWD))), @intFromPtr(new));
    }
}

pub fn symlinkat(existing: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8) usize {
    return syscall3(.symlinkat, @intFromPtr(existing), @as(u32, @bitCast(newfd)), @intFromPtr(newpath));
}

pub fn access(path: [*:0]const u8, mode: mode_t) usize {
    if (@hasField(SYS, "access")) {
        return syscall2(.access, @intFromPtr(path), mode);
    } else {
        return faccessat(AT.FDCWD, path, mode, 0);
    }
}

pub fn faccessat(dirfd: fd_t, path: [*:0]const u8, mode: mode_t, flags: u32) usize {
    if (flags == 0) {
        return syscall3(.faccessat, @as(u32, @bitCast(dirfd)), @intFromPtr(path), mode);
    }
    return syscall4(.faccessat2, @as(u32, @bitCast(dirfd)), @intFromPtr(path), mode, flags);
}

pub fn acct(path: [*:0]const u8) usize {
    return syscall1(.acct, @intFromPtr(path));
}

pub fn pipe(fd: *[2]fd_t) usize {
    if (native_arch.isMIPS() or native_arch.isSPARC()) {
        return syscall_pipe(fd);
    } else if (@hasField(SYS, "pipe")) {
        return syscall1(.pipe, @intFromPtr(fd));
    } else {
        return syscall2(.pipe2, @intFromPtr(fd), 0);
    }
}

pub fn pipe2(fd: *[2]fd_t, flags: O) usize {
    return syscall2(.pipe2, @intFromPtr(fd), @as(u32, @bitCast(flags)));
}

pub fn ftruncate(fd: fd_t, length: off_t) usize {
    if (@sizeOf(syscall_arg_t) < @sizeOf(u64)) {
        const length_halves = splitValue64(length);
        if (require_aligned_register_pair) {
            return syscall4(
                .ftruncate64,
                @as(u32, @bitCast(fd)),
                0,
                length_halves[0],
                length_halves[1],
            );
        } else {
            return syscall3(
                .ftruncate64,
                @as(u32, @bitCast(fd)),
                length_halves[0],
                length_halves[1],
            );
        }
    } else {
        return syscall2(
            .ftruncate,
            @as(u32, @bitCast(fd)),
            @as(u64, @bitCast(length)),
        );
    }
}

pub fn rename(old: [*:0]const u8, new: [*:0]const u8) usize {
    if (@hasField(SYS, "rename")) {
        return syscall2(.rename, @intFromPtr(old), @intFromPtr(new));
    } else if (@hasField(SYS, "renameat")) {
        return syscall4(
            .renameat,
            @as(u32, @bitCast(@as(i32, AT.FDCWD))),
            @intFromPtr(old),
            @as(u32, @bitCast(@as(i32, AT.FDCWD))),
            @intFromPtr(new),
        );
    } else {
        return syscall5(
            .renameat2,
            @as(u32, @bitCast(@as(i32, AT.FDCWD))),
            @intFromPtr(old),
            @as(u32, @bitCast(@as(i32, AT.FDCWD))),
            @intFromPtr(new),
            0,
        );
    }
}

pub fn renameat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8) usize {
    if (@hasField(SYS, "renameat")) {
        return syscall4(
            .renameat,
            @as(u32, @bitCast(oldfd)),
            @intFromPtr(oldpath),
            @as(u32, @bitCast(newfd)),
            @intFromPtr(newpath),
        );
    } else {
        return syscall5(
            .renameat2,
            @as(u32, @bitCast(oldfd)),
            @intFromPtr(oldpath),
            @as(u32, @bitCast(newfd)),
            @intFromPtr(newpath),
            0,
        );
    }
}

pub fn renameat2(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8, flags: RENAME) usize {
    return syscall5(
        .renameat2,
        @as(u32, @bitCast(oldfd)),
        @intFromPtr(oldpath),
        @as(u32, @bitCast(newfd)),
        @intFromPtr(newpath),
        @as(u32, @bitCast(flags)),
    );
}

pub fn open(path: [*:0]const u8, flags: O, perm: mode_t) usize {
    if (@hasField(SYS, "open")) {
        return syscall3(.open, @intFromPtr(path), @as(u32, @bitCast(flags)), perm);
    } else {
        return syscall4(
            .openat,
            @as(u32, @bitCast(@as(i32, AT.FDCWD))),
            @intFromPtr(path),
            @as(u32, @bitCast(flags)),
            perm,
        );
    }
}

pub fn create(path: [*:0]const u8, perm: mode_t) usize {
    return syscall2(.creat, @intFromPtr(path), perm);
}

pub fn openat(dirfd: fd_t, path: [*:0]const u8, flags: O, mode: mode_t) usize {
    // dirfd could be negative, for example AT.FDCWD is -100
    return syscall4(.openat, @as(u32, @bitCast(dirfd)), @intFromPtr(path), @as(u32, @bitCast(flags)), mode);
}

/// See also `clone` (from the arch-specific include)
pub fn clone5(flags: usize, child_stack_ptr: usize, parent_tid: *pid_t, child_tid: *pid_t, newtls: usize) usize {
    return syscall5(.clone, flags, child_stack_ptr, @intFromPtr(parent_tid), @intFromPtr(child_tid), newtls);
}

/// See also `clone` (from the arch-specific include)
pub fn clone2(flags: u32, child_stack_ptr: usize) usize {
    return syscall2(.clone, flags, child_stack_ptr);
}

/// This call cannot fail, and the return value is the caller's thread id
pub fn set_tid_address(tidptr: ?*pid_t) pid_t {
    return @intCast(@as(u32, @truncate(syscall1(.set_tid_address, @intFromPtr(tidptr)))));
}

pub fn close(fd: fd_t) usize {
    return syscall1(.close, @as(u32, @bitCast(fd)));
}

pub const CLOSE_RANGE = packed struct(u32) {
    _0: u1 = 0,
    /// Unshare the file descriptor table before closing file descriptors.
    UNSHARE: bool, // 0x00000001
    /// Set the FD_CLOEXEC bit instead of closing the file descriptor.
    CLOEXEC: bool, // 0x00000002
    _: u29 = 0,
};

pub fn close_range(first: fd_t, last: fd_t, flags: CLOSE_RANGE) usize {
    return syscall3(.close_range, @as(u32, @bitCast(first)), @as(u32, @bitCast(last)), @as(u32, @bitCast(flags)));
}

pub fn fchmod(fd: fd_t, mode: mode_t) usize {
    return syscall2(.fchmod, @as(u32, @bitCast(fd)), mode);
}

pub fn chmod(path: [*:0]const u8, mode: mode_t) usize {
    if (@hasField(SYS, "chmod")) {
        return syscall2(.chmod, @intFromPtr(path), mode);
    } else {
        return fchmodat(AT.FDCWD, path, mode);
    }
}

pub fn fchown(fd: fd_t, owner: uid_t, group: gid_t) usize {
    if (@hasField(SYS, "fchown32")) {
        return syscall3(.fchown32, @as(u32, @bitCast(fd)), owner, group);
    } else {
        return syscall3(.fchown, @as(u32, @bitCast(fd)), owner, group);
    }
}

pub fn fchownat(fd: fd_t, path: [*:0]const u8, owner: uid_t, group: gid_t, flags: u32) usize {
    return syscall5(.fchownat, @as(u32, @bitCast(fd)), @intFromPtr(path), owner, group, flags);
}

pub fn chown(path: [*:0]const u8, owner: uid_t, group: gid_t) usize {
    if (@hasField(SYS, "chown32")) {
        return syscall3(.chown32, @intFromPtr(path), owner, group);
    } else if (@hasField(SYS, "chown")) {
        return syscall3(.chown, @intFromPtr(path), owner, group);
    } else {
        return fchownat(AT.FDCWD, path, owner, group, 0);
    }
}

pub fn lchown(path: [*:0]const u8, owner: uid_t, group: gid_t) usize {
    if (@hasField(SYS, "lchown32")) {
        return syscall3(.lchown32, @intFromPtr(path), owner, group);
    } else if (@hasField(SYS, "lchown")) {
        return syscall3(.lchown, @intFromPtr(path), owner, group);
    } else {
        return fchownat(AT.FDCWD, path, owner, group, AT.SYMLINK_NOFOLLOW);
    }
}

pub fn fchmodat(fd: fd_t, path: [*:0]const u8, mode: mode_t) usize {
    return syscall3(.fchmodat, @as(u32, @bitCast(fd)), @intFromPtr(path), mode);
}

pub fn fchmodat2(fd: fd_t, path: [*:0]const u8, mode: mode_t, flags: u32) usize {
    return syscall4(.fchmodat2, @as(u32, @bitCast(fd)), @intFromPtr(path), mode, flags);
}

/// Can only be called on 32 bit systems. For 64 bit see `lseek`.
pub fn llseek(fd: fd_t, offset: off_t, result: ?*off_t, whence: u32) u32 {
    // NOTE: The offset parameter splitting is independent from the target
    // endianness.
    return syscall5(
        .llseek,
        @as(u32, @bitCast(fd)),
        @truncate(@as(u64, @bitCast(offset >> 32))),
        @truncate(@as(u64, @bitCast(offset))),
        @intFromPtr(result),
        whence,
    );
}

/// Can only be called on 64 bit systems. For 32 bit see `llseek`.
pub fn lseek(fd: fd_t, offset: off_t, whence: u32) u64 {
    return switch (builtin.abi) {
        .gnuabin32,
        .muslabin32,
        .abin32,
        .gnux32,
        .muslx32,
        .x32,
        => syscall_lseek(fd, offset, whence),
        else => syscall3(.lseek, @as(u32, @bitCast(fd)), @as(u64, @bitCast(offset)), whence),
    };
}

pub fn exit(status: i32) noreturn {
    _ = syscall1(.exit, @as(u32, @bitCast(status)));
    unreachable;
}

pub fn exit_group(status: i32) noreturn {
    _ = syscall1(.exit_group, @as(u32, @bitCast(status)));
    unreachable;
}

/// flags for the `reboot' system call.
pub const LINUX_REBOOT = struct {
    /// First magic value required to use _reboot() system call.
    pub const MAGIC1 = enum(u32) {
        MAGIC1 = 0xfee1dead,
        _,
    };

    /// Second magic value required to use _reboot() system call.
    pub const MAGIC2 = enum(u32) {
        MAGIC2 = 672274793,
        MAGIC2A = 85072278,
        MAGIC2B = 369367448,
        MAGIC2C = 537993216,
        _,
    };

    /// Commands accepted by the _reboot() system call.
    pub const CMD = enum(u32) {
        /// Restart system using default command and mode.
        RESTART = 0x01234567,

        /// Stop OS and give system control to ROM monitor, if any.
        HALT = 0xCDEF0123,

        /// Ctrl-Alt-Del sequence causes RESTART command.
        CAD_ON = 0x89ABCDEF,

        /// Ctrl-Alt-Del sequence sends SIGINT to init task.
        CAD_OFF = 0x00000000,

        /// Stop OS and remove all power from system, if possible.
        POWER_OFF = 0x4321FEDC,

        /// Restart system using given command string.
        RESTART2 = 0xA1B2C3D4,

        /// Suspend system using software suspend if compiled in.
        SW_SUSPEND = 0xD000FCE2,

        /// Restart system using a previously loaded Linux kernel
        KEXEC = 0x45584543,

        _,
    };
};

pub fn reboot(magic: LINUX_REBOOT.MAGIC1, magic2: LINUX_REBOOT.MAGIC2, cmd: LINUX_REBOOT.CMD, arg: ?*const anyopaque) usize {
    return std.os.linux.syscall4(
        .reboot,
        @backingInt(magic),
        @backingInt(magic2),
        @backingInt(cmd),
        @intFromPtr(arg),
    );
}

pub fn getrandom(buf: [*]u8, count: usize, flags: u32) usize {
    return syscall3(.getrandom, @intFromPtr(buf), count, flags);
}

pub fn kill(pid: pid_t, sig: SIG) usize {
    return syscall2(.kill, @as(u32, @bitCast(pid)), @backingInt(sig));
}

pub fn tkill(tid: pid_t, sig: SIG) usize {
    return syscall2(.tkill, @as(u32, @bitCast(tid)), @backingInt(sig));
}

pub fn tgkill(tgid: pid_t, tid: pid_t, sig: SIG) usize {
    return syscall3(.tgkill, @as(u32, @bitCast(tgid)), @as(u32, @bitCast(tid)), @backingInt(sig));
}

pub fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8) usize {
    if (@hasField(SYS, "link")) {
        return syscall2(
            .link,
            @intFromPtr(oldpath),
            @intFromPtr(newpath),
        );
    } else {
        return syscall5(
            .linkat,
            @as(u32, @bitCast(@as(i32, AT.FDCWD))),
            @intFromPtr(oldpath),
            @as(u32, @bitCast(@as(i32, AT.FDCWD))),
            @intFromPtr(newpath),
            0,
        );
    }
}

pub fn linkat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8, flags: u32) usize {
    return syscall5(
        .linkat,
        @as(u32, @bitCast(oldfd)),
        @intFromPtr(oldpath),
        @as(u32, @bitCast(newfd)),
        @intFromPtr(newpath),
        flags,
    );
}

pub fn unlink(path: [*:0]const u8) usize {
    if (@hasField(SYS, "unlink")) {
        return syscall1(.unlink, @intFromPtr(path));
    } else {
        return syscall3(.unlinkat, @as(u32, @bitCast(@as(i32, AT.FDCWD))), @intFromPtr(path), 0);
    }
}

pub fn unlinkat(dirfd: fd_t, path: [*:0]const u8, flags: u32) usize {
    return syscall3(.unlinkat, @as(u32, @bitCast(dirfd)), @intFromPtr(path), flags);
}

pub fn waitpid(pid: pid_t, status: *i32, flags: u32) usize {
    return syscall4(.wait4, @as(u32, @bitCast(pid)), @intFromPtr(status), flags, 0);
}

pub fn wait4(pid: pid_t, status: *i32, flags: u32, usage: ?*rusage) usize {
    return syscall4(
        .wait4,
        @as(u32, @bitCast(pid)),
        @intFromPtr(status),
        flags,
        @intFromPtr(usage),
    );
}

pub fn waitid(id_type: P, id: pid_t, infop: *siginfo_t, flags: u32, usage: ?*rusage) usize {
    return syscall5(
        .waitid,
        @backingInt(id_type),
        @as(u32, @bitCast(id)),
        @intFromPtr(infop),
        flags,
        @intFromPtr(usage),
    );
}

pub const F = struct {
    pub const DUPFD = 0;
    pub const GETFD = 1;
    pub const SETFD = 2;
    pub const GETFL = 3;
    pub const SETFL = 4;

    pub const GETLK = GET_SET_LK.GETLK;
    pub const SETLK = GET_SET_LK.SETLK;
    pub const SETLKW = GET_SET_LK.SETLKW;

    pub const SETOWN = GET_SET_OWN.SETOWN;
    pub const GETOWN = GET_SET_OWN.GETOWN;

    const GET_SET_LK = switch (native_arch) {
        .mips, .mipsel => struct {
            const GETLK = 33;
            const SETLK = 34;
            const SETLKW = 35;
        },
        .mips64, .mips64el => switch (native_abi) {
            .gnuabin32, .muslabin32, .abin32 => struct {
                const GETLK = 33;
                const SETLK = 34;
                const SETLKW = 35;
            },
            else => struct {
                const GETLK = 14;
                const SETLK = 6;
                const SETLKW = 7;
            },
        },
        .alpha, .sparc, .sparc64 => struct {
            const GETLK = 7;
            const SETLK = 8;
            const SETLKW = 9;
        },
        .hppa, .hppa64 => struct {
            const GETLK = 8;
            const SETLK = 9;
            const SETLKW = 10;
        },
        else => if (@sizeOf(usize) == 8) struct {
            const GETLK = 5;
            const SETLK = 6;
            const SETLKW = 7;
        } else struct {
            const GETLK = 12;
            const SETLK = 13;
            const SETLKW = 14;
        },
    };
    const GET_SET_OWN = switch (native_arch) {
        .mips, .mipsel, .mips64, .mips64el => struct {
            const GETOWN = 23;
            const SETOWN = 24;
        },
        .alpha, .sparc, .sparc64 => struct {
            const GETOWN = 5;
            const SETOWN = 6;
        },
        .hppa, .hppa64 => struct {
            const GETOWN = 11;
            const SETOWN = 12;
        },
        else => struct {
            const GETOWN = 8;
            const SETOWN = 9;
        },
    };

    pub const SETSIG = if (is_hppa) 13 else 10;
    pub const GETSIG = if (is_hppa) 14 else 11;

    pub const SETOWN_EX = 15;
    pub const GETOWN_EX = 16;

    pub const GETOWNER_UIDS = 17;

    pub const OFD_GETLK = 36;
    pub const OFD_SETLK = 37;
    pub const OFD_SETLKW = 38;

    pub const RDLCK = if (is_sparc) 1 else 0;
    pub const WRLCK = if (is_sparc) 2 else 1;
    pub const UNLCK = if (is_sparc) 3 else if (native_arch == .alpha) 8 else 2;

    pub const LINUX_SPECIFIC_BASE = 1024;

    pub const SETLEASE = LINUX_SPECIFIC_BASE + 0;
    pub const GETLEASE = LINUX_SPECIFIC_BASE + 1;
    pub const NOTIFY = LINUX_SPECIFIC_BASE + 2;
    pub const DUPFD_QUERY = LINUX_SPECIFIC_BASE + 3;
    pub const CREATED_QUERY = LINUX_SPECIFIC_BASE + 4;
    pub const CANCELLK = LINUX_SPECIFIC_BASE + 5;
    pub const DUPFD_CLOEXEC = LINUX_SPECIFIC_BASE + 6;
    pub const SETPIPE_SZ = LINUX_SPECIFIC_BASE + 7;
    pub const GETPIPE_SZ = LINUX_SPECIFIC_BASE + 8;
    pub const ADD_SEALS = LINUX_SPECIFIC_BASE + 9;
    pub const GET_SEALS = LINUX_SPECIFIC_BASE + 10;

    pub const SEAL_SEAL = 0x0001;
    pub const SEAL_SHRINK = 0x0002;
    pub const SEAL_GROW = 0x0004;
    pub const SEAL_WRITE = 0x0008;
    pub const SEAL_FUTURE_WRITE = 0x0010;
    pub const SEAL_EXEC = 0x0020;

    pub const GET_RW_HINT = LINUX_SPECIFIC_BASE + 11;
    pub const SET_RW_HINT = LINUX_SPECIFIC_BASE + 12;
    pub const GET_FILE_RW_HINT = LINUX_SPECIFIC_BASE + 13;
    pub const SET_FILE_RW_HINT = LINUX_SPECIFIC_BASE + 14;
};

pub const F_OWNER = enum(i32) {
    TID = 0,
    PID = 1,
    PGRP = 2,
    _,
};

pub const f_owner_ex = extern struct {
    type: F_OWNER,
    pid: pid_t,
};

pub const Flock = extern struct {
    type: i16,
    whence: i16,
    start: off_t,
    len: off_t,
    pid: pid_t,
    _unused: if (is_sparc) i16 else void,
};

pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) usize {
    if (@hasField(SYS, "fcntl64")) {
        return syscall3(.fcntl64, @as(u32, @bitCast(fd)), @as(u32, @bitCast(cmd)), arg);
    } else {
        return syscall3(.fcntl, @as(u32, @bitCast(fd)), @as(u32, @bitCast(cmd)), arg);
    }
}

pub fn flock(fd: fd_t, operation: i32) usize {
    return syscall2(.flock, @as(u32, @bitCast(fd)), @as(u32, @bitCast(operation)));
}

pub const Elf_Symndx = switch (native_arch) {
    .alpha, .s390x => u64,
    else => u32,
};

// We must follow the C calling convention when we call into the VDSO
const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.c) usize;
var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime;

pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize {
    if (VDSO != void) {
        const ptr = @atomicLoad(?VdsoClockGettime, &vdso_clock_gettime, .unordered);
        if (ptr) |f| {
            const rc = f(clk_id, tp);
            switch (rc) {
                0, @as(usize, @bitCast(-@as(isize, @backingInt(E.INVAL)))) => return rc,
                else => {},
            }
        }
    }
    return syscall2(
        if (@hasField(SYS, "clock_gettime") and native_arch != .hexagon) .clock_gettime else .clock_gettime64,
        @backingInt(clk_id),
        @intFromPtr(tp),
    );
}

fn init_vdso_clock_gettime(clk: clockid_t, ts: *timespec) callconv(.c) usize {
    const ptr: ?VdsoClockGettime = @ptrFromInt(vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM));
    // Note that we may not have a VDSO at all, update the stub address anyway
    // so that clock_gettime will fall back on the good old (and slow) syscall
    @atomicStore(?VdsoClockGettime, &vdso_clock_gettime, ptr, .monotonic);
    // Call into the VDSO if available
    if (ptr) |f| return f(clk, ts);
    return @bitCast(-@as(isize, @backingInt(E.NOSYS)));
}

pub fn clock_getres(clk_id: clockid_t, tp: *timespec) usize {
    return syscall2(
        if (@hasField(SYS, "clock_getres") and native_arch != .hexagon) .clock_getres else .clock_getres_time64,
        @backingInt(clk_id),
        @intFromPtr(tp),
    );
}

pub fn clock_settime(clk_id: clockid_t, tp: *const timespec) usize {
    return syscall2(
        if (@hasField(SYS, "clock_settime") and native_arch != .hexagon) .clock_settime else .clock_settime64,
        @backingInt(clk_id),
        @intFromPtr(tp),
    );
}

pub fn clock_nanosleep(clockid: clockid_t, flags: TIMER, request: *const timespec, remain: ?*timespec) usize {
    return syscall4(
        if (@hasField(SYS, "clock_nanosleep") and native_arch != .hexagon) .clock_nanosleep else .clock_nanosleep_time64,
        @backingInt(clockid),
        @as(u32, @bitCast(flags)),
        @intFromPtr(request),
        @intFromPtr(remain),
    );
}

pub fn gettimeofday(tv: ?*timeval, tz: ?*timezone) usize {
    return syscall2(.gettimeofday, @intFromPtr(tv), @intFromPtr(tz));
}

pub fn settimeofday(tv: *const timeval, tz: *const timezone) usize {
    return syscall2(.settimeofday, @intFromPtr(tv), @intFromPtr(tz));
}

pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize {
    return syscall2(.nanosleep, @intFromPtr(req), @intFromPtr(rem));
}

pub fn pause() usize {
    if (@hasField(SYS, "pause")) {
        return syscall0(.pause);
    } else {
        return syscall4(.ppoll, 0, 0, 0, 0);
    }
}

pub fn setuid(uid: uid_t) usize {
    if (@hasField(SYS, "setuid32")) {
        return syscall1(.setuid32, uid);
    } else {
        return syscall1(.setuid, uid);
    }
}

pub fn setgid(gid: gid_t) usize {
    if (@hasField(SYS, "setgid32")) {
        return syscall1(.setgid32, gid);
    } else {
        return syscall1(.setgid, gid);
    }
}

pub fn setreuid(ruid: uid_t, euid: uid_t) usize {
    if (@hasField(SYS, "setreuid32")) {
        return syscall2(.setreuid32, ruid, euid);
    } else {
        return syscall2(.setreuid, ruid, euid);
    }
}

pub fn setregid(rgid: gid_t, egid: gid_t) usize {
    if (@hasField(SYS, "setregid32")) {
        return syscall2(.setregid32, rgid, egid);
    } else {
        return syscall2(.setregid, rgid, egid);
    }
}

pub fn getuid() uid_t {
    if (@hasField(SYS, "getuid32")) {
        return @as(uid_t, @intCast(syscall0(.getuid32)));
    } else {
        return @as(uid_t, @intCast(syscall0(.getuid)));
    }
}

pub fn getgid() gid_t {
    if (@hasField(SYS, "getgid32")) {
        return @as(gid_t, @intCast(syscall0(.getgid32)));
    } else {
        return @as(gid_t, @intCast(syscall0(.getgid)));
    }
}

pub fn geteuid() uid_t {
    if (@hasField(SYS, "geteuid32")) {
        return @as(uid_t, @intCast(syscall0(.geteuid32)));
    } else {
        return @as(uid_t, @intCast(syscall0(.geteuid)));
    }
}

pub fn getegid() gid_t {
    if (@hasField(SYS, "getegid32")) {
        return @as(gid_t, @intCast(syscall0(.getegid32)));
    } else {
        return @as(gid_t, @intCast(syscall0(.getegid)));
    }
}

pub fn seteuid(euid: uid_t) usize {
    // We use setresuid here instead of setreuid to ensure that the saved uid
    // is not changed. This is what musl and recent glibc versions do as well.
    //
    // The setresuid(2) man page says that if -1 is passed the corresponding
    // id will not be changed. Since uid_t is unsigned, this wraps around to the
    // max value in C.
    comptime assert(@typeInfo(uid_t) == .int and @typeInfo(uid_t).int.signedness == .unsigned);
    return setresuid(maxInt(uid_t), euid, maxInt(uid_t));
}

pub fn setegid(egid: gid_t) usize {
    // We use setresgid here instead of setregid to ensure that the saved uid
    // is not changed. This is what musl and recent glibc versions do as well.
    //
    // The setresgid(2) man page says that if -1 is passed the corresponding
    // id will not be changed. Since gid_t is unsigned, this wraps around to the
    // max value in C.
    comptime assert(@typeInfo(uid_t) == .int and @typeInfo(uid_t).int.signedness == .unsigned);
    return setresgid(maxInt(gid_t), egid, maxInt(gid_t));
}

pub fn getresuid(ruid: *uid_t, euid: *uid_t, suid: *uid_t) usize {
    if (@hasField(SYS, "getresuid32")) {
        return syscall3(.getresuid32, @intFromPtr(ruid), @intFromPtr(euid), @intFromPtr(suid));
    } else {
        return syscall3(.getresuid, @intFromPtr(ruid), @intFromPtr(euid), @intFromPtr(suid));
    }
}

pub fn getresgid(rgid: *gid_t, egid: *gid_t, sgid: *gid_t) usize {
    if (@hasField(SYS, "getresgid32")) {
        return syscall3(.getresgid32, @intFromPtr(rgid), @intFromPtr(egid), @intFromPtr(sgid));
    } else {
        return syscall3(.getresgid, @intFromPtr(rgid), @intFromPtr(egid), @intFromPtr(sgid));
    }
}

pub fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) usize {
    if (@hasField(SYS, "setresuid32")) {
        return syscall3(.setresuid32, ruid, euid, suid);
    } else {
        return syscall3(.setresuid, ruid, euid, suid);
    }
}

pub fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) usize {
    if (@hasField(SYS, "setresgid32")) {
        return syscall3(.setresgid32, rgid, egid, sgid);
    } else {
        return syscall3(.setresgid, rgid, egid, sgid);
    }
}

pub fn setpgid(pid: pid_t, pgid: pid_t) usize {
    return syscall2(.setpgid, @as(u32, @bitCast(pid)), @as(u32, @bitCast(pgid)));
}

pub fn getpgid(pid: pid_t) usize {
    return syscall1(.getpgid, @as(u32, @bitCast(pid)));
}

pub fn getgroups(size: usize, list: ?[*]gid_t) usize {
    if (@hasField(SYS, "getgroups32")) {
        return syscall2(.getgroups32, size, @intFromPtr(list));
    } else {
        return syscall2(.getgroups, size, @intFromPtr(list));
    }
}

pub fn setgroups(size: usize, list: [*]const gid_t) usize {
    if (@hasField(SYS, "setgroups32")) {
        return syscall2(.setgroups32, size, @intFromPtr(list));
    } else {
        return syscall2(.setgroups, size, @intFromPtr(list));
    }
}

pub fn setsid() usize {
    return syscall0(.setsid);
}

pub fn getsid(pid: pid_t) usize {
    return syscall1(.getsid, @as(u32, @bitCast(pid)));
}

pub fn getpid() pid_t {
    // Casts result to a pid_t, safety-checking >= 0, because getpid() cannot fail
    return @intCast(@as(u32, @truncate(syscall0(.getpid))));
}

pub fn getppid() pid_t {
    // Casts result to a pid_t, safety-checking >= 0, because getppid() cannot fail
    return @intCast(@as(u32, @truncate(syscall0(.getppid))));
}

pub fn gettid() pid_t {
    // Casts result to a pid_t, safety-checking >= 0, because gettid() cannot fail
    return @intCast(@as(u32, @truncate(syscall0(.gettid))));
}

pub fn sigprocmask(flags: u32, noalias set: ?*const sigset_t, noalias oldset: ?*sigset_t) usize {
    return syscall4(.rt_sigprocmask, flags, @intFromPtr(set), @intFromPtr(oldset), NSIG / 8);
}

pub fn sigaction(sig: SIG, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) usize {
    assert(@backingInt(sig) > 0);
    assert(@backingInt(sig) < NSIG);
    assert(sig != .KILL);
    assert(sig != .STOP);

    var ksa: k_sigaction = undefined;
    var oldksa: k_sigaction = undefined;
    const mask_size = @sizeOf(@TypeOf(ksa.mask));

    if (act) |new| {
        if (native_arch == .hexagon or is_loongarch or is_mips or native_arch == .or1k or is_riscv) {
            ksa = .{
                .handler = new.handler.handler,
                .flags = new.flags,
                .mask = new.mask,
            };
        } else {
            // Zig needs to install our arch restorer function with any signal handler, so
            // must copy the Sigaction struct
            const restorer_fn = if ((new.flags & SA.SIGINFO) != 0) &restore_rt else &restore;
            ksa = .{
                .handler = new.handler.handler,
                .flags = new.flags | SA.RESTORER,
                .mask = new.mask,
                .restorer = @ptrCast(restorer_fn),
            };
        }
    }

    const ksa_arg = if (act != null) @intFromPtr(&ksa) else 0;
    const oldksa_arg = if (oact != null) @intFromPtr(&oldksa) else 0;

    const result = switch (native_arch) {
        // The sparc version of rt_sigaction needs the restorer function to be passed as an argument too.
        .sparc, .sparc64 => syscall5(.rt_sigaction, @backingInt(sig), ksa_arg, oldksa_arg, @intFromPtr(ksa.restorer), mask_size),
        else => syscall4(.rt_sigaction, @backingInt(sig), ksa_arg, oldksa_arg, mask_size),
    };
    if (errno(result) != .SUCCESS) return result;

    if (oact) |old| {
        old.handler.handler = oldksa.handler;
        old.flags = oldksa.flags;
        old.mask = oldksa.mask;
    }

    return 0;
}

/// Defined as one greater than the largest defined signal number.
pub const NSIG = if (is_mips) 128 else 65;

/// Linux kernel's sigset_t.  This is logically 64-bit on most
/// architectures, but 128-bit on MIPS.  Contrast with the 1024-bit
/// sigset_t exported by the glibc and musl library ABIs.
pub const sigset_t = [(NSIG - 1 + 7) / @bitSizeOf(SigsetElement)]SigsetElement;

const SigsetElement = c_ulong;

const sigset_len = @typeInfo(sigset_t).array.len;

/// Zig's SIGRTMIN, but is a function for compatibility with glibc
pub fn sigrtmin() u8 {
    // Default is 32 in the kernel UAPI: https://github.com/torvalds/linux/blob/78109c591b806e41987e0b83390e61d675d1f724/include/uapi/asm-generic/signal.h#L50
    // AFAICT, all architectures that override this also set it to 32:
    // https://github.com/search?q=repo%3Atorvalds%2Flinux+sigrtmin+path%3Auapi&type=code
    return 32;
}

/// Zig's SIGRTMAX, but is a function for compatibility with glibc
pub fn sigrtmax() u8 {
    return NSIG - 1;
}

/// Zig's version of sigemptyset.  Returns initialized sigset_t.
pub fn sigemptyset() sigset_t {
    return @splat(0);
}

/// Zig's version of sigfillset.  Returns initalized sigset_t.
pub fn sigfillset() sigset_t {
    return @splat(~@as(SigsetElement, 0));
}

fn sigset_bit_index(sig: SIG) struct { word: usize, mask: SigsetElement } {
    assert(@backingInt(sig) > 0);
    assert(@backingInt(sig) < NSIG);
    const bit = @backingInt(sig) - 1;
    return .{
        .word = bit / @bitSizeOf(SigsetElement),
        .mask = @as(SigsetElement, 1) << @truncate(bit % @bitSizeOf(SigsetElement)),
    };
}

pub fn sigaddset(set: *sigset_t, sig: SIG) void {
    const index = sigset_bit_index(sig);
    (set.*)[index.word] |= index.mask;
}

pub fn sigdelset(set: *sigset_t, sig: SIG) void {
    const index = sigset_bit_index(sig);
    (set.*)[index.word] &= ~index.mask;
}

pub fn sigismember(set: *const sigset_t, sig: SIG) bool {
    const index = sigset_bit_index(sig);
    return ((set.*)[index.word] & index.mask) != 0;
}

pub fn getsockname(fd: fd_t, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
    if (native_arch == .x86) {
        return socketcall(SC.getsockname, &[3]usize{ @as(u32, @bitCast(fd)), @intFromPtr(addr), @intFromPtr(len) });
    }
    return syscall3(.getsockname, @as(u32, @bitCast(fd)), @intFromPtr(addr), @intFromPtr(len));
}

pub fn getpeername(fd: fd_t, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
    if (native_arch == .x86) {
        return socketcall(SC.getpeername, &[3]usize{ @as(u32, @bitCast(fd)), @intFromPtr(addr), @intFromPtr(len) });
    }
    return syscall3(.getpeername, @as(u32, @bitCast(fd)), @intFromPtr(addr), @intFromPtr(len));
}

pub fn socket(domain: u32, socket_type: u32, protocol: u32) usize {
    if (native_arch == .x86) {
        return socketcall(SC.socket, &[3]usize{ domain, socket_type, protocol });
    }
    return syscall3(.socket, domain, socket_type, protocol);
}

pub fn setsockopt(fd: fd_t, level: i32, optname: u32, optval: [*]const u8, optlen: socklen_t) usize {
    if (native_arch == .x86) {
        return socketcall(SC.setsockopt, &[5]usize{ @as(u32, @bitCast(fd)), @as(usize, @bitCast(@as(isize, level))), optname, @intFromPtr(optval), @as(usize, @intCast(optlen)) });
    }
    return syscall5(.setsockopt, @as(u32, @bitCast(fd)), @as(usize, @bitCast(@as(isize, level))), optname, @intFromPtr(optval), @as(usize, @intCast(optlen)));
}

pub fn getsockopt(fd: fd_t, level: i32, optname: u32, noalias optval: [*]u8, noalias optlen: *socklen_t) usize {
    if (native_arch == .x86) {
        return socketcall(SC.getsockopt, &[5]usize{ @as(u32, @bitCast(fd)), @as(usize, @bitCast(@as(isize, level))), optname, @intFromPtr(optval), @intFromPtr(optlen) });
    }
    return syscall5(.getsockopt, @as(u32, @bitCast(fd)), @as(usize, @bitCast(@as(isize, level))), optname, @intFromPtr(optval), @intFromPtr(optlen));
}

pub fn sendmsg(fd: fd_t, msg: *const msghdr_const, flags: u32) usize {
    if (native_arch == .x86) {
        return socketcall(SC.sendmsg, &[3]usize{ @as(u32, @bitCast(fd)), @intFromPtr(msg), flags });
    } else {
        return syscall3(.sendmsg, @as(u32, @bitCast(fd)), @intFromPtr(msg), flags);
    }
}

pub fn sendmmsg(fd: fd_t, msgvec: [*]mmsghdr, vlen: u32, flags: u32) usize {
    return syscall4(.sendmmsg, @as(u32, @bitCast(fd)), @intFromPtr(msgvec), vlen, flags);
}

pub fn connect(fd: fd_t, addr: *const anyopaque, len: socklen_t) usize {
    if (native_arch == .x86) {
        return socketcall(SC.connect, &[3]usize{ @as(u32, @bitCast(fd)), @intFromPtr(addr), len });
    } else {
        return syscall3(.connect, @as(u32, @bitCast(fd)), @intFromPtr(addr), len);
    }
}

pub fn recvmsg(fd: fd_t, msg: *msghdr, flags: u32) usize {
    if (native_arch == .x86) {
        return socketcall(SC.recvmsg, &[3]usize{ @as(u32, @bitCast(fd)), @intFromPtr(msg), flags });
    } else {
        return syscall3(.recvmsg, @as(u32, @bitCast(fd)), @intFromPtr(msg), flags);
    }
}

pub fn recvmmsg(fd: fd_t, msgvec: ?[*]mmsghdr, vlen: u32, flags: u32, timeout: ?*timespec) usize {
    return syscall5(
        if (@hasField(SYS, "recvmmsg") and native_arch != .hexagon) .recvmmsg else .recvmmsg_time64,
        @as(u32, @bitCast(fd)),
        @intFromPtr(msgvec),
        vlen,
        flags,
        @intFromPtr(timeout),
    );
}

pub fn recvfrom(
    fd: fd_t,
    noalias buf: [*]u8,
    len: usize,
    flags: u32,
    noalias addr: ?*sockaddr,
    noalias alen: ?*socklen_t,
) usize {
    if (native_arch == .x86) {
        return socketcall(SC.recvfrom, &[6]usize{ @as(u32, @bitCast(fd)), @intFromPtr(buf), len, flags, @intFromPtr(addr), @intFromPtr(alen) });
    } else {
        return syscall6(.recvfrom, @as(u32, @bitCast(fd)), @intFromPtr(buf), len, flags, @intFromPtr(addr), @intFromPtr(alen));
    }
}

pub fn shutdown(fd: fd_t, how: i32) usize {
    if (native_arch == .x86) {
        return socketcall(SC.shutdown, &[2]usize{ @as(u32, @bitCast(fd)), @as(u32, @bitCast(how)) });
    }
    return syscall2(.shutdown, @as(u32, @bitCast(fd)), @as(u32, @bitCast(how)));
}

pub fn bind(fd: fd_t, addr: *const sockaddr, len: socklen_t) usize {
    if (native_arch == .x86) {
        return socketcall(SC.bind, &[3]usize{ @as(u32, @bitCast(fd)), @intFromPtr(addr), len });
    }
    return syscall3(.bind, @as(u32, @bitCast(fd)), @intFromPtr(addr), len);
}

pub fn listen(fd: fd_t, backlog: u32) usize {
    if (native_arch == .x86) {
        return socketcall(SC.listen, &[2]usize{ @as(u32, @bitCast(fd)), backlog });
    }
    return syscall2(.listen, @as(u32, @bitCast(fd)), backlog);
}

pub fn sendto(fd: i32, buf: [*]const u8, len: usize, flags: u32, addr: ?*const sockaddr, alen: socklen_t) usize {
    if (native_arch == .x86) {
        return socketcall(SC.sendto, &[6]usize{ @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(buf), len, flags, @intFromPtr(addr), @as(usize, @intCast(alen)) });
    }
    return syscall6(.sendto, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(buf), len, flags, @intFromPtr(addr), @as(usize, @intCast(alen)));
}

pub fn sendfile(outfd: fd_t, infd: fd_t, offset: ?*off_t, count: usize) usize {
    return syscall4(
        if (@hasField(SYS, "sendfile64")) .sendfile64 else .sendfile,
        @as(u32, @bitCast(outfd)),
        @as(u32, @bitCast(infd)),
        @intFromPtr(offset),
        count,
    );
}

pub fn socketpair(domain: u32, socket_type: u32, protocol: u32, fd: *[2]fd_t) usize {
    if (native_arch == .x86) {
        return socketcall(SC.socketpair, &[4]usize{ domain, socket_type, protocol, @intFromPtr(fd) });
    }
    return syscall4(.socketpair, domain, socket_type, protocol, @intFromPtr(fd));
}

pub fn accept(fd: fd_t, noalias addr: ?*sockaddr, noalias len: ?*socklen_t) usize {
    if (native_arch == .x86) {
        return socketcall(SC.accept, &[4]usize{ @as(u32, @bitCast(fd)), @intFromPtr(addr), @intFromPtr(len), 0 });
    }
    return accept4(fd, addr, len, 0);
}

pub fn accept4(fd: fd_t, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flags: u32) usize {
    if (native_arch == .x86) {
        return socketcall(SC.accept4, &[4]usize{ @as(u32, @bitCast(fd)), @intFromPtr(addr), @intFromPtr(len), flags });
    }
    return syscall4(.accept4, @as(u32, @bitCast(fd)), @intFromPtr(addr), @intFromPtr(len), flags);
}

pub fn statx(dirfd: fd_t, path: [*:0]const u8, flags: u32, mask: STATX, statx_buf: *Statx) usize {
    return syscall5(
        .statx,
        @as(u32, @bitCast(dirfd)),
        @intFromPtr(path),
        flags,
        @as(u32, @bitCast(mask)),
        @intFromPtr(statx_buf),
    );
}

pub fn listxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize {
    return syscall3(.listxattr, @intFromPtr(path), @intFromPtr(list), size);
}

pub fn llistxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize {
    return syscall3(.llistxattr, @intFromPtr(path), @intFromPtr(list), size);
}

pub fn flistxattr(fd: fd_t, list: [*]u8, size: usize) usize {
    return syscall3(.flistxattr, @as(u32, @bitCast(fd)), @intFromPtr(list), size);
}

pub fn getxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]u8, size: usize) usize {
    return syscall4(.getxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size);
}

pub fn lgetxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]u8, size: usize) usize {
    return syscall4(.lgetxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size);
}

pub fn fgetxattr(fd: fd_t, name: [*:0]const u8, value: [*]u8, size: usize) usize {
    return syscall4(.fgetxattr, @as(u32, @bitCast(fd)), @intFromPtr(name), @intFromPtr(value), size);
}

pub fn setxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]const u8, size: usize, flags: usize) usize {
    return syscall5(.setxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size, flags);
}

pub fn lsetxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]const u8, size: usize, flags: usize) usize {
    return syscall5(.lsetxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size, flags);
}

pub fn fsetxattr(fd: fd_t, name: [*:0]const u8, value: [*]const u8, size: usize, flags: usize) usize {
    return syscall5(.fsetxattr, @as(u32, @bitCast(fd)), @intFromPtr(name), @intFromPtr(value), size, flags);
}

pub fn removexattr(path: [*:0]const u8, name: [*:0]const u8) usize {
    return syscall2(.removexattr, @intFromPtr(path), @intFromPtr(name));
}

pub fn lremovexattr(path: [*:0]const u8, name: [*:0]const u8) usize {
    return syscall2(.lremovexattr, @intFromPtr(path), @intFromPtr(name));
}

pub fn fremovexattr(fd: fd_t, name: [*:0]const u8) usize {
    return syscall2(.fremovexattr, @as(u32, @bitCast(fd)), @intFromPtr(name));
}

pub const sched_param = extern struct {
    priority: i32,
};

pub const SCHED = packed struct(i32) {
    pub const Mode = enum(u3) {
        /// normal multi-user scheduling
        NORMAL = 0,
        /// FIFO realtime scheduling
        FIFO = 1,
        /// Round-robin realtime scheduling
        RR = 2,
        /// For "batch" style execution of processes
        BATCH = 3,
        /// Low latency scheduling
        IDLE = 5,
        /// Sporadic task model deadline scheduling
        DEADLINE = 6,
    };
    mode: Mode, //bits [0, 2]
    _3: u27 = 0, //bits [3, 29]
    /// set to true to stop children from inheriting policies
    RESET_ON_FORK: bool = false, //bit 30
    _31: u1 = 0, //bit 31
};

pub fn sched_setparam(pid: pid_t, param: *const sched_param) usize {
    return syscall2(.sched_setparam, @as(u32, @bitCast(pid)), @intFromPtr(param));
}

pub fn sched_getparam(pid: pid_t, param: *sched_param) usize {
    return syscall2(.sched_getparam, @as(u32, @bitCast(pid)), @intFromPtr(param));
}

pub fn sched_setscheduler(pid: pid_t, policy: SCHED, param: *const sched_param) usize {
    return syscall3(.sched_setscheduler, @as(u32, @bitCast(pid)), @as(u32, @bitCast(policy)), @intFromPtr(param));
}

pub fn sched_getscheduler(pid: pid_t) usize {
    return syscall1(.sched_getscheduler, @as(u32, @bitCast(pid)));
}

pub fn sched_get_priority_max(policy: SCHED) usize {
    return syscall1(.sched_get_priority_max, @as(u32, @bitCast(policy)));
}

pub fn sched_get_priority_min(policy: SCHED) usize {
    return syscall1(.sched_get_priority_min, @as(u32, @bitCast(policy)));
}

pub fn getcpu(cpu: ?*usize, node: ?*usize) usize {
    return syscall2(.getcpu, @intFromPtr(cpu), @intFromPtr(node));
}

pub const sched_attr = extern struct {
    size: u32 = 48, // Size of this structure
    policy: u32 = 0, // Policy (SCHED_*)
    flags: u64 = 0, // Flags
    nice: u32 = 0, // Nice value (SCHED_OTHER, SCHED_BATCH)
    priority: u32 = 0, // Static priority (SCHED_FIFO, SCHED_RR)
    // Remaining fields are for SCHED_DEADLINE
    runtime: u64 = 0,
    deadline: u64 = 0,
    period: u64 = 0,
};

pub fn sched_setattr(pid: pid_t, attr: *const sched_attr, flags: u32) usize {
    return syscall3(.sched_setattr, @as(u32, @bitCast(pid)), @intFromPtr(attr), flags);
}

pub fn sched_getattr(pid: pid_t, attr: *sched_attr, size: u32, flags: u32) usize {
    return syscall4(.sched_getattr, @as(u32, @bitCast(pid)), @intFromPtr(attr), size, flags);
}

pub fn sched_rr_get_interval(pid: pid_t, tp: *timespec) usize {
    return syscall2(.sched_rr_get_interval, @as(u32, @bitCast(pid)), @intFromPtr(tp));
}

pub fn sched_yield() usize {
    return syscall0(.sched_yield);
}

pub fn sched_getaffinity(pid: pid_t, size: u32, set: *cpu_set_t) usize {
    const rc = syscall3(.sched_getaffinity, @as(u32, @bitCast(pid)), size, @intFromPtr(set));
    if (@as(isize, @bitCast(rc)) < 0) return rc;
    if (rc < size) @memset(@as([*]u8, @ptrCast(set))[rc..size], 0);
    return 0;
}

pub fn sched_setaffinity(pid: pid_t, set: *const cpu_set_t) !void {
    const size = @sizeOf(cpu_set_t);
    const rc = syscall3(.sched_setaffinity, @as(u32, @bitCast(pid)), size, @intFromPtr(set));

    switch (errno(rc)) {
        .SUCCESS => return,
        else => |err| return std.posix.unexpectedErrno(err),
    }
}

pub fn epoll_create() usize {
    return epoll_create1(0);
}

pub fn epoll_create1(flags: u32) usize {
    return syscall1(.epoll_create1, flags);
}

pub fn epoll_ctl(epoll_fd: fd_t, op: u32, fd: fd_t, ev: ?*epoll_event) usize {
    return syscall4(.epoll_ctl, @as(u32, @bitCast(epoll_fd)), op, @as(u32, @bitCast(fd)), @intFromPtr(ev));
}

pub fn epoll_wait(epoll_fd: fd_t, events: [*]epoll_event, maxevents: u32, timeout: i32) usize {
    return epoll_pwait(epoll_fd, events, maxevents, timeout, null);
}

pub fn epoll_pwait(epoll_fd: fd_t, events: [*]epoll_event, maxevents: u32, timeout: i32, sigmask: ?*const sigset_t) usize {
    return syscall6(
        .epoll_pwait,
        @as(u32, @bitCast(epoll_fd)),
        @intFromPtr(events),
        maxevents,
        @as(u32, @bitCast(timeout)),
        @intFromPtr(sigmask),
        NSIG / 8,
    );
}

pub fn eventfd(count: u32, flags: u32) usize {
    return syscall2(.eventfd2, count, flags);
}

pub fn timerfd_create(clockid: timerfd_clockid_t, flags: TFD) usize {
    return syscall2(
        .timerfd_create,
        @backingInt(clockid),
        @as(u32, @bitCast(flags)),
    );
}

pub const itimerspec = extern struct {
    it_interval: timespec,
    it_value: timespec,
};

pub fn timerfd_gettime(fd: fd_t, curr_value: *itimerspec) usize {
    return syscall2(
        if (@hasField(SYS, "timerfd_gettime") and native_arch != .hexagon) .timerfd_gettime else .timerfd_gettime64,
        @as(u32, @bitCast(fd)),
        @intFromPtr(curr_value),
    );
}

pub fn timerfd_settime(fd: fd_t, flags: TFD.TIMER, new_value: *const itimerspec, old_value: ?*itimerspec) usize {
    return syscall4(
        if (@hasField(SYS, "timerfd_settime") and native_arch != .hexagon) .timerfd_settime else .timerfd_settime64,
        @as(u32, @bitCast(fd)),
        @as(u32, @bitCast(flags)),
        @intFromPtr(new_value),
        @intFromPtr(old_value),
    );
}

// Flags for the 'setitimer' system call
pub const ITIMER = enum(i32) {
    REAL = 0,
    VIRTUAL = 1,
    PROF = 2,
};

pub fn getitimer(which: i32, curr_value: *itimerspec) usize {
    return syscall2(.getitimer, @as(u32, @bitCast(which)), @intFromPtr(curr_value));
}

pub fn setitimer(which: i32, new_value: *const itimerspec, old_value: ?*itimerspec) usize {
    return syscall3(.setitimer, @as(u32, @bitCast(which)), @intFromPtr(new_value), @intFromPtr(old_value));
}

pub fn unshare(flags: usize) usize {
    return syscall1(.unshare, flags);
}

pub fn setns(fd: fd_t, flags: u32) usize {
    return syscall2(.setns, @as(u32, @bitCast(fd)), flags);
}

pub fn capget(hdrp: *cap_user_header_t, datap: *cap_user_data_t) usize {
    return syscall2(.capget, @intFromPtr(hdrp), @intFromPtr(datap));
}

pub fn capset(hdrp: *cap_user_header_t, datap: *const cap_user_data_t) usize {
    return syscall2(.capset, @intFromPtr(hdrp), @intFromPtr(datap));
}

pub fn sigaltstack(ss: ?*const stack_t, old_ss: ?*stack_t) usize {
    return syscall2(.sigaltstack, @intFromPtr(ss), @intFromPtr(old_ss));
}

pub fn uname(uts: *utsname) usize {
    return syscall1(.uname, @intFromPtr(uts));
}

pub fn io_uring_setup(entries: u32, p: *io_uring_params) usize {
    return syscall2(.io_uring_setup, entries, @intFromPtr(p));
}

pub fn io_uring_enter(fd: fd_t, to_submit: u32, min_complete: u32, flags: u32, sig: ?*sigset_t) usize {
    return syscall6(.io_uring_enter, @as(u32, @bitCast(fd)), to_submit, min_complete, flags, @intFromPtr(sig), NSIG / 8);
}

pub fn io_uring_register(fd: fd_t, opcode: IORING_REGISTER, arg: ?*const anyopaque, nr_args: u32) usize {
    return syscall4(.io_uring_register, @as(u32, @bitCast(fd)), @backingInt(opcode), @intFromPtr(arg), nr_args);
}

pub fn memfd_create(name: [*:0]const u8, flags: u32) usize {
    return syscall2(.memfd_create, @intFromPtr(name), flags);
}

pub fn getrusage(who: i32, usage: *rusage) usize {
    return syscall2(.getrusage, @as(u32, @bitCast(who)), @intFromPtr(usage));
}

pub fn tcgetattr(fd: fd_t, termios_p: *termios) usize {
    return syscall3(.ioctl, @as(u32, @bitCast(fd)), T.CGETS, @intFromPtr(termios_p));
}

pub fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) usize {
    return syscall3(.ioctl, @as(u32, @bitCast(fd)), T.CSETS + @backingInt(optional_action), @intFromPtr(termios_p));
}

pub fn tcgetpgrp(fd: fd_t, pgrp: *pid_t) usize {
    return syscall3(.ioctl, @as(u32, @bitCast(fd)), T.IOCGPGRP, @intFromPtr(pgrp));
}

pub fn tcsetpgrp(fd: fd_t, pgrp: *const pid_t) usize {
    return syscall3(.ioctl, @as(u32, @bitCast(fd)), T.IOCSPGRP, @intFromPtr(pgrp));
}

pub fn tcdrain(fd: fd_t) usize {
    return syscall3(.ioctl, @as(u32, @bitCast(fd)), T.CSBRK, 1);
}

pub fn ioctl(fd: fd_t, request: u32, arg: usize) usize {
    return syscall3(.ioctl, @as(u32, @bitCast(fd)), request, arg);
}

pub fn signalfd(fd: fd_t, mask: *const sigset_t, flags: u32) usize {
    return syscall4(.signalfd4, @as(u32, @bitCast(fd)), @intFromPtr(mask), NSIG / 8, flags);
}

pub fn copy_file_range(fd_in: fd_t, off_in: ?*off_t, fd_out: fd_t, off_out: ?*off_t, len: usize, flags: u32) usize {
    return syscall6(
        .copy_file_range,
        @as(u32, @bitCast(fd_in)),
        @intFromPtr(off_in),
        @as(u32, @bitCast(fd_out)),
        @intFromPtr(off_out),
        len,
        flags,
    );
}

pub fn bpf(cmd: BPF.Cmd, attr: *BPF.Attr, size: u32) usize {
    return syscall3(.bpf, @backingInt(cmd), @intFromPtr(attr), size);
}

pub fn sync() void {
    _ = syscall0(.sync);
}

pub fn syncfs(fd: fd_t) usize {
    return syscall1(.syncfs, @as(u32, @bitCast(fd)));
}

pub fn fsync(fd: fd_t) usize {
    return syscall1(.fsync, @as(u32, @bitCast(fd)));
}

pub fn fdatasync(fd: fd_t) usize {
    return syscall1(.fdatasync, @as(u32, @bitCast(fd)));
}

pub fn prctl(option: i32, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
    return syscall5(.prctl, @as(u32, @bitCast(option)), arg2, arg3, arg4, arg5);
}

pub fn getrlimit(resource: rlimit_resource, rlim: *rlimit) usize {
    // use prlimit64 to have 64 bit limits on 32 bit platforms
    return prlimit(0, resource, null, rlim);
}

pub fn setrlimit(resource: rlimit_resource, rlim: *const rlimit) usize {
    // use prlimit64 to have 64 bit limits on 32 bit platforms
    return prlimit(0, resource, rlim, null);
}

pub fn prlimit(pid: pid_t, resource: rlimit_resource, new_limit: ?*const rlimit, old_limit: ?*rlimit) usize {
    return syscall4(
        .prlimit64,
        @as(u32, @bitCast(pid)),
        @as(u32, @bitCast(@as(i32, @backingInt(resource)))),
        @intFromPtr(new_limit),
        @intFromPtr(old_limit),
    );
}

pub fn mincore(address: [*]u8, len: usize, vec: [*]u8) usize {
    return syscall3(.mincore, @intFromPtr(address), len, @intFromPtr(vec));
}

pub fn madvise(address: [*]u8, len: usize, advice: u32) usize {
    return syscall3(.madvise, @intFromPtr(address), len, advice);
}

pub fn pidfd_open(pid: pid_t, flags: u32) usize {
    return syscall2(.pidfd_open, @as(u32, @bitCast(pid)), flags);
}

pub fn pidfd_getfd(pidfd: fd_t, targetfd: fd_t, flags: u32) usize {
    return syscall3(
        .pidfd_getfd,
        @as(u32, @bitCast(pidfd)),
        @as(u32, @bitCast(targetfd)),
        flags,
    );
}

pub fn pidfd_send_signal(pidfd: fd_t, sig: SIG, info: ?*siginfo_t, flags: u32) usize {
    return syscall4(
        .pidfd_send_signal,
        @as(u32, @bitCast(pidfd)),
        @backingInt(sig),
        @intFromPtr(info),
        flags,
    );
}

pub fn process_vm_readv(pid: pid_t, local: []const iovec, remote: []const iovec_const, flags: usize) usize {
    return syscall6(
        .process_vm_readv,
        @as(u32, @bitCast(pid)),
        @intFromPtr(local.ptr),
        local.len,
        @intFromPtr(remote.ptr),
        remote.len,
        flags,
    );
}

pub fn process_vm_writev(pid: pid_t, local: []const iovec_const, remote: []const iovec_const, flags: usize) usize {
    return syscall6(
        .process_vm_writev,
        @as(u32, @bitCast(pid)),
        @intFromPtr(local.ptr),
        local.len,
        @intFromPtr(remote.ptr),
        remote.len,
        flags,
    );
}

pub fn fadvise(fd: fd_t, offset: i64, len: i64, advice: usize) usize {
    if (native_arch.isMIPS32()) {
        // MIPS O32 weirdly differs from the other architectures that require
        // aligned register pairs for this specific syscall.

        const offset_halves = splitValue64(offset);
        const length_halves = splitValue64(len);

        return syscall7(
            .fadvise64,
            @as(u32, @bitCast(fd)),
            0,
            offset_halves[0],
            offset_halves[1],
            length_halves[0],
            length_halves[1],
            advice,
        );
    } else if (require_aligned_register_pair) {
        const offset_halves = splitValue64(offset);
        const length_halves = splitValue64(len);

        return syscall6(
            .fadvise64_64,
            @as(u32, @bitCast(fd)),
            advice,
            offset_halves[0],
            offset_halves[1],
            length_halves[0],
            length_halves[1],
        );
    } else if (@sizeOf(syscall_arg_t) < @sizeOf(u64)) {
        const offset_halves = splitValue64(offset);
        const length_halves = splitValue64(len);

        return syscall6(
            .fadvise64_64,
            @as(u32, @bitCast(fd)),
            offset_halves[0],
            offset_halves[1],
            length_halves[0],
            length_halves[1],
            advice,
        );
    } else {
        return syscall4(
            .fadvise64,
            @as(u32, @bitCast(fd)),
            @as(u64, @bitCast(offset)),
            @as(u64, @bitCast(len)),
            advice,
        );
    }
}

pub fn perf_event_open(
    attr: *perf_event_attr,
    pid: pid_t,
    cpu: i32,
    group_fd: fd_t,
    flags: usize,
) usize {
    return syscall5(
        .perf_event_open,
        @intFromPtr(attr),
        @as(u32, @bitCast(pid)),
        @as(u32, @bitCast(cpu)),
        @as(u32, @bitCast(group_fd)),
        flags,
    );
}

pub fn seccomp(operation: u32, flags: u32, args: ?*const anyopaque) usize {
    return syscall3(.seccomp, operation, flags, @intFromPtr(args));
}

pub fn ptrace(
    req: u32,
    pid: pid_t,
    addr: usize,
    data: usize,
    addr2: usize,
) usize {
    return syscall5(
        .ptrace,
        req,
        @as(u32, @bitCast(pid)),
        addr,
        data,
        addr2,
    );
}

/// Query the page cache statistics of a file.
pub fn cachestat(
    /// The open file descriptor to retrieve statistics from.
    fd: fd_t,
    /// The byte range in `fd` to query.
    /// When `len > 0`, the range is `[off..off + len]`.
    /// When `len` == 0, the range is from `off` to the end of `fd`.
    cstat_range: *const cache_stat_range,
    /// The structure where page cache statistics are stored.
    cstat: *cache_stat,
    /// Currently unused, and must be set to `0`.
    flags: u32,
) usize {
    return syscall4(
        .cachestat,
        @as(u32, @bitCast(fd)),
        @intFromPtr(cstat_range),
        @intFromPtr(cstat),
        flags,
    );
}

pub fn map_shadow_stack(addr: usize, size: usize, flags: u32) usize {
    return syscall3(.map_shadow_stack, addr, size, flags);
}

pub fn tee(src: fd_t, dest: fd_t, len: usize, flags: u32) usize {
    return syscall4(
        .tee,
        @as(u32, @bitCast(src)),
        @as(u32, @bitCast(dest)),
        len,
        flags,
    );
}

pub const Sysinfo = switch (native_abi) {
    .gnux32, .muslx32, .x32 => extern struct {
        /// Seconds since boot
        uptime: i64,
        /// 1, 5, and 15 minute load averages
        loads: [3]u64,
        /// Total usable main memory size
        totalram: u64,
        /// Available memory size
        freeram: u64,
        /// Amount of shared memory
        sharedram: u64,
        /// Memory used by buffers
        bufferram: u64,
        /// Total swap space size
        totalswap: u64,
        /// swap space still available
        freeswap: u64,
        /// Number of current processes
        procs: u16,
        /// Explicit padding for m68k
        pad: u16,
        /// Total high memory size
        totalhigh: u64,
        /// Available high memory size
        freehigh: u64,
        /// Memory unit size in bytes
        mem_unit: u32,
    },
    else => extern struct {
        /// Seconds since boot
        uptime: isize,
        /// 1, 5, and 15 minute load averages
        loads: [3]usize,
        /// Total usable main memory size
        totalram: usize,
        /// Available memory size
        freeram: usize,
        /// Amount of shared memory
        sharedram: usize,
        /// Memory used by buffers
        bufferram: usize,
        /// Total swap space size
        totalswap: usize,
        /// swap space still available
        freeswap: usize,
        /// Number of current processes
        procs: u16,
        /// Explicit padding for m68k
        pad: u16,
        /// Total high memory size
        totalhigh: usize,
        /// Available high memory size
        freehigh: usize,
        /// Memory unit size in bytes
        mem_unit: u32,
        /// Pad
        _f: [20 - 2 * @sizeOf(usize) - @sizeOf(u32)]u8,
    },
};

pub fn sysinfo(info: *Sysinfo) usize {
    return syscall1(.sysinfo, @intFromPtr(info));
}

const VdsoSysRiscvHwprobe = *align(1) const fn (
    pairs: [*]riscv_hwprobe,
    pair_count: usize,
    cpusetsize: usize,
    cpus: ?[*]cpu_set_t,
    flags: u32,
) callconv(.c) usize;
var vdso_sys_riscv_hwprobe: ?VdsoSysRiscvHwprobe = &init_vdso_sys_riscv_hwprobe;

fn init_vdso_sys_riscv_hwprobe(
    pairs: [*]riscv_hwprobe,
    pair_count: usize,
    cpusetsize: usize,
    cpus: ?[*]cpu_set_t,
    flags: u32,
) callconv(.c) usize {
    const ptr: ?VdsoSysRiscvHwprobe = @ptrFromInt(vdso.lookup(VDSO.HWPROBE_VER, VDSO.HWPROBE_SYM));
    @atomicStore(?VdsoSysRiscvHwprobe, &vdso_sys_riscv_hwprobe, ptr, .monotonic);
    if (ptr) |f| return f(pairs, pair_count, cpusetsize, cpus, flags);
    return @bitCast(-@as(isize, @backingInt(E.NOSYS)));
}

pub fn sys_riscv_hwprobe(
    pairs: [*]riscv_hwprobe,
    pair_count: usize,
    cpusetsize: usize,
    cpus: ?[*]cpu_set_t,
    flags: u32,
) usize {
    if (VDSO != void) {
        const ptr = @atomicLoad(?VdsoSysRiscvHwprobe, &vdso_sys_riscv_hwprobe, .unordered);
        if (ptr) |f| {
            if (f(pairs, pair_count, cpusetsize, cpus, flags) == 0) return 0;
        }
    }
    return syscall5(.riscv_hwprobe, @intFromPtr(pairs), pair_count, cpusetsize, @intFromPtr(cpus), flags);
}

pub const E = switch (native_arch) {
    .mips, .mipsel, .mips64, .mips64el => enum(u16) {
        /// No error occurred.
        SUCCESS = 0,

        PERM = 1,
        NOENT = 2,
        SRCH = 3,
        INTR = 4,
        IO = 5,
        NXIO = 6,
        @"2BIG" = 7,
        NOEXEC = 8,
        BADF = 9,
        CHILD = 10,
        /// Also used for WOULDBLOCK.
        AGAIN = 11,
        NOMEM = 12,
        ACCES = 13,
        FAULT = 14,
        NOTBLK = 15,
        BUSY = 16,
        EXIST = 17,
        XDEV = 18,
        NODEV = 19,
        NOTDIR = 20,
        ISDIR = 21,
        INVAL = 22,
        NFILE = 23,
        MFILE = 24,
        NOTTY = 25,
        TXTBSY = 26,
        FBIG = 27,
        NOSPC = 28,
        SPIPE = 29,
        ROFS = 30,
        MLINK = 31,
        PIPE = 32,
        DOM = 33,
        RANGE = 34,

        NOMSG = 35,
        IDRM = 36,
        CHRNG = 37,
        L2NSYNC = 38,
        L3HLT = 39,
        L3RST = 40,
        LNRNG = 41,
        UNATCH = 42,
        NOCSI = 43,
        L2HLT = 44,
        DEADLK = 45,
        NOLCK = 46,
        BADE = 50,
        BADR = 51,
        XFULL = 52,
        NOANO = 53,
        BADRQC = 54,
        BADSLT = 55,
        DEADLOCK = 56,
        BFONT = 59,
        NOSTR = 60,
        NODATA = 61,
        TIME = 62,
        NOSR = 63,
        NONET = 64,
        NOPKG = 65,
        REMOTE = 66,
        NOLINK = 67,
        ADV = 68,
        SRMNT = 69,
        COMM = 70,
        PROTO = 71,
        DOTDOT = 73,
        MULTIHOP = 74,
        BADMSG = 77,
        NAMETOOLONG = 78,
        OVERFLOW = 79,
        NOTUNIQ = 80,
        BADFD = 81,
        REMCHG = 82,
        LIBACC = 83,
        LIBBAD = 84,
        LIBSCN = 85,
        LIBMAX = 86,
        LIBEXEC = 87,
        ILSEQ = 88,
        NOSYS = 89,
        LOOP = 90,
        RESTART = 91,
        STRPIPE = 92,
        NOTEMPTY = 93,
        USERS = 94,
        NOTSOCK = 95,
        DESTADDRREQ = 96,
        MSGSIZE = 97,
        PROTOTYPE = 98,
        NOPROTOOPT = 99,
        PROTONOSUPPORT = 120,
        SOCKTNOSUPPORT = 121,
        OPNOTSUPP = 122,
        PFNOSUPPORT = 123,
        AFNOSUPPORT = 124,
        ADDRINUSE = 125,
        ADDRNOTAVAIL = 126,
        NETDOWN = 127,
        NETUNREACH = 128,
        NETRESET = 129,
        CONNABORTED = 130,
        CONNRESET = 131,
        NOBUFS = 132,
        ISCONN = 133,
        NOTCONN = 134,
        UCLEAN = 135,
        NOTNAM = 137,
        NAVAIL = 138,
        ISNAM = 139,
        REMOTEIO = 140,
        SHUTDOWN = 143,
        TOOMANYREFS = 144,
        TIMEDOUT = 145,
        CONNREFUSED = 146,
        HOSTDOWN = 147,
        HOSTUNREACH = 148,
        ALREADY = 149,
        INPROGRESS = 150,
        STALE = 151,
        CANCELED = 158,
        NOMEDIUM = 159,
        MEDIUMTYPE = 160,
        NOKEY = 161,
        KEYEXPIRED = 162,
        KEYREVOKED = 163,
        KEYREJECTED = 164,
        OWNERDEAD = 165,
        NOTRECOVERABLE = 166,
        RFKILL = 167,
        HWPOISON = 168,
        DQUOT = 1133,
        _,
    },
    .sparc, .sparc64 => enum(u16) {
        /// No error occurred.
        SUCCESS = 0,

        PERM = 1,
        NOENT = 2,
        SRCH = 3,
        INTR = 4,
        IO = 5,
        NXIO = 6,
        @"2BIG" = 7,
        NOEXEC = 8,
        BADF = 9,
        CHILD = 10,
        /// Also used for WOULDBLOCK
        AGAIN = 11,
        NOMEM = 12,
        ACCES = 13,
        FAULT = 14,
        NOTBLK = 15,
        BUSY = 16,
        EXIST = 17,
        XDEV = 18,
        NODEV = 19,
        NOTDIR = 20,
        ISDIR = 21,
        INVAL = 22,
        NFILE = 23,
        MFILE = 24,
        NOTTY = 25,
        TXTBSY = 26,
        FBIG = 27,
        NOSPC = 28,
        SPIPE = 29,
        ROFS = 30,
        MLINK = 31,
        PIPE = 32,
        DOM = 33,
        RANGE = 34,

        INPROGRESS = 36,
        ALREADY = 37,
        NOTSOCK = 38,
        DESTADDRREQ = 39,
        MSGSIZE = 40,
        PROTOTYPE = 41,
        NOPROTOOPT = 42,
        PROTONOSUPPORT = 43,
        SOCKTNOSUPPORT = 44,
        /// Also used for NOTSUP
        OPNOTSUPP = 45,
        PFNOSUPPORT = 46,
        AFNOSUPPORT = 47,
        ADDRINUSE = 48,
        ADDRNOTAVAIL = 49,
        NETDOWN = 50,
        NETUNREACH = 51,
        NETRESET = 52,
        CONNABORTED = 53,
        CONNRESET = 54,
        NOBUFS = 55,
        ISCONN = 56,
        NOTCONN = 57,
        SHUTDOWN = 58,
        TOOMANYREFS = 59,
        TIMEDOUT = 60,
        CONNREFUSED = 61,
        LOOP = 62,
        NAMETOOLONG = 63,
        HOSTDOWN = 64,
        HOSTUNREACH = 65,
        NOTEMPTY = 66,
        PROCLIM = 67,
        USERS = 68,
        DQUOT = 69,
        STALE = 70,
        REMOTE = 71,
        NOSTR = 72,
        TIME = 73,
        NOSR = 74,
        NOMSG = 75,
        BADMSG = 76,
        IDRM = 77,
        DEADLK = 78,
        NOLCK = 79,
        NONET = 80,
        RREMOTE = 81,
        NOLINK = 82,
        ADV = 83,
        SRMNT = 84,
        COMM = 85,
        PROTO = 86,
        MULTIHOP = 87,
        DOTDOT = 88,
        REMCHG = 89,
        NOSYS = 90,
        STRPIPE = 91,
        OVERFLOW = 92,
        BADFD = 93,
        CHRNG = 94,
        L2NSYNC = 95,
        L3HLT = 96,
        L3RST = 97,
        LNRNG = 98,
        UNATCH = 99,
        NOCSI = 100,
        L2HLT = 101,
        BADE = 102,
        BADR = 103,
        XFULL = 104,
        NOANO = 105,
        BADRQC = 106,
        BADSLT = 107,
        DEADLOCK = 108,
        BFONT = 109,
        LIBEXEC = 110,
        NODATA = 111,
        LIBBAD = 112,
        NOPKG = 113,
        LIBACC = 114,
        NOTUNIQ = 115,
        RESTART = 116,
        UCLEAN = 117,
        NOTNAM = 118,
        NAVAIL = 119,
        ISNAM = 120,
        REMOTEIO = 121,
        ILSEQ = 122,
        LIBMAX = 123,
        LIBSCN = 124,
        NOMEDIUM = 125,
        MEDIUMTYPE = 126,
        CANCELED = 127,
        NOKEY = 128,
        KEYEXPIRED = 129,
        KEYREVOKED = 130,
        KEYREJECTED = 131,
        OWNERDEAD = 132,
        NOTRECOVERABLE = 133,
        RFKILL = 134,
        HWPOISON = 135,
        _,
    },
    .alpha => enum(u16) {
        /// No error occurred.
        SUCCESS = 0,

        /// Operation not permitted
        PERM = 1,
        /// No such file or directory
        NOENT = 2,
        /// No such process
        SRCH = 3,
        /// Interrupted system call
        INTR = 4,
        /// I/O error
        IO = 5,
        /// No such device or address
        NXIO = 6,
        /// Argument list too long
        @"2BIG" = 7,
        /// Exec format error
        NOEXEC = 8,
        /// Bad file number
        BADF = 9,
        /// No child processes
        CHILD = 10,
        /// Out of memory
        NOMEM = 12,
        /// Permission denied
        ACCES = 13,
        /// Bad address
        FAULT = 14,
        /// Block device required
        NOTBLK = 15,
        /// Device or resource busy
        BUSY = 16,
        /// File exists
        EXIST = 17,
        /// Cross-device link
        XDEV = 18,
        /// No such device
        NODEV = 19,
        /// Not a directory
        NOTDIR = 20,
        /// Is a directory
        ISDIR = 21,
        /// Invalid argument
        INVAL = 22,
        /// File table overflow
        NFILE = 23,
        /// Too many open files
        MFILE = 24,
        /// Not a typewriter
        NOTTY = 25,
        /// Text file busy
        TXTBSY = 26,
        /// File too large
        FBIG = 27,
        /// No space left on device
        NOSPC = 28,
        /// Illegal seek
        SPIPE = 29,
        /// Read-only file system
        ROFS = 30,
        /// Too many links
        MLINK = 31,
        /// Broken pipe
        PIPE = 32,
        /// Math argument out of domain of func
        DOM = 33,
        /// Math result not representable
        RANGE = 34,

        /// Resource deadlock would occur
        DEADLK = 11,

        /// Try again.
        /// Also used for WOULDBLOCK.
        AGAIN = 35,
        /// Operation now in progress
        INPROGRESS = 36,
        /// Operation already in progress
        ALREADY = 37,
        /// Socket operation on non-socket
        NOTSOCK = 38,
        /// Destination address required
        DESTADDRREQ = 39,
        /// Message too long
        MSGSIZE = 40,
        /// Protocol wrong type for socket
        PROTOTYPE = 41,
        /// Protocol not available
        NOPROTOOPT = 42,
        /// Protocol not supported
        PROTONOSUPPORT = 43,
        /// Socket type not supported
        SOCKTNOSUPPORT = 44,
        /// Operation not supported on transport endpoint
        OPNOTSUPP = 45,
        /// Protocol family not supported
        PFNOSUPPORT = 46,
        /// Address family not supported by protocol
        AFNOSUPPORT = 47,
        /// Address already in use
        ADDRINUSE = 48,
        /// Cannot assign requested address
        ADDRNOTAVAIL = 49,
        /// Network is down
        NETDOWN = 50,
        /// Network is unreachable
        NETUNREACH = 51,
        /// Network dropped connection because of reset
        NETRESET = 52,
        /// Software caused connection abort
        CONNABORTED = 53,
        /// Connection reset by peer
        CONNRESET = 54,
        /// No buffer space available
        NOBUFS = 55,
        /// Transport endpoint is already connected
        ISCONN = 56,
        /// Transport endpoint is not connected
        NOTCONN = 57,
        /// Cannot send after transport endpoint shutdown
        SHUTDOWN = 58,
        /// Too many references: cannot splice
        TOOMANYREFS = 59,
        /// Connection timed out
        TIMEDOUT = 60,
        /// Connection refused
        CONNREFUSED = 61,
        /// Too many symbolic links encountered
        LOOP = 62,
        /// File name too long
        NAMETOOLONG = 63,
        /// Host is down
        HOSTDOWN = 64,
        /// No route to host
        HOSTUNREACH = 65,
        /// Directory not empty
        NOTEMPTY = 66,

        /// Too many users
        USERS = 68,
        /// Quota exceeded
        DQUOT = 69,
        /// Stale file handle
        STALE = 70,
        /// Object is remote
        REMOTE = 71,

        /// No record locks available
        NOLCK = 77,
        /// Function not implemented
        NOSYS = 78,

        /// No message of desired type
        NOMSG = 80,
        /// Identifier removed
        IDRM = 81,
        /// Out of streams resources
        NOSR = 82,
        /// Timer expired
        TIME = 83,
        /// Not a data message
        /// Also used for FSBADCRC.
        BADMSG = 84,
        /// Protocol error
        PROTO = 85,
        /// No data available
        NODATA = 86,
        /// Device not a stream
        NOSTR = 87,

        /// Package not installed
        NOPKG = 92,

        /// Illegal byte sequence
        ILSEQ = 116,

        // The following are designated "random noise" by the kernel sources.
        /// Channel number out of range
        CHRNG = 88,
        /// Level 2 not synchronized
        L2NSYNC = 89,
        /// Level 3 halted
        L3HLT = 90,
        /// Level 3 reset
        L3RST = 91,

        /// Link number out of range
        LNRNG = 93,
        /// Protocol driver not attached
        UNATCH = 94,
        /// No CSI structure available
        NOCSI = 95,
        /// Level 2 halted
        L2HLT = 96,
        /// Invalid exchange
        BADE = 97,
        /// Invalid request descriptor
        BADR = 98,
        /// Exchange full
        XFULL = 99,
        /// No anode
        NOANO = 100,
        /// Invalid request code
        BADRQC = 101,
        /// Invalid slot
        BADSLT = 102,

        /// Bad font file format
        BFONT = 104,
        /// Machine is not on the network
        NONET = 105,
        /// Link has been severed
        NOLINK = 106,
        /// Advertise error
        ADV = 107,
        /// Srmount error
        SRMNT = 108,
        /// Communication error on send
        COMM = 109,
        /// Multihop attempted
        MULTIHOP = 110,
        /// RFS specific error
        DOTDOT = 111,
        /// Value too large for defined data type
        OVERFLOW = 112,
        /// Name not unique on network
        NOTUNIQ = 113,
        /// File descriptor in bad state
        BADFD = 114,
        /// Remote address changed
        REMCHG = 115,

        /// Structure needs cleaning
        /// Also used for FSCORRUPTED.
        UCLEAN = 117,
        /// Not a XENIX named type file
        NOTNAM = 118,
        /// No XENIX semaphores available
        NAVAIL = 119,
        /// Is a named type file
        ISNAM = 120,
        /// Remote I/O error
        REMOTEIO = 121,

        /// Can not access a needed shared library
        LIBACC = 122,
        /// Accessing a corrupted shared library
        LIBBAD = 123,
        /// .lib section in a.out corrupted
        LIBSCN = 124,
        /// Attempting to link in too many shared libraries
        LIBMAX = 125,
        /// Cannot exec a shared library directly
        LIBEXEC = 126,
        /// Interrupted system call should be restarted
        RESTART = 127,
        /// Streams pipe error
        STRPIPE = 128,

        /// No medium found
        NOMEDIUM = 129,
        /// Wrong medium type
        MEDIUMTYPE = 130,
        /// Operation Cancelled
        CANCELED = 131,
        /// Required key not available
        NOKEY = 132,
        /// Key has expired
        KEYEXPIRED = 133,
        /// Key has been revoked
        KEYREVOKED = 134,
        /// Key was rejected by service
        KEYREJECTED = 135,

        // For robust mutexes
        /// Owner died
        OWNERDEAD = 136,
        /// State not recoverable
        NOTRECOVERABLE = 137,

        /// Operation not possible due to RF-kill
        RFKILL = 138,
        /// Memory page has hardware error
        HWPOISON = 139,
        _,
    },
    else => enum(u16) {
        /// No error occurred.
        /// Same code used for `NSROK`.
        SUCCESS = 0,
        /// Operation not permitted
        PERM = 1,
        /// No such file or directory
        NOENT = 2,
        /// No such process
        SRCH = 3,
        /// Interrupted system call
        INTR = 4,
        /// I/O error
        IO = 5,
        /// No such device or address
        NXIO = 6,
        /// Arg list too long
        @"2BIG" = 7,
        /// Exec format error
        NOEXEC = 8,
        /// Bad file number
        BADF = 9,
        /// No child processes
        CHILD = 10,
        /// Try again
        /// Also means: WOULDBLOCK: operation would block
        AGAIN = 11,
        /// Out of memory
        NOMEM = 12,
        /// Permission denied
        ACCES = 13,
        /// Bad address
        FAULT = 14,
        /// Block device required
        NOTBLK = 15,
        /// Device or resource busy
        BUSY = 16,
        /// File exists
        EXIST = 17,
        /// Cross-device link
        XDEV = 18,
        /// No such device
        NODEV = 19,
        /// Not a directory
        NOTDIR = 20,
        /// Is a directory
        ISDIR = 21,
        /// Invalid argument
        INVAL = 22,
        /// File table overflow
        NFILE = 23,
        /// Too many open files
        MFILE = 24,
        /// Not a typewriter
        NOTTY = 25,
        /// Text file busy
        TXTBSY = 26,
        /// File too large
        FBIG = 27,
        /// No space left on device
        NOSPC = 28,
        /// Illegal seek
        SPIPE = 29,
        /// Read-only file system
        ROFS = 30,
        /// Too many links
        MLINK = 31,
        /// Broken pipe
        PIPE = 32,
        /// Math argument out of domain of func
        DOM = 33,
        /// Math result not representable
        RANGE = 34,
        /// Resource deadlock would occur
        DEADLK = 35,
        /// File name too long
        NAMETOOLONG = 36,
        /// No record locks available
        NOLCK = 37,
        /// Function not implemented
        NOSYS = 38,
        /// Directory not empty
        NOTEMPTY = 39,
        /// Too many symbolic links encountered
        LOOP = 40,
        /// No message of desired type
        NOMSG = 42,
        /// Identifier removed
        IDRM = 43,
        /// Channel number out of range
        CHRNG = 44,
        /// Level 2 not synchronized
        L2NSYNC = 45,
        /// Level 3 halted
        L3HLT = 46,
        /// Level 3 reset
        L3RST = 47,
        /// Link number out of range
        LNRNG = 48,
        /// Protocol driver not attached
        UNATCH = 49,
        /// No CSI structure available
        NOCSI = 50,
        /// Level 2 halted
        L2HLT = 51,
        /// Invalid exchange
        BADE = 52,
        /// Invalid request descriptor
        BADR = 53,
        /// Exchange full
        XFULL = 54,
        /// No anode
        NOANO = 55,
        /// Invalid request code
        BADRQC = 56,
        /// Invalid slot
        BADSLT = 57,
        /// Bad font file format
        BFONT = 59,
        /// Device not a stream
        NOSTR = 60,
        /// No data available
        NODATA = 61,
        /// Timer expired
        TIME = 62,
        /// Out of streams resources
        NOSR = 63,
        /// Machine is not on the network
        NONET = 64,
        /// Package not installed
        NOPKG = 65,
        /// Object is remote
        REMOTE = 66,
        /// Link has been severed
        NOLINK = 67,
        /// Advertise error
        ADV = 68,
        /// Srmount error
        SRMNT = 69,
        /// Communication error on send
        COMM = 70,
        /// Protocol error
        PROTO = 71,
        /// Multihop attempted
        MULTIHOP = 72,
        /// RFS specific error
        DOTDOT = 73,
        /// Not a data message
        BADMSG = 74,
        /// Value too large for defined data type
        OVERFLOW = 75,
        /// Name not unique on network
        NOTUNIQ = 76,
        /// File descriptor in bad state
        BADFD = 77,
        /// Remote address changed
        REMCHG = 78,
        /// Can not access a needed shared library
        LIBACC = 79,
        /// Accessing a corrupted shared library
        LIBBAD = 80,
        /// .lib section in a.out corrupted
        LIBSCN = 81,
        /// Attempting to link in too many shared libraries
        LIBMAX = 82,
        /// Cannot exec a shared library directly
        LIBEXEC = 83,
        /// Illegal byte sequence
        ILSEQ = 84,
        /// Interrupted system call should be restarted
        RESTART = 85,
        /// Streams pipe error
        STRPIPE = 86,
        /// Too many users
        USERS = 87,
        /// Socket operation on non-socket
        NOTSOCK = 88,
        /// Destination address required
        DESTADDRREQ = 89,
        /// Message too long
        MSGSIZE = 90,
        /// Protocol wrong type for socket
        PROTOTYPE = 91,
        /// Protocol not available
        NOPROTOOPT = 92,
        /// Protocol not supported
        PROTONOSUPPORT = 93,
        /// Socket type not supported
        SOCKTNOSUPPORT = 94,
        /// Operation not supported on transport endpoint
        /// This code also means `NOTSUP`.
        OPNOTSUPP = 95,
        /// Protocol family not supported
        PFNOSUPPORT = 96,
        /// Address family not supported by protocol
        AFNOSUPPORT = 97,
        /// Address already in use
        ADDRINUSE = 98,
        /// Cannot assign requested address
        ADDRNOTAVAIL = 99,
        /// Network is down
        NETDOWN = 100,
        /// Network is unreachable
        NETUNREACH = 101,
        /// Network dropped connection because of reset
        NETRESET = 102,
        /// Software caused connection abort
        CONNABORTED = 103,
        /// Connection reset by peer
        CONNRESET = 104,
        /// No buffer space available
        NOBUFS = 105,
        /// Transport endpoint is already connected
        ISCONN = 106,
        /// Transport endpoint is not connected
        NOTCONN = 107,
        /// Cannot send after transport endpoint shutdown
        SHUTDOWN = 108,
        /// Too many references: cannot splice
        TOOMANYREFS = 109,
        /// Connection timed out
        TIMEDOUT = 110,
        /// Connection refused
        CONNREFUSED = 111,
        /// Host is down
        HOSTDOWN = 112,
        /// No route to host
        HOSTUNREACH = 113,
        /// Operation already in progress
        ALREADY = 114,
        /// Operation now in progress
        INPROGRESS = 115,
        /// Stale NFS file handle
        STALE = 116,
        /// Structure needs cleaning
        UCLEAN = 117,
        /// Not a XENIX named type file
        NOTNAM = 118,
        /// No XENIX semaphores available
        NAVAIL = 119,
        /// Is a named type file
        ISNAM = 120,
        /// Remote I/O error
        REMOTEIO = 121,
        /// Quota exceeded
        DQUOT = 122,
        /// No medium found
        NOMEDIUM = 123,
        /// Wrong medium type
        MEDIUMTYPE = 124,
        /// Operation canceled
        CANCELED = 125,
        /// Required key not available
        NOKEY = 126,
        /// Key has expired
        KEYEXPIRED = 127,
        /// Key has been revoked
        KEYREVOKED = 128,
        /// Key was rejected by service
        KEYREJECTED = 129,
        // for robust mutexes
        /// Owner died
        OWNERDEAD = 130,
        /// State not recoverable
        NOTRECOVERABLE = 131,
        /// Operation not possible due to RF-kill
        RFKILL = 132,
        /// Memory page has hardware error
        HWPOISON = 133,
        // nameserver query return codes
        /// DNS server returned answer with no data
        NSRNODATA = 160,
        /// DNS server claims query was misformatted
        NSRFORMERR = 161,
        /// DNS server returned general failure
        NSRSERVFAIL = 162,
        /// Domain name not found
        NSRNOTFOUND = 163,
        /// DNS server does not implement requested operation
        NSRNOTIMP = 164,
        /// DNS server refused query
        NSRREFUSED = 165,
        /// Misformatted DNS query
        NSRBADQUERY = 166,
        /// Misformatted domain name
        NSRBADNAME = 167,
        /// Unsupported address family
        NSRBADFAMILY = 168,
        /// Misformatted DNS reply
        NSRBADRESP = 169,
        /// Could not contact DNS servers
        NSRCONNREFUSED = 170,
        /// Timeout while contacting DNS servers
        NSRTIMEOUT = 171,
        /// End of file
        NSROF = 172,
        /// Error reading file
        NSRFILE = 173,
        /// Out of memory
        NSRNOMEM = 174,
        /// Application terminated lookup
        NSRDESTRUCTION = 175,
        /// Domain name is too long
        NSRQUERYDOMAINTOOLONG = 176,
        /// Domain name is too long
        NSRCNAMELOOP = 177,

        _,
    },
};

pub const NAME_MAX = 255;
pub const PATH_MAX = 4096;
pub const IOV_MAX = 1024;

/// Largest hardware address length
/// e.g. a mac address is a type of hardware address
pub const MAX_ADDR_LEN = 32;

pub const STDIN_FILENO = 0;
pub const STDOUT_FILENO = 1;
pub const STDERR_FILENO = 2;

pub const AT = struct {
    /// Special value used to indicate openat should use the current working directory
    pub const FDCWD = -100;

    /// Do not follow symbolic links
    pub const SYMLINK_NOFOLLOW = 0x100;

    /// Remove directory instead of unlinking file
    pub const REMOVEDIR = 0x200;

    /// Follow symbolic links.
    pub const SYMLINK_FOLLOW = 0x400;

    /// Suppress terminal automount traversal
    pub const NO_AUTOMOUNT = 0x800;

    /// Allow empty relative pathname
    pub const EMPTY_PATH = 0x1000;

    /// Type of synchronisation required from statx()
    pub const STATX_SYNC_TYPE = 0x6000;

    /// - Do whatever stat() does
    pub const STATX_SYNC_AS_STAT = 0x0000;

    /// - Force the attributes to be sync'd with the server
    pub const STATX_FORCE_SYNC = 0x2000;

    /// - Don't sync attributes with the server
    pub const STATX_DONT_SYNC = 0x4000;

    /// Apply to the entire subtree
    pub const RECURSIVE = 0x8000;

    pub const HANDLE_FID = REMOVEDIR;
};

pub const FALLOC = struct {
    /// Default is extend size
    pub const FL_KEEP_SIZE = 0x01;

    /// De-allocates range
    pub const FL_PUNCH_HOLE = 0x02;

    /// Reserved codepoint
    pub const FL_NO_HIDE_STALE = 0x04;

    /// Removes a range of a file without leaving a hole in the file
    pub const FL_COLLAPSE_RANGE = 0x08;

    /// Converts a range of file to zeros preferably without issuing data IO
    pub const FL_ZERO_RANGE = 0x10;

    /// Inserts space within the file size without overwriting any existing data
    pub const FL_INSERT_RANGE = 0x20;

    /// Unshares shared blocks within the file size without overwriting any existing data
    pub const FL_UNSHARE_RANGE = 0x40;
};

// Futex v1 API commands.  See futex man page for each command's
// interpretation of the futex arguments.
pub const FUTEX_COMMAND = enum(u7) {
    WAIT = 0,
    WAKE = 1,
    FD = 2,
    REQUEUE = 3,
    CMP_REQUEUE = 4,
    WAKE_OP = 5,
    LOCK_PI = 6,
    UNLOCK_PI = 7,
    TRYLOCK_PI = 8,
    WAIT_BITSET = 9,
    WAKE_BITSET = 10,
    WAIT_REQUEUE_PI = 11,
    CMP_REQUEUE_PI = 12,
};

/// Futex v1 API command and flags for the `futex_op` parameter
pub const FUTEX_OP = packed struct(u32) {
    cmd: FUTEX_COMMAND,
    private: bool,
    realtime: bool = false, // realtime clock vs. monotonic clock
    _reserved: u23 = 0,
};

/// Futex v1 FUTEX_WAKE_OP `val3` operation:
pub const FUTEX_WAKE_OP = packed struct(u32) {
    cmd: FUTEX_WAKE_OP_CMD,
    /// From C API `FUTEX_OP_ARG_SHIFT`:  Use (1 << oparg) as operand
    arg_shift: bool = false,
    cmp: FUTEX_WAKE_OP_CMP,
    oparg: u12,
    cmdarg: u12,
};

/// Futex v1 cmd for FUTEX_WAKE_OP `val3` command.
pub const FUTEX_WAKE_OP_CMD = enum(u3) {
    /// uaddr2 = oparg
    SET = 0,
    /// uaddr2 += oparg
    ADD = 1,
    /// uaddr2 |= oparg
    OR = 2,
    /// uaddr2 &= ~oparg
    ANDN = 3,
    /// uaddr2 ^= oparg
    XOR = 4,
};

/// Futex v1 comparison op for FUTEX_WAKE_OP `val3` cmp
pub const FUTEX_WAKE_OP_CMP = enum(u4) {
    EQ = 0,
    NE = 1,
    LT = 2,
    LE = 3,
    GT = 4,
    GE = 5,
};

/// Max numbers of elements in a `futex2_waitone` array.
pub const FUTEX2_WAITONE_MAX = 128;

/// For futex v2 API, the size of the futex at the uaddr.  v1 futex are
/// always implicitly U32.  As of kernel v6.14, only U32 is implemented
/// for v2 futexes.
pub const FUTEX2_SIZE = enum(u2) {
    U8 = 0,
    U16 = 1,
    U32 = 2,
    U64 = 3,
};

/// As of kernel 6.14 there are no defined flags to futex2_waitv.
pub const FUTEX2_FLAGS_WAITV = packed struct(u32) {
    _reserved: u32 = 0,
};

/// As of kernel 6.14 there are no defined flags to futex2_requeue.
pub const FUTEX2_FLAGS_REQUEUE = packed struct(u32) {
    _reserved: u32 = 0,
};

/// Flags for futex v2 APIs (futex2_wait, futex2_wake, futex2_requeue, but
/// not the futex2_waitv syscall, but also used in the futex2_waitone struct).
pub const FUTEX2_FLAGS = packed struct(u32) {
    size: FUTEX2_SIZE,
    numa: bool = false,
    _reserved: u4 = 0,
    private: bool,
    _undefined: u24 = 0,
};

pub const PROT = switch (native_arch) {
    .mips, .mipsel, .mips64, .mips64el, .xtensa, .xtensaeb => packed struct(u32) {
        READ: bool = false,
        WRITE: bool = false,
        EXEC: bool = false,
        _: u1 = 0,
        /// Page may be used for atomic ops.
        SEM: bool = false,
        __: u19 = 0,
        GROWSDOWN: bool = false,
        GROWSUP: bool = false,
        ___: u6 = 0,
    },
    else => packed struct(u32) {
        READ: bool = false,
        WRITE: bool = false,
        EXEC: bool = false,
        /// Page may be used for atomic ops.
        SEM: bool = false,
        __: u20 = 0,
        GROWSDOWN: bool = false,
        GROWSUP: bool = false,
        ___: u6 = 0,
    },
};

pub const FD_CLOEXEC = 1;

pub const F_OK = 0;
pub const X_OK = 1;
pub const W_OK = 2;
pub const R_OK = 4;

pub const W = struct {
    pub const NOHANG = 1;
    pub const UNTRACED = 2;
    pub const STOPPED = 2;
    pub const EXITED = 4;
    pub const CONTINUED = 8;
    pub const NOWAIT = 0x1000000;

    pub fn EXITSTATUS(s: u32) u8 {
        return @as(u8, @intCast((s & 0xff00) >> 8));
    }
    pub fn TERMSIG(s: u32) SIG {
        return @fromBackingInt(@intCast(s & 0x7f));
    }
    pub fn STOPSIG(s: u32) SIG {
        return @fromBackingInt(@intCast(EXITSTATUS(s)));
    }
    pub fn IFEXITED(s: u32) bool {
        return (s & 0x7f) == 0;
    }
    pub fn IFSTOPPED(s: u32) bool {
        return @as(u16, @truncate(((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
    }
    pub fn IFSIGNALED(s: u32) bool {
        return (s & 0xffff) -% 1 < 0xff;
    }
};

// waitid id types
pub const P = enum(c_uint) {
    ALL = 0,
    PID = 1,
    PGID = 2,
    PIDFD = 3,
    _,
};

pub const SA = if (is_mips) struct {
    pub const NOCLDSTOP = 1;
    pub const NOCLDWAIT = 0x10000;
    pub const SIGINFO = 8;
    pub const RESTART = 0x10000000;
    pub const RESETHAND = 0x80000000;
    pub const ONSTACK = 0x08000000;
    pub const NODEFER = 0x40000000;
} else if (is_sparc) struct {
    pub const NOCLDSTOP = 0x8;
    pub const NOCLDWAIT = 0x100;
    pub const SIGINFO = 0x200;
    pub const RESTART = 0x2;
    pub const RESETHAND = 0x4;
    pub const ONSTACK = 0x1;
    pub const NODEFER = 0x20;
    pub const RESTORER = 0x04000000;
} else if (native_arch == .hexagon or is_loongarch or native_arch == .or1k or is_riscv) struct {
    pub const NOCLDSTOP = 1;
    pub const NOCLDWAIT = 2;
    pub const SIGINFO = 4;
    pub const RESTART = 0x10000000;
    pub const RESETHAND = 0x80000000;
    pub const ONSTACK = 0x08000000;
    pub const NODEFER = 0x40000000;
} else if (native_arch == .alpha) struct {
    pub const ONSTACK = 0x00000001;
    pub const RESTART = 0x00000002;
    pub const NOCLDSTOP = 0x00000004;
    pub const NODEFER = 0x00000008;
    pub const RESETHAND = 0x00000010;
    pub const NOCLDWAIT = 0x00000020;
    pub const SIGINFO = 0x00000040;
} else struct {
    pub const NOCLDSTOP = 1;
    pub const NOCLDWAIT = 2;
    pub const SIGINFO = 4;
    pub const RESTART = 0x10000000;
    pub const RESETHAND = 0x80000000;
    pub const ONSTACK = 0x08000000;
    pub const NODEFER = 0x40000000;
    pub const RESTORER = 0x04000000;
};

pub const SIG = if (is_mips) enum(u32) {
    pub const BLOCK = 1;
    pub const UNBLOCK = 2;
    pub const SETMASK = 3;

    pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
    pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
    pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);

    pub const IOT: SIG = .ABRT;
    pub const POLL: SIG = .IO;

    // /arch/mips/include/uapi/asm/signal.h#L25
    HUP = 1,
    INT = 2,
    QUIT = 3,
    ILL = 4,
    TRAP = 5,
    ABRT = 6,
    EMT = 7,
    FPE = 8,
    KILL = 9,
    BUS = 10,
    SEGV = 11,
    SYS = 12,
    PIPE = 13,
    ALRM = 14,
    TERM = 15,
    USR1 = 16,
    USR2 = 17,
    CHLD = 18,
    PWR = 19,
    WINCH = 20,
    URG = 21,
    IO = 22,
    STOP = 23,
    TSTP = 24,
    CONT = 25,
    TTIN = 26,
    TTOU = 27,
    VTALRM = 28,
    PROF = 29,
    XCPU = 30,
    XFZ = 31,
    _,
} else if (is_sparc) enum(u32) {
    pub const BLOCK = 1;
    pub const UNBLOCK = 2;
    pub const SETMASK = 4;

    pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
    pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
    pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);

    pub const IOT: SIG = .ABRT;
    pub const CLD: SIG = .CHLD;
    pub const PWR: SIG = .LOST;
    pub const POLL: SIG = .IO;

    HUP = 1,
    INT = 2,
    QUIT = 3,
    ILL = 4,
    TRAP = 5,
    ABRT = 6,
    EMT = 7,
    FPE = 8,
    KILL = 9,
    BUS = 10,
    SEGV = 11,
    SYS = 12,
    PIPE = 13,
    ALRM = 14,
    TERM = 15,
    URG = 16,
    STOP = 17,
    TSTP = 18,
    CONT = 19,
    CHLD = 20,
    TTIN = 21,
    TTOU = 22,
    IO = 23,
    XCPU = 24,
    XFSZ = 25,
    VTALRM = 26,
    PROF = 27,
    WINCH = 28,
    LOST = 29,
    USR1 = 30,
    USR2 = 31,
    _,
} else if (native_arch == .alpha) enum(u32) {
    pub const BLOCK = 1;
    pub const UNBLOCK = 2;
    pub const SETMASK = 3;

    pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
    pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
    pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);

    pub const POLL: SIG = .IO;
    pub const PWR: SIG = .INFO;
    pub const IOT: SIG = .ABRT;

    HUP = 1,
    INT = 2,
    QUIT = 3,
    ILL = 4,
    TRAP = 5,
    ABRT = 6,
    EMT = 7,
    FPE = 8,
    KILL = 9,
    BUS = 10,
    SEGV = 11,
    SYS = 12,
    PIPE = 13,
    ALRM = 14,
    TERM = 15,
    URG = 16,
    STOP = 17,
    TSTP = 18,
    CONT = 19,
    CHLD = 20,
    TTIN = 21,
    TTOU = 22,
    IO = 23,
    XCPU = 24,
    XFSZ = 25,
    VTALRM = 26,
    PROF = 27,
    WINCH = 28,
    INFO = 29,
    USR1 = 30,
    USR2 = 31,
    _,
} else if (is_hppa) enum(u32) {
    pub const BLOCK = 0;
    pub const UNBLOCK = 1;
    pub const SETMASK = 2;

    pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
    pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
    pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);

    pub const POLL: SIG = .IO;
    pub const IOT: SIG = .ABRT;

    HUP = 1,
    INT = 2,
    QUIT = 3,
    ILL = 4,
    TRAP = 5,
    ABRT = 6,
    STKFLT = 7,
    FPE = 8,
    KILL = 9,
    BUS = 10,
    SEGV = 11,
    XCPU = 12,
    PIPE = 13,
    ALRM = 14,
    TERM = 15,
    USR1 = 16,
    USR2 = 17,
    CHLD = 18,
    PWR = 19,
    VTALRM = 20,
    PROF = 21,
    IO = 22,
    WINCH = 23,
    STOP = 24,
    TSTP = 25,
    CONT = 26,
    TTIN = 27,
    TTOU = 28,
    URG = 29,
    XFSZ = 30,
    SYS = 31,
    _,
} else enum(u32) {
    pub const BLOCK = 0;
    pub const UNBLOCK = 1;
    pub const SETMASK = 2;

    pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
    pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
    pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);

    pub const POLL: SIG = .IO;
    pub const IOT: SIG = .ABRT;

    HUP = 1,
    INT = 2,
    QUIT = 3,
    ILL = 4,
    TRAP = 5,
    ABRT = 6,
    BUS = 7,
    FPE = 8,
    KILL = 9,
    USR1 = 10,
    SEGV = 11,
    USR2 = 12,
    PIPE = 13,
    ALRM = 14,
    TERM = 15,
    STKFLT = 16,
    CHLD = 17,
    CONT = 18,
    STOP = 19,
    TSTP = 20,
    TTIN = 21,
    TTOU = 22,
    URG = 23,
    XCPU = 24,
    XFSZ = 25,
    VTALRM = 26,
    PROF = 27,
    WINCH = 28,
    IO = 29,
    PWR = 30,
    SYS = 31,
    _,
};

pub const kernel_rwf = u32;

pub const RWF = struct {
    pub const HIPRI: kernel_rwf = 0x00000001;
    pub const DSYNC: kernel_rwf = 0x00000002;
    pub const SYNC: kernel_rwf = 0x00000004;
    pub const NOWAIT: kernel_rwf = 0x00000008;
    pub const APPEND: kernel_rwf = 0x00000010;
};

pub const SEEK = struct {
    pub const SET = 0;
    pub const CUR = 1;
    pub const END = 2;
};

pub const SHUT = struct {
    pub const RD = 0;
    pub const WR = 1;
    pub const RDWR = 2;
};

pub const SOCK = struct {
    pub const STREAM = if (is_mips) 2 else 1;
    pub const DGRAM = if (is_mips) 1 else 2;
    pub const RAW = 3;
    pub const RDM = 4;
    pub const SEQPACKET = 5;
    pub const DCCP = 6;
    pub const PACKET = 10;
    pub const CLOEXEC = if (is_sparc)
        0o20000000
    else if (native_arch == .alpha)
        0o10000000
    else
        0o2000000;
    pub const NONBLOCK = if (is_mips)
        0o200
    else if (is_sparc)
        0o40000
    else if (is_hppa or native_arch == .alpha)
        0x40000000
    else
        0o4000;
};

pub const TCP = struct {
    /// Turn off Nagle's algorithm
    pub const NODELAY = 1;
    /// Limit MSS
    pub const MAXSEG = 2;
    /// Never send partially complete segments.
    pub const CORK = 3;
    /// Start keeplives after this period, in seconds
    pub const KEEPIDLE = 4;
    /// Interval between keepalives
    pub const KEEPINTVL = 5;
    /// Number of keepalives before death
    pub const KEEPCNT = 6;
    /// Number of SYN retransmits
    pub const SYNCNT = 7;
    /// Life time of orphaned FIN-WAIT-2 state
    pub const LINGER2 = 8;
    /// Wake up listener only when data arrive
    pub const DEFER_ACCEPT = 9;
    /// Bound advertised window
    pub const WINDOW_CLAMP = 10;
    /// Information about this connection.
    pub const INFO = 11;
    /// Block/reenable quick acks
    pub const QUICKACK = 12;
    /// Congestion control algorithm
    pub const CONGESTION = 13;
    /// TCP MD5 Signature (RFC2385)
    pub const MD5SIG = 14;
    /// Use linear timeouts for thin streams
    pub const THIN_LINEAR_TIMEOUTS = 16;
    /// Fast retrans. after 1 dupack
    pub const THIN_DUPACK = 17;
    /// How long for loss retry before timeout
    pub const USER_TIMEOUT = 18;
    /// TCP sock is under repair right now
    pub const REPAIR = 19;
    pub const REPAIR_QUEUE = 20;
    pub const QUEUE_SEQ = 21;
    pub const REPAIR_OPTIONS = 22;
    /// Enable FastOpen on listeners
    pub const FASTOPEN = 23;
    pub const TIMESTAMP = 24;
    /// limit number of unsent bytes in write queue
    pub const NOTSENT_LOWAT = 25;
    /// Get Congestion Control (optional) info
    pub const CC_INFO = 26;
    /// Record SYN headers for new connections
    pub const SAVE_SYN = 27;
    /// Get SYN headers recorded for connection
    pub const SAVED_SYN = 28;
    /// Get/set window parameters
    pub const REPAIR_WINDOW = 29;
    /// Attempt FastOpen with connect
    pub const FASTOPEN_CONNECT = 30;
    /// Attach a ULP to a TCP connection
    pub const ULP = 31;
    /// TCP MD5 Signature with extensions
    pub const MD5SIG_EXT = 32;
    /// Set the key for Fast Open (cookie)
    pub const FASTOPEN_KEY = 33;
    /// Enable TFO without a TFO cookie
    pub const FASTOPEN_NO_COOKIE = 34;
    pub const ZEROCOPY_RECEIVE = 35;
    /// Notify bytes available to read as a cmsg on read
    pub const INQ = 36;
    pub const CM_INQ = INQ;
    /// delay outgoing packets by XX usec
    pub const TX_DELAY = 37;

    pub const REPAIR_ON = 1;
    pub const REPAIR_OFF = 0;
    /// Turn off without window probes
    pub const REPAIR_OFF_NO_WP = -1;
};

pub const UDP = struct {
    /// Never send partially complete segments
    pub const CORK = 1;
    /// Set the socket to accept encapsulated packets
    pub const ENCAP = 100;
    /// Disable sending checksum for UDP6X
    pub const NO_CHECK6_TX = 101;
    /// Disable accepting checksum for UDP6
    pub const NO_CHECK6_RX = 102;
    /// Set GSO segmentation size
    pub const SEGMENT = 103;
    /// This socket can receive UDP GRO packets
    pub const GRO = 104;
};

pub const UDP_ENCAP = struct {
    pub const ESPINUDP_NON_IKE = 1;
    pub const ESPINUDP = 2;
    pub const L2TPINUDP = 3;
    pub const GTP0 = 4;
    pub const GTP1U = 5;
    pub const RXRPC = 6;
};

pub const PF = struct {
    pub const UNSPEC = 0;
    pub const LOCAL = 1;
    pub const UNIX = LOCAL;
    pub const FILE = LOCAL;
    pub const INET = 2;
    pub const AX25 = 3;
    pub const IPX = 4;
    pub const APPLETALK = 5;
    pub const NETROM = 6;
    pub const BRIDGE = 7;
    pub const ATMPVC = 8;
    pub const X25 = 9;
    pub const INET6 = 10;
    pub const ROSE = 11;
    pub const DECnet = 12;
    pub const NETBEUI = 13;
    pub const SECURITY = 14;
    pub const KEY = 15;
    pub const NETLINK = 16;
    pub const ROUTE = PF.NETLINK;
    pub const PACKET = 17;
    pub const ASH = 18;
    pub const ECONET = 19;
    pub const ATMSVC = 20;
    pub const RDS = 21;
    pub const SNA = 22;
    pub const IRDA = 23;
    pub const PPPOX = 24;
    pub const WANPIPE = 25;
    pub const LLC = 26;
    pub const IB = 27;
    pub const MPLS = 28;
    pub const CAN = 29;
    pub const TIPC = 30;
    pub const BLUETOOTH = 31;
    pub const IUCV = 32;
    pub const RXRPC = 33;
    pub const ISDN = 34;
    pub const PHONET = 35;
    pub const IEEE802154 = 36;
    pub const CAIF = 37;
    pub const ALG = 38;
    pub const NFC = 39;
    pub const VSOCK = 40;
    pub const KCM = 41;
    pub const QIPCRTR = 42;
    pub const SMC = 43;
    pub const XDP = 44;
    pub const MAX = 45;
};

pub const AF = struct {
    pub const UNSPEC = PF.UNSPEC;
    pub const LOCAL = PF.LOCAL;
    pub const UNIX = AF.LOCAL;
    pub const FILE = AF.LOCAL;
    pub const INET = PF.INET;
    pub const AX25 = PF.AX25;
    pub const IPX = PF.IPX;
    pub const APPLETALK = PF.APPLETALK;
    pub const NETROM = PF.NETROM;
    pub const BRIDGE = PF.BRIDGE;
    pub const ATMPVC = PF.ATMPVC;
    pub const X25 = PF.X25;
    pub const INET6 = PF.INET6;
    pub const ROSE = PF.ROSE;
    pub const DECnet = PF.DECnet;
    pub const NETBEUI = PF.NETBEUI;
    pub const SECURITY = PF.SECURITY;
    pub const KEY = PF.KEY;
    pub const NETLINK = PF.NETLINK;
    pub const ROUTE = PF.ROUTE;
    pub const PACKET = PF.PACKET;
    pub const ASH = PF.ASH;
    pub const ECONET = PF.ECONET;
    pub const ATMSVC = PF.ATMSVC;
    pub const RDS = PF.RDS;
    pub const SNA = PF.SNA;
    pub const IRDA = PF.IRDA;
    pub const PPPOX = PF.PPPOX;
    pub const WANPIPE = PF.WANPIPE;
    pub const LLC = PF.LLC;
    pub const IB = PF.IB;
    pub const MPLS = PF.MPLS;
    pub const CAN = PF.CAN;
    pub const TIPC = PF.TIPC;
    pub const BLUETOOTH = PF.BLUETOOTH;
    pub const IUCV = PF.IUCV;
    pub const RXRPC = PF.RXRPC;
    pub const ISDN = PF.ISDN;
    pub const PHONET = PF.PHONET;
    pub const IEEE802154 = PF.IEEE802154;
    pub const CAIF = PF.CAIF;
    pub const ALG = PF.ALG;
    pub const NFC = PF.NFC;
    pub const VSOCK = PF.VSOCK;
    pub const KCM = PF.KCM;
    pub const QIPCRTR = PF.QIPCRTR;
    pub const SMC = PF.SMC;
    pub const XDP = PF.XDP;
    pub const MAX = PF.MAX;
};

pub const SO = if (is_mips) struct {
    pub const DEBUG = 1;
    pub const REUSEADDR = 0x0004;
    pub const KEEPALIVE = 0x0008;
    pub const DONTROUTE = 0x0010;
    pub const BROADCAST = 0x0020;
    pub const LINGER = 0x0080;
    pub const OOBINLINE = 0x0100;
    pub const REUSEPORT = 0x0200;
    pub const SNDBUF = 0x1001;
    pub const RCVBUF = 0x1002;
    pub const SNDLOWAT = 0x1003;
    pub const RCVLOWAT = 0x1004;
    pub const RCVTIMEO = 0x1006;
    pub const SNDTIMEO = 0x1005;
    pub const ERROR = 0x1007;
    pub const TYPE = 0x1008;
    pub const ACCEPTCONN = 0x1009;
    pub const PROTOCOL = 0x1028;
    pub const DOMAIN = 0x1029;
    pub const NO_CHECK = 11;
    pub const PRIORITY = 12;
    pub const BSDCOMPAT = 14;
    pub const PASSCRED = 17;
    pub const PEERCRED = 18;
    pub const PEERSEC = 30;
    pub const SNDBUFFORCE = 31;
    pub const RCVBUFFORCE = 33;
    pub const SECURITY_AUTHENTICATION = 22;
    pub const SECURITY_ENCRYPTION_TRANSPORT = 23;
    pub const SECURITY_ENCRYPTION_NETWORK = 24;
    pub const BINDTODEVICE = 25;
    pub const ATTACH_FILTER = 26;
    pub const DETACH_FILTER = 27;
    pub const GET_FILTER = ATTACH_FILTER;
    pub const PEERNAME = 28;
    pub const TIMESTAMP_OLD = 29;
    pub const PASSSEC = 34;
    pub const TIMESTAMPNS_OLD = 35;
    pub const MARK = 36;
    pub const TIMESTAMPING_OLD = 37;
    pub const RXQ_OVFL = 40;
    pub const WIFI_STATUS = 41;
    pub const PEEK_OFF = 42;
    pub const NOFCS = 43;
    pub const LOCK_FILTER = 44;
    pub const SELECT_ERR_QUEUE = 45;
    pub const BUSY_POLL = 46;
    pub const MAX_PACING_RATE = 47;
    pub const BPF_EXTENSIONS = 48;
    pub const INCOMING_CPU = 49;
    pub const ATTACH_BPF = 50;
    pub const DETACH_BPF = DETACH_FILTER;
    pub const ATTACH_REUSEPORT_CBPF = 51;
    pub const ATTACH_REUSEPORT_EBPF = 52;
    pub const CNX_ADVICE = 53;
    pub const MEMINFO = 55;
    pub const INCOMING_NAPI_ID = 56;
    pub const COOKIE = 57;
    pub const PEERGROUPS = 59;
    pub const ZEROCOPY = 60;
    pub const TXTIME = 61;
    pub const BINDTOIFINDEX = 62;
    pub const TIMESTAMP_NEW = 63;
    pub const TIMESTAMPNS_NEW = 64;
    pub const TIMESTAMPING_NEW = 65;
    pub const RCVTIMEO_NEW = 66;
    pub const SNDTIMEO_NEW = 67;
    pub const DETACH_REUSEPORT_BPF = 68;
} else if (is_ppc) struct {
    pub const DEBUG = 1;
    pub const REUSEADDR = 2;
    pub const TYPE = 3;
    pub const ERROR = 4;
    pub const DONTROUTE = 5;
    pub const BROADCAST = 6;
    pub const SNDBUF = 7;
    pub const RCVBUF = 8;
    pub const KEEPALIVE = 9;
    pub const OOBINLINE = 10;
    pub const NO_CHECK = 11;
    pub const PRIORITY = 12;
    pub const LINGER = 13;
    pub const BSDCOMPAT = 14;
    pub const REUSEPORT = 15;
    pub const RCVLOWAT = 16;
    pub const SNDLOWAT = 17;
    pub const RCVTIMEO = 18;
    pub const SNDTIMEO = 19;
    pub const PASSCRED = 20;
    pub const PEERCRED = 21;
    pub const ACCEPTCONN = 30;
    pub const PEERSEC = 31;
    pub const SNDBUFFORCE = 32;
    pub const RCVBUFFORCE = 33;
    pub const PROTOCOL = 38;
    pub const DOMAIN = 39;
    pub const SECURITY_AUTHENTICATION = 22;
    pub const SECURITY_ENCRYPTION_TRANSPORT = 23;
    pub const SECURITY_ENCRYPTION_NETWORK = 24;
    pub const BINDTODEVICE = 25;
    pub const ATTACH_FILTER = 26;
    pub const DETACH_FILTER = 27;
    pub const GET_FILTER = ATTACH_FILTER;
    pub const PEERNAME = 28;
    pub const TIMESTAMP_OLD = 29;
    pub const PASSSEC = 34;
    pub const TIMESTAMPNS_OLD = 35;
    pub const MARK = 36;
    pub const TIMESTAMPING_OLD = 37;
    pub const RXQ_OVFL = 40;
    pub const WIFI_STATUS = 41;
    pub const PEEK_OFF = 42;
    pub const NOFCS = 43;
    pub const LOCK_FILTER = 44;
    pub const SELECT_ERR_QUEUE = 45;
    pub const BUSY_POLL = 46;
    pub const MAX_PACING_RATE = 47;
    pub const BPF_EXTENSIONS = 48;
    pub const INCOMING_CPU = 49;
    pub const ATTACH_BPF = 50;
    pub const DETACH_BPF = DETACH_FILTER;
    pub const ATTACH_REUSEPORT_CBPF = 51;
    pub const ATTACH_REUSEPORT_EBPF = 52;
    pub const CNX_ADVICE = 53;
    pub const MEMINFO = 55;
    pub const INCOMING_NAPI_ID = 56;
    pub const COOKIE = 57;
    pub const PEERGROUPS = 59;
    pub const ZEROCOPY = 60;
    pub const TXTIME = 61;
    pub const BINDTOIFINDEX = 62;
    pub const TIMESTAMP_NEW = 63;
    pub const TIMESTAMPNS_NEW = 64;
    pub const TIMESTAMPING_NEW = 65;
    pub const RCVTIMEO_NEW = 66;
    pub const SNDTIMEO_NEW = 67;
    pub const DETACH_REUSEPORT_BPF = 68;
} else if (is_sparc) struct {
    pub const DEBUG = 1;
    pub const REUSEADDR = 4;
    pub const TYPE = 4104;
    pub const ERROR = 4103;
    pub const DONTROUTE = 16;
    pub const BROADCAST = 32;
    pub const SNDBUF = 4097;
    pub const RCVBUF = 4098;
    pub const KEEPALIVE = 8;
    pub const OOBINLINE = 256;
    pub const NO_CHECK = 11;
    pub const PRIORITY = 12;
    pub const LINGER = 128;
    pub const BSDCOMPAT = 1024;
    pub const REUSEPORT = 512;
    pub const PASSCRED = 2;
    pub const PEERCRED = 64;
    pub const RCVLOWAT = 2048;
    pub const SNDLOWAT = 4096;
    pub const RCVTIMEO = 8192;
    pub const SNDTIMEO = 16384;
    pub const ACCEPTCONN = 32768;
    pub const PEERSEC = 30;
    pub const SNDBUFFORCE = 4106;
    pub const RCVBUFFORCE = 4107;
    pub const PROTOCOL = 4136;
    pub const DOMAIN = 4137;
    pub const SECURITY_AUTHENTICATION = 20481;
    pub const SECURITY_ENCRYPTION_TRANSPORT = 20482;
    pub const SECURITY_ENCRYPTION_NETWORK = 20484;
    pub const BINDTODEVICE = 13;
    pub const ATTACH_FILTER = 26;
    pub const DETACH_FILTER = 27;
    pub const GET_FILTER = 26;
    pub const PEERNAME = 28;
    pub const TIMESTAMP_OLD = 29;
    pub const PASSSEC = 31;
    pub const TIMESTAMPNS_OLD = 33;
    pub const MARK = 34;
    pub const TIMESTAMPING_OLD = 35;
    pub const RXQ_OVFL = 36;
    pub const WIFI_STATUS = 37;
    pub const PEEK_OFF = 38;
    pub const NOFCS = 39;
    pub const LOCK_FILTER = 40;
    pub const SELECT_ERR_QUEUE = 41;
    pub const BUSY_POLL = 48;
    pub const MAX_PACING_RATE = 49;
    pub const BPF_EXTENSIONS = 50;
    pub const INCOMING_CPU = 51;
    pub const ATTACH_BPF = 52;
    pub const DETACH_BPF = 27;
    pub const ATTACH_REUSEPORT_CBPF = 53;
    pub const ATTACH_REUSEPORT_EBPF = 54;
    pub const CNX_ADVICE = 55;
    pub const MEMINFO = 57;
    pub const INCOMING_NAPI_ID = 58;
    pub const COOKIE = 59;
    pub const PEERGROUPS = 61;
    pub const ZEROCOPY = 62;
    pub const TXTIME = 63;
    pub const BINDTOIFINDEX = 65;
    pub const TIMESTAMP_NEW = 70;
    pub const TIMESTAMPNS_NEW = 66;
    pub const TIMESTAMPING_NEW = 67;
    pub const RCVTIMEO_NEW = 68;
    pub const SNDTIMEO_NEW = 69;
    pub const DETACH_REUSEPORT_BPF = 71;
} else if (native_arch == .alpha) struct {
    pub const DEBUG = 1;
    pub const REUSEADDR = 0x0004;
    pub const KEEPALIVE = 0x0008;
    pub const DONTROUTE = 0x0010;
    pub const BROADCAST = 0x0020;
    pub const LINGER = 0x0080;
    pub const OOBINLINE = 0x0100;
    pub const REUSEPORT = 0x0200;

    pub const SNDBUF = 0x1001;
    pub const RCVBUF = 0x1002;
    pub const SNDLOWAT = 0x1011;
    pub const RCVLOWAT = 0x1010;
    pub const RCVTIMEO = 0x1012;
    pub const SNDTIMEO = 0x1013;
    pub const ERROR = 0x1007;
    pub const TYPE = 0x1008;
    pub const ACCEPTCONN = 0x1014;
    pub const PROTOCOL = 0x1028;
    pub const DOMAIN = 0x1029;

    pub const NO_CHECK = 11;
    pub const PRIORITY = 12;
    pub const BSDCOMPAT = 14;
    pub const PASSCRED = 17;
    pub const PEERCRED = 18;
    pub const PEERSEC = 30;
    pub const SNDBUFFORCE = 0x100a;
    pub const RCVBUFFORCE = 0x100b;
    pub const SECURITY_AUTHENTICATION = 19;
    pub const SECURITY_ENCRYPTION_TRANSPORT = 20;
    pub const SECURITY_ENCRYPTION_NETWORK = 21;
    pub const BINDTODEVICE = 25;
    pub const ATTACH_FILTER = 26;
    pub const DETACH_FILTER = 27;
    pub const GET_FILTER = ATTACH_FILTER;
    pub const PEERNAME = 28;
    pub const TIMESTAMP_OLD = 29;
    pub const PASSSEC = 34;
    pub const TIMESTAMPNS_OLD = 35;
    pub const MARK = 36;
    pub const TIMESTAMPING_OLD = 37;
    pub const RXQ_OVFL = 40;
    pub const WIFI_STATUS = 41;
    pub const PEEK_OFF = 42;
    pub const NOFCS = 43;
    pub const LOCK_FILTER = 44;
    pub const SELECT_ERR_QUEUE = 45;
    pub const BUSY_POLL = 46;
    pub const MAX_PACING_RATE = 47;
    pub const BPF_EXTENSIONS = 48;
    pub const INCOMING_CPU = 49;
    pub const ATTACH_BPF = 50;
    pub const DETACH_BPF = DETACH_FILTER;
    pub const ATTACH_REUSEPORT_CBPF = 51;
    pub const ATTACH_REUSEPORT_EBPF = 52;
    pub const CNX_ADVICE = 53;
    pub const MEMINFO = 55;
    pub const INCOMING_NAPI_ID = 56;
    pub const COOKIE = 57;
    pub const PEERGROUPS = 59;
    pub const ZEROCOPY = 60;
    pub const TXTIME = 61;
    pub const BINDTOIFINDEX = 62;
    pub const TIMESTAMP_NEW = 63;
    pub const TIMESTAMPNS_NEW = 64;
    pub const TIMESTAMPING_NEW = 65;
    pub const RCVTIMEO_NEW = 66;
    pub const SNDTIMEO_NEW = 67;
    pub const DETACH_REUSEPORT_BPF = 68;
} else struct {
    pub const DEBUG = 1;
    pub const REUSEADDR = 2;
    pub const TYPE = 3;
    pub const ERROR = 4;
    pub const DONTROUTE = 5;
    pub const BROADCAST = 6;
    pub const SNDBUF = 7;
    pub const RCVBUF = 8;
    pub const KEEPALIVE = 9;
    pub const OOBINLINE = 10;
    pub const NO_CHECK = 11;
    pub const PRIORITY = 12;
    pub const LINGER = 13;
    pub const BSDCOMPAT = 14;
    pub const REUSEPORT = 15;
    pub const PASSCRED = 16;
    pub const PEERCRED = 17;
    pub const RCVLOWAT = 18;
    pub const SNDLOWAT = 19;
    pub const RCVTIMEO = 20;
    pub const SNDTIMEO = 21;
    pub const ACCEPTCONN = 30;
    pub const PEERSEC = 31;
    pub const SNDBUFFORCE = 32;
    pub const RCVBUFFORCE = 33;
    pub const PROTOCOL = 38;
    pub const DOMAIN = 39;
    pub const SECURITY_AUTHENTICATION = 22;
    pub const SECURITY_ENCRYPTION_TRANSPORT = 23;
    pub const SECURITY_ENCRYPTION_NETWORK = 24;
    pub const BINDTODEVICE = 25;
    pub const ATTACH_FILTER = 26;
    pub const DETACH_FILTER = 27;
    pub const GET_FILTER = ATTACH_FILTER;
    pub const PEERNAME = 28;
    pub const TIMESTAMP_OLD = 29;
    pub const PASSSEC = 34;
    pub const TIMESTAMPNS_OLD = 35;
    pub const MARK = 36;
    pub const TIMESTAMPING_OLD = 37;
    pub const RXQ_OVFL = 40;
    pub const WIFI_STATUS = 41;
    pub const PEEK_OFF = 42;
    pub const NOFCS = 43;
    pub const LOCK_FILTER = 44;
    pub const SELECT_ERR_QUEUE = 45;
    pub const BUSY_POLL = 46;
    pub const MAX_PACING_RATE = 47;
    pub const BPF_EXTENSIONS = 48;
    pub const INCOMING_CPU = 49;
    pub const ATTACH_BPF = 50;
    pub const DETACH_BPF = DETACH_FILTER;
    pub const ATTACH_REUSEPORT_CBPF = 51;
    pub const ATTACH_REUSEPORT_EBPF = 52;
    pub const CNX_ADVICE = 53;
    pub const MEMINFO = 55;
    pub const INCOMING_NAPI_ID = 56;
    pub const COOKIE = 57;
    pub const PEERGROUPS = 59;
    pub const ZEROCOPY = 60;
    pub const TXTIME = 61;
    pub const BINDTOIFINDEX = 62;
    pub const TIMESTAMP_NEW = 63;
    pub const TIMESTAMPNS_NEW = 64;
    pub const TIMESTAMPING_NEW = 65;
    pub const RCVTIMEO_NEW = 66;
    pub const SNDTIMEO_NEW = 67;
    pub const DETACH_REUSEPORT_BPF = 68;
};

pub const SCM = struct {
    // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/socket.h?id=f777d1112ee597d7f7dd3ca232220873a34ad0c8#n178
    pub const RIGHTS = 1;
    pub const CREDENTIALS = 2;
    pub const SECURITY = 3;
    pub const PIDFD = 4;

    pub const WIFI_STATUS = SO.WIFI_STATUS;
    pub const TIMESTAMPING_OPT_STATS = 54;
    pub const TIMESTAMPING_PKTINFO = 58;
    pub const TXTIME = SO.TXTIME;
};

pub const SOL = struct {
    pub const SOCKET = if (is_mips or is_sparc or native_arch == .alpha)
        0xffff
    else
        1;

    pub const IP = 0;
    pub const IPV6 = 41;
    pub const ICMPV6 = 58;

    pub const RAW = 255;
    pub const DECNET = 261;
    pub const X25 = 262;
    pub const PACKET = 263;
    pub const ATM = 264;
    pub const AAL = 265;
    pub const IRDA = 266;
    pub const NETBEUI = 267;
    pub const LLC = 268;
    pub const DCCP = 269;
    pub const NETLINK = 270;
    pub const TIPC = 271;
    pub const RXRPC = 272;
    pub const PPPOL2TP = 273;
    pub const BLUETOOTH = 274;
    pub const PNPIPE = 275;
    pub const RDS = 276;
    pub const IUCV = 277;
    pub const CAIF = 278;
    pub const ALG = 279;
    pub const NFC = 280;
    pub const KCM = 281;
    pub const TLS = 282;
    pub const XDP = 283;
};

pub const SOMAXCONN = 128;

pub const IP = struct {
    pub const TOS = 1;
    pub const TTL = 2;
    pub const HDRINCL = 3;
    pub const OPTIONS = 4;
    pub const ROUTER_ALERT = 5;
    pub const RECVOPTS = 6;
    pub const RETOPTS = 7;
    pub const PKTINFO = 8;
    pub const PKTOPTIONS = 9;
    pub const PMTUDISC = 10;
    pub const MTU_DISCOVER = 10;
    pub const RECVERR = 11;
    pub const RECVTTL = 12;
    pub const RECVTOS = 13;
    pub const MTU = 14;
    pub const FREEBIND = 15;
    pub const IPSEC_POLICY = 16;
    pub const XFRM_POLICY = 17;
    pub const PASSSEC = 18;
    pub const TRANSPARENT = 19;
    pub const ORIGDSTADDR = 20;
    pub const RECVORIGDSTADDR = IP.ORIGDSTADDR;
    pub const MINTTL = 21;
    pub const NODEFRAG = 22;
    pub const CHECKSUM = 23;
    pub const BIND_ADDRESS_NO_PORT = 24;
    pub const RECVFRAGSIZE = 25;
    pub const MULTICAST_IF = 32;
    pub const MULTICAST_TTL = 33;
    pub const MULTICAST_LOOP = 34;
    pub const ADD_MEMBERSHIP = 35;
    pub const DROP_MEMBERSHIP = 36;
    pub const UNBLOCK_SOURCE = 37;
    pub const BLOCK_SOURCE = 38;
    pub const ADD_SOURCE_MEMBERSHIP = 39;
    pub const DROP_SOURCE_MEMBERSHIP = 40;
    pub const MSFILTER = 41;
    pub const MULTICAST_ALL = 49;
    pub const UNICAST_IF = 50;

    pub const RECVRETOPTS = IP.RETOPTS;

    pub const PMTUDISC_DONT = 0;
    pub const PMTUDISC_WANT = 1;
    pub const PMTUDISC_DO = 2;
    pub const PMTUDISC_PROBE = 3;
    pub const PMTUDISC_INTERFACE = 4;
    pub const PMTUDISC_OMIT = 5;

    pub const DEFAULT_MULTICAST_TTL = 1;
    pub const DEFAULT_MULTICAST_LOOP = 1;
    pub const MAX_MEMBERSHIPS = 20;
};

/// IPv6 socket options
pub const IPV6 = struct {
    pub const ADDRFORM = 1;
    pub const @"2292PKTINFO" = 2;
    pub const @"2292HOPOPTS" = 3;
    pub const @"2292DSTOPTS" = 4;
    pub const @"2292RTHDR" = 5;
    pub const @"2292PKTOPTIONS" = 6;
    pub const CHECKSUM = 7;
    pub const @"2292HOPLIMIT" = 8;
    pub const NEXTHOP = 9;
    pub const AUTHHDR = 10;
    pub const FLOWINFO = 11;

    pub const UNICAST_HOPS = 16;
    pub const MULTICAST_IF = 17;
    pub const MULTICAST_HOPS = 18;
    pub const MULTICAST_LOOP = 19;
    pub const ADD_MEMBERSHIP = 20;
    pub const DROP_MEMBERSHIP = 21;
    pub const ROUTER_ALERT = 22;
    pub const MTU_DISCOVER = 23;
    pub const MTU = 24;
    pub const RECVERR = 25;
    pub const V6ONLY = 26;
    pub const JOIN_ANYCAST = 27;
    pub const LEAVE_ANYCAST = 28;

    // IPV6.MTU_DISCOVER values
    pub const PMTUDISC_DONT = 0;
    pub const PMTUDISC_WANT = 1;
    pub const PMTUDISC_DO = 2;
    pub const PMTUDISC_PROBE = 3;
    pub const PMTUDISC_INTERFACE = 4;
    pub const PMTUDISC_OMIT = 5;

    // Flowlabel
    pub const FLOWLABEL_MGR = 32;
    pub const FLOWINFO_SEND = 33;
    pub const IPSEC_POLICY = 34;
    pub const XFRM_POLICY = 35;
    pub const HDRINCL = 36;

    // Advanced API (RFC3542) (1)
    pub const RECVPKTINFO = 49;
    pub const PKTINFO = 50;
    pub const RECVHOPLIMIT = 51;
    pub const HOPLIMIT = 52;
    pub const RECVHOPOPTS = 53;
    pub const HOPOPTS = 54;
    pub const RTHDRDSTOPTS = 55;
    pub const RECVRTHDR = 56;
    pub const RTHDR = 57;
    pub const RECVDSTOPTS = 58;
    pub const DSTOPTS = 59;
    pub const RECVPATHMTU = 60;
    pub const PATHMTU = 61;
    pub const DONTFRAG = 62;

    // Advanced API (RFC3542) (2)
    pub const RECVTCLASS = 66;
    pub const TCLASS = 67;

    pub const AUTOFLOWLABEL = 70;

    // RFC5014: Source address selection
    pub const ADDR_PREFERENCES = 72;

    pub const PREFER_SRC_TMP = 0x0001;
    pub const PREFER_SRC_PUBLIC = 0x0002;
    pub const PREFER_SRC_PUBTMP_DEFAULT = 0x0100;
    pub const PREFER_SRC_COA = 0x0004;
    pub const PREFER_SRC_HOME = 0x0400;
    pub const PREFER_SRC_CGA = 0x0008;
    pub const PREFER_SRC_NONCGA = 0x0800;

    // RFC5082: Generalized Ttl Security Mechanism
    pub const MINHOPCOUNT = 73;

    pub const ORIGDSTADDR = 74;
    pub const RECVORIGDSTADDR = IPV6.ORIGDSTADDR;
    pub const TRANSPARENT = 75;
    pub const UNICAST_IF = 76;
    pub const RECVFRAGSIZE = 77;
    pub const FREEBIND = 78;
};

// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/ip.h?id=64e844505bc08cde3f346f193cbbbab0096fef54#n24
pub const IPTOS = struct {
    pub const TOS_MASK = 0x1e;
    pub fn TOS(t: anytype) @TypeOf(t) {
        return t & TOS_MASK;
    }

    pub const MINCOST = 0x02;
    pub const RELIABILITY = 0x04;
    pub const THROUGHPUT = 0x08;
    pub const LOWDELAY = 0x10;

    pub const PREC_MASK = 0xe0;
    pub fn PREC(t: anytype) @TypeOf(t) {
        return t & PREC_MASK;
    }

    pub const PREC_ROUTINE = 0x00;
    pub const PREC_PRIORITY = 0x20;
    pub const PREC_IMMEDIATE = 0x40;
    pub const PREC_FLASH = 0x60;
    pub const PREC_FLASHOVERRIDE = 0x80;
    pub const PREC_CRITIC_ECP = 0xa0;
    pub const PREC_INTERNETCONTROL = 0xc0;
    pub const PREC_NETCONTROL = 0xe0;
};

// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/socket.h?id=b1e904999542ad6764eafa54545f1c55776006d1#n43
pub const linger = extern struct {
    onoff: i32, // non-zero to linger on close
    linger: i32, // time to linger in seconds
};

// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/in.h?id=64e844505bc08cde3f346f193cbbbab0096fef54#n250
pub const in_pktinfo = extern struct {
    ifindex: i32,
    spec_dst: u32,
    addr: u32,
};

// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/ipv6.h?id=f24987ef6959a7efaf79bffd265522c3df18d431#n22
pub const in6_pktinfo = extern struct {
    addr: [16]u8,
    ifindex: i32,
};

/// IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
/// and FCS/CRC (frame check sequence).
pub const ETH = struct {
    /// Octets in one ethernet addr
    pub const ALEN = 6;
    /// Octets in ethernet type field
    pub const TLEN = 2;
    /// Total octets in header
    pub const HLEN = 14;
    /// Min. octets in frame sans FC
    pub const ZLEN = 60;
    /// Max. octets in payload
    pub const DATA_LEN = 1500;
    /// Max. octets in frame sans FCS
    pub const FRAME_LEN = 1514;
    /// Octets in the FCS
    pub const FCS_LEN = 4;

    /// Min IPv4 MTU per RFC791
    pub const MIN_MTU = 68;
    /// 65535, same as IP_MAX_MTU
    pub const MAX_MTU = 0xFFFF;

    /// These are the defined Ethernet Protocol ID's.
    pub const P = struct {
        /// Ethernet Loopback packet
        pub const LOOP = 0x0060;
        /// Xerox PUP packet
        pub const PUP = 0x0200;
        /// Xerox PUP Addr Trans packet
        pub const PUPAT = 0x0201;
        /// TSN (IEEE 1722) packet
        pub const TSN = 0x22F0;
        /// ERSPAN version 2 (type III)
        pub const ERSPAN2 = 0x22EB;
        /// Internet Protocol packet
        pub const IP = 0x0800;
        /// CCITT X.25
        pub const X25 = 0x0805;
        /// Address Resolution packet
        pub const ARP = 0x0806;
        /// G8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ]
        pub const BPQ = 0x08FF;
        /// Xerox IEEE802.3 PUP packet
        pub const IEEEPUP = 0x0a00;
        /// Xerox IEEE802.3 PUP Addr Trans packet
        pub const IEEEPUPAT = 0x0a01;
        /// B.A.T.M.A.N.-Advanced packet [ NOT AN OFFICIALLY REGISTERED ID ]
        pub const BATMAN = 0x4305;
        /// DEC Assigned proto
        pub const DEC = 0x6000;
        /// DEC DNA Dump/Load
        pub const DNA_DL = 0x6001;
        /// DEC DNA Remote Console
        pub const DNA_RC = 0x6002;
        /// DEC DNA Routing
        pub const DNA_RT = 0x6003;
        /// DEC LAT
        pub const LAT = 0x6004;
        /// DEC Diagnostics
        pub const DIAG = 0x6005;
        /// DEC Customer use
        pub const CUST = 0x6006;
        /// DEC Systems Comms Arch
        pub const SCA = 0x6007;
        /// Trans Ether Bridging
        pub const TEB = 0x6558;
        /// Reverse Addr Res packet
        pub const RARP = 0x8035;
        /// Appletalk DDP
        pub const ATALK = 0x809B;
        /// Appletalk AARP
        pub const AARP = 0x80F3;
        /// 802.1Q VLAN Extended Header
        pub const P_8021Q = 0x8100;
        /// ERSPAN type II
        pub const ERSPAN = 0x88BE;
        /// IPX over DIX
        pub const IPX = 0x8137;
        /// IPv6 over bluebook
        pub const IPV6 = 0x86DD;
        /// IEEE Pause frames. See 802.3 31B
        pub const PAUSE = 0x8808;
        /// Slow Protocol. See 802.3ad 43B
        pub const SLOW = 0x8809;
        /// Web-cache coordination protocol defined in draft-wilson-wrec-wccp-v2-00.txt
        pub const WCCP = 0x883E;
        /// MPLS Unicast traffic
        pub const MPLS_UC = 0x8847;
        /// MPLS Multicast traffic
        pub const MPLS_MC = 0x8848;
        /// MultiProtocol Over ATM
        pub const ATMMPOA = 0x884c;
        /// PPPoE discovery messages
        pub const PPP_DISC = 0x8863;
        /// PPPoE session messages
        pub const PPP_SES = 0x8864;
        /// HPNA, wlan link local tunnel
        pub const LINK_CTL = 0x886c;
        /// Frame-based ATM Transport over Ethernet
        pub const ATMFATE = 0x8884;
        /// Port Access Entity (IEEE 802.1X)
        pub const PAE = 0x888E;
        /// PROFINET
        pub const PROFINET = 0x8892;
        /// Multiple proprietary protocols
        pub const REALTEK = 0x8899;
        /// ATA over Ethernet
        pub const AOE = 0x88A2;
        /// EtherCAT
        pub const ETHERCAT = 0x88A4;
        /// 802.1ad Service VLAN
        pub const @"8021AD" = 0x88A8;
        /// 802.1 Local Experimental 1.
        pub const @"802_EX1" = 0x88B5;
        /// 802.11 Preauthentication
        pub const PREAUTH = 0x88C7;
        /// TIPC
        pub const TIPC = 0x88CA;
        /// Link Layer Discovery Protocol
        pub const LLDP = 0x88CC;
        /// Media Redundancy Protocol
        pub const MRP = 0x88E3;
        /// 802.1ae MACsec
        pub const MACSEC = 0x88E5;
        /// 802.1ah Backbone Service Tag
        pub const @"8021AH" = 0x88E7;
        /// 802.1Q MVRP
        pub const MVRP = 0x88F5;
        /// IEEE 1588 Timesync
        pub const @"1588" = 0x88F7;
        /// NCSI protocol
        pub const NCSI = 0x88F8;
        /// IEC 62439-3 PRP/HSRv0
        pub const PRP = 0x88FB;
        /// Connectivity Fault Management
        pub const CFM = 0x8902;
        /// Fibre Channel over Ethernet
        pub const FCOE = 0x8906;
        /// Infiniband over Ethernet
        pub const IBOE = 0x8915;
        /// TDLS
        pub const TDLS = 0x890D;
        /// FCoE Initialization Protocol
        pub const FIP = 0x8914;
        /// IEEE 802.21 Media Independent Handover Protocol
        pub const @"80221" = 0x8917;
        /// IEC 62439-3 HSRv1
        pub const HSR = 0x892F;
        /// Network Service Header
        pub const NSH = 0x894F;
        /// Ethernet loopback packet, per IEEE 802.3
        pub const LOOPBACK = 0x9000;
        /// deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ]
        pub const QINQ1 = 0x9100;
        /// deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ]
        pub const QINQ2 = 0x9200;
        /// deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ]
        pub const QINQ3 = 0x9300;
        /// Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ]
        pub const EDSA = 0xDADA;
        /// Fake VLAN Header for DSA [ NOT AN OFFICIALLY REGISTERED ID ]
        pub const DSA_8021Q = 0xDADB;
        /// A5PSW Tag Value [ NOT AN OFFICIALLY REGISTERED ID ]
        pub const DSA_A5PSW = 0xE001;
        /// ForCES inter-FE LFB type
        pub const IFE = 0xED3E;
        /// IBM af_iucv [ NOT AN OFFICIALLY REGISTERED ID ]
        pub const AF_IUCV = 0xFBFB;
        /// If the value in the ethernet type is more than this value then the frame is Ethernet II. Else it is 802.3
        pub const @"802_3_MIN" = 0x0600;

        // Non DIX types. Won't clash for 1500 types.

        /// Dummy type for 802.3 frames
        pub const @"802_3" = 0x0001;
        /// Dummy protocol id for AX.25
        pub const AX25 = 0x0002;
        /// Every packet (be careful!!!)
        pub const ALL = 0x0003;
        /// 802.2 frames
        pub const @"802_2" = 0x0004;
        /// Internal only
        pub const SNAP = 0x0005;
        /// DEC DDCMP: Internal only
        pub const DDCMP = 0x0006;
        /// Dummy type for WAN PPP frames
        pub const WAN_PPP = 0x0007;
        /// Dummy type for PPP MP frames
        pub const PPP_MP = 0x0008;
        /// Localtalk pseudo type
        pub const LOCALTALK = 0x0009;
        /// CAN: Controller Area Network
        pub const CAN = 0x000C;
        /// CANFD: CAN flexible data rate
        pub const CANFD = 0x000D;
        /// CANXL: eXtended frame Length
        pub const CANXL = 0x000E;
        /// Dummy type for Atalk over PPP
        pub const PPPTALK = 0x0010;
        /// 802.2 frames
        pub const TR_802_2 = 0x0011;
        /// Mobitex (kaz@cafe.net)
        pub const MOBITEX = 0x0015;
        /// Card specific control frames
        pub const CONTROL = 0x0016;
        /// Linux-IrDA
        pub const IRDA = 0x0017;
        /// Acorn Econet
        pub const ECONET = 0x0018;
        /// HDLC frames
        pub const HDLC = 0x0019;
        /// 1A for ArcNet :-)
        pub const ARCNET = 0x001A;
        /// Distributed Switch Arch.
        pub const DSA = 0x001B;
        /// Trailer switch tagging
        pub const TRAILER = 0x001C;
        /// Nokia Phonet frames
        pub const PHONET = 0x00F5;
        /// IEEE802.15.4 frame
        pub const IEEE802154 = 0x00F6;
        /// ST-Ericsson CAIF protocol
        pub const CAIF = 0x00F7;
        /// Multiplexed DSA protocol
        pub const XDSA = 0x00F8;
        /// Qualcomm multiplexing and aggregation protocol
        pub const MAP = 0x00F9;
        /// Management component transport protocol packets
        pub const MCTP = 0x00FA;
    };
};

pub const MSG = struct {
    pub const OOB = 0x0001;
    pub const PEEK = 0x0002;
    pub const DONTROUTE = 0x0004;
    pub const CTRUNC = 0x0008;
    pub const PROXY = 0x0010;
    pub const TRUNC = 0x0020;
    pub const DONTWAIT = 0x0040;
    pub const EOR = 0x0080;
    pub const WAITALL = 0x0100;
    pub const FIN = 0x0200;
    pub const SYN = 0x0400;
    pub const CONFIRM = 0x0800;
    pub const RST = 0x1000;
    pub const ERRQUEUE = 0x2000;
    pub const NOSIGNAL = 0x4000;
    pub const MORE = 0x8000;
    pub const WAITFORONE = 0x10000;
    pub const BATCH = 0x40000;
    pub const ZEROCOPY = 0x4000000;
    pub const FASTOPEN = 0x20000000;
    pub const CMSG_CLOEXEC = 0x40000000;
};

pub const DT = struct {
    pub const UNKNOWN = 0;
    pub const FIFO = 1;
    pub const CHR = 2;
    pub const DIR = 4;
    pub const BLK = 6;
    pub const REG = 8;
    pub const LNK = 10;
    pub const SOCK = 12;
    pub const WHT = 14;
};

pub const T = if (is_mips) struct {
    pub const CGETA = 0x5401;
    pub const CSETA = 0x5402;
    pub const CSETAW = 0x5403;
    pub const CSETAF = 0x5404;

    pub const CSBRK = 0x5405;
    pub const CXONC = 0x5406;
    pub const CFLSH = 0x5407;

    pub const CGETS = 0x540d;
    pub const CSETS = 0x540e;
    pub const CSETSW = 0x540f;
    pub const CSETSF = 0x5410;

    pub const IOCEXCL = 0x740d;
    pub const IOCNXCL = 0x740e;
    pub const IOCOUTQ = 0x7472;
    pub const IOCSTI = 0x5472;
    pub const IOCMGET = 0x741d;
    pub const IOCMBIS = 0x741b;
    pub const IOCMBIC = 0x741c;
    pub const IOCMSET = 0x741a;
    pub const IOCPKT = 0x5470;
    pub const IOCPKT_DATA = 0x00;
    pub const IOCPKT_FLUSHREAD = 0x01;
    pub const IOCPKT_FLUSHWRITE = 0x02;
    pub const IOCPKT_STOP = 0x04;
    pub const IOCPKT_START = 0x08;
    pub const IOCPKT_NOSTOP = 0x10;
    pub const IOCPKT_DOSTOP = 0x20;
    pub const IOCPKT_IOCTL = 0x40;
    pub const IOCSWINSZ = IOCTL.IOW('t', 103, winsize);
    pub const IOCGWINSZ = IOCTL.IOR('t', 104, winsize);
    pub const IOCNOTTY = 0x5471;
    pub const IOCSETD = 0x7401;
    pub const IOCGETD = 0x7400;

    pub const FIOCLEX = 0x6601;
    pub const FIONCLEX = 0x6602;
    pub const FIOASYNC = 0x667d;
    pub const FIONBIO = 0x667e;
    pub const FIOQSIZE = 0x667f;

    pub const IOCGLTC = 0x7474;
    pub const IOCSLTC = 0x7475;
    pub const IOCSPGRP = IOCTL.IOW('t', 118, c_int);
    pub const IOCGPGRP = IOCTL.IOR('t', 119, c_int);
    pub const IOCCONS = IOCTL.IOW('t', 120, c_int);

    pub const FIONREAD = 0x467f;
    pub const IOCINQ = FIONREAD;

    pub const IOCGETP = 0x7408;
    pub const IOCSETP = 0x7409;
    pub const IOCSETN = 0x740a;

    pub const IOCSBRK = 0x5427;
    pub const IOCCBRK = 0x5428;
    pub const IOCGSID = 0x7416;
    pub const CGETS2 = IOCTL.IOR('T', 0x2a, termios2);
    pub const CSETS2 = IOCTL.IOW('T', 0x2b, termios2);
    pub const CSETSW2 = IOCTL.IOW('T', 0x2c, termios2);
    pub const CSETSF2 = IOCTL.IOW('T', 0x2d, termios2);
    pub const IOCGRS485 = IOCTL.IOR('T', 0x2e, serial_rs485);
    pub const IOCSRS485 = IOCTL.IOWR('T', 0x2f, serial_rs485);
    pub const IOCGPTN = IOCTL.IOR('T', 0x30, c_uint);
    pub const IOCSPTLCK = IOCTL.IOW('T', 0x31, c_int);
    pub const IOCGDEV = IOCTL.IOR('T', 0x32, c_uint);
    pub const IOCSIG = IOCTL.IOW('T', 0x36, c_int);
    pub const IOCVHANGUP = 0x5437;
    pub const IOCGPKT = IOCTL.IOR('T', 0x38, c_int);
    pub const IOCGPTLCK = IOCTL.IOR('T', 0x39, c_int);
    pub const IOCGEXCL = IOCTL.IOR('T', 0x40, c_int);
    pub const IOCGPTPEER = IOCTL.IO('T', 0x41);
    pub const IOCGISO7816 = IOCTL.IOR('T', 0x42, serial_iso7816);
    pub const IOCSISO7816 = IOCTL.IOWR('T', 0x43, serial_iso7816);

    pub const IOCSCTTY = 0x5480;
    pub const IOCGSOFTCAR = 0x5481;
    pub const IOCSSOFTCAR = 0x5482;
    pub const IOCLINUX = 0x5483;
    pub const IOCGSERIAL = 0x5484;
    pub const IOCSSERIAL = 0x5485;
    pub const CSBRKP = 0x5486;
    pub const IOCSERCONFIG = 0x5488;
    pub const IOCSERGWILD = 0x5489;
    pub const IOCSERSWILD = 0x548a;
    pub const IOCGLCKTRMIOS = 0x548b;
    pub const IOCSLCKTRMIOS = 0x548c;
    pub const IOCSERGSTRUCT = 0x548d;
    pub const IOCSERGETLSR = 0x548e;
    pub const IOCSERGETMULTI = 0x548f;
    pub const IOCSERSETMULTI = 0x5490;
    pub const IOCMIWAIT = 0x5491;
    pub const IOCGICOUNT = 0x5492;
} else if (is_ppc or native_arch == .alpha) struct {
    pub const FIOCLEX = IOCTL.IO('f', 1);
    pub const FIONCLEX = IOCTL.IO('f', 2);
    pub const FIOASYNC = IOCTL.IOW('f', 125, c_int);
    pub const FIONBIO = IOCTL.IOW('f', 126, c_int);
    pub const FIONREAD = IOCTL.IOR('f', 127, c_int);
    pub const IOCINQ = FIONREAD;
    pub const FIOQSIZE = IOCTL.IOR('f', 128, c_longlong); // loff_t -> __kernel_loff_t -> long long

    pub const IOCGETP = IOCTL.IOR('t', 8, sgttyb);
    pub const IOCSETP = IOCTL.IOW('t', 9, sgttyb);
    pub const IOCSETN = IOCTL.IOW('t', 10, sgttyb);

    pub const IOCSETC = IOCTL.IOW('t', 17, tchars);
    pub const IOCGETC = IOCTL.IOR('t', 18, tchars);
    pub const CGETS = IOCTL.IOR('t', 19, termios);
    pub const CSETS = IOCTL.IOW('t', 20, termios);
    pub const CSETSW = IOCTL.IOW('t', 21, termios);
    pub const CSETSF = IOCTL.IOW('t', 22, termios);

    pub const CGETA = IOCTL.IOR('t', 23, termio);
    pub const CSETA = IOCTL.IOW('t', 24, termio);
    pub const CSETAW = IOCTL.IOW('t', 25, termio);
    pub const CSETAF = IOCTL.IOW('t', 28, termio);

    pub const CSBRK = IOCTL.IO('t', 29);
    pub const CXONC = IOCTL.IO('t', 30);
    pub const CFLSH = IOCTL.IO('t', 31);

    pub const IOCSWINSZ = IOCTL.IOW('t', 103, winsize);
    pub const IOCGWINSZ = IOCTL.IOR('t', 104, winsize);
    pub const IOCSTART = IOCTL.IO('t', 110);
    pub const IOCSTOP = IOCTL.IO('t', 111);
    pub const IOCOUTQ = IOCTL.IOR('t', 115, c_int);

    pub const IOCGLTC = IOCTL.IOR('t', 116, ltchars);
    pub const IOCSLTC = IOCTL.IOW('t', 117, ltchars);
    pub const IOCSPGRP = IOCTL.IOW('t', 118, c_int);
    pub const IOCGPGRP = IOCTL.IOR('t', 119, c_int);

    pub const IOCEXCL = 0x540c;
    pub const IOCNXCL = 0x540d;
    pub const IOCSCTTY = 0x540e;

    pub const IOCSTI = 0x5412;
    pub const IOCMGET = 0x5415;
    pub const IOCMBIS = 0x5416;
    pub const IOCMBIC = 0x5417;
    pub const IOCMSET = 0x5418;
    pub const IOCM_LE = 0x001;
    pub const IOCM_DTR = 0x002;
    pub const IOCM_RTS = 0x004;
    pub const IOCM_ST = 0x008;
    pub const IOCM_SR = 0x010;
    pub const IOCM_CTS = 0x020;
    pub const IOCM_CAR = 0x040;
    pub const IOCM_RNG = 0x080;
    pub const IOCM_DSR = 0x100;
    pub const IOCM_CD = IOCM_CAR;
    pub const IOCM_RI = IOCM_RNG;
    pub const IOCM_OUT1 = 0x2000;
    pub const IOCM_OUT2 = 0x4000;
    pub const IOCM_LOOP = 0x8000;

    pub const IOCGSOFTCAR = 0x5419;
    pub const IOCSSOFTCAR = 0x541a;
    pub const IOCLINUX = 0x541c;
    pub const IOCCONS = 0x541d;
    pub const IOCGSERIAL = 0x541e;
    pub const IOCSSERIAL = 0x541f;
    pub const IOCPKT = 0x5420;
    pub const IOCPKT_DATA = 0;
    pub const IOCPKT_FLUSHREAD = 1;
    pub const IOCPKT_FLUSHWRITE = 2;
    pub const IOCPKT_STOP = 4;
    pub const IOCPKT_START = 8;
    pub const IOCPKT_NOSTOP = 16;
    pub const IOCPKT_DOSTOP = 32;
    pub const IOCPKT_IOCTL = 64;

    pub const IOCNOTTY = 0x5422;
    pub const IOCSETD = 0x5423;
    pub const IOCGETD = 0x5424;
    pub const CSBRKP = 0x5425;
    pub const IOCSBRK = 0x5427;
    pub const IOCCBRK = 0x5428;
    pub const IOCGSID = 0x5429;
    pub const IOCGRS485 = 0x542e;
    pub const IOCSRS485 = 0x542f;
    pub const IOCGPTN = IOCTL.IOR('T', 0x30, c_uint);
    pub const IOCSPTLCK = IOCTL.IOW('T', 0x31, c_int);
    pub const IOCGDEV = IOCTL.IOR('T', 0x32, c_uint);
    pub const IOCSIG = IOCTL.IOW('T', 0x36, c_int);
    pub const IOCVHANGUP = 0x5437;
    pub const IOCGPKT = IOCTL.IOR('T', 0x38, c_int);
    pub const IOCGPTLCK = IOCTL.IOR('T', 0x39, c_int);
    pub const IOCGEXCL = IOCTL.IOR('T', 0x40, c_int);
    pub const IOCGPTPEER = IOCTL.IO('T', 0x41);
    pub const IOCGISO7816 = IOCTL.IOR('T', 0x42, serial_iso7816);
    pub const IOCSISO7816 = IOCTL.IOWR('T', 0x43, serial_iso7816);

    pub const IOCSERCONFIG = 0x5453;
    pub const IOCSERGWILD = 0x5454;
    pub const IOCSERSWILD = 0x5455;
    pub const IOCGLCKTRMIOS = 0x5456;
    pub const IOCSLCKTRMIOS = 0x5457;
    pub const IOCSERGSTRUCT = 0x5458;
    pub const IOCSERGETLSR = 0x5459;
    pub const IOCSER_TEMT = 0x01;
    pub const IOCSERGETMULTI = 0x545a;
    pub const IOCSERSETMULTI = 0x545b;

    pub const IOCMIWAIT = 0x545c;
    pub const IOCGICOUNT = 0x545d;
} else if (is_sparc) struct {
    // Entries with double-underscore prefix have not been translated as they are unsupported.

    pub const CGETA = IOCTL.IOR('T', 1, termio);
    pub const CSETA = IOCTL.IOW('T', 2, termio);
    pub const CSETAW = IOCTL.IOW('T', 3, termio);
    pub const CSETAF = IOCTL.IOW('T', 4, termio);
    pub const CSBRK = IOCTL.IO('T', 5);
    pub const CXONC = IOCTL.IO('T', 6);
    pub const CFLSH = IOCTL.IO('T', 7);
    pub const CGETS = IOCTL.IOR('T', 8, termios);
    pub const CSETS = IOCTL.IOW('T', 9, termios);
    pub const CSETSW = IOCTL.IOW('T', 10, termios);
    pub const CSETSF = IOCTL.IOW('T', 11, termios);
    pub const CGETS2 = IOCTL.IOR('T', 12, termios2);
    pub const CSETS2 = IOCTL.IOW('T', 13, termios2);
    pub const CSETSW2 = IOCTL.IOW('T', 14, termios2);
    pub const CSETSF2 = IOCTL.IOW('T', 15, termios2);
    pub const IOCGDEV = IOCTL.IOR('T', 0x32, c_uint);
    pub const IOCVHANGUP = IOCTL.IO('T', 0x37);
    pub const IOCGPKT = IOCTL.IOR('T', 0x38, c_int);
    pub const IOCGPTLCK = IOCTL.IOR('T', 0x39, c_int);
    pub const IOCGEXCL = IOCTL.IOR('T', 0x40, c_int);
    pub const IOCGRS485 = IOCTL.IOR('T', 0x41, serial_rs485);
    pub const IOCSRS485 = IOCTL.IOWR('T', 0x42, serial_rs485);
    pub const IOCGISO7816 = IOCTL.IOR('T', 0x43, serial_iso7816);
    pub const IOCSISO7816 = IOCTL.IOWR('T', 0x44, serial_iso7816);

    pub const IOCGETD = IOCTL.IOR('t', 0, c_int);
    pub const IOCSETD = IOCTL.IOW('t', 1, c_int);
    pub const IOCEXCL = IOCTL.IO('t', 13);
    pub const IOCNXCL = IOCTL.IO('t', 14);
    pub const IOCCONS = IOCTL.IO('t', 36);
    pub const IOCGSOFTCAR = IOCTL.IOR('t', 100, c_int);
    pub const IOCSSOFTCAR = IOCTL.IOW('t', 101, c_int);
    pub const IOCSWINSZ = IOCTL.IOW('t', 103, winsize);
    pub const IOCGWINSZ = IOCTL.IOR('t', 104, winsize);
    pub const IOCMGET = IOCTL.IOR('t', 106, c_int);
    pub const IOCMBIC = IOCTL.IOW('t', 107, c_int);
    pub const IOCMBIS = IOCTL.IOW('t', 108, c_int);
    pub const IOCMSET = IOCTL.IOW('t', 109, c_int);
    pub const IOCSTART = IOCTL.IO('t', 110);
    pub const IOCSTOP = IOCTL.IO('t', 111);
    pub const IOCPKT = IOCTL.IOW('t', 112, c_int);
    pub const IOCNOTTY = IOCTL.IO('t', 113);
    pub const IOCSTI = IOCTL.IOW('t', 114, c_char);
    pub const IOCOUTQ = IOCTL.IOR('t', 115, c_int);
    pub const IOCCBRK = IOCTL.IO('t', 122);
    pub const IOCSBRK = IOCTL.IO('t', 123);
    pub const IOCSPGRP = IOCTL.IOW('t', 130, c_int);
    pub const IOCGPGRP = IOCTL.IOR('t', 131, c_int);
    pub const IOCSCTTY = IOCTL.IO('t', 132);
    pub const IOCGSID = IOCTL.IOR('t', 133, c_int);
    pub const IOCGPTN = IOCTL.IOR('t', 134, c_uint);
    pub const IOCSPTLCK = IOCTL.IOW('t', 135, c_int);
    pub const IOCSIG = IOCTL.IOW('t', 136, c_int);
    pub const IOCGPTPEER = IOCTL.IO('t', 137);

    pub const FIOCLEX = IOCTL.IO('f', 1);
    pub const FIONCLEX = IOCTL.IO('f', 2);
    pub const FIOASYNC = IOCTL.IOW('f', 125, c_int);
    pub const FIONBIO = IOCTL.IOW('f', 126, c_int);
    pub const FIONREAD = IOCTL.IOR('f', 127, c_int);
    pub const IOCINQ = FIONREAD;
    pub const FIOQSIZE = IOCTL.IOR('f', 128, c_longlong); // loff_t -> __kernel_loff_t -> long long

    pub const IOCLINUX = 0x541c;
    pub const IOCGSERIAL = 0x541e;
    pub const IOCSSERIAL = 0x541f;
    pub const CSBRKP = 0x5425;
    pub const IOCSERCONFIG = 0x5453;
    pub const IOCSERGWILD = 0x5454;
    pub const IOCSERSWILD = 0x5455;
    pub const IOCGLCKTRMIOS = 0x5456;
    pub const IOCSLCKTRMIOS = 0x5457;
    pub const IOCSERGSTRUCT = 0x5458;
    pub const IOCSERGETLSR = 0x5459;
    pub const IOCSERGETMULTI = 0x545a;
    pub const IOCSERSETMULTI = 0x545b;
    pub const IOCMIWAIT = 0x545c;
    pub const IOCGICOUNT = 0x545d;

    pub const IOCPKT_DATA = 0;
    pub const IOCPKT_FLUSHREAD = 1;
    pub const IOCPKT_FLUSHWRITE = 2;
    pub const IOCPKT_STOP = 4;
    pub const IOCPKT_START = 8;
    pub const IOCPKT_NOSTOP = 16;
    pub const IOCPKT_DOSTOP = 32;
    pub const IOCPKT_IOCTL = 64;
} else struct {
    pub const CGETS = 0x5401;
    pub const CSETS = 0x5402;
    pub const CSETSW = 0x5403;
    pub const CSETSF = 0x5404;
    pub const CGETA = 0x5405;
    pub const CSETA = 0x5406;
    pub const CSETAW = 0x5407;
    pub const CSETAF = 0x5408;
    pub const CSBRK = 0x5409;
    pub const CXONC = 0x540a;
    pub const CFLSH = 0x540b;
    pub const IOCEXCL = 0x540c;
    pub const IOCNXCL = 0x540d;
    pub const IOCSCTTY = 0x540e;
    pub const IOCGPGRP = 0x540f;
    pub const IOCSPGRP = 0x5410;
    pub const IOCOUTQ = 0x5411;
    pub const IOCSTI = 0x5412;
    pub const IOCGWINSZ = 0x5413;
    pub const IOCSWINSZ = 0x5414;
    pub const IOCMGET = 0x5415;
    pub const IOCMBIS = 0x5416;
    pub const IOCMBIC = 0x5417;
    pub const IOCMSET = 0x5418;
    pub const IOCGSOFTCAR = 0x5419;
    pub const IOCSSOFTCAR = 0x541a;
    pub const FIONREAD = 0x541b;
    pub const IOCINQ = FIONREAD;
    pub const IOCLINUX = 0x541c;
    pub const IOCCONS = 0x541d;
    pub const IOCGSERIAL = 0x541e;
    pub const IOCSSERIAL = 0x541f;
    pub const IOCPKT = 0x5420;
    pub const FIONBIO = 0x5421;
    pub const IOCNOTTY = 0x5422;
    pub const IOCSETD = 0x5423;
    pub const IOCGETD = 0x5424;
    pub const CSBRKP = 0x5425;
    pub const IOCSBRK = 0x5427;
    pub const IOCCBRK = 0x5428;
    pub const IOCGSID = 0x5429;
    pub const CGETS2 = IOCTL.IOR('T', 0x2a, termios2);
    pub const CSETS2 = IOCTL.IOW('T', 0x2b, termios2);
    pub const CSETSW2 = IOCTL.IOW('T', 0x2c, termios2);
    pub const CSETSF2 = IOCTL.IOW('T', 0x2d, termios2);
    pub const IOCGRS485 = 0x542e;
    pub const IOCSRS485 = 0x542f;
    pub const IOCGPTN = IOCTL.IOR('T', 0x30, c_uint);
    pub const IOCSPTLCK = IOCTL.IOW('T', 0x31, c_int);
    pub const IOCGDEV = IOCTL.IOR('T', 0x32, c_uint);
    pub const CGETX = 0x5432;
    pub const CSETX = 0x5433;
    pub const CSETXF = 0x5434;
    pub const CSETXW = 0x5435;
    pub const IOCSIG = IOCTL.IOW('T', 0x36, c_int);
    pub const IOCVHANGUP = 0x5437;
    pub const IOCGPKT = IOCTL.IOR('T', 0x38, c_int);
    pub const IOCGPTLCK = IOCTL.IOR('T', 0x39, c_int);
    pub const IOCGEXCL = IOCTL.IOR('T', 0x40, c_int);
    pub const IOCGPTPEER = IOCTL.IO('T', 0x41);
    pub const IOCGISO7816 = IOCTL.IOR('T', 0x42, serial_iso7816);
    pub const IOCSISO7816 = IOCTL.IOWR('T', 0x43, serial_iso7816);

    pub const FIONCLEX = 0x5450;
    pub const FIOCLEX = 0x5451;
    pub const FIOASYNC = 0x5452;
    pub const IOCSERCONFIG = 0x5453;
    pub const IOCSERGWILD = 0x5454;
    pub const IOCSERSWILD = 0x5455;
    pub const IOCGLCKTRMIOS = 0x5456;
    pub const IOCSLCKTRMIOS = 0x5457;
    pub const IOCSERGSTRUCT = 0x5458;
    pub const IOCSERGETLSR = 0x5459;
    pub const IOCSERGETMULTI = 0x545a;
    pub const IOCSERSETMULTI = 0x545b;

    pub const IOCMIWAIT = 0x545c;
    pub const IOCGICOUNT = 0x545d;

    pub const FIOQSIZE = switch (native_arch) {
        .arm,
        .armeb,
        .thumb,
        .thumbeb,
        .m68k,
        .s390x,
        => 0x545e,
        else => 0x5460,
    };

    pub const IOCPKT_DATA = 0;
    pub const IOCPKT_FLUSHREAD = 1;
    pub const IOCPKT_FLUSHWRITE = 2;
    pub const IOCPKT_STOP = 4;
    pub const IOCPKT_START = 8;
    pub const IOCPKT_NOSTOP = 16;
    pub const IOCPKT_DOSTOP = 32;
    pub const IOCPKT_IOCTL = 64;

    pub const IOCSER_TEMT = 0x01;
};

pub const serial_rs485 = extern struct {
    flags: u32,
    delay_rts_before_send: u32,
    delay_rts_after_send: u32,
    extra: extern union {
        _pad1: [5]u32,
        s: extern struct {
            addr_recv: u8,
            addr_dest: u8,
            _pad2: [2]u8,
            _pad3: [4]u32,
        },
    },
};

pub const serial_iso7816 = extern struct {
    flags: u32,
    tg: u32,
    sc_fi: u32,
    sc_di: u32,
    clk: u32,
    _reserved: [5]u32,
};

pub const SER = struct {
    pub const RS485 = struct {
        pub const ENABLED = 1 << 0;
        pub const RTS_ON_SEND = 1 << 1;
        pub const RTS_AFTER_SEND = 1 << 2;
        pub const RX_DURING_TX = 1 << 4;
        pub const TERMINATE_BUS = 1 << 5;
        pub const ADDRB = 1 << 6;
        pub const ADDR_RECV = 1 << 7;
        pub const ADDR_DEST = 1 << 8;
    };

    pub const ISO7816 = struct {
        pub const ENABLED = 1 << 0;
        pub const T_PARAM = 0x0f << 4;

        pub fn T(t: anytype) @TypeOf(t) {
            return (t & 0x0f) << 4;
        }
    };
};

pub const EPOLL = struct {
    pub const CLOEXEC = 1 << @bitOffsetOf(O, "CLOEXEC");

    pub const CTL_ADD = 1;
    pub const CTL_DEL = 2;
    pub const CTL_MOD = 3;

    pub const IN = 0x001;
    pub const PRI = 0x002;
    pub const OUT = 0x004;
    pub const RDNORM = 0x040;
    pub const RDBAND = 0x080;
    pub const WRNORM = if (is_mips) 0x004 else 0x100;
    pub const WRBAND = if (is_mips) 0x100 else 0x200;
    pub const MSG = 0x400;
    pub const ERR = 0x008;
    pub const HUP = 0x010;
    pub const RDHUP = 0x2000;
    pub const EXCLUSIVE = (@as(u32, 1) << 28);
    pub const WAKEUP = (@as(u32, 1) << 29);
    pub const ONESHOT = (@as(u32, 1) << 30);
    pub const ET = (@as(u32, 1) << 31);
};

pub const CLOCK = clockid_t;

pub const clockid_t = enum(u32) {
    REALTIME = 0,
    MONOTONIC = 1,
    PROCESS_CPUTIME_ID = 2,
    THREAD_CPUTIME_ID = 3,
    MONOTONIC_RAW = 4,
    REALTIME_COARSE = 5,
    MONOTONIC_COARSE = 6,
    BOOTTIME = 7,
    REALTIME_ALARM = 8,
    BOOTTIME_ALARM = 9,
    // In the linux kernel header file (time.h) is the following note:
    // * The driver implementing this got removed. The clock ID is kept as a
    // * place holder. Do not reuse!
    // Therefore, calling clock_gettime() with these IDs will result in an error.
    //
    // Some backgrond:
    // - SGI_CYCLE was for Silicon Graphics (SGI) workstations,
    // which are probably no longer in use, so it makes sense to disable
    // - TAI_CLOCK was designed as CLOCK_REALTIME(UTC) + tai_offset,
    // but tai_offset was always 0 in the kernel.
    // So there is no point in using this clock.
    // SGI_CYCLE = 10,
    // TAI = 11,
    _,
};

// For use with posix.timerfd_create()
// Actually, the parameter for the timerfd_create() function is in integer,
// which means that the developer has to figure out which value is appropriate.
// To make this easier and, above all, safer, because an incorrect value leads
// to a panic, an enum is introduced which only allows the values
// that actually work.
pub const TIMERFD_CLOCK = timerfd_clockid_t;
pub const timerfd_clockid_t = enum(u32) {
    REALTIME = 0,
    MONOTONIC = 1,
    BOOTTIME = 7,
    REALTIME_ALARM = 8,
    BOOTTIME_ALARM = 9,
    _,
};

pub const TIMER = packed struct(u32) {
    ABSTIME: bool,
    _: u31 = 0,
};

pub const CSIGNAL = 0x000000ff;

pub const CLONE = struct {
    pub const VM = 0x00000100;
    pub const FS = 0x00000200;
    pub const FILES = 0x00000400;
    pub const SIGHAND = 0x00000800;
    pub const PIDFD = 0x00001000;
    pub const PTRACE = 0x00002000;
    pub const VFORK = 0x00004000;
    pub const PARENT = 0x00008000;
    pub const THREAD = 0x00010000;
    pub const NEWNS = 0x00020000;
    pub const SYSVSEM = 0x00040000;
    pub const SETTLS = 0x00080000;
    pub const PARENT_SETTID = 0x00100000;
    pub const CHILD_CLEARTID = 0x00200000;
    pub const DETACHED = 0x00400000;
    pub const UNTRACED = 0x00800000;
    pub const CHILD_SETTID = 0x01000000;
    pub const NEWCGROUP = 0x02000000;
    pub const NEWUTS = 0x04000000;
    pub const NEWIPC = 0x08000000;
    pub const NEWUSER = 0x10000000;
    pub const NEWPID = 0x20000000;
    pub const NEWNET = 0x40000000;
    pub const IO = 0x80000000;

    // Flags for the clone3() syscall.

    /// Clear any signal handler and reset to SIG_DFL.
    pub const CLEAR_SIGHAND = 0x100000000;
    /// Clone into a specific cgroup given the right permissions.
    pub const INTO_CGROUP = 0x200000000;

    // cloning flags intersect with CSIGNAL so can be used with unshare and clone3 syscalls only.

    /// New time namespace
    pub const NEWTIME = 0x00000080;
};

pub const EFD = struct {
    pub const SEMAPHORE = 1;
    pub const CLOEXEC = 1 << @bitOffsetOf(O, "CLOEXEC");
    pub const NONBLOCK = 1 << @bitOffsetOf(O, "NONBLOCK");
};

pub const MS = struct {
    pub const RDONLY = 1;
    pub const NOSUID = 2;
    pub const NODEV = 4;
    pub const NOEXEC = 8;
    pub const SYNCHRONOUS = 16;
    pub const REMOUNT = 32;
    pub const MANDLOCK = 64;
    pub const DIRSYNC = 128;
    pub const NOATIME = 1024;
    pub const NODIRATIME = 2048;
    pub const BIND = 4096;
    pub const MOVE = 8192;
    pub const REC = 16384;
    pub const SILENT = 32768;
    pub const POSIXACL = (1 << 16);
    pub const UNBINDABLE = (1 << 17);
    pub const PRIVATE = (1 << 18);
    pub const SLAVE = (1 << 19);
    pub const SHARED = (1 << 20);
    pub const RELATIME = (1 << 21);
    pub const KERNMOUNT = (1 << 22);
    pub const I_VERSION = (1 << 23);
    pub const STRICTATIME = (1 << 24);
    pub const LAZYTIME = (1 << 25);
    pub const NOREMOTELOCK = (1 << 27);
    pub const NOSEC = (1 << 28);
    pub const BORN = (1 << 29);
    pub const ACTIVE = (1 << 30);
    pub const NOUSER = (1 << 31);

    pub const RMT_MASK = (RDONLY | SYNCHRONOUS | MANDLOCK | I_VERSION | LAZYTIME);

    pub const MGC_VAL = 0xc0ed0000;
    pub const MGC_MSK = 0xffff0000;
};

pub const MNT = struct {
    pub const FORCE = 1;
    pub const DETACH = 2;
    pub const EXPIRE = 4;
};

pub const UMOUNT_NOFOLLOW = 8;

pub const IN = struct {
    pub const CLOEXEC = 1 << @bitOffsetOf(O, "CLOEXEC");
    pub const NONBLOCK = 1 << @bitOffsetOf(O, "NONBLOCK");

    pub const ACCESS = 0x00000001;
    pub const MODIFY = 0x00000002;
    pub const ATTRIB = 0x00000004;
    pub const CLOSE_WRITE = 0x00000008;
    pub const CLOSE_NOWRITE = 0x00000010;
    pub const CLOSE = CLOSE_WRITE | CLOSE_NOWRITE;
    pub const OPEN = 0x00000020;
    pub const MOVED_FROM = 0x00000040;
    pub const MOVED_TO = 0x00000080;
    pub const MOVE = MOVED_FROM | MOVED_TO;
    pub const CREATE = 0x00000100;
    pub const DELETE = 0x00000200;
    pub const DELETE_SELF = 0x00000400;
    pub const MOVE_SELF = 0x00000800;
    pub const ALL_EVENTS = 0x00000fff;

    pub const UNMOUNT = 0x00002000;
    pub const Q_OVERFLOW = 0x00004000;
    pub const IGNORED = 0x00008000;

    pub const ONLYDIR = 0x01000000;
    pub const DONT_FOLLOW = 0x02000000;
    pub const EXCL_UNLINK = 0x04000000;
    pub const MASK_CREATE = 0x10000000;
    pub const MASK_ADD = 0x20000000;

    pub const ISDIR = 0x40000000;
    pub const ONESHOT = 0x80000000;
};

pub const fanotify = struct {
    pub const InitFlags = packed struct(u32) {
        CLOEXEC: bool = false,
        NONBLOCK: bool = false,
        CLASS: enum(u2) {
            NOTIF = 0,
            CONTENT = 1,
            PRE_CONTENT = 2,
        } = .NOTIF,
        UNLIMITED_QUEUE: bool = false,
        UNLIMITED_MARKS: bool = false,
        ENABLE_AUDIT: bool = false,
        REPORT_PIDFD: bool = false,
        REPORT_TID: bool = false,
        REPORT_FID: bool = false,
        REPORT_DIR_FID: bool = false,
        REPORT_NAME: bool = false,
        REPORT_TARGET_FID: bool = false,
        _: u19 = 0,
    };

    pub const MarkFlags = packed struct(u32) {
        ADD: bool = false,
        REMOVE: bool = false,
        DONT_FOLLOW: bool = false,
        ONLYDIR: bool = false,
        MOUNT: bool = false,
        /// Mutually exclusive with `IGNORE`
        IGNORED_MASK: bool = false,
        IGNORED_SURV_MODIFY: bool = false,
        FLUSH: bool = false,
        FILESYSTEM: bool = false,
        EVICTABLE: bool = false,
        /// Mutually exclusive with `IGNORED_MASK`
        IGNORE: bool = false,
        _: u21 = 0,
    };

    pub const MarkMask = packed struct(u64) {
        /// File was accessed
        ACCESS: bool = false,
        /// File was modified
        MODIFY: bool = false,
        /// Metadata changed
        ATTRIB: bool = false,
        /// Writtable file closed
        CLOSE_WRITE: bool = false,
        /// Unwrittable file closed
        CLOSE_NOWRITE: bool = false,
        /// File was opened
        OPEN: bool = false,
        /// File was moved from X
        MOVED_FROM: bool = false,
        /// File was moved to Y
        MOVED_TO: bool = false,

        /// Subfile was created
        CREATE: bool = false,
        /// Subfile was deleted
        DELETE: bool = false,
        /// Self was deleted
        DELETE_SELF: bool = false,
        /// Self was moved
        MOVE_SELF: bool = false,
        /// File was opened for exec
        OPEN_EXEC: bool = false,
        reserved13: u1 = 0,
        /// Event queued overflowed
        Q_OVERFLOW: bool = false,
        /// Filesystem error
        FS_ERROR: bool = false,

        /// File open in perm check
        OPEN_PERM: bool = false,
        /// File accessed in perm check
        ACCESS_PERM: bool = false,
        /// File open/exec in perm check
        OPEN_EXEC_PERM: bool = false,
        reserved19: u8 = 0,
        /// Interested in child events
        EVENT_ON_CHILD: bool = false,
        /// File was renamed
        RENAME: bool = false,
        reserved30: u1 = 0,
        /// Event occurred against dir
        ONDIR: bool = false,
        reserved31: u33 = 0,
    };

    pub const event_metadata = extern struct {
        event_len: u32,
        vers: u8,
        reserved: u8,
        metadata_len: u16,
        mask: MarkMask align(8),
        fd: i32,
        pid: i32,

        pub const VERSION = 3;
    };

    pub const response = extern struct {
        fd: i32,
        response: u32,
    };

    /// Unique file identifier info record.
    ///
    /// This structure is used for records of types `EVENT_INFO_TYPE.FID`.
    /// `EVENT_INFO_TYPE.DFID` and `EVENT_INFO_TYPE.DFID_NAME`.
    ///
    /// For `EVENT_INFO_TYPE.DFID_NAME` there is additionally a null terminated
    /// name immediately after the file handle.
    pub const event_info_fid = extern struct {
        hdr: event_info_header,
        fsid: kernel_fsid_t,
        /// Following is an opaque struct file_handle that can be passed as
        /// an argument to open_by_handle_at(2).
        handle: [0]u8,
    };

    /// Variable length info record following event metadata.
    pub const event_info_header = extern struct {
        info_type: EVENT_INFO_TYPE,
        pad: u8,
        len: u16,
    };

    pub const EVENT_INFO_TYPE = enum(u8) {
        FID = 1,
        DFID_NAME = 2,
        DFID = 3,
        PIDFD = 4,
        ERROR = 5,
        OLD_DFID_NAME = 10,
        OLD_DFID = 11,
        NEW_DFID_NAME = 12,
        NEW_DFID = 13,
    };
};

pub const file_handle = extern struct {
    handle_bytes: u32,
    handle_type: i32,
    f_handle: [0]u8,
};

pub const kernel_fsid_t = fsid_t;
pub const fsid_t = [2]i32;

pub const S = struct {
    pub const IFMT = 0o170000;

    pub const IFDIR = 0o040000;
    pub const IFCHR = 0o020000;
    pub const IFBLK = 0o060000;
    pub const IFREG = 0o100000;
    pub const IFIFO = 0o010000;
    pub const IFLNK = 0o120000;
    pub const IFSOCK = 0o140000;

    pub const ISUID = 0o4000;
    pub const ISGID = 0o2000;
    pub const ISVTX = 0o1000;
    pub const IRUSR = 0o400;
    pub const IWUSR = 0o200;
    pub const IXUSR = 0o100;
    pub const IRWXU = 0o700;
    pub const IRGRP = 0o040;
    pub const IWGRP = 0o020;
    pub const IXGRP = 0o010;
    pub const IRWXG = 0o070;
    pub const IROTH = 0o004;
    pub const IWOTH = 0o002;
    pub const IXOTH = 0o001;
    pub const IRWXO = 0o007;

    pub fn ISREG(m: mode_t) bool {
        return m & IFMT == IFREG;
    }

    pub fn ISDIR(m: mode_t) bool {
        return m & IFMT == IFDIR;
    }

    pub fn ISCHR(m: mode_t) bool {
        return m & IFMT == IFCHR;
    }

    pub fn ISBLK(m: mode_t) bool {
        return m & IFMT == IFBLK;
    }

    pub fn ISFIFO(m: mode_t) bool {
        return m & IFMT == IFIFO;
    }

    pub fn ISLNK(m: mode_t) bool {
        return m & IFMT == IFLNK;
    }

    pub fn ISSOCK(m: mode_t) bool {
        return m & IFMT == IFSOCK;
    }
};

const TFD_TIMER = packed struct(u32) {
    ABSTIME: bool = false,
    CANCEL_ON_SET: bool = false,
    _: u30 = 0,
};

pub const TFD = switch (native_arch) {
    .sparc, .sparc64 => packed struct(u32) {
        _0: u14 = 0,
        NONBLOCK: bool = false,
        _15: u7 = 0,
        CLOEXEC: bool = false,
        _: u9 = 0,

        pub const TIMER = TFD_TIMER;
    },
    .mips, .mipsel, .mips64, .mips64el => packed struct(u32) {
        _0: u7 = 0,
        NONBLOCK: bool = false,
        _8: u11 = 0,
        CLOEXEC: bool = false,
        _: u12 = 0,

        pub const TIMER = TFD_TIMER;
    },
    .alpha => packed struct(u32) {
        _0: u2 = 0,
        NONBLOCK: bool = false,
        _3: u18 = 0,
        CLOEXEC: bool = false,
        _: u10 = 0,

        pub const TIMER = TFD_TIMER;
    },
    else => packed struct(u32) {
        _0: u11 = 0,
        NONBLOCK: bool = false,
        _12: u7 = 0,
        CLOEXEC: bool = false,
        _: u12 = 0,

        pub const TIMER = TFD_TIMER;
    },
};

const k_sigaction_funcs = struct {
    const handler = ?*align(1) const fn (SIG) callconv(.c) void;
    const restorer = *const fn () callconv(.c) void;
};

/// Kernel sigaction struct, as expected by the `rt_sigaction` syscall.  Includes `restorer` on
/// targets where userspace is responsible for hooking up `rt_sigreturn`.
pub const k_sigaction = switch (native_arch) {
    .mips, .mipsel, .mips64, .mips64el => extern struct {
        flags: c_uint,
        handler: k_sigaction_funcs.handler,
        mask: sigset_t,
    },
    .csky, .hexagon, .loongarch32, .loongarch64, .or1k, .riscv32, .riscv64 => extern struct {
        handler: k_sigaction_funcs.handler,
        flags: c_ulong,
        mask: sigset_t,
    },
    .alpha => extern struct {
        handler: k_sigaction_funcs.handler,
        mask: sigset_t,
        flags: c_int,
    },
    .xtensa, .xtensaeb => extern struct {
        handler: k_sigaction_funcs.handler,
        mask: sigset_t,
        flags: c_ulong,
        restorer: k_sigaction_funcs.restorer,
    },
    else => extern struct {
        handler: k_sigaction_funcs.handler,
        flags: c_ulong,
        restorer: k_sigaction_funcs.restorer,
        mask: sigset_t,
    },
};

/// Kernel Sigaction wrapper for the actual ABI `k_sigaction`.  The Zig
/// linux.zig wrapper library still does some pre-processing on
/// sigaction() calls (to add the `restorer` field).
///
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
pub const Sigaction = struct {
    pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void;
    pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void;

    handler: extern union {
        handler: ?handler_fn,
        sigaction: ?sigaction_fn,
    },
    mask: sigset_t,
    flags: switch (native_arch) {
        .mips, .mipsel, .mips64, .mips64el => c_uint,
        .alpha => c_int,
        else => c_ulong,
    },
};

pub const SFD = struct {
    pub const CLOEXEC = 1 << @bitOffsetOf(O, "CLOEXEC");
    pub const NONBLOCK = 1 << @bitOffsetOf(O, "NONBLOCK");
};

pub const signalfd_siginfo = extern struct {
    signo: u32,
    errno: i32,
    code: i32,
    pid: u32,
    uid: uid_t,
    fd: i32,
    tid: u32,
    band: u32,
    overrun: u32,
    trapno: u32,
    status: i32,
    int: i32,
    ptr: u64,
    utime: u64,
    stime: u64,
    addr: u64,
    addr_lsb: u16,
    __pad2: u16,
    syscall: i32,
    call_addr: u64,
    native_arch: u32,
    __pad: [28]u8,
};

pub const in_port_t = u16;
pub const sa_family_t = u16;
pub const socklen_t = u32;

pub const sockaddr = extern struct {
    family: sa_family_t,
    data: [14]u8,

    pub const SS_MAXSIZE = 128;
    pub const storage = extern struct {
        family: sa_family_t align(8),
        padding: [SS_MAXSIZE - @sizeOf(sa_family_t)]u8 = undefined,

        comptime {
            assert(@sizeOf(storage) == SS_MAXSIZE);
            assert(@alignOf(storage) == 8);
        }
    };

    /// IPv4 socket address
    pub const in = extern struct {
        family: sa_family_t = AF.INET,
        port: in_port_t,
        addr: u32,
        zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
    };

    /// IPv6 socket address
    pub const in6 = extern struct {
        family: sa_family_t = AF.INET6,
        port: in_port_t,
        flowinfo: u32,
        addr: [16]u8,
        scope_id: u32,
    };

    /// UNIX domain socket address
    pub const un = extern struct {
        family: sa_family_t = AF.UNIX,
        path: [108]u8,
    };

    /// Packet socket address
    pub const ll = extern struct {
        family: sa_family_t = AF.PACKET,
        protocol: u16,
        ifindex: i32,
        hatype: u16,
        pkttype: u8,
        halen: u8,
        addr: [8]u8,
    };

    /// Netlink socket address
    pub const nl = extern struct {
        family: sa_family_t = AF.NETLINK,
        __pad1: c_ushort = 0,

        /// port ID
        pid: u32,

        /// multicast groups mask
        groups: u32,
    };

    pub const xdp = extern struct {
        family: u16 = AF.XDP,
        flags: u16,
        ifindex: u32,
        queue_id: u32,
        shared_umem_fd: u32,
    };

    /// Address structure for vSockets
    pub const vm = extern struct {
        family: sa_family_t = AF.VSOCK,
        reserved1: u16 = 0,
        port: u32,
        cid: u32,
        flags: u8,

        /// The total size of this structure should be exactly the same as that of struct sockaddr.
        zero: [3]u8 = @splat(0),
        comptime {
            std.debug.assert(@sizeOf(vm) == @sizeOf(sockaddr));
        }
    };
};

pub const mmsghdr = extern struct {
    hdr: msghdr,
    len: u32,
};

pub const epoll_data = extern union {
    ptr: usize,
    fd: i32,
    u32: u32,
    u64: u64,
};

pub const epoll_event = extern struct {
    events: u32,
    data: epoll_data align(switch (native_arch) {
        .x86_64 => 4,
        else => @alignOf(epoll_data),
    }),
};

pub const VFS_CAP_REVISION_MASK = 0xFF000000;
pub const VFS_CAP_REVISION_SHIFT = 24;
pub const VFS_CAP_FLAGS_MASK = ~@as(u32, VFS_CAP_REVISION_MASK);
pub const VFS_CAP_FLAGS_EFFECTIVE = 0x000001;

pub const VFS_CAP_REVISION_1 = 0x01000000;
pub const VFS_CAP_U32_1 = 1;
pub const XATTR_CAPS_SZ_1 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_1);

pub const VFS_CAP_REVISION_2 = 0x02000000;
pub const VFS_CAP_U32_2 = 2;
pub const XATTR_CAPS_SZ_2 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_2);

pub const XATTR_CAPS_SZ = XATTR_CAPS_SZ_2;
pub const VFS_CAP_U32 = VFS_CAP_U32_2;
pub const VFS_CAP_REVISION = VFS_CAP_REVISION_2;

pub const vfs_cap_data = extern struct {
    //all of these are mandated as little endian
    //when on disk.
    const Data = extern struct {
        permitted: u32,
        inheritable: u32,
    };

    magic_etc: u32,
    data: [VFS_CAP_U32]Data,
};

pub const CAP = struct {
    pub const CHOWN = 0;
    pub const DAC_OVERRIDE = 1;
    pub const DAC_READ_SEARCH = 2;
    pub const FOWNER = 3;
    pub const FSETID = 4;
    pub const KILL = 5;
    pub const SETGID = 6;
    pub const SETUID = 7;
    pub const SETPCAP = 8;
    pub const LINUX_IMMUTABLE = 9;
    pub const NET_BIND_SERVICE = 10;
    pub const NET_BROADCAST = 11;
    pub const NET_ADMIN = 12;
    pub const NET_RAW = 13;
    pub const IPC_LOCK = 14;
    pub const IPC_OWNER = 15;
    pub const SYS_MODULE = 16;
    pub const SYS_RAWIO = 17;
    pub const SYS_CHROOT = 18;
    pub const SYS_PTRACE = 19;
    pub const SYS_PACCT = 20;
    pub const SYS_ADMIN = 21;
    pub const SYS_BOOT = 22;
    pub const SYS_NICE = 23;
    pub const SYS_RESOURCE = 24;
    pub const SYS_TIME = 25;
    pub const SYS_TTY_CONFIG = 26;
    pub const MKNOD = 27;
    pub const LEASE = 28;
    pub const AUDIT_WRITE = 29;
    pub const AUDIT_CONTROL = 30;
    pub const SETFCAP = 31;
    pub const MAC_OVERRIDE = 32;
    pub const MAC_ADMIN = 33;
    pub const SYSLOG = 34;
    pub const WAKE_ALARM = 35;
    pub const BLOCK_SUSPEND = 36;
    pub const AUDIT_READ = 37;
    pub const PERFMON = 38;
    pub const BPF = 39;
    pub const CHECKPOINT_RESTORE = 40;
    pub const LAST_CAP = CHECKPOINT_RESTORE;

    pub fn valid(x: u8) bool {
        return x >= 0 and x <= LAST_CAP;
    }

    pub fn TO_MASK(cap: u8) u32 {
        return @as(u32, 1) << @as(u5, @intCast(cap & 31));
    }

    pub fn TO_INDEX(cap: u8) u8 {
        return cap >> 5;
    }
};

pub const cap_t = extern struct {
    hdrp: *cap_user_header_t,
    datap: *cap_user_data_t,
};

pub const cap_user_header_t = extern struct {
    version: u32,
    pid: usize,
};

pub const cap_user_data_t = extern struct {
    effective: u32,
    permitted: u32,
    inheritable: u32,
};

pub const inotify_event = extern struct {
    wd: i32,
    mask: u32,
    cookie: u32,
    len: u32,
    //name: [?]u8,

    // if an event is returned for a directory or file inside the directory being watched
    // returns the name of said directory/file
    // returns `null` if the directory/file is the one being watched
    pub fn getName(self: *const inotify_event) ?[:0]const u8 {
        if (self.len == 0) return null;
        return std.mem.span(@as([*:0]const u8, @ptrCast(self)) + @sizeOf(inotify_event));
    }
};

pub const dirent64 = extern struct {
    ino: u64,
    off: u64,
    reclen: u16,
    type: u8,
    name: [0]u8,
};

pub const dl_phdr_info = extern struct {
    addr: usize,
    name: ?[*:0]const u8,
    phdr: [*]std.elf.ElfN.Phdr,
    phnum: u16,
};

pub const CPU_SETSIZE = 128;
pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize;
pub const cpu_count_t = @Int(.unsigned, std.math.log2(CPU_SETSIZE * 8));

pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t {
    var sum: cpu_count_t = 0;
    for (set) |x| {
        sum += @popCount(x);
    }
    return sum;
}

pub const MINSIGSTKSZ = switch (native_arch) {
    .arc,
    .arceb,
    .arm,
    .armeb,
    .csky,
    .hexagon,
    .m68k,
    .mips,
    .mipsel,
    .mips64,
    .mips64el,
    .microblaze,
    .microblazeel,
    .or1k,
    .powerpc,
    .powerpcle,
    .riscv32,
    .riscv64,
    .s390x,
    .sh,
    .sheb,
    .thumb,
    .thumbeb,
    .x86,
    .x86_64,
    .xtensa,
    .xtensaeb,
    => 2048,
    .loongarch32,
    .loongarch64,
    .sparc,
    .sparc64,
    => 4096,
    .aarch64,
    .aarch64_be,
    => 5120,
    .powerpc64,
    .powerpc64le,
    => 8192,
    else => @compileError("MINSIGSTKSZ not defined for this architecture"),
};
pub const SIGSTKSZ = switch (native_arch) {
    .arc,
    .arceb,
    .arm,
    .armeb,
    .csky,
    .hexagon,
    .m68k,
    .mips,
    .mipsel,
    .mips64,
    .mips64el,
    .microblaze,
    .microblazeel,
    .or1k,
    .powerpc,
    .powerpcle,
    .riscv32,
    .riscv64,
    .s390x,
    .sh,
    .sheb,
    .thumb,
    .thumbeb,
    .x86,
    .x86_64,
    .xtensa,
    .xtensaeb,
    => 8192,
    .aarch64,
    .aarch64_be,
    .loongarch32,
    .loongarch64,
    .sparc,
    .sparc64,
    => 16384,
    .powerpc64,
    .powerpc64le,
    => 32768,
    else => @compileError("SIGSTKSZ not defined for this architecture"),
};

pub const SS = struct {
    pub const ONSTACK = 1;
    pub const DISABLE = 2;
    pub const AUTODISARM = 1 << 31;
};

pub const stack_t = if (is_mips)
    // IRIX compatible stack_t
    extern struct {
        sp: [*]u8,
        size: usize,
        flags: i32,
    }
else
    extern struct {
        sp: [*]u8,
        flags: i32,
        size: usize,
    };

pub const sigval = extern union {
    int: i32,
    ptr: *anyopaque,
};

const siginfo_fields_union = extern union {
    pad: [128 - 2 * @sizeOf(c_int) - @sizeOf(c_long)]u8,
    common: extern struct {
        first: extern union {
            piduid: extern struct {
                pid: pid_t,
                uid: uid_t,
            },
            timer: extern struct {
                timerid: i32,
                overrun: i32,
            },
        },
        second: extern union {
            value: sigval,
            sigchld: extern struct {
                status: i32,
                utime: clock_t,
                stime: clock_t,
            },
        },
    },
    sigfault: extern struct {
        addr: *allowzero anyopaque,
        addr_lsb: i16,
        first: extern union {
            addr_bnd: extern struct {
                lower: *anyopaque,
                upper: *anyopaque,
            },
            pkey: u32,
        },
    },
    sigpoll: extern struct {
        band: isize,
        fd: i32,
    },
    sigsys: extern struct {
        call_addr: *anyopaque,
        syscall: i32,
        native_arch: u32,
    },
};

pub const CLD = enum(i32) {
    EXITED = 1,
    KILLED = 2,
    DUMPED = 3,
    TRAPPED = 4,
    STOPPED = 5,
    CONTINUED = 6,
    _,
};

pub const siginfo_t = if (is_mips)
    extern struct {
        signo: SIG,
        code: i32,
        errno: i32,
        fields: siginfo_fields_union,
    }
else
    extern struct {
        signo: SIG,
        errno: i32,
        code: i32,
        fields: siginfo_fields_union,
    };

// io_uring_params.flags

/// io_context is polled
pub const IORING_SETUP_IOPOLL = 1 << 0;

/// SQ poll thread
pub const IORING_SETUP_SQPOLL = 1 << 1;

/// sq_thread_cpu is valid
pub const IORING_SETUP_SQ_AFF = 1 << 2;

/// app defines CQ size
pub const IORING_SETUP_CQSIZE = 1 << 3;

/// clamp SQ/CQ ring sizes
pub const IORING_SETUP_CLAMP = 1 << 4;

/// attach to existing wq
pub const IORING_SETUP_ATTACH_WQ = 1 << 5;

/// start with ring disabled
pub const IORING_SETUP_R_DISABLED = 1 << 6;

/// continue submit on error
pub const IORING_SETUP_SUBMIT_ALL = 1 << 7;

/// Cooperative task running. When requests complete, they often require
/// forcing the submitter to transition to the kernel to complete. If this
/// flag is set, work will be done when the task transitions anyway, rather
/// than force an inter-processor interrupt reschedule. This avoids interrupting
/// a task running in userspace, and saves an IPI.
pub const IORING_SETUP_COOP_TASKRUN = 1 << 8;

/// If COOP_TASKRUN is set, get notified if task work is available for
/// running and a kernel transition would be needed to run it. This sets
/// IORING_SQ_TASKRUN in the sq ring flags. Not valid with COOP_TASKRUN.
pub const IORING_SETUP_TASKRUN_FLAG = 1 << 9;

/// SQEs are 128 byte
pub const IORING_SETUP_SQE128 = 1 << 10;
/// CQEs are 32 byte
pub const IORING_SETUP_CQE32 = 1 << 11;

/// Only one task is allowed to submit requests
pub const IORING_SETUP_SINGLE_ISSUER = 1 << 12;

/// Defer running task work to get events.
/// Rather than running bits of task work whenever the task transitions
/// try to do it just before it is needed.
pub const IORING_SETUP_DEFER_TASKRUN = 1 << 13;

/// Application provides ring memory
pub const IORING_SETUP_NO_MMAP = 1 << 14;

/// Register the ring fd in itself for use with
/// IORING_REGISTER_USE_REGISTERED_RING; return a registered fd index rather
/// than an fd.
pub const IORING_SETUP_REGISTERED_FD_ONLY = 1 << 15;

/// Removes indirection through the SQ index array.
pub const IORING_SETUP_NO_SQARRAY = 1 << 16;

/// IO submission data structure (Submission Queue Entry)
pub const io_uring_sqe = @import("linux/io_uring_sqe.zig").io_uring_sqe;

pub const IoUring = @import("linux/IoUring.zig");

/// If sqe->file_index is set to this for opcodes that instantiate a new
/// direct descriptor (like openat/openat2/accept), then io_uring will allocate
/// an available direct descriptor instead of having the application pass one
/// in. The picked direct descriptor will be returned in cqe->res, or -ENFILE
/// if the space is full.
/// Available since Linux 5.19
pub const IORING_FILE_INDEX_ALLOC = maxInt(u32);

pub const IOSQE_BIT = enum(u8) {
    FIXED_FILE,
    IO_DRAIN,
    IO_LINK,
    IO_HARDLINK,
    ASYNC,
    BUFFER_SELECT,
    CQE_SKIP_SUCCESS,

    _,
};

// io_uring_sqe.flags

/// use fixed fileset
pub const IOSQE_FIXED_FILE = 1 << @backingInt(IOSQE_BIT.FIXED_FILE);

/// issue after inflight IO
pub const IOSQE_IO_DRAIN = 1 << @backingInt(IOSQE_BIT.IO_DRAIN);

/// links next sqe
pub const IOSQE_IO_LINK = 1 << @backingInt(IOSQE_BIT.IO_LINK);

/// like LINK, but stronger
pub const IOSQE_IO_HARDLINK = 1 << @backingInt(IOSQE_BIT.IO_HARDLINK);

/// always go async
pub const IOSQE_ASYNC = 1 << @backingInt(IOSQE_BIT.ASYNC);

/// select buffer from buf_group
pub const IOSQE_BUFFER_SELECT = 1 << @backingInt(IOSQE_BIT.BUFFER_SELECT);

/// don't post CQE if request succeeded
/// Available since Linux 5.17
pub const IOSQE_CQE_SKIP_SUCCESS = 1 << @backingInt(IOSQE_BIT.CQE_SKIP_SUCCESS);

pub const IORING_OP = enum(u8) {
    NOP,
    READV,
    WRITEV,
    FSYNC,
    READ_FIXED,
    WRITE_FIXED,
    POLL_ADD,
    POLL_REMOVE,
    SYNC_FILE_RANGE,
    SENDMSG,
    RECVMSG,
    TIMEOUT,
    TIMEOUT_REMOVE,
    ACCEPT,
    ASYNC_CANCEL,
    LINK_TIMEOUT,
    CONNECT,
    FALLOCATE,
    OPENAT,
    CLOSE,
    FILES_UPDATE,
    STATX,
    READ,
    WRITE,
    FADVISE,
    MADVISE,
    SEND,
    RECV,
    OPENAT2,
    EPOLL_CTL,
    SPLICE,
    PROVIDE_BUFFERS,
    REMOVE_BUFFERS,
    TEE,
    SHUTDOWN,
    RENAMEAT,
    UNLINKAT,
    MKDIRAT,
    SYMLINKAT,
    LINKAT,
    MSG_RING,
    FSETXATTR,
    SETXATTR,
    FGETXATTR,
    GETXATTR,
    SOCKET,
    URING_CMD,
    SEND_ZC,
    SENDMSG_ZC,
    READ_MULTISHOT,
    WAITID,
    FUTEX_WAIT,
    FUTEX_WAKE,
    FUTEX_WAITV,
    FIXED_FD_INSTALL,
    FTRUNCATE,
    BIND,
    LISTEN,
    RECV_ZC,

    _,
};
// io_uring_sqe.uring_cmd_flags (rw_flags in the Zig struct)

/// use registered buffer; pass thig flag along with setting sqe->buf_index.
pub const IORING_URING_CMD_FIXED = 1 << 0;

// io_uring_sqe.fsync_flags (rw_flags in the Zig struct)
pub const IORING_FSYNC_DATASYNC = 1 << 0;

// io_uring_sqe.timeout_flags (rw_flags in the Zig struct)
pub const IORING_TIMEOUT_ABS = 1 << 0;
pub const IORING_TIMEOUT_UPDATE = 1 << 1; // Available since Linux 5.11
pub const IORING_TIMEOUT_BOOTTIME = 1 << 2; // Available since Linux 5.15
pub const IORING_TIMEOUT_REALTIME = 1 << 3; // Available since Linux 5.15
pub const IORING_LINK_TIMEOUT_UPDATE = 1 << 4; // Available since Linux 5.15
pub const IORING_TIMEOUT_ETIME_SUCCESS = 1 << 5; // Available since Linux 5.16
pub const IORING_TIMEOUT_CLOCK_MASK = IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME;
pub const IORING_TIMEOUT_UPDATE_MASK = IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE;

// io_uring_sqe.splice_flags (rw_flags in the Zig struct)
// extends splice(2) flags
pub const IORING_SPLICE_F_FD_IN_FIXED = 1 << 31;

// POLL_ADD flags.
// Note that since sqe->poll_events (rw_flags in the Zig struct) is the flag space, the command flags for POLL_ADD are stored in sqe->len.

/// Multishot poll. Sets IORING_CQE_F_MORE if the poll handler will continue to report CQEs on behalf of the same SQE.
pub const IORING_POLL_ADD_MULTI = 1 << 0;
/// Update existing poll request, matching sqe->addr as the old user_data field.
pub const IORING_POLL_UPDATE_EVENTS = 1 << 1;
pub const IORING_POLL_UPDATE_USER_DATA = 1 << 2;
pub const IORING_POLL_ADD_LEVEL = 1 << 3;

// ASYNC_CANCEL flags.

/// Cancel all requests that match the given key
pub const IORING_ASYNC_CANCEL_ALL = 1 << 0;
/// Key off 'fd' for cancelation rather than the request 'user_data'.
pub const IORING_ASYNC_CANCEL_FD = 1 << 1;
/// Match any request
pub const IORING_ASYNC_CANCEL_ANY = 1 << 2;
/// 'fd' passed in is a fixed descriptor. Available since Linux 6.0
pub const IORING_ASYNC_CANCEL_FD_FIXED = 1 << 3;

// send/sendmsg and recv/recvmsg flags (sqe->ioprio)

/// If set, instead of first attempting to send or receive and arm poll if that yields an -EAGAIN result,
/// arm poll upfront and skip the initial transfer attempt.
pub const IORING_RECVSEND_POLL_FIRST = 1 << 0;
/// Multishot recv. Sets IORING_CQE_F_MORE if the handler will continue to report CQEs on behalf of the same SQE.
pub const IORING_RECV_MULTISHOT = 1 << 1;
/// Use registered buffers, the index is stored in the buf_index field.
pub const IORING_RECVSEND_FIXED_BUF = 1 << 2;
/// If set, SEND[MSG]_ZC should report the zerocopy usage in cqe.res for the IORING_CQE_F_NOTIF cqe.
pub const IORING_SEND_ZC_REPORT_USAGE = 1 << 3;
/// If set, send or recv will grab as many buffers from the buffer group ID given and send them all.
/// The completion result will be the number of buffers send, with the starting buffer ID in cqe as per usual.
/// The buffers be contigious from the starting buffer ID.
/// Used with IOSQE_BUFFER_SELECT.
pub const IORING_RECVSEND_BUNDLE = 1 << 4;
/// CQE.RES FOR IORING_CQE_F_NOTIF if IORING_SEND_ZC_REPORT_USAGE was requested
pub const IORING_NOTIF_USAGE_ZC_COPIED = 1 << 31;

/// accept flags stored in sqe->iopri
pub const IORING_ACCEPT_MULTISHOT = 1 << 0;

/// IORING_OP_MSG_RING command types, stored in sqe->addr
pub const IORING_MSG_RING_COMMAND = enum(u8) {
    /// pass sqe->len as 'res' and off as user_data
    DATA = 0,
    /// send a registered fd to another ring
    SEND_FD = 1,
    _,
};

// io_uring_sqe.msg_ring_flags (rw_flags in the Zig struct)

/// Don't post a CQE to the target ring. Not applicable for IORING_MSG_DATA, obviously.
pub const IORING_MSG_RING_CQE_SKIP = 1 << 0;

/// Pass through the flags from sqe->file_index (splice_fd_in in the zig struct) to cqe->flags */
pub const IORING_MSG_RING_FLAGS_PASS = 1 << 1;

// IO completion data structure (Completion Queue Entry)
pub const io_uring_cqe = extern struct {
    /// io_uring_sqe.data submission passed back
    user_data: u64,

    /// result code for this event
    res: i32,
    flags: u32,

    // Followed by 16 bytes of padding if initialized with IORING_SETUP_CQE32, doubling cqe size

    pub fn err(self: io_uring_cqe) E {
        if (self.res > -4096 and self.res < 0) {
            return @as(E, @fromBackingInt(@intCast(-self.res)));
        }
        return .SUCCESS;
    }

    // On successful completion of the provided buffers IO request, the CQE flags field
    // will have IORING_CQE_F_BUFFER set and the selected buffer ID will be indicated by
    // the upper 16-bits of the flags field.
    pub fn buffer_id(self: io_uring_cqe) !u16 {
        if (self.flags & IORING_CQE_F_BUFFER != IORING_CQE_F_BUFFER) {
            return error.NoBufferSelected;
        }
        return @as(u16, @intCast(self.flags >> IORING_CQE_BUFFER_SHIFT));
    }
};

// io_uring_cqe.flags

/// If set, the upper 16 bits are the buffer ID
pub const IORING_CQE_F_BUFFER = 1 << 0;
/// If set, parent SQE will generate more CQE entries.
/// Available since Linux 5.13.
pub const IORING_CQE_F_MORE = 1 << 1;
/// If set, more data to read after socket recv
pub const IORING_CQE_F_SOCK_NONEMPTY = 1 << 2;
/// Set for notification CQEs. Can be used to distinct them from sends.
pub const IORING_CQE_F_NOTIF = 1 << 3;
/// If set, the buffer ID set in the completion will get more completions.
pub const IORING_CQE_F_BUF_MORE = 1 << 4;
pub const IORING_CQE_F_SKIP = 1 << 5;
pub const IORING_CQE_F_32 = 1 << 15;

pub const IORING_CQE_BUFFER_SHIFT = 16;

/// Magic offsets for the application to mmap the data it needs
pub const IORING_OFF_SQ_RING = 0;
pub const IORING_OFF_CQ_RING = 0x8000000;
pub const IORING_OFF_SQES = 0x10000000;

/// Filled with the offset for mmap(2)
pub const io_sqring_offsets = extern struct {
    /// offset of ring head
    head: u32,

    /// offset of ring tail
    tail: u32,

    /// ring mask value
    ring_mask: u32,

    /// entries in ring
    ring_entries: u32,

    /// ring flags
    flags: u32,

    /// number of sqes not submitted
    dropped: u32,

    /// sqe index array
    array: u32,

    resv1: u32,
    user_addr: u64,
};

// io_sqring_offsets.flags

/// needs io_uring_enter wakeup
pub const IORING_SQ_NEED_WAKEUP = 1 << 0;
/// kernel has cqes waiting beyond the cq ring
pub const IORING_SQ_CQ_OVERFLOW = 1 << 1;
/// task should enter the kernel
pub const IORING_SQ_TASKRUN = 1 << 2;

pub const io_cqring_offsets = extern struct {
    head: u32,
    tail: u32,
    ring_mask: u32,
    ring_entries: u32,
    overflow: u32,
    cqes: u32,
    flags: u32,
    resv: u32,
    user_addr: u64,
};

// io_cqring_offsets.flags

/// disable eventfd notifications
pub const IORING_CQ_EVENTFD_DISABLED = 1 << 0;

// io_uring_enter flags
pub const IORING_ENTER_GETEVENTS = 1 << 0;
pub const IORING_ENTER_SQ_WAKEUP = 1 << 1;
pub const IORING_ENTER_SQ_WAIT = 1 << 2;
pub const IORING_ENTER_EXT_ARG = 1 << 3;
pub const IORING_ENTER_REGISTERED_RING = 1 << 4;

pub const io_uring_params = extern struct {
    sq_entries: u32,
    cq_entries: u32,
    flags: u32,
    sq_thread_cpu: u32,
    sq_thread_idle: u32,
    features: u32,
    wq_fd: u32,
    resv: [3]u32,
    sq_off: io_sqring_offsets,
    cq_off: io_cqring_offsets,
};

// io_uring_params.features flags

pub const IORING_FEAT_SINGLE_MMAP = 1 << 0;
pub const IORING_FEAT_NODROP = 1 << 1;
pub const IORING_FEAT_SUBMIT_STABLE = 1 << 2;
pub const IORING_FEAT_RW_CUR_POS = 1 << 3;
pub const IORING_FEAT_CUR_PERSONALITY = 1 << 4;
pub const IORING_FEAT_FAST_POLL = 1 << 5;
pub const IORING_FEAT_POLL_32BITS = 1 << 6;
pub const IORING_FEAT_SQPOLL_NONFIXED = 1 << 7;
pub const IORING_FEAT_EXT_ARG = 1 << 8;
pub const IORING_FEAT_NATIVE_WORKERS = 1 << 9;
pub const IORING_FEAT_RSRC_TAGS = 1 << 10;
pub const IORING_FEAT_CQE_SKIP = 1 << 11;
pub const IORING_FEAT_LINKED_FILE = 1 << 12;

// io_uring_register opcodes and arguments
pub const IORING_REGISTER = enum(u32) {
    REGISTER_BUFFERS,
    UNREGISTER_BUFFERS,
    REGISTER_FILES,
    UNREGISTER_FILES,
    REGISTER_EVENTFD,
    UNREGISTER_EVENTFD,
    REGISTER_FILES_UPDATE,
    REGISTER_EVENTFD_ASYNC,
    REGISTER_PROBE,
    REGISTER_PERSONALITY,
    UNREGISTER_PERSONALITY,
    REGISTER_RESTRICTIONS,
    REGISTER_ENABLE_RINGS,

    // extended with tagging
    REGISTER_FILES2,
    REGISTER_FILES_UPDATE2,
    REGISTER_BUFFERS2,
    REGISTER_BUFFERS_UPDATE,

    // set/clear io-wq thread affinities
    REGISTER_IOWQ_AFF,
    UNREGISTER_IOWQ_AFF,

    // set/get max number of io-wq workers
    REGISTER_IOWQ_MAX_WORKERS,

    // register/unregister io_uring fd with the ring
    REGISTER_RING_FDS,
    UNREGISTER_RING_FDS,

    // register ring based provide buffer group
    REGISTER_PBUF_RING,
    UNREGISTER_PBUF_RING,

    // sync cancelation API
    REGISTER_SYNC_CANCEL,

    // register a range of fixed file slots for automatic slot allocation
    REGISTER_FILE_ALLOC_RANGE,

    // return status information for a buffer group
    REGISTER_PBUF_STATUS,

    // set/clear busy poll settings
    REGISTER_NAPI,
    UNREGISTER_NAPI,

    REGISTER_CLOCK,

    // clone registered buffers from source ring to current ring
    REGISTER_CLONE_BUFFERS,

    // send MSG_RING without having a ring
    REGISTER_SEND_MSG_RING,

    // register a netdev hw rx queue for zerocopy
    REGISTER_ZCRX_IFQ,

    // resize CQ ring
    REGISTER_RESIZE_RINGS,

    REGISTER_MEM_REGION,

    // flag added to the opcode to use a registered ring fd
    REGISTER_USE_REGISTERED_RING = 1 << 31,

    _,
};

/// io_uring_restriction->opcode values
pub const IOWQ_CATEGORIES = enum(u8) {
    BOUND,
    UNBOUND,
};

/// deprecated, see struct io_uring_rsrc_update
pub const io_uring_files_update = extern struct {
    offset: u32,
    resv: u32,
    fds: u64,
};

/// Register a fully sparse file space, rather than pass in an array of all -1 file descriptors.
pub const IORING_RSRC_REGISTER_SPARSE = 1 << 0;

pub const io_uring_rsrc_register = extern struct {
    nr: u32,
    flags: u32,
    resv2: u64,
    data: u64,
    tags: u64,
};

pub const io_uring_rsrc_update = extern struct {
    offset: u32,
    resv: u32,
    data: u64,
};

pub const io_uring_rsrc_update2 = extern struct {
    offset: u32,
    resv: u32,
    data: u64,
    tags: u64,
    nr: u32,
    resv2: u32,
};

pub const io_uring_notification_slot = extern struct {
    tag: u64,
    resv: [3]u64,
};

pub const io_uring_notification_register = extern struct {
    nr_slots: u32,
    resv: u32,
    resv2: u64,
    data: u64,
    resv3: u64,
};

pub const io_uring_napi = extern struct {
    busy_poll_to: u32,
    prefer_busy_poll: u8,
    _pad: [3]u8,
    resv: u64,
};

/// Skip updating fd indexes set to this value in the fd table */
pub const IORING_REGISTER_FILES_SKIP = -2;

pub const IO_URING_OP_SUPPORTED = 1 << 0;

pub const io_uring_probe_op = extern struct {
    op: IORING_OP,
    resv: u8,
    /// IO_URING_OP_* flags
    flags: u16,
    resv2: u32,

    pub fn is_supported(self: @This()) bool {
        return self.flags & IO_URING_OP_SUPPORTED != 0;
    }
};

pub const io_uring_probe = extern struct {
    /// Last opcode supported
    last_op: IORING_OP,
    /// Length of ops[] array below
    ops_len: u8,
    resv: u16,
    resv2: [3]u32,
    ops: [256]io_uring_probe_op,

    /// Is the operation supported on the running kernel.
    pub fn is_supported(self: @This(), op: IORING_OP) bool {
        const i = @backingInt(op);
        if (i > @backingInt(self.last_op) or i >= self.ops_len)
            return false;
        return self.ops[i].is_supported();
    }
};

pub const io_uring_restriction = extern struct {
    opcode: IORING_RESTRICTION,
    arg: extern union {
        /// IORING_RESTRICTION_REGISTER_OP
        register_op: IORING_REGISTER,

        /// IORING_RESTRICTION_SQE_OP
        sqe_op: IORING_OP,

        /// IORING_RESTRICTION_SQE_FLAGS_*
        sqe_flags: u8,
    },
    resv: u8,
    resv2: [3]u32,
};

/// io_uring_restriction->opcode values
pub const IORING_RESTRICTION = enum(u16) {
    /// Allow an io_uring_register(2) opcode
    REGISTER_OP = 0,

    /// Allow an sqe opcode
    SQE_OP = 1,

    /// Allow sqe flags
    SQE_FLAGS_ALLOWED = 2,

    /// Require sqe flags (these flags must be set on each submission)
    SQE_FLAGS_REQUIRED = 3,

    _,
};

pub const IO_URING_SOCKET_OP = enum(u32) {
    SIOCIN = 0,
    SIOCOUTQ = 1,
    GETSOCKOPT = 2,
    SETSOCKOPT = 3,
};

pub const io_uring_buf = extern struct {
    addr: u64,
    len: u32,
    bid: u16,
    resv: u16,
};

pub const io_uring_buf_ring = extern struct {
    resv1: u64,
    resv2: u32,
    resv3: u16,
    tail: u16,
};

/// argument for IORING_(UN)REGISTER_PBUF_RING
pub const io_uring_buf_reg = extern struct {
    ring_addr: u64,
    ring_entries: u32,
    bgid: u16,
    flags: Flags,
    resv: [3]u64,

    pub const Flags = packed struct(u16) {
        _0: u1 = 0,
        /// Incremental buffer consumption.
        inc: bool,
        _: u14 = 0,
    };
};

pub const io_uring_getevents_arg = extern struct {
    sigmask: u64,
    sigmask_sz: u32,
    pad: u32,
    ts: u64,
};

/// Argument for IORING_REGISTER_SYNC_CANCEL
pub const io_uring_sync_cancel_reg = extern struct {
    addr: u64,
    fd: i32,
    flags: u32,
    timeout: kernel_timespec,
    pad: [4]u64,
};

/// Argument for IORING_REGISTER_FILE_ALLOC_RANGE
/// The range is specified as [off, off + len)
pub const io_uring_file_index_range = extern struct {
    off: u32,
    len: u32,
    resv: u64,
};

pub const io_uring_recvmsg_out = extern struct {
    namelen: u32,
    controllen: u32,
    payloadlen: u32,
    flags: u32,
};

pub const utsname = extern struct {
    sysname: [64:0]u8,
    nodename: [64:0]u8,
    release: [64:0]u8,
    version: [64:0]u8,
    machine: [64:0]u8,
    domainname: [64:0]u8,
};
pub const HOST_NAME_MAX = 64;

pub const STATX = packed struct(u32) {
    /// Want `mode & S.IFMT`.
    TYPE: bool = false,
    /// Want `mode & ~S.IFMT`.
    MODE: bool = false,
    /// Want the `nlink` member.
    NLINK: bool = false,
    /// Want the `uid` member.
    UID: bool = false,
    /// Want the `gid` member.
    GID: bool = false,
    /// Want the `atime` member.
    ATIME: bool = false,
    /// Want the `mtime` member.
    MTIME: bool = false,
    /// Want the `ctime` member.
    CTIME: bool = false,
    /// Want the `ino` member.
    INO: bool = false,
    /// Want the `size` member.
    SIZE: bool = false,
    /// Want the `blocks` member.
    BLOCKS: bool = false,
    /// Want the `btime` member.
    BTIME: bool = false,
    /// Want the `mnt_id` member.
    MNT_ID: bool = false,
    /// Want the `dio_mem_align` and `dio_offset_align` members.
    DIOALIGN: bool = false,
    /// Want the `stx_mnt_id` member.
    MNT_ID_UNIQUE: bool = false,
    /// Want the `sub` member.
    SUBVOL: bool = false,
    /// Want the `atomic_write_unit_min`, `atomic_write_unit_max` and
    /// `atomic_write_segments_max` members.
    WRITE_ATOMIC: bool = false,
    /// Want the `dio_read_offset_align` member.
    DIO_READ_ALIGN: bool = false,
    __pad: u13 = 0,
    /// Reserved for future expansion; must not be set.
    __RESERVED: bool = false,

    pub const BASIC_STATS: STATX = @bitCast(@as(u32, 0x7ff));
};

/// Attributes about the state or features of a file as a bitmask.
/// Flags marked [I] correspond to the `FS_IOC_SETFLAGS` values semantically.
/// See [FS_IOC_SETFLAGS(2const)](https://man7.org/linux/man-pages/man2/FS_IOC_GETFLAGS.2const.html)
/// for more.
pub const STATX_ATTR = packed struct(u64) {
    __pad1: u3 = 0,
    /// [I] File is compressed by the fs.
    COMPRESSED: bool = false,
    __pad2: u1 = 0,
    /// [I] File is marked immutable.
    IMMUTABLE: bool = false,
    /// [I] File is append-only.
    APPEND: bool = false,
    /// [I] File is not to be dumped.
    NODUMP: bool = false,
    /// [I] File requires a key to decrypt in the filesystem.
    ENCRYPTED: bool = false,
    /// File names a directory that triggers an automount.
    AUTOMOUNT: bool = false,
    /// File names the root of a mount.
    MOUNT_ROOT: bool = false,
    /// [I] File is protected by the `dm-verity` device.
    VERITY: bool = false,
    /// File is currently in the CPU direct access state.
    /// Does not correspond to the per-inode DAX flag that some filesystems support.
    DAX: bool = false,
    /// File supports atomic write operations.
    WRITE_ATOMIC: bool = false,
    __pad3: u50 = 0,
};

pub const statx_timestamp = extern struct {
    /// Number of seconds before or after `1970-01-01T00:00:00Z`.
    sec: i64,
    /// Number of nanoseconds (0..999,999,999) after `sec`.
    nsec: u32,
    // Reserved for future increases in resolution.
    __pad1: u32,
};

/// Renamed to `Statx` to not conflict with the `statx` function.
pub const Statx = extern struct {
    /// Mask of bits indicating filled fields. Updated with what information
    /// the kernel returned. Callers must check this field since support varies
    /// by kernel version and filesystem.
    mask: STATX,
    /// Block size for filesystem I/O.
    blksize: u32,
    /// Extra file attribute indicators.
    attributes: STATX_ATTR,
    /// Number of hard links.
    nlink: u32,
    /// User ID of owner.
    uid: uid_t,
    /// Group ID of owner.
    gid: gid_t,
    /// File type and mode.
    mode: u16,
    __spare0: u16,
    /// Inode number.
    ino: u64,
    /// Total size in bytes.
    size: u64,
    /// Number of 512B blocks allocated.
    blocks: u64,
    /// Mask to show what's supported in `attributes`.
    attributes_mask: STATX_ATTR,
    /// Last access file timestamp.
    atime: statx_timestamp,
    /// Creation file timestamp.
    btime: statx_timestamp,
    /// Last status change file timestamp.
    ctime: statx_timestamp,
    /// Last modification file timestamp.
    mtime: statx_timestamp,
    /// Major ID, if this file represents a device.
    rdev_major: u32,
    /// Minor ID, if this file represents a device.
    rdev_minor: u32,
    /// Major ID of the device containing the filesystem where this file resides.
    dev_major: u32,
    /// Minor ID of the device containing the filesystem where this file resides.
    dev_minor: u32,
    /// Mount ID
    mnt_id: u64,
    /// Memory buffer alignment for direct I/O.
    dio_mem_align: u32,
    /// File offset alignment for direct I/O.
    dio_offset_align: u32,
    /// Subvolume identifier.
    subvol: u64,
    /// Min atomic write unit in bytes.
    atomic_write_unit_min: u32,
    /// Max atomic write unit in bytes.
    atomic_write_unit_max: u32,
    /// Max atomic write segment count.
    atomic_write_segments_max: u32,
    /// File offset alignment for direct I/O reads.
    dio_read_offset_align: u32,
    /// Optimised max atomic write unit in bytes.
    atomic_write_unit_max_opt: u32,
    __spare2: [1]u32,
    __spare3: [8]u64,
};

comptime {
    assert(@sizeOf(Statx) == 0x100);
}

pub const addrinfo = extern struct {
    flags: AI,
    family: i32,
    socktype: i32,
    protocol: i32,
    addrlen: socklen_t,
    addr: ?*sockaddr,
    canonname: ?[*:0]u8,
    next: ?*addrinfo,
};

pub const AI = packed struct(u32) {
    PASSIVE: bool = false,
    CANONNAME: bool = false,
    NUMERICHOST: bool = false,
    V4MAPPED: bool = false,
    ALL: bool = false,
    ADDRCONFIG: bool = false,
    _6: u4 = 0,
    NUMERICSERV: bool = false,
    _: u21 = 0,
};

pub const IPPORT_RESERVED = 1024;

pub const IPPROTO = struct {
    pub const IP = 0;
    pub const HOPOPTS = 0;
    pub const ICMP = 1;
    pub const IGMP = 2;
    pub const IPIP = 4;
    pub const TCP = 6;
    pub const EGP = 8;
    pub const PUP = 12;
    pub const UDP = 17;
    pub const IDP = 22;
    pub const TP = 29;
    pub const DCCP = 33;
    pub const IPV6 = 41;
    pub const ROUTING = 43;
    pub const FRAGMENT = 44;
    pub const RSVP = 46;
    pub const GRE = 47;
    pub const ESP = 50;
    pub const AH = 51;
    pub const ICMPV6 = 58;
    pub const NONE = 59;
    pub const DSTOPTS = 60;
    pub const MTP = 92;
    pub const BEETPH = 94;
    pub const ENCAP = 98;
    pub const PIM = 103;
    pub const COMP = 108;
    pub const SCTP = 132;
    pub const MH = 135;
    pub const UDPLITE = 136;
    pub const MPLS = 137;
    pub const RAW = 255;
    pub const MAX = 256;
};

pub const tcp_repair_opt = extern struct {
    opt_code: u32,
    opt_val: u32,
};

pub const tcp_repair_window = extern struct {
    snd_wl1: u32,
    snd_wnd: u32,
    max_window: u32,
    rcv_wnd: u32,
    rcv_wup: u32,
};

pub const TcpRepairOption = enum {
    TCP_NO_QUEUE,
    TCP_RECV_QUEUE,
    TCP_SEND_QUEUE,
    TCP_QUEUES_NR,
};

/// why fastopen failed from client perspective
pub const tcp_fastopen_client_fail = enum {
    /// catch-all
    TFO_STATUS_UNSPEC,
    /// if not in TFO_CLIENT_NO_COOKIE mode
    TFO_COOKIE_UNAVAILABLE,
    /// SYN-ACK did not ack SYN data
    TFO_DATA_NOT_ACKED,
    /// SYN-ACK did not ack SYN data after timeout
    TFO_SYN_RETRANSMITTED,
};

/// for TCP_INFO socket option
pub const TCPI_OPT_TIMESTAMPS = 1;
pub const TCPI_OPT_SACK = 2;
pub const TCPI_OPT_WSCALE = 4;
/// ECN was negotiated at TCP session init
pub const TCPI_OPT_ECN = 8;
/// we received at least one packet with ECT
pub const TCPI_OPT_ECN_SEEN = 16;
/// SYN-ACK acked data in SYN sent or rcvd
pub const TCPI_OPT_SYN_DATA = 32;

pub const nfds_t = usize;
pub const pollfd = extern struct {
    fd: fd_t,
    events: i16,
    revents: i16 = undefined,
};

pub const POLL = struct {
    pub const IN = 0x001;
    pub const PRI = 0x002;
    pub const OUT = 0x004;
    pub const ERR = 0x008;
    pub const HUP = 0x010;
    pub const NVAL = 0x020;
    pub const RDNORM = 0x040;
    pub const RDBAND = 0x080;
};

pub const HUGETLB_FLAG_ENCODE_SHIFT = 26;
pub const HUGETLB_FLAG_ENCODE_MASK = 0x3f;
pub const HUGETLB_FLAG_ENCODE_64KB = 16 << HUGETLB_FLAG_ENCODE_SHIFT;
pub const HUGETLB_FLAG_ENCODE_512KB = 19 << HUGETLB_FLAG_ENCODE_SHIFT;
pub const HUGETLB_FLAG_ENCODE_1MB = 20 << HUGETLB_FLAG_ENCODE_SHIFT;
pub const HUGETLB_FLAG_ENCODE_2MB = 21 << HUGETLB_FLAG_ENCODE_SHIFT;
pub const HUGETLB_FLAG_ENCODE_8MB = 23 << HUGETLB_FLAG_ENCODE_SHIFT;
pub const HUGETLB_FLAG_ENCODE_16MB = 24 << HUGETLB_FLAG_ENCODE_SHIFT;
pub const HUGETLB_FLAG_ENCODE_32MB = 25 << HUGETLB_FLAG_ENCODE_SHIFT;
pub const HUGETLB_FLAG_ENCODE_256MB = 28 << HUGETLB_FLAG_ENCODE_SHIFT;
pub const HUGETLB_FLAG_ENCODE_512MB = 29 << HUGETLB_FLAG_ENCODE_SHIFT;
pub const HUGETLB_FLAG_ENCODE_1GB = 30 << HUGETLB_FLAG_ENCODE_SHIFT;
pub const HUGETLB_FLAG_ENCODE_2GB = 31 << HUGETLB_FLAG_ENCODE_SHIFT;
pub const HUGETLB_FLAG_ENCODE_16GB = 34 << HUGETLB_FLAG_ENCODE_SHIFT;

pub const MFD = struct {
    pub const CLOEXEC = 0x0001;
    pub const ALLOW_SEALING = 0x0002;
    pub const HUGETLB = 0x0004;
    pub const ALL_FLAGS = CLOEXEC | ALLOW_SEALING | HUGETLB;

    pub const HUGE_SHIFT = HUGETLB_FLAG_ENCODE_SHIFT;
    pub const HUGE_MASK = HUGETLB_FLAG_ENCODE_MASK;
    pub const HUGE_64KB = HUGETLB_FLAG_ENCODE_64KB;
    pub const HUGE_512KB = HUGETLB_FLAG_ENCODE_512KB;
    pub const HUGE_1MB = HUGETLB_FLAG_ENCODE_1MB;
    pub const HUGE_2MB = HUGETLB_FLAG_ENCODE_2MB;
    pub const HUGE_8MB = HUGETLB_FLAG_ENCODE_8MB;
    pub const HUGE_16MB = HUGETLB_FLAG_ENCODE_16MB;
    pub const HUGE_32MB = HUGETLB_FLAG_ENCODE_32MB;
    pub const HUGE_256MB = HUGETLB_FLAG_ENCODE_256MB;
    pub const HUGE_512MB = HUGETLB_FLAG_ENCODE_512MB;
    pub const HUGE_1GB = HUGETLB_FLAG_ENCODE_1GB;
    pub const HUGE_2GB = HUGETLB_FLAG_ENCODE_2GB;
    pub const HUGE_16GB = HUGETLB_FLAG_ENCODE_16GB;
};

pub const rusage = extern struct {
    utime: timeval,
    stime: timeval,
    maxrss: isize,
    ixrss: isize,
    idrss: isize,
    isrss: isize,
    minflt: isize,
    majflt: isize,
    nswap: isize,
    inblock: isize,
    oublock: isize,
    msgsnd: isize,
    msgrcv: isize,
    nsignals: isize,
    nvcsw: isize,
    nivcsw: isize,
    __reserved: [16]isize = @splat(0),

    pub const SELF = 0;
    pub const CHILDREN = -1;
    pub const THREAD = 1;
};

pub const NCC = if (is_ppc) 10 else 8;
pub const NCCS = if (is_mips)
    23
else if (is_sparc)
    17
else
    19;

pub const speed_t = if (is_ppc) enum(c_uint) {
    B0 = 0x0000000,
    B50 = 0x0000001,
    B75 = 0x0000002,
    B110 = 0x0000003,
    B134 = 0x0000004,
    B150 = 0x0000005,
    B200 = 0x0000006,
    B300 = 0x0000007,
    B600 = 0x0000008,
    B1200 = 0x0000009,
    B1800 = 0x000000a,
    B2400 = 0x000000b,
    B4800 = 0x000000c,
    B9600 = 0x000000d,
    B19200 = 0x000000e,
    B38400 = 0x000000f,

    B57600 = 0x00000010,
    B115200 = 0x00000011,
    B230400 = 0x00000012,
    B460800 = 0x00000013,
    B500000 = 0x00000014,
    B576000 = 0x00000015,
    B921600 = 0x00000016,
    B1000000 = 0x00000017,
    B1152000 = 0x00000018,
    B1500000 = 0x00000019,
    B2000000 = 0x0000001a,
    B2500000 = 0x0000001b,
    B3000000 = 0x0000001c,
    B3500000 = 0x0000001d,
    B4000000 = 0x0000001e,

    pub const EXTA = speed_t.B19200;
    pub const EXTB = speed_t.B38400;
} else if (is_sparc) enum(c_uint) {
    B0 = 0x0000000,
    B50 = 0x0000001,
    B75 = 0x0000002,
    B110 = 0x0000003,
    B134 = 0x0000004,
    B150 = 0x0000005,
    B200 = 0x0000006,
    B300 = 0x0000007,
    B600 = 0x0000008,
    B1200 = 0x0000009,
    B1800 = 0x000000a,
    B2400 = 0x000000b,
    B4800 = 0x000000c,
    B9600 = 0x000000d,
    B19200 = 0x000000e,
    B38400 = 0x000000f,

    B57600 = 0x00001001,
    B115200 = 0x00001002,
    B230400 = 0x00001003,
    B460800 = 0x00001004,
    B76800 = 0x00001005,
    B153600 = 0x00001006,
    B307200 = 0x00001007,
    B614400 = 0x00001008,
    B921600 = 0x00001009,
    B500000 = 0x0000100a,
    B576000 = 0x0000100b,
    B1000000 = 0x0000100c,
    B1152000 = 0x0000100d,
    B1500000 = 0x0000100e,
    B2000000 = 0x0000100f,

    pub const EXTA = speed_t.B19200;
    pub const EXTB = speed_t.B38400;
} else enum(c_uint) {
    B0 = 0x0000000,
    B50 = 0x0000001,
    B75 = 0x0000002,
    B110 = 0x0000003,
    B134 = 0x0000004,
    B150 = 0x0000005,
    B200 = 0x0000006,
    B300 = 0x0000007,
    B600 = 0x0000008,
    B1200 = 0x0000009,
    B1800 = 0x000000a,
    B2400 = 0x000000b,
    B4800 = 0x000000c,
    B9600 = 0x000000d,
    B19200 = 0x000000e,
    B38400 = 0x000000f,

    B57600 = 0x00001001,
    B115200 = 0x00001002,
    B230400 = 0x00001003,
    B460800 = 0x00001004,
    B500000 = 0x00001005,
    B576000 = 0x00001006,
    B921600 = 0x00001007,
    B1000000 = 0x00001008,
    B1152000 = 0x00001009,
    B1500000 = 0x0000100a,
    B2000000 = 0x0000100b,
    B2500000 = 0x0000100c,
    B3000000 = 0x0000100d,
    B3500000 = 0x0000100e,
    B4000000 = 0x0000100f,

    pub const EXTA = speed_t.B19200;
    pub const EXTB = speed_t.B38400;
};

pub const tcflag_t = if (native_arch == .sparc) c_ulong else c_uint;

pub const tc_iflag_t = if (is_ppc or native_arch == .alpha) packed struct(tcflag_t) {
    IGNBRK: bool = false,
    BRKINT: bool = false,
    IGNPAR: bool = false,
    PARMRK: bool = false,
    INPCK: bool = false,
    ISTRIP: bool = false,
    INLCR: bool = false,
    IGNCR: bool = false,
    ICRNL: bool = false,
    IXON: bool = false,
    IXOFF: bool = false,
    IXANY: bool = false,
    IUCLC: bool = false,
    IMAXBEL: bool = false,
    IUTF8: bool = false,
    _15: u17 = 0,
} else packed struct(tcflag_t) {
    IGNBRK: bool = false,
    BRKINT: bool = false,
    IGNPAR: bool = false,
    PARMRK: bool = false,
    INPCK: bool = false,
    ISTRIP: bool = false,
    INLCR: bool = false,
    IGNCR: bool = false,
    ICRNL: bool = false,
    IUCLC: bool = false,
    IXON: bool = false,
    IXANY: bool = false,
    IXOFF: bool = false,
    IMAXBEL: bool = false,
    IUTF8: bool = false,
    _15: u17 = 0,
};

pub const NLDLY = if (is_ppc or native_arch == .alpha) enum(u2) {
    NL0 = 0,
    NL1 = 1,
    NL2 = 2,
    NL3 = 3,
} else enum(u1) {
    NL0 = 0,
    NL1 = 1,
};

pub const CRDLY = enum(u2) {
    CR0 = 0,
    CR1 = 1,
    CR2 = 2,
    CR3 = 3,
};

pub const TABDLY = enum(u2) {
    TAB0 = 0,
    TAB1 = 1,
    TAB2 = 2,
    TAB3 = 3,

    pub const XTABS = TABDLY.TAB3;
};

pub const BSDLY = enum(u1) {
    BS0 = 0,
    BS1 = 1,
};

pub const VTDLY = enum(u1) {
    VT0 = 0,
    VT1 = 1,
};

pub const FFDLY = enum(u1) {
    FF0 = 0,
    FF1 = 1,
};

pub const tc_oflag_t = if (is_ppc or native_arch == .alpha) packed struct(tcflag_t) {
    OPOST: bool = false,
    ONLCR: bool = false,
    OLCUC: bool = false,
    OCRNL: bool = false,
    ONOCR: bool = false,
    ONLRET: bool = false,
    OFILL: bool = false,
    OFDEL: bool = false,
    NLDLY: NLDLY = .NL0,
    TABDLY: TABDLY = .TAB0,
    CRDLY: CRDLY = .CR0,
    FFDLY: FFDLY = .FF0,
    BSDLY: BSDLY = .BS0,
    VTDLY: VTDLY = .VT0,
    _17: u15 = 0,
} else if (is_sparc) packed struct(tcflag_t) {
    OPOST: bool = false,
    OLCUC: bool = false,
    ONLCR: bool = false,
    OCRNL: bool = false,
    ONOCR: bool = false,
    ONLRET: bool = false,
    OFILL: bool = false,
    OFDEL: bool = false,
    NLDLY: NLDLY = .NL0,
    CRDLY: CRDLY = .CR0,
    TABDLY: TABDLY = .TAB0,
    BSDLY: BSDLY = .BS0,
    VTDLY: VTDLY = .VT0,
    FFDLY: FFDLY = .FF0,
    PAGEOUT: bool = false,
    WRAP: bool = false,
    _18: u14 = 0,
} else packed struct(tcflag_t) {
    OPOST: bool = false,
    OLCUC: bool = false,
    ONLCR: bool = false,
    OCRNL: bool = false,
    ONOCR: bool = false,
    ONLRET: bool = false,
    OFILL: bool = false,
    OFDEL: bool = false,
    NLDLY: NLDLY = .NL0,
    CRDLY: CRDLY = .CR0,
    TABDLY: TABDLY = .TAB0,
    BSDLY: BSDLY = .BS0,
    VTDLY: VTDLY = .VT0,
    FFDLY: FFDLY = .FF0,
    _16: u16 = 0,
};

pub const CSIZE = enum(u2) {
    CS5 = 0,
    CS6 = 1,
    CS7 = 2,
    CS8 = 3,
};

pub const tc_cflag_t = if (is_ppc or native_arch == .alpha) packed struct(tcflag_t) {
    _0: u8 = 0,
    CSIZE: CSIZE = .CS5,
    CSTOPB: bool = false,
    CREAD: bool = false,
    PARENB: bool = false,
    PARODD: bool = false,
    HUPCL: bool = false,
    CLOCAL: bool = false,
    _16: u13 = 0,
    ADDRB: bool = false,
    CMSPAR: bool = false,
    CRTSCTS: bool = false,
} else packed struct(tcflag_t) {
    _0: u4 = 0,
    CSIZE: CSIZE = .CS5,
    CSTOPB: bool = false,
    CREAD: bool = false,
    PARENB: bool = false,
    PARODD: bool = false,
    HUPCL: bool = false,
    CLOCAL: bool = false,
    _12: u17 = 0,
    ADDRB: bool = false,
    CMSPAR: bool = false,
    CRTSCTS: bool = false,
};

pub const tc_lflag_t = if (is_mips) packed struct(tcflag_t) {
    ISIG: bool = false,
    ICANON: bool = false,
    XCASE: bool = false,
    ECHO: bool = false,
    ECHOE: bool = false,
    ECHOK: bool = false,
    ECHONL: bool = false,
    NOFLSH: bool = false,
    IEXTEN: bool = false,
    ECHOCTL: bool = false,
    ECHOPRT: bool = false,
    ECHOKE: bool = false,
    _12: u1 = 0,
    FLUSHO: bool = false,
    PENDIN: bool = false,
    TOSTOP: bool = false,
    EXTPROC: bool = false,
    _17: u15 = 0,
} else if (is_ppc or native_arch == .alpha) packed struct(tcflag_t) {
    ECHOKE: bool = false,
    ECHOE: bool = false,
    ECHOK: bool = false,
    ECHO: bool = false,
    ECHONL: bool = false,
    ECHOPRT: bool = false,
    ECHOCTL: bool = false,
    ISIG: bool = false,
    ICANON: bool = false,
    _9: u1 = 0,
    IEXTEN: bool = false,
    _11: u3 = 0,
    XCASE: bool = false,
    _15: u7 = 0,
    TOSTOP: bool = false,
    FLUSHO: bool = false,
    _24: u4 = 0,
    EXTPROC: bool = false,
    PENDIN: bool = false,
    _30: u1 = 0,
    NOFLSH: bool = false,
} else if (is_sparc) packed struct(tcflag_t) {
    ISIG: bool = false,
    ICANON: bool = false,
    XCASE: bool = false,
    ECHO: bool = false,
    ECHOE: bool = false,
    ECHOK: bool = false,
    ECHONL: bool = false,
    NOFLSH: bool = false,
    TOSTOP: bool = false,
    ECHOCTL: bool = false,
    ECHOPRT: bool = false,
    ECHOKE: bool = false,
    DEFECHO: bool = false,
    FLUSHO: bool = false,
    PENDIN: bool = false,
    IEXTEN: bool = false,
    EXTPROC: bool = false,
    _17: u15 = 0,
} else packed struct(tcflag_t) {
    ISIG: bool = false,
    ICANON: bool = false,
    XCASE: bool = false,
    ECHO: bool = false,
    ECHOE: bool = false,
    ECHOK: bool = false,
    ECHONL: bool = false,
    NOFLSH: bool = false,
    TOSTOP: bool = false,
    ECHOCTL: bool = false,
    ECHOPRT: bool = false,
    ECHOKE: bool = false,
    FLUSHO: bool = false,
    _13: u1 = 0,
    PENDIN: bool = false,
    IEXTEN: bool = false,
    EXTPROC: bool = false,
    _17: u15 = 0,
};

pub const cc_t = u8;

/// Indices into the `cc` array in the `termios` struct.
pub const V = if (is_mips) enum(u32) {
    INTR = 0,
    QUIT = 1,
    ERASE = 2,
    KILL = 3,
    MIN = 4,
    TIME = 5,
    EOL2 = 6,
    SWTC = 7,
    START = 8,
    STOP = 9,
    SUSP = 10,
    REPRINT = 12,
    DISCARD = 13,
    WERASE = 14,
    LNEXT = 15,
    EOF = 16,
    EOL = 17,
} else if (is_ppc) enum(u32) {
    INTR = 0,
    QUIT = 1,
    ERASE = 2,
    KILL = 3,
    EOF = 4,
    MIN = 5,
    EOL = 6,
    TIME = 7,
    EOL2 = 8,
    SWTC = 9,
    WERASE = 10,
    REPRINT = 11,
    SUSP = 12,
    START = 13,
    STOP = 14,
    LNEXT = 15,
    DISCARD = 16,
} else if (native_arch == .alpha) enum(u32) {
    EOF = 0,
    EOL = 1,
    EOL2 = 2,
    ERASE = 3,
    WERASE = 4,
    KILL = 5,
    REPRINT = 6,
    SWTC = 7,
    INTR = 8,
    QUIT = 9,
    SUSP = 10,
    START = 12,
    STOP = 13,
    LNEXT = 14,
    DISCARD = 15,
    MIN = 16,
    TIME = 17,
} else enum(u32) {
    INTR = 0,
    QUIT = 1,
    ERASE = 2,
    KILL = 3,
    EOF = 4,
    TIME = 5,
    MIN = 6,
    SWTC = 7,
    START = 8,
    STOP = 9,
    SUSP = 10,
    EOL = 11,
    REPRINT = 12,
    DISCARD = 13,
    WERASE = 14,
    LNEXT = 15,
    EOL2 = 16,
};

pub const TCSA = std.posix.TCSA;

pub const sgttyb = if (is_mips or is_ppc or is_sparc) extern struct {
    ispeed: c_char,
    ospeed: c_char,
    erase: c_char,
    kill: c_char,
    flags: if (is_mips) c_int else c_short,
} else void;

pub const tchars = if (is_mips or is_ppc or is_sparc or native_arch == .alpha) extern struct {
    intrc: c_char,
    quitc: c_char,
    startc: c_char,
    stopc: c_char,
    eofc: c_char,
    brkc: c_char,
} else void;

pub const ltchars = if (is_mips or is_ppc or is_sparc or native_arch == .alpha) extern struct {
    suspc: c_char,
    dsuspc: c_char,
    rprntc: c_char,
    flushc: c_char,
    werasc: c_char,
    lnextc: c_char,
} else void;

pub const termio = extern struct {
    iflag: c_ushort,
    oflag: c_ushort,
    cflag: c_ushort,
    lflag: c_ushort,
    line: if (is_mips) c_char else u8,
    cc: [if (is_mips) NCCS else NCC]u8,
};

pub const termios = if (is_mips or is_sparc) extern struct {
    iflag: tc_iflag_t,
    oflag: tc_oflag_t,
    cflag: tc_cflag_t,
    lflag: tc_lflag_t,
    line: cc_t,
    cc: [NCCS]cc_t,
} else if (is_ppc or native_arch == .alpha) extern struct {
    iflag: tc_iflag_t,
    oflag: tc_oflag_t,
    cflag: tc_cflag_t,
    lflag: tc_lflag_t,
    cc: [NCCS]cc_t,
    line: cc_t,
    ispeed: speed_t,
    ospeed: speed_t,
} else extern struct {
    iflag: tc_iflag_t,
    oflag: tc_oflag_t,
    cflag: tc_cflag_t,
    lflag: tc_lflag_t,
    line: cc_t,
    cc: [NCCS]cc_t,
    ispeed: speed_t,
    ospeed: speed_t,
};

pub const termios2 = if (is_mips or native_arch == .alpha) extern struct {
    iflag: tc_iflag_t,
    oflag: tc_oflag_t,
    cflag: tc_cflag_t,
    lflag: tc_lflag_t,
    cc: [NCCS]cc_t,
    line: cc_t,
    ispeed: speed_t,
    ospeed: speed_t,
} else extern struct {
    iflag: tc_iflag_t,
    oflag: tc_oflag_t,
    cflag: tc_cflag_t,
    lflag: tc_lflag_t,
    line: cc_t,
    cc: [NCCS + if (is_sparc) 2 else 0]cc_t,
    ispeed: speed_t,
    ospeed: speed_t,
};

/// Linux-specific socket ioctls
pub const SIOCINQ = T.FIONREAD;

/// Linux-specific socket ioctls
/// output queue size (not sent + not acked)
pub const SIOCOUTQ = T.IOCOUTQ;

pub const SOCK_IOC_TYPE = 0x89;

pub const SIOCGSTAMP_NEW = IOCTL.IOR(SOCK_IOC_TYPE, 0x06, [2]i64);
pub const SIOCGSTAMP_OLD = IOCTL.IOR('s', 100, timeval);

/// Get stamp (timeval)
pub const SIOCGSTAMP = if (native_arch == .x86_64 or @sizeOf(timeval) == 8) SIOCGSTAMP_OLD else SIOCGSTAMP_NEW;

pub const SIOCGSTAMPNS_NEW = IOCTL.IOR(SOCK_IOC_TYPE, 0x07, [2]i64);
pub const SIOCGSTAMPNS_OLD = IOCTL.IOR('s', 101, kernel_timespec);

/// Get stamp (timespec)
pub const SIOCGSTAMPNS = if (native_arch == .x86_64 or @sizeOf(timespec) == 8) SIOCGSTAMPNS_OLD else SIOCGSTAMPNS_NEW;

// Routing table calls.
/// Add routing table entry
pub const SIOCADDRT = 0x890B;

/// Delete routing table entry
pub const SIOCDELRT = 0x890C;

/// Unused
pub const SIOCRTMSG = 0x890D;

// Socket configuration controls.
/// Get iface name
pub const SIOCGIFNAME = 0x8910;

/// Set iface channel
pub const SIOCSIFLINK = 0x8911;

/// Get iface list
pub const SIOCGIFCONF = 0x8912;

/// Get flags
pub const SIOCGIFFLAGS = 0x8913;

/// Set flags
pub const SIOCSIFFLAGS = 0x8914;

/// Get PA address
pub const SIOCGIFADDR = 0x8915;

/// Set PA address
pub const SIOCSIFADDR = 0x8916;

/// Get remote PA address
pub const SIOCGIFDSTADDR = 0x8917;

/// Set remote PA address
pub const SIOCSIFDSTADDR = 0x8918;

/// Get broadcast PA address
pub const SIOCGIFBRDADDR = 0x8919;

/// Set broadcast PA address
pub const SIOCSIFBRDADDR = 0x891a;

/// Get network PA mask
pub const SIOCGIFNETMASK = 0x891b;

/// Set network PA mask
pub const SIOCSIFNETMASK = 0x891c;

/// Get metric
pub const SIOCGIFMETRIC = 0x891d;

/// Set metric
pub const SIOCSIFMETRIC = 0x891e;

/// Get memory address (BSD)
pub const SIOCGIFMEM = 0x891f;

/// Set memory address (BSD)
pub const SIOCSIFMEM = 0x8920;

/// Get MTU size
pub const SIOCGIFMTU = 0x8921;

/// Set MTU size
pub const SIOCSIFMTU = 0x8922;

/// Set interface name
pub const SIOCSIFNAME = 0x8923;

/// Set hardware address
pub const SIOCSIFHWADDR = 0x8924;

/// Get encapsulations
pub const SIOCGIFENCAP = 0x8925;

/// Set encapsulations
pub const SIOCSIFENCAP = 0x8926;

/// Get hardware address
pub const SIOCGIFHWADDR = 0x8927;

/// Driver slaving support
pub const SIOCGIFSLAVE = 0x8929;

/// Driver slaving support
pub const SIOCSIFSLAVE = 0x8930;

/// Add to Multicast address lists
pub const SIOCADDMULTI = 0x8931;

/// Delete from Multicast address lists
pub const SIOCDELMULTI = 0x8932;

/// name -> if_index mapping
pub const SIOCGIFINDEX = 0x8933;

/// Set extended flags set
pub const SIOCSIFPFLAGS = 0x8934;

/// Get extended flags set
pub const SIOCGIFPFLAGS = 0x8935;

/// Delete PA address
pub const SIOCDIFADDR = 0x8936;

/// Set hardware broadcast addr
pub const SIOCSIFHWBROADCAST = 0x8937;

/// Get number of devices
pub const SIOCGIFCOUNT = 0x8938;

/// Bridging support
pub const SIOCGIFBR = 0x8940;

/// Set bridging options
pub const SIOCSIFBR = 0x8941;

/// Get the tx queue length
pub const SIOCGIFTXQLEN = 0x8942;

/// Set the tx queue length
pub const SIOCSIFTXQLEN = 0x8943;

/// Ethtool interface
pub const SIOCETHTOOL = 0x8946;

/// Get address of MII PHY in use.
pub const SIOCGMIIPHY = 0x8947;

/// Read MII PHY register.
pub const SIOCGMIIREG = 0x8948;

/// Write MII PHY register.
pub const SIOCSMIIREG = 0x8949;

/// Get / Set netdev parameters
pub const SIOCWANDEV = 0x894A;

/// Output queue size (not sent only)
pub const SIOCOUTQNSD = 0x894B;

/// Get socket network namespace
pub const SIOCGSKNS = 0x894C;

// ARP cache control calls.
//  0x8950 - 0x8952 obsolete calls.
/// Delete ARP table entry
pub const SIOCDARP = 0x8953;

/// Get ARP table entry
pub const SIOCGARP = 0x8954;

/// Set ARP table entry
pub const SIOCSARP = 0x8955;

// RARP cache control calls.
/// Delete RARP table entry
pub const SIOCDRARP = 0x8960;

/// Get RARP table entry
pub const SIOCGRARP = 0x8961;

/// Set RARP table entry
pub const SIOCSRARP = 0x8962;

// Driver configuration calls
/// Get device parameters
pub const SIOCGIFMAP = 0x8970;

/// Set device parameters
pub const SIOCSIFMAP = 0x8971;

// DLCI configuration calls
/// Create new DLCI device
pub const SIOCADDDLCI = 0x8980;

/// Delete DLCI device
pub const SIOCDELDLCI = 0x8981;

/// 802.1Q VLAN support
pub const SIOCGIFVLAN = 0x8982;

/// Set 802.1Q VLAN options
pub const SIOCSIFVLAN = 0x8983;

// bonding calls
/// Enslave a device to the bond
pub const SIOCBONDENSLAVE = 0x8990;

/// Release a slave from the bond
pub const SIOCBONDRELEASE = 0x8991;

/// Set the hw addr of the bond
pub const SIOCBONDSETHWADDR = 0x8992;

/// rtn info about slave state
pub const SIOCBONDSLAVEINFOQUERY = 0x8993;

/// rtn info about bond state
pub const SIOCBONDINFOQUERY = 0x8994;

/// Update to a new active slave
pub const SIOCBONDCHANGEACTIVE = 0x8995;

// Bridge calls
/// Create new bridge device
pub const SIOCBRADDBR = 0x89a0;

/// Remove bridge device
pub const SIOCBRDELBR = 0x89a1;

/// Add interface to bridge
pub const SIOCBRADDIF = 0x89a2;

/// Remove interface from bridge
pub const SIOCBRDELIF = 0x89a3;

/// Get hardware time stamp config
pub const SIOCSHWTSTAMP = 0x89b0;

/// Set hardware time stamp config
pub const SIOCGHWTSTAMP = 0x89b1;

/// Device private ioctl calls
pub const SIOCDEVPRIVATE = 0x89F0;

/// These 16 ioctl calls are protocol private
pub const SIOCPROTOPRIVATE = 0x89E0;

pub const IFNAMESIZE = 16;

pub const IFF = packed struct(u16) {
    UP: bool = false,
    BROADCAST: bool = false,
    DEBUG: bool = false,
    LOOPBACK: bool = false,
    POINTOPOINT: bool = false,
    NOTRAILERS: bool = false,
    RUNNING: bool = false,
    NOARP: bool = false,
    PROMISC: bool = false,
    _9: u7 = 0,
};

pub const ifmap = extern struct {
    mem_start: usize,
    mem_end: usize,
    base_addr: u16,
    irq: u8,
    dma: u8,
    port: u8,
};

pub const ifreq = extern struct {
    ifrn: extern union {
        name: [IFNAMESIZE]u8,
    },
    ifru: extern union {
        addr: sockaddr,
        dstaddr: sockaddr,
        broadaddr: sockaddr,
        netmask: sockaddr,
        hwaddr: sockaddr,
        flags: IFF,
        ivalue: i32,
        mtu: i32,
        map: ifmap,
        slave: [IFNAMESIZE - 1:0]u8,
        newname: [IFNAMESIZE - 1:0]u8,
        data: ?[*]u8,
    },
};

pub const PACKET = struct {
    pub const HOST = 0;
    pub const BROADCAST = 1;
    pub const MULTICAST = 2;
    pub const OTHERHOST = 3;
    pub const OUTGOING = 4;
    pub const LOOPBACK = 5;
    pub const USER = 6;
    pub const KERNEL = 7;

    pub const ADD_MEMBERSHIP = 1;
    pub const DROP_MEMBERSHIP = 2;
    pub const RECV_OUTPUT = 3;
    pub const RX_RING = 5;
    pub const STATISTICS = 6;
    pub const COPY_THRESH = 7;
    pub const AUXDATA = 8;
    pub const ORIGDEV = 9;
    pub const VERSION = 10;
    pub const HDRLEN = 11;
    pub const RESERVE = 12;
    pub const TX_RING = 13;
    pub const LOSS = 14;
    pub const VNET_HDR = 15;
    pub const TX_TIMESTAMP = 16;
    pub const TIMESTAMP = 17;
    pub const FANOUT = 18;
    pub const TX_HAS_OFF = 19;
    pub const QDISC_BYPASS = 20;
    pub const ROLLOVER_STATS = 21;
    pub const FANOUT_DATA = 22;
    pub const IGNORE_OUTGOING = 23;
    pub const VNET_HDR_SZ = 24;

    pub const FANOUT_HASH = 0;
    pub const FANOUT_LB = 1;
    pub const FANOUT_CPU = 2;
    pub const FANOUT_ROLLOVER = 3;
    pub const FANOUT_RND = 4;
    pub const FANOUT_QM = 5;
    pub const FANOUT_CBPF = 6;
    pub const FANOUT_EBPF = 7;
    pub const FANOUT_FLAG_ROLLOVER = 0x1000;
    pub const FANOUT_FLAG_UNIQUEID = 0x2000;
    pub const FANOUT_FLAG_IGNORE_OUTGOING = 0x4000;
    pub const FANOUT_FLAG_DEFRAG = 0x8000;
};

pub const tpacket_versions = enum(u32) {
    V1 = 0,
    V2 = 1,
    V3 = 2,
};

pub const tpacket_req3 = extern struct {
    block_size: c_uint, // Minimal size of contiguous block
    block_nr: c_uint, // Number of blocks
    frame_size: c_uint, // Size of frame
    frame_nr: c_uint, // Total number of frames
    retire_blk_tov: c_uint, // Timeout in msecs
    sizeof_priv: c_uint, // Offset to private data area
    feature_req_word: c_uint,
};

pub const tpacket_bd_ts = extern struct {
    sec: c_uint,
    frac: extern union {
        usec: c_uint,
        nsec: c_uint,
    },
};

pub const TP_STATUS = extern union {
    rx: packed struct(u32) {
        USER: bool,
        COPY: bool,
        LOSING: bool,
        CSUMNOTREADY: bool,
        VLAN_VALID: bool,
        BLK_TMO: bool,
        VLAN_TPID_VALID: bool,
        CSUM_VALID: bool,
        GSO_TCP: bool,
        _: u20,
        TS_SOFTWARE: bool,
        TS_SYS_HARDWARE: bool,
        TS_RAW_HARDWARE: bool,
    },
    tx: packed struct(u32) {
        SEND_REQUEST: bool,
        SENDING: bool,
        WRONG_FORMAT: bool,
        _: u26,
        TS_SOFTWARE: bool,
        TS_SYS_HARDWARE: bool,
        TS_RAW_HARDWARE: bool,
    },
};

pub const tpacket_hdr_v1 = extern struct {
    block_status: TP_STATUS,
    num_pkts: u32,
    offset_to_first_pkt: u32,
    blk_len: u32,
    seq_num: u64 align(8),
    ts_first_pkt: tpacket_bd_ts,
    ts_last_pkt: tpacket_bd_ts,
};

pub const tpacket_bd_header_u = extern union {
    bh1: tpacket_hdr_v1,
};

pub const tpacket_block_desc = extern struct {
    version: u32,
    offset_to_priv: u32,
    hdr: tpacket_bd_header_u,
};

pub const tpacket_hdr_variant1 = extern struct {
    rxhash: u32,
    vlan_tci: u32,
    vlan_tpid: u16,
    padding: u16,
};

pub const tpacket3_hdr = extern struct {
    next_offset: u32,
    sec: u32,
    nsec: u32,
    snaplen: u32,
    len: u32,
    status: u32,
    mac: u16,
    net: u16,
    variant: extern union {
        hv1: tpacket_hdr_variant1,
    },
    padding: [8]u8,
};

pub const tpacket_stats_v3 = extern struct {
    packets: c_uint,
    drops: c_uint,
    freeze_q_cnt: c_uint,
};

// doc comments copied from musl
pub const rlimit_resource = if (native_arch.isMIPS()) enum(c_int) {
    /// Per-process CPU limit, in seconds.
    CPU = 0,

    /// Largest file that can be created, in bytes.
    FSIZE = 1,

    /// Maximum size of data segment, in bytes.
    DATA = 2,

    /// Maximum size of stack segment, in bytes.
    STACK = 3,

    /// Largest core file that can be created, in bytes.
    CORE = 4,

    /// Number of open files.
    NOFILE = 5,

    /// Address space limit.
    AS = 6,

    /// Largest resident set size, in bytes.
    /// This affects swapping; processes that are exceeding their
    /// resident set size will be more likely to have physical memory
    /// taken from them.
    RSS = 7,

    /// Number of processes.
    NPROC = 8,

    /// Locked-in-memory address space.
    MEMLOCK = 9,

    /// Maximum number of file locks.
    LOCKS = 10,

    /// Maximum number of pending signals.
    SIGPENDING = 11,

    /// Maximum bytes in POSIX message queues.
    MSGQUEUE = 12,

    /// Maximum nice priority allowed to raise to.
    /// Nice levels 19 .. -20 correspond to 0 .. 39
    /// values of this resource limit.
    NICE = 13,

    /// Maximum realtime priority allowed for non-privileged
    /// processes.
    RTPRIO = 14,

    /// Maximum CPU time in µs that a process scheduled under a real-time
    /// scheduling policy may consume without making a blocking system
    /// call before being forcibly descheduled.
    RTTIME = 15,

    _,
} else if (native_arch.isSPARC()) enum(c_int) {
    /// Per-process CPU limit, in seconds.
    CPU = 0,

    /// Largest file that can be created, in bytes.
    FSIZE = 1,

    /// Maximum size of data segment, in bytes.
    DATA = 2,

    /// Maximum size of stack segment, in bytes.
    STACK = 3,

    /// Largest core file that can be created, in bytes.
    CORE = 4,

    /// Largest resident set size, in bytes.
    /// This affects swapping; processes that are exceeding their
    /// resident set size will be more likely to have physical memory
    /// taken from them.
    RSS = 5,

    /// Number of open files.
    NOFILE = 6,

    /// Number of processes.
    NPROC = 7,

    /// Locked-in-memory address space.
    MEMLOCK = 8,

    /// Address space limit.
    AS = 9,

    /// Maximum number of file locks.
    LOCKS = 10,

    /// Maximum number of pending signals.
    SIGPENDING = 11,

    /// Maximum bytes in POSIX message queues.
    MSGQUEUE = 12,

    /// Maximum nice priority allowed to raise to.
    /// Nice levels 19 .. -20 correspond to 0 .. 39
    /// values of this resource limit.
    NICE = 13,

    /// Maximum realtime priority allowed for non-privileged
    /// processes.
    RTPRIO = 14,

    /// Maximum CPU time in µs that a process scheduled under a real-time
    /// scheduling policy may consume without making a blocking system
    /// call before being forcibly descheduled.
    RTTIME = 15,

    _,
} else if (native_arch == .alpha) enum(c_int) {
    /// Per-process CPU limit, in seconds.
    CPU = 0,
    /// Largest file that can be created, in bytes.
    FSIZE = 1,
    /// Maximum size of data segment, in bytes.
    DATA = 2,
    /// Maximum size of stack segment, in bytes.
    STACK = 3,
    /// Largest core file that can be created, in bytes.
    CORE = 4,
    /// Largest resident set size, in bytes.
    /// This affects swapping; processes that are exceeding their
    /// resident set size will be more likely to have physical memory
    /// taken from them.
    RSS = 5,
    /// Number of open files.
    NOFILE = 6,
    /// Address space limit.
    AS = 7,
    /// Number of processes.
    NPROC = 8,
    /// Locked-in-memory address space.
    MEMLOCK = 9,
    /// Maximum number of file locks.
    LOCKS = 10,
    /// Maximum number of pending signals.
    SIGPENDING = 11,
    /// Maximum bytes in POSIX message queues.
    MSGQUEUE = 12,
    /// Maximum nice priority allowed to raise to.
    /// Nice levels 19 .. -20 correspond to 0 .. 39
    /// values of this resource limit.
    NICE = 13,
    /// Maximum realtime priority allowed for non-privileged
    /// processes.
    RTPRIO = 14,
    /// Maximum CPU time in µs that a process scheduled under a real-time
    /// scheduling policy may consume without making a blocking system
    /// call before being forcibly descheduled.
    RTTIME = 15,

    _,
} else enum(c_int) {
    /// Per-process CPU limit, in seconds.
    CPU = 0,
    /// Largest file that can be created, in bytes.
    FSIZE = 1,
    /// Maximum size of data segment, in bytes.
    DATA = 2,
    /// Maximum size of stack segment, in bytes.
    STACK = 3,
    /// Largest core file that can be created, in bytes.
    CORE = 4,
    /// Largest resident set size, in bytes.
    /// This affects swapping; processes that are exceeding their
    /// resident set size will be more likely to have physical memory
    /// taken from them.
    RSS = 5,
    /// Number of processes.
    NPROC = 6,
    /// Number of open files.
    NOFILE = 7,
    /// Locked-in-memory address space.
    MEMLOCK = 8,
    /// Address space limit.
    AS = 9,
    /// Maximum number of file locks.
    LOCKS = 10,
    /// Maximum number of pending signals.
    SIGPENDING = 11,
    /// Maximum bytes in POSIX message queues.
    MSGQUEUE = 12,
    /// Maximum nice priority allowed to raise to.
    /// Nice levels 19 .. -20 correspond to 0 .. 39
    /// values of this resource limit.
    NICE = 13,
    /// Maximum realtime priority allowed for non-privileged
    /// processes.
    RTPRIO = 14,
    /// Maximum CPU time in µs that a process scheduled under a real-time
    /// scheduling policy may consume without making a blocking system
    /// call before being forcibly descheduled.
    RTTIME = 15,

    _,
};

pub const rlim_t = u64;

pub const RLIM = struct {
    /// No limit
    pub const INFINITY: rlim_t = if (native_arch == .alpha)
        ~@as(u63, 0)
    else
        ~@as(rlim_t, 0);

    pub const SAVED_MAX = INFINITY;
    pub const SAVED_CUR = INFINITY;
};

pub const rlimit = extern struct {
    /// Soft limit
    cur: rlim_t,
    /// Hard limit
    max: rlim_t,
};

pub const MADV = struct {
    pub const NORMAL = 0;
    pub const RANDOM = 1;
    pub const SEQUENTIAL = 2;
    pub const WILLNEED = 3;
    pub const DONTNEED = 4;
    pub const FREE = 8;
    pub const REMOVE = 9;
    pub const DONTFORK = 10;
    pub const DOFORK = 11;
    pub const MERGEABLE = 12;
    pub const UNMERGEABLE = 13;
    pub const HUGEPAGE = 14;
    pub const NOHUGEPAGE = 15;
    pub const DONTDUMP = 16;
    pub const DODUMP = 17;
    pub const WIPEONFORK = 18;
    pub const KEEPONFORK = 19;
    pub const COLD = 20;
    pub const PAGEOUT = 21;
    pub const HWPOISON = 100;
    pub const SOFT_OFFLINE = 101;
};

pub const POSIX_FADV = switch (native_arch) {
    .s390x => if (@typeInfo(usize).int.bits == 64) struct {
        pub const NORMAL = 0;
        pub const RANDOM = 1;
        pub const SEQUENTIAL = 2;
        pub const WILLNEED = 3;
        pub const DONTNEED = 6;
        pub const NOREUSE = 7;
    } else struct {
        pub const NORMAL = 0;
        pub const RANDOM = 1;
        pub const SEQUENTIAL = 2;
        pub const WILLNEED = 3;
        pub const DONTNEED = 4;
        pub const NOREUSE = 5;
    },
    else => struct {
        pub const NORMAL = 0;
        pub const RANDOM = 1;
        pub const SEQUENTIAL = 2;
        pub const WILLNEED = 3;
        pub const DONTNEED = 4;
        pub const NOREUSE = 5;
    },
};

pub const timeval = extern struct {
    sec: isize,
    usec: i64,
};

pub const timezone = extern struct {
    minuteswest: i32,
    dsttime: i32,
};

/// The timespec struct used by the kernel.
pub const kernel_timespec = extern struct {
    sec: i64,
    nsec: i64,

    /// For use with `utimensat` and `futimens`.
    pub const NOW: timespec = .{
        .sec = 0,
        .nsec = 0x3fffffff,
    };

    /// For use with `utimensat` and `futimens`.
    pub const OMIT: timespec = .{
        .sec = 0,
        .nsec = 0x3ffffffe,
    };
};

/// For use with `utimensat` and `futimens`.
pub const UTIME = struct {
    pub const NOW: timespec = .{ .sec = 0, .nsec = 0x3fffffff };
    pub const OMIT: timespec = .{ .sec = 0, .nsec = 0x3ffffffe };
};

// https://github.com/ziglang/zig/issues/4726#issuecomment-2190337877
const use_kernel_timespec = native_arch == .hexagon or native_arch == .riscv32 or switch (native_abi) {
    .gnux32, .muslx32, .x32 => true,
    else => false,
};
pub const timespec = if (use_kernel_timespec) kernel_timespec else extern struct {
    sec: isize,
    nsec: isize,
};

pub const XDP = struct {
    pub const SHARED_UMEM = (1 << 0);
    pub const COPY = (1 << 1);
    pub const ZEROCOPY = (1 << 2);
    pub const UMEM_UNALIGNED_CHUNK_FLAG = (1 << 0);
    pub const USE_NEED_WAKEUP = (1 << 3);

    pub const MMAP_OFFSETS = 1;
    pub const RX_RING = 2;
    pub const TX_RING = 3;
    pub const UMEM_REG = 4;
    pub const UMEM_FILL_RING = 5;
    pub const UMEM_COMPLETION_RING = 6;
    pub const STATISTICS = 7;
    pub const OPTIONS = 8;

    pub const OPTIONS_ZEROCOPY = (1 << 0);

    pub const PGOFF_RX_RING = 0;
    pub const PGOFF_TX_RING = 0x80000000;
    pub const UMEM_PGOFF_FILL_RING = 0x100000000;
    pub const UMEM_PGOFF_COMPLETION_RING = 0x180000000;
};

pub const xdp_ring_offset = extern struct {
    producer: u64,
    consumer: u64,
    desc: u64,
    flags: u64,
};

pub const xdp_mmap_offsets = extern struct {
    rx: xdp_ring_offset,
    tx: xdp_ring_offset,
    fr: xdp_ring_offset,
    cr: xdp_ring_offset,
};

pub const xdp_umem_reg = extern struct {
    addr: u64,
    len: u64,
    chunk_size: u32,
    headroom: u32,
    flags: u32,
};

pub const xdp_statistics = extern struct {
    rx_dropped: u64,
    rx_invalid_descs: u64,
    tx_invalid_descs: u64,
    rx_ring_full: u64,
    rx_fill_ring_empty_descs: u64,
    tx_ring_empty_descs: u64,
};

pub const xdp_options = extern struct {
    flags: u32,
};

pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT = 48;
pub const XSK_UNALIGNED_BUF_ADDR_MASK = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1;

pub const xdp_desc = extern struct {
    addr: u64,
    len: u32,
    options: u32,
};

fn issecure_mask(comptime x: comptime_int) comptime_int {
    return 1 << x;
}

pub const SECUREBITS_DEFAULT = 0x00000000;

pub const SECURE_NOROOT = 0;
pub const SECURE_NOROOT_LOCKED = 1;

pub const SECBIT_NOROOT = issecure_mask(SECURE_NOROOT);
pub const SECBIT_NOROOT_LOCKED = issecure_mask(SECURE_NOROOT_LOCKED);

pub const SECURE_NO_SETUID_FIXUP = 2;
pub const SECURE_NO_SETUID_FIXUP_LOCKED = 3;

pub const SECBIT_NO_SETUID_FIXUP = issecure_mask(SECURE_NO_SETUID_FIXUP);
pub const SECBIT_NO_SETUID_FIXUP_LOCKED = issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED);

pub const SECURE_KEEP_CAPS = 4;
pub const SECURE_KEEP_CAPS_LOCKED = 5;

pub const SECBIT_KEEP_CAPS = issecure_mask(SECURE_KEEP_CAPS);
pub const SECBIT_KEEP_CAPS_LOCKED = issecure_mask(SECURE_KEEP_CAPS_LOCKED);

pub const SECURE_NO_CAP_AMBIENT_RAISE = 6;
pub const SECURE_NO_CAP_AMBIENT_RAISE_LOCKED = 7;

pub const SECBIT_NO_CAP_AMBIENT_RAISE = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE);
pub const SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED);

pub const SECURE_ALL_BITS = issecure_mask(SECURE_NOROOT) |
    issecure_mask(SECURE_NO_SETUID_FIXUP) |
    issecure_mask(SECURE_KEEP_CAPS) |
    issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE);
pub const SECURE_ALL_LOCKS = SECURE_ALL_BITS << 1;

pub const PR = enum(i32) {
    SET_PDEATHSIG = 1,
    GET_PDEATHSIG = 2,

    GET_DUMPABLE = 3,
    SET_DUMPABLE = 4,

    GET_UNALIGN = 5,
    SET_UNALIGN = 6,

    GET_KEEPCAPS = 7,
    SET_KEEPCAPS = 8,

    GET_FPEMU = 9,
    SET_FPEMU = 10,

    GET_FPEXC = 11,
    SET_FPEXC = 12,

    GET_TIMING = 13,
    SET_TIMING = 14,

    SET_NAME = 15,
    GET_NAME = 16,

    GET_ENDIAN = 19,
    SET_ENDIAN = 20,

    GET_SECCOMP = 21,
    SET_SECCOMP = 22,

    CAPBSET_READ = 23,
    CAPBSET_DROP = 24,

    GET_TSC = 25,
    SET_TSC = 26,

    GET_SECUREBITS = 27,
    SET_SECUREBITS = 28,

    SET_TIMERSLACK = 29,
    GET_TIMERSLACK = 30,

    TASK_PERF_EVENTS_DISABLE = 31,
    TASK_PERF_EVENTS_ENABLE = 32,

    MCE_KILL = 33,

    MCE_KILL_GET = 34,

    SET_MM = 35,

    SET_PTRACER = 0x59616d61,

    SET_CHILD_SUBREAPER = 36,
    GET_CHILD_SUBREAPER = 37,

    SET_NO_NEW_PRIVS = 38,
    GET_NO_NEW_PRIVS = 39,

    GET_TID_ADDRESS = 40,

    SET_THP_DISABLE = 41,
    GET_THP_DISABLE = 42,

    MPX_ENABLE_MANAGEMENT = 43,
    MPX_DISABLE_MANAGEMENT = 44,

    SET_FP_MODE = 45,
    GET_FP_MODE = 46,

    CAP_AMBIENT = 47,

    SVE_SET_VL = 50,
    SVE_GET_VL = 51,

    GET_SPECULATION_CTRL = 52,
    SET_SPECULATION_CTRL = 53,

    _,

    pub const UNALIGN_NOPRINT = 1;
    pub const UNALIGN_SIGBUS = 2;

    pub const FPEMU_NOPRINT = 1;
    pub const FPEMU_SIGFPE = 2;

    pub const FP_EXC_SW_ENABLE = 0x80;
    pub const FP_EXC_DIV = 0x010000;
    pub const FP_EXC_OVF = 0x020000;
    pub const FP_EXC_UND = 0x040000;
    pub const FP_EXC_RES = 0x080000;
    pub const FP_EXC_INV = 0x100000;
    pub const FP_EXC_DISABLED = 0;
    pub const FP_EXC_NONRECOV = 1;
    pub const FP_EXC_ASYNC = 2;
    pub const FP_EXC_PRECISE = 3;

    pub const TIMING_STATISTICAL = 0;
    pub const TIMING_TIMESTAMP = 1;

    pub const ENDIAN_BIG = 0;
    pub const ENDIAN_LITTLE = 1;
    pub const ENDIAN_PPC_LITTLE = 2;

    pub const TSC_ENABLE = 1;
    pub const TSC_SIGSEGV = 2;

    pub const MCE_KILL_CLEAR = 0;
    pub const MCE_KILL_SET = 1;

    pub const MCE_KILL_LATE = 0;
    pub const MCE_KILL_EARLY = 1;
    pub const MCE_KILL_DEFAULT = 2;

    pub const SET_MM_START_CODE = 1;
    pub const SET_MM_END_CODE = 2;
    pub const SET_MM_START_DATA = 3;
    pub const SET_MM_END_DATA = 4;
    pub const SET_MM_START_STACK = 5;
    pub const SET_MM_START_BRK = 6;
    pub const SET_MM_BRK = 7;
    pub const SET_MM_ARG_START = 8;
    pub const SET_MM_ARG_END = 9;
    pub const SET_MM_ENV_START = 10;
    pub const SET_MM_ENV_END = 11;
    pub const SET_MM_AUXV = 12;
    pub const SET_MM_EXE_FILE = 13;
    pub const SET_MM_MAP = 14;
    pub const SET_MM_MAP_SIZE = 15;

    pub const SET_PTRACER_ANY = maxInt(c_ulong);

    pub const FP_MODE_FR = 1 << 0;
    pub const FP_MODE_FRE = 1 << 1;

    pub const CAP_AMBIENT_IS_SET = 1;
    pub const CAP_AMBIENT_RAISE = 2;
    pub const CAP_AMBIENT_LOWER = 3;
    pub const CAP_AMBIENT_CLEAR_ALL = 4;

    pub const SVE_SET_VL_ONEXEC = 1 << 18;
    pub const SVE_VL_LEN_MASK = 0xffff;
    pub const SVE_VL_INHERIT = 1 << 17;

    pub const SPEC_STORE_BYPASS = 0;
    pub const SPEC_NOT_AFFECTED = 0;
    pub const SPEC_PRCTL = 1 << 0;
    pub const SPEC_ENABLE = 1 << 1;
    pub const SPEC_DISABLE = 1 << 2;
    pub const SPEC_FORCE_DISABLE = 1 << 3;
};

pub const prctl_mm_map = extern struct {
    start_code: u64,
    end_code: u64,
    start_data: u64,
    end_data: u64,
    start_brk: u64,
    brk: u64,
    start_stack: u64,
    arg_start: u64,
    arg_end: u64,
    env_start: u64,
    env_end: u64,
    auxv: *u64,
    auxv_size: u32,
    exe_fd: u32,
};

pub const NETLINK = struct {
    /// Routing/device hook
    pub const ROUTE = 0;

    /// Unused number
    pub const UNUSED = 1;

    /// Reserved for user mode socket protocols
    pub const USERSOCK = 2;

    /// Unused number, formerly ip_queue
    pub const FIREWALL = 3;

    /// socket monitoring
    pub const SOCK_DIAG = 4;

    /// netfilter/iptables ULOG
    pub const NFLOG = 5;

    /// ipsec
    pub const XFRM = 6;

    /// SELinux event notifications
    pub const SELINUX = 7;

    /// Open-iSCSI
    pub const ISCSI = 8;

    /// auditing
    pub const AUDIT = 9;

    pub const FIB_LOOKUP = 10;

    pub const CONNECTOR = 11;

    /// netfilter subsystem
    pub const NETFILTER = 12;

    pub const IP6_FW = 13;

    /// DECnet routing messages
    pub const DNRTMSG = 14;

    /// Kernel messages to userspace
    pub const KOBJECT_UEVENT = 15;

    pub const GENERIC = 16;

    // leave room for NETLINK_DM (DM Events)

    /// SCSI Transports
    pub const SCSITRANSPORT = 18;

    pub const ECRYPTFS = 19;

    pub const RDMA = 20;

    /// Crypto layer
    pub const CRYPTO = 21;

    /// SMC monitoring
    pub const SMC = 22;
};

// Flags values

/// It is request message.
pub const NLM_F_REQUEST = 0x01;

/// Multipart message, terminated by NLMSG_DONE
pub const NLM_F_MULTI = 0x02;

/// Reply with ack, with zero or error code
pub const NLM_F_ACK = 0x04;

/// Echo this request
pub const NLM_F_ECHO = 0x08;

/// Dump was inconsistent due to sequence change
pub const NLM_F_DUMP_INTR = 0x10;

/// Dump was filtered as requested
pub const NLM_F_DUMP_FILTERED = 0x20;

// Modifiers to GET request

/// specify tree root
pub const NLM_F_ROOT = 0x100;

/// return all matching
pub const NLM_F_MATCH = 0x200;

/// atomic GET
pub const NLM_F_ATOMIC = 0x400;
pub const NLM_F_DUMP = NLM_F_ROOT | NLM_F_MATCH;

// Modifiers to NEW request

/// Override existing
pub const NLM_F_REPLACE = 0x100;

/// Do not touch, if it exists
pub const NLM_F_EXCL = 0x200;

/// Create, if it does not exist
pub const NLM_F_CREATE = 0x400;

/// Add to end of list
pub const NLM_F_APPEND = 0x800;

// Modifiers to DELETE request

/// Do not delete recursively
pub const NLM_F_NONREC = 0x100;

// Flags for ACK message

/// request was capped
pub const NLM_F_CAPPED = 0x100;

/// extended ACK TVLs were included
pub const NLM_F_ACK_TLVS = 0x200;

pub const NetlinkMessageType = enum(u16) {
    /// < 0x10: reserved control messages
    pub const MIN_TYPE = 0x10;

    /// Nothing.
    NOOP = 0x1,

    /// Error
    ERROR = 0x2,

    /// End of a dump
    DONE = 0x3,

    /// Data lost
    OVERRUN = 0x4,

    // rtlink types

    RTM_NEWLINK = 16,
    RTM_DELLINK,
    RTM_GETLINK,
    RTM_SETLINK,

    RTM_NEWADDR = 20,
    RTM_DELADDR,
    RTM_GETADDR,

    RTM_NEWROUTE = 24,
    RTM_DELROUTE,
    RTM_GETROUTE,

    RTM_NEWNEIGH = 28,
    RTM_DELNEIGH,
    RTM_GETNEIGH,

    RTM_NEWRULE = 32,
    RTM_DELRULE,
    RTM_GETRULE,

    RTM_NEWQDISC = 36,
    RTM_DELQDISC,
    RTM_GETQDISC,

    RTM_NEWTCLASS = 40,
    RTM_DELTCLASS,
    RTM_GETTCLASS,

    RTM_NEWTFILTER = 44,
    RTM_DELTFILTER,
    RTM_GETTFILTER,

    RTM_NEWACTION = 48,
    RTM_DELACTION,
    RTM_GETACTION,

    RTM_NEWPREFIX = 52,

    RTM_GETMULTICAST = 58,

    RTM_GETANYCAST = 62,

    RTM_NEWNEIGHTBL = 64,
    RTM_GETNEIGHTBL = 66,
    RTM_SETNEIGHTBL,

    RTM_NEWNDUSEROPT = 68,

    RTM_NEWADDRLABEL = 72,
    RTM_DELADDRLABEL,
    RTM_GETADDRLABEL,

    RTM_GETDCB = 78,
    RTM_SETDCB,

    RTM_NEWNETCONF = 80,
    RTM_DELNETCONF,
    RTM_GETNETCONF = 82,

    RTM_NEWMDB = 84,
    RTM_DELMDB = 85,
    RTM_GETMDB = 86,

    RTM_NEWNSID = 88,
    RTM_DELNSID = 89,
    RTM_GETNSID = 90,

    RTM_NEWSTATS = 92,
    RTM_GETSTATS = 94,

    RTM_NEWCACHEREPORT = 96,

    RTM_NEWCHAIN = 100,
    RTM_DELCHAIN,
    RTM_GETCHAIN,

    RTM_NEWNEXTHOP = 104,
    RTM_DELNEXTHOP,
    RTM_GETNEXTHOP,

    _,
};

/// Netlink message header
/// Specified in RFC 3549 Section 2.3.2
pub const nlmsghdr = extern struct {
    /// Length of message including header
    len: u32,

    /// Message content
    type: NetlinkMessageType,

    /// Additional flags
    flags: u16,

    /// Sequence number
    seq: u32,

    /// Sending process port ID
    pid: u32,
};

pub const ifinfomsg = extern struct {
    family: u8,
    __pad1: u8 = 0,

    /// ARPHRD_*
    type: c_ushort,

    /// Link index
    index: c_int,

    /// IFF_* flags
    flags: c_uint,

    /// IFF_* change mask
    change: c_uint,
};

pub const rtattr = extern struct {
    /// Length of option
    len: c_ushort,

    /// Type of option
    type: extern union {
        /// IFLA_* from linux/if_link.h
        link: IFLA,
        /// IFA_* from linux/if_addr.h
        addr: IFA,
    },

    pub const ALIGNTO = 4;
};

pub const IFA = enum(c_ushort) {
    UNSPEC,
    ADDRESS,
    LOCAL,
    LABEL,
    BROADCAST,
    ANYCAST,
    CACHEINFO,
    MULTICAST,
    FLAGS,
    RT_PRIORITY,
    TARGET_NETNSID,
    PROTO,

    _,
};

pub const IFLA = enum(c_ushort) {
    UNSPEC,
    ADDRESS,
    BROADCAST,
    IFNAME,
    MTU,
    LINK,
    QDISC,
    STATS,
    COST,
    PRIORITY,
    MASTER,

    /// Wireless Extension event
    WIRELESS,

    /// Protocol specific information for a link
    PROTINFO,

    TXQLEN,
    MAP,
    WEIGHT,
    OPERSTATE,
    LINKMODE,
    LINKINFO,
    NET_NS_PID,
    IFALIAS,

    /// Number of VFs if device is SR-IOV PF
    NUM_VF,

    VFINFO_LIST,
    STATS64,
    VF_PORTS,
    PORT_SELF,
    AF_SPEC,

    /// Group the device belongs to
    GROUP,

    NET_NS_FD,

    /// Extended info mask, VFs, etc
    EXT_MASK,

    /// Promiscuity count: > 0 means acts PROMISC
    PROMISCUITY,

    NUM_TX_QUEUES,
    NUM_RX_QUEUES,
    CARRIER,
    PHYS_PORT_ID,
    CARRIER_CHANGES,
    PHYS_SWITCH_ID,
    LINK_NETNSID,
    PHYS_PORT_NAME,
    PROTO_DOWN,
    GSO_MAX_SEGS,
    GSO_MAX_SIZE,
    PAD,
    XDP,
    EVENT,

    NEW_NETNSID,
    IF_NETNSID,

    CARRIER_UP_COUNT,
    CARRIER_DOWN_COUNT,
    NEW_IFINDEX,
    MIN_MTU,
    MAX_MTU,

    _,

    pub const TARGET_NETNSID: IFLA = .IF_NETNSID;
};

pub const rtnl_link_ifmap = extern struct {
    mem_start: u64,
    mem_end: u64,
    base_addr: u64,
    irq: u16,
    dma: u8,
    port: u8,
};

pub const rtnl_link_stats = extern struct {
    /// total packets received
    rx_packets: u32,

    /// total packets transmitted
    tx_packets: u32,

    /// total bytes received
    rx_bytes: u32,

    /// total bytes transmitted
    tx_bytes: u32,

    /// bad packets received
    rx_errors: u32,

    /// packet transmit problems
    tx_errors: u32,

    /// no space in linux buffers
    rx_dropped: u32,

    /// no space available in linux
    tx_dropped: u32,

    /// multicast packets received
    multicast: u32,

    collisions: u32,

    // detailed rx_errors

    rx_length_errors: u32,

    /// receiver ring buff overflow
    rx_over_errors: u32,

    /// recved pkt with crc error
    rx_crc_errors: u32,

    /// recv'd frame alignment error
    rx_frame_errors: u32,

    /// recv'r fifo overrun
    rx_fifo_errors: u32,

    /// receiver missed packet
    rx_missed_errors: u32,

    // detailed tx_errors
    tx_aborted_errors: u32,
    tx_carrier_errors: u32,
    tx_fifo_errors: u32,
    tx_heartbeat_errors: u32,
    tx_window_errors: u32,

    // for cslip etc

    rx_compressed: u32,
    tx_compressed: u32,

    /// dropped, no handler found
    rx_nohandler: u32,
};

pub const rtnl_link_stats64 = extern struct {
    /// total packets received
    rx_packets: u64,

    /// total packets transmitted
    tx_packets: u64,

    /// total bytes received
    rx_bytes: u64,

    /// total bytes transmitted
    tx_bytes: u64,

    /// bad packets received
    rx_errors: u64,

    /// packet transmit problems
    tx_errors: u64,

    /// no space in linux buffers
    rx_dropped: u64,

    /// no space available in linux
    tx_dropped: u64,

    /// multicast packets received
    multicast: u64,

    collisions: u64,

    // detailed rx_errors

    rx_length_errors: u64,

    /// receiver ring buff overflow
    rx_over_errors: u64,

    /// recved pkt with crc error
    rx_crc_errors: u64,

    /// recv'd frame alignment error
    rx_frame_errors: u64,

    /// recv'r fifo overrun
    rx_fifo_errors: u64,

    /// receiver missed packet
    rx_missed_errors: u64,

    // detailed tx_errors
    tx_aborted_errors: u64,
    tx_carrier_errors: u64,
    tx_fifo_errors: u64,
    tx_heartbeat_errors: u64,
    tx_window_errors: u64,

    // for cslip etc

    rx_compressed: u64,
    tx_compressed: u64,

    /// dropped, no handler found
    rx_nohandler: u64,
};

pub const perf_event_attr = extern struct {
    /// Major type: hardware/software/tracepoint/etc.
    type: PERF.TYPE = undefined,
    /// Size of the attr structure, for fwd/bwd compat.
    size: u32 = @sizeOf(perf_event_attr),
    /// Type specific configuration information.
    config: u64 = 0,

    sample_period_or_freq: u64 = 0,
    sample_type: u64 = 0,
    read_format: u64 = 0,

    flags: packed struct(u64) {
        /// off by default
        disabled: bool = false,
        /// children inherit it
        inherit: bool = false,
        /// must always be on PMU
        pinned: bool = false,
        /// only group on PMU
        exclusive: bool = false,
        /// don't count user
        exclude_user: bool = false,
        /// ditto kernel
        exclude_kernel: bool = false,
        /// ditto hypervisor
        exclude_hv: bool = false,
        /// don't count when idle
        exclude_idle: bool = false,
        /// include mmap data
        mmap: bool = false,
        /// include comm data
        comm: bool = false,
        /// use freq, not period
        freq: bool = false,
        /// per task counts
        inherit_stat: bool = false,
        /// next exec enables
        enable_on_exec: bool = false,
        /// trace fork/exit
        task: bool = false,
        /// wakeup_watermark
        watermark: bool = false,
        /// precise_ip:
        ///
        ///  0 - SAMPLE_IP can have arbitrary skid
        ///  1 - SAMPLE_IP must have constant skid
        ///  2 - SAMPLE_IP requested to have 0 skid
        ///  3 - SAMPLE_IP must have 0 skid
        ///
        ///  See also PERF_RECORD_MISC_EXACT_IP
        /// skid constraint
        precise_ip: u2 = 0,
        /// non-exec mmap data
        mmap_data: bool = false,
        /// sample_type all events
        sample_id_all: bool = false,

        /// don't count in host
        exclude_host: bool = false,
        /// don't count in guest
        exclude_guest: bool = false,

        /// exclude kernel callchains
        exclude_callchain_kernel: bool = false,
        /// exclude user callchains
        exclude_callchain_user: bool = false,
        /// include mmap with inode data
        mmap2: bool = false,
        /// flag comm events that are due to an exec
        comm_exec: bool = false,
        /// use @clockid for time fields
        use_clockid: bool = false,
        /// context switch data
        context_switch: bool = false,
        /// Write ring buffer from end to beginning
        write_backward: bool = false,
        /// include namespaces data
        namespaces: bool = false,
        /// include ksymbol events
        ksymbol: bool = false,
        /// include BPF events
        bpf_event: bool = false,
        /// generate AUX records instead of events
        aux_output: bool = false,
        /// include cgroup events
        cgroup: bool = false,
        /// include text poke events
        text_poke: bool = false,
        /// use build ID in mmap2 events
        build_id: bool = false,
        /// children only inherit if cloned with CLONE_THREAD
        inherit_thread: bool = false,
        /// event is removed from task on exec
        remove_on_exec: bool = false,
        /// send synchronous SIGTRAP on event
        sigtrap: bool = false,

        __reserved_1: u26 = 0,
    } = .{},
    /// wakeup every n events, or
    /// bytes before wakeup
    wakeup_events_or_watermark: u32 = 0,

    bp_type: u32 = 0,

    /// This field is also used for:
    /// bp_addr
    /// kprobe_func for perf_kprobe
    /// uprobe_path for perf_uprobe
    config1: u64 = 0,
    /// This field is also used for:
    /// bp_len
    /// kprobe_addr when kprobe_func == null
    /// probe_offset for perf_[k,u]probe
    config2: u64 = 0,

    /// enum perf_branch_sample_type
    branch_sample_type: u64 = 0,

    /// Defines set of user regs to dump on samples.
    /// See asm/perf_regs.h for details.
    sample_regs_user: u64 = 0,

    /// Defines size of the user stack to dump on samples.
    sample_stack_user: u32 = 0,

    clockid: clockid_t = .REALTIME,
    /// Defines set of regs to dump for each sample
    /// state captured on:
    ///  - precise = 0: PMU interrupt
    ///  - precise > 0: sampled instruction
    ///
    /// See asm/perf_regs.h for details.
    sample_regs_intr: u64 = 0,

    /// Wakeup watermark for AUX area
    aux_watermark: u32 = 0,
    sample_max_stack: u16 = 0,
    /// Align to u64
    __reserved_2: u16 = 0,

    aux_sample_size: u32 = 0,
    aux_action: packed struct(u32) {
        /// start AUX area tracing paused
        start_paused: bool = false,
        /// on overflow, pause AUX area tracing
        pause: bool = false,
        /// on overflow, resume AUX area tracing
        @"resume": bool = false,

        __reserved_3: u29 = 0,
    } = .{},

    /// User provided data if sigtrap == true
    sig_data: u64 = 0,

    /// Extension of config2
    config3: u64 = 0,
};

pub const perf_event_header = extern struct {
    /// Event type: sample/mmap/fork/etc.
    type: PERF.RECORD,
    /// Additional informations on the event: kernel/user/hypervisor/etc.
    misc: packed struct(u16) {
        cpu_mode: PERF.RECORD.MISC.CPU_MODE,
        _: u9,
        PROC_MAP_PARSE_TIMEOUT: bool,
        bit13: packed union {
            MMAP_DATA: bool,
            COMM_EXEC: bool,
            FORK_EXEC: bool,
            SWITCH_OUT: bool,
        },
        bit14: packed union {
            EXACT_IP: bool,
            SWITCH_OUT_PREEMPT: bool,
            MMAP_BUILD_ID: bool,
        },
        EXT_RESERVED: bool,
    },
    /// Size of the following record
    size: u16,
};

pub const perf_event_mmap_page = extern struct {
    /// Version number of this struct
    version: u32,
    /// Lowest version this is compatible with
    compt_version: u32,
    /// Seqlock for synchronization
    lock: u32,
    /// Hardware counter identifier
    index: u32,
    /// Add to hardware counter value
    offset: i64,
    /// Time the event was active
    time_enabled: u64,
    /// Time the event was running
    time_running: u64,
    capabilities: packed struct(u64) {
        /// If kernel version < 3.12
        /// this rapresents both user_rdpmc and user_time (user_rdpmc | user_time)
        /// otherwise deprecated.
        bit0: bool,
        /// Set if bit0 is deprecated
        bit0_is_deprecated: bool,
        /// Hardware support for userspace read of performance counters
        user_rdpmc: bool,
        /// Hardware support for a constant non stop timestamp counter (Eg. TSC on x86)
        user_time: bool,
        /// The time_zero field is used
        user_time_zero: bool,
        /// The time_{cycle,mask} fields are used
        user_time_short: bool,
        ____res: u58,
    },
    /// If capabilities.user_rdpmc
    /// this field reports the bit-width of the value read with rdpmc() or equivalent
    pcm_width: u16,
    /// If capabilities.user_time the following fields can be used to compute the time
    /// delta since time_enabled (in ns) using RDTSC or similar
    time_shift: u16,
    time_mult: u32,
    time_offset: u64,
    /// If capabilities.user_time_zero the hardware clock can be calculated from
    /// sample timestamps
    time_zero: u64,
    /// Header size
    size: u32,
    __reserved_1: u32,
    /// The following fields are used to compute the timestamp when the hardware clock
    /// is less than 64bit wide
    time_cycles: u64,
    time_mask: u64,
    __reserved: [116 * 8]u8,
    /// Head in the data section
    data_head: u64,
    /// Userspace written tail
    data_tail: u64,
    /// Where the buffer starts
    data_offset: u64,
    /// Data buffer size
    data_size: u64,
    // if aux is used, head in the data section
    aux_head: u64,
    // if aux is used, userspace written tail
    aux_tail: u64,
    // if aux is used, where the buffer starts
    aux_offset: u64,
    // if aux is used, data buffer size
    aux_size: u64,
};

pub const PERF = struct {
    pub const TYPE = enum(u32) {
        HARDWARE,
        SOFTWARE,
        TRACEPOINT,
        HW_CACHE,
        RAW,
        BREAKPOINT,
        MAX,
        _,
    };

    pub const COUNT = struct {
        pub const HW = enum(u32) {
            CPU_CYCLES,
            INSTRUCTIONS,
            CACHE_REFERENCES,
            CACHE_MISSES,
            BRANCH_INSTRUCTIONS,
            BRANCH_MISSES,
            BUS_CYCLES,
            STALLED_CYCLES_FRONTEND,
            STALLED_CYCLES_BACKEND,
            REF_CPU_CYCLES,
            MAX,

            pub const CACHE = enum(u32) {
                L1D,
                L1I,
                LL,
                DTLB,
                ITLB,
                BPU,
                NODE,
                MAX,

                pub const OP = enum(u32) {
                    READ,
                    WRITE,
                    PREFETCH,
                    MAX,
                };

                pub const RESULT = enum(u32) {
                    ACCESS,
                    MISS,
                    MAX,
                };
            };
        };

        pub const SW = enum(u32) {
            CPU_CLOCK,
            TASK_CLOCK,
            PAGE_FAULTS,
            CONTEXT_SWITCHES,
            CPU_MIGRATIONS,
            PAGE_FAULTS_MIN,
            PAGE_FAULTS_MAJ,
            ALIGNMENT_FAULTS,
            EMULATION_FAULTS,
            DUMMY,
            BPF_OUTPUT,
            MAX,
        };
    };

    pub const SAMPLE = struct {
        pub const IP = 1;
        pub const TID = 2;
        pub const TIME = 4;
        pub const ADDR = 8;
        pub const READ = 16;
        pub const CALLCHAIN = 32;
        pub const ID = 64;
        pub const CPU = 128;
        pub const PERIOD = 256;
        pub const STREAM_ID = 512;
        pub const RAW = 1024;
        pub const BRANCH_STACK = 2048;
        pub const REGS_USER = 4096;
        pub const STACK_USER = 8192;
        pub const WEIGHT = 16384;
        pub const DATA_SRC = 32768;
        pub const IDENTIFIER = 65536;
        pub const TRANSACTION = 131072;
        pub const REGS_INTR = 262144;
        pub const PHYS_ADDR = 524288;
        pub const MAX = 1048576;

        pub const BRANCH = struct {
            pub const USER = 1 << 0;
            pub const KERNEL = 1 << 1;
            pub const HV = 1 << 2;
            pub const ANY = 1 << 3;
            pub const ANY_CALL = 1 << 4;
            pub const ANY_RETURN = 1 << 5;
            pub const IND_CALL = 1 << 6;
            pub const ABORT_TX = 1 << 7;
            pub const IN_TX = 1 << 8;
            pub const NO_TX = 1 << 9;
            pub const COND = 1 << 10;
            pub const CALL_STACK = 1 << 11;
            pub const IND_JUMP = 1 << 12;
            pub const CALL = 1 << 13;
            pub const NO_FLAGS = 1 << 14;
            pub const NO_CYCLES = 1 << 15;
            pub const TYPE_SAVE = 1 << 16;
            pub const MAX = 1 << 17;
        };
    };

    pub const RECORD = enum(u32) {
        MMAP = 1,
        LOST = 2,
        COMM = 3,
        EXIT = 4,
        THROTTLE = 5,
        UNTHROTTLE = 6,
        FORK = 7,
        READ = 8,
        SAMPLE = 9,
        MMAP2 = 10,
        AUX = 11,
        ITRACE_START = 12,
        LOST_SAMPLES = 13,
        SWITCH = 14,
        SWITCH_CPU_WIDE = 15,
        NAMESPACES = 16,
        KSYMBOL = 17,
        BPF_EVENT = 18,
        CGROUP = 19,
        TEXT_POKE = 20,
        AUX_OUTPUT_HW_ID = 21,

        const MISC = struct {
            pub const CPU_MODE = enum(u3) {
                UNKNOWN = 0,
                KERNEL = 1,
                USER = 2,
                HYPERVISOR = 3,
                GUEST_KERNEL = 4,
                GUEST_USER = 5,
            };
        };
    };

    pub const FLAG = struct {
        pub const FD_NO_GROUP = 1 << 0;
        pub const FD_OUTPUT = 1 << 1;
        pub const PID_CGROUP = 1 << 2;
        pub const FD_CLOEXEC = 1 << 3;
    };

    pub const EVENT_IOC = struct {
        pub const ENABLE = 9216;
        pub const DISABLE = 9217;
        pub const REFRESH = 9218;
        pub const RESET = 9219;
        pub const PERIOD = 1074275332;
        pub const SET_OUTPUT = 9221;
        pub const SET_FILTER = 1074275334;
        pub const ID = 2148017159;
        pub const SET_BPF = 1074013192;
        pub const PAUSE_OUTPUT = 1074013193;
        pub const QUERY_BPF = 3221758986;
        pub const MODIFY_ATTRIBUTES = 1074275339;
    };

    pub const IOC_FLAG_GROUP = 1;
};

// TODO: Add the rest of the AUDIT defines?
pub const AUDIT = struct {
    pub const ARCH = enum(u32) {
        const CONVENTION_MIPS64_N32 = 0x20000000;
        const @"64BIT" = 0x80000000;
        const LE = 0x40000000;

        AARCH64 = toAudit(.AARCH64, @"64BIT" | LE),
        ALPHA = toAudit(.ALPHA, @"64BIT" | LE),
        ARCOMPACT = toAudit(.ARC_COMPACT, LE),
        ARCOMPACTBE = toAudit(.ARC_COMPACT, 0),
        ARCV2 = toAudit(.ARC_COMPACT2, LE),
        ARCV2BE = toAudit(.ARC_COMPACT2, 0),
        ARM = toAudit(.ARM, LE),
        ARMEB = toAudit(.ARM, 0),
        C6X = toAudit(.TI_C6000, LE),
        C6XBE = toAudit(.TI_C6000, 0),
        CRIS = toAudit(.CRIS, LE),
        CSKY = toAudit(.CSKY, LE),
        FRV = toAudit(.FRV, 0),
        H8300 = toAudit(.H8_300, 0),
        HEXAGON = toAudit(.HEXAGON, 0),
        I386 = toAudit(.@"386", LE),
        IA64 = toAudit(.IA_64, @"64BIT" | LE),
        M32R = toAudit(.M32R, 0),
        M68K = toAudit(.@"68K", 0),
        MICROBLAZE = toAudit(.MICROBLAZE, 0),
        MIPS = toAudit(.MIPS, 0),
        MIPSEL = toAudit(.MIPS, LE),
        MIPS64 = toAudit(.MIPS, @"64BIT"),
        MIPS64N32 = toAudit(.MIPS, @"64BIT" | CONVENTION_MIPS64_N32),
        MIPSEL64 = toAudit(.MIPS, @"64BIT" | LE),
        MIPSEL64N32 = toAudit(.MIPS, @"64BIT" | LE | CONVENTION_MIPS64_N32),
        NDS32 = toAudit(.NDS32, LE),
        NDS32BE = toAudit(.NDS32, 0),
        NIOS2 = toAudit(.ALTERA_NIOS2, LE),
        OPENRISC = toAudit(.OPENRISC, 0),
        PARISC = toAudit(.PARISC, 0),
        PARISC64 = toAudit(.PARISC, @"64BIT"),
        PPC = toAudit(.PPC, 0),
        PPC64 = toAudit(.PPC64, @"64BIT"),
        PPC64LE = toAudit(.PPC64, @"64BIT" | LE),
        RISCV32 = toAudit(.RISCV, LE),
        RISCV64 = toAudit(.RISCV, @"64BIT" | LE),
        S390 = toAudit(.S390, 0),
        S390X = toAudit(.S390, @"64BIT"),
        SH = toAudit(.SH, 0),
        SHEL = toAudit(.SH, LE),
        SH64 = toAudit(.SH, @"64BIT"),
        SHEL64 = toAudit(.SH, @"64BIT" | LE),
        SPARC = toAudit(.SPARC, 0),
        SPARC64 = toAudit(.SPARCV9, @"64BIT"),
        TILEGX = toAudit(.TILEGX, @"64BIT" | LE),
        TILEGX32 = toAudit(.TILEGX, LE),
        TILEPRO = toAudit(.TILEPRO, LE),
        UNICORE = toAudit(.UNICORE, LE),
        X86_64 = toAudit(.X86_64, @"64BIT" | LE),
        XTENSA = toAudit(.XTENSA, 0),
        LOONGARCH32 = toAudit(.LOONGARCH, LE),
        LOONGARCH64 = toAudit(.LOONGARCH, @"64BIT" | LE),

        fn toAudit(em: elf.EM, flags: u32) u32 {
            return @backingInt(em) | flags;
        }

        pub const current: AUDIT.ARCH = switch (native_arch) {
            .arm, .thumb => .ARM,
            .armeb, .thumbeb => .ARMEB,
            .aarch64 => .AARCH64,
            .arc => .ARCV2,
            .arceb => .ARCV2BE,
            .csky => .CSKY,
            .hexagon => .HEXAGON,
            .loongarch32 => .LOONGARCH32,
            .loongarch64 => .LOONGARCH64,
            .m68k => .M68K,
            .microblaze, .microblazeel => .MICROBLAZE,
            .mips => .MIPS,
            .mipsel => .MIPSEL,
            .mips64 => switch (native_abi) {
                .gnuabin32, .muslabin32, .abin32 => .MIPS64N32,
                else => .MIPS64,
            },
            .mips64el => switch (native_abi) {
                .gnuabin32, .muslabin32, .abin32 => .MIPSEL64N32,
                else => .MIPSEL64,
            },
            .or1k => .OPENRISC,
            .powerpc => .PPC,
            .powerpc64 => .PPC64,
            .powerpc64le => .PPC64LE,
            .riscv32 => .RISCV32,
            .riscv64 => .RISCV64,
            .s390x => .S390X,
            .sh => .SHEL,
            .sheb => .SH,
            .sparc => .SPARC,
            .sparc64 => .SPARC64,
            .x86 => .I386,
            .x86_64 => .X86_64,
            .xtensa => .XTENSA,
            else => @compileError("unsupported architecture"),
        };
    };
};

pub const PTRACE = struct {
    pub const TRACEME = 0;
    pub const PEEKTEXT = 1;
    pub const PEEKDATA = 2;
    pub const PEEKUSER = 3;
    pub const POKETEXT = 4;
    pub const POKEDATA = 5;
    pub const POKEUSER = 6;
    pub const CONT = 7;
    pub const KILL = 8;
    pub const SINGLESTEP = 9;
    pub const GETREGS = 12;
    pub const SETREGS = 13;
    pub const GETFPREGS = 14;
    pub const SETFPREGS = 15;
    pub const ATTACH = 16;
    pub const DETACH = 17;
    pub const GETFPXREGS = 18;
    pub const SETFPXREGS = 19;
    pub const SYSCALL = 24;
    pub const SETOPTIONS = 0x4200;
    pub const GETEVENTMSG = 0x4201;
    pub const GETSIGINFO = 0x4202;
    pub const SETSIGINFO = 0x4203;
    pub const GETREGSET = 0x4204;
    pub const SETREGSET = 0x4205;
    pub const SEIZE = 0x4206;
    pub const INTERRUPT = 0x4207;
    pub const LISTEN = 0x4208;
    pub const PEEKSIGINFO = 0x4209;
    pub const GETSIGMASK = 0x420a;
    pub const SETSIGMASK = 0x420b;
    pub const SECCOMP_GET_FILTER = 0x420c;
    pub const SECCOMP_GET_METADATA = 0x420d;
    pub const GET_SYSCALL_INFO = 0x420e;

    pub const EVENT = struct {
        pub const FORK = 1;
        pub const VFORK = 2;
        pub const CLONE = 3;
        pub const EXEC = 4;
        pub const VFORK_DONE = 5;
        pub const EXIT = 6;
        pub const SECCOMP = 7;
        pub const STOP = 128;
    };

    pub const O = struct {
        pub const TRACESYSGOOD = 1;
        pub const TRACEFORK = 1 << PTRACE.EVENT.FORK;
        pub const TRACEVFORK = 1 << PTRACE.EVENT.VFORK;
        pub const TRACECLONE = 1 << PTRACE.EVENT.CLONE;
        pub const TRACEEXEC = 1 << PTRACE.EVENT.EXEC;
        pub const TRACEVFORKDONE = 1 << PTRACE.EVENT.VFORK_DONE;
        pub const TRACEEXIT = 1 << PTRACE.EVENT.EXIT;
        pub const TRACESECCOMP = 1 << PTRACE.EVENT.SECCOMP;

        pub const EXITKILL = 1 << 20;
        pub const SUSPEND_SECCOMP = 1 << 21;

        pub const MASK = 0x000000ff | PTRACE.O.EXITKILL | PTRACE.O.SUSPEND_SECCOMP;
    };
};

/// For futex2_waitv and futex2_requeue. Arrays of `futex2_waitone` allow
/// waiting on multiple futexes in one call.
pub const futex2_waitone = extern struct {
    /// Expected value at uaddr, should match size of futex.
    val: u64,
    /// User address to wait on.  Top-bits must be 0 on 32-bit.
    uaddr: u64,
    /// Flags for this waiter.
    flags: FUTEX2_FLAGS,
    /// Reserved member to preserve alignment.
    __reserved: u32 = 0,
};

pub const cache_stat_range = extern struct {
    off: u64,
    len: u64,
};

pub const cache_stat = extern struct {
    /// Number of cached pages.
    cache: u64,
    /// Number of dirty pages.
    dirty: u64,
    /// Number of pages marked for writeback.
    writeback: u64,
    /// Number of pages evicted from the cache.
    evicted: u64,
    /// Number of recently evicted pages.
    /// A page is recently evicted if its last eviction was recent enough that its
    /// reentry to the cache would indicate that it is actively being used by the
    /// system, and that there is memory pressure on the system.
    recently_evicted: u64,
};

pub const SHADOW_STACK = struct {
    /// Set up a restore token in the shadow stack.
    pub const SET_TOKEN: u64 = 1 << 0;
};

pub const msghdr = extern struct {
    name: ?*sockaddr,
    namelen: socklen_t,
    iov: [*]iovec,
    /// The kernel and glibc use `usize` for this field; POSIX and musl use `c_int`.
    iovlen: usize,
    control: ?*anyopaque,
    /// The kernel and glibc use `usize` for this field; POSIX and musl use `socklen_t`.
    controllen: usize,
    flags: u32,
};

pub const msghdr_const = extern struct {
    name: ?*const sockaddr,
    namelen: socklen_t,
    iov: [*]const iovec_const,
    iovlen: usize,
    control: ?*const anyopaque,
    controllen: usize,
    flags: u32,
};

// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/socket.h?id=b320789d6883cc00ac78ce83bccbfe7ed58afcf0#n105
pub const cmsghdr = extern struct {
    /// The kernel and glibc use `usize` for this field; musl uses `socklen_t`.
    len: usize,
    level: i32,
    type: i32,
};

// https://github.com/torvalds/linux/blob/72d3fcf802c45d00b300f25b848a93c3a2bd7c7e/include/linux/socket.h#L133
pub const cmsg_align = @sizeOf(c_long);

pub const riscv_hwprobe = extern struct {
    key: i64,
    value: u64,
};

pub const RISCV_HWPROBE = struct {
    pub const KEY = struct {
        pub const MVENDORID = 0;
        pub const MARCHID = 1;
        pub const MIMPID = 2;
        pub const BASE_BEHAVIOR = 3;
        pub const IMA_EXT_0 = 4;
        pub const CPUPERF_0 = 5;
        pub const ZICBOZ_BLOCK_SIZE = 6;
        pub const HIGHEST_VIRT_ADDRESS = 7;
        pub const TIME_CSR_FREQ = 8;
        pub const MISALIGNED_SCALAR_PERF = 9;
        pub const MISALIGNED_VECTOR_PERF = 10;
        pub const VENDOR_EXT_THEAD_0 = 11;
        pub const ZICBOM_BLOCK_SIZE = 12;
        pub const VENDOR_EXT_SIFIVE_0 = 13;
        pub const VENDOR_EXT_MIPS_0 = 14;
        pub const ZICBOP_BLOCK_SIZE = 15;
        pub const IMA_EXT_1 = 16;
    };

    pub const FLAGS_WHICH_CPUS = 1 << 0;

    pub const BASE_BEHAVIOR_IMA = 1 << 0;

    pub const IMA_EXT_0 = struct {
        pub const IMA_FD = 1 << 0;
        pub const IMA_C = 1 << 1;
        pub const IMA_V = 1 << 2;
        pub const EXT_ZBA = 1 << 3;
        pub const EXT_ZBB = 1 << 4;
        pub const EXT_ZBS = 1 << 5;
        pub const EXT_ZICBOZ = 1 << 6;
        pub const EXT_ZBC = 1 << 7;
        pub const EXT_ZBKB = 1 << 8;
        pub const EXT_ZBKC = 1 << 9;
        pub const EXT_ZBKX = 1 << 10;
        pub const EXT_ZKND = 1 << 11;
        pub const EXT_ZKNE = 1 << 12;
        pub const EXT_ZKNH = 1 << 13;
        pub const EXT_ZKSED = 1 << 14;
        pub const EXT_ZKSH = 1 << 15;
        pub const EXT_ZKT = 1 << 16;
        pub const EXT_ZVBB = 1 << 17;
        pub const EXT_ZVBC = 1 << 18;
        pub const EXT_ZVKB = 1 << 19;
        pub const EXT_ZVKG = 1 << 20;
        pub const EXT_ZVKNED = 1 << 21;
        pub const EXT_ZVKNHA = 1 << 22;
        pub const EXT_ZVKNHB = 1 << 23;
        pub const EXT_ZVKSED = 1 << 24;
        pub const EXT_ZVKSH = 1 << 25;
        pub const EXT_ZVKT = 1 << 26;
        pub const EXT_ZFH = 1 << 27;
        pub const EXT_ZFHMIN = 1 << 28;
        pub const EXT_ZIHINTNTL = 1 << 29;
        pub const EXT_ZVFH = 1 << 30;
        pub const EXT_ZVFHMIN = 1 << 31;
        pub const EXT_ZFA = 1 << 32;
        pub const EXT_ZTSO = 1 << 33;
        pub const EXT_ZACAS = 1 << 34;
        pub const EXT_ZICOND = 1 << 35;
        pub const EXT_ZIHINTPAUSE = 1 << 36;
        pub const EXT_ZVE32X = 1 << 37;
        pub const EXT_ZVE32F = 1 << 38;
        pub const EXT_ZVE64X = 1 << 39;
        pub const EXT_ZVE64F = 1 << 40;
        pub const EXT_ZVE64D = 1 << 41;
        pub const EXT_ZIMOP = 1 << 42;
        pub const EXT_ZCA = 1 << 43;
        pub const EXT_ZCB = 1 << 44;
        pub const EXT_ZCD = 1 << 45;
        pub const EXT_ZCF = 1 << 46;
        pub const EXT_ZCMOP = 1 << 47;
        pub const EXT_ZAWRS = 1 << 48;
        pub const EXT_SUPM = 1 << 49;
        pub const EXT_ZICNTR = 1 << 50;
        pub const EXT_ZIHPM = 1 << 51;
        pub const EXT_ZFBFMIN = 1 << 52;
        pub const EXT_ZVFBFMIN = 1 << 53;
        pub const EXT_ZVFBFWMA = 1 << 54;
        pub const EXT_ZICBOM = 1 << 55;
        pub const EXT_ZAAMO = 1 << 56;
        pub const EXT_ZALRSC = 1 << 57;
        pub const EXT_ZABHA = 1 << 58;
        pub const EXT_ZALASR = 1 << 59;
        pub const EXT_ZICBOP = 1 << 60;
        pub const EXT_ZILSD = 1 << 61;
        pub const EXT_ZCLSD = 1 << 62;
        pub const EXT_ZICFILP = 1 << 63;
    };

    pub const IMA_EXT_1_EXT_ZICFISS = 1 << 0;

    pub const MISALIGNED_SCALAR = struct {
        pub const UNKNOWN = 0;
        pub const EMULATED = 1;
        pub const SLOW = 2;
        pub const FAST = 3;
        pub const UNSUPPORTED = 4;
    };

    pub const MISALIGNED_VECTOR = struct {
        pub const UNKNOWN = 0;
        pub const SLOW = 2;
        pub const FAST = 3;
        pub const UNSUPPORTED = 4;
    };

    pub const MIPS_VENDOR_EXT_XMIPSEXECTL = 1 << 0;

    pub const SIFIVE_VENDOR_EXT = struct {
        pub const XSFVQMACCDOD = 1 << 0;
        pub const XSFVQMACCQOQ = 1 << 1;
        pub const XSFVFNRCLIPXFQF = 1 << 2;
        pub const XSFVFWMACCQQQ = 1 << 3;
    };
};