跳转到内容
标准库Zig 0.17.1官方原文
源码std/os/linux.zig

第 1 行

无论是否链接 libc,此文件均为 Linux 提供与 libc 所提供内容相匹配的系统接口函数。采用以下 抽象:

  • 实现所有系统调用,方式类似于 libc 在仅有 renameat 系统调用时仍提供 rename 函数。

std.os.linux.accept

函数

第 2919 行

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

参数

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

std.os.linux.accept4

函数

第 2926 行

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

参数

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

std.os.linux.access

函数

第 1876 行

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

参数

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

std.os.linux.ACCMODE

别名

第 25 行

别名目标 std.posix.ACCMODE

std.os.linux.acct

函数

第 1891 行

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

参数

path: [*:0]const u8

std.os.linux.addrinfo

容器

第 8327 行

字段

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

std.os.linux.AF

命名空间

第 5170 行

std.os.linux.AF.ALG

别名

第 5212 行

别名目标 std.os.linux.PF.ALG

std.os.linux.AF.APPLETALK

别名

第 5178 行

别名目标 std.os.linux.PF.APPLETALK

std.os.linux.AF.ASH

别名

第 5192 行

别名目标 std.os.linux.PF.ASH

std.os.linux.AF.ATMPVC

别名

第 5181 行

别名目标 std.os.linux.PF.ATMPVC

std.os.linux.AF.ATMSVC

别名

第 5194 行

别名目标 std.os.linux.PF.ATMSVC

std.os.linux.AF.AX25

别名

第 5176 行

别名目标 std.os.linux.PF.AX25

std.os.linux.AF.BLUETOOTH

别名

第 5205 行

别名目标 std.os.linux.PF.BLUETOOTH

std.os.linux.AF.BRIDGE

别名

第 5180 行

别名目标 std.os.linux.PF.BRIDGE

std.os.linux.AF.CAIF

别名

第 5211 行

别名目标 std.os.linux.PF.CAIF

std.os.linux.AF.CAN

别名

第 5203 行

别名目标 std.os.linux.PF.CAN

std.os.linux.AF.DECnet

别名

第 5185 行

别名目标 std.os.linux.PF.DECnet

std.os.linux.AF.ECONET

别名

第 5193 行

别名目标 std.os.linux.PF.ECONET

std.os.linux.AF.FILE

别名

第 5174 行

别名目标 std.os.linux.AF.LOCAL

std.os.linux.AF.IB

别名

第 5201 行

别名目标 std.os.linux.PF.IB

std.os.linux.AF.IEEE802154

别名

第 5210 行

别名目标 std.os.linux.PF.IEEE802154

std.os.linux.AF.INET

别名

第 5175 行

别名目标 std.os.linux.PF.INET

std.os.linux.AF.INET6

别名

第 5183 行

别名目标 std.os.linux.PF.INET6

std.os.linux.AF.IPX

别名

第 5177 行

别名目标 std.os.linux.PF.IPX

std.os.linux.AF.IRDA

别名

第 5197 行

别名目标 std.os.linux.PF.IRDA

std.os.linux.AF.ISDN

别名

第 5208 行

别名目标 std.os.linux.PF.ISDN

std.os.linux.AF.IUCV

别名

第 5206 行

别名目标 std.os.linux.PF.IUCV

std.os.linux.AF.KCM

别名

第 5215 行

别名目标 std.os.linux.PF.KCM

std.os.linux.AF.KEY

别名

第 5188 行

别名目标 std.os.linux.PF.KEY

std.os.linux.AF.LLC

别名

第 5200 行

别名目标 std.os.linux.PF.LLC

std.os.linux.AF.LOCAL

别名

第 5172 行

别名目标 std.os.linux.PF.LOCAL

std.os.linux.AF.MAX

别名

第 5219 行

别名目标 std.os.linux.PF.MAX

std.os.linux.AF.MPLS

别名

第 5202 行

别名目标 std.os.linux.PF.MPLS

std.os.linux.AF.NETBEUI

别名

第 5186 行

别名目标 std.os.linux.PF.NETBEUI

std.os.linux.AF.NETLINK

别名

第 5189 行

别名目标 std.os.linux.PF.NETLINK

std.os.linux.AF.NETROM

别名

第 5179 行

别名目标 std.os.linux.PF.NETROM

std.os.linux.AF.NFC

别名

第 5213 行

别名目标 std.os.linux.PF.NFC

std.os.linux.AF.PACKET

别名

第 5191 行

别名目标 std.os.linux.PF.PACKET

std.os.linux.AF.PHONET

别名

第 5209 行

别名目标 std.os.linux.PF.PHONET

std.os.linux.AF.PPPOX

别名

第 5198 行

别名目标 std.os.linux.PF.PPPOX

std.os.linux.AF.QIPCRTR

别名

第 5216 行

别名目标 std.os.linux.PF.QIPCRTR

std.os.linux.AF.RDS

别名

第 5195 行

别名目标 std.os.linux.PF.RDS

std.os.linux.AF.ROSE

别名

第 5184 行

别名目标 std.os.linux.PF.ROSE

std.os.linux.AF.ROUTE

别名

第 5190 行

别名目标 std.os.linux.PF.ROUTE

std.os.linux.AF.RXRPC

别名

第 5207 行

别名目标 std.os.linux.PF.RXRPC

std.os.linux.AF.SECURITY

别名

第 5187 行

别名目标 std.os.linux.PF.SECURITY

std.os.linux.AF.SMC

别名

第 5217 行

别名目标 std.os.linux.PF.SMC

std.os.linux.AF.SNA

别名

第 5196 行

别名目标 std.os.linux.PF.SNA

std.os.linux.AF.TIPC

别名

第 5204 行

别名目标 std.os.linux.PF.TIPC

std.os.linux.AF.UNIX

别名

第 5173 行

别名目标 std.os.linux.AF.LOCAL

std.os.linux.AF.UNSPEC

别名

第 5171 行

别名目标 std.os.linux.PF.UNSPEC

std.os.linux.AF.VSOCK

别名

第 5214 行

别名目标 std.os.linux.PF.VSOCK

std.os.linux.AF.WANPIPE

别名

第 5199 行

别名目标 std.os.linux.PF.WANPIPE

std.os.linux.AF.X25

别名

第 5182 行

别名目标 std.os.linux.PF.X25

std.os.linux.AF.XDP

别名

第 5218 行

别名目标 std.os.linux.PF.XDP

std.os.linux.AI

容器

第 8338 行

字段

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

常量

第 106 行

std.os.linux.arch_bits

类型

第 33 行

std.os.linux.assert

别名

第 8 行

别名目标 std.debug.assert

std.os.linux.AT

命名空间

第 4479 行

std.os.linux.AT.EMPTY_PATH

常量

第 4496 行

允许空的相对路径名

std.os.linux.AT.FDCWD

常量

第 4481 行

用于指示 openat 应使用当前工作目录的特殊值。

std.os.linux.AT.HANDLE_FID

别名

第 4513 行

别名目标 std.os.linux.AT.REMOVEDIR

std.os.linux.AT.NO_AUTOMOUNT

常量

第 4493 行

抑制末尾分量的自动挂载遍历

std.os.linux.AT.RECURSIVE

常量

第 4511 行

应用于整个子树

std.os.linux.AT.REMOVEDIR

常量

第 4487 行

移除目录,而非解除文件链接

std.os.linux.AT.STATX_DONT_SYNC

常量

第 4508 行

  • 不与服务器同步属性

std.os.linux.AT.STATX_FORCE_SYNC

常量

第 4505 行

  • 强制将属性与服务器同步。

std.os.linux.AT.STATX_SYNC_AS_STAT

常量

第 4502 行

  • 执行与 stat() 相同的操作

std.os.linux.AT.STATX_SYNC_TYPE

常量

第 4499 行

statx() 所需的同步类型

std.os.linux.AT.SYMLINK_FOLLOW

常量

第 4490 行

跟随符号链接。

std.os.linux.AT.SYMLINK_NOFOLLOW

常量

第 4484 行

不跟随符号链接

std.os.linux.AUDIT

命名空间

第 11009 行

std.os.linux.AUDIT.ARCH

容器

第 11010 行

字段

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"

常量

第 11012 行

std.os.linux.AUDIT.ARCH.CONVENTION_MIPS64_N32

常量

第 11011 行

std.os.linux.AUDIT.ARCH.current

常量

第 11073 行

AUDIT.ARCH

std.os.linux.AUDIT.ARCH.LE

常量

第 11013 行

std.os.linux.AUDIT.ARCH.toAudit

函数

第 11069 行

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

参数

em: elf.EM
flags: u32

std.os.linux.bind

函数

第 2881 行

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

参数

fd: fd_t
addr: *const sockaddr
len: socklen_t

std.os.linux.blkcnt_t

类型

第 111 行

std.os.linux.blksize_t

类型

第 112 行

std.os.linux.bpf

函数

第 3253 行

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

参数

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

std.os.linux.BPF

别名

第 127 行

别名目标 std.os.linux.bpf

std.os.linux.brk

函数

第 1047 行

pub fn brk(addr: usize) usize

参数

addr: usize

std.os.linux.BSDLY

容器

第 8692 行

字段

BS0 = 0
BS1 = 1

std.os.linux.builtin

常量

第 7 行

std.os.linux.cache_stat

容器

第 11196 行

字段

cache: u64

缓存页数量。

dirty: u64

脏页数量。

writeback: u64

标记为待写回的页数。

evicted: u64

从缓存中逐出的页数。

recently_evicted: u64

近期被逐出的页面数量。 若页面最近才被逐出,则再次进入缓存意味着它仍被系统积极使用, 且系统正面临内存压力。

std.os.linux.cache_stat_range

容器

第 11191 行

字段

off: u64
len: u64

std.os.linux.cachestat

函数

第 3446 行

查询文件的页缓存统计信息。

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

参数

fd: fd_t

用于获取统计信息的已打开文件描述符。

cstat_range: *const cache_stat_range

要查询的 fd 中的字节范围。 当 len > 0 时,范围为 [off..off + len]。 当 len == 0 时,范围从 off 到 fd 末尾。

cstat: *cache_stat

存储页缓存统计信息的结构体。

flags: u32

当前未使用,必须设为 0。

std.os.linux.CAP

命名空间

第 7205 行

std.os.linux.cap_t

容器

第 7262 行

字段

std.os.linux.cap_user_data_t

容器

第 7272 行

字段

effective: u32
permitted: u32
inheritable: u32

std.os.linux.cap_user_header_t

容器

第 7267 行

字段

version: u32
pid: usize

std.os.linux.CAP.AUDIT_CONTROL

常量

第 7236 行

std.os.linux.CAP.AUDIT_READ

常量

第 7243 行

std.os.linux.CAP.AUDIT_WRITE

常量

第 7235 行

std.os.linux.CAP.BLOCK_SUSPEND

常量

第 7242 行

std.os.linux.CAP.BPF

常量

第 7245 行

std.os.linux.CAP.CHECKPOINT_RESTORE

常量

第 7246 行

std.os.linux.CAP.CHOWN

常量

第 7206 行

std.os.linux.CAP.DAC_OVERRIDE

常量

第 7207 行

std.os.linux.CAP.DAC_READ_SEARCH

常量

第 7208 行

std.os.linux.CAP.FOWNER

常量

第 7209 行

std.os.linux.CAP.FSETID

常量

第 7210 行

std.os.linux.CAP.IPC_LOCK

常量

第 7220 行

std.os.linux.CAP.IPC_OWNER

常量

第 7221 行

std.os.linux.CAP.KILL

常量

第 7211 行

std.os.linux.CAP.LAST_CAP

别名

第 7247 行

别名目标 std.os.linux.CAP.CHECKPOINT_RESTORE

std.os.linux.CAP.LEASE

常量

第 7234 行

std.os.linux.CAP.LINUX_IMMUTABLE

常量

第 7215 行

std.os.linux.CAP.MAC_ADMIN

常量

第 7239 行

std.os.linux.CAP.MAC_OVERRIDE

常量

第 7238 行

std.os.linux.CAP.MKNOD

常量

第 7233 行

std.os.linux.CAP.NET_ADMIN

常量

第 7218 行

std.os.linux.CAP.NET_BIND_SERVICE

常量

第 7216 行

std.os.linux.CAP.NET_BROADCAST

常量

第 7217 行

std.os.linux.CAP.NET_RAW

常量

第 7219 行

std.os.linux.CAP.PERFMON

常量

第 7244 行

std.os.linux.CAP.SETFCAP

常量

第 7237 行

std.os.linux.CAP.SETGID

常量

第 7212 行

std.os.linux.CAP.SETPCAP

常量

第 7214 行

std.os.linux.CAP.SETUID

常量

第 7213 行

std.os.linux.CAP.SYS_ADMIN

常量

第 7227 行

std.os.linux.CAP.SYS_BOOT

常量

第 7228 行

std.os.linux.CAP.SYS_CHROOT

常量

第 7224 行

std.os.linux.CAP.SYS_MODULE

常量

第 7222 行

std.os.linux.CAP.SYS_NICE

常量

第 7229 行

std.os.linux.CAP.SYS_PACCT

常量

第 7226 行

std.os.linux.CAP.SYS_PTRACE

常量

第 7225 行

std.os.linux.CAP.SYS_RAWIO

常量

第 7223 行

std.os.linux.CAP.SYS_RESOURCE

常量

第 7230 行

std.os.linux.CAP.SYS_TIME

常量

第 7231 行

std.os.linux.CAP.SYS_TTY_CONFIG

常量

第 7232 行

std.os.linux.CAP.SYSLOG

常量

第 7240 行

std.os.linux.CAP.TO_INDEX

函数

第 7257 行

pub fn TO_INDEX(cap: u8) u8

参数

cap: u8

std.os.linux.CAP.TO_MASK

函数

第 7253 行

pub fn TO_MASK(cap: u8) u32

参数

cap: u8

std.os.linux.CAP.valid

函数

第 7249 行

pub fn valid(x: u8) bool

参数

x: u8

std.os.linux.CAP.WAKE_ALARM

常量

第 7241 行

std.os.linux.capget

函数

第 3177 行

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

参数

std.os.linux.capset

函数

第 3181 行

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

参数

hdrp: *cap_user_header_t
datap: *const cap_user_data_t

std.os.linux.cc_t

类型

第 8875 行

std.os.linux.chdir

函数

第 1075 行

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

参数

path: [*:0]const u8

std.os.linux.chmod

函数

第 2051 行

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

参数

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

std.os.linux.chown

函数

第 2071 行

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

参数

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

std.os.linux.chroot

函数

第 1083 行

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

参数

path: [*:0]const u8

std.os.linux.CLD

容器

第 7474 行

字段

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

std.os.linux.CLOCK

别名

第 6552 行

别名目标 std.os.linux.clockid_t

std.os.linux.clock_getres

函数

第 2461 行

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

参数

clk_id: clockid_t
tp: *timespec

std.os.linux.clock_gettime

函数

第 2433 行

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

参数

clk_id: clockid_t
tp: *timespec

std.os.linux.clock_nanosleep

函数

第 2477 行

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

参数

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

std.os.linux.clock_settime

函数

第 2469 行

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

参数

clk_id: clockid_t
tp: *const timespec

std.os.linux.clock_t

类型

第 123 行

std.os.linux.clockid_t

容器

第 6554 行

字段

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

函数

第 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

参数

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

命名空间

第 6604 行

std.os.linux.CLONE.CHILD_CLEARTID

常量

第 6618 行

std.os.linux.CLONE.CHILD_SETTID

常量

第 6621 行

std.os.linux.CLONE.CLEAR_SIGHAND

常量

第 6633 行

清除所有信号处理器,并重置为 SIG_DFL。

std.os.linux.CLONE.DETACHED

常量

第 6619 行

std.os.linux.CLONE.FILES

常量

第 6607 行

std.os.linux.CLONE.FS

常量

第 6606 行

std.os.linux.CLONE.INTO_CGROUP

常量

第 6635 行

具有相应权限时,克隆到指定 cgroup。

std.os.linux.CLONE.IO

常量

第 6628 行

std.os.linux.CLONE.NEWCGROUP

常量

第 6622 行

std.os.linux.CLONE.NEWIPC

常量

第 6624 行

std.os.linux.CLONE.NEWNET

常量

第 6627 行

std.os.linux.CLONE.NEWNS

常量

第 6614 行

std.os.linux.CLONE.NEWPID

常量

第 6626 行

std.os.linux.CLONE.NEWTIME

常量

第 6640 行

新的时间命名空间

std.os.linux.CLONE.NEWUSER

常量

第 6625 行

std.os.linux.CLONE.NEWUTS

常量

第 6623 行

std.os.linux.CLONE.PARENT

常量

第 6612 行

std.os.linux.CLONE.PARENT_SETTID

常量

第 6617 行

std.os.linux.CLONE.PIDFD

常量

第 6609 行

std.os.linux.CLONE.PTRACE

常量

第 6610 行

std.os.linux.CLONE.SETTLS

常量

第 6616 行

std.os.linux.CLONE.SIGHAND

常量

第 6608 行

std.os.linux.CLONE.SYSVSEM

常量

第 6615 行

std.os.linux.CLONE.THREAD

常量

第 6613 行

std.os.linux.CLONE.UNTRACED

常量

第 6620 行

std.os.linux.CLONE.VFORK

常量

第 6611 行

std.os.linux.CLONE.VM

常量

第 6605 行

std.os.linux.clone2

函数

第 2021 行

另请参见 clone(来自架构专属的包含文件)

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

参数

flags: u32
child_stack_ptr: usize

std.os.linux.clone5

函数

第 2016 行

另请参见 clone(来自架构专属的包含文件)

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

参数

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

std.os.linux.close

函数

第 2030 行

pub fn close(fd: fd_t) usize

参数

fd: fd_t

std.os.linux.close_range

函数

第 2043 行

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

参数

first: fd_t
last: fd_t
flags: CLOSE_RANGE

std.os.linux.CLOSE_RANGE

容器

第 2034 行

字段

_0: u1 = 0
UNSHARE: bool

关闭文件描述符前,先取消共享文件描述符表。

CLOEXEC: bool

设置 FD_CLOEXEC 位,而不关闭文件描述符。

_: u29 = 0

std.os.linux.cmsg_align

常量

第 11248 行

std.os.linux.cmsghdr

容器

第 11240 行

字段

len: usize

内核和 glibc 对此字段使用 usize;musl 使用 socklen_t。

level: i32
type: i32

std.os.linux.connect

函数

第 2832 行

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

参数

fd: fd_t
addr: *const anyopaque
len: socklen_t

std.os.linux.copy_file_range

函数

第 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

参数

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

函数

第 7313 行

pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t

参数

set: cpu_set_t

std.os.linux.cpu_count_t

常量

第 7311 行

std.os.linux.cpu_set_t

类型

第 7310 行

std.os.linux.CPU_SETSIZE

常量

第 7309 行

std.os.linux.CRDLY

容器

第 8676 行

字段

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

std.os.linux.create

函数

第 2006 行

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

参数

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

std.os.linux.CSIGNAL

常量

第 6602 行

std.os.linux.CSIZE

容器

第 8759 行

字段

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

std.os.linux.dev_t

类型

第 113 行

std.os.linux.dirent64

容器

第 7294 行

字段

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

std.os.linux.dl

别名

第 12 行

别名目标 std.dynamic_library

std.os.linux.dl_phdr_info

容器

第 7302 行

字段

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

std.os.linux.DT

命名空间

第 6067 行

std.os.linux.DT.BLK

常量

第 6072 行

std.os.linux.DT.CHR

常量

第 6070 行

std.os.linux.DT.DIR

常量

第 6071 行

std.os.linux.DT.FIFO

常量

第 6069 行

std.os.linux.DT.LNK

常量

第 6074 行

std.os.linux.DT.REG

常量

第 6073 行

std.os.linux.DT.SOCK

常量

第 6075 行

std.os.linux.DT.UNKNOWN

常量

第 6068 行

std.os.linux.DT.WHT

常量

第 6076 行

std.os.linux.dup

函数

第 1051 行

pub fn dup(old: fd_t) usize

参数

old: fd_t

std.os.linux.dup2

函数

第 1055 行

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

参数

old: fd_t
new: fd_t

std.os.linux.dup3

函数

第 1071 行

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

参数

old: fd_t
new: fd_t
flags: u32

std.os.linux.E

类型

第 3584 行

std.os.linux.EFD

命名空间

第 6643 行

std.os.linux.EFD.CLOEXEC

常量

第 6645 行

std.os.linux.EFD.NONBLOCK

常量

第 6646 行

std.os.linux.EFD.SEMAPHORE

常量

第 6644 行

std.os.linux.elf

别名

第 10 行

别名目标 std.elf

std.os.linux.elf_aux_maybe

变量

第 964 行

由启动代码设置,供 getauxval 使用。

?[*]std.elf.Auxv

std.os.linux.Elf_Symndx

类型

第 2424 行

std.os.linux.EPOLL

命名空间

第 6528 行

std.os.linux.epoll_create

函数

第 3091 行

pub fn epoll_create() usize

std.os.linux.epoll_create1

函数

第 3095 行

pub fn epoll_create1(flags: u32) usize

参数

flags: u32

std.os.linux.epoll_ctl

函数

第 3099 行

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

参数

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

std.os.linux.epoll_data

容器

第 7161 行

字段

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

std.os.linux.epoll_event

容器

第 7168 行

字段

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

std.os.linux.epoll_pwait

函数

第 3107 行

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

参数

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

std.os.linux.epoll_wait

函数

第 3103 行

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

参数

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

std.os.linux.EPOLL.CLOEXEC

常量

第 6529 行

std.os.linux.EPOLL.CTL_ADD

常量

第 6531 行

std.os.linux.EPOLL.CTL_DEL

常量

第 6532 行

std.os.linux.EPOLL.CTL_MOD

常量

第 6533 行

std.os.linux.EPOLL.ERR

常量

第 6543 行

std.os.linux.EPOLL.ET

常量

第 6549 行

std.os.linux.EPOLL.EXCLUSIVE

常量

第 6546 行

std.os.linux.EPOLL.HUP

常量

第 6544 行

std.os.linux.EPOLL.IN

常量

第 6535 行

std.os.linux.EPOLL.MSG

常量

第 6542 行

std.os.linux.EPOLL.ONESHOT

常量

第 6548 行

std.os.linux.EPOLL.OUT

常量

第 6537 行

std.os.linux.EPOLL.PRI

常量

第 6536 行

std.os.linux.EPOLL.RDBAND

常量

第 6539 行

std.os.linux.EPOLL.RDHUP

常量

第 6545 行

std.os.linux.EPOLL.RDNORM

常量

第 6538 行

std.os.linux.EPOLL.WAKEUP

常量

第 6547 行

std.os.linux.EPOLL.WRBAND

常量

第 6541 行

std.os.linux.EPOLL.WRNORM

常量

第 6540 行

std.os.linux.errno

函数

第 1042 行

从系统调用返回值中获取 errno。SUCCESS 表示无错误。

pub fn errno(r: anytype) E

std.os.linux.ETH

命名空间

第 5812 行

IEEE 802.3 以太网魔数常量。帧大小不含前导码 及 FCS/CRC(帧校验序列)。

std.os.linux.ETH.ALEN

常量

第 5814 行

单个以太网地址的字节数

std.os.linux.ETH.DATA_LEN

常量

第 5822 行

有效载荷中的最大字节数

std.os.linux.ETH.FCS_LEN

常量

第 5826 行

FCS 的字节数

std.os.linux.ETH.FRAME_LEN

常量

第 5824 行

不含 FCS 的帧最大字节数

std.os.linux.ETH.HLEN

常量

第 5818 行

首部总字节数

std.os.linux.ETH.MAX_MTU

常量

第 5831 行

65535,与 IP_MAX_MTU 相同

std.os.linux.ETH.MIN_MTU

常量

第 5829 行

RFC791 规定的最小 IPv4 MTU

std.os.linux.ETH.P

命名空间

第 5834 行

这些是已定义的以太网协议标识符。

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

常量

第 5940 行

IEEE 1588 时间同步

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

常量

第 5991 行

802.2 帧

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

常量

第 5980 行

如果以太网类型字段的值大于此值,则该帧为 Ethernet II;否则为 802.3。

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

常量

第 5985 行

802.3 帧的虚拟类型

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

常量

第 5924 行

802.1 本地实验协议 1。

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

常量

第 5922 行

802.1ad 服务 VLAN

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

常量

第 5936 行

802.1ah 骨干网服务标签

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

常量

第 5956 行

IEEE 802.21 媒体无关切换协议。

std.os.linux.ETH.P.AARP

常量

第 5882 行

Appletalk 的 AARP

std.os.linux.ETH.P.AF_IUCV

常量

第 5978 行

IBM af_iucv [非正式注册标识]

std.os.linux.ETH.P.ALL

常量

第 5989 行

每个数据包(务必谨慎!!!)

std.os.linux.ETH.P.AOE

常量

第 5918 行

基于以太网的 ATA

std.os.linux.ETH.P.ARCNET

常量

第 6023 行

ArcNet 对应 1A :-)

std.os.linux.ETH.P.ARP

常量

第 5850 行

地址解析数据包

std.os.linux.ETH.P.ATALK

常量

第 5880 行

Appletalk 的 DDP

std.os.linux.ETH.P.ATMFATE

常量

第 5910 行

基于以太网的基于帧 ATM 传输

std.os.linux.ETH.P.ATMMPOA

常量

第 5902 行

ATM 上的多协议

std.os.linux.ETH.P.AX25

常量

第 5987 行

AX.25 的占位协议标识

std.os.linux.ETH.P.BATMAN

常量

第 5858 行

B.A.T.M.A.N.-Advanced 数据包[非正式注册 ID]。

std.os.linux.ETH.P.BPQ

常量

第 5852 行

G8BPQ AX.25 以太网数据包[非正式注册 ID]。

std.os.linux.ETH.P.CAIF

常量

第 6033 行

ST-Ericsson CAIF 协议

std.os.linux.ETH.P.CAN

常量

第 6003 行

CAN:控制器局域网

std.os.linux.ETH.P.CANFD

常量

第 6005 行

CANFD:CAN 灵活数据速率

std.os.linux.ETH.P.CANXL

常量

第 6007 行

CANXL:扩展帧长度

std.os.linux.ETH.P.CFM

常量

第 5946 行

连通性故障管理

std.os.linux.ETH.P.CONTROL

常量

第 6015 行

网卡专用控制帧

std.os.linux.ETH.P.CUST

常量

第 5872 行

DEC 客户使用

std.os.linux.ETH.P.DDCMP

常量

第 5995 行

DEC DDCMP:仅供内部使用

std.os.linux.ETH.P.DEC

常量

第 5860 行

DEC 分配的协议

std.os.linux.ETH.P.DIAG

常量

第 5870 行

DEC 诊断

std.os.linux.ETH.P.DNA_DL

常量

第 5862 行

DEC DNA 转储/加载

std.os.linux.ETH.P.DNA_RC

常量

第 5864 行

DEC DNA 远程控制台

std.os.linux.ETH.P.DNA_RT

常量

第 5866 行

DEC DNA 路由

std.os.linux.ETH.P.DSA

常量

第 6025 行

分布式交换机架构

std.os.linux.ETH.P.DSA_8021Q

常量

第 5972 行

用于 DSA 的伪 VLAN 头部[非正式注册的 ID]

std.os.linux.ETH.P.DSA_A5PSW

常量

第 5974 行

A5PSW 标签值[非正式注册的 ID]

std.os.linux.ETH.P.ECONET

常量

第 6019 行

Acorn Econet

std.os.linux.ETH.P.EDSA

常量

第 5970 行

以太网类型 DSA[非正式注册 ID]。

std.os.linux.ETH.P.ERSPAN

常量

第 5886 行

ERSPAN 类型 II

std.os.linux.ETH.P.ERSPAN2

常量

第 5844 行

ERSPAN 版本 2(类型 III)

std.os.linux.ETH.P.ETHERCAT

常量

第 5920 行

EtherCAT

std.os.linux.ETH.P.FCOE

常量

第 5948 行

基于以太网的光纤通道

std.os.linux.ETH.P.FIP

常量

第 5954 行

FCoE 初始化协议

std.os.linux.ETH.P.HDLC

常量

第 6021 行

HDLC 帧

std.os.linux.ETH.P.HSR

常量

第 5958 行

IEC 62439-3 的 HSRv1

std.os.linux.ETH.P.IBOE

常量

第 5950 行

基于以太网的 InfiniBand

std.os.linux.ETH.P.IEEE802154

常量

第 6031 行

IEEE802.15.4 帧

std.os.linux.ETH.P.IEEEPUP

常量

第 5854 行

Xerox IEEE802.3 PUP 数据包

std.os.linux.ETH.P.IEEEPUPAT

常量

第 5856 行

Xerox IEEE802.3 PUP 地址转换数据包

std.os.linux.ETH.P.IFE

常量

第 5976 行

ForCES FE 间 LFB 类型

std.os.linux.ETH.P.IP

常量

第 5846 行

互联网协议数据包

std.os.linux.ETH.P.IPV6

常量

第 5890 行

bluebook 上的 IPv6

std.os.linux.ETH.P.IPX

常量

第 5888 行

DIX 上的 IPX

std.os.linux.ETH.P.IRDA

常量

第 6017 行

Linux-IrDA

std.os.linux.ETH.P.LAT

常量

第 5868 行

DEC LAT

std.os.linux.ETH.P.LINK_CTL

常量

第 5908 行

HPNA、无线局域网链路本地隧道

std.os.linux.ETH.P.LLDP

常量

第 5930 行

链路层发现协议

std.os.linux.ETH.P.LOCALTALK

常量

第 6001 行

Localtalk 伪类型

std.os.linux.ETH.P.LOOP

常量

第 5836 行

以太网回环数据包

std.os.linux.ETH.P.LOOPBACK

常量

第 5962 行

以太网回环数据包,遵循 IEEE 802.3

std.os.linux.ETH.P.MACSEC

常量

第 5934 行

802.1ae MACsec

std.os.linux.ETH.P.MAP

常量

第 6037 行

Qualcomm 多路复用及聚合协议。

std.os.linux.ETH.P.MCTP

常量

第 6039 行

管理组件传输协议数据包

std.os.linux.ETH.P.MOBITEX

常量

第 6013 行

Mobitex(kaz@cafe.net)

std.os.linux.ETH.P.MPLS_MC

常量

第 5900 行

MPLS 组播流量

std.os.linux.ETH.P.MPLS_UC

常量

第 5898 行

MPLS 单播流量

std.os.linux.ETH.P.MRP

常量

第 5932 行

介质冗余协议

std.os.linux.ETH.P.MVRP

常量

第 5938 行

802.1Q MVRP

std.os.linux.ETH.P.NCSI

常量

第 5942 行

NCSI 协议

std.os.linux.ETH.P.NSH

常量

第 5960 行

网络服务头

std.os.linux.ETH.P.P_8021Q

常量

第 5884 行

802.1Q VLAN 扩展头

std.os.linux.ETH.P.PAE

常量

第 5912 行

端口访问实体(IEEE 802.1X)

std.os.linux.ETH.P.PAUSE

常量

第 5892 行

IEEE 暂停帧。参见 802.3 31B

std.os.linux.ETH.P.PHONET

常量

第 6029 行

Nokia Phonet 帧

std.os.linux.ETH.P.PPP_DISC

常量

第 5904 行

PPPoE 发现消息

std.os.linux.ETH.P.PPP_MP

常量

第 5999 行

PPP MP 帧的虚拟类型

std.os.linux.ETH.P.PPP_SES

常量

第 5906 行

PPPoE 会话消息

std.os.linux.ETH.P.PPPTALK

常量

第 6009 行

PPP 上 Atalk 的虚拟类型

std.os.linux.ETH.P.PREAUTH

常量

第 5926 行

802.11 预认证

std.os.linux.ETH.P.PROFINET

常量

第 5914 行

PROFINET

std.os.linux.ETH.P.PRP

常量

第 5944 行

IEC 62439-3 PRP/HSRv0

std.os.linux.ETH.P.PUP

常量

第 5838 行

Xerox PUP 数据包

std.os.linux.ETH.P.PUPAT

常量

第 5840 行

Xerox PUP 地址转换数据包

std.os.linux.ETH.P.QINQ1

常量

第 5964 行

已弃用的 QinQ VLAN [非正式注册标识]

std.os.linux.ETH.P.QINQ2

常量

第 5966 行

已弃用的 QinQ VLAN [非正式注册标识]

std.os.linux.ETH.P.QINQ3

常量

第 5968 行

已弃用的 QinQ VLAN [非正式注册标识]

std.os.linux.ETH.P.RARP

常量

第 5878 行

反向地址解析数据包

std.os.linux.ETH.P.REALTEK

常量

第 5916 行

多种专有协议

std.os.linux.ETH.P.SCA

常量

第 5874 行

DEC 系统通信架构

std.os.linux.ETH.P.SLOW

常量

第 5894 行

慢协议。参见 802.3ad 43B

std.os.linux.ETH.P.SNAP

常量

第 5993 行

仅供内部使用

std.os.linux.ETH.P.TDLS

常量

第 5952 行

TDLS

std.os.linux.ETH.P.TEB

常量

第 5876 行

透明以太网桥接

std.os.linux.ETH.P.TIPC

常量

第 5928 行

TIPC

std.os.linux.ETH.P.TR_802_2

常量

第 6011 行

802.2 帧

std.os.linux.ETH.P.TRAILER

常量

第 6027 行

Trailer switch 标记

std.os.linux.ETH.P.TSN

常量

第 5842 行

TSN(IEEE 1722)数据包

std.os.linux.ETH.P.WAN_PPP

常量

第 5997 行

WAN PPP 帧的占位类型

std.os.linux.ETH.P.WCCP

常量

第 5896 行

draft-wilson-wrec-wccp-v2-00.txt 定义的 Web 缓存协调协议

std.os.linux.ETH.P.X25

常量

第 5848 行

CCITT X.25

std.os.linux.ETH.P.XDSA

常量

第 6035 行

多路复用 DSA 协议

std.os.linux.ETH.TLEN

常量

第 5816 行

以太网类型字段的字节数

std.os.linux.ETH.ZLEN

常量

第 5820 行

不含 FC 的帧最小字节数

std.os.linux.eventfd

函数

第 3119 行

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

参数

count: u32
flags: u32

std.os.linux.execve

函数

第 1087 行

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

参数

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

std.os.linux.execveat

函数

第 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

参数

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

容器

第 1091 行

字段

_1: u8 = 0
SYMLINK_NOFOLLOW: bool

不跟随符号链接。

_200: u3 = 0
EMPTY_PATH: bool

允许空的相对路径名。

_: u19 = 0

std.os.linux.exit

函数

第 2127 行

pub fn exit(status: i32) noreturn

参数

status: i32

std.os.linux.exit_group

函数

第 2132 行

pub fn exit_group(status: i32) noreturn

参数

status: i32

std.os.linux.extern_getauxval

常量

第 967 行

使用外部还是内部的 getauxval 实现。

std.os.linux.F

命名空间

第 2277 行

std.os.linux.F_OK

常量

第 4660 行

std.os.linux.F_OWNER

容器

第 2391 行

字段

TID = 0
PID = 1
PGRP = 2
_

std.os.linux.f_owner_ex

容器

第 2398 行

字段

type: F_OWNER
pid: pid_t

std.os.linux.F.ADD_SEALS

常量

第 2375 行

std.os.linux.F.CANCELLK

常量

第 2371 行

std.os.linux.F.CREATED_QUERY

常量

第 2370 行

std.os.linux.F.DUPFD

常量

第 2278 行

std.os.linux.F.DUPFD_CLOEXEC

常量

第 2372 行

std.os.linux.F.DUPFD_QUERY

常量

第 2369 行

std.os.linux.F.GET_FILE_RW_HINT

常量

第 2387 行

std.os.linux.F.GET_RW_HINT

常量

第 2385 行

std.os.linux.F.GET_SEALS

常量

第 2376 行

std.os.linux.F.GET_SET_LK

类型

第 2291 行

std.os.linux.F.GET_SET_LK.GETLK

常量

第 2293 行

std.os.linux.F.GET_SET_LK.GETLK

常量

第 2299 行

std.os.linux.F.GET_SET_LK.GETLK

常量

第 2304 行

std.os.linux.F.GET_SET_LK.GETLK

常量

第 2310 行

std.os.linux.F.GET_SET_LK.GETLK

常量

第 2315 行

std.os.linux.F.GET_SET_LK.GETLK

常量

第 2320 行

std.os.linux.F.GET_SET_LK.GETLK

常量

第 2324 行

std.os.linux.F.GET_SET_LK.SETLK

常量

第 2294 行

std.os.linux.F.GET_SET_LK.SETLK

常量

第 2300 行

std.os.linux.F.GET_SET_LK.SETLK

常量

第 2305 行

std.os.linux.F.GET_SET_LK.SETLK

常量

第 2311 行

std.os.linux.F.GET_SET_LK.SETLK

常量

第 2316 行

std.os.linux.F.GET_SET_LK.SETLK

常量

第 2321 行

std.os.linux.F.GET_SET_LK.SETLK

常量

第 2325 行

std.os.linux.F.GET_SET_LK.SETLKW

常量

第 2295 行

std.os.linux.F.GET_SET_LK.SETLKW

常量

第 2301 行

std.os.linux.F.GET_SET_LK.SETLKW

常量

第 2306 行

std.os.linux.F.GET_SET_LK.SETLKW

常量

第 2312 行

std.os.linux.F.GET_SET_LK.SETLKW

常量

第 2317 行

std.os.linux.F.GET_SET_LK.SETLKW

常量

第 2322 行

std.os.linux.F.GET_SET_LK.SETLKW

常量

第 2326 行

std.os.linux.F.GET_SET_OWN

类型

第 2329 行

std.os.linux.F.GET_SET_OWN.GETOWN

常量

第 2331 行

std.os.linux.F.GET_SET_OWN.GETOWN

常量

第 2335 行

std.os.linux.F.GET_SET_OWN.GETOWN

常量

第 2339 行

std.os.linux.F.GET_SET_OWN.GETOWN

常量

第 2343 行

std.os.linux.F.GET_SET_OWN.SETOWN

常量

第 2332 行

std.os.linux.F.GET_SET_OWN.SETOWN

常量

第 2336 行

std.os.linux.F.GET_SET_OWN.SETOWN

常量

第 2340 行

std.os.linux.F.GET_SET_OWN.SETOWN

常量

第 2344 行

std.os.linux.F.GETFD

常量

第 2279 行

std.os.linux.F.GETFL

常量

第 2281 行

std.os.linux.F.GETLEASE

常量

第 2367 行

std.os.linux.F.GETLK

常量

第 2284 行

std.os.linux.F.GETOWN

常量

第 2289 行

std.os.linux.F.GETOWN_EX

常量

第 2352 行

std.os.linux.F.GETOWNER_UIDS

常量

第 2354 行

std.os.linux.F.GETPIPE_SZ

常量

第 2374 行

std.os.linux.F.GETSIG

常量

第 2349 行

std.os.linux.F.LINUX_SPECIFIC_BASE

常量

第 2364 行

std.os.linux.F.NOTIFY

常量

第 2368 行

std.os.linux.F.OFD_GETLK

常量

第 2356 行

std.os.linux.F.OFD_SETLK

常量

第 2357 行

std.os.linux.F.OFD_SETLKW

常量

第 2358 行

std.os.linux.F.RDLCK

常量

第 2360 行

std.os.linux.F.SEAL_EXEC

常量

第 2383 行

std.os.linux.F.SEAL_FUTURE_WRITE

常量

第 2382 行

std.os.linux.F.SEAL_GROW

常量

第 2380 行

std.os.linux.F.SEAL_SEAL

常量

第 2378 行

std.os.linux.F.SEAL_SHRINK

常量

第 2379 行

std.os.linux.F.SEAL_WRITE

常量

第 2381 行

std.os.linux.F.SET_FILE_RW_HINT

常量

第 2388 行

std.os.linux.F.SET_RW_HINT

常量

第 2386 行

std.os.linux.F.SETFD

常量

第 2280 行

std.os.linux.F.SETFL

常量

第 2282 行

std.os.linux.F.SETLEASE

常量

第 2366 行

std.os.linux.F.SETLK

常量

第 2285 行

std.os.linux.F.SETLKW

常量

第 2286 行

std.os.linux.F.SETOWN

常量

第 2288 行

std.os.linux.F.SETOWN_EX

常量

第 2351 行

std.os.linux.F.SETPIPE_SZ

常量

第 2373 行

std.os.linux.F.SETSIG

常量

第 2348 行

std.os.linux.F.UNLCK

常量

第 2362 行

std.os.linux.F.WRLCK

常量

第 2361 行

std.os.linux.faccessat

函数

第 1884 行

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

参数

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

std.os.linux.fadvise

函数

第 3352 行

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

参数

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

std.os.linux.FALLOC

命名空间

第 4516 行

std.os.linux.FALLOC.FL_COLLAPSE_RANGE

常量

第 4527 行

移除文件的某个范围,而不在文件中留下空洞

std.os.linux.FALLOC.FL_INSERT_RANGE

常量

第 4533 行

在文件大小范围内插入空间,不覆盖任何已有数据

std.os.linux.FALLOC.FL_KEEP_SIZE

常量

第 4518 行

默认值为扩展大小

std.os.linux.FALLOC.FL_NO_HIDE_STALE

常量

第 4524 行

保留码点

std.os.linux.FALLOC.FL_PUNCH_HOLE

常量

第 4521 行

释放该范围

std.os.linux.FALLOC.FL_UNSHARE_RANGE

常量

第 4536 行

取消文件大小范围内共享块的共享,而不覆盖任何已有数据

std.os.linux.FALLOC.FL_ZERO_RANGE

常量

第 4530 行

将文件某个范围转换为零,优先避免执行数据 I/O。

std.os.linux.fallocate

函数

第 1129 行

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

参数

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

std.os.linux.fanotify

命名空间

第 6728 行

std.os.linux.fanotify_init

函数

第 1347 行

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

参数

flags: fanotify.InitFlags
event_f_flags: u32

std.os.linux.fanotify_mark

函数

第 1351 行

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

参数

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

std.os.linux.fanotify.event_info_fid

容器

第 6841 行

唯一文件标识符信息记录。

此结构体用于 EVENT_INFO_TYPE.FID、 EVENT_INFO_TYPE.DFID 和 EVENT_INFO_TYPE.DFID_NAME 类型的记录。

对于 EVENT_INFO_TYPE.DFID_NAME,文件句柄之后还紧跟一个 以空字符结尾的名称。

字段

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

后面是不透明结构体 file_handle,可作为 参数传给 open_by_handle_at(2)。

std.os.linux.fanotify.event_info_header

容器

第 6850 行

跟随事件元数据的变长信息记录。

字段

info_type: EVENT_INFO_TYPE
pad: u8
len: u16

std.os.linux.fanotify.EVENT_INFO_TYPE

容器

第 6856 行

字段

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

容器

第 6817 行

字段

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

常量

第 6826 行

std.os.linux.fanotify.InitFlags

容器

第 6729 行

字段

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

容器

第 6749 行

字段

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

与 IGNORE 互斥

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

与 IGNORED_MASK 互斥

_: u21 = 0

std.os.linux.fanotify.MarkMask

容器

第 6766 行

字段

ACCESS: bool = false

文件已被访问

MODIFY: bool = false

文件已修改

ATTRIB: bool = false

元数据已更改

CLOSE_WRITE: bool = false

可写文件已关闭

CLOSE_NOWRITE: bool = false

不可写文件已关闭

OPEN: bool = false

文件已打开

MOVED_FROM: bool = false

文件从 X 移出

MOVED_TO: bool = false

文件被移动至 Y

CREATE: bool = false

已创建子文件

DELETE: bool = false

子文件已删除

DELETE_SELF: bool = false

自身已被删除

MOVE_SELF: bool = false

自身已被移动

OPEN_EXEC: bool = false

文件以执行方式打开

reserved13: u1 = 0
Q_OVERFLOW: bool = false

事件队列溢出

FS_ERROR: bool = false

文件系统错误

OPEN_PERM: bool = false

权限检查中的文件打开

ACCESS_PERM: bool = false

权限检查中访问了文件

OPEN_EXEC_PERM: bool = false

权限检查中的文件打开/执行

reserved19: u8 = 0
EVENT_ON_CHILD: bool = false

关注子事件

RENAME: bool = false

文件已重命名

reserved30: u1 = 0
ONDIR: bool = false

事件发生在目录上

reserved31: u33 = 0

std.os.linux.fanotify.response

容器

第 6829 行

字段

fd: i32
response: u32

std.os.linux.fchdir

函数

第 1079 行

pub fn fchdir(fd: fd_t) usize

参数

fd: fd_t

std.os.linux.fchmod

函数

第 2047 行

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

参数

fd: fd_t
mode: mode_t

std.os.linux.fchmodat

函数

第 2091 行

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

参数

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

std.os.linux.fchmodat2

函数

第 2095 行

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

参数

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

std.os.linux.fchown

函数

第 2059 行

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

参数

fd: fd_t
owner: uid_t
group: gid_t

std.os.linux.fchownat

函数

第 2067 行

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

参数

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

std.os.linux.fcntl

函数

第 2412 行

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

参数

fd: fd_t
cmd: i32
arg: usize

std.os.linux.FD_CLOEXEC

常量

第 4658 行

std.os.linux.fd_t

类型

第 119 行

std.os.linux.fdatasync

函数

第 3269 行

pub fn fdatasync(fd: fd_t) usize

参数

fd: fd_t

std.os.linux.FFDLY

容器

第 8702 行

字段

FF0 = 0
FF1 = 1

std.os.linux.fgetxattr

函数

第 2964 行

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

参数

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

std.os.linux.file_handle

容器

第 6869 行

字段

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

std.os.linux.flistxattr

函数

第 2952 行

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

参数

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

std.os.linux.flock

函数

第 2420 行

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

参数

fd: fd_t
operation: i32

std.os.linux.Flock

容器

第 2403 行

字段

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

std.os.linux.fork

函数

第 1105 行

pub fn fork() usize

std.os.linux.fremovexattr

函数

第 2988 行

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

参数

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

std.os.linux.fsconfig

函数

第 1538 行

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

参数

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

std.os.linux.FSCONFIG_CMD

容器

第 1519 行

字段

SET_FLAG

设置参数,但不提供值。

SET_STRING

提供字符串值来设置参数。

SET_BINARY

设置参数,提供二进制数据块值。

SET_PATH

设置参数,通过路径提供对象。

SET_PATH_EMPTY

设置参数,通过(空)路径提供对象。

SET_FD

设置参数,通过文件描述符提供对象。

CREATE

触发超级块创建。

RECONFIGURE

触发超级块重新配置。

std.os.linux.fsetxattr

函数

第 2976 行

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

参数

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

std.os.linux.fsid_t

类型

第 6876 行

std.os.linux.fsmount

函数

第 1548 行

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

参数

fsfd: fd_t
flags: FSMOUNT
attr_flags: MOUNT_ATTR

std.os.linux.FSMOUNT

容器

第 1542 行

字段

CLOEXEC: bool

在文件描述符上设置 CLOEXEC。

_31: u31 = 0

std.os.linux.fsopen

函数

第 1515 行

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

参数

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

std.os.linux.FSOPEN

容器

第 1509 行

字段

CLOEXEC: bool

在新 fd 上设置 CLOEXEC。

_: u31 = 0

std.os.linux.fspick

函数

第 1561 行

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

参数

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

std.os.linux.FSPICK

容器

第 1552 行

字段

CLOEXEC: bool

在新 fd 上设置 CLOEXEC。

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

std.os.linux.fsync

函数

第 3265 行

pub fn fsync(fd: fd_t) usize

参数

fd: fd_t

std.os.linux.ftruncate

函数

第 1909 行

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

参数

fd: fd_t
length: off_t

std.os.linux.futex

函数

第 1167 行

futex 第一版系统调用;另见较新的 futex2_{wait,wakeup,requeue,waitv} 系统调用。

futex_op 参数包含子命令和标志。子命令决定 后续参数中哪些参数相关。

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

参数

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

std.os.linux.futex_3arg

函数

第 1181 行

v1 futex 调用的三参数变体。仅适用于忽略其余参数的 futex_op(例如 FUTUX_OP.WAKE)。

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

参数

uaddr: *const anyopaque
futex_op: FUTEX_OP
val: u32

std.os.linux.futex_4arg

函数

第 1192 行

v1 futex 调用的四参数变体。仅适用于忽略其余参数的 futex_op(例如 FUTEX_OP.WAIT)。

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

参数

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

std.os.linux.FUTEX_COMMAND

容器

第 4541 行

字段

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

容器

第 4558 行

futex_op 参数所用的 Futex v1 API 命令和标志

字段

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

std.os.linux.futex_param4

容器

第 1156 行

字段

timeout: ?*const timespec
val2: usize

所有平台上仅使用 val2 的低 32 位。 此处采用 64 位以匹配联合体中的指针。

std.os.linux.FUTEX_WAKE_OP

容器

第 4566 行

Futex v1 FUTEX_WAKE_OP 的 val3 操作:

字段

cmd: FUTEX_WAKE_OP_CMD
arg_shift: bool = false

来自 C API FUTEX_OP_ARG_SHIFT:使用 (1 << oparg) 作为操作数

cmp: FUTEX_WAKE_OP_CMP
oparg: u12
cmdarg: u12

std.os.linux.FUTEX_WAKE_OP_CMD

容器

第 4576 行

Futex v1 中用于 FUTEX_WAKE_OP 的 cmd val3 命令。

字段

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

容器

第 4590 行

FUTEX_WAKE_OP 的 val3 cmp 所用 Futex v1 比较操作

字段

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

std.os.linux.FUTEX2_FLAGS

容器

第 4624 行

futex v2 API 的标志(futex2_wait、futex2_wake、futex2_requeue,不包括 futex2_waitv 系统调用,但也用于 futex2_waitone 结构体)。

字段

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

std.os.linux.FUTEX2_FLAGS_REQUEUE

容器

第 4618 行

截至内核 6.14,futex2_requeue 没有已定义标志。

字段

_reserved: u32 = 0

std.os.linux.FUTEX2_FLAGS_WAITV

容器

第 4613 行

截至内核 6.14,尚未为 futex2_waitv 定义任何标志。

字段

_reserved: u32 = 0

std.os.linux.futex2_requeue

函数

第 1294 行

唤醒等待方,和/或将其从一个 futex 重新排队到另一个。 与 FUTEX.CMP_REQUEUE 相同,但属于 futex2 调用族。

至少需要内核 v6.7。

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

参数

waiters: [*]const futex2_waitone

源 futex 与目标 futex。必须为包含 2 个元素的数组。

flags: FUTEX2_FLAGS_REQUEUE

当前未使用。

nr_wake: i32

在源 futex 上最多唤醒的等待者数量。

nr_requeue: i32

要转移到目标 futex 的最大等待者数量。

std.os.linux.FUTEX2_SIZE

容器

第 4605 行

对于 futex v2 API,表示 uaddr 处 futex 的大小。v1 futex 始终隐式为 U32。截至内核 v6.14,v2 futex 仅实现 U32。

字段

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

std.os.linux.futex2_wait

函数

第 1243 行

等待单个 futex。 与 futex v1 的 FUTEX.FUTEX_WAIT_BITSET 操作相同,但属于 futex2 调用族。

要求内核至少为 v6.7。

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

参数

uaddr: *const anyopaque

要等待的 futex 地址。

val: usize

uaddr 的值。

mask: usize

用于匹配传入唤醒掩码的位掩码。不得为零。

flags: FUTEX2_FLAGS
timeout: ?*const kernel_timespec

可选的绝对超时时间。即使在 32 位平台上也始终为 64 位。

clockid: clockid_t

超时使用的时钟,可以是实时时钟或单调时钟。

std.os.linux.futex2_waitone

容器

第 11180 行

用于 futex2_waitv 和 futex2_requeue。futex2_waitone 数组允许 在一次调用中等待多个 futex。

字段

val: u64

uaddr 处的预期值,大小应与 futex 一致。

uaddr: u64

等待的用户地址。在 32 位平台上,高位必须为 0。

flags: FUTEX2_FLAGS

此等待者的标志。

__reserved: u32 = 0

保留成员以维持对齐。

std.os.linux.FUTEX2_WAITONE_MAX

常量

第 4600 行

futex2_waitone 数组的最大元素数量。

std.os.linux.futex2_waitv

函数

第 1218 行

给定 futex2_waitone 数组,在每个 uaddr 上等待。 任意 uaddr 上执行 futex_wake() 都会唤醒线程。 若任一 futex 满足 *uaddr != val,系统调用立即返回。 timeout 是可选的操作绝对超时时刻。 flags 参数保留供将来使用,目前应设为 .{}。 私有 futex、大小等标志应设置在 每个 futex2_waitone 各自的 flags 中。

返回被唤醒 futex 之一在数组中的索引。 不提供其他信息:同一事件可能同时唤醒 任意数量的其他 futex;若唤醒了多个 futex, 返回索引可以指向其中任意一个。 它不一定是索引最小的 futex, 也不一定是最后被唤醒的 futex。

至少需要内核 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

参数

futexes: [*]const futex2_waitone
nr_futexes: u32

futexes 的长度。最大为 FUTEX2_WAITONE_MAX。

flags: FUTEX2_FLAGS_WAITV
timeout: ?*const kernel_timespec

可选的绝对超时时间。即使在 32 位平台上也始终为 64 位。

clockid: clockid_t

超时使用的时钟,可以是实时时钟或单调时钟。

std.os.linux.futex2_wake

函数

第 1272 行

唤醒给定 futex 上的部分或全部等待者。 与传统的 FUTEX.FUTEX_WAKE_BITSET 操作相同,但属于 futex2 调用族。

要求内核至少为 v6.7。

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

参数

uaddr: *const anyopaque

要唤醒的 futex

mask: usize

用于匹配等待者的位掩码。

nr_wake: i32

在 futex 上最多唤醒的等待者数量。

flags: FUTEX2_FLAGS

std.os.linux.futimens

函数

第 1115 行

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

参数

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

std.os.linux.getauxval

常量

第 978 行

std.os.linux.getauxval.getauxval

函数

第 987 行

extern fn getauxval(index: usize) usize

参数

index: usize

std.os.linux.getauxvalImpl

函数

第 990 行

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

参数

index: usize

std.os.linux.getcpu

函数

第 3042 行

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

参数

cpu: ?*usize
node: ?*usize

std.os.linux.getcwd

函数

第 1313 行

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

参数

buf: [*]u8
size: usize

std.os.linux.getdents

函数

第 1317 行

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

参数

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

std.os.linux.getdents64

函数

第 1326 行

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

参数

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

std.os.linux.getegid

函数

第 2563 行

pub fn getegid() gid_t

std.os.linux.geteuid

函数

第 2555 行

pub fn geteuid() uid_t

std.os.linux.getgid

函数

第 2547 行

pub fn getgid() gid_t

std.os.linux.getgroups

函数

第 2633 行

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

参数

size: usize
list: ?[*]gid_t

std.os.linux.getitimer

函数

第 3161 行

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

参数

which: i32
curr_value: *itimerspec

std.os.linux.getpeername

函数

第 2792 行

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

参数

fd: fd_t
addr: *sockaddr
len: *socklen_t

std.os.linux.getpgid

函数

第 2629 行

pub fn getpgid(pid: pid_t) usize

参数

pid: pid_t

std.os.linux.getpid

函数

第 2657 行

pub fn getpid() pid_t

std.os.linux.getppid

函数

第 2662 行

pub fn getppid() pid_t

std.os.linux.getrandom

函数

第 2194 行

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

参数

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

std.os.linux.getresgid

函数

第 2601 行

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

参数

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

std.os.linux.getresuid

函数

第 2593 行

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

参数

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

std.os.linux.getrlimit

函数

第 3277 行

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

参数

resource: rlimit_resource
rlim: *rlimit

std.os.linux.getrusage

函数

第 3209 行

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

参数

who: i32
usage: *rusage

std.os.linux.getsid

函数

第 2653 行

pub fn getsid(pid: pid_t) usize

参数

pid: pid_t

std.os.linux.getsockname

函数

第 2785 行

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

参数

fd: fd_t
addr: *sockaddr
len: *socklen_t

std.os.linux.getsockopt

函数

第 2813 行

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

参数

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

std.os.linux.gettid

函数

第 2667 行

pub fn gettid() pid_t

std.os.linux.gettimeofday

函数

第 2487 行

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

参数

tv: ?*timeval
tz: ?*timezone

std.os.linux.getuid

函数

第 2539 行

pub fn getuid() uid_t

std.os.linux.getxattr

函数

第 2956 行

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

参数

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

std.os.linux.gid_t

类型

第 122 行

std.os.linux.HOST_NAME_MAX

常量

第 8171 行

std.os.linux.HUGETLB_FLAG_ENCODE_16GB

常量

第 8462 行

std.os.linux.HUGETLB_FLAG_ENCODE_16MB

常量

第 8456 行

std.os.linux.HUGETLB_FLAG_ENCODE_1GB

常量

第 8460 行

std.os.linux.HUGETLB_FLAG_ENCODE_1MB

常量

第 8453 行

std.os.linux.HUGETLB_FLAG_ENCODE_256MB

常量

第 8458 行

std.os.linux.HUGETLB_FLAG_ENCODE_2GB

常量

第 8461 行

std.os.linux.HUGETLB_FLAG_ENCODE_2MB

常量

第 8454 行

std.os.linux.HUGETLB_FLAG_ENCODE_32MB

常量

第 8457 行

std.os.linux.HUGETLB_FLAG_ENCODE_512KB

常量

第 8452 行

std.os.linux.HUGETLB_FLAG_ENCODE_512MB

常量

第 8459 行

std.os.linux.HUGETLB_FLAG_ENCODE_64KB

常量

第 8451 行

std.os.linux.HUGETLB_FLAG_ENCODE_8MB

常量

第 8455 行

std.os.linux.HUGETLB_FLAG_ENCODE_MASK

常量

第 8450 行

std.os.linux.HUGETLB_FLAG_ENCODE_SHIFT

常量

第 8449 行

std.os.linux.HWCAP

类型

第 621 行

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

命名空间

第 672 行

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

命名空间

第 785 行

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

命名空间

第 861 行

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

命名空间

第 946 行

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

常量

第 786 行

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

常量

第 693 行

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

常量

第 878 行

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

常量

第 870 行

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

常量

第 865 行

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

常量

第 863 行

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

常量

第 687 行

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

常量

第 690 行

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

常量

第 790 行

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

常量

第 707 行

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

常量

第 868 行

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

常量

第 673 行

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

常量

第 688 行

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

常量

第 862 行

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

常量

第 876 行

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

常量

第 875 行

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

常量

第 705 行

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

常量

第 692 行

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

常量

第 724 行

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

常量

第 727 行

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

常量

第 726 行

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

常量

第 728 行

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

常量

第 729 行

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

常量

第 725 行

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

常量

第 723 行

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

常量

第 680 行

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

常量

第 721 行

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

常量

第 681 行

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

常量

第 948 行

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

常量

第 869 行

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

常量

第 717 行

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

常量

第 877 行

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

常量

第 866 行

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

常量

第 871 行

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

常量

第 686 行

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

常量

第 874 行

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

常量

第 719 行

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

常量

第 720 行

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

常量

第 722 行

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

常量

第 864 行

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

常量

第 716 行

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

常量

第 691 行

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

常量

第 695 行

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

常量

第 787 行

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

常量

第 736 行

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

常量

第 947 行

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

常量

第 689 行

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

常量

第 694 行

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

常量

第 708 行

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

常量

第 791 行

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

常量

第 867 行

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

常量

第 788 行

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

常量

第 789 行

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

常量

第 696 行

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

常量

第 714 行

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

常量

第 701 行

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

常量

第 713 行

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

常量

第 715 行

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

常量

第 700 行

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

常量

第 702 行

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

常量

第 698 行

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

常量

第 731 行

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

常量

第 732 行

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

常量

第 703 行

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

常量

第 712 行

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

常量

第 697 行

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

常量

第 699 行

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

常量

第 730 行

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

常量

第 735 行

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

常量

第 734 行

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

常量

第 733 行

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

常量

第 710 行

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

常量

第 711 行

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

常量

第 792 行

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

常量

第 718 行

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

常量

第 706 行

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

常量

第 674 行

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

常量

第 709 行

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

常量

第 675 行

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

常量

第 685 行

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

常量

第 677 行

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

常量

第 683 行

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

常量

第 684 行

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

常量

第 682 行

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

常量

第 676 行

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

常量

第 678 行

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

常量

第 679 行

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

常量

第 873 行

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

常量

第 872 行

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

常量

第 704 行

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

常量

第 758 行

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

命名空间

第 739 行

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

常量

第 749 行

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

常量

第 750 行

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

常量

第 748 行

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

常量

第 743 行

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

常量

第 742 行

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

常量

第 740 行

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

常量

第 741 行

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

常量

第 746 行

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

常量

第 747 行

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

常量

第 744 行

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

常量

第 751 行

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

常量

第 745 行

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

常量

第 859 行

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

常量

第 857 行

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

常量

第 858 行

std.os.linux.HWCAP.ADI

常量

第 943 行

std.os.linux.HWCAP.AES

常量

第 626 行

std.os.linux.HWCAP.ARCH_2_05

常量

第 840 行

std.os.linux.HWCAP.ARCH_2_06

常量

第 836 行

std.os.linux.HWCAP.ASI_BLK_INIT

常量

第 931 行

std.os.linux.HWCAP.ASI_CACHE_SPARING

常量

第 939 行

std.os.linux.HWCAP.ASIMD

常量

第 624 行

std.os.linux.HWCAP.ASIMDBF16

常量

第 782 行

std.os.linux.HWCAP.ASIMDDP

常量

第 643 行

std.os.linux.HWCAP.ASIMDDP

常量

第 780 行

std.os.linux.HWCAP.ASIMDFHM

常量

第 646 行

std.os.linux.HWCAP.ASIMDFHM

常量

第 781 行

std.os.linux.HWCAP.ASIMDHP

常量

第 633 行

std.os.linux.HWCAP.ASIMDHP

常量

第 779 行

std.os.linux.HWCAP.ASIMDRDM

常量

第 635 行

std.os.linux.HWCAP.ATOMICS

常量

第 631 行

std.os.linux.HWCAP.BLKINIT

常量

第 922 行

std.os.linux.HWCAP.BOOKE

常量

第 843 行

std.os.linux.HWCAP.CBCOND

常量

第 941 行

std.os.linux.HWCAP.CELL

常量

第 844 行

std.os.linux.HWCAP.CMPBR

常量

第 656 行

std.os.linux.HWCAP.COMPLEX

常量

第 803 行

std.os.linux.HWCAP.CPUCFG

常量

第 796 行

std.os.linux.HWCAP.CPUID

常量

第 634 行

std.os.linux.HWCAP.CRC32

常量

第 630 行

std.os.linux.HWCAP.CRC32

常量

第 802 行

std.os.linux.HWCAP.CRC32

常量

第 817 行

std.os.linux.HWCAP.CRUNCH

常量

第 765 行

std.os.linux.HWCAP.CRYPTO

常量

第 804 行

std.os.linux.HWCAP.CRYPTO

常量

第 942 行

std.os.linux.HWCAP.DCPOP

常量

第 639 行

std.os.linux.HWCAP.DFLT

常量

第 909 行

std.os.linux.HWCAP.DFP

常量

第 897 行

std.os.linux.HWCAP.DIT

常量

第 647 行

std.os.linux.HWCAP.DIV32

常量

第 925 行

std.os.linux.HWCAP.DSP

常量

第 822 行

std.os.linux.HWCAP.DSP2

常量

第 823 行

std.os.linux.HWCAP.DSP3

常量

第 824 行

std.os.linux.HWCAP.EDSP

常量

第 762 行

std.os.linux.HWCAP.EIMM

常量

第 896 行

std.os.linux.HWCAP.ESAN3

常量

第 891 行

std.os.linux.HWCAP.ETF3EH

常量

第 899 行

std.os.linux.HWCAP.EVTSTRM

常量

第 625 行

std.os.linux.HWCAP.EVTSTRM

常量

第 777 行

std.os.linux.HWCAP.F8MM4

常量

第 659 行

std.os.linux.HWCAP.F8MM8

常量

第 658 行

std.os.linux.HWCAP.FAST_MULT

常量

第 759 行

std.os.linux.HWCAP.FCMA

常量

第 637 行

std.os.linux.HWCAP.FJFMAU

常量

第 937 行

std.os.linux.HWCAP.FLAGM

常量

第 650 行

std.os.linux.HWCAP.FLUSH

常量

第 916 行

std.os.linux.HWCAP.FMAF

常量

第 932 行

std.os.linux.HWCAP.FP

常量

第 623 行

std.os.linux.HWCAP.FPA

常量

第 760 行

std.os.linux.HWCAP.FPHP

常量

第 632 行

std.os.linux.HWCAP.FPHP

常量

第 778 行

std.os.linux.HWCAP.FPRCVT

常量

第 657 行

std.os.linux.HWCAP.FPU

常量

第 799 行

std.os.linux.HWCAP.FSMULD

常量

第 926 行

std.os.linux.HWCAP.GCS

常量

第 655 行

std.os.linux.HWCAP.GS

常量

第 905 行

std.os.linux.HWCAP.HALF

常量

第 756 行

std.os.linux.HWCAP.HAS_4xxMAC

常量

第 853 行

std.os.linux.HWCAP.HAS_ALTIVEC

常量

第 856 行

std.os.linux.HWCAP.HAS_DFP

常量

第 838 行

std.os.linux.HWCAP.HAS_EFP_DOUBLE

常量

第 849 行

std.os.linux.HWCAP.HAS_EFP_SINGLE

常量

第 850 行

std.os.linux.HWCAP.HAS_FPU

常量

第 855 行

std.os.linux.HWCAP.HAS_MMU

常量

第 854 行

std.os.linux.HWCAP.HAS_SPE

常量

第 851 行

std.os.linux.HWCAP.HAS_VSX

常量

第 835 行

std.os.linux.HWCAP.HIGH_GPRS

常量

第 900 行

std.os.linux.HWCAP.HPAGE

常量

第 898 行

std.os.linux.HWCAP.HPC

常量

第 934 行

std.os.linux.HWCAP.I8MM

常量

第 783 行

std.os.linux.HWCAP.ICACHE_SNOOP

常量

第 841 行

std.os.linux.HWCAP.IDIV

常量

第 775 行

std.os.linux.HWCAP.IDIVA

常量

第 772 行

std.os.linux.HWCAP.IDIVT

常量

第 773 行

std.os.linux.HWCAP.ILRCPC

常量

第 649 行

std.os.linux.HWCAP.IMA

常量

第 938 行

std.os.linux.HWCAP.ISA_A

常量

第 882 行

std.os.linux.HWCAP.ISA_C

常量

第 883 行

std.os.linux.HWCAP.ISA_D

常量

第 884 行

std.os.linux.HWCAP.ISA_F

常量

第 885 行

std.os.linux.HWCAP.ISA_I

常量

第 886 行

std.os.linux.HWCAP.ISA_M

常量

第 887 行

std.os.linux.HWCAP.ISA_V

常量

第 888 行

std.os.linux.HWCAP.IWMMXT

常量

第 764 行

std.os.linux.HWCAP.JAVA

常量

第 763 行

std.os.linux.HWCAP.JSCVT

常量

第 636 行

std.os.linux.HWCAP.LAM

常量

第 797 行

std.os.linux.HWCAP.LAM_BH

常量

第 812 行

std.os.linux.HWCAP.LASX

常量

第 801 行

std.os.linux.HWCAP.LBT_ARM

常量

第 807 行

std.os.linux.HWCAP.LBT_MIPS

常量

第 808 行

std.os.linux.HWCAP.LBT_X86

常量

第 806 行

std.os.linux.HWCAP.LDISP

常量

第 895 行

std.os.linux.HWCAP.LOONGSON_CPUCFG

常量

第 829 行

std.os.linux.HWCAP.LOONGSON_EXT

常量

第 827 行

std.os.linux.HWCAP.LOONGSON_EXT2

常量

第 828 行

std.os.linux.HWCAP.LOONGSON_MMI

常量

第 826 行

std.os.linux.HWCAP.LPAE

常量

第 776 行

std.os.linux.HWCAP.LRCPC

常量

第 638 行

std.os.linux.HWCAP.LSPW

常量

第 810 行

std.os.linux.HWCAP.LSX

常量

第 800 行

std.os.linux.HWCAP.LVZ

常量

第 805 行

std.os.linux.HWCAP.MDMX

常量

第 819 行

std.os.linux.HWCAP.MIPS16

常量

第 818 行

std.os.linux.HWCAP.MIPS16E2

常量

第 825 行

std.os.linux.HWCAP.MIPS3D

常量

第 820 行

std.os.linux.HWCAP.MSA

常量

第 816 行

std.os.linux.HWCAP.MSA

常量

第 894 行

std.os.linux.HWCAP.MUL32

常量

第 924 行

std.os.linux.HWCAP.MULDIV

常量

第 919 行

std.os.linux.HWCAP.N2

常量

第 923 行

std.os.linux.HWCAP.NEON

常量

第 767 行

std.os.linux.HWCAP.NNPA

常量

第 911 行

std.os.linux.HWCAP.NO_TB

常量

第 848 行

std.os.linux.HWCAP.PA6T

常量

第 839 行

std.os.linux.HWCAP.PACA

常量

第 653 行

std.os.linux.HWCAP.PACG

常量

第 654 行

std.os.linux.HWCAP.PAUSE

常量

第 940 行

std.os.linux.HWCAP.PCI_MIO

常量

第 912 行

std.os.linux.HWCAP.PMULL

常量

第 627 行

std.os.linux.HWCAP.POPC

常量

第 928 行

std.os.linux.HWCAP.POWER4

常量

第 847 行

std.os.linux.HWCAP.POWER5

常量

第 846 行

std.os.linux.HWCAP.POWER5_PLUS

常量

第 845 行

std.os.linux.HWCAP.POWER6_EXT

常量

第 837 行

std.os.linux.HWCAP.PPC_LE

常量

第 832 行

std.os.linux.HWCAP.PSERIES_PERFMON_COMPAT

常量

第 834 行

std.os.linux.HWCAP.PTW

常量

第 809 行

std.os.linux.HWCAP.R6

常量

第 815 行

std.os.linux.HWCAP.RANDOM

常量

第 935 行

std.os.linux.HWCAP.SB

常量

第 652 行

std.os.linux.HWCAP.SCQ

常量

第 811 行

std.os.linux.HWCAP.SHA1

常量

第 628 行

std.os.linux.HWCAP.SHA2

常量

第 629 行

std.os.linux.HWCAP.SHA3

常量

第 640 行

std.os.linux.HWCAP.SHA512

常量

第 644 行

std.os.linux.HWCAP.SIE

常量

第 913 行

std.os.linux.HWCAP.SM3

常量

第 641 行

std.os.linux.HWCAP.SM4

常量

第 642 行

std.os.linux.HWCAP.SMARTMIPS

常量

第 821 行

std.os.linux.HWCAP.SME_AES

常量

第 667 行

std.os.linux.HWCAP.SME_SBITPERM

常量

第 666 行

std.os.linux.HWCAP.SME_SFEXPA

常量

第 668 行

std.os.linux.HWCAP.SME_SMOP4

常量

第 670 行

std.os.linux.HWCAP.SME_STMOP

常量

第 669 行

std.os.linux.HWCAP.SME2P2

常量

第 665 行

std.os.linux.HWCAP.SMT

常量

第 842 行

std.os.linux.HWCAP.SORT

常量

第 908 行

std.os.linux.HWCAP.SSBS

常量

第 651 行

std.os.linux.HWCAP.STBAR

常量

第 917 行

std.os.linux.HWCAP.STFLE

常量

第 893 行

std.os.linux.HWCAP.SVE

常量

第 645 行

std.os.linux.HWCAP.SVE_AES2

常量

第 662 行

std.os.linux.HWCAP.SVE_BFSCALE

常量

第 663 行

std.os.linux.HWCAP.SVE_ELTPERM

常量

第 661 行

std.os.linux.HWCAP.SVE_F16MM

常量

第 660 行

std.os.linux.HWCAP.SVE2P2

常量

第 664 行

std.os.linux.HWCAP.SWAP

常量

第 918 行

std.os.linux.HWCAP.SWP

常量

第 755 行

std.os.linux.HWCAP.TE

常量

第 901 行

std.os.linux.HWCAP.THUMB

常量

第 757 行

std.os.linux.HWCAP.THUMBEE

常量

第 766 行

std.os.linux.HWCAP.TLS

常量

第 770 行

std.os.linux.HWCAP.TRANS

常量

第 936 行

std.os.linux.HWCAP.TRUE_LE

常量

第 833 行

std.os.linux.HWCAP.UAL

常量

第 798 行

std.os.linux.HWCAP.ULTRA3

常量

第 921 行

std.os.linux.HWCAP.UNIFIED_CACHE

常量

第 852 行

std.os.linux.HWCAP.USCAT

常量

第 648 行

std.os.linux.HWCAP.V8PLUS

常量

第 927 行

std.os.linux.HWCAP.V9

常量

第 920 行

std.os.linux.HWCAP.VFP

常量

第 761 行

std.os.linux.HWCAP.VFPD32

常量

第 774 行

std.os.linux.HWCAP.VFPv3

常量

第 768 行

std.os.linux.HWCAP.VFPv3D16

常量

第 769 行

std.os.linux.HWCAP.VFPv4

常量

第 771 行

std.os.linux.HWCAP.VIS

常量

第 929 行

std.os.linux.HWCAP.VIS2

常量

第 930 行

std.os.linux.HWCAP.VIS3

常量

第 933 行

std.os.linux.HWCAP.VXRS

常量

第 902 行

std.os.linux.HWCAP.VXRS_BCD

常量

第 903 行

std.os.linux.HWCAP.VXRS_EXT

常量

第 904 行

std.os.linux.HWCAP.VXRS_EXT2

常量

第 906 行

std.os.linux.HWCAP.VXRS_PDE

常量

第 907 行

std.os.linux.HWCAP.VXRS_PDE2

常量

第 910 行

std.os.linux.HWCAP.ZARCH

常量

第 892 行

std.os.linux.IFA

容器

第 10348 行

字段

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

std.os.linux.IFF

容器

第 9290 行

字段

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

容器

第 10316 行

字段

family: u8
__pad1: u8 = 0
type: c_ushort

ARPHRD_*

index: c_int

链接索引

flags: c_uint

IFF_* 标志

change: c_uint

IFF_* 更改掩码

std.os.linux.IFLA

容器

第 10365 行

字段

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

无线扩展事件

PROTINFO

链路的协议专用信息

TXQLEN
MAP
WEIGHT
OPERSTATE
LINKMODE
LINKINFO
NET_NS_PID
IFALIAS
NUM_VF

若设备为 SR-IOV PF,则为 VF 数量

VFINFO_LIST
STATS64
VF_PORTS
PORT_SELF
AF_SPEC
GROUP

设备所属的组

NET_NS_FD
EXT_MASK

扩展信息掩码、虚拟功能等

PROMISCUITY

混杂模式计数:> 0 表示采用 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

常量

第 10439 行

IFLA

std.os.linux.ifmap

容器

第 9303 行

字段

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

std.os.linux.IFNAMESIZE

常量

第 9288 行

std.os.linux.ifreq

容器

第 9312 行

字段

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

命名空间

第 6694 行

std.os.linux.in_pktinfo

容器

第 5798 行

字段

ifindex: i32
spec_dst: u32
addr: u32

std.os.linux.in_port_t

类型

第 7067 行

std.os.linux.IN.ACCESS

常量

第 6698 行

std.os.linux.IN.ALL_EVENTS

常量

第 6712 行

std.os.linux.IN.ATTRIB

常量

第 6700 行

std.os.linux.IN.CLOEXEC

常量

第 6695 行

std.os.linux.IN.CLOSE

常量

第 6703 行

std.os.linux.IN.CLOSE_NOWRITE

常量

第 6702 行

std.os.linux.IN.CLOSE_WRITE

常量

第 6701 行

std.os.linux.IN.CREATE

常量

第 6708 行

std.os.linux.IN.DELETE

常量

第 6709 行

std.os.linux.IN.DELETE_SELF

常量

第 6710 行

std.os.linux.IN.DONT_FOLLOW

常量

第 6719 行

std.os.linux.IN.EXCL_UNLINK

常量

第 6720 行

std.os.linux.IN.IGNORED

常量

第 6716 行

std.os.linux.IN.ISDIR

常量

第 6724 行

std.os.linux.IN.MASK_ADD

常量

第 6722 行

std.os.linux.IN.MASK_CREATE

常量

第 6721 行

std.os.linux.IN.MODIFY

常量

第 6699 行

std.os.linux.IN.MOVE

常量

第 6707 行

std.os.linux.IN.MOVE_SELF

常量

第 6711 行

std.os.linux.IN.MOVED_FROM

常量

第 6705 行

std.os.linux.IN.MOVED_TO

常量

第 6706 行

std.os.linux.IN.NONBLOCK

常量

第 6696 行

std.os.linux.IN.ONESHOT

常量

第 6725 行

std.os.linux.IN.ONLYDIR

常量

第 6718 行

std.os.linux.IN.OPEN

常量

第 6704 行

std.os.linux.IN.Q_OVERFLOW

常量

第 6715 行

std.os.linux.IN.UNMOUNT

常量

第 6714 行

std.os.linux.in6_pktinfo

容器

第 5805 行

字段

addr: [16]u8
ifindex: i32

std.os.linux.init_vdso_clock_gettime

函数

第 2451 行

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

参数

clk: clockid_t
ts: *timespec

std.os.linux.init_vdso_sys_riscv_hwprobe

函数

第 3555 行

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

参数

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

std.os.linux.ino_t

类型

第 114 行

std.os.linux.inotify_add_watch

函数

第 1339 行

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

参数

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

std.os.linux.inotify_event

容器

第 7278 行

字段

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

std.os.linux.inotify_event.getName

函数

第 7288 行

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

参数

self: *const inotify_event

std.os.linux.inotify_init1

函数

第 1335 行

pub fn inotify_init1(flags: u32) usize

参数

flags: u32

std.os.linux.inotify_rm_watch

函数

第 1343 行

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

参数

fd: fd_t
wd: fd_t

std.os.linux.io_cqring_offsets

容器

第 7843 行

字段

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

容器

第 7808 行

填入 mmap(2) 的偏移量

字段

head: u32

环头部的偏移量

tail: u32

环形队列尾部的偏移

ring_mask: u32

环掩码值

ring_entries: u32

环形队列中的条目

flags: u32

环标志

dropped: u32

未提交的 sqe 数量

array: u32

sqe 索引数组

resv1: u32
user_addr: u64

std.os.linux.io_uring_buf

容器

第 8102 行

字段

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

std.os.linux.io_uring_buf_reg

容器

第 8117 行

IORING_(UN)REGISTER_PBUF_RING 的参数

字段

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

std.os.linux.io_uring_buf_reg.Flags

容器

第 8124 行

字段

_0: u1 = 0
inc: bool

增量消耗缓冲区。

_: u14 = 0

std.os.linux.io_uring_buf_ring

容器

第 8109 行

字段

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

std.os.linux.io_uring_cqe

容器

第 7756 行

字段

user_data: u64

原样回传提交的 io_uring_sqe.data

res: i32

此事件的结果代码

flags: u32

std.os.linux.io_uring_cqe.buffer_id

函数

第 7776 行

pub fn buffer_id(self: io_uring_cqe) !u16

参数

self: io_uring_cqe

std.os.linux.io_uring_cqe.err

函数

第 7766 行

pub fn err(self: io_uring_cqe) E

参数

self: io_uring_cqe

std.os.linux.io_uring_enter

函数

第 3197 行

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

参数

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

std.os.linux.io_uring_file_index_range

容器

第 8150 行

IORING_REGISTER_FILE_ALLOC_RANGE 的参数。 范围指定为 [off, off + len)。

字段

off: u32
len: u32
resv: u64

std.os.linux.io_uring_files_update

容器

第 7975 行

已弃用,参见 struct io_uring_rsrc_update

字段

offset: u32
resv: u32
fds: u64

std.os.linux.io_uring_getevents_arg

容器

第 8132 行

字段

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

std.os.linux.io_uring_napi

容器

第 8020 行

字段

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

std.os.linux.io_uring_notification_register

容器

第 8012 行

字段

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

std.os.linux.io_uring_notification_slot

容器

第 8007 行

字段

tag: u64
resv: [3]u64

std.os.linux.IO_URING_OP_SUPPORTED

常量

第 8030 行

std.os.linux.io_uring_params

容器

第 7867 行

字段

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

容器

第 8044 行

字段

last_op: IORING_OP

最后一个支持的操作码

ops_len: u8

下方 ops[] 数组的长度

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

std.os.linux.io_uring_probe_op

容器

第 8032 行

字段

op: IORING_OP
resv: u8
flags: u16

IO_URING_OP_* 标志

resv2: u32

std.os.linux.io_uring_probe_op.is_supported

函数

第 8039 行

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

参数

self: @This()

std.os.linux.io_uring_probe.is_supported

函数

第 8054 行

当前运行的内核是否支持此操作。

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

参数

self: @This()
op: IORING_OP

std.os.linux.io_uring_recvmsg_out

容器

第 8156 行

字段

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

std.os.linux.io_uring_register

函数

第 3201 行

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

参数

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

std.os.linux.io_uring_restriction

容器

第 8062 行

字段

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

容器

第 7984 行

字段

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

std.os.linux.io_uring_rsrc_update

容器

第 7992 行

字段

offset: u32
resv: u32
data: u64

std.os.linux.io_uring_rsrc_update2

容器

第 7998 行

字段

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

std.os.linux.io_uring_setup

函数

第 3193 行

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

参数

entries: u32
p: *io_uring_params

std.os.linux.IO_URING_SOCKET_OP

容器

第 8095 行

字段

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

std.os.linux.io_uring_sqe

别名

第 7562 行

I/O 提交数据结构(提交队列条目)

别名目标 std.os.linux.io_uring_sqe.io_uring_sqe

std.os.linux.io_uring_sync_cancel_reg

容器

第 8140 行

IORING_REGISTER_SYNC_CANCEL 的参数

字段

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

std.os.linux.ioctl

函数

第 3233 行

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

参数

fd: fd_t
request: u32
arg: usize

std.os.linux.IOCTL

别名

第 128 行

别名目标 std.os.linux.ioctl

std.os.linux.IORING_ACCEPT_MULTISHOT

常量

第 7736 行

accept 标志存于 sqe->iopri

std.os.linux.IORING_ASYNC_CANCEL_ALL

常量

第 7708 行

取消所有与给定键匹配的请求

std.os.linux.IORING_ASYNC_CANCEL_ANY

常量

第 7712 行

匹配任意请求

std.os.linux.IORING_ASYNC_CANCEL_FD

常量

第 7710 行

根据 'fd' 而不是请求的 'user_data' 执行取消。

std.os.linux.IORING_ASYNC_CANCEL_FD_FIXED

常量

第 7714 行

传入的 'fd' 为固定描述符。自 Linux 6.0 起可用

std.os.linux.IORING_CQ_EVENTFD_DISABLED

常量

第 7858 行

禁用 eventfd 通知

std.os.linux.IORING_CQE_BUFFER_SHIFT

常量

第 7800 行

std.os.linux.IORING_CQE_F_32

常量

第 7798 行

std.os.linux.IORING_CQE_F_BUF_MORE

常量

第 7796 行

若设置,则完成事件中指定的缓冲区 ID 还将收到更多完成事件。

std.os.linux.IORING_CQE_F_BUFFER

常量

第 7787 行

若置位,高 16 位为缓冲区标识符

std.os.linux.IORING_CQE_F_MORE

常量

第 7790 行

若设置,则父 SQE 将生成更多 CQE 条目。 自 Linux 5.13 起可用。

std.os.linux.IORING_CQE_F_NOTIF

常量

第 7794 行

对通知 CQE 设置此标志,可据此与发送完成事件区分。

std.os.linux.IORING_CQE_F_SKIP

常量

第 7797 行

std.os.linux.IORING_CQE_F_SOCK_NONEMPTY

常量

第 7792 行

若设置,套接字接收后仍有更多数据可读

std.os.linux.IORING_ENTER_EXT_ARG

常量

第 7864 行

std.os.linux.IORING_ENTER_GETEVENTS

常量

第 7861 行

std.os.linux.IORING_ENTER_REGISTERED_RING

常量

第 7865 行

std.os.linux.IORING_ENTER_SQ_WAIT

常量

第 7863 行

std.os.linux.IORING_ENTER_SQ_WAKEUP

常量

第 7862 行

std.os.linux.IORING_FEAT_CQE_SKIP

常量

第 7893 行

std.os.linux.IORING_FEAT_CUR_PERSONALITY

常量

第 7886 行

std.os.linux.IORING_FEAT_EXT_ARG

常量

第 7890 行

std.os.linux.IORING_FEAT_FAST_POLL

常量

第 7887 行

std.os.linux.IORING_FEAT_LINKED_FILE

常量

第 7894 行

std.os.linux.IORING_FEAT_NATIVE_WORKERS

常量

第 7891 行

std.os.linux.IORING_FEAT_NODROP

常量

第 7883 行

std.os.linux.IORING_FEAT_POLL_32BITS

常量

第 7888 行

std.os.linux.IORING_FEAT_RSRC_TAGS

常量

第 7892 行

std.os.linux.IORING_FEAT_RW_CUR_POS

常量

第 7885 行

std.os.linux.IORING_FEAT_SINGLE_MMAP

常量

第 7882 行

std.os.linux.IORING_FEAT_SQPOLL_NONFIXED

常量

第 7889 行

std.os.linux.IORING_FEAT_SUBMIT_STABLE

常量

第 7884 行

std.os.linux.IORING_FILE_INDEX_ALLOC

常量

第 7572 行

对于会创建新直接描述符的操作码,例如 openat、openat2、accept,若 sqe->file_index 设为此值,则 io_uring 分配一个可用的直接描述符,而无需应用程序传入。 选中的直接描述符通过 cqe->res 返回;若空间已满,则返回 -ENFILE。 自 Linux 5.19 起可用。

std.os.linux.IORING_FSYNC_DATASYNC

常量

第 7679 行

std.os.linux.IORING_LINK_TIMEOUT_UPDATE

常量

第 7686 行

std.os.linux.IORING_MSG_RING_COMMAND

容器

第 7739 行

IORING_OP_MSG_RING 命令类型,存储于 sqe->addr

字段

DATA = 0

将 sqe->len 作为 'res'、off 作为 user_data 传入

SEND_FD = 1

将已注册的文件描述符发送到另一个 ring

_

std.os.linux.IORING_MSG_RING_CQE_SKIP

常量

第 7750 行

不向目标环提交 CQE。显然不适用于 IORING_MSG_DATA。

std.os.linux.IORING_MSG_RING_FLAGS_PASS

常量

第 7753 行

将 sqe->file_index(Zig 结构体中的 splice_fd_in)的标志传递给 cqe->flags */

std.os.linux.IORING_NOTIF_USAGE_ZC_COPIED

常量

第 7733 行

请求 IORING_SEND_ZC_REPORT_USAGE 时,IORING_CQE_F_NOTIF 对应的 CQE.RES。

std.os.linux.IORING_OFF_CQ_RING

常量

第 7804 行

std.os.linux.IORING_OFF_SQ_RING

常量

第 7803 行

供应用程序通过 mmap 映射所需数据的特定偏移量

std.os.linux.IORING_OFF_SQES

常量

第 7805 行

std.os.linux.IORING_OP

容器

第 7610 行

字段

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

常量

第 7703 行

std.os.linux.IORING_POLL_ADD_MULTI

常量

第 7699 行

多次触发 poll。若 poll 处理程序将继续代表同一个 SQE 报告 CQE,则设置 IORING_CQE_F_MORE。

std.os.linux.IORING_POLL_UPDATE_EVENTS

常量

第 7701 行

更新现有轮询请求,以 sqe->addr 匹配旧的 user_data 字段。

std.os.linux.IORING_POLL_UPDATE_USER_DATA

常量

第 7702 行

std.os.linux.IORING_RECV_MULTISHOT

常量

第 7722 行

多次接收。若处理器将继续为同一 SQE 报告 CQE,则设置 IORING_CQE_F_MORE。

std.os.linux.IORING_RECVSEND_BUNDLE

常量

第 7731 行

若设置,send 或 recv 会从指定缓冲区组标识中取得尽可能多的缓冲区,并全部发送。 完成结果为已发送的缓冲区数量,CQE 仍按通常方式包含起始缓冲区标识。 这些缓冲区从起始标识起连续排列。 与 IOSQE_BUFFER_SELECT 配合使用。

std.os.linux.IORING_RECVSEND_FIXED_BUF

常量

第 7724 行

使用已注册缓冲区,索引存储于 buf_index 字段。

std.os.linux.IORING_RECVSEND_POLL_FIRST

常量

第 7720 行

设置后,提前设置 poll 并跳过初次传输尝试, 而非先尝试发送或接收,再在结果为 -EAGAIN 时设置 poll。

std.os.linux.IORING_REGISTER

容器

第 7897 行

字段

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

常量

第 8028 行

跳过更新 fd 表中设置为此值的 fd 索引 */

std.os.linux.IORING_RESTRICTION

容器

第 8079 行

io_uring_restriction->opcode 的取值

字段

REGISTER_OP = 0

允许某个 io_uring_register(2) 操作码

SQE_OP = 1

允许某个 sqe 操作码

SQE_FLAGS_ALLOWED = 2

允许 sqe 标志

SQE_FLAGS_REQUIRED = 3

要求的 SQE 标志(每次提交时都必须设置这些标志)。

_

std.os.linux.IORING_RSRC_REGISTER_SPARSE

常量

第 7982 行

注册完全稀疏的文件空间,无需传入元素全为 -1 的文件描述符数组。

std.os.linux.IORING_SEND_ZC_REPORT_USAGE

常量

第 7726 行

若设置,SEND[MSG]_ZC 应在 IORING_CQE_F_NOTIF 完成事件的 cqe.res 中报告零拷贝使用情况。

std.os.linux.IORING_SETUP_ATTACH_WQ

常量

第 7517 行

附加到现有 wq

std.os.linux.IORING_SETUP_CLAMP

常量

第 7514 行

限制 SQ/CQ 环大小

std.os.linux.IORING_SETUP_COOP_TASKRUN

常量

第 7530 行

协作式任务执行。请求完成时,往往需要 强制提交方进入内核来完成处理。如果设置此 标志,则等任务本来就要进入内核时再处理, 而不是强制通过处理器间中断重新调度。这样避免中断 正在用户空间运行的任务,并节省一次 IPI。

std.os.linux.IORING_SETUP_CQE32

常量

第 7540 行

CQE 为 32 字节

std.os.linux.IORING_SETUP_CQSIZE

常量

第 7511 行

应用程序定义 CQ 大小

std.os.linux.IORING_SETUP_DEFER_TASKRUN

常量

第 7548 行

延迟执行任务工作以获取事件。 不在任务每次状态转换时执行部分任务工作, 而尽量延迟到即将需要时再执行。

std.os.linux.IORING_SETUP_IOPOLL

常量

第 7502 行

轮询 io_context

std.os.linux.IORING_SETUP_NO_MMAP

常量

第 7551 行

应用程序提供环内存

std.os.linux.IORING_SETUP_NO_SQARRAY

常量

第 7559 行

消除通过 SQ 索引数组的间接访问。

std.os.linux.IORING_SETUP_R_DISABLED

常量

第 7520 行

从禁用环开始

std.os.linux.IORING_SETUP_REGISTERED_FD_ONLY

常量

第 7556 行

将环的文件描述符注册到自身,供 IORING_REGISTER_USE_REGISTERED_RING 使用;返回已注册文件描述符索引, 而非文件描述符。

std.os.linux.IORING_SETUP_SINGLE_ISSUER

常量

第 7543 行

仅允许一个任务提交请求

std.os.linux.IORING_SETUP_SQ_AFF

常量

第 7508 行

sq_thread_cpu 有效

std.os.linux.IORING_SETUP_SQE128

常量

第 7538 行

SQE 为 128 字节

std.os.linux.IORING_SETUP_SQPOLL

常量

第 7505 行

SQ 轮询线程

std.os.linux.IORING_SETUP_SUBMIT_ALL

常量

第 7523 行

发生错误时继续提交

std.os.linux.IORING_SETUP_TASKRUN_FLAG

常量

第 7535 行

若设置 COOP_TASKRUN,则在存在可运行任务工作且需要进入内核才能运行时 获得通知。这会在 SQ 环标志中设置 IORING_SQ_TASKRUN。 不能与 COOP_TASKRUN 一起使用(原文条件如此)。

std.os.linux.IORING_SPLICE_F_FD_IN_FIXED

常量

第 7693 行

std.os.linux.IORING_SQ_CQ_OVERFLOW

常量

第 7839 行

内核中有超出 cq 环容量的待处理 cqe

std.os.linux.IORING_SQ_NEED_WAKEUP

常量

第 7837 行

需要 io_uring_enter 唤醒

std.os.linux.IORING_SQ_TASKRUN

常量

第 7841 行

任务应进入内核

std.os.linux.IORING_TIMEOUT_ABS

常量

第 7682 行

std.os.linux.IORING_TIMEOUT_BOOTTIME

常量

第 7684 行

std.os.linux.IORING_TIMEOUT_CLOCK_MASK

常量

第 7688 行

std.os.linux.IORING_TIMEOUT_ETIME_SUCCESS

常量

第 7687 行

std.os.linux.IORING_TIMEOUT_REALTIME

常量

第 7685 行

std.os.linux.IORING_TIMEOUT_UPDATE

常量

第 7683 行

std.os.linux.IORING_TIMEOUT_UPDATE_MASK

常量

第 7689 行

std.os.linux.IORING_URING_CMD_FIXED

常量

第 7676 行

使用已注册缓冲区;传递此标志并同时设置 sqe->buf_index。

std.os.linux.IOSQE_ASYNC

常量

第 7601 行

始终异步执行

std.os.linux.IOSQE_BIT

容器

第 7574 行

字段

FIXED_FILE
IO_DRAIN
IO_LINK
IO_HARDLINK
ASYNC
BUFFER_SELECT
CQE_SKIP_SUCCESS
_

std.os.linux.IOSQE_BUFFER_SELECT

常量

第 7604 行

从 buf_group 选择缓冲区

std.os.linux.IOSQE_CQE_SKIP_SUCCESS

常量

第 7608 行

请求成功时不提交 CQE 自 Linux 5.17 起可用

std.os.linux.IOSQE_FIXED_FILE

常量

第 7589 行

使用固定文件集

std.os.linux.IOSQE_IO_DRAIN

常量

第 7592 行

在执行中的 IO 之后发出

std.os.linux.IOSQE_IO_HARDLINK

常量

第 7598 行

类似 LINK,但约束更强

std.os.linux.IOSQE_IO_LINK

常量

第 7595 行

链接下一个 sqe

std.os.linux.IoUring

别名

第 7564 行

别名目标 std.os.linux.IoUring

std.os.linux.IOV_MAX

常量

第 4469 行

std.os.linux.iovec

别名

第 22 行

别名目标 std.posix.iovec

std.os.linux.iovec_const

别名

第 23 行

别名目标 std.posix.iovec_const

std.os.linux.IOWQ_CATEGORIES

容器

第 7969 行

io_uring_restriction->opcode 的取值

字段

BOUND
UNBOUND

std.os.linux.IP

命名空间

第 5622 行

std.os.linux.IP.ADD_MEMBERSHIP

常量

第 5653 行

std.os.linux.IP.ADD_SOURCE_MEMBERSHIP

常量

第 5657 行

std.os.linux.IP.BIND_ADDRESS_NO_PORT

常量

第 5648 行

std.os.linux.IP.BLOCK_SOURCE

常量

第 5656 行

std.os.linux.IP.CHECKSUM

常量

第 5647 行

std.os.linux.IP.DEFAULT_MULTICAST_LOOP

常量

第 5673 行

std.os.linux.IP.DEFAULT_MULTICAST_TTL

常量

第 5672 行

std.os.linux.IP.DROP_MEMBERSHIP

常量

第 5654 行

std.os.linux.IP.DROP_SOURCE_MEMBERSHIP

常量

第 5658 行

std.os.linux.IP.FREEBIND

常量

第 5638 行

std.os.linux.IP.HDRINCL

常量

第 5625 行

std.os.linux.IP.IPSEC_POLICY

常量

第 5639 行

std.os.linux.IP.MAX_MEMBERSHIPS

常量

第 5674 行

std.os.linux.IP.MINTTL

常量

第 5645 行

std.os.linux.IP.MSFILTER

常量

第 5659 行

std.os.linux.IP.MTU

常量

第 5637 行

std.os.linux.IP.MTU_DISCOVER

常量

第 5633 行

std.os.linux.IP.MULTICAST_ALL

常量

第 5660 行

std.os.linux.IP.MULTICAST_IF

常量

第 5650 行

std.os.linux.IP.MULTICAST_LOOP

常量

第 5652 行

std.os.linux.IP.MULTICAST_TTL

常量

第 5651 行

std.os.linux.IP.NODEFRAG

常量

第 5646 行

std.os.linux.IP.OPTIONS

常量

第 5626 行

std.os.linux.IP.ORIGDSTADDR

常量

第 5643 行

std.os.linux.IP.PASSSEC

常量

第 5641 行

std.os.linux.IP.PKTINFO

常量

第 5630 行

std.os.linux.IP.PKTOPTIONS

常量

第 5631 行

std.os.linux.IP.PMTUDISC

常量

第 5632 行

std.os.linux.IP.PMTUDISC_DO

常量

第 5667 行

std.os.linux.IP.PMTUDISC_DONT

常量

第 5665 行

std.os.linux.IP.PMTUDISC_INTERFACE

常量

第 5669 行

std.os.linux.IP.PMTUDISC_OMIT

常量

第 5670 行

std.os.linux.IP.PMTUDISC_PROBE

常量

第 5668 行

std.os.linux.IP.PMTUDISC_WANT

常量

第 5666 行

std.os.linux.IP.RECVERR

常量

第 5634 行

std.os.linux.IP.RECVFRAGSIZE

常量

第 5649 行

std.os.linux.IP.RECVOPTS

常量

第 5628 行

std.os.linux.IP.RECVORIGDSTADDR

别名

第 5644 行

别名目标 std.os.linux.IP.ORIGDSTADDR

std.os.linux.IP.RECVRETOPTS

别名

第 5663 行

别名目标 std.os.linux.IP.RETOPTS

std.os.linux.IP.RECVTOS

常量

第 5636 行

std.os.linux.IP.RECVTTL

常量

第 5635 行

std.os.linux.IP.RETOPTS

常量

第 5629 行

std.os.linux.IP.ROUTER_ALERT

常量

第 5627 行

std.os.linux.IP.TOS

常量

第 5623 行

std.os.linux.IP.TRANSPARENT

常量

第 5642 行

std.os.linux.IP.TTL

常量

第 5624 行

std.os.linux.IP.UNBLOCK_SOURCE

常量

第 5655 行

std.os.linux.IP.UNICAST_IF

常量

第 5661 行

std.os.linux.IP.XFRM_POLICY

常量

第 5640 行

std.os.linux.IPPORT_RESERVED

常量

第 8350 行

std.os.linux.IPPROTO

命名空间

第 8352 行

std.os.linux.IPPROTO.AH

常量

第 8371 行

std.os.linux.IPPROTO.BEETPH

常量

第 8376 行

std.os.linux.IPPROTO.COMP

常量

第 8379 行

std.os.linux.IPPROTO.DCCP

常量

第 8364 行

std.os.linux.IPPROTO.DSTOPTS

常量

第 8374 行

std.os.linux.IPPROTO.EGP

常量

第 8359 行

std.os.linux.IPPROTO.ENCAP

常量

第 8377 行

std.os.linux.IPPROTO.ESP

常量

第 8370 行

std.os.linux.IPPROTO.FRAGMENT

常量

第 8367 行

std.os.linux.IPPROTO.GRE

常量

第 8369 行

std.os.linux.IPPROTO.HOPOPTS

常量

第 8354 行

std.os.linux.IPPROTO.ICMP

常量

第 8355 行

std.os.linux.IPPROTO.ICMPV6

常量

第 8372 行

std.os.linux.IPPROTO.IDP

常量

第 8362 行

std.os.linux.IPPROTO.IGMP

常量

第 8356 行

std.os.linux.IPPROTO.IP

常量

第 8353 行

std.os.linux.IPPROTO.IPIP

常量

第 8357 行

std.os.linux.IPPROTO.IPV6

常量

第 8365 行

std.os.linux.IPPROTO.MAX

常量

第 8385 行

std.os.linux.IPPROTO.MH

常量

第 8381 行

std.os.linux.IPPROTO.MPLS

常量

第 8383 行

std.os.linux.IPPROTO.MTP

常量

第 8375 行

std.os.linux.IPPROTO.NONE

常量

第 8373 行

std.os.linux.IPPROTO.PIM

常量

第 8378 行

std.os.linux.IPPROTO.PUP

常量

第 8360 行

std.os.linux.IPPROTO.RAW

常量

第 8384 行

std.os.linux.IPPROTO.ROUTING

常量

第 8366 行

std.os.linux.IPPROTO.RSVP

常量

第 8368 行

std.os.linux.IPPROTO.SCTP

常量

第 8380 行

std.os.linux.IPPROTO.TCP

常量

第 8358 行

std.os.linux.IPPROTO.TP

常量

第 8363 行

std.os.linux.IPPROTO.UDP

常量

第 8361 行

std.os.linux.IPPROTO.UDPLITE

常量

第 8382 行

std.os.linux.IPTOS

命名空间

第 5765 行

std.os.linux.IPTOS.LOWDELAY

常量

第 5774 行

std.os.linux.IPTOS.MINCOST

常量

第 5771 行

std.os.linux.IPTOS.PREC

函数

第 5777 行

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

std.os.linux.IPTOS.PREC_CRITIC_ECP

常量

第 5786 行

std.os.linux.IPTOS.PREC_FLASH

常量

第 5784 行

std.os.linux.IPTOS.PREC_FLASHOVERRIDE

常量

第 5785 行

std.os.linux.IPTOS.PREC_IMMEDIATE

常量

第 5783 行

std.os.linux.IPTOS.PREC_INTERNETCONTROL

常量

第 5787 行

std.os.linux.IPTOS.PREC_MASK

常量

第 5776 行

std.os.linux.IPTOS.PREC_NETCONTROL

常量

第 5788 行

std.os.linux.IPTOS.PREC_PRIORITY

常量

第 5782 行

std.os.linux.IPTOS.PREC_ROUTINE

常量

第 5781 行

std.os.linux.IPTOS.RELIABILITY

常量

第 5772 行

std.os.linux.IPTOS.THROUGHPUT

常量

第 5773 行

std.os.linux.IPTOS.TOS

函数

第 5767 行

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

std.os.linux.IPTOS.TOS_MASK

常量

第 5766 行

std.os.linux.IPV6

命名空间

第 5678 行

IPv6 套接字选项

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

常量

第 5682 行

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

常量

第 5686 行

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

常量

第 5681 行

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

常量

第 5680 行

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

常量

第 5684 行

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

常量

第 5683 行

std.os.linux.IPV6.ADD_MEMBERSHIP

常量

第 5695 行

std.os.linux.IPV6.ADDR_PREFERENCES

常量

第 5743 行

std.os.linux.IPV6.ADDRFORM

常量

第 5679 行

std.os.linux.IPV6.AUTHHDR

常量

第 5688 行

std.os.linux.IPV6.AUTOFLOWLABEL

常量

第 5740 行

std.os.linux.IPV6.CHECKSUM

常量

第 5685 行

std.os.linux.IPV6.DONTFRAG

常量

第 5734 行

std.os.linux.IPV6.DROP_MEMBERSHIP

常量

第 5696 行

std.os.linux.IPV6.DSTOPTS

常量

第 5731 行

std.os.linux.IPV6.FLOWINFO

常量

第 5689 行

std.os.linux.IPV6.FLOWINFO_SEND

常量

第 5715 行

std.os.linux.IPV6.FLOWLABEL_MGR

常量

第 5714 行

std.os.linux.IPV6.FREEBIND

常量

第 5761 行

std.os.linux.IPV6.HDRINCL

常量

第 5718 行

std.os.linux.IPV6.HOPLIMIT

常量

第 5724 行

std.os.linux.IPV6.HOPOPTS

常量

第 5726 行

std.os.linux.IPV6.IPSEC_POLICY

常量

第 5716 行

std.os.linux.IPV6.JOIN_ANYCAST

常量

第 5702 行

std.os.linux.IPV6.LEAVE_ANYCAST

常量

第 5703 行

std.os.linux.IPV6.MINHOPCOUNT

常量

第 5754 行

std.os.linux.IPV6.MTU

常量

第 5699 行

std.os.linux.IPV6.MTU_DISCOVER

常量

第 5698 行

std.os.linux.IPV6.MULTICAST_HOPS

常量

第 5693 行

std.os.linux.IPV6.MULTICAST_IF

常量

第 5692 行

std.os.linux.IPV6.MULTICAST_LOOP

常量

第 5694 行

std.os.linux.IPV6.NEXTHOP

常量

第 5687 行

std.os.linux.IPV6.ORIGDSTADDR

常量

第 5756 行

std.os.linux.IPV6.PATHMTU

常量

第 5733 行

std.os.linux.IPV6.PKTINFO

常量

第 5722 行

std.os.linux.IPV6.PMTUDISC_DO

常量

第 5708 行

std.os.linux.IPV6.PMTUDISC_DONT

常量

第 5706 行

std.os.linux.IPV6.PMTUDISC_INTERFACE

常量

第 5710 行

std.os.linux.IPV6.PMTUDISC_OMIT

常量

第 5711 行

std.os.linux.IPV6.PMTUDISC_PROBE

常量

第 5709 行

std.os.linux.IPV6.PMTUDISC_WANT

常量

第 5707 行

std.os.linux.IPV6.PREFER_SRC_CGA

常量

第 5750 行

std.os.linux.IPV6.PREFER_SRC_COA

常量

第 5748 行

std.os.linux.IPV6.PREFER_SRC_HOME

常量

第 5749 行

std.os.linux.IPV6.PREFER_SRC_NONCGA

常量

第 5751 行

std.os.linux.IPV6.PREFER_SRC_PUBLIC

常量

第 5746 行

std.os.linux.IPV6.PREFER_SRC_PUBTMP_DEFAULT

常量

第 5747 行

std.os.linux.IPV6.PREFER_SRC_TMP

常量

第 5745 行

std.os.linux.IPV6.RECVDSTOPTS

常量

第 5730 行

std.os.linux.IPV6.RECVERR

常量

第 5700 行

std.os.linux.IPV6.RECVFRAGSIZE

常量

第 5760 行

std.os.linux.IPV6.RECVHOPLIMIT

常量

第 5723 行

std.os.linux.IPV6.RECVHOPOPTS

常量

第 5725 行

std.os.linux.IPV6.RECVORIGDSTADDR

别名

第 5757 行

别名目标 std.os.linux.IPV6.ORIGDSTADDR

std.os.linux.IPV6.RECVPATHMTU

常量

第 5732 行

std.os.linux.IPV6.RECVPKTINFO

常量

第 5721 行

std.os.linux.IPV6.RECVRTHDR

常量

第 5728 行

std.os.linux.IPV6.RECVTCLASS

常量

第 5737 行

std.os.linux.IPV6.ROUTER_ALERT

常量

第 5697 行

std.os.linux.IPV6.RTHDR

常量

第 5729 行

std.os.linux.IPV6.RTHDRDSTOPTS

常量

第 5727 行

std.os.linux.IPV6.TCLASS

常量

第 5738 行

std.os.linux.IPV6.TRANSPARENT

常量

第 5758 行

std.os.linux.IPV6.UNICAST_HOPS

常量

第 5691 行

std.os.linux.IPV6.UNICAST_IF

常量

第 5759 行

std.os.linux.IPV6.V6ONLY

常量

第 5701 行

std.os.linux.IPV6.XFRM_POLICY

常量

第 5717 行

std.os.linux.is_hppa

常量

第 21 行

std.os.linux.is_loongarch

常量

第 16 行

std.os.linux.is_mips

常量

第 17 行

std.os.linux.is_ppc

常量

第 18 行

std.os.linux.is_riscv

常量

第 19 行

std.os.linux.is_sparc

常量

第 20 行

std.os.linux.issecure_mask

函数

第 9866 行

fn issecure_mask(comptime x: comptime_int) comptime_int

参数

x: comptime_int

std.os.linux.ITIMER

容器

第 3155 行

字段

REAL = 0
VIRTUAL = 1
PROF = 2

std.os.linux.itimerspec

容器

第 3131 行

字段

it_interval: timespec
it_value: timespec

std.os.linux.k_sigaction

类型

第 6986 行

供 rt_sigaction 系统调用使用的内核 sigaction 结构体。 在用户空间负责连接 rt_sigreturn 的目标上包含 restorer。

std.os.linux.k_sigaction_funcs

命名空间

第 6979 行

std.os.linux.k_sigaction_funcs.handler

类型

第 6980 行

std.os.linux.k_sigaction_funcs.restorer

类型

第 6981 行

std.os.linux.kernel_fsid_t

别名

第 6875 行

别名目标 std.os.linux.fsid_t

std.os.linux.kernel_rwf

类型

第 4972 行

std.os.linux.kernel_timespec

容器

第 9765 行

内核使用的 timespec 结构体。

字段

sec: i64
nsec: i64

std.os.linux.kernel_timespec.NOW

常量

第 9770 行

与 utimensat 和 futimens 配合使用。

timespec

std.os.linux.kernel_timespec.OMIT

常量

第 9776 行

与 utimensat 和 futimens 配合使用。

timespec

std.os.linux.kill

函数

第 2198 行

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

参数

pid: pid_t
sig: SIG

std.os.linux.lchown

函数

第 2081 行

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

参数

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

std.os.linux.lgetxattr

函数

第 2960 行

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

参数

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

std.os.linux.linger

容器

第 5792 行

字段

onoff: i32
linger: i32

std.os.linux.link

函数

第 2210 行

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

参数

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

std.os.linux.linkat

函数

第 2229 行

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

参数

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

std.os.linux.LINUX_REBOOT

命名空间

第 2138 行

reboot 系统调用的标志。

std.os.linux.LINUX_REBOOT.CMD

容器

第 2155 行

_reboot() 系统调用接受的命令。

字段

RESTART = 0x01234567

使用默认命令及模式重启系统。

HALT = 0xCDEF0123

停止操作系统,并将控制权交给 ROM 监控器(若存在)。

CAD_ON = 0x89ABCDEF

Ctrl-Alt-Del 按键序列触发 RESTART 命令。

CAD_OFF = 0x00000000

Ctrl-Alt-Del 组合键向 init 任务发送 SIGINT。

POWER_OFF = 0x4321FEDC

停止操作系统,并尽可能切断系统全部电源。

RESTART2 = 0xA1B2C3D4

使用给定命令字符串重新启动系统。

SW_SUSPEND = 0xD000FCE2

若编译时启用了软件挂起,则使用它挂起系统。

KEXEC = 0x45584543

使用先前加载的 Linux 内核重启系统。

_

std.os.linux.LINUX_REBOOT.MAGIC1

容器

第 2140 行

使用 _reboot() 系统调用所需的第一个魔数。

字段

MAGIC1 = 0xfee1dead
_

std.os.linux.LINUX_REBOOT.MAGIC2

容器

第 2146 行

使用 _reboot() 系统调用所需的第二个魔数。

字段

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

std.os.linux.listen

函数

第 2888 行

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

参数

fd: fd_t
backlog: u32

std.os.linux.listxattr

函数

第 2944 行

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

参数

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

std.os.linux.llistxattr

函数

第 2948 行

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

参数

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

std.os.linux.llseek

函数

第 2100 行

仅可在 32 位系统上调用。64 位系统参见 lseek。

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

参数

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

std.os.linux.lremovexattr

函数

第 2984 行

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

参数

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

std.os.linux.lseek

函数

第 2114 行

仅可在 64 位系统上调用。32 位系统参见 llseek。

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

参数

fd: fd_t
offset: off_t
whence: u32

std.os.linux.lsetxattr

函数

第 2972 行

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

参数

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

std.os.linux.ltchars

类型

第 8971 行

std.os.linux.MADV

命名空间

第 9704 行

std.os.linux.MADV.COLD

常量

第 9722 行

std.os.linux.MADV.DODUMP

常量

第 9719 行

std.os.linux.MADV.DOFORK

常量

第 9713 行

std.os.linux.MADV.DONTDUMP

常量

第 9718 行

std.os.linux.MADV.DONTFORK

常量

第 9712 行

std.os.linux.MADV.DONTNEED

常量

第 9709 行

std.os.linux.MADV.FREE

常量

第 9710 行

std.os.linux.MADV.HUGEPAGE

常量

第 9716 行

std.os.linux.MADV.HWPOISON

常量

第 9724 行

std.os.linux.MADV.KEEPONFORK

常量

第 9721 行

std.os.linux.MADV.MERGEABLE

常量

第 9714 行

std.os.linux.MADV.NOHUGEPAGE

常量

第 9717 行

std.os.linux.MADV.NORMAL

常量

第 9705 行

std.os.linux.MADV.PAGEOUT

常量

第 9723 行

std.os.linux.MADV.RANDOM

常量

第 9706 行

std.os.linux.MADV.REMOVE

常量

第 9711 行

std.os.linux.MADV.SEQUENTIAL

常量

第 9707 行

std.os.linux.MADV.SOFT_OFFLINE

常量

第 9725 行

std.os.linux.MADV.UNMERGEABLE

常量

第 9715 行

std.os.linux.MADV.WILLNEED

常量

第 9708 行

std.os.linux.MADV.WIPEONFORK

常量

第 9720 行

std.os.linux.madvise

函数

第 3301 行

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

参数

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

std.os.linux.MAP

类型

第 175 行

std.os.linux.map_shadow_stack

函数

第 3467 行

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

参数

addr: usize
size: usize
flags: u32

std.os.linux.MAP_TYPE

容器

第 168 行

字段

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

std.os.linux.MAX_ADDR_LEN

常量

第 4473 行

硬件地址的最大长度 例如,mac 地址是一种硬件地址

std.os.linux.maxInt

别名

第 9 行

别名目标 std.math.maxInt

std.os.linux.MCL

类型

第 1664 行

std.os.linux.memfd_create

函数

第 3205 行

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

参数

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

std.os.linux.MFD

命名空间

第 8464 行

std.os.linux.MFD.ALL_FLAGS

常量

第 8468 行

std.os.linux.MFD.ALLOW_SEALING

常量

第 8466 行

std.os.linux.MFD.CLOEXEC

常量

第 8465 行

std.os.linux.MFD.HUGE_16GB

别名

第 8483 行

别名目标 std.os.linux.HUGETLB_FLAG_ENCODE_16GB

std.os.linux.MFD.HUGE_16MB

别名

第 8477 行

别名目标 std.os.linux.HUGETLB_FLAG_ENCODE_16MB

std.os.linux.MFD.HUGE_1GB

别名

第 8481 行

别名目标 std.os.linux.HUGETLB_FLAG_ENCODE_1GB

std.os.linux.MFD.HUGE_1MB

别名

第 8474 行

别名目标 std.os.linux.HUGETLB_FLAG_ENCODE_1MB

std.os.linux.MFD.HUGE_256MB

别名

第 8479 行

别名目标 std.os.linux.HUGETLB_FLAG_ENCODE_256MB

std.os.linux.MFD.HUGE_2GB

别名

第 8482 行

别名目标 std.os.linux.HUGETLB_FLAG_ENCODE_2GB

std.os.linux.MFD.HUGE_2MB

别名

第 8475 行

别名目标 std.os.linux.HUGETLB_FLAG_ENCODE_2MB

std.os.linux.MFD.HUGE_32MB

别名

第 8478 行

别名目标 std.os.linux.HUGETLB_FLAG_ENCODE_32MB

std.os.linux.MFD.HUGE_512KB

别名

第 8473 行

别名目标 std.os.linux.HUGETLB_FLAG_ENCODE_512KB

std.os.linux.MFD.HUGE_512MB

别名

第 8480 行

别名目标 std.os.linux.HUGETLB_FLAG_ENCODE_512MB

std.os.linux.MFD.HUGE_64KB

别名

第 8472 行

别名目标 std.os.linux.HUGETLB_FLAG_ENCODE_64KB

std.os.linux.MFD.HUGE_8MB

别名

第 8476 行

别名目标 std.os.linux.HUGETLB_FLAG_ENCODE_8MB

std.os.linux.MFD.HUGE_MASK

别名

第 8471 行

别名目标 std.os.linux.HUGETLB_FLAG_ENCODE_MASK

std.os.linux.MFD.HUGE_SHIFT

别名

第 8470 行

别名目标 std.os.linux.HUGETLB_FLAG_ENCODE_SHIFT

std.os.linux.MFD.HUGETLB

常量

第 8467 行

std.os.linux.mincore

函数

第 3297 行

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

参数

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

std.os.linux.MINSIGSTKSZ

常量

第 7321 行

std.os.linux.mkdir

函数

第 1410 行

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

参数

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

std.os.linux.mkdirat

函数

第 1418 行

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

参数

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

std.os.linux.mknod

函数

第 1422 行

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

参数

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

std.os.linux.mknodat

函数

第 1430 行

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

参数

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

std.os.linux.mlock

函数

第 1647 行

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

参数

address: [*]const u8
length: usize

std.os.linux.MLOCK

容器

第 1655 行

字段

ONFAULT: bool = false
_1: u31 = 0

std.os.linux.mlock2

函数

第 1660 行

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

参数

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

std.os.linux.mlockall

函数

第 1677 行

pub fn mlockall(flags: MCL) usize

参数

flags: MCL

std.os.linux.mmap

函数

第 1577 行

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

参数

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

std.os.linux.mmap2Unit

函数

第 1569 行

fn mmap2Unit() u64

std.os.linux.mmsghdr

容器

第 7156 行

字段

hdr: msghdr
len: u32

std.os.linux.MNT

命名空间

第 6686 行

std.os.linux.MNT.DETACH

常量

第 6688 行

std.os.linux.MNT.EXPIRE

常量

第 6689 行

std.os.linux.MNT.FORCE

常量

第 6687 行

std.os.linux.mode_t

类型

第 115 行

std.os.linux.mount

函数

第 1434 行

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

参数

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

std.os.linux.MOUNT_ATTR

容器

第 1477 行

字段

RELATIME: u0

相对于 mtime/ctime 更新 atime。

RDONLY: bool

只读挂载。

NOSUID: bool

忽略 suid 和 sgid 位。

NODEV: bool

禁止访问设备特殊文件。

NOEXEC: bool

禁止执行程序。

NOATIME: bool

不更新访问时间。

STRICTATIME: bool

始终更新 atime。

_40: bool = false
NODIRATIME: bool

不更新目录的访问时间。

_100: u12 = 0
IDMAP: bool

将挂载的 ID 映射到 struct mount_attr 中的 @userns_fd。

NOSYMFOLLOW: bool

不跟随符号链接。

_: u10 = 0

std.os.linux.mount_setattr

函数

第 1505 行

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

参数

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

std.os.linux.move_mount

函数

第 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

参数

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

容器

第 1446 行

字段

F_SYMLINKS: bool

沿源路径跟随符号链接。

F_AUTOMOUNTS: bool

沿源路径遍历自动挂载点。

F_EMPTY_PATH: bool

允许源路径为空。

_8: bool = false
T_SYMLINKS: bool

跟随目标路径上的符号链接。

T_AUTOMOUNTS: bool

沿路径跟随自动挂载点。

T_EMPTY_PATH: bool

允许空的目标路径。

_80: bool = false
SET_GROUP: bool

改用共享组。

_: u23 = 0

std.os.linux.mprotect

函数

第 1613 行

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

参数

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

std.os.linux.mremap

函数

第 1617 行

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

参数

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

std.os.linux.MREMAP

容器

第 382 行

字段

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

std.os.linux.MS

命名空间

第 6649 行

std.os.linux.MS.ACTIVE

常量

第 6677 行

std.os.linux.MS.BIND

常量

第 6660 行

std.os.linux.MS.BORN

常量

第 6676 行

std.os.linux.MS.DIRSYNC

常量

第 6657 行

std.os.linux.MS.I_VERSION

常量

第 6671 行

std.os.linux.MS.KERNMOUNT

常量

第 6670 行

std.os.linux.MS.LAZYTIME

常量

第 6673 行

std.os.linux.MS.MANDLOCK

常量

第 6656 行

std.os.linux.MS.MGC_MSK

常量

第 6683 行

std.os.linux.MS.MGC_VAL

常量

第 6682 行

std.os.linux.MS.MOVE

常量

第 6661 行

std.os.linux.MS.NOATIME

常量

第 6658 行

std.os.linux.MS.NODEV

常量

第 6652 行

std.os.linux.MS.NODIRATIME

常量

第 6659 行

std.os.linux.MS.NOEXEC

常量

第 6653 行

std.os.linux.MS.NOREMOTELOCK

常量

第 6674 行

std.os.linux.MS.NOSEC

常量

第 6675 行

std.os.linux.MS.NOSUID

常量

第 6651 行

std.os.linux.MS.NOUSER

常量

第 6678 行

std.os.linux.MS.POSIXACL

常量

第 6664 行

std.os.linux.MS.PRIVATE

常量

第 6666 行

std.os.linux.MS.RDONLY

常量

第 6650 行

std.os.linux.MS.REC

常量

第 6662 行

std.os.linux.MS.RELATIME

常量

第 6669 行

std.os.linux.MS.REMOUNT

常量

第 6655 行

std.os.linux.MS.RMT_MASK

常量

第 6680 行

std.os.linux.MS.SHARED

常量

第 6668 行

std.os.linux.MS.SILENT

常量

第 6663 行

std.os.linux.MS.SLAVE

常量

第 6667 行

std.os.linux.MS.STRICTATIME

常量

第 6672 行

std.os.linux.MS.SYNCHRONOUS

常量

第 6654 行

std.os.linux.MS.UNBINDABLE

常量

第 6665 行

std.os.linux.mseal

函数

第 1635 行

仅可在 64 位系统上调用。

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

参数

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

std.os.linux.MSF

命名空间

第 1628 行

std.os.linux.MSF.ASYNC

常量

第 1629 行

std.os.linux.MSF.INVALIDATE

常量

第 1630 行

std.os.linux.MSF.SYNC

常量

第 1631 行

std.os.linux.MSG

命名空间

第 6043 行

std.os.linux.MSG.BATCH

常量

第 6061 行

std.os.linux.MSG.CMSG_CLOEXEC

常量

第 6064 行

std.os.linux.MSG.CONFIRM

常量

第 6055 行

std.os.linux.MSG.CTRUNC

常量

第 6047 行

std.os.linux.MSG.DONTROUTE

常量

第 6046 行

std.os.linux.MSG.DONTWAIT

常量

第 6050 行

std.os.linux.MSG.EOR

常量

第 6051 行

std.os.linux.MSG.ERRQUEUE

常量

第 6057 行

std.os.linux.MSG.FASTOPEN

常量

第 6063 行

std.os.linux.MSG.FIN

常量

第 6053 行

std.os.linux.MSG.MORE

常量

第 6059 行

std.os.linux.MSG.NOSIGNAL

常量

第 6058 行

std.os.linux.MSG.OOB

常量

第 6044 行

std.os.linux.MSG.PEEK

常量

第 6045 行

std.os.linux.MSG.PROXY

常量

第 6048 行

std.os.linux.MSG.RST

常量

第 6056 行

std.os.linux.MSG.SYN

常量

第 6054 行

std.os.linux.MSG.TRUNC

常量

第 6049 行

std.os.linux.MSG.WAITALL

常量

第 6052 行

std.os.linux.MSG.WAITFORONE

常量

第 6060 行

std.os.linux.MSG.ZEROCOPY

常量

第 6062 行

std.os.linux.msghdr

容器

第 11217 行

字段

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

内核和 glibc 对此字段使用 usize;POSIX 和 musl 使用 c_int。

control: ?*anyopaque
controllen: usize

内核和 glibc 对此字段使用 usize;POSIX 和 musl 使用 socklen_t。

flags: u32

std.os.linux.msghdr_const

容器

第 11229 行

字段

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

std.os.linux.msync

函数

第 1639 行

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

参数

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

std.os.linux.munlock

函数

第 1651 行

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

参数

address: [*]const u8
length: usize

std.os.linux.munlockall

函数

第 1681 行

pub fn munlockall() usize

std.os.linux.munmap

函数

第 1643 行

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

参数

address: [*]const u8
length: usize

std.os.linux.NAME_MAX

常量

第 4467 行

std.os.linux.name_to_handle_at

函数

第 1381 行

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

参数

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

std.os.linux.nanosleep

函数

第 2495 行

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

参数

req: *const timespec
rem: ?*timespec

std.os.linux.native_abi

常量

第 14 行

std.os.linux.native_arch

常量

第 13 行

std.os.linux.native_endian

常量

第 15 行

std.os.linux.NCC

常量

第 8510 行

std.os.linux.NCCS

常量

第 8511 行

std.os.linux.NETLINK

命名空间

第 10072 行

std.os.linux.NETLINK.AUDIT

常量

第 10101 行

审计

std.os.linux.NETLINK.CONNECTOR

常量

第 10105 行

std.os.linux.NETLINK.CRYPTO

常量

第 10130 行

加密层

std.os.linux.NETLINK.DNRTMSG

常量

第 10113 行

DECnet 路由消息

std.os.linux.NETLINK.ECRYPTFS

常量

第 10125 行

std.os.linux.NETLINK.FIB_LOOKUP

常量

第 10103 行

std.os.linux.NETLINK.FIREWALL

常量

第 10083 行

未使用的编号,原为 ip_queue

std.os.linux.NETLINK.GENERIC

常量

第 10118 行

std.os.linux.NETLINK.IP6_FW

常量

第 10110 行

std.os.linux.NETLINK.ISCSI

常量

第 10098 行

Open-iSCSI

std.os.linux.NETLINK.KOBJECT_UEVENT

常量

第 10116 行

从内核发送到用户空间的消息

std.os.linux.NETLINK.NETFILTER

常量

第 10108 行

netfilter 子系统

std.os.linux.NETLINK.NFLOG

常量

第 10089 行

netfilter/iptables 的 ULOG

std.os.linux.NETLINK.RDMA

常量

第 10127 行

std.os.linux.NETLINK.ROUTE

常量

第 10074 行

路由/设备挂钩

std.os.linux.NETLINK.SCSITRANSPORT

常量

第 10123 行

SCSI 传输

std.os.linux.NETLINK.SELINUX

常量

第 10095 行

SELinux 事件通知

std.os.linux.NETLINK.SMC

常量

第 10133 行

SMC 监视

std.os.linux.NETLINK.SOCK_DIAG

常量

第 10086 行

套接字监视

std.os.linux.NETLINK.UNUSED

常量

第 10077 行

未使用的编号

std.os.linux.NETLINK.USERSOCK

常量

第 10080 行

为用户态套接字协议保留

std.os.linux.NETLINK.XFRM

常量

第 10092 行

ipsec

std.os.linux.NetlinkMessageType

容器

第 10195 行

字段

NOOP = 0x1

无内容。

ERROR = 0x2

错误

DONE = 0x3

转储结束

OVERRUN = 0x4

数据丢失

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

常量

第 10197 行

< 0x10:保留控制消息

std.os.linux.nfds_t

类型

第 8431 行

std.os.linux.NLDLY

类型

第 8666 行

std.os.linux.nlink_t

类型

第 116 行

std.os.linux.NLM_F_ACK

常量

第 10145 行

以确认消息回复,附带零或错误码

std.os.linux.NLM_F_ACK_TLVS

常量

第 10193 行

包含了扩展 ACK TVL

std.os.linux.NLM_F_APPEND

常量

第 10180 行

添加到列表末尾

std.os.linux.NLM_F_ATOMIC

常量

第 10165 行

原子 GET

std.os.linux.NLM_F_CAPPED

常量

第 10190 行

请求受到限制

std.os.linux.NLM_F_CREATE

常量

第 10177 行

不存在时创建

std.os.linux.NLM_F_DUMP

常量

第 10166 行

std.os.linux.NLM_F_DUMP_FILTERED

常量

第 10154 行

转储已按要求过滤

std.os.linux.NLM_F_DUMP_INTR

常量

第 10151 行

由于序列更改,转储不一致

std.os.linux.NLM_F_ECHO

常量

第 10148 行

回显此请求

std.os.linux.NLM_F_EXCL

常量

第 10174 行

如果存在则不要触碰

std.os.linux.NLM_F_MATCH

常量

第 10162 行

返回所有匹配项

std.os.linux.NLM_F_MULTI

常量

第 10142 行

多部分消息,以 NLMSG_DONE 终止

std.os.linux.NLM_F_NONREC

常量

第 10185 行

不要递归删除

std.os.linux.NLM_F_REPLACE

常量

第 10171 行

覆盖现有内容

std.os.linux.NLM_F_REQUEST

常量

第 10139 行

它是请求消息。

std.os.linux.NLM_F_ROOT

常量

第 10159 行

指定树根

std.os.linux.nlmsghdr

容器

第 10299 行

Netlink 消息头部 由 RFC 3549 第 2.3.2 节规定

字段

len: u32

消息长度,含头部

type: NetlinkMessageType

消息内容

flags: u16

附加标志

seq: u32

序列号

pid: u32

发送进程的端口 ID

std.os.linux.NSIG

常量

第 2726 行

定义为已定义的最大信号编号加一。

std.os.linux.O

类型

第 389 行

std.os.linux.off_t

类型

第 117 行

std.os.linux.open

函数

第 1992 行

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

参数

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

std.os.linux.openat

函数

第 2010 行

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

参数

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

std.os.linux.P

容器

第 4694 行

字段

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

std.os.linux.PACKET

命名空间

第 9332 行

std.os.linux.PACKET.ADD_MEMBERSHIP

常量

第 9342 行

std.os.linux.PACKET.AUXDATA

常量

第 9348 行

std.os.linux.PACKET.BROADCAST

常量

第 9334 行

std.os.linux.PACKET.COPY_THRESH

常量

第 9347 行

std.os.linux.PACKET.DROP_MEMBERSHIP

常量

第 9343 行

std.os.linux.PACKET.FANOUT

常量

第 9358 行

std.os.linux.PACKET.FANOUT_CBPF

常量

第 9372 行

std.os.linux.PACKET.FANOUT_CPU

常量

第 9368 行

std.os.linux.PACKET.FANOUT_DATA

常量

第 9362 行

std.os.linux.PACKET.FANOUT_EBPF

常量

第 9373 行

std.os.linux.PACKET.FANOUT_FLAG_DEFRAG

常量

第 9377 行

std.os.linux.PACKET.FANOUT_FLAG_IGNORE_OUTGOING

常量

第 9376 行

std.os.linux.PACKET.FANOUT_FLAG_ROLLOVER

常量

第 9374 行

std.os.linux.PACKET.FANOUT_FLAG_UNIQUEID

常量

第 9375 行

std.os.linux.PACKET.FANOUT_HASH

常量

第 9366 行

std.os.linux.PACKET.FANOUT_LB

常量

第 9367 行

std.os.linux.PACKET.FANOUT_QM

常量

第 9371 行

std.os.linux.PACKET.FANOUT_RND

常量

第 9370 行

std.os.linux.PACKET.FANOUT_ROLLOVER

常量

第 9369 行

std.os.linux.PACKET.HDRLEN

常量

第 9351 行

std.os.linux.PACKET.HOST

常量

第 9333 行

std.os.linux.PACKET.IGNORE_OUTGOING

常量

第 9363 行

std.os.linux.PACKET.KERNEL

常量

第 9340 行

std.os.linux.PACKET.LOOPBACK

常量

第 9338 行

std.os.linux.PACKET.LOSS

常量

第 9354 行

std.os.linux.PACKET.MULTICAST

常量

第 9335 行

std.os.linux.PACKET.ORIGDEV

常量

第 9349 行

std.os.linux.PACKET.OTHERHOST

常量

第 9336 行

std.os.linux.PACKET.OUTGOING

常量

第 9337 行

std.os.linux.PACKET.QDISC_BYPASS

常量

第 9360 行

std.os.linux.PACKET.RECV_OUTPUT

常量

第 9344 行

std.os.linux.PACKET.RESERVE

常量

第 9352 行

std.os.linux.PACKET.ROLLOVER_STATS

常量

第 9361 行

std.os.linux.PACKET.RX_RING

常量

第 9345 行

std.os.linux.PACKET.STATISTICS

常量

第 9346 行

std.os.linux.PACKET.TIMESTAMP

常量

第 9357 行

std.os.linux.PACKET.TX_HAS_OFF

常量

第 9359 行

std.os.linux.PACKET.TX_RING

常量

第 9353 行

std.os.linux.PACKET.TX_TIMESTAMP

常量

第 9356 行

std.os.linux.PACKET.USER

常量

第 9339 行

std.os.linux.PACKET.VERSION

常量

第 9350 行

std.os.linux.PACKET.VNET_HDR

常量

第 9355 行

std.os.linux.PACKET.VNET_HDR_SZ

常量

第 9364 行

std.os.linux.PATH_MAX

常量

第 4468 行

std.os.linux.pause

函数

第 2499 行

pub fn pause() usize

std.os.linux.PERF

命名空间

第 10836 行

std.os.linux.perf_event_attr

容器

第 10581 行

字段

type: PERF.TYPE = undefined

主要类型:硬件/软件/跟踪点等。

size: u32 = @sizeOf(perf_event_attr)

attr 结构体的大小,用于向前/向后兼容。

config: u64 = 0

类型专用配置信息。

sample_period_or_freq: u64 = 0
sample_type: u64 = 0
read_format: u64 = 0
flags: packed struct(u64) {
    /// 默认关闭
    disabled: bool = false,
    /// 子进程继承它
    inherit: bool = false,
    /// 必须始终位于 PMU 上
    pinned: bool = false,
    /// 仅在 PMU 上分组
    exclusive: bool = false,
    /// 不统计用户态
    exclude_user: bool = false,
    /// 内核同上
    exclude_kernel: bool = false,
    /// 虚拟机监控器同上
    exclude_hv: bool = false,
    /// 空闲时不计数
    exclude_idle: bool = false,
    /// 包含 mmap 数据
    mmap: bool = false,
    /// 包含 comm 数据
    comm: bool = false,
    /// 使用频率而非周期
    freq: bool = false,
    /// 每个任务的计数
    inherit_stat: bool = false,
    /// 下次执行时启用
    enable_on_exec: bool = false,
    /// 跟踪派生/退出
    task: bool = false,
    /// wakeup_watermark
    watermark: bool = false,
    /// precise_ip:
    ///
    ///  0 - SAMPLE_IP 的采样偏移可任意
    ///  1 - SAMPLE_IP 的采样偏移必须固定
    ///  2 - 请求 SAMPLE_IP 的采样偏移为 0
    ///  3 - SAMPLE_IP 的采样偏移必须为 0
    ///
    ///  另见 PERF_RECORD_MISC_EXACT_IP
    /// 采样偏移约束
    precise_ip: u2 = 0,
    /// 不可执行的 mmap 数据
    mmap_data: bool = false,
    /// 所有事件的 sample_type
    sample_id_all: bool = false,

    /// 不在宿主机中计数
    exclude_host: bool = false,
    /// 不在客户机中计数
    exclude_guest: bool = false,

    /// 排除内核调用链
    exclude_callchain_kernel: bool = false,
    /// 排除用户调用链
    exclude_callchain_user: bool = false,
    /// 包含带 inode 数据的 mmap
    mmap2: bool = false,
    /// 标记由 exec 产生的 comm 事件
    comm_exec: bool = false,
    /// 时间字段使用 @clockid
    use_clockid: bool = false,
    /// 上下文切换数据
    context_switch: bool = false,
    /// 从末尾向开头写入环形缓冲区
    write_backward: bool = false,
    /// 包含命名空间数据
    namespaces: bool = false,
    /// 包含内核符号事件
    ksymbol: bool = false,
    /// 包含 BPF 事件
    bpf_event: bool = false,
    /// 生成 AUX 记录而非事件
    aux_output: bool = false,
    /// 包含 cgroup 事件
    cgroup: bool = false,
    /// 包含文本修改事件
    text_poke: bool = false,
    /// 在 mmap2 事件中使用构建 ID
    build_id: bool = false,
    /// 仅使用 CLONE_THREAD 克隆的子任务才继承。
    inherit_thread: bool = false,
    /// exec 时从任务中移除事件
    remove_on_exec: bool = false,
    /// 事件发生时发送同步 SIGTRAP
    sigtrap: bool = false,

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

每 n 个事件唤醒一次,或 达到指定字节数后唤醒

bp_type: u32 = 0
config1: u64 = 0

此字段还用于: bp_addr perf_kprobe 的 kprobe_func perf_uprobe 的 uprobe_path

config2: u64 = 0

此字段还用于: bp_len kprobe_func == null 时的 kprobe_addr perf_[k,u]probe 的 probe_offset

branch_sample_type: u64 = 0

enum perf_branch_sample_type

sample_regs_user: u64 = 0

定义采样时要转储的用户寄存器集合。 详情参见 asm/perf_regs.h。

sample_stack_user: u32 = 0

定义采样时要转储的用户栈大小。

clockid: clockid_t = .REALTIME
sample_regs_intr: u64 = 0

定义每个采样状态要转储的寄存器集合:

  • precise = 0:PMU 中断
  • precise > 0:采样指令

详情参见 asm/perf_regs.h。

aux_watermark: u32 = 0

AUX 区域的唤醒水位

sample_max_stack: u16 = 0
__reserved_2: u16 = 0

对齐到 u64

aux_sample_size: u32 = 0
aux_action: packed struct(u32) {
    /// 启动时暂停 AUX 区域跟踪
    start_paused: bool = false,
    /// 溢出时暂停 AUX 区域跟踪
    pause: bool = false,
    /// 溢出时恢复 AUX 区域跟踪
    @"resume": bool = false,

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

sigtrap == true 时为用户提供的数据

config3: u64 = 0

config2 的扩展

std.os.linux.perf_event_header

容器

第 10742 行

字段

type: PERF.RECORD

事件类型:sample/mmap/fork 等

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: u16

后续记录的大小

std.os.linux.perf_event_mmap_page

容器

第 10767 行

字段

version: u32

此结构体的版本号

compt_version: u32

与之兼容的最低版本

lock: u32

用于同步的顺序锁

index: u32

硬件计数器标识符

offset: i64

加到硬件计数器值上

time_enabled: u64

事件处于活动状态的时间

time_running: u64

事件运行的时间

capabilities: packed struct(u64) {
    /// 内核版本 < 3.12 时,
    /// 同时表示 user_rdpmc 和 user_time(user_rdpmc | user_time),
    /// 否则已弃用。
    bit0: bool,
    /// bit0 已弃用时设置
    bit0_is_deprecated: bool,
    /// 支持用户空间读取性能计数器的硬件能力。
    user_rdpmc: bool,
    /// 硬件支持恒定且不停走的时间戳计数器(例如 x86 上的 TSC)
    user_time: bool,
    /// 使用 time_zero 字段
    user_time_zero: bool,
    /// 使用 time_{cycle,mask} 字段
    user_time_short: bool,
    ____res: u58,
}
pcm_width: u16

如果 capabilities.user_rdpmc 为真, 此字段报告 rdpmc() 或等价操作读取值的位宽。

time_shift: u16

若 capabilities.user_time 成立,可使用以下字段,通过 RDTSC 或类似机制 计算自 time_enabled 以来的时间差,单位为纳秒。

time_mult: u32
time_offset: u64
time_zero: u64

如果 capabilities.user_time_zero,便可根据采样时间戳计算硬件时钟

size: u32

头部大小

__reserved_1: u32
time_cycles: u64

当硬件时钟的位宽小于 64 位时, 使用以下字段计算时间戳。

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

位于数据段中的头部

data_tail: u64

由用户空间写入的尾部

data_offset: u64

缓冲区的起始位置

data_size: u64

数据缓冲区大小

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

std.os.linux.perf_event_open

函数

第 3407 行

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

参数

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

std.os.linux.PERF.COUNT

命名空间

第 10848 行

std.os.linux.PERF.COUNT.HW

容器

第 10849 行

字段

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

容器

第 10862 行

字段

L1D
L1I
LL
DTLB
ITLB
BPU
NODE
MAX

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

容器

第 10872 行

字段

READ
WRITE
PREFETCH
MAX

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

容器

第 10879 行

字段

ACCESS
MISS
MAX

std.os.linux.PERF.COUNT.SW

容器

第 10887 行

字段

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

命名空间

第 10990 行

std.os.linux.PERF.EVENT_IOC.DISABLE

常量

第 10992 行

std.os.linux.PERF.EVENT_IOC.ENABLE

常量

第 10991 行

std.os.linux.PERF.EVENT_IOC.ID

常量

第 10998 行

std.os.linux.PERF.EVENT_IOC.MODIFY_ATTRIBUTES

常量

第 11002 行

std.os.linux.PERF.EVENT_IOC.PAUSE_OUTPUT

常量

第 11000 行

std.os.linux.PERF.EVENT_IOC.PERIOD

常量

第 10995 行

std.os.linux.PERF.EVENT_IOC.QUERY_BPF

常量

第 11001 行

std.os.linux.PERF.EVENT_IOC.REFRESH

常量

第 10993 行

std.os.linux.PERF.EVENT_IOC.RESET

常量

第 10994 行

std.os.linux.PERF.EVENT_IOC.SET_BPF

常量

第 10999 行

std.os.linux.PERF.EVENT_IOC.SET_FILTER

常量

第 10997 行

std.os.linux.PERF.EVENT_IOC.SET_OUTPUT

常量

第 10996 行

std.os.linux.PERF.FLAG

命名空间

第 10983 行

std.os.linux.PERF.FLAG.FD_CLOEXEC

常量

第 10987 行

std.os.linux.PERF.FLAG.FD_NO_GROUP

常量

第 10984 行

std.os.linux.PERF.FLAG.FD_OUTPUT

常量

第 10985 行

std.os.linux.PERF.FLAG.PID_CGROUP

常量

第 10986 行

std.os.linux.PERF.IOC_FLAG_GROUP

常量

第 11005 行

std.os.linux.PERF.RECORD

容器

第 10948 行

字段

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

命名空间

第 10971 行

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

容器

第 10972 行

字段

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

std.os.linux.PERF.SAMPLE

命名空间

第 10903 行

std.os.linux.PERF.SAMPLE.ADDR

常量

第 10907 行

std.os.linux.PERF.SAMPLE.BRANCH

命名空间

第 10926 行

std.os.linux.PERF.SAMPLE.BRANCH_STACK

常量

第 10915 行

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

常量

第 10934 行

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

常量

第 10930 行

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

常量

第 10931 行

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

常量

第 10932 行

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

常量

第 10940 行

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

常量

第 10938 行

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

常量

第 10937 行

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

常量

第 10929 行

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

常量

第 10935 行

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

常量

第 10933 行

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

常量

第 10939 行

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

常量

第 10928 行

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

常量

第 10944 行

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

常量

第 10942 行

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

常量

第 10941 行

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

常量

第 10936 行

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

常量

第 10943 行

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

常量

第 10927 行

std.os.linux.PERF.SAMPLE.CALLCHAIN

常量

第 10909 行

std.os.linux.PERF.SAMPLE.CPU

常量

第 10911 行

std.os.linux.PERF.SAMPLE.DATA_SRC

常量

第 10919 行

std.os.linux.PERF.SAMPLE.ID

常量

第 10910 行

std.os.linux.PERF.SAMPLE.IDENTIFIER

常量

第 10920 行

std.os.linux.PERF.SAMPLE.IP

常量

第 10904 行

std.os.linux.PERF.SAMPLE.MAX

常量

第 10924 行

std.os.linux.PERF.SAMPLE.PERIOD

常量

第 10912 行

std.os.linux.PERF.SAMPLE.PHYS_ADDR

常量

第 10923 行

std.os.linux.PERF.SAMPLE.RAW

常量

第 10914 行

std.os.linux.PERF.SAMPLE.READ

常量

第 10908 行

std.os.linux.PERF.SAMPLE.REGS_INTR

常量

第 10922 行

std.os.linux.PERF.SAMPLE.REGS_USER

常量

第 10916 行

std.os.linux.PERF.SAMPLE.STACK_USER

常量

第 10917 行

std.os.linux.PERF.SAMPLE.STREAM_ID

常量

第 10913 行

std.os.linux.PERF.SAMPLE.TID

常量

第 10905 行

std.os.linux.PERF.SAMPLE.TIME

常量

第 10906 行

std.os.linux.PERF.SAMPLE.TRANSACTION

常量

第 10921 行

std.os.linux.PERF.SAMPLE.WEIGHT

常量

第 10918 行

std.os.linux.PERF.TYPE

容器

第 10837 行

字段

HARDWARE
SOFTWARE
TRACEPOINT
HW_CACHE
RAW
BREAKPOINT
MAX
_

std.os.linux.PF

命名空间

第 5118 行

std.os.linux.PF.ALG

常量

第 5160 行

std.os.linux.PF.APPLETALK

常量

第 5126 行

std.os.linux.PF.ASH

常量

第 5140 行

std.os.linux.PF.ATMPVC

常量

第 5129 行

std.os.linux.PF.ATMSVC

常量

第 5142 行

std.os.linux.PF.AX25

常量

第 5124 行

std.os.linux.PF.BLUETOOTH

常量

第 5153 行

std.os.linux.PF.BRIDGE

常量

第 5128 行

std.os.linux.PF.CAIF

常量

第 5159 行

std.os.linux.PF.CAN

常量

第 5151 行

std.os.linux.PF.DECnet

常量

第 5133 行

std.os.linux.PF.ECONET

常量

第 5141 行

std.os.linux.PF.FILE

别名

第 5122 行

别名目标 std.os.linux.PF.LOCAL

std.os.linux.PF.IB

常量

第 5149 行

std.os.linux.PF.IEEE802154

常量

第 5158 行

std.os.linux.PF.INET

常量

第 5123 行

std.os.linux.PF.INET6

常量

第 5131 行

std.os.linux.PF.IPX

常量

第 5125 行

std.os.linux.PF.IRDA

常量

第 5145 行

std.os.linux.PF.ISDN

常量

第 5156 行

std.os.linux.PF.IUCV

常量

第 5154 行

std.os.linux.PF.KCM

常量

第 5163 行

std.os.linux.PF.KEY

常量

第 5136 行

std.os.linux.PF.LLC

常量

第 5148 行

std.os.linux.PF.LOCAL

常量

第 5120 行

std.os.linux.PF.MAX

常量

第 5167 行

std.os.linux.PF.MPLS

常量

第 5150 行

std.os.linux.PF.NETBEUI

常量

第 5134 行

std.os.linux.PF.NETLINK

常量

第 5137 行

std.os.linux.PF.NETROM

常量

第 5127 行

std.os.linux.PF.NFC

常量

第 5161 行

std.os.linux.PF.PACKET

常量

第 5139 行

std.os.linux.PF.PHONET

常量

第 5157 行

std.os.linux.PF.PPPOX

常量

第 5146 行

std.os.linux.PF.QIPCRTR

常量

第 5164 行

std.os.linux.PF.RDS

常量

第 5143 行

std.os.linux.PF.ROSE

常量

第 5132 行

std.os.linux.PF.ROUTE

别名

第 5138 行

别名目标 std.os.linux.PF.NETLINK

std.os.linux.PF.RXRPC

常量

第 5155 行

std.os.linux.PF.SECURITY

常量

第 5135 行

std.os.linux.PF.SMC

常量

第 5165 行

std.os.linux.PF.SNA

常量

第 5144 行

std.os.linux.PF.TIPC

常量

第 5152 行

std.os.linux.PF.UNIX

别名

第 5121 行

别名目标 std.os.linux.PF.LOCAL

std.os.linux.PF.UNSPEC

常量

第 5119 行

std.os.linux.PF.VSOCK

常量

第 5162 行

std.os.linux.PF.WANPIPE

常量

第 5147 行

std.os.linux.PF.X25

常量

第 5130 行

std.os.linux.PF.XDP

常量

第 5166 行

std.os.linux.pid_t

类型

第 118 行

std.os.linux.pidfd_getfd

函数

第 3309 行

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

参数

pidfd: fd_t
targetfd: fd_t
flags: u32

std.os.linux.pidfd_open

函数

第 3305 行

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

参数

pid: pid_t
flags: u32

std.os.linux.pidfd_send_signal

函数

第 3318 行

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

参数

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

std.os.linux.pipe

函数

第 1895 行

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

参数

fd: *[2]fd_t

std.os.linux.pipe2

函数

第 1905 行

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

参数

fd: *[2]fd_t
flags: O

std.os.linux.pivot_root

函数

第 1565 行

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

参数

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

std.os.linux.poll

函数

第 1685 行

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

参数

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

std.os.linux.POLL

命名空间

第 8438 行

std.os.linux.POLL.ERR

常量

第 8442 行

std.os.linux.POLL.HUP

常量

第 8443 行

std.os.linux.POLL.IN

常量

第 8439 行

std.os.linux.POLL.NVAL

常量

第 8444 行

std.os.linux.POLL.OUT

常量

第 8441 行

std.os.linux.POLL.PRI

常量

第 8440 行

std.os.linux.POLL.RDBAND

常量

第 8446 行

std.os.linux.POLL.RDNORM

常量

第 8445 行

std.os.linux.pollfd

容器

第 8432 行

字段

fd: fd_t
events: i16
revents: i16 = undefined

std.os.linux.POSIX_FADV

类型

第 9728 行

std.os.linux.POSIX_FADV.DONTNEED

常量

第 9734 行

std.os.linux.POSIX_FADV.DONTNEED

常量

第 9741 行

std.os.linux.POSIX_FADV.DONTNEED

常量

第 9749 行

std.os.linux.POSIX_FADV.NOREUSE

常量

第 9735 行

std.os.linux.POSIX_FADV.NOREUSE

常量

第 9742 行

std.os.linux.POSIX_FADV.NOREUSE

常量

第 9750 行

std.os.linux.POSIX_FADV.NORMAL

常量

第 9730 行

std.os.linux.POSIX_FADV.NORMAL

常量

第 9737 行

std.os.linux.POSIX_FADV.NORMAL

常量

第 9745 行

std.os.linux.POSIX_FADV.RANDOM

常量

第 9731 行

std.os.linux.POSIX_FADV.RANDOM

常量

第 9738 行

std.os.linux.POSIX_FADV.RANDOM

常量

第 9746 行

std.os.linux.POSIX_FADV.SEQUENTIAL

常量

第 9732 行

std.os.linux.POSIX_FADV.SEQUENTIAL

常量

第 9739 行

std.os.linux.POSIX_FADV.SEQUENTIAL

常量

第 9747 行

std.os.linux.POSIX_FADV.WILLNEED

常量

第 9733 行

std.os.linux.POSIX_FADV.WILLNEED

常量

第 9740 行

std.os.linux.POSIX_FADV.WILLNEED

常量

第 9748 行

std.os.linux.ppoll

函数

第 1705 行

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

参数

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

std.os.linux.PR

容器

第 9902 行

字段

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

常量

第 10041 行

std.os.linux.PR.CAP_AMBIENT_IS_SET

常量

第 10038 行

std.os.linux.PR.CAP_AMBIENT_LOWER

常量

第 10040 行

std.os.linux.PR.CAP_AMBIENT_RAISE

常量

第 10039 行

std.os.linux.PR.ENDIAN_BIG

常量

第 10003 行

std.os.linux.PR.ENDIAN_LITTLE

常量

第 10004 行

std.os.linux.PR.ENDIAN_PPC_LITTLE

常量

第 10005 行

std.os.linux.PR.FP_EXC_ASYNC

常量

第 9997 行

std.os.linux.PR.FP_EXC_DISABLED

常量

第 9995 行

std.os.linux.PR.FP_EXC_DIV

常量

第 9990 行

std.os.linux.PR.FP_EXC_INV

常量

第 9994 行

std.os.linux.PR.FP_EXC_NONRECOV

常量

第 9996 行

std.os.linux.PR.FP_EXC_OVF

常量

第 9991 行

std.os.linux.PR.FP_EXC_PRECISE

常量

第 9998 行

std.os.linux.PR.FP_EXC_RES

常量

第 9993 行

std.os.linux.PR.FP_EXC_SW_ENABLE

常量

第 9989 行

std.os.linux.PR.FP_EXC_UND

常量

第 9992 行

std.os.linux.PR.FP_MODE_FR

常量

第 10035 行

std.os.linux.PR.FP_MODE_FRE

常量

第 10036 行

std.os.linux.PR.FPEMU_NOPRINT

常量

第 9986 行

std.os.linux.PR.FPEMU_SIGFPE

常量

第 9987 行

std.os.linux.PR.MCE_KILL_CLEAR

常量

第 10010 行

std.os.linux.PR.MCE_KILL_DEFAULT

常量

第 10015 行

std.os.linux.PR.MCE_KILL_EARLY

常量

第 10014 行

std.os.linux.PR.MCE_KILL_LATE

常量

第 10013 行

std.os.linux.PR.MCE_KILL_SET

常量

第 10011 行

std.os.linux.PR.SET_MM_ARG_END

常量

第 10025 行

std.os.linux.PR.SET_MM_ARG_START

常量

第 10024 行

std.os.linux.PR.SET_MM_AUXV

常量

第 10028 行

std.os.linux.PR.SET_MM_BRK

常量

第 10023 行

std.os.linux.PR.SET_MM_END_CODE

常量

第 10018 行

std.os.linux.PR.SET_MM_END_DATA

常量

第 10020 行

std.os.linux.PR.SET_MM_ENV_END

常量

第 10027 行

std.os.linux.PR.SET_MM_ENV_START

常量

第 10026 行

std.os.linux.PR.SET_MM_EXE_FILE

常量

第 10029 行

std.os.linux.PR.SET_MM_MAP

常量

第 10030 行

std.os.linux.PR.SET_MM_MAP_SIZE

常量

第 10031 行

std.os.linux.PR.SET_MM_START_BRK

常量

第 10022 行

std.os.linux.PR.SET_MM_START_CODE

常量

第 10017 行

std.os.linux.PR.SET_MM_START_DATA

常量

第 10019 行

std.os.linux.PR.SET_MM_START_STACK

常量

第 10021 行

std.os.linux.PR.SET_PTRACER_ANY

常量

第 10033 行

std.os.linux.PR.SPEC_DISABLE

常量

第 10051 行

std.os.linux.PR.SPEC_ENABLE

常量

第 10050 行

std.os.linux.PR.SPEC_FORCE_DISABLE

常量

第 10052 行

std.os.linux.PR.SPEC_NOT_AFFECTED

常量

第 10048 行

std.os.linux.PR.SPEC_PRCTL

常量

第 10049 行

std.os.linux.PR.SPEC_STORE_BYPASS

常量

第 10047 行

std.os.linux.PR.SVE_SET_VL_ONEXEC

常量

第 10043 行

std.os.linux.PR.SVE_VL_INHERIT

常量

第 10045 行

std.os.linux.PR.SVE_VL_LEN_MASK

常量

第 10044 行

std.os.linux.PR.TIMING_STATISTICAL

常量

第 10000 行

std.os.linux.PR.TIMING_TIMESTAMP

常量

第 10001 行

std.os.linux.PR.TSC_ENABLE

常量

第 10007 行

std.os.linux.PR.TSC_SIGSEGV

常量

第 10008 行

std.os.linux.PR.UNALIGN_NOPRINT

常量

第 9983 行

std.os.linux.PR.UNALIGN_SIGBUS

常量

第 9984 行

std.os.linux.prctl

函数

第 3273 行

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

参数

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

std.os.linux.prctl_mm_map

容器

第 10055 行

字段

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

函数

第 1720 行

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

参数

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

std.os.linux.preadv

函数

第 1758 行

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

参数

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

std.os.linux.preadv2

函数

第 1773 行

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

参数

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

std.os.linux.prlimit

函数

第 3287 行

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

参数

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

std.os.linux.process_vm_readv

函数

第 3328 行

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

参数

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

std.os.linux.process_vm_writev

函数

第 3340 行

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

参数

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

std.os.linux.PROT

类型

第 4632 行

std.os.linux.ptrace

函数

第 3428 行

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

参数

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

std.os.linux.PTRACE

命名空间

第 11114 行

std.os.linux.PTRACE.ATTACH

常量

第 11129 行

std.os.linux.PTRACE.CONT

常量

第 11122 行

std.os.linux.PTRACE.DETACH

常量

第 11130 行

std.os.linux.PTRACE.EVENT

命名空间

第 11150 行

std.os.linux.PTRACE.EVENT.CLONE

常量

第 11153 行

std.os.linux.PTRACE.EVENT.EXEC

常量

第 11154 行

std.os.linux.PTRACE.EVENT.EXIT

常量

第 11156 行

std.os.linux.PTRACE.EVENT.FORK

常量

第 11151 行

std.os.linux.PTRACE.EVENT.SECCOMP

常量

第 11157 行

std.os.linux.PTRACE.EVENT.STOP

常量

第 11158 行

std.os.linux.PTRACE.EVENT.VFORK

常量

第 11152 行

std.os.linux.PTRACE.EVENT.VFORK_DONE

常量

第 11155 行

std.os.linux.PTRACE.GET_SYSCALL_INFO

常量

第 11148 行

std.os.linux.PTRACE.GETEVENTMSG

常量

第 11135 行

std.os.linux.PTRACE.GETFPREGS

常量

第 11127 行

std.os.linux.PTRACE.GETFPXREGS

常量

第 11131 行

std.os.linux.PTRACE.GETREGS

常量

第 11125 行

std.os.linux.PTRACE.GETREGSET

常量

第 11138 行

std.os.linux.PTRACE.GETSIGINFO

常量

第 11136 行

std.os.linux.PTRACE.GETSIGMASK

常量

第 11144 行

std.os.linux.PTRACE.INTERRUPT

常量

第 11141 行

std.os.linux.PTRACE.KILL

常量

第 11123 行

std.os.linux.PTRACE.LISTEN

常量

第 11142 行

std.os.linux.PTRACE.O

命名空间

第 11161 行

std.os.linux.PTRACE.O.EXITKILL

常量

第 11171 行

std.os.linux.PTRACE.O.MASK

常量

第 11174 行

std.os.linux.PTRACE.O.SUSPEND_SECCOMP

常量

第 11172 行

std.os.linux.PTRACE.O.TRACECLONE

常量

第 11165 行

std.os.linux.PTRACE.O.TRACEEXEC

常量

第 11166 行

std.os.linux.PTRACE.O.TRACEEXIT

常量

第 11168 行

std.os.linux.PTRACE.O.TRACEFORK

常量

第 11163 行

std.os.linux.PTRACE.O.TRACESECCOMP

常量

第 11169 行

std.os.linux.PTRACE.O.TRACESYSGOOD

常量

第 11162 行

std.os.linux.PTRACE.O.TRACEVFORK

常量

第 11164 行

std.os.linux.PTRACE.O.TRACEVFORKDONE

常量

第 11167 行

std.os.linux.PTRACE.PEEKDATA

常量

第 11117 行

std.os.linux.PTRACE.PEEKSIGINFO

常量

第 11143 行

std.os.linux.PTRACE.PEEKTEXT

常量

第 11116 行

std.os.linux.PTRACE.PEEKUSER

常量

第 11118 行

std.os.linux.PTRACE.POKEDATA

常量

第 11120 行

std.os.linux.PTRACE.POKETEXT

常量

第 11119 行

std.os.linux.PTRACE.POKEUSER

常量

第 11121 行

std.os.linux.PTRACE.SECCOMP_GET_FILTER

常量

第 11146 行

std.os.linux.PTRACE.SECCOMP_GET_METADATA

常量

第 11147 行

std.os.linux.PTRACE.SEIZE

常量

第 11140 行

std.os.linux.PTRACE.SETFPREGS

常量

第 11128 行

std.os.linux.PTRACE.SETFPXREGS

常量

第 11132 行

std.os.linux.PTRACE.SETOPTIONS

常量

第 11134 行

std.os.linux.PTRACE.SETREGS

常量

第 11126 行

std.os.linux.PTRACE.SETREGSET

常量

第 11139 行

std.os.linux.PTRACE.SETSIGINFO

常量

第 11137 行

std.os.linux.PTRACE.SETSIGMASK

常量

第 11145 行

std.os.linux.PTRACE.SINGLESTEP

常量

第 11124 行

std.os.linux.PTRACE.SYSCALL

常量

第 11133 行

std.os.linux.PTRACE.TRACEME

常量

第 11115 行

std.os.linux.pwrite

函数

第 1791 行

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

参数

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

std.os.linux.pwritev

函数

第 1829 行

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

参数

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

std.os.linux.pwritev2

函数

第 1842 行

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

参数

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

std.os.linux.R_OK

常量

第 4663 行

std.os.linux.read

函数

第 1716 行

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

参数

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

std.os.linux.readlink

函数

第 1398 行

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

参数

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

std.os.linux.readlinkat

函数

第 1406 行

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

参数

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

std.os.linux.readv

函数

第 1754 行

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

参数

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

std.os.linux.reboot

函数

第 2184 行

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

参数

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

std.os.linux.recvfrom

函数

第 2859 行

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

参数

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

std.os.linux.recvmmsg

函数

第 2848 行

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

参数

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

std.os.linux.recvmsg

函数

第 2840 行

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

参数

fd: fd_t
msg: *msghdr
flags: u32

std.os.linux.removexattr

函数

第 2980 行

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

参数

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

std.os.linux.rename

函数

第 1937 行

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

参数

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

std.os.linux.RENAME

容器

第 954 行

字段

NOREPLACE: bool = false

不能与 EXCHANGE 同时设置。

EXCHANGE: bool = false

不能与 NOREPLACE 同时设置。

WHITEOUT: bool = false
_: u29 = 0

std.os.linux.renameat

函数

第 1960 行

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

参数

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

std.os.linux.renameat2

函数

第 1981 行

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

参数

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

std.os.linux.require_aligned_register_pair

常量

第 1003 行

std.os.linux.restore

常量

第 78 行

std.os.linux.restore_rt

常量

第 79 行

std.os.linux.riscv_hwprobe

容器

第 11250 行

字段

key: i64
value: u64

std.os.linux.RISCV_HWPROBE

命名空间

第 11255 行

std.os.linux.RISCV_HWPROBE.BASE_BEHAVIOR_IMA

常量

第 11278 行

std.os.linux.RISCV_HWPROBE.FLAGS_WHICH_CPUS

常量

第 11276 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0

命名空间

第 11280 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_SUPM

常量

第 11330 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZAAMO

常量

第 11337 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZABHA

常量

第 11339 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZACAS

常量

第 11315 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZALASR

常量

第 11340 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZALRSC

常量

第 11338 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZAWRS

常量

第 11329 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZBA

常量

第 11284 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZBB

常量

第 11285 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZBC

常量

第 11288 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZBKB

常量

第 11289 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZBKC

常量

第 11290 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZBKX

常量

第 11291 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZBS

常量

第 11286 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZCA

常量

第 11324 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZCB

常量

第 11325 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZCD

常量

第 11326 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZCF

常量

第 11327 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZCLSD

常量

第 11343 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZCMOP

常量

第 11328 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZFA

常量

第 11313 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZFBFMIN

常量

第 11333 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZFH

常量

第 11308 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZFHMIN

常量

第 11309 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZICBOM

常量

第 11336 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZICBOP

常量

第 11341 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZICBOZ

常量

第 11287 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZICFILP

常量

第 11344 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZICNTR

常量

第 11331 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZICOND

常量

第 11316 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZIHINTNTL

常量

第 11310 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZIHINTPAUSE

常量

第 11317 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZIHPM

常量

第 11332 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZILSD

常量

第 11342 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZIMOP

常量

第 11323 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZKND

常量

第 11292 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZKNE

常量

第 11293 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZKNH

常量

第 11294 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZKSED

常量

第 11295 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZKSH

常量

第 11296 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZKT

常量

第 11297 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZTSO

常量

第 11314 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVBB

常量

第 11298 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVBC

常量

第 11299 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVE32F

常量

第 11319 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVE32X

常量

第 11318 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVE64D

常量

第 11322 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVE64F

常量

第 11321 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVE64X

常量

第 11320 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVFBFMIN

常量

第 11334 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVFBFWMA

常量

第 11335 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVFH

常量

第 11311 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVFHMIN

常量

第 11312 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKB

常量

第 11300 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKG

常量

第 11301 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKNED

常量

第 11302 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKNHA

常量

第 11303 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKNHB

常量

第 11304 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKSED

常量

第 11305 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKSH

常量

第 11306 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.EXT_ZVKT

常量

第 11307 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.IMA_C

常量

第 11282 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.IMA_FD

常量

第 11281 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_0.IMA_V

常量

第 11283 行

std.os.linux.RISCV_HWPROBE.IMA_EXT_1_EXT_ZICFISS

常量

第 11347 行

std.os.linux.RISCV_HWPROBE.KEY

命名空间

第 11256 行

std.os.linux.RISCV_HWPROBE.KEY.BASE_BEHAVIOR

常量

第 11260 行

std.os.linux.RISCV_HWPROBE.KEY.CPUPERF_0

常量

第 11262 行

std.os.linux.RISCV_HWPROBE.KEY.HIGHEST_VIRT_ADDRESS

常量

第 11264 行

std.os.linux.RISCV_HWPROBE.KEY.IMA_EXT_0

常量

第 11261 行

std.os.linux.RISCV_HWPROBE.KEY.IMA_EXT_1

常量

第 11273 行

std.os.linux.RISCV_HWPROBE.KEY.MARCHID

常量

第 11258 行

std.os.linux.RISCV_HWPROBE.KEY.MIMPID

常量

第 11259 行

std.os.linux.RISCV_HWPROBE.KEY.MISALIGNED_SCALAR_PERF

常量

第 11266 行

std.os.linux.RISCV_HWPROBE.KEY.MISALIGNED_VECTOR_PERF

常量

第 11267 行

std.os.linux.RISCV_HWPROBE.KEY.MVENDORID

常量

第 11257 行

std.os.linux.RISCV_HWPROBE.KEY.TIME_CSR_FREQ

常量

第 11265 行

std.os.linux.RISCV_HWPROBE.KEY.VENDOR_EXT_MIPS_0

常量

第 11271 行

std.os.linux.RISCV_HWPROBE.KEY.VENDOR_EXT_SIFIVE_0

常量

第 11270 行

std.os.linux.RISCV_HWPROBE.KEY.VENDOR_EXT_THEAD_0

常量

第 11268 行

std.os.linux.RISCV_HWPROBE.KEY.ZICBOM_BLOCK_SIZE

常量

第 11269 行

std.os.linux.RISCV_HWPROBE.KEY.ZICBOP_BLOCK_SIZE

常量

第 11272 行

std.os.linux.RISCV_HWPROBE.KEY.ZICBOZ_BLOCK_SIZE

常量

第 11263 行

std.os.linux.RISCV_HWPROBE.MIPS_VENDOR_EXT_XMIPSEXECTL

常量

第 11364 行

std.os.linux.RISCV_HWPROBE.MISALIGNED_SCALAR

命名空间

第 11349 行

std.os.linux.RISCV_HWPROBE.MISALIGNED_SCALAR.EMULATED

常量

第 11351 行

std.os.linux.RISCV_HWPROBE.MISALIGNED_SCALAR.FAST

常量

第 11353 行

std.os.linux.RISCV_HWPROBE.MISALIGNED_SCALAR.SLOW

常量

第 11352 行

std.os.linux.RISCV_HWPROBE.MISALIGNED_SCALAR.UNKNOWN

常量

第 11350 行

std.os.linux.RISCV_HWPROBE.MISALIGNED_SCALAR.UNSUPPORTED

常量

第 11354 行

std.os.linux.RISCV_HWPROBE.MISALIGNED_VECTOR

命名空间

第 11357 行

std.os.linux.RISCV_HWPROBE.MISALIGNED_VECTOR.FAST

常量

第 11360 行

std.os.linux.RISCV_HWPROBE.MISALIGNED_VECTOR.SLOW

常量

第 11359 行

std.os.linux.RISCV_HWPROBE.MISALIGNED_VECTOR.UNKNOWN

常量

第 11358 行

std.os.linux.RISCV_HWPROBE.MISALIGNED_VECTOR.UNSUPPORTED

常量

第 11361 行

std.os.linux.RISCV_HWPROBE.SIFIVE_VENDOR_EXT

命名空间

第 11366 行

std.os.linux.RISCV_HWPROBE.SIFIVE_VENDOR_EXT.XSFVFNRCLIPXFQF

常量

第 11369 行

std.os.linux.RISCV_HWPROBE.SIFIVE_VENDOR_EXT.XSFVFWMACCQQQ

常量

第 11370 行

std.os.linux.RISCV_HWPROBE.SIFIVE_VENDOR_EXT.XSFVQMACCDOD

常量

第 11367 行

std.os.linux.RISCV_HWPROBE.SIFIVE_VENDOR_EXT.XSFVQMACCQOQ

常量

第 11368 行

std.os.linux.RLIM

命名空间

第 9686 行

std.os.linux.rlim_t

类型

第 9684 行

std.os.linux.RLIM.INFINITY

常量

第 9688 行

无限制

rlim_t

std.os.linux.RLIM.SAVED_CUR

别名

第 9694 行

别名目标 std.os.linux.RLIM.INFINITY

std.os.linux.RLIM.SAVED_MAX

别名

第 9693 行

别名目标 std.os.linux.RLIM.INFINITY

std.os.linux.rlimit

容器

第 9697 行

字段

cur: rlim_t

软限制

max: rlim_t

硬限制

std.os.linux.rlimit_resource

类型

第 9480 行

std.os.linux.rmdir

函数

第 1856 行

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

参数

path: [*:0]const u8

std.os.linux.rtattr

容器

第 10333 行

字段

len: c_ushort

选项长度

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

选项类型

std.os.linux.rtattr.ALIGNTO

常量

第 10345 行

std.os.linux.rtnl_link_ifmap

容器

第 10442 行

字段

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

std.os.linux.rtnl_link_stats

容器

第 10451 行

字段

rx_packets: u32

收到的数据包总数

tx_packets: u32

已发送的数据包总数

rx_bytes: u32

已接收的总字节数

tx_bytes: u32

已发送的总字节数

rx_errors: u32

收到的错误数据包

tx_errors: u32

数据包发送问题

rx_dropped: u32

Linux 缓冲区中没有空间

tx_dropped: u32

linux 中没有可用空间

multicast: u32

收到的多播数据包

collisions: u32
rx_length_errors: u32
rx_over_errors: u32

接收环形缓冲区溢出

rx_crc_errors: u32

收到 CRC 错误的数据包

rx_frame_errors: u32

接收帧对齐错误

rx_fifo_errors: u32

接收 FIFO 溢出

rx_missed_errors: u32

接收端漏掉的数据包

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

已丢弃,未找到处理器

std.os.linux.rtnl_link_stats64

容器

第 10516 行

字段

rx_packets: u64

收到的数据包总数

tx_packets: u64

已发送的数据包总数

rx_bytes: u64

已接收的总字节数

tx_bytes: u64

已发送的总字节数

rx_errors: u64

收到的错误数据包

tx_errors: u64

数据包发送问题

rx_dropped: u64

Linux 缓冲区中没有空间

tx_dropped: u64

linux 中没有可用空间

multicast: u64

收到的多播数据包

collisions: u64
rx_length_errors: u64
rx_over_errors: u64

接收环形缓冲区溢出

rx_crc_errors: u64

收到 CRC 错误的数据包

rx_frame_errors: u64

接收帧对齐错误

rx_fifo_errors: u64

接收 FIFO 溢出

rx_missed_errors: u64

接收端漏掉的数据包

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

已丢弃,未找到处理器

std.os.linux.rusage

容器

第 8486 行

字段

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

常量

第 8506 行

std.os.linux.rusage.SELF

常量

第 8505 行

std.os.linux.rusage.THREAD

常量

第 8507 行

std.os.linux.RWF

命名空间

第 4974 行

std.os.linux.RWF.APPEND

常量

第 4979 行

kernel_rwf

std.os.linux.RWF.DSYNC

常量

第 4976 行

kernel_rwf

std.os.linux.RWF.HIPRI

常量

第 4975 行

kernel_rwf

std.os.linux.RWF.NOWAIT

常量

第 4978 行

kernel_rwf

std.os.linux.RWF.SYNC

常量

第 4977 行

kernel_rwf

std.os.linux.S

命名空间

第 6878 行

std.os.linux.S.IFBLK

常量

第 6883 行

std.os.linux.S.IFCHR

常量

第 6882 行

std.os.linux.S.IFDIR

常量

第 6881 行

std.os.linux.S.IFIFO

常量

第 6885 行

std.os.linux.S.IFLNK

常量

第 6886 行

std.os.linux.S.IFMT

常量

第 6879 行

std.os.linux.S.IFREG

常量

第 6884 行

std.os.linux.S.IFSOCK

常量

第 6887 行

std.os.linux.S.IRGRP

常量

第 6896 行

std.os.linux.S.IROTH

常量

第 6900 行

std.os.linux.S.IRUSR

常量

第 6892 行

std.os.linux.S.IRWXG

常量

第 6899 行

std.os.linux.S.IRWXO

常量

第 6903 行

std.os.linux.S.IRWXU

常量

第 6895 行

std.os.linux.S.ISBLK

函数

第 6917 行

pub fn ISBLK(m: mode_t) bool

参数

m: mode_t

std.os.linux.S.ISCHR

函数

第 6913 行

pub fn ISCHR(m: mode_t) bool

参数

m: mode_t

std.os.linux.S.ISDIR

函数

第 6909 行

pub fn ISDIR(m: mode_t) bool

参数

m: mode_t

std.os.linux.S.ISFIFO

函数

第 6921 行

pub fn ISFIFO(m: mode_t) bool

参数

m: mode_t

std.os.linux.S.ISGID

常量

第 6890 行

std.os.linux.S.ISLNK

函数

第 6925 行

pub fn ISLNK(m: mode_t) bool

参数

m: mode_t

std.os.linux.S.ISREG

函数

第 6905 行

pub fn ISREG(m: mode_t) bool

参数

m: mode_t

std.os.linux.S.ISSOCK

函数

第 6929 行

pub fn ISSOCK(m: mode_t) bool

参数

m: mode_t

std.os.linux.S.ISUID

常量

第 6889 行

std.os.linux.S.ISVTX

常量

第 6891 行

std.os.linux.S.IWGRP

常量

第 6897 行

std.os.linux.S.IWOTH

常量

第 6901 行

std.os.linux.S.IWUSR

常量

第 6893 行

std.os.linux.S.IXGRP

常量

第 6898 行

std.os.linux.S.IXOTH

常量

第 6902 行

std.os.linux.S.IXUSR

常量

第 6894 行

std.os.linux.SA

类型

第 4702 行

std.os.linux.sa_family_t

类型

第 7068 行

std.os.linux.SA.NOCLDSTOP

常量

第 4703 行

std.os.linux.SA.NOCLDSTOP

常量

第 4711 行

std.os.linux.SA.NOCLDSTOP

常量

第 4720 行

std.os.linux.SA.NOCLDSTOP

常量

第 4730 行

std.os.linux.SA.NOCLDSTOP

常量

第 4736 行

std.os.linux.SA.NOCLDWAIT

常量

第 4704 行

std.os.linux.SA.NOCLDWAIT

常量

第 4712 行

std.os.linux.SA.NOCLDWAIT

常量

第 4721 行

std.os.linux.SA.NOCLDWAIT

常量

第 4733 行

std.os.linux.SA.NOCLDWAIT

常量

第 4737 行

std.os.linux.SA.NODEFER

常量

第 4709 行

std.os.linux.SA.NODEFER

常量

第 4717 行

std.os.linux.SA.NODEFER

常量

第 4726 行

std.os.linux.SA.NODEFER

常量

第 4731 行

std.os.linux.SA.NODEFER

常量

第 4742 行

std.os.linux.SA.ONSTACK

常量

第 4708 行

std.os.linux.SA.ONSTACK

常量

第 4716 行

std.os.linux.SA.ONSTACK

常量

第 4725 行

std.os.linux.SA.ONSTACK

常量

第 4728 行

std.os.linux.SA.ONSTACK

常量

第 4741 行

std.os.linux.SA.RESETHAND

常量

第 4707 行

std.os.linux.SA.RESETHAND

常量

第 4715 行

std.os.linux.SA.RESETHAND

常量

第 4724 行

std.os.linux.SA.RESETHAND

常量

第 4732 行

std.os.linux.SA.RESETHAND

常量

第 4740 行

std.os.linux.SA.RESTART

常量

第 4706 行

std.os.linux.SA.RESTART

常量

第 4714 行

std.os.linux.SA.RESTART

常量

第 4723 行

std.os.linux.SA.RESTART

常量

第 4729 行

std.os.linux.SA.RESTART

常量

第 4739 行

std.os.linux.SA.RESTORER

常量

第 4718 行

std.os.linux.SA.RESTORER

常量

第 4743 行

std.os.linux.SA.SIGINFO

常量

第 4705 行

std.os.linux.SA.SIGINFO

常量

第 4713 行

std.os.linux.SA.SIGINFO

常量

第 4722 行

std.os.linux.SA.SIGINFO

常量

第 4734 行

std.os.linux.SA.SIGINFO

常量

第 4738 行

std.os.linux.SC

常量

第 107 行

std.os.linux.SCHED

容器

第 2996 行

字段

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

设为 true,以阻止子项继承策略

_31: u1 = 0

std.os.linux.sched_attr

容器

第 3046 行

字段

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

函数

第 3034 行

pub fn sched_get_priority_max(policy: SCHED) usize

参数

policy: SCHED

std.os.linux.sched_get_priority_min

函数

第 3038 行

pub fn sched_get_priority_min(policy: SCHED) usize

参数

policy: SCHED

std.os.linux.sched_getaffinity

函数

第 3074 行

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

参数

pid: pid_t
size: u32
set: *cpu_set_t

std.os.linux.sched_getattr

函数

第 3062 行

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

参数

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

std.os.linux.sched_getparam

函数

第 3022 行

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

参数

pid: pid_t
param: *sched_param

std.os.linux.sched_getscheduler

函数

第 3030 行

pub fn sched_getscheduler(pid: pid_t) usize

参数

pid: pid_t

std.os.linux.sched_param

容器

第 2992 行

字段

priority: i32

std.os.linux.sched_rr_get_interval

函数

第 3066 行

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

参数

pid: pid_t
tp: *timespec

std.os.linux.sched_setaffinity

函数

第 3081 行

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

参数

pid: pid_t
set: *const cpu_set_t

std.os.linux.sched_setattr

函数

第 3058 行

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

参数

pid: pid_t
attr: *const sched_attr
flags: u32

std.os.linux.sched_setparam

函数

第 3018 行

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

参数

pid: pid_t
param: *const sched_param

std.os.linux.sched_setscheduler

函数

第 3026 行

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

参数

pid: pid_t
policy: SCHED
param: *const sched_param

std.os.linux.sched_yield

函数

第 3070 行

pub fn sched_yield() usize

std.os.linux.SCHED.Mode

容器

第 2997 行

字段

NORMAL = 0

常规多用户调度

FIFO = 1

FIFO 实时调度

RR = 2

轮转实时调度

BATCH = 3

用于“批量”执行进程

IDLE = 5

低延迟调度

DEADLINE = 6

零星任务模型的截止时间调度

std.os.linux.SCM

命名空间

第 5571 行

std.os.linux.SCM.CREDENTIALS

常量

第 5574 行

std.os.linux.SCM.PIDFD

常量

第 5576 行

std.os.linux.SCM.RIGHTS

常量

第 5573 行

std.os.linux.SCM.SECURITY

常量

第 5575 行

std.os.linux.SCM.TIMESTAMPING_OPT_STATS

常量

第 5579 行

std.os.linux.SCM.TIMESTAMPING_PKTINFO

常量

第 5580 行

std.os.linux.SCM.TXTIME

常量

第 5581 行

std.os.linux.SCM.WIFI_STATUS

常量

第 5578 行

std.os.linux.SECBIT_KEEP_CAPS

常量

第 9887 行

std.os.linux.SECBIT_KEEP_CAPS_LOCKED

常量

第 9888 行

std.os.linux.SECBIT_NO_CAP_AMBIENT_RAISE

常量

第 9893 行

std.os.linux.SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED

常量

第 9894 行

std.os.linux.SECBIT_NO_SETUID_FIXUP

常量

第 9881 行

std.os.linux.SECBIT_NO_SETUID_FIXUP_LOCKED

常量

第 9882 行

std.os.linux.SECBIT_NOROOT

常量

第 9875 行

std.os.linux.SECBIT_NOROOT_LOCKED

常量

第 9876 行

std.os.linux.seccomp

函数

第 3424 行

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

参数

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

std.os.linux.SECCOMP

别名

第 129 行

别名目标 std.os.linux.seccomp

std.os.linux.SECURE_ALL_BITS

常量

第 9896 行

std.os.linux.SECURE_ALL_LOCKS

常量

第 9900 行

std.os.linux.SECURE_KEEP_CAPS

常量

第 9884 行

std.os.linux.SECURE_KEEP_CAPS_LOCKED

常量

第 9885 行

std.os.linux.SECURE_NO_CAP_AMBIENT_RAISE

常量

第 9890 行

std.os.linux.SECURE_NO_CAP_AMBIENT_RAISE_LOCKED

常量

第 9891 行

std.os.linux.SECURE_NO_SETUID_FIXUP

常量

第 9878 行

std.os.linux.SECURE_NO_SETUID_FIXUP_LOCKED

常量

第 9879 行

std.os.linux.SECURE_NOROOT

常量

第 9872 行

std.os.linux.SECURE_NOROOT_LOCKED

常量

第 9873 行

std.os.linux.SECUREBITS_DEFAULT

常量

第 9870 行

std.os.linux.SEEK

命名空间

第 4982 行

std.os.linux.SEEK.CUR

常量

第 4984 行

std.os.linux.SEEK.END

常量

第 4985 行

std.os.linux.SEEK.SET

常量

第 4983 行

std.os.linux.sendfile

函数

第 2902 行

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

参数

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

std.os.linux.sendmmsg

函数

第 2828 行

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

参数

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

std.os.linux.sendmsg

函数

第 2820 行

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

参数

fd: fd_t
msg: *const msghdr_const
flags: u32

std.os.linux.sendto

函数

第 2895 行

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

参数

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

std.os.linux.SER

命名空间

第 6506 行

std.os.linux.SER.ISO7816

命名空间

第 6518 行

std.os.linux.SER.ISO7816.ENABLED

常量

第 6519 行

std.os.linux.SER.ISO7816.T

函数

第 6522 行

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

std.os.linux.SER.ISO7816.T_PARAM

常量

第 6520 行

std.os.linux.SER.RS485

命名空间

第 6507 行

std.os.linux.SER.RS485.ADDR_DEST

常量

第 6515 行

std.os.linux.SER.RS485.ADDR_RECV

常量

第 6514 行

std.os.linux.SER.RS485.ADDRB

常量

第 6513 行

std.os.linux.SER.RS485.ENABLED

常量

第 6508 行

std.os.linux.SER.RS485.RTS_AFTER_SEND

常量

第 6510 行

std.os.linux.SER.RS485.RTS_ON_SEND

常量

第 6509 行

std.os.linux.SER.RS485.RX_DURING_TX

常量

第 6511 行

std.os.linux.SER.RS485.TERMINATE_BUS

常量

第 6512 行

std.os.linux.serial_iso7816

容器

第 6497 行

字段

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

std.os.linux.serial_rs485

容器

第 6482 行

字段

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

函数

第 2026 行

此调用不会失败,返回值为调用方的线程 ID

pub fn set_tid_address(tidptr: ?*pid_t) pid_t

参数

tidptr: ?*pid_t

std.os.linux.setegid

函数

第 2582 行

pub fn setegid(egid: gid_t) usize

参数

egid: gid_t

std.os.linux.seteuid

函数

第 2571 行

pub fn seteuid(euid: uid_t) usize

参数

euid: uid_t

std.os.linux.setgid

函数

第 2515 行

pub fn setgid(gid: gid_t) usize

参数

gid: gid_t

std.os.linux.setgroups

函数

第 2641 行

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

参数

size: usize
list: [*]const gid_t

std.os.linux.setitimer

函数

第 3165 行

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

参数

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

std.os.linux.setns

函数

第 3173 行

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

参数

fd: fd_t
flags: u32

std.os.linux.setpgid

函数

第 2625 行

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

参数

pid: pid_t
pgid: pid_t

std.os.linux.setregid

函数

第 2531 行

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

参数

rgid: gid_t
egid: gid_t

std.os.linux.setresgid

函数

第 2617 行

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

参数

rgid: gid_t
egid: gid_t
sgid: gid_t

std.os.linux.setresuid

函数

第 2609 行

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

参数

ruid: uid_t
euid: uid_t
suid: uid_t

std.os.linux.setreuid

函数

第 2523 行

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

参数

ruid: uid_t
euid: uid_t

std.os.linux.setrlimit

函数

第 3282 行

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

参数

resource: rlimit_resource
rlim: *const rlimit

std.os.linux.setsid

函数

第 2649 行

pub fn setsid() usize

std.os.linux.setsockopt

函数

第 2806 行

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

参数

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

std.os.linux.settimeofday

函数

第 2491 行

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

参数

tv: *const timeval
tz: *const timezone

std.os.linux.setuid

函数

第 2507 行

pub fn setuid(uid: uid_t) usize

参数

uid: uid_t

std.os.linux.setxattr

函数

第 2968 行

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

参数

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

std.os.linux.SFD

命名空间

第 7037 行

std.os.linux.SFD.CLOEXEC

常量

第 7038 行

std.os.linux.SFD.NONBLOCK

常量

第 7039 行

std.os.linux.sgttyb

类型

第 8954 行

std.os.linux.SHADOW_STACK

命名空间

第 11212 行

std.os.linux.SHADOW_STACK.SET_TOKEN

常量

第 11214 行

在影子栈中设置恢复令牌。

u64

std.os.linux.SHUT

命名空间

第 4988 行

std.os.linux.SHUT.RD

常量

第 4989 行

std.os.linux.SHUT.RDWR

常量

第 4991 行

std.os.linux.SHUT.WR

常量

第 4990 行

std.os.linux.shutdown

函数

第 2874 行

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

参数

fd: fd_t
how: i32

std.os.linux.SIG

类型

第 4746 行

std.os.linux.SIG.BLOCK

常量

第 4747 行

std.os.linux.SIG.BLOCK

常量

第 4792 行

std.os.linux.SIG.BLOCK

常量

第 4838 行

std.os.linux.SIG.BLOCK

常量

第 4883 行

std.os.linux.SIG.BLOCK

常量

第 4927 行

std.os.linux.SIG.CLD

常量

第 4801 行

SIG

std.os.linux.SIG.DFL

常量

第 4752 行

?Sigaction.handler_fn

std.os.linux.SIG.DFL

常量

第 4797 行

?Sigaction.handler_fn

std.os.linux.SIG.DFL

常量

第 4843 行

?Sigaction.handler_fn

std.os.linux.SIG.DFL

常量

第 4888 行

?Sigaction.handler_fn

std.os.linux.SIG.DFL

常量

第 4932 行

?Sigaction.handler_fn

std.os.linux.SIG.ERR

常量

第 4751 行

?Sigaction.handler_fn

std.os.linux.SIG.ERR

常量

第 4796 行

?Sigaction.handler_fn

std.os.linux.SIG.ERR

常量

第 4842 行

?Sigaction.handler_fn

std.os.linux.SIG.ERR

常量

第 4887 行

?Sigaction.handler_fn

std.os.linux.SIG.ERR

常量

第 4931 行

?Sigaction.handler_fn

std.os.linux.SIG.IGN

常量

第 4753 行

?Sigaction.handler_fn

std.os.linux.SIG.IGN

常量

第 4798 行

?Sigaction.handler_fn

std.os.linux.SIG.IGN

常量

第 4844 行

?Sigaction.handler_fn

std.os.linux.SIG.IGN

常量

第 4889 行

?Sigaction.handler_fn

std.os.linux.SIG.IGN

常量

第 4933 行

?Sigaction.handler_fn

std.os.linux.SIG.IOT

常量

第 4755 行

SIG

std.os.linux.SIG.IOT

常量

第 4800 行

SIG

std.os.linux.SIG.IOT

常量

第 4848 行

SIG

std.os.linux.SIG.IOT

常量

第 4892 行

SIG

std.os.linux.SIG.IOT

常量

第 4936 行

SIG

std.os.linux.SIG.POLL

常量

第 4756 行

SIG

std.os.linux.SIG.POLL

常量

第 4803 行

SIG

std.os.linux.SIG.POLL

常量

第 4846 行

SIG

std.os.linux.SIG.POLL

常量

第 4891 行

SIG

std.os.linux.SIG.POLL

常量

第 4935 行

SIG

std.os.linux.SIG.PWR

常量

第 4802 行

SIG

std.os.linux.SIG.PWR

常量

第 4847 行

SIG

std.os.linux.SIG.SETMASK

常量

第 4749 行

std.os.linux.SIG.SETMASK

常量

第 4794 行

std.os.linux.SIG.SETMASK

常量

第 4840 行

std.os.linux.SIG.SETMASK

常量

第 4885 行

std.os.linux.SIG.SETMASK

常量

第 4929 行

std.os.linux.SIG.UNBLOCK

常量

第 4748 行

std.os.linux.SIG.UNBLOCK

常量

第 4793 行

std.os.linux.SIG.UNBLOCK

常量

第 4839 行

std.os.linux.SIG.UNBLOCK

常量

第 4884 行

std.os.linux.SIG.UNBLOCK

常量

第 4928 行

std.os.linux.sigaction

函数

第 2676 行

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

参数

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

std.os.linux.Sigaction

容器

第 7021 行

用于实际 ABI k_sigaction 的内核 Sigaction 包装器。 Zig 的 linux.zig 包装库仍会对 sigaction() 调用 进行一些预处理,以添加 restorer 字段。

从 sigaction 改名为 Sigaction,避免与系统调用冲突。

字段

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

类型

第 7022 行

std.os.linux.Sigaction.sigaction_fn

类型

第 7023 行

std.os.linux.sigaddset

函数

第 2770 行

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

参数

set: *sigset_t
sig: SIG

std.os.linux.sigaltstack

函数

第 3185 行

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

参数

ss: ?*const stack_t
old_ss: ?*stack_t

std.os.linux.sigdelset

函数

第 2775 行

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

参数

set: *sigset_t
sig: SIG

std.os.linux.sigemptyset

函数

第 2751 行

Zig 版 sigemptyset。返回已初始化的 sigset_t。

pub fn sigemptyset() sigset_t

std.os.linux.sigfillset

函数

第 2756 行

Zig 版本的 sigfillset。返回已初始化的 sigset_t。

pub fn sigfillset() sigset_t

std.os.linux.siginfo_fields_union

容器

第 7430 行

字段

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

类型

第 7484 行

std.os.linux.sigismember

函数

第 2780 行

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

参数

set: *const sigset_t
sig: SIG

std.os.linux.signalfd

函数

第 3237 行

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

参数

fd: fd_t
mask: *const sigset_t
flags: u32

std.os.linux.signalfd_siginfo

容器

第 7042 行

字段

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

函数

第 2672 行

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

参数

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

std.os.linux.sigrtmax

函数

第 2746 行

Zig 的 SIGRTMAX,但为兼容 glibc 而采用函数形式

pub fn sigrtmax() u8

std.os.linux.sigrtmin

函数

第 2738 行

Zig 的 SIGRTMIN,但为兼容 glibc,采用函数形式。

pub fn sigrtmin() u8

std.os.linux.sigset_bit_index

类型函数

第 2760 行

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

参数

sig: SIG

std.os.linux.sigset_len

常量

第 2735 行

std.os.linux.sigset_t

类型

第 2731 行

Linux 内核的 sigset_t。多数 架构上逻辑位宽为 64 位,但 MIPS 上为 128 位。 与 glibc 和 musl 库 ABI 导出的 1024 位 sigset_t 不同。

std.os.linux.SigsetElement

类型

第 2733 行

std.os.linux.SIGSTKSZ

常量

第 7363 行

std.os.linux.sigval

容器

第 7425 行

字段

int: i32
ptr: *anyopaque

std.os.linux.SIOCADDDLCI

常量

第 9233 行

创建新的 DLCI 设备

std.os.linux.SIOCADDMULTI

常量

第 9147 行

添加到多播地址列表

std.os.linux.SIOCADDRT

常量

第 9059 行

添加路由表项

std.os.linux.SIOCBONDCHANGEACTIVE

常量

第 9261 行

更新为新的活动从属设备

std.os.linux.SIOCBONDENSLAVE

常量

第 9246 行

将设备加入 bond 成为从设备

std.os.linux.SIOCBONDINFOQUERY

常量

第 9258 行

返回绑定状态信息

std.os.linux.SIOCBONDRELEASE

常量

第 9249 行

从绑定中释放从属接口

std.os.linux.SIOCBONDSETHWADDR

常量

第 9252 行

设置绑定的硬件地址

std.os.linux.SIOCBONDSLAVEINFOQUERY

常量

第 9255 行

返回从设备状态信息

std.os.linux.SIOCBRADDBR

常量

第 9265 行

创建新的网桥设备

std.os.linux.SIOCBRADDIF

常量

第 9271 行

将接口添加到网桥

std.os.linux.SIOCBRDELBR

常量

第 9268 行

移除网桥设备

std.os.linux.SIOCBRDELIF

常量

第 9274 行

从网桥移除接口

std.os.linux.SIOCDARP

常量

第 9206 行

删除 ARP 表条目

std.os.linux.SIOCDELDLCI

常量

第 9236 行

删除 DLCI 设备

std.os.linux.SIOCDELMULTI

常量

第 9150 行

从多播地址列表中删除

std.os.linux.SIOCDELRT

常量

第 9062 行

删除路由表条目

std.os.linux.SIOCDEVPRIVATE

常量

第 9283 行

设备私有 ioctl 调用

std.os.linux.SIOCDIFADDR

常量

第 9162 行

删除 PA 地址

std.os.linux.SIOCDRARP

常量

第 9216 行

删除 RARP 表条目

std.os.linux.SIOCETHTOOL

常量

第 9183 行

Ethtool 接口

std.os.linux.SIOCGARP

常量

第 9209 行

获取 ARP 表条目

std.os.linux.SIOCGHWTSTAMP

常量

第 9280 行

设置硬件时间戳配置

std.os.linux.SIOCGIFADDR

常量

第 9084 行

获取 PA 地址

std.os.linux.SIOCGIFBR

常量

第 9171 行

桥接支持

std.os.linux.SIOCGIFBRDADDR

常量

第 9096 行

获取广播 PA 地址

std.os.linux.SIOCGIFCONF

常量

第 9075 行

获取接口列表

std.os.linux.SIOCGIFCOUNT

常量

第 9168 行

获取设备数量

std.os.linux.SIOCGIFDSTADDR

常量

第 9090 行

获取远程 PA 地址

std.os.linux.SIOCGIFENCAP

常量

第 9132 行

获取封装方式

std.os.linux.SIOCGIFFLAGS

常量

第 9078 行

获取标志

std.os.linux.SIOCGIFHWADDR

常量

第 9138 行

获取硬件地址

std.os.linux.SIOCGIFINDEX

常量

第 9153 行

name -> if_index 映射

std.os.linux.SIOCGIFMAP

常量

第 9226 行

获取设备参数

std.os.linux.SIOCGIFMEM

常量

第 9114 行

获取内存地址(BSD)

std.os.linux.SIOCGIFMETRIC

常量

第 9108 行

获取度量值

std.os.linux.SIOCGIFMTU

常量

第 9120 行

获取 MTU 大小

std.os.linux.SIOCGIFNAME

常量

第 9069 行

获取接口名称

std.os.linux.SIOCGIFNETMASK

常量

第 9102 行

获取网络 PA 掩码

std.os.linux.SIOCGIFPFLAGS

常量

第 9159 行

获取已设置的扩展标志

std.os.linux.SIOCGIFSLAVE

常量

第 9141 行

驱动程序从属关系支持

std.os.linux.SIOCGIFTXQLEN

常量

第 9177 行

获取发送队列长度

std.os.linux.SIOCGIFVLAN

常量

第 9239 行

802.1Q VLAN 支持

std.os.linux.SIOCGMIIPHY

常量

第 9186 行

获取当前使用的 MII PHY 地址。

std.os.linux.SIOCGMIIREG

常量

第 9189 行

读取 MII PHY 寄存器。

std.os.linux.SIOCGRARP

常量

第 9219 行

获取 RARP 表条目

std.os.linux.SIOCGSKNS

常量

第 9201 行

获取套接字的网络命名空间

std.os.linux.SIOCGSTAMP

常量

第 9049 行

获取时间戳(timeval)

std.os.linux.SIOCGSTAMP_NEW

常量

第 9045 行

std.os.linux.SIOCGSTAMP_OLD

常量

第 9046 行

std.os.linux.SIOCGSTAMPNS

常量

第 9055 行

获取时间戳(timespec)

std.os.linux.SIOCGSTAMPNS_NEW

常量

第 9051 行

std.os.linux.SIOCGSTAMPNS_OLD

常量

第 9052 行

std.os.linux.SIOCINQ

常量

第 9037 行

Linux 专用套接字 ioctl

std.os.linux.SIOCOUTQ

常量

第 9041 行

Linux 专用套接字 ioctl。 输出队列大小(未发送 + 未确认)。

std.os.linux.SIOCOUTQNSD

常量

第 9198 行

输出队列大小(不仅包括尚未发送的内容)

std.os.linux.SIOCPROTOPRIVATE

常量

第 9286 行

这 16 个 ioctl 调用为协议私有

std.os.linux.SIOCRTMSG

常量

第 9065 行

未使用

std.os.linux.SIOCSARP

常量

第 9212 行

设置 ARP 表项

std.os.linux.SIOCSHWTSTAMP

常量

第 9277 行

获取硬件时间戳配置

std.os.linux.SIOCSIFADDR

常量

第 9087 行

设置 PA 地址

std.os.linux.SIOCSIFBR

常量

第 9174 行

设置桥接选项

std.os.linux.SIOCSIFBRDADDR

常量

第 9099 行

设置广播 PA 地址

std.os.linux.SIOCSIFDSTADDR

常量

第 9093 行

设置远端 PA 地址

std.os.linux.SIOCSIFENCAP

常量

第 9135 行

设置封装

std.os.linux.SIOCSIFFLAGS

常量

第 9081 行

设置标志

std.os.linux.SIOCSIFHWADDR

常量

第 9129 行

设置硬件地址

std.os.linux.SIOCSIFHWBROADCAST

常量

第 9165 行

设置硬件广播地址

std.os.linux.SIOCSIFLINK

常量

第 9072 行

设置接口通道

std.os.linux.SIOCSIFMAP

常量

第 9229 行

设置设备参数

std.os.linux.SIOCSIFMEM

常量

第 9117 行

设置内存地址(BSD)

std.os.linux.SIOCSIFMETRIC

常量

第 9111 行

设置度量值

std.os.linux.SIOCSIFMTU

常量

第 9123 行

设置 MTU 大小

std.os.linux.SIOCSIFNAME

常量

第 9126 行

设置接口名称

std.os.linux.SIOCSIFNETMASK

常量

第 9105 行

设置网络 PA 掩码

std.os.linux.SIOCSIFPFLAGS

常量

第 9156 行

设置扩展标志集

std.os.linux.SIOCSIFSLAVE

常量

第 9144 行

驱动程序从属关系支持

std.os.linux.SIOCSIFTXQLEN

常量

第 9180 行

设置发送队列长度

std.os.linux.SIOCSIFVLAN

常量

第 9242 行

设置 802.1Q VLAN 选项

std.os.linux.SIOCSMIIREG

常量

第 9192 行

写入 MII PHY 寄存器。

std.os.linux.SIOCSRARP

常量

第 9222 行

设置 RARP 表项

std.os.linux.SIOCWANDEV

常量

第 9195 行

获取/设置网络设备参数

std.os.linux.SO

类型

第 5222 行

std.os.linux.SO.ACCEPTCONN

常量

第 5239 行

std.os.linux.SO.ACCEPTCONN

常量

第 5313 行

std.os.linux.SO.ACCEPTCONN

常量

第 5382 行

std.os.linux.SO.ACCEPTCONN

常量

第 5447 行

std.os.linux.SO.ACCEPTCONN

常量

第 5522 行

std.os.linux.SO.ATTACH_BPF

常量

第 5273 行

std.os.linux.SO.ATTACH_BPF

常量

第 5342 行

std.os.linux.SO.ATTACH_BPF

常量

第 5411 行

std.os.linux.SO.ATTACH_BPF

常量

第 5482 行

std.os.linux.SO.ATTACH_BPF

常量

第 5551 行

std.os.linux.SO.ATTACH_FILTER

常量

第 5254 行

std.os.linux.SO.ATTACH_FILTER

常量

第 5323 行

std.os.linux.SO.ATTACH_FILTER

常量

第 5392 行

std.os.linux.SO.ATTACH_FILTER

常量

第 5463 行

std.os.linux.SO.ATTACH_FILTER

常量

第 5532 行

std.os.linux.SO.ATTACH_REUSEPORT_CBPF

常量

第 5275 行

std.os.linux.SO.ATTACH_REUSEPORT_CBPF

常量

第 5344 行

std.os.linux.SO.ATTACH_REUSEPORT_CBPF

常量

第 5413 行

std.os.linux.SO.ATTACH_REUSEPORT_CBPF

常量

第 5484 行

std.os.linux.SO.ATTACH_REUSEPORT_CBPF

常量

第 5553 行

std.os.linux.SO.ATTACH_REUSEPORT_EBPF

常量

第 5276 行

std.os.linux.SO.ATTACH_REUSEPORT_EBPF

常量

第 5345 行

std.os.linux.SO.ATTACH_REUSEPORT_EBPF

常量

第 5414 行

std.os.linux.SO.ATTACH_REUSEPORT_EBPF

常量

第 5485 行

std.os.linux.SO.ATTACH_REUSEPORT_EBPF

常量

第 5554 行

std.os.linux.SO.BINDTODEVICE

常量

第 5253 行

std.os.linux.SO.BINDTODEVICE

常量

第 5322 行

std.os.linux.SO.BINDTODEVICE

常量

第 5391 行

std.os.linux.SO.BINDTODEVICE

常量

第 5462 行

std.os.linux.SO.BINDTODEVICE

常量

第 5531 行

std.os.linux.SO.BINDTOIFINDEX

常量

第 5284 行

std.os.linux.SO.BINDTOIFINDEX

常量

第 5353 行

std.os.linux.SO.BINDTOIFINDEX

常量

第 5422 行

std.os.linux.SO.BINDTOIFINDEX

常量

第 5493 行

std.os.linux.SO.BINDTOIFINDEX

常量

第 5562 行

std.os.linux.SO.BPF_EXTENSIONS

常量

第 5271 行

std.os.linux.SO.BPF_EXTENSIONS

常量

第 5340 行

std.os.linux.SO.BPF_EXTENSIONS

常量

第 5409 行

std.os.linux.SO.BPF_EXTENSIONS

常量

第 5480 行

std.os.linux.SO.BPF_EXTENSIONS

常量

第 5549 行

std.os.linux.SO.BROADCAST

常量

第 5227 行

std.os.linux.SO.BROADCAST

常量

第 5297 行

std.os.linux.SO.BROADCAST

常量

第 5366 行

std.os.linux.SO.BROADCAST

常量

第 5434 行

std.os.linux.SO.BROADCAST

常量

第 5506 行

std.os.linux.SO.BSDCOMPAT

常量

第 5244 行

std.os.linux.SO.BSDCOMPAT

常量

第 5305 行

std.os.linux.SO.BSDCOMPAT

常量

第 5374 行

std.os.linux.SO.BSDCOMPAT

常量

第 5453 行

std.os.linux.SO.BSDCOMPAT

常量

第 5514 行

std.os.linux.SO.BUSY_POLL

常量

第 5269 行

std.os.linux.SO.BUSY_POLL

常量

第 5338 行

std.os.linux.SO.BUSY_POLL

常量

第 5407 行

std.os.linux.SO.BUSY_POLL

常量

第 5478 行

std.os.linux.SO.BUSY_POLL

常量

第 5547 行

std.os.linux.SO.CNX_ADVICE

常量

第 5277 行

std.os.linux.SO.CNX_ADVICE

常量

第 5346 行

std.os.linux.SO.CNX_ADVICE

常量

第 5415 行

std.os.linux.SO.CNX_ADVICE

常量

第 5486 行

std.os.linux.SO.CNX_ADVICE

常量

第 5555 行

std.os.linux.SO.COOKIE

常量

第 5280 行

std.os.linux.SO.COOKIE

常量

第 5349 行

std.os.linux.SO.COOKIE

常量

第 5418 行

std.os.linux.SO.COOKIE

常量

第 5489 行

std.os.linux.SO.COOKIE

常量

第 5558 行

std.os.linux.SO.DEBUG

常量

第 5223 行

std.os.linux.SO.DEBUG

常量

第 5292 行

std.os.linux.SO.DEBUG

常量

第 5361 行

std.os.linux.SO.DEBUG

常量

第 5430 行

std.os.linux.SO.DEBUG

常量

第 5501 行

std.os.linux.SO.DETACH_BPF

别名

第 5274 行

别名目标 std.os.linux.SO.DETACH_FILTER

std.os.linux.SO.DETACH_BPF

别名

第 5343 行

别名目标 std.os.linux.SO.DETACH_FILTER

std.os.linux.SO.DETACH_BPF

常量

第 5412 行

std.os.linux.SO.DETACH_BPF

别名

第 5483 行

别名目标 std.os.linux.SO.DETACH_FILTER

std.os.linux.SO.DETACH_BPF

别名

第 5552 行

别名目标 std.os.linux.SO.DETACH_FILTER

std.os.linux.SO.DETACH_FILTER

常量

第 5255 行

std.os.linux.SO.DETACH_FILTER

常量

第 5324 行

std.os.linux.SO.DETACH_FILTER

常量

第 5393 行

std.os.linux.SO.DETACH_FILTER

常量

第 5464 行

std.os.linux.SO.DETACH_FILTER

常量

第 5533 行

std.os.linux.SO.DETACH_REUSEPORT_BPF

常量

第 5290 行

std.os.linux.SO.DETACH_REUSEPORT_BPF

常量

第 5359 行

std.os.linux.SO.DETACH_REUSEPORT_BPF

常量

第 5428 行

std.os.linux.SO.DETACH_REUSEPORT_BPF

常量

第 5499 行

std.os.linux.SO.DETACH_REUSEPORT_BPF

常量

第 5568 行

std.os.linux.SO.DOMAIN

常量

第 5241 行

std.os.linux.SO.DOMAIN

常量

第 5318 行

std.os.linux.SO.DOMAIN

常量

第 5387 行

std.os.linux.SO.DOMAIN

常量

第 5449 行

std.os.linux.SO.DOMAIN

常量

第 5527 行

std.os.linux.SO.DONTROUTE

常量

第 5226 行

std.os.linux.SO.DONTROUTE

常量

第 5296 行

std.os.linux.SO.DONTROUTE

常量

第 5365 行

std.os.linux.SO.DONTROUTE

常量

第 5433 行

std.os.linux.SO.DONTROUTE

常量

第 5505 行

std.os.linux.SO.ERROR

常量

第 5237 行

std.os.linux.SO.ERROR

常量

第 5295 行

std.os.linux.SO.ERROR

常量

第 5364 行

std.os.linux.SO.ERROR

常量

第 5445 行

std.os.linux.SO.ERROR

常量

第 5504 行

std.os.linux.SO.GET_FILTER

别名

第 5256 行

别名目标 std.os.linux.SO.ATTACH_FILTER

std.os.linux.SO.GET_FILTER

别名

第 5325 行

别名目标 std.os.linux.SO.ATTACH_FILTER

std.os.linux.SO.GET_FILTER

常量

第 5394 行

std.os.linux.SO.GET_FILTER

别名

第 5465 行

别名目标 std.os.linux.SO.ATTACH_FILTER

std.os.linux.SO.GET_FILTER

别名

第 5534 行

别名目标 std.os.linux.SO.ATTACH_FILTER

std.os.linux.SO.INCOMING_CPU

常量

第 5272 行

std.os.linux.SO.INCOMING_CPU

常量

第 5341 行

std.os.linux.SO.INCOMING_CPU

常量

第 5410 行

std.os.linux.SO.INCOMING_CPU

常量

第 5481 行

std.os.linux.SO.INCOMING_CPU

常量

第 5550 行

std.os.linux.SO.INCOMING_NAPI_ID

常量

第 5279 行

std.os.linux.SO.INCOMING_NAPI_ID

常量

第 5348 行

std.os.linux.SO.INCOMING_NAPI_ID

常量

第 5417 行

std.os.linux.SO.INCOMING_NAPI_ID

常量

第 5488 行

std.os.linux.SO.INCOMING_NAPI_ID

常量

第 5557 行

std.os.linux.SO.KEEPALIVE

常量

第 5225 行

std.os.linux.SO.KEEPALIVE

常量

第 5300 行

std.os.linux.SO.KEEPALIVE

常量

第 5369 行

std.os.linux.SO.KEEPALIVE

常量

第 5432 行

std.os.linux.SO.KEEPALIVE

常量

第 5509 行

std.os.linux.SO.LINGER

常量

第 5228 行

std.os.linux.SO.LINGER

常量

第 5304 行

std.os.linux.SO.LINGER

常量

第 5373 行

std.os.linux.SO.LINGER

常量

第 5435 行

std.os.linux.SO.LINGER

常量

第 5513 行

std.os.linux.SO.LOCK_FILTER

常量

第 5267 行

std.os.linux.SO.LOCK_FILTER

常量

第 5336 行

std.os.linux.SO.LOCK_FILTER

常量

第 5405 行

std.os.linux.SO.LOCK_FILTER

常量

第 5476 行

std.os.linux.SO.LOCK_FILTER

常量

第 5545 行

std.os.linux.SO.MARK

常量

第 5261 行

std.os.linux.SO.MARK

常量

第 5330 行

std.os.linux.SO.MARK

常量

第 5399 行

std.os.linux.SO.MARK

常量

第 5470 行

std.os.linux.SO.MARK

常量

第 5539 行

std.os.linux.SO.MAX_PACING_RATE

常量

第 5270 行

std.os.linux.SO.MAX_PACING_RATE

常量

第 5339 行

std.os.linux.SO.MAX_PACING_RATE

常量

第 5408 行

std.os.linux.SO.MAX_PACING_RATE

常量

第 5479 行

std.os.linux.SO.MAX_PACING_RATE

常量

第 5548 行

std.os.linux.SO.MEMINFO

常量

第 5278 行

std.os.linux.SO.MEMINFO

常量

第 5347 行

std.os.linux.SO.MEMINFO

常量

第 5416 行

std.os.linux.SO.MEMINFO

常量

第 5487 行

std.os.linux.SO.MEMINFO

常量

第 5556 行

std.os.linux.SO.NO_CHECK

常量

第 5242 行

std.os.linux.SO.NO_CHECK

常量

第 5302 行

std.os.linux.SO.NO_CHECK

常量

第 5371 行

std.os.linux.SO.NO_CHECK

常量

第 5451 行

std.os.linux.SO.NO_CHECK

常量

第 5511 行

std.os.linux.SO.NOFCS

常量

第 5266 行

std.os.linux.SO.NOFCS

常量

第 5335 行

std.os.linux.SO.NOFCS

常量

第 5404 行

std.os.linux.SO.NOFCS

常量

第 5475 行

std.os.linux.SO.NOFCS

常量

第 5544 行

std.os.linux.SO.OOBINLINE

常量

第 5229 行

std.os.linux.SO.OOBINLINE

常量

第 5301 行

std.os.linux.SO.OOBINLINE

常量

第 5370 行

std.os.linux.SO.OOBINLINE

常量

第 5436 行

std.os.linux.SO.OOBINLINE

常量

第 5510 行

std.os.linux.SO.PASSCRED

常量

第 5245 行

std.os.linux.SO.PASSCRED

常量

第 5311 行

std.os.linux.SO.PASSCRED

常量

第 5376 行

std.os.linux.SO.PASSCRED

常量

第 5454 行

std.os.linux.SO.PASSCRED

常量

第 5516 行

std.os.linux.SO.PASSSEC

常量

第 5259 行

std.os.linux.SO.PASSSEC

常量

第 5328 行

std.os.linux.SO.PASSSEC

常量

第 5397 行

std.os.linux.SO.PASSSEC

常量

第 5468 行

std.os.linux.SO.PASSSEC

常量

第 5537 行

std.os.linux.SO.PEEK_OFF

常量

第 5265 行

std.os.linux.SO.PEEK_OFF

常量

第 5334 行

std.os.linux.SO.PEEK_OFF

常量

第 5403 行

std.os.linux.SO.PEEK_OFF

常量

第 5474 行

std.os.linux.SO.PEEK_OFF

常量

第 5543 行

std.os.linux.SO.PEERCRED

常量

第 5246 行

std.os.linux.SO.PEERCRED

常量

第 5312 行

std.os.linux.SO.PEERCRED

常量

第 5377 行

std.os.linux.SO.PEERCRED

常量

第 5455 行

std.os.linux.SO.PEERCRED

常量

第 5517 行

std.os.linux.SO.PEERGROUPS

常量

第 5281 行

std.os.linux.SO.PEERGROUPS

常量

第 5350 行

std.os.linux.SO.PEERGROUPS

常量

第 5419 行

std.os.linux.SO.PEERGROUPS

常量

第 5490 行

std.os.linux.SO.PEERGROUPS

常量

第 5559 行

std.os.linux.SO.PEERNAME

常量

第 5257 行

std.os.linux.SO.PEERNAME

常量

第 5326 行

std.os.linux.SO.PEERNAME

常量

第 5395 行

std.os.linux.SO.PEERNAME

常量

第 5466 行

std.os.linux.SO.PEERNAME

常量

第 5535 行

std.os.linux.SO.PEERSEC

常量

第 5247 行

std.os.linux.SO.PEERSEC

常量

第 5314 行

std.os.linux.SO.PEERSEC

常量

第 5383 行

std.os.linux.SO.PEERSEC

常量

第 5456 行

std.os.linux.SO.PEERSEC

常量

第 5523 行

std.os.linux.SO.PRIORITY

常量

第 5243 行

std.os.linux.SO.PRIORITY

常量

第 5303 行

std.os.linux.SO.PRIORITY

常量

第 5372 行

std.os.linux.SO.PRIORITY

常量

第 5452 行

std.os.linux.SO.PRIORITY

常量

第 5512 行

std.os.linux.SO.PROTOCOL

常量

第 5240 行

std.os.linux.SO.PROTOCOL

常量

第 5317 行

std.os.linux.SO.PROTOCOL

常量

第 5386 行

std.os.linux.SO.PROTOCOL

常量

第 5448 行

std.os.linux.SO.PROTOCOL

常量

第 5526 行

std.os.linux.SO.RCVBUF

常量

第 5232 行

std.os.linux.SO.RCVBUF

常量

第 5299 行

std.os.linux.SO.RCVBUF

常量

第 5368 行

std.os.linux.SO.RCVBUF

常量

第 5440 行

std.os.linux.SO.RCVBUF

常量

第 5508 行

std.os.linux.SO.RCVBUFFORCE

常量

第 5249 行

std.os.linux.SO.RCVBUFFORCE

常量

第 5316 行

std.os.linux.SO.RCVBUFFORCE

常量

第 5385 行

std.os.linux.SO.RCVBUFFORCE

常量

第 5458 行

std.os.linux.SO.RCVBUFFORCE

常量

第 5525 行

std.os.linux.SO.RCVLOWAT

常量

第 5234 行

std.os.linux.SO.RCVLOWAT

常量

第 5307 行

std.os.linux.SO.RCVLOWAT

常量

第 5378 行

std.os.linux.SO.RCVLOWAT

常量

第 5442 行

std.os.linux.SO.RCVLOWAT

常量

第 5518 行

std.os.linux.SO.RCVTIMEO

常量

第 5235 行

std.os.linux.SO.RCVTIMEO

常量

第 5309 行

std.os.linux.SO.RCVTIMEO

常量

第 5380 行

std.os.linux.SO.RCVTIMEO

常量

第 5443 行

std.os.linux.SO.RCVTIMEO

常量

第 5520 行

std.os.linux.SO.RCVTIMEO_NEW

常量

第 5288 行

std.os.linux.SO.RCVTIMEO_NEW

常量

第 5357 行

std.os.linux.SO.RCVTIMEO_NEW

常量

第 5426 行

std.os.linux.SO.RCVTIMEO_NEW

常量

第 5497 行

std.os.linux.SO.RCVTIMEO_NEW

常量

第 5566 行

std.os.linux.SO.REUSEADDR

常量

第 5224 行

std.os.linux.SO.REUSEADDR

常量

第 5293 行

std.os.linux.SO.REUSEADDR

常量

第 5362 行

std.os.linux.SO.REUSEADDR

常量

第 5431 行

std.os.linux.SO.REUSEADDR

常量

第 5502 行

std.os.linux.SO.REUSEPORT

常量

第 5230 行

std.os.linux.SO.REUSEPORT

常量

第 5306 行

std.os.linux.SO.REUSEPORT

常量

第 5375 行

std.os.linux.SO.REUSEPORT

常量

第 5437 行

std.os.linux.SO.REUSEPORT

常量

第 5515 行

std.os.linux.SO.RXQ_OVFL

常量

第 5263 行

std.os.linux.SO.RXQ_OVFL

常量

第 5332 行

std.os.linux.SO.RXQ_OVFL

常量

第 5401 行

std.os.linux.SO.RXQ_OVFL

常量

第 5472 行

std.os.linux.SO.RXQ_OVFL

常量

第 5541 行

std.os.linux.SO.SECURITY_AUTHENTICATION

常量

第 5250 行

std.os.linux.SO.SECURITY_AUTHENTICATION

常量

第 5319 行

std.os.linux.SO.SECURITY_AUTHENTICATION

常量

第 5388 行

std.os.linux.SO.SECURITY_AUTHENTICATION

常量

第 5459 行

std.os.linux.SO.SECURITY_AUTHENTICATION

常量

第 5528 行

std.os.linux.SO.SECURITY_ENCRYPTION_NETWORK

常量

第 5252 行

std.os.linux.SO.SECURITY_ENCRYPTION_NETWORK

常量

第 5321 行

std.os.linux.SO.SECURITY_ENCRYPTION_NETWORK

常量

第 5390 行

std.os.linux.SO.SECURITY_ENCRYPTION_NETWORK

常量

第 5461 行

std.os.linux.SO.SECURITY_ENCRYPTION_NETWORK

常量

第 5530 行

std.os.linux.SO.SECURITY_ENCRYPTION_TRANSPORT

常量

第 5251 行

std.os.linux.SO.SECURITY_ENCRYPTION_TRANSPORT

常量

第 5320 行

std.os.linux.SO.SECURITY_ENCRYPTION_TRANSPORT

常量

第 5389 行

std.os.linux.SO.SECURITY_ENCRYPTION_TRANSPORT

常量

第 5460 行

std.os.linux.SO.SECURITY_ENCRYPTION_TRANSPORT

常量

第 5529 行

std.os.linux.SO.SELECT_ERR_QUEUE

常量

第 5268 行

std.os.linux.SO.SELECT_ERR_QUEUE

常量

第 5337 行

std.os.linux.SO.SELECT_ERR_QUEUE

常量

第 5406 行

std.os.linux.SO.SELECT_ERR_QUEUE

常量

第 5477 行

std.os.linux.SO.SELECT_ERR_QUEUE

常量

第 5546 行

std.os.linux.SO.SNDBUF

常量

第 5231 行

std.os.linux.SO.SNDBUF

常量

第 5298 行

std.os.linux.SO.SNDBUF

常量

第 5367 行

std.os.linux.SO.SNDBUF

常量

第 5439 行

std.os.linux.SO.SNDBUF

常量

第 5507 行

std.os.linux.SO.SNDBUFFORCE

常量

第 5248 行

std.os.linux.SO.SNDBUFFORCE

常量

第 5315 行

std.os.linux.SO.SNDBUFFORCE

常量

第 5384 行

std.os.linux.SO.SNDBUFFORCE

常量

第 5457 行

std.os.linux.SO.SNDBUFFORCE

常量

第 5524 行

std.os.linux.SO.SNDLOWAT

常量

第 5233 行

std.os.linux.SO.SNDLOWAT

常量

第 5308 行

std.os.linux.SO.SNDLOWAT

常量

第 5379 行

std.os.linux.SO.SNDLOWAT

常量

第 5441 行

std.os.linux.SO.SNDLOWAT

常量

第 5519 行

std.os.linux.SO.SNDTIMEO

常量

第 5236 行

std.os.linux.SO.SNDTIMEO

常量

第 5310 行

std.os.linux.SO.SNDTIMEO

常量

第 5381 行

std.os.linux.SO.SNDTIMEO

常量

第 5444 行

std.os.linux.SO.SNDTIMEO

常量

第 5521 行

std.os.linux.SO.SNDTIMEO_NEW

常量

第 5289 行

std.os.linux.SO.SNDTIMEO_NEW

常量

第 5358 行

std.os.linux.SO.SNDTIMEO_NEW

常量

第 5427 行

std.os.linux.SO.SNDTIMEO_NEW

常量

第 5498 行

std.os.linux.SO.SNDTIMEO_NEW

常量

第 5567 行

std.os.linux.SO.TIMESTAMP_NEW

常量

第 5285 行

std.os.linux.SO.TIMESTAMP_NEW

常量

第 5354 行

std.os.linux.SO.TIMESTAMP_NEW

常量

第 5423 行

std.os.linux.SO.TIMESTAMP_NEW

常量

第 5494 行

std.os.linux.SO.TIMESTAMP_NEW

常量

第 5563 行

std.os.linux.SO.TIMESTAMP_OLD

常量

第 5258 行

std.os.linux.SO.TIMESTAMP_OLD

常量

第 5327 行

std.os.linux.SO.TIMESTAMP_OLD

常量

第 5396 行

std.os.linux.SO.TIMESTAMP_OLD

常量

第 5467 行

std.os.linux.SO.TIMESTAMP_OLD

常量

第 5536 行

std.os.linux.SO.TIMESTAMPING_NEW

常量

第 5287 行

std.os.linux.SO.TIMESTAMPING_NEW

常量

第 5356 行

std.os.linux.SO.TIMESTAMPING_NEW

常量

第 5425 行

std.os.linux.SO.TIMESTAMPING_NEW

常量

第 5496 行

std.os.linux.SO.TIMESTAMPING_NEW

常量

第 5565 行

std.os.linux.SO.TIMESTAMPING_OLD

常量

第 5262 行

std.os.linux.SO.TIMESTAMPING_OLD

常量

第 5331 行

std.os.linux.SO.TIMESTAMPING_OLD

常量

第 5400 行

std.os.linux.SO.TIMESTAMPING_OLD

常量

第 5471 行

std.os.linux.SO.TIMESTAMPING_OLD

常量

第 5540 行

std.os.linux.SO.TIMESTAMPNS_NEW

常量

第 5286 行

std.os.linux.SO.TIMESTAMPNS_NEW

常量

第 5355 行

std.os.linux.SO.TIMESTAMPNS_NEW

常量

第 5424 行

std.os.linux.SO.TIMESTAMPNS_NEW

常量

第 5495 行

std.os.linux.SO.TIMESTAMPNS_NEW

常量

第 5564 行

std.os.linux.SO.TIMESTAMPNS_OLD

常量

第 5260 行

std.os.linux.SO.TIMESTAMPNS_OLD

常量

第 5329 行

std.os.linux.SO.TIMESTAMPNS_OLD

常量

第 5398 行

std.os.linux.SO.TIMESTAMPNS_OLD

常量

第 5469 行

std.os.linux.SO.TIMESTAMPNS_OLD

常量

第 5538 行

std.os.linux.SO.TXTIME

常量

第 5283 行

std.os.linux.SO.TXTIME

常量

第 5352 行

std.os.linux.SO.TXTIME

常量

第 5421 行

std.os.linux.SO.TXTIME

常量

第 5492 行

std.os.linux.SO.TXTIME

常量

第 5561 行

std.os.linux.SO.TYPE

常量

第 5238 行

std.os.linux.SO.TYPE

常量

第 5294 行

std.os.linux.SO.TYPE

常量

第 5363 行

std.os.linux.SO.TYPE

常量

第 5446 行

std.os.linux.SO.TYPE

常量

第 5503 行

std.os.linux.SO.WIFI_STATUS

常量

第 5264 行

std.os.linux.SO.WIFI_STATUS

常量

第 5333 行

std.os.linux.SO.WIFI_STATUS

常量

第 5402 行

std.os.linux.SO.WIFI_STATUS

常量

第 5473 行

std.os.linux.SO.WIFI_STATUS

常量

第 5542 行

std.os.linux.SO.ZEROCOPY

常量

第 5282 行

std.os.linux.SO.ZEROCOPY

常量

第 5351 行

std.os.linux.SO.ZEROCOPY

常量

第 5420 行

std.os.linux.SO.ZEROCOPY

常量

第 5491 行

std.os.linux.SO.ZEROCOPY

常量

第 5560 行

std.os.linux.SOCK

命名空间

第 4994 行

std.os.linux.SOCK_IOC_TYPE

常量

第 9043 行

std.os.linux.SOCK.CLOEXEC

常量

第 5002 行

std.os.linux.SOCK.DCCP

常量

第 5000 行

std.os.linux.SOCK.DGRAM

常量

第 4996 行

std.os.linux.SOCK.NONBLOCK

常量

第 5008 行

std.os.linux.SOCK.PACKET

常量

第 5001 行

std.os.linux.SOCK.RAW

常量

第 4997 行

std.os.linux.SOCK.RDM

常量

第 4998 行

std.os.linux.SOCK.SEQPACKET

常量

第 4999 行

std.os.linux.SOCK.STREAM

常量

第 4995 行

std.os.linux.sockaddr

容器

第 7071 行

字段

family: sa_family_t
data: [14]u8

std.os.linux.sockaddr.in

容器

第 7087 行

IPv4 套接字地址

字段

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

容器

第 7095 行

IPv6 套接字地址

字段

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

std.os.linux.sockaddr.ll

容器

第 7110 行

分组套接字地址

字段

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

std.os.linux.sockaddr.nl

容器

第 7121 行

Netlink 套接字地址

字段

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

端口 ID

groups: u32

多播组掩码

std.os.linux.sockaddr.SS_MAXSIZE

常量

第 7075 行

std.os.linux.sockaddr.storage

容器

第 7076 行

字段

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

std.os.linux.sockaddr.un

容器

第 7104 行

UNIX 域套接字地址

字段

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

std.os.linux.sockaddr.vm

容器

第 7141 行

vSockets 的地址结构

字段

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

此结构的总大小应与 struct sockaddr 完全相同。

std.os.linux.sockaddr.xdp

容器

第 7132 行

字段

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

std.os.linux.socket

函数

第 2799 行

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

参数

domain: u32
socket_type: u32
protocol: u32

std.os.linux.socket_t

别名

第 120 行

别名目标 std.os.linux.fd_t

std.os.linux.socketcall

常量

第 80 行

std.os.linux.socketpair

函数

第 2912 行

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

参数

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

std.os.linux.socklen_t

类型

第 7069 行

std.os.linux.SOL

命名空间

第 5584 行

std.os.linux.SOL.AAL

常量

第 5599 行

std.os.linux.SOL.ALG

常量

第 5613 行

std.os.linux.SOL.ATM

常量

第 5598 行

std.os.linux.SOL.BLUETOOTH

常量

第 5608 行

std.os.linux.SOL.CAIF

常量

第 5612 行

std.os.linux.SOL.DCCP

常量

第 5603 行

std.os.linux.SOL.DECNET

常量

第 5595 行

std.os.linux.SOL.ICMPV6

常量

第 5592 行

std.os.linux.SOL.IP

常量

第 5590 行

std.os.linux.SOL.IPV6

常量

第 5591 行

std.os.linux.SOL.IRDA

常量

第 5600 行

std.os.linux.SOL.IUCV

常量

第 5611 行

std.os.linux.SOL.KCM

常量

第 5615 行

std.os.linux.SOL.LLC

常量

第 5602 行

std.os.linux.SOL.NETBEUI

常量

第 5601 行

std.os.linux.SOL.NETLINK

常量

第 5604 行

std.os.linux.SOL.NFC

常量

第 5614 行

std.os.linux.SOL.PACKET

常量

第 5597 行

std.os.linux.SOL.PNPIPE

常量

第 5609 行

std.os.linux.SOL.PPPOL2TP

常量

第 5607 行

std.os.linux.SOL.RAW

常量

第 5594 行

std.os.linux.SOL.RDS

常量

第 5610 行

std.os.linux.SOL.RXRPC

常量

第 5606 行

std.os.linux.SOL.SOCKET

常量

第 5585 行

std.os.linux.SOL.TIPC

常量

第 5605 行

std.os.linux.SOL.TLS

常量

第 5616 行

std.os.linux.SOL.X25

常量

第 5596 行

std.os.linux.SOL.XDP

常量

第 5617 行

std.os.linux.SOMAXCONN

常量

第 5620 行

std.os.linux.speed_t

类型

第 8518 行

std.os.linux.speed_t.EXTA

常量

第 8552 行

std.os.linux.speed_t.EXTA

常量

第 8588 行

std.os.linux.speed_t.EXTA

常量

第 8624 行

std.os.linux.speed_t.EXTB

常量

第 8553 行

std.os.linux.speed_t.EXTB

常量

第 8589 行

std.os.linux.speed_t.EXTB

常量

第 8625 行

std.os.linux.splitValue64

函数

第 1027 行

fn splitValue64(val: i64) [2]u32

参数

val: i64

std.os.linux.splitValueBE64

函数

第 1020 行

fn splitValueBE64(val: i64) [2]u32

参数

val: i64

std.os.linux.splitValueLE64

函数

第 1013 行

fn splitValueLE64(val: i64) [2]u32

参数

val: i64

std.os.linux.SS

命名空间

第 7405 行

std.os.linux.SS.AUTODISARM

常量

第 7408 行

std.os.linux.SS.DISABLE

常量

第 7407 行

std.os.linux.SS.ONSTACK

常量

第 7406 行

std.os.linux.stack_t

类型

第 7411 行

std.os.linux.statx

函数

第 2933 行

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

参数

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

std.os.linux.Statx

容器

第 8259 行

重命名为 Statx,以避免与 statx 函数冲突。

字段

mask: STATX

指示已填充字段的位掩码。根据内核实际返回的 信息更新。调用者必须检查此字段,因为支持情况 随内核版本和文件系统而异。

blksize: u32

文件系统 I/O 的块大小。

attributes: STATX_ATTR

额外文件属性指示符。

nlink: u32

硬链接数量。

uid: uid_t

所有者的用户标识。

gid: gid_t

所有者的组 ID。

mode: u16

文件类型和模式。

__spare0: u16
ino: u64

inode 编号。

size: u64

总大小,单位为字节。

blocks: u64

已分配的 512B 块数。

attributes_mask: STATX_ATTR

用于显示 attributes 中受支持项目的掩码。

atime: statx_timestamp

文件的最后访问时间戳。

btime: statx_timestamp

文件创建时间戳。

ctime: statx_timestamp

文件最后一次状态更改时间戳。

mtime: statx_timestamp

文件最后修改时间戳。

rdev_major: u32

若此文件表示设备,则为主设备号。

rdev_minor: u32

若此文件表示设备,则为次设备号。

dev_major: u32

包含此文件所在文件系统的设备的主设备号。

dev_minor: u32

包含此文件所在文件系统的设备的次设备号。

mnt_id: u64

挂载 ID

dio_mem_align: u32

直接输入输出所需的内存缓冲区对齐。

dio_offset_align: u32

直接输入输出所需的文件偏移量对齐。

subvol: u64

子卷标识符。

atomic_write_unit_min: u32

最小原子写入单位,单位为字节。

atomic_write_unit_max: u32

最大原子写入单元,单位为字节。

atomic_write_segments_max: u32

原子写入的最大分段数。

dio_read_offset_align: u32

直接 I/O 读取的文件偏移对齐要求。

atomic_write_unit_max_opt: u32

优化后的最大原子写入单元,单位为字节。

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

std.os.linux.STATX

容器

第 8173 行

字段

TYPE: bool = false

需要 mode & S.IFMT。

MODE: bool = false

需要 mode & ~S.IFMT。

NLINK: bool = false

需要 nlink 成员。

UID: bool = false

需要 uid 成员。

GID: bool = false

需要 gid 成员。

ATIME: bool = false

需要 atime 成员。

MTIME: bool = false

需要 mtime 成员。

CTIME: bool = false

需要 ctime 成员。

INO: bool = false

需要 ino 成员。

SIZE: bool = false

需要 size 成员。

BLOCKS: bool = false

需要 blocks 成员。

BTIME: bool = false

需要 btime 成员。

MNT_ID: bool = false

需要 mnt_id 成员。

DIOALIGN: bool = false

需要 dio_mem_align 和 dio_offset_align 成员。

MNT_ID_UNIQUE: bool = false

请求 stx_mnt_id 成员。

SUBVOL: bool = false

需要 sub 成员。

WRITE_ATOMIC: bool = false

需要 atomic_write_unit_min、atomic_write_unit_max 和 atomic_write_segments_max 成员。

DIO_READ_ALIGN: bool = false

需要 dio_read_offset_align 成员。

__pad: u13 = 0
__RESERVED: bool = false

保留供将来扩展;不得设置。

std.os.linux.STATX_ATTR

容器

第 8222 行

以位掩码形式表示文件状态或特征的属性。 标有 [I] 的标志在语义上对应 FS_IOC_SETFLAGS 的值。 更多信息参见 FS_IOC_SETFLAGS(2const)。

字段

__pad1: u3 = 0
COMPRESSED: bool = false

[I] 文件被文件系统压缩。

__pad2: u1 = 0
IMMUTABLE: bool = false

[I] 文件被标记为不可变。

APPEND: bool = false

[I] 文件仅允许追加。

NODUMP: bool = false

[I] 不应转储此文件。

ENCRYPTED: bool = false

[I] 文件系统中此文件需要密钥才能解密。

AUTOMOUNT: bool = false

文件所命名的目录会触发自动挂载。

MOUNT_ROOT: bool = false

文件指向挂载点的根。

VERITY: bool = false

[I] 文件受 dm-verity 设备保护。

DAX: bool = false

文件当前处于 CPU 直接访问状态。 不对应某些文件系统支持的逐 inode DAX 标志。

WRITE_ATOMIC: bool = false

文件支持原子写操作。

__pad3: u50 = 0

std.os.linux.statx_timestamp

容器

第 8249 行

字段

sec: i64

相对于 1970-01-01T00:00:00Z 前后相差的秒数。

nsec: u32

sec 之后的纳秒数(0..999,999,999)。

__pad1: u32

std.os.linux.STATX.BASIC_STATS

常量

第 8215 行

STATX

std.os.linux.std

别名

第 6 行

别名目标 std

std.os.linux.STDERR_FILENO

常量

第 4477 行

std.os.linux.STDIN_FILENO

常量

第 4475 行

std.os.linux.STDOUT_FILENO

常量

第 4476 行

std.os.linux.symlink

函数

第 1864 行

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

参数

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

std.os.linux.symlinkat

函数

第 1872 行

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

参数

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

std.os.linux.sync

函数

第 3257 行

pub fn sync() void

std.os.linux.syncfs

函数

第 3261 行

pub fn syncfs(fd: fd_t) usize

参数

fd: fd_t

std.os.linux.SYS

类型

第 132 行

std.os.linux.sys_riscv_hwprobe

函数

第 3568 行

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

参数

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

std.os.linux.syscall_arg_t

常量

第 69 行

std.os.linux.syscall_bits

类型

第 67 行

std.os.linux.syscall_fork

常量

第 82 行

std.os.linux.syscall_lseek

常量

第 83 行

std.os.linux.syscall_pipe

常量

第 81 行

std.os.linux.syscall0

常量

第 70 行

std.os.linux.syscall1

常量

第 71 行

std.os.linux.syscall2

常量

第 72 行

std.os.linux.syscall3

常量

第 73 行

std.os.linux.syscall4

常量

第 74 行

std.os.linux.syscall5

常量

第 75 行

std.os.linux.syscall6

常量

第 76 行

std.os.linux.syscall7

常量

第 77 行

std.os.linux.syscalls

别名

第 131 行

别名目标 std.os.linux.syscalls

std.os.linux.sysinfo

函数

第 3542 行

pub fn sysinfo(info: *Sysinfo) usize

参数

info: *Sysinfo

std.os.linux.Sysinfo

类型

第 3481 行

std.os.linux.T

类型

第 6079 行

std.os.linux.T.CFLSH

常量

第 6087 行

std.os.linux.T.CFLSH

常量

第 6202 行

std.os.linux.T.CFLSH

常量

第 6298 行

std.os.linux.T.CFLSH

常量

第 6390 行

std.os.linux.T.CGETA

常量

第 6080 行

std.os.linux.T.CGETA

常量

第 6195 行

std.os.linux.T.CGETA

常量

第 6292 行

std.os.linux.T.CGETA

常量

第 6384 行

std.os.linux.T.CGETS

常量

第 6089 行

std.os.linux.T.CGETS

常量

第 6190 行

std.os.linux.T.CGETS

常量

第 6299 行

std.os.linux.T.CGETS

常量

第 6380 行

std.os.linux.T.CGETS2

常量

第 6139 行

std.os.linux.T.CGETS2

常量

第 6303 行

std.os.linux.T.CGETS2

常量

第 6421 行

std.os.linux.T.CGETX

常量

第 6430 行

std.os.linux.T.CSBRK

常量

第 6085 行

std.os.linux.T.CSBRK

常量

第 6200 行

std.os.linux.T.CSBRK

常量

第 6296 行

std.os.linux.T.CSBRK

常量

第 6388 行

std.os.linux.T.CSBRKP

常量

第 6163 行

std.os.linux.T.CSBRKP

常量

第 6258 行

std.os.linux.T.CSBRKP

常量

第 6358 行

std.os.linux.T.CSBRKP

常量

第 6417 行

std.os.linux.T.CSETA

常量

第 6081 行

std.os.linux.T.CSETA

常量

第 6196 行

std.os.linux.T.CSETA

常量

第 6293 行

std.os.linux.T.CSETA

常量

第 6385 行

std.os.linux.T.CSETAF

常量

第 6083 行

std.os.linux.T.CSETAF

常量

第 6198 行

std.os.linux.T.CSETAF

常量

第 6295 行

std.os.linux.T.CSETAF

常量

第 6387 行

std.os.linux.T.CSETAW

常量

第 6082 行

std.os.linux.T.CSETAW

常量

第 6197 行

std.os.linux.T.CSETAW

常量

第 6294 行

std.os.linux.T.CSETAW

常量

第 6386 行

std.os.linux.T.CSETS

常量

第 6090 行

std.os.linux.T.CSETS

常量

第 6191 行

std.os.linux.T.CSETS

常量

第 6300 行

std.os.linux.T.CSETS

常量

第 6381 行

std.os.linux.T.CSETS2

常量

第 6140 行

std.os.linux.T.CSETS2

常量

第 6304 行

std.os.linux.T.CSETS2

常量

第 6422 行

std.os.linux.T.CSETSF

常量

第 6092 行

std.os.linux.T.CSETSF

常量

第 6193 行

std.os.linux.T.CSETSF

常量

第 6302 行

std.os.linux.T.CSETSF

常量

第 6383 行

std.os.linux.T.CSETSF2

常量

第 6142 行

std.os.linux.T.CSETSF2

常量

第 6306 行

std.os.linux.T.CSETSF2

常量

第 6424 行

std.os.linux.T.CSETSW

常量

第 6091 行

std.os.linux.T.CSETSW

常量

第 6192 行

std.os.linux.T.CSETSW

常量

第 6301 行

std.os.linux.T.CSETSW

常量

第 6382 行

std.os.linux.T.CSETSW2

常量

第 6141 行

std.os.linux.T.CSETSW2

常量

第 6305 行

std.os.linux.T.CSETSW2

常量

第 6423 行

std.os.linux.T.CSETX

常量

第 6431 行

std.os.linux.T.CSETXF

常量

第 6432 行

std.os.linux.T.CSETXW

常量

第 6433 行

std.os.linux.T.CXONC

常量

第 6086 行

std.os.linux.T.CXONC

常量

第 6201 行

std.os.linux.T.CXONC

常量

第 6297 行

std.os.linux.T.CXONC

常量

第 6389 行

std.os.linux.T.FIOASYNC

常量

第 6119 行

std.os.linux.T.FIOASYNC

常量

第 6178 行

std.os.linux.T.FIOASYNC

常量

第 6349 行

std.os.linux.T.FIOASYNC

常量

第 6445 行

std.os.linux.T.FIOCLEX

常量

第 6117 行

std.os.linux.T.FIOCLEX

常量

第 6176 行

std.os.linux.T.FIOCLEX

常量

第 6347 行

std.os.linux.T.FIOCLEX

常量

第 6444 行

std.os.linux.T.FIONBIO

常量

第 6120 行

std.os.linux.T.FIONBIO

常量

第 6179 行

std.os.linux.T.FIONBIO

常量

第 6350 行

std.os.linux.T.FIONBIO

常量

第 6413 行

std.os.linux.T.FIONCLEX

常量

第 6118 行

std.os.linux.T.FIONCLEX

常量

第 6177 行

std.os.linux.T.FIONCLEX

常量

第 6348 行

std.os.linux.T.FIONCLEX

常量

第 6443 行

std.os.linux.T.FIONREAD

常量

第 6129 行

std.os.linux.T.FIONREAD

常量

第 6180 行

std.os.linux.T.FIONREAD

常量

第 6351 行

std.os.linux.T.FIONREAD

常量

第 6406 行

std.os.linux.T.FIOQSIZE

常量

第 6121 行

std.os.linux.T.FIOQSIZE

常量

第 6182 行

std.os.linux.T.FIOQSIZE

常量

第 6353 行

std.os.linux.T.FIOQSIZE

常量

第 6459 行

std.os.linux.T.IOCCBRK

常量

第 6137 行

std.os.linux.T.IOCCBRK

常量

第 6260 行

std.os.linux.T.IOCCBRK

常量

第 6336 行

std.os.linux.T.IOCCBRK

常量

第 6419 行

std.os.linux.T.IOCCONS

常量

第 6127 行

std.os.linux.T.IOCCONS

常量

第 6242 行

std.os.linux.T.IOCCONS

常量

第 6321 行

std.os.linux.T.IOCCONS

常量

第 6409 行

std.os.linux.T.IOCEXCL

常量

第 6094 行

std.os.linux.T.IOCEXCL

常量

第 6215 行

std.os.linux.T.IOCEXCL

常量

第 6319 行

std.os.linux.T.IOCEXCL

常量

第 6391 行

std.os.linux.T.IOCGDEV

常量

第 6147 行

std.os.linux.T.IOCGDEV

常量

第 6266 行

std.os.linux.T.IOCGDEV

常量

第 6307 行

std.os.linux.T.IOCGDEV

常量

第 6429 行

std.os.linux.T.IOCGETC

常量

第 6189 行

std.os.linux.T.IOCGETD

常量

第 6115 行

std.os.linux.T.IOCGETD

常量

第 6257 行

std.os.linux.T.IOCGETD

常量

第 6317 行

std.os.linux.T.IOCGETD

常量

第 6416 行

std.os.linux.T.IOCGETP

常量

第 6132 行

std.os.linux.T.IOCGETP

常量

第 6184 行

std.os.linux.T.IOCGEXCL

常量

第 6152 行

std.os.linux.T.IOCGEXCL

常量

第 6271 行

std.os.linux.T.IOCGEXCL

常量

第 6311 行

std.os.linux.T.IOCGEXCL

常量

第 6438 行

std.os.linux.T.IOCGICOUNT

常量

第 6174 行

std.os.linux.T.IOCGICOUNT

常量

第 6288 行

std.os.linux.T.IOCGICOUNT

常量

第 6369 行

std.os.linux.T.IOCGICOUNT

常量

第 6457 行

std.os.linux.T.IOCGISO7816

常量

第 6154 行

std.os.linux.T.IOCGISO7816

常量

第 6273 行

std.os.linux.T.IOCGISO7816

常量

第 6314 行

std.os.linux.T.IOCGISO7816

常量

第 6440 行

std.os.linux.T.IOCGLCKTRMIOS

常量

第 6167 行

std.os.linux.T.IOCGLCKTRMIOS

常量

第 6279 行

std.os.linux.T.IOCGLCKTRMIOS

常量

第 6362 行

std.os.linux.T.IOCGLCKTRMIOS

常量

第 6449 行

std.os.linux.T.IOCGLTC

常量

第 6123 行

std.os.linux.T.IOCGLTC

常量

第 6210 行

std.os.linux.T.IOCGPGRP

常量

第 6126 行

std.os.linux.T.IOCGPGRP

常量

第 6213 行

std.os.linux.T.IOCGPGRP

常量

第 6339 行

std.os.linux.T.IOCGPGRP

常量

第 6394 行

std.os.linux.T.IOCGPKT

常量

第 6150 行

std.os.linux.T.IOCGPKT

常量

第 6269 行

std.os.linux.T.IOCGPKT

常量

第 6309 行

std.os.linux.T.IOCGPKT

常量

第 6436 行

std.os.linux.T.IOCGPTLCK

常量

第 6151 行

std.os.linux.T.IOCGPTLCK

常量

第 6270 行

std.os.linux.T.IOCGPTLCK

常量

第 6310 行

std.os.linux.T.IOCGPTLCK

常量

第 6437 行

std.os.linux.T.IOCGPTN

常量

第 6145 行

std.os.linux.T.IOCGPTN

常量

第 6264 行

std.os.linux.T.IOCGPTN

常量

第 6342 行

std.os.linux.T.IOCGPTN

常量

第 6427 行

std.os.linux.T.IOCGPTPEER

常量

第 6153 行

std.os.linux.T.IOCGPTPEER

常量

第 6272 行

std.os.linux.T.IOCGPTPEER

常量

第 6345 行

std.os.linux.T.IOCGPTPEER

常量

第 6439 行

std.os.linux.T.IOCGRS485

常量

第 6143 行

std.os.linux.T.IOCGRS485

常量

第 6262 行

std.os.linux.T.IOCGRS485

常量

第 6312 行

std.os.linux.T.IOCGRS485

常量

第 6425 行

std.os.linux.T.IOCGSERIAL

常量

第 6161 行

std.os.linux.T.IOCGSERIAL

常量

第 6243 行

std.os.linux.T.IOCGSERIAL

常量

第 6356 行

std.os.linux.T.IOCGSERIAL

常量

第 6410 行

std.os.linux.T.IOCGSID

常量

第 6138 行

std.os.linux.T.IOCGSID

常量

第 6261 行

std.os.linux.T.IOCGSID

常量

第 6341 行

std.os.linux.T.IOCGSID

常量

第 6420 行

std.os.linux.T.IOCGSOFTCAR

常量

第 6158 行

std.os.linux.T.IOCGSOFTCAR

常量

第 6239 行

std.os.linux.T.IOCGSOFTCAR

常量

第 6322 行

std.os.linux.T.IOCGSOFTCAR

常量

第 6404 行

std.os.linux.T.IOCGWINSZ

常量

第 6112 行

std.os.linux.T.IOCGWINSZ

常量

第 6205 行

std.os.linux.T.IOCGWINSZ

常量

第 6325 行

std.os.linux.T.IOCGWINSZ

常量

第 6398 行

std.os.linux.T.IOCINQ

别名

第 6130 行

别名目标 std.os.linux.T.FIONREAD

std.os.linux.T.IOCINQ

别名

第 6181 行

别名目标 std.os.linux.T.FIONREAD

std.os.linux.T.IOCINQ

别名

第 6352 行

别名目标 std.os.linux.T.FIONREAD

std.os.linux.T.IOCINQ

别名

第 6407 行

别名目标 std.os.linux.T.FIONREAD

std.os.linux.T.IOCLINUX

常量

第 6160 行

std.os.linux.T.IOCLINUX

常量

第 6241 行

std.os.linux.T.IOCLINUX

常量

第 6355 行

std.os.linux.T.IOCLINUX

常量

第 6408 行

std.os.linux.T.IOCM_CAR

常量

第 6230 行

std.os.linux.T.IOCM_CD

别名

第 6233 行

别名目标 std.os.linux.T.IOCM_CAR

std.os.linux.T.IOCM_CTS

常量

第 6229 行

std.os.linux.T.IOCM_DSR

常量

第 6232 行

std.os.linux.T.IOCM_DTR

常量

第 6225 行

std.os.linux.T.IOCM_LE

常量

第 6224 行

std.os.linux.T.IOCM_LOOP

常量

第 6237 行

std.os.linux.T.IOCM_OUT1

常量

第 6235 行

std.os.linux.T.IOCM_OUT2

常量

第 6236 行

std.os.linux.T.IOCM_RI

别名

第 6234 行

别名目标 std.os.linux.T.IOCM_RNG

std.os.linux.T.IOCM_RNG

常量

第 6231 行

std.os.linux.T.IOCM_RTS

常量

第 6226 行

std.os.linux.T.IOCM_SR

常量

第 6228 行

std.os.linux.T.IOCM_ST

常量

第 6227 行

std.os.linux.T.IOCMBIC

常量

第 6100 行

std.os.linux.T.IOCMBIC

常量

第 6222 行

std.os.linux.T.IOCMBIC

常量

第 6327 行

std.os.linux.T.IOCMBIC

常量

第 6402 行

std.os.linux.T.IOCMBIS

常量

第 6099 行

std.os.linux.T.IOCMBIS

常量

第 6221 行

std.os.linux.T.IOCMBIS

常量

第 6328 行

std.os.linux.T.IOCMBIS

常量

第 6401 行

std.os.linux.T.IOCMGET

常量

第 6098 行

std.os.linux.T.IOCMGET

常量

第 6220 行

std.os.linux.T.IOCMGET

常量

第 6326 行

std.os.linux.T.IOCMGET

常量

第 6400 行

std.os.linux.T.IOCMIWAIT

常量

第 6173 行

std.os.linux.T.IOCMIWAIT

常量

第 6287 行

std.os.linux.T.IOCMIWAIT

常量

第 6368 行

std.os.linux.T.IOCMIWAIT

常量

第 6456 行

std.os.linux.T.IOCMSET

常量

第 6101 行

std.os.linux.T.IOCMSET

常量

第 6223 行

std.os.linux.T.IOCMSET

常量

第 6329 行

std.os.linux.T.IOCMSET

常量

第 6403 行

std.os.linux.T.IOCNOTTY

常量

第 6113 行

std.os.linux.T.IOCNOTTY

常量

第 6255 行

std.os.linux.T.IOCNOTTY

常量

第 6333 行

std.os.linux.T.IOCNOTTY

常量

第 6414 行

std.os.linux.T.IOCNXCL

常量

第 6095 行

std.os.linux.T.IOCNXCL

常量

第 6216 行

std.os.linux.T.IOCNXCL

常量

第 6320 行

std.os.linux.T.IOCNXCL

常量

第 6392 行

std.os.linux.T.IOCOUTQ

常量

第 6096 行

std.os.linux.T.IOCOUTQ

常量

第 6208 行

std.os.linux.T.IOCOUTQ

常量

第 6335 行

std.os.linux.T.IOCOUTQ

常量

第 6396 行

std.os.linux.T.IOCPKT

常量

第 6102 行

std.os.linux.T.IOCPKT

常量

第 6245 行

std.os.linux.T.IOCPKT

常量

第 6332 行

std.os.linux.T.IOCPKT

常量

第 6412 行

std.os.linux.T.IOCPKT_DATA

常量

第 6103 行

std.os.linux.T.IOCPKT_DATA

常量

第 6246 行

std.os.linux.T.IOCPKT_DATA

常量

第 6371 行

std.os.linux.T.IOCPKT_DATA

常量

第 6470 行

std.os.linux.T.IOCPKT_DOSTOP

常量

第 6109 行

std.os.linux.T.IOCPKT_DOSTOP

常量

第 6252 行

std.os.linux.T.IOCPKT_DOSTOP

常量

第 6377 行

std.os.linux.T.IOCPKT_DOSTOP

常量

第 6476 行

std.os.linux.T.IOCPKT_FLUSHREAD

常量

第 6104 行

std.os.linux.T.IOCPKT_FLUSHREAD

常量

第 6247 行

std.os.linux.T.IOCPKT_FLUSHREAD

常量

第 6372 行

std.os.linux.T.IOCPKT_FLUSHREAD

常量

第 6471 行

std.os.linux.T.IOCPKT_FLUSHWRITE

常量

第 6105 行

std.os.linux.T.IOCPKT_FLUSHWRITE

常量

第 6248 行

std.os.linux.T.IOCPKT_FLUSHWRITE

常量

第 6373 行

std.os.linux.T.IOCPKT_FLUSHWRITE

常量

第 6472 行

std.os.linux.T.IOCPKT_IOCTL

常量

第 6110 行

std.os.linux.T.IOCPKT_IOCTL

常量

第 6253 行

std.os.linux.T.IOCPKT_IOCTL

常量

第 6378 行

std.os.linux.T.IOCPKT_IOCTL

常量

第 6477 行

std.os.linux.T.IOCPKT_NOSTOP

常量

第 6108 行

std.os.linux.T.IOCPKT_NOSTOP

常量

第 6251 行

std.os.linux.T.IOCPKT_NOSTOP

常量

第 6376 行

std.os.linux.T.IOCPKT_NOSTOP

常量

第 6475 行

std.os.linux.T.IOCPKT_START

常量

第 6107 行

std.os.linux.T.IOCPKT_START

常量

第 6250 行

std.os.linux.T.IOCPKT_START

常量

第 6375 行

std.os.linux.T.IOCPKT_START

常量

第 6474 行

std.os.linux.T.IOCPKT_STOP

常量

第 6106 行

std.os.linux.T.IOCPKT_STOP

常量

第 6249 行

std.os.linux.T.IOCPKT_STOP

常量

第 6374 行

std.os.linux.T.IOCPKT_STOP

常量

第 6473 行

std.os.linux.T.IOCSBRK

常量

第 6136 行

std.os.linux.T.IOCSBRK

常量

第 6259 行

std.os.linux.T.IOCSBRK

常量

第 6337 行

std.os.linux.T.IOCSBRK

常量

第 6418 行

std.os.linux.T.IOCSCTTY

常量

第 6157 行

std.os.linux.T.IOCSCTTY

常量

第 6217 行

std.os.linux.T.IOCSCTTY

常量

第 6340 行

std.os.linux.T.IOCSCTTY

常量

第 6393 行

std.os.linux.T.IOCSER_TEMT

常量

第 6283 行

std.os.linux.T.IOCSER_TEMT

常量

第 6479 行

std.os.linux.T.IOCSERCONFIG

常量

第 6164 行

std.os.linux.T.IOCSERCONFIG

常量

第 6276 行

std.os.linux.T.IOCSERCONFIG

常量

第 6359 行

std.os.linux.T.IOCSERCONFIG

常量

第 6446 行

std.os.linux.T.IOCSERGETLSR

常量

第 6170 行

std.os.linux.T.IOCSERGETLSR

常量

第 6282 行

std.os.linux.T.IOCSERGETLSR

常量

第 6365 行

std.os.linux.T.IOCSERGETLSR

常量

第 6452 行

std.os.linux.T.IOCSERGETMULTI

常量

第 6171 行

std.os.linux.T.IOCSERGETMULTI

常量

第 6284 行

std.os.linux.T.IOCSERGETMULTI

常量

第 6366 行

std.os.linux.T.IOCSERGETMULTI

常量

第 6453 行

std.os.linux.T.IOCSERGSTRUCT

常量

第 6169 行

std.os.linux.T.IOCSERGSTRUCT

常量

第 6281 行

std.os.linux.T.IOCSERGSTRUCT

常量

第 6364 行

std.os.linux.T.IOCSERGSTRUCT

常量

第 6451 行

std.os.linux.T.IOCSERGWILD

常量

第 6165 行

std.os.linux.T.IOCSERGWILD

常量

第 6277 行

std.os.linux.T.IOCSERGWILD

常量

第 6360 行

std.os.linux.T.IOCSERGWILD

常量

第 6447 行

std.os.linux.T.IOCSERSETMULTI

常量

第 6172 行

std.os.linux.T.IOCSERSETMULTI

常量

第 6285 行

std.os.linux.T.IOCSERSETMULTI

常量

第 6367 行

std.os.linux.T.IOCSERSETMULTI

常量

第 6454 行

std.os.linux.T.IOCSERSWILD

常量

第 6166 行

std.os.linux.T.IOCSERSWILD

常量

第 6278 行

std.os.linux.T.IOCSERSWILD

常量

第 6361 行

std.os.linux.T.IOCSERSWILD

常量

第 6448 行

std.os.linux.T.IOCSETC

常量

第 6188 行

std.os.linux.T.IOCSETD

常量

第 6114 行

std.os.linux.T.IOCSETD

常量

第 6256 行

std.os.linux.T.IOCSETD

常量

第 6318 行

std.os.linux.T.IOCSETD

常量

第 6415 行

std.os.linux.T.IOCSETN

常量

第 6134 行

std.os.linux.T.IOCSETN

常量

第 6186 行

std.os.linux.T.IOCSETP

常量

第 6133 行

std.os.linux.T.IOCSETP

常量

第 6185 行

std.os.linux.T.IOCSIG

常量

第 6148 行

std.os.linux.T.IOCSIG

常量

第 6267 行

std.os.linux.T.IOCSIG

常量

第 6344 行

std.os.linux.T.IOCSIG

常量

第 6434 行

std.os.linux.T.IOCSISO7816

常量

第 6155 行

std.os.linux.T.IOCSISO7816

常量

第 6274 行

std.os.linux.T.IOCSISO7816

常量

第 6315 行

std.os.linux.T.IOCSISO7816

常量

第 6441 行

std.os.linux.T.IOCSLCKTRMIOS

常量

第 6168 行

std.os.linux.T.IOCSLCKTRMIOS

常量

第 6280 行

std.os.linux.T.IOCSLCKTRMIOS

常量

第 6363 行

std.os.linux.T.IOCSLCKTRMIOS

常量

第 6450 行

std.os.linux.T.IOCSLTC

常量

第 6124 行

std.os.linux.T.IOCSLTC

常量

第 6211 行

std.os.linux.T.IOCSPGRP

常量

第 6125 行

std.os.linux.T.IOCSPGRP

常量

第 6212 行

std.os.linux.T.IOCSPGRP

常量

第 6338 行

std.os.linux.T.IOCSPGRP

常量

第 6395 行

std.os.linux.T.IOCSPTLCK

常量

第 6146 行

std.os.linux.T.IOCSPTLCK

常量

第 6265 行

std.os.linux.T.IOCSPTLCK

常量

第 6343 行

std.os.linux.T.IOCSPTLCK

常量

第 6428 行

std.os.linux.T.IOCSRS485

常量

第 6144 行

std.os.linux.T.IOCSRS485

常量

第 6263 行

std.os.linux.T.IOCSRS485

常量

第 6313 行

std.os.linux.T.IOCSRS485

常量

第 6426 行

std.os.linux.T.IOCSSERIAL

常量

第 6162 行

std.os.linux.T.IOCSSERIAL

常量

第 6244 行

std.os.linux.T.IOCSSERIAL

常量

第 6357 行

std.os.linux.T.IOCSSERIAL

常量

第 6411 行

std.os.linux.T.IOCSSOFTCAR

常量

第 6159 行

std.os.linux.T.IOCSSOFTCAR

常量

第 6240 行

std.os.linux.T.IOCSSOFTCAR

常量

第 6323 行

std.os.linux.T.IOCSSOFTCAR

常量

第 6405 行

std.os.linux.T.IOCSTART

常量

第 6206 行

std.os.linux.T.IOCSTART

常量

第 6330 行

std.os.linux.T.IOCSTI

常量

第 6097 行

std.os.linux.T.IOCSTI

常量

第 6219 行

std.os.linux.T.IOCSTI

常量

第 6334 行

std.os.linux.T.IOCSTI

常量

第 6397 行

std.os.linux.T.IOCSTOP

常量

第 6207 行

std.os.linux.T.IOCSTOP

常量

第 6331 行

std.os.linux.T.IOCSWINSZ

常量

第 6111 行

std.os.linux.T.IOCSWINSZ

常量

第 6204 行

std.os.linux.T.IOCSWINSZ

常量

第 6324 行

std.os.linux.T.IOCSWINSZ

常量

第 6399 行

std.os.linux.T.IOCVHANGUP

常量

第 6149 行

std.os.linux.T.IOCVHANGUP

常量

第 6268 行

std.os.linux.T.IOCVHANGUP

常量

第 6308 行

std.os.linux.T.IOCVHANGUP

常量

第 6435 行

std.os.linux.TABDLY

容器

第 8683 行

字段

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

std.os.linux.TABDLY.XTABS

常量

第 8689 行

std.os.linux.tc_cflag_t

类型

第 8766 行

std.os.linux.tc_iflag_t

类型

第 8630 行

std.os.linux.tc_lflag_t

类型

第 8794 行

std.os.linux.tc_oflag_t

类型

第 8707 行

std.os.linux.tcdrain

函数

第 3229 行

pub fn tcdrain(fd: fd_t) usize

参数

fd: fd_t

std.os.linux.tcflag_t

类型

第 8628 行

std.os.linux.tcgetattr

函数

第 3213 行

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

参数

fd: fd_t
termios_p: *termios

std.os.linux.tcgetpgrp

函数

第 3221 行

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

参数

fd: fd_t
pgrp: *pid_t

std.os.linux.tchars

类型

第 8962 行

std.os.linux.TCP

命名空间

第 5018 行

std.os.linux.tcp_fastopen_client_fail

容器

第 8409 行

从客户端角度解释 fastopen 失败的原因

字段

TFO_STATUS_UNSPEC

兜底分支

TFO_COOKIE_UNAVAILABLE

不处于 TFO_CLIENT_NO_COOKIE 模式时

TFO_DATA_NOT_ACKED

SYN-ACK 未确认 SYN 数据

TFO_SYN_RETRANSMITTED

超时后 SYN-ACK 仍未确认 SYN 数据

std.os.linux.tcp_repair_opt

容器

第 8388 行

字段

opt_code: u32
opt_val: u32

std.os.linux.tcp_repair_window

容器

第 8393 行

字段

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

std.os.linux.TCP.CC_INFO

常量

第 5064 行

获取拥塞控制信息(可选)

std.os.linux.TCP.CM_INQ

别名

第 5084 行

别名目标 std.os.linux.TCP.INQ

std.os.linux.TCP.CONGESTION

常量

第 5044 行

拥塞控制算法

std.os.linux.TCP.CORK

常量

第 5024 行

绝不发送尚未完整的段。

std.os.linux.TCP.DEFER_ACCEPT

常量

第 5036 行

仅在数据到达时唤醒监听者

std.os.linux.TCP.FASTOPEN

常量

第 5059 行

在监听套接字上启用 FastOpen

std.os.linux.TCP.FASTOPEN_CONNECT

常量

第 5072 行

在 connect 时尝试 FastOpen

std.os.linux.TCP.FASTOPEN_KEY

常量

第 5078 行

设置 Fast Open 的密钥(cookie)

std.os.linux.TCP.FASTOPEN_NO_COOKIE

常量

第 5080 行

无需 TFO cookie 即可启用 TFO

std.os.linux.TCP.INFO

常量

第 5040 行

此连接的信息。

std.os.linux.TCP.INQ

常量

第 5083 行

读取时,以 cmsg 通知可读取的字节数

std.os.linux.TCP.KEEPCNT

常量

第 5030 行

判定失效前的保活次数

std.os.linux.TCP.KEEPIDLE

常量

第 5026 行

在此时间段后启动保活,单位为秒

std.os.linux.TCP.KEEPINTVL

常量

第 5028 行

保活消息之间的间隔

std.os.linux.TCP.LINGER2

常量

第 5034 行

孤立 FIN-WAIT-2 状态的生存期

std.os.linux.TCP.MAXSEG

常量

第 5022 行

限制 MSS

std.os.linux.TCP.MD5SIG

常量

第 5046 行

TCP MD5 签名(RFC2385)

std.os.linux.TCP.MD5SIG_EXT

常量

第 5076 行

带扩展的 TCP MD5 签名

std.os.linux.TCP.NODELAY

常量

第 5020 行

禁用 Nagle 算法

std.os.linux.TCP.NOTSENT_LOWAT

常量

第 5062 行

限制写队列中未发送字节的数量

std.os.linux.TCP.QUEUE_SEQ

常量

第 5056 行

std.os.linux.TCP.QUICKACK

常量

第 5042 行

阻止或重新启用快速确认

std.os.linux.TCP.REPAIR

常量

第 5054 行

TCP 套接字当前正在修复

std.os.linux.TCP.REPAIR_OFF

常量

第 5089 行

std.os.linux.TCP.REPAIR_OFF_NO_WP

常量

第 5091 行

不使用窗口探测直接关闭

std.os.linux.TCP.REPAIR_ON

常量

第 5088 行

std.os.linux.TCP.REPAIR_OPTIONS

常量

第 5057 行

std.os.linux.TCP.REPAIR_QUEUE

常量

第 5055 行

std.os.linux.TCP.REPAIR_WINDOW

常量

第 5070 行

获取/设置窗口参数

std.os.linux.TCP.SAVE_SYN

常量

第 5066 行

记录新连接的 SYN 头

std.os.linux.TCP.SAVED_SYN

常量

第 5068 行

获取为连接记录的 SYN 头

std.os.linux.TCP.SYNCNT

常量

第 5032 行

SYN 重传次数

std.os.linux.TCP.THIN_DUPACK

常量

第 5050 行

收到 1 个重复确认后快速重传

std.os.linux.TCP.THIN_LINEAR_TIMEOUTS

常量

第 5048 行

对稀疏流使用线性超时

std.os.linux.TCP.TIMESTAMP

常量

第 5060 行

std.os.linux.TCP.TX_DELAY

常量

第 5086 行

将发出的数据包延迟 XX 微秒

std.os.linux.TCP.ULP

常量

第 5074 行

将 ULP 附加到 TCP 连接

std.os.linux.TCP.USER_TIMEOUT

常量

第 5052 行

丢失后重试直到超时的时长

std.os.linux.TCP.WINDOW_CLAMP

常量

第 5038 行

限制通告窗口

std.os.linux.TCP.ZEROCOPY_RECEIVE

常量

第 5081 行

std.os.linux.TCPI_OPT_ECN

常量

第 8425 行

ECN 已在 TCP 会话初始化时协商

std.os.linux.TCPI_OPT_ECN_SEEN

常量

第 8427 行

已接收到至少一个带 ECT 的数据包

std.os.linux.TCPI_OPT_SACK

常量

第 8422 行

std.os.linux.TCPI_OPT_SYN_DATA

常量

第 8429 行

SYN-ACK 已确认所发送或接收 SYN 中的数据

std.os.linux.TCPI_OPT_TIMESTAMPS

常量

第 8421 行

用于 TCP_INFO 套接字选项

std.os.linux.TCPI_OPT_WSCALE

常量

第 8423 行

std.os.linux.TcpRepairOption

容器

第 8401 行

字段

TCP_NO_QUEUE
TCP_RECV_QUEUE
TCP_SEND_QUEUE
TCP_QUEUES_NR

std.os.linux.TCSA

别名

第 8952 行

别名目标 std.posix.TCSA

std.os.linux.tcsetattr

函数

第 3217 行

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

参数

fd: fd_t
optional_action: TCSA
termios_p: *const termios

std.os.linux.tcsetpgrp

函数

第 3225 行

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

参数

fd: fd_t
pgrp: *const pid_t

std.os.linux.tee

函数

第 3471 行

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

参数

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

std.os.linux.termio

容器

第 8980 行

字段

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

类型

第 8989 行

std.os.linux.termios2

类型

第 9016 行

std.os.linux.TFD

类型

第 6940 行

std.os.linux.TFD_TIMER

容器

第 6934 行

字段

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

std.os.linux.TFD.TIMER

别名

第 6948 行

别名目标 std.os.linux.TFD_TIMER

std.os.linux.TFD.TIMER

别名

第 6957 行

别名目标 std.os.linux.TFD_TIMER

std.os.linux.TFD.TIMER

别名

第 6966 行

别名目标 std.os.linux.TFD_TIMER

std.os.linux.TFD.TIMER

别名

第 6975 行

别名目标 std.os.linux.TFD_TIMER

std.os.linux.tgkill

函数

第 2206 行

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

参数

tgid: pid_t
tid: pid_t
sig: SIG

std.os.linux.time_t

常量

第 124 行

std.os.linux.TIMER

容器

第 6597 行

字段

ABSTIME: bool
_: u31 = 0

std.os.linux.TIMERFD_CLOCK

别名

第 6587 行

别名目标 std.os.linux.timerfd_clockid_t

std.os.linux.timerfd_clockid_t

容器

第 6588 行

字段

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

std.os.linux.timerfd_create

函数

第 3123 行

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

参数

clockid: timerfd_clockid_t
flags: TFD

std.os.linux.timerfd_gettime

函数

第 3136 行

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

参数

fd: fd_t
curr_value: *itimerspec

std.os.linux.timerfd_settime

函数

第 3144 行

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

参数

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

std.os.linux.timespec

类型

第 9793 行

std.os.linux.timeval

容器

第 9754 行

字段

sec: isize
usec: i64

std.os.linux.timezone

容器

第 9759 行

字段

minuteswest: i32
dsttime: i32

std.os.linux.tkill

函数

第 2202 行

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

参数

tid: pid_t
sig: SIG

std.os.linux.tls

别名

第 126 行

别名目标 std.os.linux.tls

std.os.linux.TP_STATUS

容器

第 9404 行

字段

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

容器

第 9441 行

字段

std.os.linux.tpacket_bd_ts

容器

第 9396 行

字段

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

std.os.linux.tpacket_block_desc

容器

第 9445 行

字段

version: u32
offset_to_priv: u32
hdr: tpacket_bd_header_u

std.os.linux.tpacket_hdr_v1

容器

第 9431 行

字段

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

容器

第 9451 行

字段

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

std.os.linux.tpacket_req3

容器

第 9386 行

字段

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

容器

第 9473 行

字段

packets: c_uint
drops: c_uint
freeze_q_cnt: c_uint

std.os.linux.tpacket_versions

容器

第 9380 行

字段

V1 = 0
V2 = 1
V3 = 2

std.os.linux.tpacket3_hdr

容器

第 9458 行

字段

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

命名空间

第 5094 行

std.os.linux.UDP_ENCAP

命名空间

第 5109 行

std.os.linux.UDP_ENCAP.ESPINUDP

常量

第 5111 行

std.os.linux.UDP_ENCAP.ESPINUDP_NON_IKE

常量

第 5110 行

std.os.linux.UDP_ENCAP.GTP0

常量

第 5113 行

std.os.linux.UDP_ENCAP.GTP1U

常量

第 5114 行

std.os.linux.UDP_ENCAP.L2TPINUDP

常量

第 5112 行

std.os.linux.UDP_ENCAP.RXRPC

常量

第 5115 行

std.os.linux.UDP.CORK

常量

第 5096 行

绝不发送不完整的段

std.os.linux.UDP.ENCAP

常量

第 5098 行

将套接字设置为接收封装数据包

std.os.linux.UDP.GRO

常量

第 5106 行

此套接字可接收 UDP GRO 数据包

std.os.linux.UDP.NO_CHECK6_RX

常量

第 5102 行

禁止接收 UDP6 校验和

std.os.linux.UDP.NO_CHECK6_TX

常量

第 5100 行

禁用发送 UDP6X 校验和

std.os.linux.UDP.SEGMENT

常量

第 5104 行

设置 GSO 分段大小

std.os.linux.uid_t

类型

第 121 行

std.os.linux.umount

函数

第 1438 行

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

参数

special: [*:0]const u8

std.os.linux.UMOUNT_NOFOLLOW

常量

第 6692 行

std.os.linux.umount2

函数

第 1442 行

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

参数

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

std.os.linux.uname

函数

第 3189 行

pub fn uname(uts: *utsname) usize

参数

uts: *utsname

std.os.linux.unlink

函数

第 2240 行

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

参数

path: [*:0]const u8

std.os.linux.unlinkat

函数

第 2248 行

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

参数

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

std.os.linux.unshare

函数

第 3169 行

pub fn unshare(flags: usize) usize

参数

flags: usize

std.os.linux.use_kernel_timespec

常量

第 9789 行

std.os.linux.user_desc

常量

第 109 行

std.os.linux.UTIME

命名空间

第 9783 行

与 utimensat 和 futimens 配合使用。

std.os.linux.UTIME.NOW

常量

第 9784 行

timespec

std.os.linux.UTIME.OMIT

常量

第 9785 行

timespec

std.os.linux.utimensat

函数

第 1119 行

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

参数

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

std.os.linux.utsname

容器

第 8163 行

字段

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

类型

第 8878 行

termios 结构体中 cc 数组的索引。

std.os.linux.vdso

别名

第 11 行

别名目标 std.os.linux.vdso

std.os.linux.VDSO

常量

第 108 行

std.os.linux.vdso_clock_gettime

变量

第 2431 行

?VdsoClockGettime

std.os.linux.vdso_sys_riscv_hwprobe

变量

第 3553 行

?VdsoSysRiscvHwprobe

std.os.linux.VdsoClockGettime

类型

第 2430 行

std.os.linux.VdsoSysRiscvHwprobe

类型

第 3546 行

std.os.linux.vfs_cap_data

容器

第 7193 行

字段

magic_etc: u32
data: [VFS_CAP_U32]Data

std.os.linux.vfs_cap_data.Data

容器

第 7196 行

字段

permitted: u32
inheritable: u32

std.os.linux.VFS_CAP_FLAGS_EFFECTIVE

常量

第 7179 行

std.os.linux.VFS_CAP_FLAGS_MASK

常量

第 7178 行

std.os.linux.VFS_CAP_REVISION

别名

第 7191 行

别名目标 std.os.linux.VFS_CAP_REVISION_2

std.os.linux.VFS_CAP_REVISION_1

常量

第 7181 行

std.os.linux.VFS_CAP_REVISION_2

常量

第 7185 行

std.os.linux.VFS_CAP_REVISION_MASK

常量

第 7176 行

std.os.linux.VFS_CAP_REVISION_SHIFT

常量

第 7177 行

std.os.linux.VFS_CAP_U32

别名

第 7190 行

别名目标 std.os.linux.VFS_CAP_U32_2

std.os.linux.VFS_CAP_U32_1

常量

第 7182 行

std.os.linux.VFS_CAP_U32_2

常量

第 7186 行

std.os.linux.VTDLY

容器

第 8697 行

字段

VT0 = 0
VT1 = 1

std.os.linux.W

命名空间

第 4665 行

std.os.linux.W_OK

常量

第 4662 行

std.os.linux.W.CONTINUED

常量

第 4670 行

std.os.linux.W.EXITED

常量

第 4669 行

std.os.linux.W.EXITSTATUS

函数

第 4673 行

pub fn EXITSTATUS(s: u32) u8

参数

s: u32

std.os.linux.W.IFEXITED

函数

第 4682 行

pub fn IFEXITED(s: u32) bool

参数

s: u32

std.os.linux.W.IFSIGNALED

函数

第 4688 行

pub fn IFSIGNALED(s: u32) bool

参数

s: u32

std.os.linux.W.IFSTOPPED

函数

第 4685 行

pub fn IFSTOPPED(s: u32) bool

参数

s: u32

std.os.linux.W.NOHANG

常量

第 4666 行

std.os.linux.W.NOWAIT

常量

第 4671 行

std.os.linux.W.STOPPED

常量

第 4668 行

std.os.linux.W.STOPSIG

函数

第 4679 行

pub fn STOPSIG(s: u32) SIG

参数

s: u32

std.os.linux.W.TERMSIG

函数

第 4676 行

pub fn TERMSIG(s: u32) SIG

参数

s: u32

std.os.linux.W.UNTRACED

常量

第 4667 行

std.os.linux.wait4

函数

第 2256 行

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

参数

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

std.os.linux.waitid

函数

第 2266 行

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

参数

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

std.os.linux.waitpid

函数

第 2252 行

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

参数

pid: pid_t
status: *i32
flags: u32

std.os.linux.winsize

别名

第 24 行

别名目标 std.posix.winsize

std.os.linux.write

函数

第 1787 行

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

参数

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

std.os.linux.writev

函数

第 1825 行

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

参数

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

std.os.linux.X_OK

常量

第 4661 行

std.os.linux.XATTR_CAPS_SZ

别名

第 7189 行

别名目标 std.os.linux.XATTR_CAPS_SZ_2

std.os.linux.XATTR_CAPS_SZ_1

常量

第 7183 行

std.os.linux.XATTR_CAPS_SZ_2

常量

第 7187 行

std.os.linux.XDP

命名空间

第 9798 行

std.os.linux.xdp_desc

容器

第 9860 行

字段

addr: u64
len: u32
options: u32

std.os.linux.xdp_mmap_offsets

容器

第 9829 行

字段

std.os.linux.xdp_options

容器

第 9853 行

字段

flags: u32

std.os.linux.xdp_ring_offset

容器

第 9822 行

字段

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

std.os.linux.xdp_statistics

容器

第 9844 行

字段

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

容器

第 9836 行

字段

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

std.os.linux.XDP.COPY

常量

第 9800 行

std.os.linux.XDP.MMAP_OFFSETS

常量

第 9805 行

std.os.linux.XDP.OPTIONS

常量

第 9812 行

std.os.linux.XDP.OPTIONS_ZEROCOPY

常量

第 9814 行

std.os.linux.XDP.PGOFF_RX_RING

常量

第 9816 行

std.os.linux.XDP.PGOFF_TX_RING

常量

第 9817 行

std.os.linux.XDP.RX_RING

常量

第 9806 行

std.os.linux.XDP.SHARED_UMEM

常量

第 9799 行

std.os.linux.XDP.STATISTICS

常量

第 9811 行

std.os.linux.XDP.TX_RING

常量

第 9807 行

std.os.linux.XDP.UMEM_COMPLETION_RING

常量

第 9810 行

std.os.linux.XDP.UMEM_FILL_RING

常量

第 9809 行

std.os.linux.XDP.UMEM_PGOFF_COMPLETION_RING

常量

第 9819 行

std.os.linux.XDP.UMEM_PGOFF_FILL_RING

常量

第 9818 行

std.os.linux.XDP.UMEM_REG

常量

第 9808 行

std.os.linux.XDP.UMEM_UNALIGNED_CHUNK_FLAG

常量

第 9802 行

std.os.linux.XDP.USE_NEED_WAKEUP

常量

第 9803 行

std.os.linux.XDP.ZEROCOPY

常量

第 9801 行

std.os.linux.XSK_UNALIGNED_BUF_ADDR_MASK

常量

第 9858 行

std.os.linux.XSK_UNALIGNED_BUF_OFFSET_SHIFT

常量

第 9857 行

源码

std/os/linux.zig

//! 无论是否链接 libc,此文件均为 Linux 提供与 libc
//! 所提供内容相匹配的系统接口函数。采用以下
//! 抽象:
//! * 实现所有系统调用,方式类似于 libc 在仅有
//!   `renameat` 系统调用时仍提供 `rename` 函数。
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, // 又称 tls
    ctid: ?*pid_t,
) usize {
    // 不能直接调用 naked 函数;先转换为 C 调用约定。
    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,
        /// 通常必须同时设置 `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,
        /// 通常必须同时设置 `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,
        /// 通常必须同时设置 `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,
        /// 通常必须同时设置 `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,
        /// 通常必须同时设置 `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,
        /// 通常必须同时设置 `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,
        /// 如果不同时设置 `TMPFILE1` 和 `DIRECTORY`,这通常无效。
        TMPFILE0: bool = false,
        PATH: bool = false,
        _22: u4 = 0,
        /// 若不同时设置 `TMPFILE0` 和 `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) {
    /// 不能与 `EXCHANGE` 同时设置。
    NOREPLACE: bool = false,
    /// 不能与 `NOREPLACE` 同时设置。
    EXCHANGE: bool = false,
    WHITEOUT: bool = false,
    _: u29 = 0,
};

/// 由启动代码设置,供 `getauxval` 使用。
pub var elf_aux_maybe: ?[*]std.elf.Auxv = null;

/// 使用外部还是内部的 getauxval 实现。
const extern_getauxval = switch (builtin.zig_backend) {
    // 这些后端尚不支持调用 extern 函数
    .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");
        // 仅在构建可执行文件时导出此符号,否则会覆盖
        // libc 的实现。
        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;
}

// 某些架构及某些系统调用要求通过
// 偶数对齐的寄存器对传递 64 位参数。
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();

// 将 64 位值拆成 {LSB,MSB} 对。
// LE/BE 变体指定采用的端序。
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)),
        },
    }
}

/// 从系统调用返回值中获取 errno。SUCCESS 表示无错误。
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
    /// 不跟随符号链接。
    SYMLINK_NOFOLLOW: bool, // 0x00000100
    _200: u3 = 0, // 0x00000200
    /// 允许空的相对路径名。
    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)),
        );
    }
}

// v1 futex 系统调用的第 4 个参数可以是可选的
// 指向 timespec 的指针,也可以是 uint32,取决于执行的
// "op"。
pub const futex_param4 = extern union {
    timeout: ?*const timespec,
    /// 所有平台上仅使用 `val2` 的低 32 位。
    /// 此处采用 64 位以匹配联合体中的指针。
    val2: usize,
};

/// futex 第一版系统调用;另见较新的 futex2_{wait,wakeup,requeue,waitv} 系统调用。
///
/// futex_op 参数包含子命令和标志。子命令决定
/// 后续参数中哪些参数相关。
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,
    );
}

/// v1 futex 调用的三参数变体。仅适用于忽略其余参数的 futex_op(例如 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,
    );
}

/// v1 futex 调用的四参数变体。仅适用于忽略其余参数的 futex_op(例如 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),
    );
}

/// 给定 `futex2_waitone` 数组,在每个 uaddr 上等待。
/// 任意 uaddr 上执行 futex_wake() 都会唤醒线程。
/// 若任一 futex 满足 *uaddr != val,系统调用立即返回。
/// timeout 是可选的操作绝对超时时刻。
/// `flags` 参数保留供将来使用,目前应设为 `.{}`。
/// 私有 futex、大小等标志应设置在
/// 每个 `futex2_waitone` 各自的 flags 中。
///
/// 返回被唤醒 futex 之一在数组中的索引。
/// 不提供其他信息:同一事件可能同时唤醒
/// 任意数量的其他 futex;若唤醒了多个 futex,
/// 返回索引可以指向其中任意一个。
/// 它不一定是索引最小的 futex,
/// 也不一定是最后被唤醒的 futex。
///
/// 至少需要内核 v5.16。
pub fn futex2_waitv(
    futexes: [*]const futex2_waitone,
    /// `futexes` 的长度。最大为 FUTEX2_WAITONE_MAX。
    nr_futexes: u32,
    flags: FUTEX2_FLAGS_WAITV,
    /// 可选的绝对超时时间。即使在 32 位平台上也始终为 64 位。
    timeout: ?*const kernel_timespec,
    /// 超时使用的时钟,可以是实时时钟或单调时钟。
    clockid: clockid_t,
) usize {
    return syscall5(
        .futex_waitv,
        @intFromPtr(futexes),
        nr_futexes,
        @as(u32, @bitCast(flags)),
        @intFromPtr(timeout),
        @backingInt(clockid),
    );
}

/// 等待单个 futex。
/// 与 futex v1 的 `FUTEX.FUTEX_WAIT_BITSET` 操作相同,但属于
/// futex2 调用族。
///
/// 要求内核至少为 v6.7。
pub fn futex2_wait(
    /// 要等待的 futex 地址。
    uaddr: *const anyopaque,
    /// `uaddr` 的值。
    val: usize,
    /// 用于匹配传入唤醒掩码的位掩码。不得为零。
    mask: usize,
    flags: FUTEX2_FLAGS,
    /// 可选的绝对超时时间。即使在 32 位平台上也始终为 64 位。
    timeout: ?*const kernel_timespec,
    /// 超时使用的时钟,可以是实时时钟或单调时钟。
    clockid: clockid_t,
) usize {
    return syscall6(
        .futex_wait,
        @intFromPtr(uaddr),
        val,
        mask,
        @as(u32, @bitCast(flags)),
        @intFromPtr(timeout),
        @backingInt(clockid),
    );
}

/// 唤醒给定 futex 上的部分或全部等待者。
/// 与传统的 `FUTEX.FUTEX_WAKE_BITSET` 操作相同,但属于
/// futex2 调用族。
///
/// 要求内核至少为 v6.7。
pub fn futex2_wake(
    /// 要唤醒的 futex
    uaddr: *const anyopaque,
    /// 用于匹配等待者的位掩码。
    mask: usize,
    /// 在 futex 上最多唤醒的等待者数量。
    nr_wake: i32,
    flags: FUTEX2_FLAGS,
) usize {
    return syscall4(
        .futex_wake,
        @intFromPtr(uaddr),
        mask,
        @as(u32, @bitCast(nr_wake)),
        @as(u32, @bitCast(flags)),
    );
}

/// 唤醒等待方,和/或将其从一个 futex 重新排队到另一个。
/// 与 `FUTEX.CMP_REQUEUE` 相同,但属于 futex2 调用族。
///
/// 至少需要内核 v6.7。
pub fn futex2_requeue(
    /// 源 futex 与目标 futex。必须为包含 2 个元素的数组。
    waiters: [*]const futex2_waitone,
    /// 当前未使用。
    flags: FUTEX2_FLAGS_REQUEUE,
    /// 在源 futex 上最多唤醒的等待者数量。
    nr_wake: i32,
    /// 要转移到目标 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) {
    /// 沿源路径跟随符号链接。
    F_SYMLINKS: bool, // 0x00000001
    /// 沿源路径遍历自动挂载点。
    F_AUTOMOUNTS: bool, // 0x00000002
    /// 允许源路径为空。
    F_EMPTY_PATH: bool, // 0x00000004
    _8: bool = false, // 0x00000008
    /// 跟随目标路径上的符号链接。
    T_SYMLINKS: bool, // 0x00000010
    /// 沿路径跟随自动挂载点。
    T_AUTOMOUNTS: bool, // 0x00000020
    /// 允许空的目标路径。
    T_EMPTY_PATH: bool, // 0x00000040
    _80: bool = false, // 0x00000080
    /// 改用共享组。
    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) {
    /// 相对于 mtime/ctime 更新 atime。
    RELATIME: u0, // 这是默认 ATIME,除非设置其他 ATIME,否则为 true。
    /// 只读挂载。
    RDONLY: bool, // 0x00000001
    /// 忽略 suid 和 sgid 位。
    NOSUID: bool, // 0x00000002
    /// 禁止访问设备特殊文件。
    NODEV: bool, // 0x00000004
    /// 禁止执行程序。
    NOEXEC: bool, // 0x00000008
    /// 不更新访问时间。
    NOATIME: bool, // 0x00000010
    /// 始终更新 atime。
    STRICTATIME: bool, // 0x00000020
    _40: bool = false, // 0x00000040
    /// 不更新目录的访问时间。
    NODIRATIME: bool, // 0x00000080
    _100: u12 = 0, // 0x00000100
    /// 将挂载的 ID 映射到 struct mount_attr 中的 @userns_fd。
    IDMAP: bool, // 0x00100000
    /// 不跟随符号链接。
    NOSYMFOLLOW: bool, // 0x00200000
    _: u10 = 0,

    // ATIME: u32, // 0x00000070 这是掩码,不是标志。
};

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) {
    /// 在新 fd 上设置 CLOEXEC。
    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_FLAG,
    /// 提供字符串值来设置参数。
    SET_STRING,
    /// 设置参数,提供二进制数据块值。
    SET_BINARY,
    /// 设置参数,通过路径提供对象。
    SET_PATH,
    /// 设置参数,通过(空)路径提供对象。
    SET_PATH_EMPTY,
    /// 设置参数,通过文件描述符提供对象。
    SET_FD,
    /// 触发超级块创建。
    CREATE,
    /// 触发超级块重新配置。
    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) {
    /// 在文件描述符上设置 CLOEXEC。
    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) {
    /// 在新 fd 上设置 CLOEXEC。
    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 {
        // s390x 的 mmap() 系统调用早于 Linux 支持 5 个及以上参数的系统调用,因此它只接受一个指向参数数组的指针。
        //
        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;
};

/// 仅可在 64 位系统上调用。
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,
        // 内核要求按最大自然字长拆分偏移量。
        // 详细信息请参见:
        // 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,
        // 参见 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,
        // 参见 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,
        // 参见 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 可能为负数,例如 AT.FDCWD 为 -100
    return syscall4(.openat, @as(u32, @bitCast(dirfd)), @intFromPtr(path), @as(u32, @bitCast(flags)), mode);
}

/// 另请参见 `clone`(来自架构专属的包含文件)
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);
}

/// 另请参见 `clone`(来自架构专属的包含文件)
pub fn clone2(flags: u32, child_stack_ptr: usize) usize {
    return syscall2(.clone, flags, child_stack_ptr);
}

/// 此调用不会失败,返回值为调用方的线程 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: bool, // 0x00000001
    /// 设置 FD_CLOEXEC 位,而不关闭文件描述符。
    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);
}

/// 仅可在 32 位系统上调用。64 位系统参见 `lseek`。
pub fn llseek(fd: fd_t, offset: off_t, result: ?*off_t, whence: u32) u32 {
    // 注意:offset 参数的拆分与目标
    // 端序无关。
    return syscall5(
        .llseek,
        @as(u32, @bitCast(fd)),
        @truncate(@as(u64, @bitCast(offset >> 32))),
        @truncate(@as(u64, @bitCast(offset))),
        @intFromPtr(result),
        whence,
    );
}

/// 仅可在 64 位系统上调用。32 位系统参见 `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;
}

/// reboot 系统调用的标志。
pub const LINUX_REBOOT = struct {
    /// 使用 _reboot() 系统调用所需的第一个魔数。
    pub const MAGIC1 = enum(u32) {
        MAGIC1 = 0xfee1dead,
        _,
    };

    /// 使用 _reboot() 系统调用所需的第二个魔数。
    pub const MAGIC2 = enum(u32) {
        MAGIC2 = 672274793,
        MAGIC2A = 85072278,
        MAGIC2B = 369367448,
        MAGIC2C = 537993216,
        _,
    };

    /// _reboot() 系统调用接受的命令。
    pub const CMD = enum(u32) {
        /// 使用默认命令及模式重启系统。
        RESTART = 0x01234567,

        /// 停止操作系统,并将控制权交给 ROM 监控器(若存在)。
        HALT = 0xCDEF0123,

        /// Ctrl-Alt-Del 按键序列触发 RESTART 命令。
        CAD_ON = 0x89ABCDEF,

        /// Ctrl-Alt-Del 组合键向 init 任务发送 SIGINT。
        CAD_OFF = 0x00000000,

        /// 停止操作系统,并尽可能切断系统全部电源。
        POWER_OFF = 0x4321FEDC,

        /// 使用给定命令字符串重新启动系统。
        RESTART2 = 0xA1B2C3D4,

        /// 若编译时启用了软件挂起,则使用它挂起系统。
        SW_SUSPEND = 0xD000FCE2,

        /// 使用先前加载的 Linux 内核重启系统。
        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,
};

// 调用 VDSO 时必须遵循 C 调用约定。
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));
    // 注意,可能根本不存在 VDSO,但仍更新桩函数地址,
    // 使 clock_gettime 回退到传统但较慢的系统调用。
    @atomicStore(?VdsoClockGettime, &vdso_clock_gettime, ptr, .monotonic);
    // 若可用,则调用 VDSO
    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 {
    // 这里使用 setresuid 而非 setreuid,确保保存的 uid 不被修改。musl 和较新版 glibc 也采用相同方式。
    //
    // setresuid(2) 手册说明,传入 -1 时,对应标识不变。由于 uid_t 为无符号类型,在 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 {
    // 此处使用 setresgid 而非 setregid,以确保保存的 uid
    // 不发生变化。musl 和较新版本的 glibc 也采用此方式。
    //
    // setresgid(2) 手册说明,传入 -1 时,相应
    // 标识不会改变。由于 gid_t 无符号,在 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 {
    // 将结果转换为 pid_t,并进行 >= 0 安全检查,因为 getpid() 不会失败。
    return @intCast(@as(u32, @truncate(syscall0(.getpid))));
}

pub fn getppid() pid_t {
    // 将结果转换为 pid_t,并安全检查 >= 0,因为 getppid() 不会失败
    return @intCast(@as(u32, @truncate(syscall0(.getppid))));
}

pub fn gettid() pid_t {
    // 将结果转换为 pid_t,并安全检查 >= 0,因为 gettid() 不会失败
    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 需要为每个信号处理程序安装本架构的恢复函数,
            // 因此必须复制 Sigaction 结构体。
            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) {
        // sparc 版本的 rt_sigaction 还需要将恢复函数作为参数传入。
        .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;
}

/// 定义为已定义的最大信号编号加一。
pub const NSIG = if (is_mips) 128 else 65;

/// Linux 内核的 sigset_t。多数
/// 架构上逻辑位宽为 64 位,但 MIPS 上为 128 位。
/// 与 glibc 和 musl 库 ABI 导出的 1024 位 sigset_t 不同。
pub const sigset_t = [(NSIG - 1 + 7) / @bitSizeOf(SigsetElement)]SigsetElement;

const SigsetElement = c_ulong;

const sigset_len = @typeInfo(sigset_t).array.len;

/// Zig 的 SIGRTMIN,但为兼容 glibc,采用函数形式。
pub fn sigrtmin() u8 {
    // 内核 UAPI 中的默认值为 32:https://github.com/torvalds/linux/blob/78109c591b806e41987e0b83390e61d675d1f724/include/uapi/asm-generic/signal.h#L50
    // 据原作者所知,所有覆盖此值的架构也都将其设为 32:
    // https://github.com/search?q=repo%3Atorvalds%2Flinux+sigrtmin+path%3Auapi&type=code
    return 32;
}

/// Zig 的 SIGRTMAX,但为兼容 glibc 而采用函数形式
pub fn sigrtmax() u8 {
    return NSIG - 1;
}

/// Zig 版 sigemptyset。返回已初始化的 sigset_t。
pub fn sigemptyset() sigset_t {
    return @splat(0);
}

/// Zig 版本的 sigfillset。返回已初始化的 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 = 0,
        /// FIFO 实时调度
        FIFO = 1,
        /// 轮转实时调度
        RR = 2,
        /// 用于“批量”执行进程
        BATCH = 3,
        /// 低延迟调度
        IDLE = 5,
        /// 零星任务模型的截止时间调度
        DEADLINE = 6,
    };
    mode: Mode, // 位 [0, 2]
    _3: u27 = 0, // 位 [3, 29]
    /// 设为 true,以阻止子项继承策略
    RESET_ON_FORK: bool = false, // 位 30
    _31: u1 = 0, // 第 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, // 此结构的大小
    policy: u32 = 0, // 策略(SCHED_*)
    flags: u64 = 0, // 标志
    nice: u32 = 0, // Nice 值(SCHED_OTHER、SCHED_BATCH)
    priority: u32 = 0, // 静态优先级(SCHED_FIFO、SCHED_RR)
    // 其余字段用于 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),
    );
}

// 'setitimer' 系统调用的标志
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 {
    // 使用 prlimit64,以在 32 位平台上获得 64 位限制值
    return prlimit(0, resource, null, rlim);
}

pub fn setrlimit(resource: rlimit_resource, rlim: *const rlimit) usize {
    // 使用 prlimit64,以在 32 位平台上获得 64 位限制值
    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 与其他要求
        // 寄存器对对齐的架构不同。

        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,
    );
}

/// 查询文件的页缓存统计信息。
pub fn cachestat(
    /// 用于获取统计信息的已打开文件描述符。
    fd: fd_t,
    /// 要查询的 `fd` 中的字节范围。
    /// 当 `len > 0` 时,范围为 `[off..off + len]`。
    /// 当 `len` == 0 时,范围从 `off` 到 `fd` 末尾。
    cstat_range: *const cache_stat_range,
    /// 存储页缓存统计信息的结构体。
    cstat: *cache_stat,
    /// 当前未使用,必须设为 `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 {
        /// 自启动经过的秒数
        uptime: i64,
        /// 1、5 和 15 分钟的负载平均值
        loads: [3]u64,
        /// 可用主内存总大小
        totalram: u64,
        /// 可用内存大小
        freeram: u64,
        /// 共享内存量
        sharedram: u64,
        /// 缓冲区使用的内存
        bufferram: u64,
        /// 交换空间总大小
        totalswap: u64,
        /// 交换空间仍然可用
        freeswap: u64,
        /// 当前进程数量
        procs: u16,
        /// m68k 的显式填充
        pad: u16,
        /// 高端内存总大小
        totalhigh: u64,
        /// 可用高端内存大小
        freehigh: u64,
        /// 内存单位大小,单位为字节
        mem_unit: u32,
    },
    else => extern struct {
        /// 自启动经过的秒数
        uptime: isize,
        /// 1、5 和 15 分钟的负载平均值
        loads: [3]usize,
        /// 可用主内存总大小
        totalram: usize,
        /// 可用内存大小
        freeram: usize,
        /// 共享内存量
        sharedram: usize,
        /// 缓冲区使用的内存
        bufferram: usize,
        /// 交换空间总大小
        totalswap: usize,
        /// 交换空间仍然可用
        freeswap: usize,
        /// 当前进程数量
        procs: u16,
        /// m68k 的显式填充
        pad: u16,
        /// 高端内存总大小
        totalhigh: usize,
        /// 可用高端内存大小
        freehigh: usize,
        /// 内存单位大小,单位为字节
        mem_unit: u32,
        /// 填充
        _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) {
        /// 未发生错误。
        SUCCESS = 0,

        PERM = 1,
        NOENT = 2,
        SRCH = 3,
        INTR = 4,
        IO = 5,
        NXIO = 6,
        @"2BIG" = 7,
        NOEXEC = 8,
        BADF = 9,
        CHILD = 10,
        /// 也用于 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) {
        /// 未发生错误。
        SUCCESS = 0,

        PERM = 1,
        NOENT = 2,
        SRCH = 3,
        INTR = 4,
        IO = 5,
        NXIO = 6,
        @"2BIG" = 7,
        NOEXEC = 8,
        BADF = 9,
        CHILD = 10,
        /// 也用于 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,
        /// 也用于 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) {
        /// 未发生错误。
        SUCCESS = 0,

        /// 操作不被允许
        PERM = 1,
        /// 没有此文件或目录
        NOENT = 2,
        /// 无此进程
        SRCH = 3,
        /// 系统调用被中断
        INTR = 4,
        /// I/O 错误
        IO = 5,
        /// 无此设备或地址
        NXIO = 6,
        /// 参数列表过长
        @"2BIG" = 7,
        /// 可执行文件格式错误
        NOEXEC = 8,
        /// 错误的文件编号
        BADF = 9,
        /// 没有子进程
        CHILD = 10,
        /// 内存不足
        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,

        /// 操作将导致资源死锁
        DEADLK = 11,

        /// 重试。
        /// 也用于 WOULDBLOCK。
        AGAIN = 35,
        /// 操作正在进行中
        INPROGRESS = 36,
        /// 操作已在进行中
        ALREADY = 37,
        /// 对非套接字执行了套接字操作
        NOTSOCK = 38,
        /// 需要目标地址
        DESTADDRREQ = 39,
        /// 消息过长
        MSGSIZE = 40,
        /// 套接字的协议类型错误
        PROTOTYPE = 41,
        /// 协议不可用
        NOPROTOOPT = 42,
        /// 不支持此协议
        PROTONOSUPPORT = 43,
        /// 不支持的套接字类型
        SOCKTNOSUPPORT = 44,
        /// 传输端点不支持此操作
        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,

        /// 用户过多
        USERS = 68,
        /// 超出配额
        DQUOT = 69,
        /// 失效的文件句柄
        STALE = 70,
        /// 对象位于远程
        REMOTE = 71,

        /// 没有可用的记录锁
        NOLCK = 77,
        /// 函数未实现
        NOSYS = 78,

        /// 没有所需类型的消息
        NOMSG = 80,
        /// 标识符已移除
        IDRM = 81,
        /// 流资源不足
        NOSR = 82,
        /// 定时器已到期
        TIME = 83,
        /// 不是数据消息
        /// 也用于 FSBADCRC。
        BADMSG = 84,
        /// 协议错误
        PROTO = 85,
        /// 无可用数据
        NODATA = 86,
        /// 设备不是流
        NOSTR = 87,

        /// 未安装软件包
        NOPKG = 92,

        /// 非法字节序列
        ILSEQ = 116,

        // 内核源码将以下内容指定为“随机噪声”。
        /// 通道号超出范围
        CHRNG = 88,
        /// 第 2 层未同步
        L2NSYNC = 89,
        /// 第 3 级已停止
        L3HLT = 90,
        /// 第 3 级重置
        L3RST = 91,

        /// 链接数超出范围
        LNRNG = 93,
        /// 未附加协议驱动程序
        UNATCH = 94,
        /// 没有可用的 CSI 结构
        NOCSI = 95,
        /// 第 2 层已停止
        L2HLT = 96,
        /// 交换无效
        BADE = 97,
        /// 无效的请求描述符
        BADR = 98,
        /// 交换区已满
        XFULL = 99,
        /// 没有 anode
        NOANO = 100,
        /// 无效的请求代码
        BADRQC = 101,
        /// 槽位无效
        BADSLT = 102,

        /// 错误的字体文件格式
        BFONT = 104,
        /// 机器不在网络中
        NONET = 105,
        /// 链路已断开
        NOLINK = 106,
        /// 通告错误
        ADV = 107,
        /// Srmount 错误
        SRMNT = 108,
        /// 发送时发生通信错误
        COMM = 109,
        /// 尝试进行多跳
        MULTIHOP = 110,
        /// RFS 专用错误
        DOTDOT = 111,
        /// 值超出所定义数据类型的范围
        OVERFLOW = 112,
        /// 网络上的名称不唯一
        NOTUNIQ = 113,
        /// 文件描述符状态错误
        BADFD = 114,
        /// 远程地址已更改
        REMCHG = 115,

        /// 结构需要清理
        /// 也用于 FSCORRUPTED。
        UCLEAN = 117,
        /// 不是 XENIX 命名类型文件
        NOTNAM = 118,
        /// 没有可用的 XENIX 信号量
        NAVAIL = 119,
        /// 是命名类型文件
        ISNAM = 120,
        /// 远程 I/O 错误
        REMOTEIO = 121,

        /// 无法访问所需的共享库
        LIBACC = 122,
        /// 访问已损坏的共享库
        LIBBAD = 123,
        /// a.out 中的 .lib 节已损坏
        LIBSCN = 124,
        /// 尝试链接的共享库过多
        LIBMAX = 125,
        /// 无法直接执行共享库
        LIBEXEC = 126,
        /// 被中断的系统调用应重新启动
        RESTART = 127,
        /// 流管道错误
        STRPIPE = 128,

        /// 未找到介质
        NOMEDIUM = 129,
        /// 介质类型错误
        MEDIUMTYPE = 130,
        /// 操作已取消
        CANCELED = 131,
        /// 所需密钥不可用
        NOKEY = 132,
        /// 密钥已过期
        KEYEXPIRED = 133,
        /// 密钥已被撤销
        KEYREVOKED = 134,
        /// 密钥被服务拒绝
        KEYREJECTED = 135,

        // 用于健壮互斥锁
        /// 所有者已终止
        OWNERDEAD = 136,
        /// 状态不可恢复
        NOTRECOVERABLE = 137,

        /// 受射频禁用状态影响,无法执行操作
        RFKILL = 138,
        /// 内存页存在硬件错误
        HWPOISON = 139,
        _,
    },
    else => enum(u16) {
        /// 未发生错误。
        /// `NSROK` 使用同一错误码。
        SUCCESS = 0,
        /// 操作不被允许
        PERM = 1,
        /// 没有此文件或目录
        NOENT = 2,
        /// 无此进程
        SRCH = 3,
        /// 系统调用被中断
        INTR = 4,
        /// I/O 错误
        IO = 5,
        /// 无此设备或地址
        NXIO = 6,
        /// 参数列表过长
        @"2BIG" = 7,
        /// 可执行文件格式错误
        NOEXEC = 8,
        /// 错误的文件编号
        BADF = 9,
        /// 没有子进程
        CHILD = 10,
        /// 请重试。
        /// 也表示 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,
        /// 操作将导致资源死锁
        DEADLK = 35,
        /// 文件名过长
        NAMETOOLONG = 36,
        /// 没有可用的记录锁
        NOLCK = 37,
        /// 函数未实现
        NOSYS = 38,
        /// 目录非空
        NOTEMPTY = 39,
        /// 遇到的符号链接过多
        LOOP = 40,
        /// 没有所需类型的消息
        NOMSG = 42,
        /// 标识符已移除
        IDRM = 43,
        /// 通道号超出范围
        CHRNG = 44,
        /// 第 2 层未同步
        L2NSYNC = 45,
        /// 第 3 级已停止
        L3HLT = 46,
        /// 第 3 级重置
        L3RST = 47,
        /// 链接数超出范围
        LNRNG = 48,
        /// 未附加协议驱动程序
        UNATCH = 49,
        /// 没有可用的 CSI 结构
        NOCSI = 50,
        /// 第 2 层已停止
        L2HLT = 51,
        /// 交换无效
        BADE = 52,
        /// 无效的请求描述符
        BADR = 53,
        /// 交换区已满
        XFULL = 54,
        /// 没有 anode
        NOANO = 55,
        /// 无效的请求代码
        BADRQC = 56,
        /// 槽位无效
        BADSLT = 57,
        /// 错误的字体文件格式
        BFONT = 59,
        /// 设备不是流
        NOSTR = 60,
        /// 无可用数据
        NODATA = 61,
        /// 定时器已到期
        TIME = 62,
        /// 流资源不足
        NOSR = 63,
        /// 机器不在网络中
        NONET = 64,
        /// 未安装软件包
        NOPKG = 65,
        /// 对象位于远程
        REMOTE = 66,
        /// 链路已断开
        NOLINK = 67,
        /// 通告错误
        ADV = 68,
        /// Srmount 错误
        SRMNT = 69,
        /// 发送时发生通信错误
        COMM = 70,
        /// 协议错误
        PROTO = 71,
        /// 尝试进行多跳
        MULTIHOP = 72,
        /// RFS 专用错误
        DOTDOT = 73,
        /// 不是数据消息
        BADMSG = 74,
        /// 值超出所定义数据类型的范围
        OVERFLOW = 75,
        /// 网络上的名称不唯一
        NOTUNIQ = 76,
        /// 文件描述符状态错误
        BADFD = 77,
        /// 远程地址已更改
        REMCHG = 78,
        /// 无法访问所需的共享库
        LIBACC = 79,
        /// 访问已损坏的共享库
        LIBBAD = 80,
        /// a.out 中的 .lib 节已损坏
        LIBSCN = 81,
        /// 尝试链接的共享库过多
        LIBMAX = 82,
        /// 无法直接执行共享库
        LIBEXEC = 83,
        /// 非法字节序列
        ILSEQ = 84,
        /// 被中断的系统调用应重新启动
        RESTART = 85,
        /// 流管道错误
        STRPIPE = 86,
        /// 用户过多
        USERS = 87,
        /// 对非套接字执行了套接字操作
        NOTSOCK = 88,
        /// 需要目标地址
        DESTADDRREQ = 89,
        /// 消息过长
        MSGSIZE = 90,
        /// 套接字的协议类型错误
        PROTOTYPE = 91,
        /// 协议不可用
        NOPROTOOPT = 92,
        /// 不支持此协议
        PROTONOSUPPORT = 93,
        /// 不支持的套接字类型
        SOCKTNOSUPPORT = 94,
        /// 传输端点不支持此操作
        /// 此错误码也表示 `NOTSUP`。
        OPNOTSUPP = 95,
        /// 不支持此协议族
        PFNOSUPPORT = 96,
        /// 协议不支持该地址族
        AFNOSUPPORT = 97,
        /// 地址已被使用
        ADDRINUSE = 98,
        /// 无法分配请求的地址
        ADDRNOTAVAIL = 99,
        /// 网络已关闭
        NETDOWN = 100,
        /// 网络不可达
        NETUNREACH = 101,
        /// 网络因重置而断开连接
        NETRESET = 102,
        /// 软件导致连接中止
        CONNABORTED = 103,
        /// 连接被对端重置
        CONNRESET = 104,
        /// 没有可用的缓冲区空间
        NOBUFS = 105,
        /// 传输端点已连接
        ISCONN = 106,
        /// 传输端点未连接
        NOTCONN = 107,
        /// 传输端点关闭后无法发送
        SHUTDOWN = 108,
        /// 引用过多:无法拼接
        TOOMANYREFS = 109,
        /// 连接超时
        TIMEDOUT = 110,
        /// 连接被拒绝
        CONNREFUSED = 111,
        /// 主机已关闭
        HOSTDOWN = 112,
        /// 无到主机的路由
        HOSTUNREACH = 113,
        /// 操作已在进行中
        ALREADY = 114,
        /// 操作正在进行中
        INPROGRESS = 115,
        /// 失效的 NFS 文件句柄
        STALE = 116,
        /// 结构需要清理
        UCLEAN = 117,
        /// 不是 XENIX 命名类型文件
        NOTNAM = 118,
        /// 没有可用的 XENIX 信号量
        NAVAIL = 119,
        /// 是命名类型文件
        ISNAM = 120,
        /// 远程 I/O 错误
        REMOTEIO = 121,
        /// 超出配额
        DQUOT = 122,
        /// 未找到介质
        NOMEDIUM = 123,
        /// 介质类型错误
        MEDIUMTYPE = 124,
        /// 操作已取消
        CANCELED = 125,
        /// 所需密钥不可用
        NOKEY = 126,
        /// 密钥已过期
        KEYEXPIRED = 127,
        /// 密钥已被撤销
        KEYREVOKED = 128,
        /// 密钥被服务拒绝
        KEYREJECTED = 129,
        // 用于健壮互斥锁
        /// 所有者已终止
        OWNERDEAD = 130,
        /// 状态不可恢复
        NOTRECOVERABLE = 131,
        /// 受射频禁用状态影响,无法执行操作
        RFKILL = 132,
        /// 内存页存在硬件错误
        HWPOISON = 133,
        // 域名服务器查询返回码
        /// DNS 服务器返回了无数据的应答
        NSRNODATA = 160,
        /// DNS 服务器声称查询的格式错误
        NSRFORMERR = 161,
        /// DNS 服务器返回一般性失败
        NSRSERVFAIL = 162,
        /// 找不到域名
        NSRNOTFOUND = 163,
        /// DNS 服务器未实现请求的操作
        NSRNOTIMP = 164,
        /// DNS 服务器拒绝查询
        NSRREFUSED = 165,
        /// DNS 查询格式错误
        NSRBADQUERY = 166,
        /// 域名格式错误
        NSRBADNAME = 167,
        /// 不支持的地址族
        NSRBADFAMILY = 168,
        /// DNS 响应格式错误
        NSRBADRESP = 169,
        /// 无法联系 DNS 服务器
        NSRCONNREFUSED = 170,
        /// 联系 DNS 服务器时超时
        NSRTIMEOUT = 171,
        /// 文件结束
        NSROF = 172,
        /// 读取文件时出错
        NSRFILE = 173,
        /// 内存不足
        NSRNOMEM = 174,
        /// 应用程序终止了查询
        NSRDESTRUCTION = 175,
        /// 域名过长
        NSRQUERYDOMAINTOOLONG = 176,
        /// 域名过长
        NSRCNAMELOOP = 177,

        _,
    },
};

pub const NAME_MAX = 255;
pub const PATH_MAX = 4096;
pub const IOV_MAX = 1024;

/// 硬件地址的最大长度
/// 例如,mac 地址是一种硬件地址
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 {
    /// 用于指示 openat 应使用当前工作目录的特殊值。
    pub const FDCWD = -100;

    /// 不跟随符号链接
    pub const SYMLINK_NOFOLLOW = 0x100;

    /// 移除目录,而非解除文件链接
    pub const REMOVEDIR = 0x200;

    /// 跟随符号链接。
    pub const SYMLINK_FOLLOW = 0x400;

    /// 抑制末尾分量的自动挂载遍历
    pub const NO_AUTOMOUNT = 0x800;

    /// 允许空的相对路径名
    pub const EMPTY_PATH = 0x1000;

    /// statx() 所需的同步类型
    pub const STATX_SYNC_TYPE = 0x6000;

    /// - 执行与 stat() 相同的操作
    pub const STATX_SYNC_AS_STAT = 0x0000;

    /// - 强制将属性与服务器同步。
    pub const STATX_FORCE_SYNC = 0x2000;

    /// - 不与服务器同步属性
    pub const STATX_DONT_SYNC = 0x4000;

    /// 应用于整个子树
    pub const RECURSIVE = 0x8000;

    pub const HANDLE_FID = REMOVEDIR;
};

pub const FALLOC = struct {
    /// 默认值为扩展大小
    pub const FL_KEEP_SIZE = 0x01;

    /// 释放该范围
    pub const FL_PUNCH_HOLE = 0x02;

    /// 保留码点
    pub const FL_NO_HIDE_STALE = 0x04;

    /// 移除文件的某个范围,而不在文件中留下空洞
    pub const FL_COLLAPSE_RANGE = 0x08;

    /// 将文件某个范围转换为零,优先避免执行数据 I/O。
    pub const FL_ZERO_RANGE = 0x10;

    /// 在文件大小范围内插入空间,不覆盖任何已有数据
    pub const FL_INSERT_RANGE = 0x20;

    /// 取消文件大小范围内共享块的共享,而不覆盖任何已有数据
    pub const FL_UNSHARE_RANGE = 0x40;
};

// Futex v1 API 命令。
// 各命令对 futex 参数的解释见 futex 手册页。
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_op` 参数所用的 Futex v1 API 命令和标志
pub const FUTEX_OP = packed struct(u32) {
    cmd: FUTEX_COMMAND,
    private: bool,
    realtime: bool = false, // 实时时钟与单调时钟
    _reserved: u23 = 0,
};

/// Futex v1 FUTEX_WAKE_OP 的 `val3` 操作:
pub const FUTEX_WAKE_OP = packed struct(u32) {
    cmd: FUTEX_WAKE_OP_CMD,
    /// 来自 C API `FUTEX_OP_ARG_SHIFT`:使用 (1 << oparg) 作为操作数
    arg_shift: bool = false,
    cmp: FUTEX_WAKE_OP_CMP,
    oparg: u12,
    cmdarg: u12,
};

/// Futex v1 中用于 FUTEX_WAKE_OP 的 cmd `val3` 命令。
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_WAKE_OP 的 `val3` cmp 所用 Futex v1 比较操作
pub const FUTEX_WAKE_OP_CMP = enum(u4) {
    EQ = 0,
    NE = 1,
    LT = 2,
    LE = 3,
    GT = 4,
    GE = 5,
};

/// `futex2_waitone` 数组的最大元素数量。
pub const FUTEX2_WAITONE_MAX = 128;

/// 对于 futex v2 API,表示 uaddr 处 futex 的大小。v1 futex 始终隐式为 U32。截至内核 v6.14,v2 futex 仅实现 U32。
///
///
pub const FUTEX2_SIZE = enum(u2) {
    U8 = 0,
    U16 = 1,
    U32 = 2,
    U64 = 3,
};

/// 截至内核 6.14,尚未为 futex2_waitv 定义任何标志。
pub const FUTEX2_FLAGS_WAITV = packed struct(u32) {
    _reserved: u32 = 0,
};

/// 截至内核 6.14,futex2_requeue 没有已定义标志。
pub const FUTEX2_FLAGS_REQUEUE = packed struct(u32) {
    _reserved: u32 = 0,
};

/// futex v2 API 的标志(futex2_wait、futex2_wake、futex2_requeue,不包括 futex2_waitv 系统调用,但也用于 futex2_waitone 结构体)。
///
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,
        /// 页可用于原子操作。
        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,
        /// 页可用于原子操作。
        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 类型
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 {
    /// 禁用 Nagle 算法
    pub const NODELAY = 1;
    /// 限制 MSS
    pub const MAXSEG = 2;
    /// 绝不发送尚未完整的段。
    pub const CORK = 3;
    /// 在此时间段后启动保活,单位为秒
    pub const KEEPIDLE = 4;
    /// 保活消息之间的间隔
    pub const KEEPINTVL = 5;
    /// 判定失效前的保活次数
    pub const KEEPCNT = 6;
    /// SYN 重传次数
    pub const SYNCNT = 7;
    /// 孤立 FIN-WAIT-2 状态的生存期
    pub const LINGER2 = 8;
    /// 仅在数据到达时唤醒监听者
    pub const DEFER_ACCEPT = 9;
    /// 限制通告窗口
    pub const WINDOW_CLAMP = 10;
    /// 此连接的信息。
    pub const INFO = 11;
    /// 阻止或重新启用快速确认
    pub const QUICKACK = 12;
    /// 拥塞控制算法
    pub const CONGESTION = 13;
    /// TCP MD5 签名(RFC2385)
    pub const MD5SIG = 14;
    /// 对稀疏流使用线性超时
    pub const THIN_LINEAR_TIMEOUTS = 16;
    /// 收到 1 个重复确认后快速重传
    pub const THIN_DUPACK = 17;
    /// 丢失后重试直到超时的时长
    pub const USER_TIMEOUT = 18;
    /// TCP 套接字当前正在修复
    pub const REPAIR = 19;
    pub const REPAIR_QUEUE = 20;
    pub const QUEUE_SEQ = 21;
    pub const REPAIR_OPTIONS = 22;
    /// 在监听套接字上启用 FastOpen
    pub const FASTOPEN = 23;
    pub const TIMESTAMP = 24;
    /// 限制写队列中未发送字节的数量
    pub const NOTSENT_LOWAT = 25;
    /// 获取拥塞控制信息(可选)
    pub const CC_INFO = 26;
    /// 记录新连接的 SYN 头
    pub const SAVE_SYN = 27;
    /// 获取为连接记录的 SYN 头
    pub const SAVED_SYN = 28;
    /// 获取/设置窗口参数
    pub const REPAIR_WINDOW = 29;
    /// 在 connect 时尝试 FastOpen
    pub const FASTOPEN_CONNECT = 30;
    /// 将 ULP 附加到 TCP 连接
    pub const ULP = 31;
    /// 带扩展的 TCP MD5 签名
    pub const MD5SIG_EXT = 32;
    /// 设置 Fast Open 的密钥(cookie)
    pub const FASTOPEN_KEY = 33;
    /// 无需 TFO cookie 即可启用 TFO
    pub const FASTOPEN_NO_COOKIE = 34;
    pub const ZEROCOPY_RECEIVE = 35;
    /// 读取时,以 cmsg 通知可读取的字节数
    pub const INQ = 36;
    pub const CM_INQ = INQ;
    /// 将发出的数据包延迟 XX 微秒
    pub const TX_DELAY = 37;

    pub const REPAIR_ON = 1;
    pub const REPAIR_OFF = 0;
    /// 不使用窗口探测直接关闭
    pub const REPAIR_OFF_NO_WP = -1;
};

pub const UDP = struct {
    /// 绝不发送不完整的段
    pub const CORK = 1;
    /// 将套接字设置为接收封装数据包
    pub const ENCAP = 100;
    /// 禁用发送 UDP6X 校验和
    pub const NO_CHECK6_TX = 101;
    /// 禁止接收 UDP6 校验和
    pub const NO_CHECK6_RX = 102;
    /// 设置 GSO 分段大小
    pub const SEGMENT = 103;
    /// 此套接字可接收 UDP GRO 数据包
    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 套接字选项
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 的取值
    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 FLOWLABEL_MGR = 32;
    pub const FLOWINFO_SEND = 33;
    pub const IPSEC_POLICY = 34;
    pub const XFRM_POLICY = 35;
    pub const HDRINCL = 36;

    // 高级 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;

    // 高级 API(RFC3542)(2)
    pub const RECVTCLASS = 66;
    pub const TCLASS = 67;

    pub const AUTOFLOWLABEL = 70;

    // RFC5014:源地址选择
    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:通用 TTL 安全机制
    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, // 非零表示关闭时延迟退出
    linger: i32, // 延迟关闭时间,单位为秒
};

// 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 以太网魔数常量。帧大小不含前导码
/// 及 FCS/CRC(帧校验序列)。
pub const ETH = struct {
    /// 单个以太网地址的字节数
    pub const ALEN = 6;
    /// 以太网类型字段的字节数
    pub const TLEN = 2;
    /// 首部总字节数
    pub const HLEN = 14;
    /// 不含 FC 的帧最小字节数
    pub const ZLEN = 60;
    /// 有效载荷中的最大字节数
    pub const DATA_LEN = 1500;
    /// 不含 FCS 的帧最大字节数
    pub const FRAME_LEN = 1514;
    /// FCS 的字节数
    pub const FCS_LEN = 4;

    /// RFC791 规定的最小 IPv4 MTU
    pub const MIN_MTU = 68;
    /// 65535,与 IP_MAX_MTU 相同
    pub const MAX_MTU = 0xFFFF;

    /// 这些是已定义的以太网协议标识符。
    pub const P = struct {
        /// 以太网回环数据包
        pub const LOOP = 0x0060;
        /// Xerox PUP 数据包
        pub const PUP = 0x0200;
        /// Xerox PUP 地址转换数据包
        pub const PUPAT = 0x0201;
        /// TSN(IEEE 1722)数据包
        pub const TSN = 0x22F0;
        /// ERSPAN 版本 2(类型 III)
        pub const ERSPAN2 = 0x22EB;
        /// 互联网协议数据包
        pub const IP = 0x0800;
        /// CCITT X.25
        pub const X25 = 0x0805;
        /// 地址解析数据包
        pub const ARP = 0x0806;
        /// G8BPQ AX.25 以太网数据包[非正式注册 ID]。
        pub const BPQ = 0x08FF;
        /// Xerox IEEE802.3 PUP 数据包
        pub const IEEEPUP = 0x0a00;
        /// Xerox IEEE802.3 PUP 地址转换数据包
        pub const IEEEPUPAT = 0x0a01;
        /// B.A.T.M.A.N.-Advanced 数据包[非正式注册 ID]。
        pub const BATMAN = 0x4305;
        /// DEC 分配的协议
        pub const DEC = 0x6000;
        /// DEC DNA 转储/加载
        pub const DNA_DL = 0x6001;
        /// DEC DNA 远程控制台
        pub const DNA_RC = 0x6002;
        /// DEC DNA 路由
        pub const DNA_RT = 0x6003;
        /// DEC LAT
        pub const LAT = 0x6004;
        /// DEC 诊断
        pub const DIAG = 0x6005;
        /// DEC 客户使用
        pub const CUST = 0x6006;
        /// DEC 系统通信架构
        pub const SCA = 0x6007;
        /// 透明以太网桥接
        pub const TEB = 0x6558;
        /// 反向地址解析数据包
        pub const RARP = 0x8035;
        /// Appletalk 的 DDP
        pub const ATALK = 0x809B;
        /// Appletalk 的 AARP
        pub const AARP = 0x80F3;
        /// 802.1Q VLAN 扩展头
        pub const P_8021Q = 0x8100;
        /// ERSPAN 类型 II
        pub const ERSPAN = 0x88BE;
        /// DIX 上的 IPX
        pub const IPX = 0x8137;
        /// bluebook 上的 IPv6
        pub const IPV6 = 0x86DD;
        /// IEEE 暂停帧。参见 802.3 31B
        pub const PAUSE = 0x8808;
        /// 慢协议。参见 802.3ad 43B
        pub const SLOW = 0x8809;
        /// draft-wilson-wrec-wccp-v2-00.txt 定义的 Web 缓存协调协议
        pub const WCCP = 0x883E;
        /// MPLS 单播流量
        pub const MPLS_UC = 0x8847;
        /// MPLS 组播流量
        pub const MPLS_MC = 0x8848;
        /// ATM 上的多协议
        pub const ATMMPOA = 0x884c;
        /// PPPoE 发现消息
        pub const PPP_DISC = 0x8863;
        /// PPPoE 会话消息
        pub const PPP_SES = 0x8864;
        /// HPNA、无线局域网链路本地隧道
        pub const LINK_CTL = 0x886c;
        /// 基于以太网的基于帧 ATM 传输
        pub const ATMFATE = 0x8884;
        /// 端口访问实体(IEEE 802.1X)
        pub const PAE = 0x888E;
        /// PROFINET
        pub const PROFINET = 0x8892;
        /// 多种专有协议
        pub const REALTEK = 0x8899;
        /// 基于以太网的 ATA
        pub const AOE = 0x88A2;
        /// EtherCAT
        pub const ETHERCAT = 0x88A4;
        /// 802.1ad 服务 VLAN
        pub const @"8021AD" = 0x88A8;
        /// 802.1 本地实验协议 1。
        pub const @"802_EX1" = 0x88B5;
        /// 802.11 预认证
        pub const PREAUTH = 0x88C7;
        /// TIPC
        pub const TIPC = 0x88CA;
        /// 链路层发现协议
        pub const LLDP = 0x88CC;
        /// 介质冗余协议
        pub const MRP = 0x88E3;
        /// 802.1ae MACsec
        pub const MACSEC = 0x88E5;
        /// 802.1ah 骨干网服务标签
        pub const @"8021AH" = 0x88E7;
        /// 802.1Q MVRP
        pub const MVRP = 0x88F5;
        /// IEEE 1588 时间同步
        pub const @"1588" = 0x88F7;
        /// NCSI 协议
        pub const NCSI = 0x88F8;
        /// IEC 62439-3 PRP/HSRv0
        pub const PRP = 0x88FB;
        /// 连通性故障管理
        pub const CFM = 0x8902;
        /// 基于以太网的光纤通道
        pub const FCOE = 0x8906;
        /// 基于以太网的 InfiniBand
        pub const IBOE = 0x8915;
        /// TDLS
        pub const TDLS = 0x890D;
        /// FCoE 初始化协议
        pub const FIP = 0x8914;
        /// IEEE 802.21 媒体无关切换协议。
        pub const @"80221" = 0x8917;
        /// IEC 62439-3 的 HSRv1
        pub const HSR = 0x892F;
        /// 网络服务头
        pub const NSH = 0x894F;
        /// 以太网回环数据包,遵循 IEEE 802.3
        pub const LOOPBACK = 0x9000;
        /// 已弃用的 QinQ VLAN [非正式注册标识]
        pub const QINQ1 = 0x9100;
        /// 已弃用的 QinQ VLAN [非正式注册标识]
        pub const QINQ2 = 0x9200;
        /// 已弃用的 QinQ VLAN [非正式注册标识]
        pub const QINQ3 = 0x9300;
        /// 以太网类型 DSA[非正式注册 ID]。
        pub const EDSA = 0xDADA;
        /// 用于 DSA 的伪 VLAN 头部[非正式注册的 ID]
        pub const DSA_8021Q = 0xDADB;
        /// A5PSW 标签值[非正式注册的 ID]
        pub const DSA_A5PSW = 0xE001;
        /// ForCES FE 间 LFB 类型
        pub const IFE = 0xED3E;
        /// IBM af_iucv [非正式注册标识]
        pub const AF_IUCV = 0xFBFB;
        /// 如果以太网类型字段的值大于此值,则该帧为 Ethernet II;否则为 802.3。
        pub const @"802_3_MIN" = 0x0600;

        // 非 DIX 类型。不会与 1500 类型冲突。

        /// 802.3 帧的虚拟类型
        pub const @"802_3" = 0x0001;
        /// AX.25 的占位协议标识
        pub const AX25 = 0x0002;
        /// 每个数据包(务必谨慎!!!)
        pub const ALL = 0x0003;
        /// 802.2 帧
        pub const @"802_2" = 0x0004;
        /// 仅供内部使用
        pub const SNAP = 0x0005;
        /// DEC DDCMP:仅供内部使用
        pub const DDCMP = 0x0006;
        /// WAN PPP 帧的占位类型
        pub const WAN_PPP = 0x0007;
        /// PPP MP 帧的虚拟类型
        pub const PPP_MP = 0x0008;
        /// Localtalk 伪类型
        pub const LOCALTALK = 0x0009;
        /// CAN:控制器局域网
        pub const CAN = 0x000C;
        /// CANFD:CAN 灵活数据速率
        pub const CANFD = 0x000D;
        /// CANXL:扩展帧长度
        pub const CANXL = 0x000E;
        /// PPP 上 Atalk 的虚拟类型
        pub const PPPTALK = 0x0010;
        /// 802.2 帧
        pub const TR_802_2 = 0x0011;
        /// Mobitex(kaz@cafe.net)
        pub const MOBITEX = 0x0015;
        /// 网卡专用控制帧
        pub const CONTROL = 0x0016;
        /// Linux-IrDA
        pub const IRDA = 0x0017;
        /// Acorn Econet
        pub const ECONET = 0x0018;
        /// HDLC 帧
        pub const HDLC = 0x0019;
        /// ArcNet 对应 1A :-)
        pub const ARCNET = 0x001A;
        /// 分布式交换机架构
        pub const DSA = 0x001B;
        /// Trailer switch 标记
        pub const TRAILER = 0x001C;
        /// Nokia Phonet 帧
        pub const PHONET = 0x00F5;
        /// IEEE802.15.4 帧
        pub const IEEE802154 = 0x00F6;
        /// ST-Ericsson CAIF 协议
        pub const CAIF = 0x00F7;
        /// 多路复用 DSA 协议
        pub const XDSA = 0x00F8;
        /// Qualcomm 多路复用及聚合协议。
        pub const MAP = 0x00F9;
        /// 管理组件传输协议数据包
        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 {
    // 带双下划线前缀的条目不受支持,因此未转换。

    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,
    // Linux 内核头文件 time.h 中有以下注释:
    // * 实现此功能的驱动已删除。保留时钟 ID 作为
    // * 占位符,不得复用!
    // 因此,使用这些 ID 调用 clock_gettime() 会返回错误。
    //
    // 一些背景:
    // - SGI_CYCLE 面向 Silicon Graphics(SGI)工作站,
    // 这些工作站可能已不再使用,因此禁用是合理的。
    // - TAI_CLOCK 设计为 CLOCK_REALTIME(UTC) + tai_offset,
    // 但内核中的 tai_offset 始终为 0,
    // 因此使用此时钟没有意义。
    // SGI_CYCLE = 10,
    // TAI = 11,
    _,
};

// 用于 posix.timerfd_create()。
// 实际上,timerfd_create() 函数的参数是整数,
// 这意味着开发者必须自行判断合适的取值。
// 为简化这一过程,尤其为提高安全性
// (错误的值会导致 panic),这里引入枚举,
// 仅允许实际可用的值。
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;

    // clone3() 系统调用的标志。

    /// 清除所有信号处理器,并重置为 SIG_DFL。
    pub const CLEAR_SIGHAND = 0x100000000;
    /// 具有相应权限时,克隆到指定 cgroup。
    pub const INTO_CGROUP = 0x200000000;

    // 克隆标志与 CSIGNAL 重叠,因此只能用于 unshare 和 clone3 系统调用。

    /// 新的时间命名空间
    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,
        /// 与 `IGNORE` 互斥
        IGNORED_MASK: bool = false,
        IGNORED_SURV_MODIFY: bool = false,
        FLUSH: bool = false,
        FILESYSTEM: bool = false,
        EVICTABLE: bool = false,
        /// 与 `IGNORED_MASK` 互斥
        IGNORE: bool = false,
        _: u21 = 0,
    };

    pub const MarkMask = packed struct(u64) {
        /// 文件已被访问
        ACCESS: bool = false,
        /// 文件已修改
        MODIFY: bool = false,
        /// 元数据已更改
        ATTRIB: bool = false,
        /// 可写文件已关闭
        CLOSE_WRITE: bool = false,
        /// 不可写文件已关闭
        CLOSE_NOWRITE: bool = false,
        /// 文件已打开
        OPEN: bool = false,
        /// 文件从 X 移出
        MOVED_FROM: bool = false,
        /// 文件被移动至 Y
        MOVED_TO: bool = false,

        /// 已创建子文件
        CREATE: bool = false,
        /// 子文件已删除
        DELETE: bool = false,
        /// 自身已被删除
        DELETE_SELF: bool = false,
        /// 自身已被移动
        MOVE_SELF: bool = false,
        /// 文件以执行方式打开
        OPEN_EXEC: bool = false,
        reserved13: u1 = 0,
        /// 事件队列溢出
        Q_OVERFLOW: bool = false,
        /// 文件系统错误
        FS_ERROR: bool = false,

        /// 权限检查中的文件打开
        OPEN_PERM: bool = false,
        /// 权限检查中访问了文件
        ACCESS_PERM: bool = false,
        /// 权限检查中的文件打开/执行
        OPEN_EXEC_PERM: bool = false,
        reserved19: u8 = 0,
        /// 关注子事件
        EVENT_ON_CHILD: bool = false,
        /// 文件已重命名
        RENAME: bool = false,
        reserved30: u1 = 0,
        /// 事件发生在目录上
        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,
    };

    /// 唯一文件标识符信息记录。
    ///
    /// 此结构体用于 `EVENT_INFO_TYPE.FID`、
    /// `EVENT_INFO_TYPE.DFID` 和 `EVENT_INFO_TYPE.DFID_NAME` 类型的记录。
    ///
    /// 对于 `EVENT_INFO_TYPE.DFID_NAME`,文件句柄之后还紧跟一个
    /// 以空字符结尾的名称。
    pub const event_info_fid = extern struct {
        hdr: event_info_header,
        fsid: kernel_fsid_t,
        /// 后面是不透明结构体 file_handle,可作为
        /// 参数传给 open_by_handle_at(2)。
        handle: [0]u8,
    };

    /// 跟随事件元数据的变长信息记录。
    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;
};

/// 供 `rt_sigaction` 系统调用使用的内核 sigaction 结构体。
/// 在用户空间负责连接 `rt_sigreturn` 的目标上包含 `restorer`。
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,
    },
};

/// 用于实际 ABI `k_sigaction` 的内核 Sigaction 包装器。
/// Zig 的 linux.zig 包装库仍会对 sigaction() 调用
/// 进行一些预处理,以添加 `restorer` 字段。
///
/// 从 `sigaction` 改名为 `Sigaction`,避免与系统调用冲突。
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 套接字地址
    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 套接字地址
    pub const in6 = extern struct {
        family: sa_family_t = AF.INET6,
        port: in_port_t,
        flowinfo: u32,
        addr: [16]u8,
        scope_id: u32,
    };

    /// UNIX 域套接字地址
    pub const un = extern struct {
        family: sa_family_t = AF.UNIX,
        path: [108]u8,
    };

    /// 分组套接字地址
    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 套接字地址
    pub const nl = extern struct {
        family: sa_family_t = AF.NETLINK,
        __pad1: c_ushort = 0,

        /// 端口 ID
        pid: u32,

        /// 多播组掩码
        groups: u32,
    };

    pub const xdp = extern struct {
        family: u16 = AF.XDP,
        flags: u16,
        ifindex: u32,
        queue_id: u32,
        shared_umem_fd: u32,
    };

    /// vSockets 的地址结构
    pub const vm = extern struct {
        family: sa_family_t = AF.VSOCK,
        reserved1: u16 = 0,
        port: u32,
        cid: u32,
        flags: u8,

        /// 此结构的总大小应与 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 {
    // 这些值在磁盘上
    // 都必须采用小端字节序。
    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,

    // 若返回的事件对应被监视目录内的目录或文件,
    // 则返回该目录/文件的名称;
    // 若对应被监视的目录/文件本身,则返回 `null`。
    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 的 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
pub const IORING_SETUP_IOPOLL = 1 << 0;

/// SQ 轮询线程
pub const IORING_SETUP_SQPOLL = 1 << 1;

/// sq_thread_cpu 有效
pub const IORING_SETUP_SQ_AFF = 1 << 2;

/// 应用程序定义 CQ 大小
pub const IORING_SETUP_CQSIZE = 1 << 3;

/// 限制 SQ/CQ 环大小
pub const IORING_SETUP_CLAMP = 1 << 4;

/// 附加到现有 wq
pub const IORING_SETUP_ATTACH_WQ = 1 << 5;

/// 从禁用环开始
pub const IORING_SETUP_R_DISABLED = 1 << 6;

/// 发生错误时继续提交
pub const IORING_SETUP_SUBMIT_ALL = 1 << 7;

/// 协作式任务执行。请求完成时,往往需要
/// 强制提交方进入内核来完成处理。如果设置此
/// 标志,则等任务本来就要进入内核时再处理,
/// 而不是强制通过处理器间中断重新调度。这样避免中断
/// 正在用户空间运行的任务,并节省一次 IPI。
pub const IORING_SETUP_COOP_TASKRUN = 1 << 8;

/// 若设置 COOP_TASKRUN,则在存在可运行任务工作且需要进入内核才能运行时
/// 获得通知。这会在 SQ 环标志中设置 IORING_SQ_TASKRUN。
/// 不能与 COOP_TASKRUN 一起使用(原文条件如此)。
pub const IORING_SETUP_TASKRUN_FLAG = 1 << 9;

/// SQE 为 128 字节
pub const IORING_SETUP_SQE128 = 1 << 10;
/// CQE 为 32 字节
pub const IORING_SETUP_CQE32 = 1 << 11;

/// 仅允许一个任务提交请求
pub const IORING_SETUP_SINGLE_ISSUER = 1 << 12;

/// 延迟执行任务工作以获取事件。
/// 不在任务每次状态转换时执行部分任务工作,
/// 而尽量延迟到即将需要时再执行。
pub const IORING_SETUP_DEFER_TASKRUN = 1 << 13;

/// 应用程序提供环内存
pub const IORING_SETUP_NO_MMAP = 1 << 14;

/// 将环的文件描述符注册到自身,供
/// IORING_REGISTER_USE_REGISTERED_RING 使用;返回已注册文件描述符索引,
/// 而非文件描述符。
pub const IORING_SETUP_REGISTERED_FD_ONLY = 1 << 15;

/// 消除通过 SQ 索引数组的间接访问。
pub const IORING_SETUP_NO_SQARRAY = 1 << 16;

/// I/O 提交数据结构(提交队列条目)
pub const io_uring_sqe = @import("linux/io_uring_sqe.zig").io_uring_sqe;

pub const IoUring = @import("linux/IoUring.zig");

/// 对于会创建新直接描述符的操作码,例如 openat、openat2、accept,若 sqe->file_index 设为此值,则 io_uring 分配一个可用的直接描述符,而无需应用程序传入。
/// 选中的直接描述符通过 cqe->res 返回;若空间已满,则返回 -ENFILE。
/// 自 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

/// 使用固定文件集
pub const IOSQE_FIXED_FILE = 1 << @backingInt(IOSQE_BIT.FIXED_FILE);

/// 在执行中的 IO 之后发出
pub const IOSQE_IO_DRAIN = 1 << @backingInt(IOSQE_BIT.IO_DRAIN);

/// 链接下一个 sqe
pub const IOSQE_IO_LINK = 1 << @backingInt(IOSQE_BIT.IO_LINK);

/// 类似 LINK,但约束更强
pub const IOSQE_IO_HARDLINK = 1 << @backingInt(IOSQE_BIT.IO_HARDLINK);

/// 始终异步执行
pub const IOSQE_ASYNC = 1 << @backingInt(IOSQE_BIT.ASYNC);

/// 从 buf_group 选择缓冲区
pub const IOSQE_BUFFER_SELECT = 1 << @backingInt(IOSQE_BIT.BUFFER_SELECT);

/// 请求成功时不提交 CQE
/// 自 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(Zig 结构体中的 rw_flags)

/// 使用已注册缓冲区;传递此标志并同时设置 sqe->buf_index。
pub const IORING_URING_CMD_FIXED = 1 << 0;

// io_uring_sqe.fsync_flags(Zig 结构体中的 rw_flags)。
pub const IORING_FSYNC_DATASYNC = 1 << 0;

// io_uring_sqe.timeout_flags(Zig 结构体中的 rw_flags)
pub const IORING_TIMEOUT_ABS = 1 << 0;
pub const IORING_TIMEOUT_UPDATE = 1 << 1; // 自 Linux 5.11 起可用
pub const IORING_TIMEOUT_BOOTTIME = 1 << 2; // 自 Linux 5.15 起可用
pub const IORING_TIMEOUT_REALTIME = 1 << 3; // 自 Linux 5.15 起可用
pub const IORING_LINK_TIMEOUT_UPDATE = 1 << 4; // 自 Linux 5.15 起可用
pub const IORING_TIMEOUT_ETIME_SUCCESS = 1 << 5; // 自 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(Zig 结构体中的 rw_flags)
// 扩展 splice(2) 的标志
pub const IORING_SPLICE_F_FD_IN_FIXED = 1 << 31;

// POLL_ADD 标志。
// 注意,sqe->poll_events(Zig 结构体中的 rw_flags)用于标志,因此 POLL_ADD 的命令标志存储在 sqe->len 中。

/// 多次触发 poll。若 poll 处理程序将继续代表同一个 SQE 报告 CQE,则设置 IORING_CQE_F_MORE。
pub const IORING_POLL_ADD_MULTI = 1 << 0;
/// 更新现有轮询请求,以 sqe->addr 匹配旧的 user_data 字段。
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 标志。

/// 取消所有与给定键匹配的请求
pub const IORING_ASYNC_CANCEL_ALL = 1 << 0;
/// 根据 'fd' 而不是请求的 'user_data' 执行取消。
pub const IORING_ASYNC_CANCEL_FD = 1 << 1;
/// 匹配任意请求
pub const IORING_ASYNC_CANCEL_ANY = 1 << 2;
/// 传入的 'fd' 为固定描述符。自 Linux 6.0 起可用
pub const IORING_ASYNC_CANCEL_FD_FIXED = 1 << 3;

// send/sendmsg 和 recv/recvmsg 标志(sqe->ioprio)

/// 设置后,提前设置 poll 并跳过初次传输尝试,
/// 而非先尝试发送或接收,再在结果为 -EAGAIN 时设置 poll。
pub const IORING_RECVSEND_POLL_FIRST = 1 << 0;
/// 多次接收。若处理器将继续为同一 SQE 报告 CQE,则设置 IORING_CQE_F_MORE。
pub const IORING_RECV_MULTISHOT = 1 << 1;
/// 使用已注册缓冲区,索引存储于 buf_index 字段。
pub const IORING_RECVSEND_FIXED_BUF = 1 << 2;
/// 若设置,SEND[MSG]_ZC 应在 IORING_CQE_F_NOTIF 完成事件的 cqe.res 中报告零拷贝使用情况。
pub const IORING_SEND_ZC_REPORT_USAGE = 1 << 3;
/// 若设置,send 或 recv 会从指定缓冲区组标识中取得尽可能多的缓冲区,并全部发送。
/// 完成结果为已发送的缓冲区数量,CQE 仍按通常方式包含起始缓冲区标识。
/// 这些缓冲区从起始标识起连续排列。
/// 与 IOSQE_BUFFER_SELECT 配合使用。
pub const IORING_RECVSEND_BUNDLE = 1 << 4;
/// 请求 IORING_SEND_ZC_REPORT_USAGE 时,IORING_CQE_F_NOTIF 对应的 CQE.RES。
pub const IORING_NOTIF_USAGE_ZC_COPIED = 1 << 31;

/// accept 标志存于 sqe->iopri
pub const IORING_ACCEPT_MULTISHOT = 1 << 0;

/// IORING_OP_MSG_RING 命令类型,存储于 sqe->addr
pub const IORING_MSG_RING_COMMAND = enum(u8) {
    /// 将 sqe->len 作为 'res'、off 作为 user_data 传入
    DATA = 0,
    /// 将已注册的文件描述符发送到另一个 ring
    SEND_FD = 1,
    _,
};

// io_uring_sqe.msg_ring_flags(Zig 结构体中的 rw_flags)。

/// 不向目标环提交 CQE。显然不适用于 IORING_MSG_DATA。
pub const IORING_MSG_RING_CQE_SKIP = 1 << 0;

/// 将 sqe->file_index(Zig 结构体中的 splice_fd_in)的标志传递给 cqe->flags */
pub const IORING_MSG_RING_FLAGS_PASS = 1 << 1;

// I/O 完成数据结构(完成队列条目)
pub const io_uring_cqe = extern struct {
    /// 原样回传提交的 io_uring_sqe.data
    user_data: u64,

    /// 此事件的结果代码
    res: i32,
    flags: u32,

    // 使用 IORING_SETUP_CQE32 初始化时,后跟 16 字节填充,使 cqe 大小加倍

    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;
    }

    // 所提供缓冲区的 IO 请求成功完成后,CQE 的 flags 字段
    // 将设置 IORING_CQE_F_BUFFER,所选缓冲区标识则由
    // flags 字段的高 16 位给出。
    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

/// 若置位,高 16 位为缓冲区标识符
pub const IORING_CQE_F_BUFFER = 1 << 0;
/// 若设置,则父 SQE 将生成更多 CQE 条目。
/// 自 Linux 5.13 起可用。
pub const IORING_CQE_F_MORE = 1 << 1;
/// 若设置,套接字接收后仍有更多数据可读
pub const IORING_CQE_F_SOCK_NONEMPTY = 1 << 2;
/// 对通知 CQE 设置此标志,可据此与发送完成事件区分。
pub const IORING_CQE_F_NOTIF = 1 << 3;
/// 若设置,则完成事件中指定的缓冲区 ID 还将收到更多完成事件。
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;

/// 供应用程序通过 mmap 映射所需数据的特定偏移量
pub const IORING_OFF_SQ_RING = 0;
pub const IORING_OFF_CQ_RING = 0x8000000;
pub const IORING_OFF_SQES = 0x10000000;

/// 填入 mmap(2) 的偏移量
pub const io_sqring_offsets = extern struct {
    /// 环头部的偏移量
    head: u32,

    /// 环形队列尾部的偏移
    tail: u32,

    /// 环掩码值
    ring_mask: u32,

    /// 环形队列中的条目
    ring_entries: u32,

    /// 环标志
    flags: u32,

    /// 未提交的 sqe 数量
    dropped: u32,

    /// sqe 索引数组
    array: u32,

    resv1: u32,
    user_addr: u64,
};

// io_sqring_offsets.flags

/// 需要 io_uring_enter 唤醒
pub const IORING_SQ_NEED_WAKEUP = 1 << 0;
/// 内核中有超出 cq 环容量的待处理 cqe
pub const IORING_SQ_CQ_OVERFLOW = 1 << 1;
/// 任务应进入内核
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

/// 禁用 eventfd 通知
pub const IORING_CQ_EVENTFD_DISABLED = 1 << 0;

// io_uring_enter 标志
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 标志

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 操作码和参数
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,

    // 通过标签机制扩展
    REGISTER_FILES2,
    REGISTER_FILES_UPDATE2,
    REGISTER_BUFFERS2,
    REGISTER_BUFFERS_UPDATE,

    // 设置或清除 io-wq 线程亲和性
    REGISTER_IOWQ_AFF,
    UNREGISTER_IOWQ_AFF,

    // 设置或获取 io-wq 工作线程的最大数量
    REGISTER_IOWQ_MAX_WORKERS,

    // 向环注册或注销 io_uring 文件描述符
    REGISTER_RING_FDS,
    UNREGISTER_RING_FDS,

    // 注册基于环形队列的缓冲区提供组
    REGISTER_PBUF_RING,
    UNREGISTER_PBUF_RING,

    // 同步取消 API
    REGISTER_SYNC_CANCEL,

    // 为自动槽分配注册一段固定文件槽
    REGISTER_FILE_ALLOC_RANGE,

    // 返回缓冲区组的状态信息
    REGISTER_PBUF_STATUS,

    // 设置或清除忙轮询设置
    REGISTER_NAPI,
    UNREGISTER_NAPI,

    REGISTER_CLOCK,

    // 将已注册缓冲区从源环克隆到当前环。
    REGISTER_CLONE_BUFFERS,

    // 没有环时发送 MSG_RING
    REGISTER_SEND_MSG_RING,

    // 为零复制注册网络设备的硬件接收队列
    REGISTER_ZCRX_IFQ,

    // 调整 CQ 环形队列大小
    REGISTER_RESIZE_RINGS,

    REGISTER_MEM_REGION,

    // 添加到操作码的标志,用于使用已注册的环 fd
    REGISTER_USE_REGISTERED_RING = 1 << 31,

    _,
};

/// io_uring_restriction->opcode 的取值
pub const IOWQ_CATEGORIES = enum(u8) {
    BOUND,
    UNBOUND,
};

/// 已弃用,参见 struct io_uring_rsrc_update
pub const io_uring_files_update = extern struct {
    offset: u32,
    resv: u32,
    fds: u64,
};

/// 注册完全稀疏的文件空间,无需传入元素全为 -1 的文件描述符数组。
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,
};

/// 跳过更新 fd 表中设置为此值的 fd 索引 */
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: 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_op: IORING_OP,
    /// 下方 ops[] 数组的长度
    ops_len: u8,
    resv: u16,
    resv2: [3]u32,
    ops: [256]io_uring_probe_op,

    /// 当前运行的内核是否支持此操作。
    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 的取值
pub const IORING_RESTRICTION = enum(u16) {
    /// 允许某个 io_uring_register(2) 操作码
    REGISTER_OP = 0,

    /// 允许某个 sqe 操作码
    SQE_OP = 1,

    /// 允许 sqe 标志
    SQE_FLAGS_ALLOWED = 2,

    /// 要求的 SQE 标志(每次提交时都必须设置这些标志)。
    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,
};

/// 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,
        /// 增量消耗缓冲区。
        inc: bool,
        _: u14 = 0,
    };
};

pub const io_uring_getevents_arg = extern struct {
    sigmask: u64,
    sigmask_sz: u32,
    pad: u32,
    ts: u64,
};

/// 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,
};

/// IORING_REGISTER_FILE_ALLOC_RANGE 的参数。
/// 范围指定为 [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) {
    /// 需要 `mode & S.IFMT`。
    TYPE: bool = false,
    /// 需要 `mode & ~S.IFMT`。
    MODE: bool = false,
    /// 需要 `nlink` 成员。
    NLINK: bool = false,
    /// 需要 `uid` 成员。
    UID: bool = false,
    /// 需要 `gid` 成员。
    GID: bool = false,
    /// 需要 `atime` 成员。
    ATIME: bool = false,
    /// 需要 `mtime` 成员。
    MTIME: bool = false,
    /// 需要 `ctime` 成员。
    CTIME: bool = false,
    /// 需要 `ino` 成员。
    INO: bool = false,
    /// 需要 `size` 成员。
    SIZE: bool = false,
    /// 需要 `blocks` 成员。
    BLOCKS: bool = false,
    /// 需要 `btime` 成员。
    BTIME: bool = false,
    /// 需要 `mnt_id` 成员。
    MNT_ID: bool = false,
    /// 需要 `dio_mem_align` 和 `dio_offset_align` 成员。
    DIOALIGN: bool = false,
    /// 请求 `stx_mnt_id` 成员。
    MNT_ID_UNIQUE: bool = false,
    /// 需要 `sub` 成员。
    SUBVOL: bool = false,
    /// 需要 `atomic_write_unit_min`、`atomic_write_unit_max` 和
    /// `atomic_write_segments_max` 成员。
    WRITE_ATOMIC: bool = false,
    /// 需要 `dio_read_offset_align` 成员。
    DIO_READ_ALIGN: bool = false,
    __pad: u13 = 0,
    /// 保留供将来扩展;不得设置。
    __RESERVED: bool = false,

    pub const BASIC_STATS: STATX = @bitCast(@as(u32, 0x7ff));
};

/// 以位掩码形式表示文件状态或特征的属性。
/// 标有 [I] 的标志在语义上对应 `FS_IOC_SETFLAGS` 的值。
/// 更多信息参见 [FS_IOC_SETFLAGS(2const)](https://man7.org/linux/man-pages/man2/FS_IOC_GETFLAGS.2const.html)。
///
pub const STATX_ATTR = packed struct(u64) {
    __pad1: u3 = 0,
    /// [I] 文件被文件系统压缩。
    COMPRESSED: bool = false,
    __pad2: u1 = 0,
    /// [I] 文件被标记为不可变。
    IMMUTABLE: bool = false,
    /// [I] 文件仅允许追加。
    APPEND: bool = false,
    /// [I] 不应转储此文件。
    NODUMP: bool = false,
    /// [I] 文件系统中此文件需要密钥才能解密。
    ENCRYPTED: bool = false,
    /// 文件所命名的目录会触发自动挂载。
    AUTOMOUNT: bool = false,
    /// 文件指向挂载点的根。
    MOUNT_ROOT: bool = false,
    /// [I] 文件受 `dm-verity` 设备保护。
    VERITY: bool = false,
    /// 文件当前处于 CPU 直接访问状态。
    /// 不对应某些文件系统支持的逐 inode DAX 标志。
    DAX: bool = false,
    /// 文件支持原子写操作。
    WRITE_ATOMIC: bool = false,
    __pad3: u50 = 0,
};

pub const statx_timestamp = extern struct {
    /// 相对于 `1970-01-01T00:00:00Z` 前后相差的秒数。
    sec: i64,
    /// `sec` 之后的纳秒数(0..999,999,999)。
    nsec: u32,
    // 保留供将来提高分辨率使用。
    __pad1: u32,
};

/// 重命名为 `Statx`,以避免与 `statx` 函数冲突。
pub const Statx = extern struct {
    /// 指示已填充字段的位掩码。根据内核实际返回的
    /// 信息更新。调用者必须检查此字段,因为支持情况
    /// 随内核版本和文件系统而异。
    mask: STATX,
    /// 文件系统 I/O 的块大小。
    blksize: u32,
    /// 额外文件属性指示符。
    attributes: STATX_ATTR,
    /// 硬链接数量。
    nlink: u32,
    /// 所有者的用户标识。
    uid: uid_t,
    /// 所有者的组 ID。
    gid: gid_t,
    /// 文件类型和模式。
    mode: u16,
    __spare0: u16,
    /// inode 编号。
    ino: u64,
    /// 总大小,单位为字节。
    size: u64,
    /// 已分配的 512B 块数。
    blocks: u64,
    /// 用于显示 `attributes` 中受支持项目的掩码。
    attributes_mask: STATX_ATTR,
    /// 文件的最后访问时间戳。
    atime: statx_timestamp,
    /// 文件创建时间戳。
    btime: statx_timestamp,
    /// 文件最后一次状态更改时间戳。
    ctime: statx_timestamp,
    /// 文件最后修改时间戳。
    mtime: statx_timestamp,
    /// 若此文件表示设备,则为主设备号。
    rdev_major: u32,
    /// 若此文件表示设备,则为次设备号。
    rdev_minor: u32,
    /// 包含此文件所在文件系统的设备的主设备号。
    dev_major: u32,
    /// 包含此文件所在文件系统的设备的次设备号。
    dev_minor: u32,
    /// 挂载 ID
    mnt_id: u64,
    /// 直接输入输出所需的内存缓冲区对齐。
    dio_mem_align: u32,
    /// 直接输入输出所需的文件偏移量对齐。
    dio_offset_align: u32,
    /// 子卷标识符。
    subvol: u64,
    /// 最小原子写入单位,单位为字节。
    atomic_write_unit_min: u32,
    /// 最大原子写入单元,单位为字节。
    atomic_write_unit_max: u32,
    /// 原子写入的最大分段数。
    atomic_write_segments_max: u32,
    /// 直接 I/O 读取的文件偏移对齐要求。
    dio_read_offset_align: u32,
    /// 优化后的最大原子写入单元,单位为字节。
    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,
};

/// 从客户端角度解释 fastopen 失败的原因
pub const tcp_fastopen_client_fail = enum {
    /// 兜底分支
    TFO_STATUS_UNSPEC,
    /// 不处于 TFO_CLIENT_NO_COOKIE 模式时
    TFO_COOKIE_UNAVAILABLE,
    /// SYN-ACK 未确认 SYN 数据
    TFO_DATA_NOT_ACKED,
    /// 超时后 SYN-ACK 仍未确认 SYN 数据
    TFO_SYN_RETRANSMITTED,
};

/// 用于 TCP_INFO 套接字选项
pub const TCPI_OPT_TIMESTAMPS = 1;
pub const TCPI_OPT_SACK = 2;
pub const TCPI_OPT_WSCALE = 4;
/// ECN 已在 TCP 会话初始化时协商
pub const TCPI_OPT_ECN = 8;
/// 已接收到至少一个带 ECT 的数据包
pub const TCPI_OPT_ECN_SEEN = 16;
/// SYN-ACK 已确认所发送或接收 SYN 中的数据
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;

/// `termios` 结构体中 `cc` 数组的索引。
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 专用套接字 ioctl
pub const SIOCINQ = T.FIONREAD;

/// Linux 专用套接字 ioctl。
/// 输出队列大小(未发送 + 未确认)。
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);

/// 获取时间戳(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);

/// 获取时间戳(timespec)
pub const SIOCGSTAMPNS = if (native_arch == .x86_64 or @sizeOf(timespec) == 8) SIOCGSTAMPNS_OLD else SIOCGSTAMPNS_NEW;

// 路由表调用。
/// 添加路由表项
pub const SIOCADDRT = 0x890B;

/// 删除路由表条目
pub const SIOCDELRT = 0x890C;

/// 未使用
pub const SIOCRTMSG = 0x890D;

// 套接字配置控制项。
/// 获取接口名称
pub const SIOCGIFNAME = 0x8910;

/// 设置接口通道
pub const SIOCSIFLINK = 0x8911;

/// 获取接口列表
pub const SIOCGIFCONF = 0x8912;

/// 获取标志
pub const SIOCGIFFLAGS = 0x8913;

/// 设置标志
pub const SIOCSIFFLAGS = 0x8914;

/// 获取 PA 地址
pub const SIOCGIFADDR = 0x8915;

/// 设置 PA 地址
pub const SIOCSIFADDR = 0x8916;

/// 获取远程 PA 地址
pub const SIOCGIFDSTADDR = 0x8917;

/// 设置远端 PA 地址
pub const SIOCSIFDSTADDR = 0x8918;

/// 获取广播 PA 地址
pub const SIOCGIFBRDADDR = 0x8919;

/// 设置广播 PA 地址
pub const SIOCSIFBRDADDR = 0x891a;

/// 获取网络 PA 掩码
pub const SIOCGIFNETMASK = 0x891b;

/// 设置网络 PA 掩码
pub const SIOCSIFNETMASK = 0x891c;

/// 获取度量值
pub const SIOCGIFMETRIC = 0x891d;

/// 设置度量值
pub const SIOCSIFMETRIC = 0x891e;

/// 获取内存地址(BSD)
pub const SIOCGIFMEM = 0x891f;

/// 设置内存地址(BSD)
pub const SIOCSIFMEM = 0x8920;

/// 获取 MTU 大小
pub const SIOCGIFMTU = 0x8921;

/// 设置 MTU 大小
pub const SIOCSIFMTU = 0x8922;

/// 设置接口名称
pub const SIOCSIFNAME = 0x8923;

/// 设置硬件地址
pub const SIOCSIFHWADDR = 0x8924;

/// 获取封装方式
pub const SIOCGIFENCAP = 0x8925;

/// 设置封装
pub const SIOCSIFENCAP = 0x8926;

/// 获取硬件地址
pub const SIOCGIFHWADDR = 0x8927;

/// 驱动程序从属关系支持
pub const SIOCGIFSLAVE = 0x8929;

/// 驱动程序从属关系支持
pub const SIOCSIFSLAVE = 0x8930;

/// 添加到多播地址列表
pub const SIOCADDMULTI = 0x8931;

/// 从多播地址列表中删除
pub const SIOCDELMULTI = 0x8932;

/// name -> if_index 映射
pub const SIOCGIFINDEX = 0x8933;

/// 设置扩展标志集
pub const SIOCSIFPFLAGS = 0x8934;

/// 获取已设置的扩展标志
pub const SIOCGIFPFLAGS = 0x8935;

/// 删除 PA 地址
pub const SIOCDIFADDR = 0x8936;

/// 设置硬件广播地址
pub const SIOCSIFHWBROADCAST = 0x8937;

/// 获取设备数量
pub const SIOCGIFCOUNT = 0x8938;

/// 桥接支持
pub const SIOCGIFBR = 0x8940;

/// 设置桥接选项
pub const SIOCSIFBR = 0x8941;

/// 获取发送队列长度
pub const SIOCGIFTXQLEN = 0x8942;

/// 设置发送队列长度
pub const SIOCSIFTXQLEN = 0x8943;

/// Ethtool 接口
pub const SIOCETHTOOL = 0x8946;

/// 获取当前使用的 MII PHY 地址。
pub const SIOCGMIIPHY = 0x8947;

/// 读取 MII PHY 寄存器。
pub const SIOCGMIIREG = 0x8948;

/// 写入 MII PHY 寄存器。
pub const SIOCSMIIREG = 0x8949;

/// 获取/设置网络设备参数
pub const SIOCWANDEV = 0x894A;

/// 输出队列大小(不仅包括尚未发送的内容)
pub const SIOCOUTQNSD = 0x894B;

/// 获取套接字的网络命名空间
pub const SIOCGSKNS = 0x894C;

// ARP 缓存控制调用。
//  0x8950 - 0x8952 为已废弃调用。
/// 删除 ARP 表条目
pub const SIOCDARP = 0x8953;

/// 获取 ARP 表条目
pub const SIOCGARP = 0x8954;

/// 设置 ARP 表项
pub const SIOCSARP = 0x8955;

// RARP 缓存控制调用。
/// 删除 RARP 表条目
pub const SIOCDRARP = 0x8960;

/// 获取 RARP 表条目
pub const SIOCGRARP = 0x8961;

/// 设置 RARP 表项
pub const SIOCSRARP = 0x8962;

// 驱动程序配置调用
/// 获取设备参数
pub const SIOCGIFMAP = 0x8970;

/// 设置设备参数
pub const SIOCSIFMAP = 0x8971;

// DLCI 配置调用
/// 创建新的 DLCI 设备
pub const SIOCADDDLCI = 0x8980;

/// 删除 DLCI 设备
pub const SIOCDELDLCI = 0x8981;

/// 802.1Q VLAN 支持
pub const SIOCGIFVLAN = 0x8982;

/// 设置 802.1Q VLAN 选项
pub const SIOCSIFVLAN = 0x8983;

// 绑定调用
/// 将设备加入 bond 成为从设备
pub const SIOCBONDENSLAVE = 0x8990;

/// 从绑定中释放从属接口
pub const SIOCBONDRELEASE = 0x8991;

/// 设置绑定的硬件地址
pub const SIOCBONDSETHWADDR = 0x8992;

/// 返回从设备状态信息
pub const SIOCBONDSLAVEINFOQUERY = 0x8993;

/// 返回绑定状态信息
pub const SIOCBONDINFOQUERY = 0x8994;

/// 更新为新的活动从属设备
pub const SIOCBONDCHANGEACTIVE = 0x8995;

// 网桥调用
/// 创建新的网桥设备
pub const SIOCBRADDBR = 0x89a0;

/// 移除网桥设备
pub const SIOCBRDELBR = 0x89a1;

/// 将接口添加到网桥
pub const SIOCBRADDIF = 0x89a2;

/// 从网桥移除接口
pub const SIOCBRDELIF = 0x89a3;

/// 获取硬件时间戳配置
pub const SIOCSHWTSTAMP = 0x89b0;

/// 设置硬件时间戳配置
pub const SIOCGHWTSTAMP = 0x89b1;

/// 设备私有 ioctl 调用
pub const SIOCDEVPRIVATE = 0x89F0;

/// 这 16 个 ioctl 调用为协议私有
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, // 连续块的最小大小
    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,
};

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,
};

// 文档注释复制自 musl
pub const rlimit_resource = if (native_arch.isMIPS()) enum(c_int) {
    /// 每个进程的 CPU 限额,单位为秒。
    CPU = 0,

    /// 可创建文件的最大大小,单位为字节。
    FSIZE = 1,

    /// 数据段最大大小,单位为字节。
    DATA = 2,

    /// 栈段的最大大小,单位为字节。
    STACK = 3,

    /// 可创建的最大核心转储文件大小,以字节表示。
    CORE = 4,

    /// 打开的文件数量。
    NOFILE = 5,

    /// 地址空间限制。
    AS = 6,

    /// 最大常驻集大小,以字节为单位。
    /// 此值影响换页;超过其常驻集大小的
    /// 进程更可能被收回
    /// 物理内存。
    RSS = 7,

    /// 进程数量。
    NPROC = 8,

    /// 锁定在内存中的地址空间。
    MEMLOCK = 9,

    /// 文件锁的最大数量。
    LOCKS = 10,

    /// 待处理信号的最大数量。
    SIGPENDING = 11,

    /// POSIX 消息队列的最大字节数。
    MSGQUEUE = 12,

    /// 允许提升到的最高 nice 优先级。
    /// nice 级别 19 .. -20 对应此资源限制的值 0 .. 39。
    ///
    NICE = 13,

    /// 非特权进程允许的最大实时优先级。
    ///
    RTPRIO = 14,

    /// 实时调度策略下,进程在不执行阻塞系统调用的情况下可消耗的
    /// 最大 CPU 时间(微秒);超过后会被强制取消调度。
    ///
    RTTIME = 15,

    _,
} else if (native_arch.isSPARC()) enum(c_int) {
    /// 每个进程的 CPU 限额,单位为秒。
    CPU = 0,

    /// 可创建文件的最大大小,单位为字节。
    FSIZE = 1,

    /// 数据段最大大小,单位为字节。
    DATA = 2,

    /// 栈段的最大大小,单位为字节。
    STACK = 3,

    /// 可创建的最大核心转储文件大小,以字节表示。
    CORE = 4,

    /// 最大常驻集大小,以字节为单位。
    /// 此值影响换页;超过其常驻集大小的
    /// 进程更可能被收回
    /// 物理内存。
    RSS = 5,

    /// 打开的文件数量。
    NOFILE = 6,

    /// 进程数量。
    NPROC = 7,

    /// 锁定在内存中的地址空间。
    MEMLOCK = 8,

    /// 地址空间限制。
    AS = 9,

    /// 文件锁的最大数量。
    LOCKS = 10,

    /// 待处理信号的最大数量。
    SIGPENDING = 11,

    /// POSIX 消息队列的最大字节数。
    MSGQUEUE = 12,

    /// 允许提升到的最高 nice 优先级。
    /// nice 级别 19 .. -20 对应此资源限制的值 0 .. 39。
    ///
    NICE = 13,

    /// 非特权进程允许的最大实时优先级。
    ///
    RTPRIO = 14,

    /// 实时调度策略下,进程在不执行阻塞系统调用的情况下可消耗的
    /// 最大 CPU 时间(微秒);超过后会被强制取消调度。
    ///
    RTTIME = 15,

    _,
} else if (native_arch == .alpha) enum(c_int) {
    /// 每个进程的 CPU 限额,单位为秒。
    CPU = 0,
    /// 可创建文件的最大大小,单位为字节。
    FSIZE = 1,
    /// 数据段最大大小,单位为字节。
    DATA = 2,
    /// 栈段的最大大小,单位为字节。
    STACK = 3,
    /// 可创建的最大核心转储文件大小,以字节表示。
    CORE = 4,
    /// 最大常驻集大小,以字节为单位。
    /// 此值影响换页;超过其常驻集大小的
    /// 进程更可能被收回
    /// 物理内存。
    RSS = 5,
    /// 打开的文件数量。
    NOFILE = 6,
    /// 地址空间限制。
    AS = 7,
    /// 进程数量。
    NPROC = 8,
    /// 锁定在内存中的地址空间。
    MEMLOCK = 9,
    /// 文件锁的最大数量。
    LOCKS = 10,
    /// 待处理信号的最大数量。
    SIGPENDING = 11,
    /// POSIX 消息队列的最大字节数。
    MSGQUEUE = 12,
    /// 允许提升到的最高 nice 优先级。
    /// nice 级别 19 .. -20 对应此资源限制的值 0 .. 39。
    ///
    NICE = 13,
    /// 非特权进程允许的最大实时优先级。
    ///
    RTPRIO = 14,
    /// 实时调度策略下,进程在不执行阻塞系统调用的情况下可消耗的
    /// 最大 CPU 时间(微秒);超过后会被强制取消调度。
    ///
    RTTIME = 15,

    _,
} else enum(c_int) {
    /// 每个进程的 CPU 限额,单位为秒。
    CPU = 0,
    /// 可创建文件的最大大小,单位为字节。
    FSIZE = 1,
    /// 数据段最大大小,单位为字节。
    DATA = 2,
    /// 栈段的最大大小,单位为字节。
    STACK = 3,
    /// 可创建的最大核心转储文件大小,以字节表示。
    CORE = 4,
    /// 最大常驻集大小,以字节为单位。
    /// 此值影响换页;超过其常驻集大小的
    /// 进程更可能被收回
    /// 物理内存。
    RSS = 5,
    /// 进程数量。
    NPROC = 6,
    /// 打开的文件数量。
    NOFILE = 7,
    /// 锁定在内存中的地址空间。
    MEMLOCK = 8,
    /// 地址空间限制。
    AS = 9,
    /// 文件锁的最大数量。
    LOCKS = 10,
    /// 待处理信号的最大数量。
    SIGPENDING = 11,
    /// POSIX 消息队列的最大字节数。
    MSGQUEUE = 12,
    /// 允许提升到的最高 nice 优先级。
    /// nice 级别 19 .. -20 对应此资源限制的值 0 .. 39。
    ///
    NICE = 13,
    /// 非特权进程允许的最大实时优先级。
    ///
    RTPRIO = 14,
    /// 实时调度策略下,进程在不执行阻塞系统调用的情况下可消耗的
    /// 最大 CPU 时间(微秒);超过后会被强制取消调度。
    ///
    RTTIME = 15,

    _,
};

pub const rlim_t = u64;

pub const RLIM = struct {
    /// 无限制
    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 {
    /// 软限制
    cur: rlim_t,
    /// 硬限制
    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,
};

/// 内核使用的 timespec 结构体。
pub const kernel_timespec = extern struct {
    sec: i64,
    nsec: i64,

    /// 与 `utimensat` 和 `futimens` 配合使用。
    pub const NOW: timespec = .{
        .sec = 0,
        .nsec = 0x3fffffff,
    };

    /// 与 `utimensat` 和 `futimens` 配合使用。
    pub const OMIT: timespec = .{
        .sec = 0,
        .nsec = 0x3ffffffe,
    };
};

/// 与 `utimensat` 和 `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 {
    /// 路由/设备挂钩
    pub const ROUTE = 0;

    /// 未使用的编号
    pub const UNUSED = 1;

    /// 为用户态套接字协议保留
    pub const USERSOCK = 2;

    /// 未使用的编号,原为 ip_queue
    pub const FIREWALL = 3;

    /// 套接字监视
    pub const SOCK_DIAG = 4;

    /// netfilter/iptables 的 ULOG
    pub const NFLOG = 5;

    /// ipsec
    pub const XFRM = 6;

    /// SELinux 事件通知
    pub const SELINUX = 7;

    /// Open-iSCSI
    pub const ISCSI = 8;

    /// 审计
    pub const AUDIT = 9;

    pub const FIB_LOOKUP = 10;

    pub const CONNECTOR = 11;

    /// netfilter 子系统
    pub const NETFILTER = 12;

    pub const IP6_FW = 13;

    /// DECnet 路由消息
    pub const DNRTMSG = 14;

    /// 从内核发送到用户空间的消息
    pub const KOBJECT_UEVENT = 15;

    pub const GENERIC = 16;

    // 为 NETLINK_DM(DM 事件)留出空间

    /// SCSI 传输
    pub const SCSITRANSPORT = 18;

    pub const ECRYPTFS = 19;

    pub const RDMA = 20;

    /// 加密层
    pub const CRYPTO = 21;

    /// SMC 监视
    pub const SMC = 22;
};

// 标志值

/// 它是请求消息。
pub const NLM_F_REQUEST = 0x01;

/// 多部分消息,以 NLMSG_DONE 终止
pub const NLM_F_MULTI = 0x02;

/// 以确认消息回复,附带零或错误码
pub const NLM_F_ACK = 0x04;

/// 回显此请求
pub const NLM_F_ECHO = 0x08;

/// 由于序列更改,转储不一致
pub const NLM_F_DUMP_INTR = 0x10;

/// 转储已按要求过滤
pub const NLM_F_DUMP_FILTERED = 0x20;

// GET 请求修饰标志

/// 指定树根
pub const NLM_F_ROOT = 0x100;

/// 返回所有匹配项
pub const NLM_F_MATCH = 0x200;

/// 原子 GET
pub const NLM_F_ATOMIC = 0x400;
pub const NLM_F_DUMP = NLM_F_ROOT | NLM_F_MATCH;

// NEW 请求的修饰符

/// 覆盖现有内容
pub const NLM_F_REPLACE = 0x100;

/// 如果存在则不要触碰
pub const NLM_F_EXCL = 0x200;

/// 不存在时创建
pub const NLM_F_CREATE = 0x400;

/// 添加到列表末尾
pub const NLM_F_APPEND = 0x800;

// DELETE 请求的修饰符

/// 不要递归删除
pub const NLM_F_NONREC = 0x100;

// ACK 消息的标志

/// 请求受到限制
pub const NLM_F_CAPPED = 0x100;

/// 包含了扩展 ACK TVL
pub const NLM_F_ACK_TLVS = 0x200;

pub const NetlinkMessageType = enum(u16) {
    /// < 0x10:保留控制消息
    pub const MIN_TYPE = 0x10;

    /// 无内容。
    NOOP = 0x1,

    /// 错误
    ERROR = 0x2,

    /// 转储结束
    DONE = 0x3,

    /// 数据丢失
    OVERRUN = 0x4,

    // rtlink 类型

    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 消息头部
/// 由 RFC 3549 第 2.3.2 节规定
pub const nlmsghdr = extern struct {
    /// 消息长度,含头部
    len: u32,

    /// 消息内容
    type: NetlinkMessageType,

    /// 附加标志
    flags: u16,

    /// 序列号
    seq: u32,

    /// 发送进程的端口 ID
    pid: u32,
};

pub const ifinfomsg = extern struct {
    family: u8,
    __pad1: u8 = 0,

    /// ARPHRD_*
    type: c_ushort,

    /// 链接索引
    index: c_int,

    /// IFF_* 标志
    flags: c_uint,

    /// IFF_* 更改掩码
    change: c_uint,
};

pub const rtattr = extern struct {
    /// 选项长度
    len: c_ushort,

    /// 选项类型
    type: extern union {
        /// 来自 linux/if_link.h 的 IFLA_*
        link: IFLA,
        /// 来自 linux/if_addr.h 的 IFA_*
        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,

    /// 链路的协议专用信息
    PROTINFO,

    TXQLEN,
    MAP,
    WEIGHT,
    OPERSTATE,
    LINKMODE,
    LINKINFO,
    NET_NS_PID,
    IFALIAS,

    /// 若设备为 SR-IOV PF,则为 VF 数量
    NUM_VF,

    VFINFO_LIST,
    STATS64,
    VF_PORTS,
    PORT_SELF,
    AF_SPEC,

    /// 设备所属的组
    GROUP,

    NET_NS_FD,

    /// 扩展信息掩码、虚拟功能等
    EXT_MASK,

    /// 混杂模式计数:> 0 表示采用 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 {
    /// 收到的数据包总数
    rx_packets: u32,

    /// 已发送的数据包总数
    tx_packets: u32,

    /// 已接收的总字节数
    rx_bytes: u32,

    /// 已发送的总字节数
    tx_bytes: u32,

    /// 收到的错误数据包
    rx_errors: u32,

    /// 数据包发送问题
    tx_errors: u32,

    /// Linux 缓冲区中没有空间
    rx_dropped: u32,

    /// linux 中没有可用空间
    tx_dropped: u32,

    /// 收到的多播数据包
    multicast: u32,

    collisions: u32,

    // 详细的 rx_errors

    rx_length_errors: u32,

    /// 接收环形缓冲区溢出
    rx_over_errors: u32,

    /// 收到 CRC 错误的数据包
    rx_crc_errors: u32,

    /// 接收帧对齐错误
    rx_frame_errors: u32,

    /// 接收 FIFO 溢出
    rx_fifo_errors: u32,

    /// 接收端漏掉的数据包
    rx_missed_errors: u32,

    // 详细的 tx_errors
    tx_aborted_errors: u32,
    tx_carrier_errors: u32,
    tx_fifo_errors: u32,
    tx_heartbeat_errors: u32,
    tx_window_errors: u32,

    // 用于 cslip 等

    rx_compressed: u32,
    tx_compressed: u32,

    /// 已丢弃,未找到处理器
    rx_nohandler: u32,
};

pub const rtnl_link_stats64 = extern struct {
    /// 收到的数据包总数
    rx_packets: u64,

    /// 已发送的数据包总数
    tx_packets: u64,

    /// 已接收的总字节数
    rx_bytes: u64,

    /// 已发送的总字节数
    tx_bytes: u64,

    /// 收到的错误数据包
    rx_errors: u64,

    /// 数据包发送问题
    tx_errors: u64,

    /// Linux 缓冲区中没有空间
    rx_dropped: u64,

    /// linux 中没有可用空间
    tx_dropped: u64,

    /// 收到的多播数据包
    multicast: u64,

    collisions: u64,

    // 详细的 rx_errors

    rx_length_errors: u64,

    /// 接收环形缓冲区溢出
    rx_over_errors: u64,

    /// 收到 CRC 错误的数据包
    rx_crc_errors: u64,

    /// 接收帧对齐错误
    rx_frame_errors: u64,

    /// 接收 FIFO 溢出
    rx_fifo_errors: u64,

    /// 接收端漏掉的数据包
    rx_missed_errors: u64,

    // 详细的 tx_errors
    tx_aborted_errors: u64,
    tx_carrier_errors: u64,
    tx_fifo_errors: u64,
    tx_heartbeat_errors: u64,
    tx_window_errors: u64,

    // 用于 cslip 等

    rx_compressed: u64,
    tx_compressed: u64,

    /// 已丢弃,未找到处理器
    rx_nohandler: u64,
};

pub const perf_event_attr = extern struct {
    /// 主要类型:硬件/软件/跟踪点等。
    type: PERF.TYPE = undefined,
    /// attr 结构体的大小,用于向前/向后兼容。
    size: u32 = @sizeOf(perf_event_attr),
    /// 类型专用配置信息。
    config: u64 = 0,

    sample_period_or_freq: u64 = 0,
    sample_type: u64 = 0,
    read_format: u64 = 0,

    flags: packed struct(u64) {
        /// 默认关闭
        disabled: bool = false,
        /// 子进程继承它
        inherit: bool = false,
        /// 必须始终位于 PMU 上
        pinned: bool = false,
        /// 仅在 PMU 上分组
        exclusive: bool = false,
        /// 不统计用户态
        exclude_user: bool = false,
        /// 内核同上
        exclude_kernel: bool = false,
        /// 虚拟机监控器同上
        exclude_hv: bool = false,
        /// 空闲时不计数
        exclude_idle: bool = false,
        /// 包含 mmap 数据
        mmap: bool = false,
        /// 包含 comm 数据
        comm: bool = false,
        /// 使用频率而非周期
        freq: bool = false,
        /// 每个任务的计数
        inherit_stat: bool = false,
        /// 下次执行时启用
        enable_on_exec: bool = false,
        /// 跟踪派生/退出
        task: bool = false,
        /// wakeup_watermark
        watermark: bool = false,
        /// precise_ip:
        ///
        ///  0 - SAMPLE_IP 的采样偏移可任意
        ///  1 - SAMPLE_IP 的采样偏移必须固定
        ///  2 - 请求 SAMPLE_IP 的采样偏移为 0
        ///  3 - SAMPLE_IP 的采样偏移必须为 0
        ///
        ///  另见 PERF_RECORD_MISC_EXACT_IP
        /// 采样偏移约束
        precise_ip: u2 = 0,
        /// 不可执行的 mmap 数据
        mmap_data: bool = false,
        /// 所有事件的 sample_type
        sample_id_all: bool = false,

        /// 不在宿主机中计数
        exclude_host: bool = false,
        /// 不在客户机中计数
        exclude_guest: bool = false,

        /// 排除内核调用链
        exclude_callchain_kernel: bool = false,
        /// 排除用户调用链
        exclude_callchain_user: bool = false,
        /// 包含带 inode 数据的 mmap
        mmap2: bool = false,
        /// 标记由 exec 产生的 comm 事件
        comm_exec: bool = false,
        /// 时间字段使用 @clockid
        use_clockid: bool = false,
        /// 上下文切换数据
        context_switch: bool = false,
        /// 从末尾向开头写入环形缓冲区
        write_backward: bool = false,
        /// 包含命名空间数据
        namespaces: bool = false,
        /// 包含内核符号事件
        ksymbol: bool = false,
        /// 包含 BPF 事件
        bpf_event: bool = false,
        /// 生成 AUX 记录而非事件
        aux_output: bool = false,
        /// 包含 cgroup 事件
        cgroup: bool = false,
        /// 包含文本修改事件
        text_poke: bool = false,
        /// 在 mmap2 事件中使用构建 ID
        build_id: bool = false,
        /// 仅使用 CLONE_THREAD 克隆的子任务才继承。
        inherit_thread: bool = false,
        /// exec 时从任务中移除事件
        remove_on_exec: bool = false,
        /// 事件发生时发送同步 SIGTRAP
        sigtrap: bool = false,

        __reserved_1: u26 = 0,
    } = .{},
    /// 每 n 个事件唤醒一次,或
    /// 达到指定字节数后唤醒
    wakeup_events_or_watermark: u32 = 0,

    bp_type: u32 = 0,

    /// 此字段还用于:
    /// bp_addr
    /// perf_kprobe 的 kprobe_func
    /// perf_uprobe 的 uprobe_path
    config1: u64 = 0,
    /// 此字段还用于:
    /// bp_len
    /// kprobe_func == null 时的 kprobe_addr
    /// perf_[k,u]probe 的 probe_offset
    config2: u64 = 0,

    /// enum perf_branch_sample_type
    branch_sample_type: u64 = 0,

    /// 定义采样时要转储的用户寄存器集合。
    /// 详情参见 asm/perf_regs.h。
    sample_regs_user: u64 = 0,

    /// 定义采样时要转储的用户栈大小。
    sample_stack_user: u32 = 0,

    clockid: clockid_t = .REALTIME,
    /// 定义每个采样状态要转储的寄存器集合:
    ///  - precise = 0:PMU 中断
    ///  - precise > 0:采样指令
    ///
    /// 详情参见 asm/perf_regs.h。
    ///
    sample_regs_intr: u64 = 0,

    /// AUX 区域的唤醒水位
    aux_watermark: u32 = 0,
    sample_max_stack: u16 = 0,
    /// 对齐到 u64
    __reserved_2: u16 = 0,

    aux_sample_size: u32 = 0,
    aux_action: packed struct(u32) {
        /// 启动时暂停 AUX 区域跟踪
        start_paused: bool = false,
        /// 溢出时暂停 AUX 区域跟踪
        pause: bool = false,
        /// 溢出时恢复 AUX 区域跟踪
        @"resume": bool = false,

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

    /// sigtrap == true 时为用户提供的数据
    sig_data: u64 = 0,

    /// config2 的扩展
    config3: u64 = 0,
};

pub const perf_event_header = extern struct {
    /// 事件类型:sample/mmap/fork 等
    type: PERF.RECORD,
    /// 事件的附加信息:内核/用户/管理程序等。
    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: u16,
};

pub const perf_event_mmap_page = extern struct {
    /// 此结构体的版本号
    version: u32,
    /// 与之兼容的最低版本
    compt_version: u32,
    /// 用于同步的顺序锁
    lock: u32,
    /// 硬件计数器标识符
    index: u32,
    /// 加到硬件计数器值上
    offset: i64,
    /// 事件处于活动状态的时间
    time_enabled: u64,
    /// 事件运行的时间
    time_running: u64,
    capabilities: packed struct(u64) {
        /// 内核版本 < 3.12 时,
        /// 同时表示 user_rdpmc 和 user_time(user_rdpmc | user_time),
        /// 否则已弃用。
        bit0: bool,
        /// bit0 已弃用时设置
        bit0_is_deprecated: bool,
        /// 支持用户空间读取性能计数器的硬件能力。
        user_rdpmc: bool,
        /// 硬件支持恒定且不停走的时间戳计数器(例如 x86 上的 TSC)
        user_time: bool,
        /// 使用 time_zero 字段
        user_time_zero: bool,
        /// 使用 time_{cycle,mask} 字段
        user_time_short: bool,
        ____res: u58,
    },
    /// 如果 capabilities.user_rdpmc 为真,
    /// 此字段报告 rdpmc() 或等价操作读取值的位宽。
    pcm_width: u16,
    /// 若 capabilities.user_time 成立,可使用以下字段,通过 RDTSC 或类似机制
    /// 计算自 time_enabled 以来的时间差,单位为纳秒。
    time_shift: u16,
    time_mult: u32,
    time_offset: u64,
    /// 如果 capabilities.user_time_zero,便可根据采样时间戳计算硬件时钟
    ///
    time_zero: u64,
    /// 头部大小
    size: u32,
    __reserved_1: u32,
    /// 当硬件时钟的位宽小于 64 位时,
    /// 使用以下字段计算时间戳。
    time_cycles: u64,
    time_mask: u64,
    __reserved: [116 * 8]u8,
    /// 位于数据段中的头部
    data_head: u64,
    /// 由用户空间写入的尾部
    data_tail: u64,
    /// 缓冲区的起始位置
    data_offset: u64,
    /// 数据缓冲区大小
    data_size: u64,
    // 若使用 aux,则为数据节中的头部
    aux_head: u64,
    // 使用 aux 时,表示由用户空间写入的尾部位置
    aux_tail: u64,
    // 使用 aux 时,表示缓冲区起始位置
    aux_offset: u64,
    // 使用 aux 时,表示数据缓冲区大小
    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: 添加其余 AUDIT 定义?
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;
    };
};

/// 用于 futex2_waitv 和 futex2_requeue。`futex2_waitone` 数组允许
/// 在一次调用中等待多个 futex。
pub const futex2_waitone = extern struct {
    /// uaddr 处的预期值,大小应与 futex 一致。
    val: u64,
    /// 等待的用户地址。在 32 位平台上,高位必须为 0。
    uaddr: u64,
    /// 此等待者的标志。
    flags: FUTEX2_FLAGS,
    /// 保留成员以维持对齐。
    __reserved: u32 = 0,
};

pub const cache_stat_range = extern struct {
    off: u64,
    len: u64,
};

pub const cache_stat = extern struct {
    /// 缓存页数量。
    cache: u64,
    /// 脏页数量。
    dirty: u64,
    /// 标记为待写回的页数。
    writeback: u64,
    /// 从缓存中逐出的页数。
    evicted: u64,
    /// 近期被逐出的页面数量。
    /// 若页面最近才被逐出,则再次进入缓存意味着它仍被系统积极使用,
    /// 且系统正面临内存压力。
    ///
    recently_evicted: u64,
};

pub const SHADOW_STACK = struct {
    /// 在影子栈中设置恢复令牌。
    pub const SET_TOKEN: u64 = 1 << 0;
};

pub const msghdr = extern struct {
    name: ?*sockaddr,
    namelen: socklen_t,
    iov: [*]iovec,
    /// 内核和 glibc 对此字段使用 `usize`;POSIX 和 musl 使用 `c_int`。
    iovlen: usize,
    control: ?*anyopaque,
    /// 内核和 glibc 对此字段使用 `usize`;POSIX 和 musl 使用 `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 {
    /// 内核和 glibc 对此字段使用 `usize`;musl 使用 `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;
    };
};