aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/linux
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-09-15 14:46:31 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-09-15 14:51:08 -0700
commitf3ebfcae3882c03da84821abed40167ea07a8c78 (patch)
treef1b759c94cba5b020a9ffb141fc62cb686fc5f04 /lib/std/os/linux
parent111a2dcf3ad53c0c8ad2c9e7c9bd042b81e90c82 (diff)
parent0395b35cee8d4082cc40b0dcd0298f797f42309d (diff)
downloadzig-f3ebfcae3882c03da84821abed40167ea07a8c78.tar.gz
zig-f3ebfcae3882c03da84821abed40167ea07a8c78.zip
Merge remote-tracking branch 'origin/master' into llvm13
Conflicts: * cmake/Findclang.cmake * cmake/Findlld.cmake * cmake/Findllvm.cmake In master branch, more search paths were added to these files with "12" in the path. In this commit I updated them to "13". * src/stage1/codegen.cpp * src/zig_llvm.cpp * src/zig_llvm.h In master branch, ZigLLVMBuildCmpXchg is improved to add `is_single_threaded`. However, the LLVM 13 C API has this already, and in the llvm13 branch, ZigLLVMBuildCmpXchg is deleted in favor of the C API. In this commit I updated stage2 to use the LLVM 13 C API rather than depending on an improved ZigLLVMBuildCmpXchg. Additionally, src/target.zig largestAtomicBits needed to be updated to include the new m68k ISA.
Diffstat (limited to 'lib/std/os/linux')
-rw-r--r--lib/std/os/linux/arm-eabi.zig649
-rw-r--r--lib/std/os/linux/arm64.zig494
-rw-r--r--lib/std/os/linux/bpf.zig16
-rw-r--r--lib/std/os/linux/bpf/btf.zig2
-rw-r--r--lib/std/os/linux/bpf/helpers.zig5
-rw-r--r--lib/std/os/linux/errno/generic.zig460
-rw-r--r--lib/std/os/linux/errno/mips.zig141
-rw-r--r--lib/std/os/linux/errno/sparc.zig144
-rw-r--r--lib/std/os/linux/i386.zig675
-rw-r--r--lib/std/os/linux/io_uring.zig36
-rw-r--r--lib/std/os/linux/mips.zig570
-rw-r--r--lib/std/os/linux/powerpc.zig624
-rw-r--r--lib/std/os/linux/powerpc64.zig607
-rw-r--r--lib/std/os/linux/riscv64.zig426
-rw-r--r--lib/std/os/linux/sparc64.zig644
-rw-r--r--lib/std/os/linux/test.zig14
-rw-r--r--lib/std/os/linux/thumb.zig18
-rw-r--r--lib/std/os/linux/tls.zig6
-rw-r--r--lib/std/os/linux/x86_64.zig642
19 files changed, 6119 insertions, 54 deletions
diff --git a/lib/std/os/linux/arm-eabi.zig b/lib/std/os/linux/arm-eabi.zig
index 415cfd42f2..4bb60a0005 100644
--- a/lib/std/os/linux/arm-eabi.zig
+++ b/lib/std/os/linux/arm-eabi.zig
@@ -1,4 +1,16 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const linux = std.os.linux;
+const iovec = std.os.iovec;
+const iovec_const = std.os.iovec_const;
+const socklen_t = linux.socklen_t;
+const stack_t = linux.stack_t;
+const sigset_t = linux.sigset_t;
+const uid_t = linux.uid_t;
+const gid_t = linux.gid_t;
+const pid_t = linux.pid_t;
+const sockaddr = linux.sockaddr;
+const timespec = linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile ("svc #0"
@@ -86,7 +98,15 @@ pub fn syscall6(
}
/// This matches the libc clone function.
-pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
+pub extern fn clone(
+ func: fn (arg: usize) callconv(.C) u8,
+ stack: usize,
+ flags: u32,
+ arg: usize,
+ ptid: *i32,
+ tls: usize,
+ ctid: *i32,
+) usize;
pub fn restore() callconv(.Naked) void {
return asm volatile ("svc #0"
@@ -103,3 +123,628 @@ pub fn restore_rt() callconv(.Naked) void {
: "memory"
);
}
+
+pub const SYS = enum(usize) {
+ restart_syscall = 0,
+ exit = 1,
+ fork = 2,
+ read = 3,
+ write = 4,
+ open = 5,
+ close = 6,
+ creat = 8,
+ link = 9,
+ unlink = 10,
+ execve = 11,
+ chdir = 12,
+ mknod = 14,
+ chmod = 15,
+ lchown = 16,
+ lseek = 19,
+ getpid = 20,
+ mount = 21,
+ setuid = 23,
+ getuid = 24,
+ ptrace = 26,
+ pause = 29,
+ access = 33,
+ nice = 34,
+ sync = 36,
+ kill = 37,
+ rename = 38,
+ mkdir = 39,
+ rmdir = 40,
+ dup = 41,
+ pipe = 42,
+ times = 43,
+ brk = 45,
+ setgid = 46,
+ getgid = 47,
+ geteuid = 49,
+ getegid = 50,
+ acct = 51,
+ umount2 = 52,
+ ioctl = 54,
+ fcntl = 55,
+ setpgid = 57,
+ umask = 60,
+ chroot = 61,
+ ustat = 62,
+ dup2 = 63,
+ getppid = 64,
+ getpgrp = 65,
+ setsid = 66,
+ sigaction = 67,
+ setreuid = 70,
+ setregid = 71,
+ sigsuspend = 72,
+ sigpending = 73,
+ sethostname = 74,
+ setrlimit = 75,
+ getrusage = 77,
+ gettimeofday = 78,
+ settimeofday = 79,
+ getgroups = 80,
+ setgroups = 81,
+ symlink = 83,
+ readlink = 85,
+ uselib = 86,
+ swapon = 87,
+ reboot = 88,
+ munmap = 91,
+ truncate = 92,
+ ftruncate = 93,
+ fchmod = 94,
+ fchown = 95,
+ getpriority = 96,
+ setpriority = 97,
+ statfs = 99,
+ fstatfs = 100,
+ syslog = 103,
+ setitimer = 104,
+ getitimer = 105,
+ stat = 106,
+ lstat = 107,
+ fstat = 108,
+ vhangup = 111,
+ wait4 = 114,
+ swapoff = 115,
+ sysinfo = 116,
+ fsync = 118,
+ sigreturn = 119,
+ clone = 120,
+ setdomainname = 121,
+ uname = 122,
+ adjtimex = 124,
+ mprotect = 125,
+ sigprocmask = 126,
+ init_module = 128,
+ delete_module = 129,
+ quotactl = 131,
+ getpgid = 132,
+ fchdir = 133,
+ bdflush = 134,
+ sysfs = 135,
+ personality = 136,
+ setfsuid = 138,
+ setfsgid = 139,
+ _llseek = 140,
+ getdents = 141,
+ _newselect = 142,
+ flock = 143,
+ msync = 144,
+ readv = 145,
+ writev = 146,
+ getsid = 147,
+ fdatasync = 148,
+ _sysctl = 149,
+ mlock = 150,
+ munlock = 151,
+ mlockall = 152,
+ munlockall = 153,
+ sched_setparam = 154,
+ sched_getparam = 155,
+ sched_setscheduler = 156,
+ sched_getscheduler = 157,
+ sched_yield = 158,
+ sched_get_priority_max = 159,
+ sched_get_priority_min = 160,
+ sched_rr_get_interval = 161,
+ nanosleep = 162,
+ mremap = 163,
+ setresuid = 164,
+ getresuid = 165,
+ poll = 168,
+ nfsservctl = 169,
+ setresgid = 170,
+ getresgid = 171,
+ prctl = 172,
+ rt_sigreturn = 173,
+ rt_sigaction = 174,
+ rt_sigprocmask = 175,
+ rt_sigpending = 176,
+ rt_sigtimedwait = 177,
+ rt_sigqueueinfo = 178,
+ rt_sigsuspend = 179,
+ pread64 = 180,
+ pwrite64 = 181,
+ chown = 182,
+ getcwd = 183,
+ capget = 184,
+ capset = 185,
+ sigaltstack = 186,
+ sendfile = 187,
+ vfork = 190,
+ ugetrlimit = 191,
+ mmap2 = 192,
+ truncate64 = 193,
+ ftruncate64 = 194,
+ stat64 = 195,
+ lstat64 = 196,
+ fstat64 = 197,
+ lchown32 = 198,
+ getuid32 = 199,
+ getgid32 = 200,
+ geteuid32 = 201,
+ getegid32 = 202,
+ setreuid32 = 203,
+ setregid32 = 204,
+ getgroups32 = 205,
+ setgroups32 = 206,
+ fchown32 = 207,
+ setresuid32 = 208,
+ getresuid32 = 209,
+ setresgid32 = 210,
+ getresgid32 = 211,
+ chown32 = 212,
+ setuid32 = 213,
+ setgid32 = 214,
+ setfsuid32 = 215,
+ setfsgid32 = 216,
+ getdents64 = 217,
+ pivot_root = 218,
+ mincore = 219,
+ madvise = 220,
+ fcntl64 = 221,
+ gettid = 224,
+ readahead = 225,
+ setxattr = 226,
+ lsetxattr = 227,
+ fsetxattr = 228,
+ getxattr = 229,
+ lgetxattr = 230,
+ fgetxattr = 231,
+ listxattr = 232,
+ llistxattr = 233,
+ flistxattr = 234,
+ removexattr = 235,
+ lremovexattr = 236,
+ fremovexattr = 237,
+ tkill = 238,
+ sendfile64 = 239,
+ futex = 240,
+ sched_setaffinity = 241,
+ sched_getaffinity = 242,
+ io_setup = 243,
+ io_destroy = 244,
+ io_getevents = 245,
+ io_submit = 246,
+ io_cancel = 247,
+ exit_group = 248,
+ lookup_dcookie = 249,
+ epoll_create = 250,
+ epoll_ctl = 251,
+ epoll_wait = 252,
+ remap_file_pages = 253,
+ set_tid_address = 256,
+ timer_create = 257,
+ timer_settime = 258,
+ timer_gettime = 259,
+ timer_getoverrun = 260,
+ timer_delete = 261,
+ clock_settime = 262,
+ clock_gettime = 263,
+ clock_getres = 264,
+ clock_nanosleep = 265,
+ statfs64 = 266,
+ fstatfs64 = 267,
+ tgkill = 268,
+ utimes = 269,
+ fadvise64_64 = 270,
+ pciconfig_iobase = 271,
+ pciconfig_read = 272,
+ pciconfig_write = 273,
+ mq_open = 274,
+ mq_unlink = 275,
+ mq_timedsend = 276,
+ mq_timedreceive = 277,
+ mq_notify = 278,
+ mq_getsetattr = 279,
+ waitid = 280,
+ socket = 281,
+ bind = 282,
+ connect = 283,
+ listen = 284,
+ accept = 285,
+ getsockname = 286,
+ getpeername = 287,
+ socketpair = 288,
+ send = 289,
+ sendto = 290,
+ recv = 291,
+ recvfrom = 292,
+ shutdown = 293,
+ setsockopt = 294,
+ getsockopt = 295,
+ sendmsg = 296,
+ recvmsg = 297,
+ semop = 298,
+ semget = 299,
+ semctl = 300,
+ msgsnd = 301,
+ msgrcv = 302,
+ msgget = 303,
+ msgctl = 304,
+ shmat = 305,
+ shmdt = 306,
+ shmget = 307,
+ shmctl = 308,
+ add_key = 309,
+ request_key = 310,
+ keyctl = 311,
+ semtimedop = 312,
+ vserver = 313,
+ ioprio_set = 314,
+ ioprio_get = 315,
+ inotify_init = 316,
+ inotify_add_watch = 317,
+ inotify_rm_watch = 318,
+ mbind = 319,
+ get_mempolicy = 320,
+ set_mempolicy = 321,
+ openat = 322,
+ mkdirat = 323,
+ mknodat = 324,
+ fchownat = 325,
+ futimesat = 326,
+ fstatat64 = 327,
+ unlinkat = 328,
+ renameat = 329,
+ linkat = 330,
+ symlinkat = 331,
+ readlinkat = 332,
+ fchmodat = 333,
+ faccessat = 334,
+ pselect6 = 335,
+ ppoll = 336,
+ unshare = 337,
+ set_robust_list = 338,
+ get_robust_list = 339,
+ splice = 340,
+ sync_file_range = 341,
+ tee = 342,
+ vmsplice = 343,
+ move_pages = 344,
+ getcpu = 345,
+ epoll_pwait = 346,
+ kexec_load = 347,
+ utimensat = 348,
+ signalfd = 349,
+ timerfd_create = 350,
+ eventfd = 351,
+ fallocate = 352,
+ timerfd_settime = 353,
+ timerfd_gettime = 354,
+ signalfd4 = 355,
+ eventfd2 = 356,
+ epoll_create1 = 357,
+ dup3 = 358,
+ pipe2 = 359,
+ inotify_init1 = 360,
+ preadv = 361,
+ pwritev = 362,
+ rt_tgsigqueueinfo = 363,
+ perf_event_open = 364,
+ recvmmsg = 365,
+ accept4 = 366,
+ fanotify_init = 367,
+ fanotify_mark = 368,
+ prlimit64 = 369,
+ name_to_handle_at = 370,
+ open_by_handle_at = 371,
+ clock_adjtime = 372,
+ syncfs = 373,
+ sendmmsg = 374,
+ setns = 375,
+ process_vm_readv = 376,
+ process_vm_writev = 377,
+ kcmp = 378,
+ finit_module = 379,
+ sched_setattr = 380,
+ sched_getattr = 381,
+ renameat2 = 382,
+ seccomp = 383,
+ getrandom = 384,
+ memfd_create = 385,
+ bpf = 386,
+ execveat = 387,
+ userfaultfd = 388,
+ membarrier = 389,
+ mlock2 = 390,
+ copy_file_range = 391,
+ preadv2 = 392,
+ pwritev2 = 393,
+ pkey_mprotect = 394,
+ pkey_alloc = 395,
+ pkey_free = 396,
+ statx = 397,
+ rseq = 398,
+ io_pgetevents = 399,
+ migrate_pages = 400,
+ kexec_file_load = 401,
+ clock_gettime64 = 403,
+ clock_settime64 = 404,
+ clock_adjtime64 = 405,
+ clock_getres_time64 = 406,
+ clock_nanosleep_time64 = 407,
+ timer_gettime64 = 408,
+ timer_settime64 = 409,
+ timerfd_gettime64 = 410,
+ timerfd_settime64 = 411,
+ utimensat_time64 = 412,
+ pselect6_time64 = 413,
+ ppoll_time64 = 414,
+ io_pgetevents_time64 = 416,
+ recvmmsg_time64 = 417,
+ mq_timedsend_time64 = 418,
+ mq_timedreceive_time64 = 419,
+ semtimedop_time64 = 420,
+ rt_sigtimedwait_time64 = 421,
+ futex_time64 = 422,
+ sched_rr_get_interval_time64 = 423,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+ epoll_pwait2 = 441,
+
+ breakpoint = 0x0f0001,
+ cacheflush = 0x0f0002,
+ usr26 = 0x0f0003,
+ usr32 = 0x0f0004,
+ set_tls = 0x0f0005,
+ get_tls = 0x0f0006,
+
+ _,
+};
+
+pub const MMAP2_UNIT = 4096;
+
+pub const O = struct {
+ pub const CREAT = 0o100;
+ pub const EXCL = 0o200;
+ pub const NOCTTY = 0o400;
+ pub const TRUNC = 0o1000;
+ pub const APPEND = 0o2000;
+ pub const NONBLOCK = 0o4000;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0o4010000;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0o40000;
+ pub const NOFOLLOW = 0o100000;
+ pub const CLOEXEC = 0o2000000;
+
+ pub const ASYNC = 0o20000;
+ pub const DIRECT = 0o200000;
+ pub const LARGEFILE = 0o400000;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20040000;
+ pub const NDELAY = NONBLOCK;
+};
+
+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 SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const GETLK = 12;
+ pub const SETLK = 13;
+ pub const SETLKW = 14;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const MAP = struct {
+ /// stack-like segment
+ pub const GROWSDOWN = 0x0100;
+ /// ETXTBSY
+ pub const DENYWRITE = 0x0800;
+ /// mark it as an executable
+ pub const EXECUTABLE = 0x1000;
+ /// pages are locked
+ pub const LOCKED = 0x2000;
+ /// don't check for reservations
+ pub const NORESERVE = 0x4000;
+};
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__vdso_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6";
+};
+
+pub const HWCAP = 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 Flock = extern struct {
+ l_type: i16,
+ l_whence: i16,
+ __pad0: [4]u8,
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ __unused: [4]u8,
+};
+
+pub const msghdr = extern struct {
+ msg_name: ?*sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec,
+ msg_iovlen: i32,
+ msg_control: ?*c_void,
+ msg_controllen: socklen_t,
+ msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ msg_name: ?*const sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec_const,
+ msg_iovlen: i32,
+ msg_control: ?*c_void,
+ msg_controllen: socklen_t,
+ msg_flags: i32,
+};
+
+pub const blksize_t = i32;
+pub const nlink_t = u32;
+pub const time_t = isize;
+pub const mode_t = u32;
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const dev_t = u64;
+pub const blkcnt_t = i64;
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: dev_t,
+ __dev_padding: u32,
+ __ino_truncated: u32,
+ mode: mode_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ __rdev_padding: u32,
+ size: off_t,
+ blksize: blksize_t,
+ blocks: blkcnt_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ ino: ino_t,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: i32,
+ tv_usec: i32,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+pub const mcontext_t = extern struct {
+ trap_no: usize,
+ error_code: usize,
+ oldmask: usize,
+ arm_r0: usize,
+ arm_r1: usize,
+ arm_r2: usize,
+ arm_r3: usize,
+ arm_r4: usize,
+ arm_r5: usize,
+ arm_r6: usize,
+ arm_r7: usize,
+ arm_r8: usize,
+ arm_r9: usize,
+ arm_r10: usize,
+ arm_fp: usize,
+ arm_ip: usize,
+ arm_sp: usize,
+ arm_lr: usize,
+ arm_pc: usize,
+ arm_cpsr: usize,
+ fault_address: usize,
+};
+
+pub const ucontext_t = extern struct {
+ flags: usize,
+ link: *ucontext_t,
+ stack: stack_t,
+ mcontext: mcontext_t,
+ sigmask: sigset_t,
+ regspace: [64]u64,
+};
+
+pub const Elf_Symndx = u32;
diff --git a/lib/std/os/linux/arm64.zig b/lib/std/os/linux/arm64.zig
index 3a619c5f45..58895843e0 100644
--- a/lib/std/os/linux/arm64.zig
+++ b/lib/std/os/linux/arm64.zig
@@ -1,4 +1,16 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const linux = std.os.linux;
+const socklen_t = linux.socklen_t;
+const sockaddr = linux.sockaddr;
+const iovec = linux.iovec;
+const iovec_const = linux.iovec_const;
+const uid_t = linux.uid_t;
+const gid_t = linux.gid_t;
+const pid_t = linux.pid_t;
+const stack_t = linux.stack_t;
+const sigset_t = linux.sigset_t;
+const timespec = std.os.linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile ("svc #0"
@@ -97,3 +109,483 @@ pub fn restore_rt() callconv(.Naked) void {
: "memory", "cc"
);
}
+
+pub const SYS = enum(usize) {
+ io_setup = 0,
+ io_destroy = 1,
+ io_submit = 2,
+ io_cancel = 3,
+ io_getevents = 4,
+ setxattr = 5,
+ lsetxattr = 6,
+ fsetxattr = 7,
+ getxattr = 8,
+ lgetxattr = 9,
+ fgetxattr = 10,
+ listxattr = 11,
+ llistxattr = 12,
+ flistxattr = 13,
+ removexattr = 14,
+ lremovexattr = 15,
+ fremovexattr = 16,
+ getcwd = 17,
+ lookup_dcookie = 18,
+ eventfd2 = 19,
+ epoll_create1 = 20,
+ epoll_ctl = 21,
+ epoll_pwait = 22,
+ dup = 23,
+ dup3 = 24,
+ fcntl = 25,
+ inotify_init1 = 26,
+ inotify_add_watch = 27,
+ inotify_rm_watch = 28,
+ ioctl = 29,
+ ioprio_set = 30,
+ ioprio_get = 31,
+ flock = 32,
+ mknodat = 33,
+ mkdirat = 34,
+ unlinkat = 35,
+ symlinkat = 36,
+ linkat = 37,
+ renameat = 38,
+ umount2 = 39,
+ mount = 40,
+ pivot_root = 41,
+ nfsservctl = 42,
+ statfs = 43,
+ fstatfs = 44,
+ truncate = 45,
+ ftruncate = 46,
+ fallocate = 47,
+ faccessat = 48,
+ chdir = 49,
+ fchdir = 50,
+ chroot = 51,
+ fchmod = 52,
+ fchmodat = 53,
+ fchownat = 54,
+ fchown = 55,
+ openat = 56,
+ close = 57,
+ vhangup = 58,
+ pipe2 = 59,
+ quotactl = 60,
+ getdents64 = 61,
+ lseek = 62,
+ read = 63,
+ write = 64,
+ readv = 65,
+ writev = 66,
+ pread64 = 67,
+ pwrite64 = 68,
+ preadv = 69,
+ pwritev = 70,
+ sendfile = 71,
+ pselect6 = 72,
+ ppoll = 73,
+ signalfd4 = 74,
+ vmsplice = 75,
+ splice = 76,
+ tee = 77,
+ readlinkat = 78,
+ fstatat = 79,
+ fstat = 80,
+ sync = 81,
+ fsync = 82,
+ fdatasync = 83,
+ sync_file_range = 84,
+ timerfd_create = 85,
+ timerfd_settime = 86,
+ timerfd_gettime = 87,
+ utimensat = 88,
+ acct = 89,
+ capget = 90,
+ capset = 91,
+ personality = 92,
+ exit = 93,
+ exit_group = 94,
+ waitid = 95,
+ set_tid_address = 96,
+ unshare = 97,
+ futex = 98,
+ set_robust_list = 99,
+ get_robust_list = 100,
+ nanosleep = 101,
+ getitimer = 102,
+ setitimer = 103,
+ kexec_load = 104,
+ init_module = 105,
+ delete_module = 106,
+ timer_create = 107,
+ timer_gettime = 108,
+ timer_getoverrun = 109,
+ timer_settime = 110,
+ timer_delete = 111,
+ clock_settime = 112,
+ clock_gettime = 113,
+ clock_getres = 114,
+ clock_nanosleep = 115,
+ syslog = 116,
+ ptrace = 117,
+ sched_setparam = 118,
+ sched_setscheduler = 119,
+ sched_getscheduler = 120,
+ sched_getparam = 121,
+ sched_setaffinity = 122,
+ sched_getaffinity = 123,
+ sched_yield = 124,
+ sched_get_priority_max = 125,
+ sched_get_priority_min = 126,
+ sched_rr_get_interval = 127,
+ restart_syscall = 128,
+ kill = 129,
+ tkill = 130,
+ tgkill = 131,
+ sigaltstack = 132,
+ rt_sigsuspend = 133,
+ rt_sigaction = 134,
+ rt_sigprocmask = 135,
+ rt_sigpending = 136,
+ rt_sigtimedwait = 137,
+ rt_sigqueueinfo = 138,
+ rt_sigreturn = 139,
+ setpriority = 140,
+ getpriority = 141,
+ reboot = 142,
+ setregid = 143,
+ setgid = 144,
+ setreuid = 145,
+ setuid = 146,
+ setresuid = 147,
+ getresuid = 148,
+ setresgid = 149,
+ getresgid = 150,
+ setfsuid = 151,
+ setfsgid = 152,
+ times = 153,
+ setpgid = 154,
+ getpgid = 155,
+ getsid = 156,
+ setsid = 157,
+ getgroups = 158,
+ setgroups = 159,
+ uname = 160,
+ sethostname = 161,
+ setdomainname = 162,
+ getrlimit = 163,
+ setrlimit = 164,
+ getrusage = 165,
+ umask = 166,
+ prctl = 167,
+ getcpu = 168,
+ gettimeofday = 169,
+ settimeofday = 170,
+ adjtimex = 171,
+ getpid = 172,
+ getppid = 173,
+ getuid = 174,
+ geteuid = 175,
+ getgid = 176,
+ getegid = 177,
+ gettid = 178,
+ sysinfo = 179,
+ mq_open = 180,
+ mq_unlink = 181,
+ mq_timedsend = 182,
+ mq_timedreceive = 183,
+ mq_notify = 184,
+ mq_getsetattr = 185,
+ msgget = 186,
+ msgctl = 187,
+ msgrcv = 188,
+ msgsnd = 189,
+ semget = 190,
+ semctl = 191,
+ semtimedop = 192,
+ semop = 193,
+ shmget = 194,
+ shmctl = 195,
+ shmat = 196,
+ shmdt = 197,
+ socket = 198,
+ socketpair = 199,
+ bind = 200,
+ listen = 201,
+ accept = 202,
+ connect = 203,
+ getsockname = 204,
+ getpeername = 205,
+ sendto = 206,
+ recvfrom = 207,
+ setsockopt = 208,
+ getsockopt = 209,
+ shutdown = 210,
+ sendmsg = 211,
+ recvmsg = 212,
+ readahead = 213,
+ brk = 214,
+ munmap = 215,
+ mremap = 216,
+ add_key = 217,
+ request_key = 218,
+ keyctl = 219,
+ clone = 220,
+ execve = 221,
+ mmap = 222,
+ fadvise64 = 223,
+ swapon = 224,
+ swapoff = 225,
+ mprotect = 226,
+ msync = 227,
+ mlock = 228,
+ munlock = 229,
+ mlockall = 230,
+ munlockall = 231,
+ mincore = 232,
+ madvise = 233,
+ remap_file_pages = 234,
+ mbind = 235,
+ get_mempolicy = 236,
+ set_mempolicy = 237,
+ migrate_pages = 238,
+ move_pages = 239,
+ rt_tgsigqueueinfo = 240,
+ perf_event_open = 241,
+ accept4 = 242,
+ recvmmsg = 243,
+ arch_specific_syscall = 244,
+ wait4 = 260,
+ prlimit64 = 261,
+ fanotify_init = 262,
+ fanotify_mark = 263,
+ clock_adjtime = 266,
+ syncfs = 267,
+ setns = 268,
+ sendmmsg = 269,
+ process_vm_readv = 270,
+ process_vm_writev = 271,
+ kcmp = 272,
+ finit_module = 273,
+ sched_setattr = 274,
+ sched_getattr = 275,
+ renameat2 = 276,
+ seccomp = 277,
+ getrandom = 278,
+ memfd_create = 279,
+ bpf = 280,
+ execveat = 281,
+ userfaultfd = 282,
+ membarrier = 283,
+ mlock2 = 284,
+ copy_file_range = 285,
+ preadv2 = 286,
+ pwritev2 = 287,
+ pkey_mprotect = 288,
+ pkey_alloc = 289,
+ pkey_free = 290,
+ statx = 291,
+ io_pgetevents = 292,
+ rseq = 293,
+ kexec_file_load = 294,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+ epoll_pwait2 = 441,
+
+ _,
+};
+
+pub const O = struct {
+ pub const CREAT = 0o100;
+ pub const EXCL = 0o200;
+ pub const NOCTTY = 0o400;
+ pub const TRUNC = 0o1000;
+ pub const APPEND = 0o2000;
+ pub const NONBLOCK = 0o4000;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0o4010000;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0o40000;
+ pub const NOFOLLOW = 0o100000;
+ pub const CLOEXEC = 0o2000000;
+
+ pub const ASYNC = 0o20000;
+ pub const DIRECT = 0o200000;
+ pub const LARGEFILE = 0o400000;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20040000;
+ pub const NDELAY = NONBLOCK;
+};
+
+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 SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const GETLK = 5;
+ pub const SETLK = 6;
+ pub const SETLKW = 7;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const MAP = struct {
+ /// stack-like segment
+ pub const GROWSDOWN = 0x0100;
+ /// ETXTBSY
+ pub const DENYWRITE = 0x0800;
+ /// mark it as an executable
+ pub const EXECUTABLE = 0x1000;
+ /// pages are locked
+ pub const LOCKED = 0x2000;
+ /// don't check for reservations
+ pub const NORESERVE = 0x4000;
+};
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__kernel_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6.39";
+};
+
+pub const Flock = extern struct {
+ l_type: i16,
+ l_whence: i16,
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ __unused: [4]u8,
+};
+
+pub const msghdr = extern struct {
+ msg_name: ?*sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec,
+ msg_iovlen: i32,
+ __pad1: i32 = 0,
+ msg_control: ?*c_void,
+ msg_controllen: socklen_t,
+ __pad2: socklen_t = 0,
+ msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ msg_name: ?*const sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec_const,
+ msg_iovlen: i32,
+ __pad1: i32 = 0,
+ msg_control: ?*c_void,
+ msg_controllen: socklen_t,
+ __pad2: socklen_t = 0,
+ msg_flags: i32,
+};
+
+pub const blksize_t = i32;
+pub const nlink_t = u32;
+pub const time_t = isize;
+pub const mode_t = u32;
+pub const off_t = isize;
+pub const ino_t = usize;
+pub const dev_t = usize;
+pub const blkcnt_t = isize;
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: dev_t,
+ ino: ino_t,
+ mode: mode_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ __pad: usize,
+ size: off_t,
+ blksize: blksize_t,
+ __pad2: i32,
+ blocks: blkcnt_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ __unused: [2]u32,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: isize,
+ tv_usec: isize,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+pub const mcontext_t = extern struct {
+ fault_address: usize,
+ regs: [31]usize,
+ sp: usize,
+ pc: usize,
+ pstate: usize,
+ // Make sure the field is correctly aligned since this area
+ // holds various FP/vector registers
+ reserved1: [256 * 16]u8 align(16),
+};
+
+pub const ucontext_t = extern struct {
+ flags: usize,
+ link: *ucontext_t,
+ stack: stack_t,
+ sigmask: sigset_t,
+ mcontext: mcontext_t,
+};
+
+pub const Elf_Symndx = u32;
diff --git a/lib/std/os/linux/bpf.zig b/lib/std/os/linux/bpf.zig
index cff4acaeee..4cb9dbf5c5 100644
--- a/lib/std/os/linux/bpf.zig
+++ b/lib/std/os/linux/bpf.zig
@@ -1,4 +1,3 @@
-usingnamespace std.os.linux;
const std = @import("../../std.zig");
const errno = getErrno;
const unexpectedErrno = std.os.unexpectedErrno;
@@ -6,6 +5,11 @@ const expectEqual = std.testing.expectEqual;
const expectError = std.testing.expectError;
const expect = std.testing.expect;
+const linux = std.os.linux;
+const fd_t = linux.fd_t;
+const pid_t = linux.pid_t;
+const getErrno = linux.getErrno;
+
pub const btf = @import("bpf/btf.zig");
pub const kern = @import("bpf/kern.zig");
@@ -1502,7 +1506,7 @@ pub fn map_create(map_type: MapType, key_size: u32, value_size: u32, max_entries
attr.map_create.value_size = value_size;
attr.map_create.max_entries = max_entries;
- const rc = bpf(.map_create, &attr, @sizeOf(MapCreateAttr));
+ const rc = linux.bpf(.map_create, &attr, @sizeOf(MapCreateAttr));
switch (errno(rc)) {
.SUCCESS => return @intCast(fd_t, rc),
.INVAL => return error.MapTypeOrAttrInvalid,
@@ -1526,7 +1530,7 @@ pub fn map_lookup_elem(fd: fd_t, key: []const u8, value: []u8) !void {
attr.map_elem.key = @ptrToInt(key.ptr);
attr.map_elem.result.value = @ptrToInt(value.ptr);
- const rc = bpf(.map_lookup_elem, &attr, @sizeOf(MapElemAttr));
+ const rc = linux.bpf(.map_lookup_elem, &attr, @sizeOf(MapElemAttr));
switch (errno(rc)) {
.SUCCESS => return,
.BADF => return error.BadFd,
@@ -1548,7 +1552,7 @@ pub fn map_update_elem(fd: fd_t, key: []const u8, value: []const u8, flags: u64)
attr.map_elem.result = .{ .value = @ptrToInt(value.ptr) };
attr.map_elem.flags = flags;
- const rc = bpf(.map_update_elem, &attr, @sizeOf(MapElemAttr));
+ const rc = linux.bpf(.map_update_elem, &attr, @sizeOf(MapElemAttr));
switch (errno(rc)) {
.SUCCESS => return,
.@"2BIG" => return error.ReachedMaxEntries,
@@ -1569,7 +1573,7 @@ pub fn map_delete_elem(fd: fd_t, key: []const u8) !void {
attr.map_elem.map_fd = fd;
attr.map_elem.key = @ptrToInt(key.ptr);
- const rc = bpf(.map_delete_elem, &attr, @sizeOf(MapElemAttr));
+ const rc = linux.bpf(.map_delete_elem, &attr, @sizeOf(MapElemAttr));
switch (errno(rc)) {
.SUCCESS => return,
.BADF => return error.BadFd,
@@ -1632,7 +1636,7 @@ pub fn prog_load(
attr.prog_load.log_level = l.level;
}
- const rc = bpf(.prog_load, &attr, @sizeOf(ProgLoadAttr));
+ const rc = linux.bpf(.prog_load, &attr, @sizeOf(ProgLoadAttr));
return switch (errno(rc)) {
.SUCCESS => @intCast(fd_t, rc),
.ACCES => error.UnsafeProgram,
diff --git a/lib/std/os/linux/bpf/btf.zig b/lib/std/os/linux/bpf/btf.zig
index 35eaf10561..8da3bbbe4c 100644
--- a/lib/std/os/linux/bpf/btf.zig
+++ b/lib/std/os/linux/bpf/btf.zig
@@ -1,3 +1,5 @@
+const std = @import("../../../std.zig");
+
const magic = 0xeb9f;
const version = 1;
diff --git a/lib/std/os/linux/bpf/helpers.zig b/lib/std/os/linux/bpf/helpers.zig
index 86c86c1ec5..3b0df9673c 100644
--- a/lib/std/os/linux/bpf/helpers.zig
+++ b/lib/std/os/linux/bpf/helpers.zig
@@ -1,5 +1,10 @@
+const std = @import("../../../std.zig");
const kern = @import("kern.zig");
+const PtRegs = @compileError("TODO missing os bits: PtRegs");
+const TcpHdr = @compileError("TODO missing os bits: TcpHdr");
+const SkFullSock = @compileError("TODO missing os bits: SkFullSock");
+
// in BPF, all the helper calls
// TODO: when https://github.com/ziglang/zig/issues/1717 is here, make a nice
// function that uses the Helper enum
diff --git a/lib/std/os/linux/errno/generic.zig b/lib/std/os/linux/errno/generic.zig
new file mode 100644
index 0000000000..730c71a5a2
--- /dev/null
+++ b/lib/std/os/linux/errno/generic.zig
@@ -0,0 +1,460 @@
+pub const E = enum(u16) {
+ /// No error occurred.
+ /// Same code used for `NSROK`.
+ SUCCESS = 0,
+
+ /// Operation not permitted
+ PERM = 1,
+
+ /// No such file or directory
+ NOENT = 2,
+
+ /// No such process
+ SRCH = 3,
+
+ /// Interrupted system call
+ INTR = 4,
+
+ /// I/O error
+ IO = 5,
+
+ /// No such device or address
+ NXIO = 6,
+
+ /// Arg list too long
+ @"2BIG" = 7,
+
+ /// Exec format error
+ NOEXEC = 8,
+
+ /// Bad file number
+ BADF = 9,
+
+ /// No child processes
+ CHILD = 10,
+
+ /// Try again
+ /// Also means: WOULDBLOCK: operation would block
+ AGAIN = 11,
+
+ /// Out of memory
+ NOMEM = 12,
+
+ /// Permission denied
+ ACCES = 13,
+
+ /// Bad address
+ FAULT = 14,
+
+ /// Block device required
+ NOTBLK = 15,
+
+ /// Device or resource busy
+ BUSY = 16,
+
+ /// File exists
+ EXIST = 17,
+
+ /// Cross-device link
+ XDEV = 18,
+
+ /// No such device
+ NODEV = 19,
+
+ /// Not a directory
+ NOTDIR = 20,
+
+ /// Is a directory
+ ISDIR = 21,
+
+ /// Invalid argument
+ INVAL = 22,
+
+ /// File table overflow
+ NFILE = 23,
+
+ /// Too many open files
+ MFILE = 24,
+
+ /// Not a typewriter
+ NOTTY = 25,
+
+ /// Text file busy
+ TXTBSY = 26,
+
+ /// File too large
+ FBIG = 27,
+
+ /// No space left on device
+ NOSPC = 28,
+
+ /// Illegal seek
+ SPIPE = 29,
+
+ /// Read-only file system
+ ROFS = 30,
+
+ /// Too many links
+ MLINK = 31,
+
+ /// Broken pipe
+ PIPE = 32,
+
+ /// Math argument out of domain of func
+ DOM = 33,
+
+ /// Math result not representable
+ RANGE = 34,
+
+ /// Resource deadlock would occur
+ DEADLK = 35,
+
+ /// File name too long
+ NAMETOOLONG = 36,
+
+ /// No record locks available
+ NOLCK = 37,
+
+ /// Function not implemented
+ NOSYS = 38,
+
+ /// Directory not empty
+ NOTEMPTY = 39,
+
+ /// Too many symbolic links encountered
+ LOOP = 40,
+
+ /// No message of desired type
+ NOMSG = 42,
+
+ /// Identifier removed
+ IDRM = 43,
+
+ /// Channel number out of range
+ CHRNG = 44,
+
+ /// Level 2 not synchronized
+ L2NSYNC = 45,
+
+ /// Level 3 halted
+ L3HLT = 46,
+
+ /// Level 3 reset
+ L3RST = 47,
+
+ /// Link number out of range
+ LNRNG = 48,
+
+ /// Protocol driver not attached
+ UNATCH = 49,
+
+ /// No CSI structure available
+ NOCSI = 50,
+
+ /// Level 2 halted
+ L2HLT = 51,
+
+ /// Invalid exchange
+ BADE = 52,
+
+ /// Invalid request descriptor
+ BADR = 53,
+
+ /// Exchange full
+ XFULL = 54,
+
+ /// No anode
+ NOANO = 55,
+
+ /// Invalid request code
+ BADRQC = 56,
+
+ /// Invalid slot
+ BADSLT = 57,
+
+ /// Bad font file format
+ BFONT = 59,
+
+ /// Device not a stream
+ NOSTR = 60,
+
+ /// No data available
+ NODATA = 61,
+
+ /// Timer expired
+ TIME = 62,
+
+ /// Out of streams resources
+ NOSR = 63,
+
+ /// Machine is not on the network
+ NONET = 64,
+
+ /// Package not installed
+ NOPKG = 65,
+
+ /// Object is remote
+ REMOTE = 66,
+
+ /// Link has been severed
+ NOLINK = 67,
+
+ /// Advertise error
+ ADV = 68,
+
+ /// Srmount error
+ SRMNT = 69,
+
+ /// Communication error on send
+ COMM = 70,
+
+ /// Protocol error
+ PROTO = 71,
+
+ /// Multihop attempted
+ MULTIHOP = 72,
+
+ /// RFS specific error
+ DOTDOT = 73,
+
+ /// Not a data message
+ BADMSG = 74,
+
+ /// Value too large for defined data type
+ OVERFLOW = 75,
+
+ /// Name not unique on network
+ NOTUNIQ = 76,
+
+ /// File descriptor in bad state
+ BADFD = 77,
+
+ /// Remote address changed
+ REMCHG = 78,
+
+ /// Can not access a needed shared library
+ LIBACC = 79,
+
+ /// Accessing a corrupted shared library
+ LIBBAD = 80,
+
+ /// .lib section in a.out corrupted
+ LIBSCN = 81,
+
+ /// Attempting to link in too many shared libraries
+ LIBMAX = 82,
+
+ /// Cannot exec a shared library directly
+ LIBEXEC = 83,
+
+ /// Illegal byte sequence
+ ILSEQ = 84,
+
+ /// Interrupted system call should be restarted
+ RESTART = 85,
+
+ /// Streams pipe error
+ STRPIPE = 86,
+
+ /// Too many users
+ USERS = 87,
+
+ /// Socket operation on non-socket
+ NOTSOCK = 88,
+
+ /// Destination address required
+ DESTADDRREQ = 89,
+
+ /// Message too long
+ MSGSIZE = 90,
+
+ /// Protocol wrong type for socket
+ PROTOTYPE = 91,
+
+ /// Protocol not available
+ NOPROTOOPT = 92,
+
+ /// Protocol not supported
+ PROTONOSUPPORT = 93,
+
+ /// Socket type not supported
+ SOCKTNOSUPPORT = 94,
+
+ /// Operation not supported on transport endpoint
+ /// This code also means `NOTSUP`.
+ OPNOTSUPP = 95,
+
+ /// Protocol family not supported
+ PFNOSUPPORT = 96,
+
+ /// Address family not supported by protocol
+ AFNOSUPPORT = 97,
+
+ /// Address already in use
+ ADDRINUSE = 98,
+
+ /// Cannot assign requested address
+ ADDRNOTAVAIL = 99,
+
+ /// Network is down
+ NETDOWN = 100,
+
+ /// Network is unreachable
+ NETUNREACH = 101,
+
+ /// Network dropped connection because of reset
+ NETRESET = 102,
+
+ /// Software caused connection abort
+ CONNABORTED = 103,
+
+ /// Connection reset by peer
+ CONNRESET = 104,
+
+ /// No buffer space available
+ NOBUFS = 105,
+
+ /// Transport endpoint is already connected
+ ISCONN = 106,
+
+ /// Transport endpoint is not connected
+ NOTCONN = 107,
+
+ /// Cannot send after transport endpoint shutdown
+ SHUTDOWN = 108,
+
+ /// Too many references: cannot splice
+ TOOMANYREFS = 109,
+
+ /// Connection timed out
+ TIMEDOUT = 110,
+
+ /// Connection refused
+ CONNREFUSED = 111,
+
+ /// Host is down
+ HOSTDOWN = 112,
+
+ /// No route to host
+ HOSTUNREACH = 113,
+
+ /// Operation already in progress
+ ALREADY = 114,
+
+ /// Operation now in progress
+ INPROGRESS = 115,
+
+ /// Stale NFS file handle
+ STALE = 116,
+
+ /// Structure needs cleaning
+ UCLEAN = 117,
+
+ /// Not a XENIX named type file
+ NOTNAM = 118,
+
+ /// No XENIX semaphores available
+ NAVAIL = 119,
+
+ /// Is a named type file
+ ISNAM = 120,
+
+ /// Remote I/O error
+ REMOTEIO = 121,
+
+ /// Quota exceeded
+ DQUOT = 122,
+
+ /// No medium found
+ NOMEDIUM = 123,
+
+ /// Wrong medium type
+ MEDIUMTYPE = 124,
+
+ /// Operation canceled
+ CANCELED = 125,
+
+ /// Required key not available
+ NOKEY = 126,
+
+ /// Key has expired
+ KEYEXPIRED = 127,
+
+ /// Key has been revoked
+ KEYREVOKED = 128,
+
+ /// Key was rejected by service
+ KEYREJECTED = 129,
+
+ // for robust mutexes
+
+ /// Owner died
+ OWNERDEAD = 130,
+
+ /// State not recoverable
+ NOTRECOVERABLE = 131,
+
+ /// Operation not possible due to RF-kill
+ RFKILL = 132,
+
+ /// Memory page has hardware error
+ HWPOISON = 133,
+
+ // nameserver query return codes
+
+ /// DNS server returned answer with no data
+ NSRNODATA = 160,
+
+ /// DNS server claims query was misformatted
+ NSRFORMERR = 161,
+
+ /// DNS server returned general failure
+ NSRSERVFAIL = 162,
+
+ /// Domain name not found
+ NSRNOTFOUND = 163,
+
+ /// DNS server does not implement requested operation
+ NSRNOTIMP = 164,
+
+ /// DNS server refused query
+ NSRREFUSED = 165,
+
+ /// Misformatted DNS query
+ NSRBADQUERY = 166,
+
+ /// Misformatted domain name
+ NSRBADNAME = 167,
+
+ /// Unsupported address family
+ NSRBADFAMILY = 168,
+
+ /// Misformatted DNS reply
+ NSRBADRESP = 169,
+
+ /// Could not contact DNS servers
+ NSRCONNREFUSED = 170,
+
+ /// Timeout while contacting DNS servers
+ NSRTIMEOUT = 171,
+
+ /// End of file
+ NSROF = 172,
+
+ /// Error reading file
+ NSRFILE = 173,
+
+ /// Out of memory
+ NSRNOMEM = 174,
+
+ /// Application terminated lookup
+ NSRDESTRUCTION = 175,
+
+ /// Domain name is too long
+ NSRQUERYDOMAINTOOLONG = 176,
+
+ /// Domain name is too long
+ NSRCNAMELOOP = 177,
+
+ _,
+};
diff --git a/lib/std/os/linux/errno/mips.zig b/lib/std/os/linux/errno/mips.zig
new file mode 100644
index 0000000000..39fb9f71ea
--- /dev/null
+++ b/lib/std/os/linux/errno/mips.zig
@@ -0,0 +1,141 @@
+//! These are MIPS ABI compatible.
+pub const E = enum(i32) {
+ /// No error occurred.
+ SUCCESS = 0,
+
+ PERM = 1,
+ NOENT = 2,
+ SRCH = 3,
+ INTR = 4,
+ IO = 5,
+ NXIO = 6,
+ @"2BIG" = 7,
+ NOEXEC = 8,
+ BADF = 9,
+ CHILD = 10,
+ /// Also used for WOULDBLOCK.
+ AGAIN = 11,
+ NOMEM = 12,
+ ACCES = 13,
+ FAULT = 14,
+ NOTBLK = 15,
+ BUSY = 16,
+ EXIST = 17,
+ XDEV = 18,
+ NODEV = 19,
+ NOTDIR = 20,
+ ISDIR = 21,
+ INVAL = 22,
+ NFILE = 23,
+ MFILE = 24,
+ NOTTY = 25,
+ TXTBSY = 26,
+ FBIG = 27,
+ NOSPC = 28,
+ SPIPE = 29,
+ ROFS = 30,
+ MLINK = 31,
+ PIPE = 32,
+ DOM = 33,
+ RANGE = 34,
+
+ NOMSG = 35,
+ IDRM = 36,
+ CHRNG = 37,
+ L2NSYNC = 38,
+ L3HLT = 39,
+ L3RST = 40,
+ LNRNG = 41,
+ UNATCH = 42,
+ NOCSI = 43,
+ L2HLT = 44,
+ DEADLK = 45,
+ NOLCK = 46,
+ BADE = 50,
+ BADR = 51,
+ XFULL = 52,
+ NOANO = 53,
+ BADRQC = 54,
+ BADSLT = 55,
+ DEADLOCK = 56,
+ BFONT = 59,
+ NOSTR = 60,
+ NODATA = 61,
+ TIME = 62,
+ NOSR = 63,
+ NONET = 64,
+ NOPKG = 65,
+ REMOTE = 66,
+ NOLINK = 67,
+ ADV = 68,
+ SRMNT = 69,
+ COMM = 70,
+ PROTO = 71,
+ DOTDOT = 73,
+ MULTIHOP = 74,
+ BADMSG = 77,
+ NAMETOOLONG = 78,
+ OVERFLOW = 79,
+ NOTUNIQ = 80,
+ BADFD = 81,
+ REMCHG = 82,
+ LIBACC = 83,
+ LIBBAD = 84,
+ LIBSCN = 85,
+ LIBMAX = 86,
+ LIBEXEC = 87,
+ ILSEQ = 88,
+ NOSYS = 89,
+ LOOP = 90,
+ RESTART = 91,
+ STRPIPE = 92,
+ NOTEMPTY = 93,
+ USERS = 94,
+ NOTSOCK = 95,
+ DESTADDRREQ = 96,
+ MSGSIZE = 97,
+ PROTOTYPE = 98,
+ NOPROTOOPT = 99,
+ PROTONOSUPPORT = 120,
+ SOCKTNOSUPPORT = 121,
+ OPNOTSUPP = 122,
+ PFNOSUPPORT = 123,
+ AFNOSUPPORT = 124,
+ ADDRINUSE = 125,
+ ADDRNOTAVAIL = 126,
+ NETDOWN = 127,
+ NETUNREACH = 128,
+ NETRESET = 129,
+ CONNABORTED = 130,
+ CONNRESET = 131,
+ NOBUFS = 132,
+ ISCONN = 133,
+ NOTCONN = 134,
+ UCLEAN = 135,
+ NOTNAM = 137,
+ NAVAIL = 138,
+ ISNAM = 139,
+ REMOTEIO = 140,
+ SHUTDOWN = 143,
+ TOOMANYREFS = 144,
+ TIMEDOUT = 145,
+ CONNREFUSED = 146,
+ HOSTDOWN = 147,
+ HOSTUNREACH = 148,
+ ALREADY = 149,
+ INPROGRESS = 150,
+ STALE = 151,
+ CANCELED = 158,
+ NOMEDIUM = 159,
+ MEDIUMTYPE = 160,
+ NOKEY = 161,
+ KEYEXPIRED = 162,
+ KEYREVOKED = 163,
+ KEYREJECTED = 164,
+ OWNERDEAD = 165,
+ NOTRECOVERABLE = 166,
+ RFKILL = 167,
+ HWPOISON = 168,
+ DQUOT = 1133,
+ _,
+};
diff --git a/lib/std/os/linux/errno/sparc.zig b/lib/std/os/linux/errno/sparc.zig
new file mode 100644
index 0000000000..c4ab65f34a
--- /dev/null
+++ b/lib/std/os/linux/errno/sparc.zig
@@ -0,0 +1,144 @@
+//! These match the SunOS error numbering scheme.
+pub const E = enum(i32) {
+ /// No error occurred.
+ SUCCESS = 0,
+
+ PERM = 1,
+ NOENT = 2,
+ SRCH = 3,
+ INTR = 4,
+ IO = 5,
+ NXIO = 6,
+ @"2BIG" = 7,
+ NOEXEC = 8,
+ BADF = 9,
+ CHILD = 10,
+ /// Also used for WOULDBLOCK
+ AGAIN = 11,
+ NOMEM = 12,
+ ACCES = 13,
+ FAULT = 14,
+ NOTBLK = 15,
+ BUSY = 16,
+ EXIST = 17,
+ XDEV = 18,
+ NODEV = 19,
+ NOTDIR = 20,
+ ISDIR = 21,
+ INVAL = 22,
+ NFILE = 23,
+ MFILE = 24,
+ NOTTY = 25,
+ TXTBSY = 26,
+ FBIG = 27,
+ NOSPC = 28,
+ SPIPE = 29,
+ ROFS = 30,
+ MLINK = 31,
+ PIPE = 32,
+ DOM = 33,
+ RANGE = 34,
+
+ INPROGRESS = 36,
+ ALREADY = 37,
+ NOTSOCK = 38,
+ DESTADDRREQ = 39,
+ MSGSIZE = 40,
+ PROTOTYPE = 41,
+ NOPROTOOPT = 42,
+ PROTONOSUPPORT = 43,
+ SOCKTNOSUPPORT = 44,
+ /// Also used for NOTSUP
+ OPNOTSUPP = 45,
+ PFNOSUPPORT = 46,
+ AFNOSUPPORT = 47,
+ ADDRINUSE = 48,
+ ADDRNOTAVAIL = 49,
+ NETDOWN = 50,
+ NETUNREACH = 51,
+ NETRESET = 52,
+ CONNABORTED = 53,
+ CONNRESET = 54,
+ NOBUFS = 55,
+ ISCONN = 56,
+ NOTCONN = 57,
+ SHUTDOWN = 58,
+ TOOMANYREFS = 59,
+ TIMEDOUT = 60,
+ CONNREFUSED = 61,
+ LOOP = 62,
+ NAMETOOLONG = 63,
+ HOSTDOWN = 64,
+ HOSTUNREACH = 65,
+ NOTEMPTY = 66,
+ PROCLIM = 67,
+ USERS = 68,
+ DQUOT = 69,
+ STALE = 70,
+ REMOTE = 71,
+ NOSTR = 72,
+ TIME = 73,
+ NOSR = 74,
+ NOMSG = 75,
+ BADMSG = 76,
+ IDRM = 77,
+ DEADLK = 78,
+ NOLCK = 79,
+ NONET = 80,
+ RREMOTE = 81,
+ NOLINK = 82,
+ ADV = 83,
+ SRMNT = 84,
+ COMM = 85,
+ PROTO = 86,
+ MULTIHOP = 87,
+ DOTDOT = 88,
+ REMCHG = 89,
+ NOSYS = 90,
+ STRPIPE = 91,
+ OVERFLOW = 92,
+ BADFD = 93,
+ CHRNG = 94,
+ L2NSYNC = 95,
+ L3HLT = 96,
+ L3RST = 97,
+ LNRNG = 98,
+ UNATCH = 99,
+ NOCSI = 100,
+ L2HLT = 101,
+ BADE = 102,
+ BADR = 103,
+ XFULL = 104,
+ NOANO = 105,
+ BADRQC = 106,
+ BADSLT = 107,
+ DEADLOCK = 108,
+ BFONT = 109,
+ LIBEXEC = 110,
+ NODATA = 111,
+ LIBBAD = 112,
+ NOPKG = 113,
+ LIBACC = 114,
+ NOTUNIQ = 115,
+ RESTART = 116,
+ UCLEAN = 117,
+ NOTNAM = 118,
+ NAVAIL = 119,
+ ISNAM = 120,
+ REMOTEIO = 121,
+ ILSEQ = 122,
+ LIBMAX = 123,
+ LIBSCN = 124,
+ NOMEDIUM = 125,
+ MEDIUMTYPE = 126,
+ CANCELED = 127,
+ NOKEY = 128,
+ KEYEXPIRED = 129,
+ KEYREVOKED = 130,
+ KEYREJECTED = 131,
+ OWNERDEAD = 132,
+ NOTRECOVERABLE = 133,
+ RFKILL = 134,
+ HWPOISON = 135,
+ _,
+};
diff --git a/lib/std/os/linux/i386.zig b/lib/std/os/linux/i386.zig
index 04a67da762..4d1af88e0a 100644
--- a/lib/std/os/linux/i386.zig
+++ b/lib/std/os/linux/i386.zig
@@ -1,4 +1,16 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const linux = std.os.linux;
+const socklen_t = linux.socklen_t;
+const iovec = linux.iovec;
+const iovec_const = linux.iovec_const;
+const uid_t = linux.uid_t;
+const gid_t = linux.gid_t;
+const pid_t = linux.pid_t;
+const stack_t = linux.stack_t;
+const sigset_t = linux.sigset_t;
+const sockaddr = linux.sockaddr;
+const timespec = linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile ("int $0x80"
@@ -123,3 +135,664 @@ pub fn restore_rt() callconv(.Naked) void {
: "memory"
);
}
+
+pub const SYS = enum(usize) {
+ restart_syscall = 0,
+ exit = 1,
+ fork = 2,
+ read = 3,
+ write = 4,
+ open = 5,
+ close = 6,
+ waitpid = 7,
+ creat = 8,
+ link = 9,
+ unlink = 10,
+ execve = 11,
+ chdir = 12,
+ time = 13,
+ mknod = 14,
+ chmod = 15,
+ lchown = 16,
+ @"break" = 17,
+ oldstat = 18,
+ lseek = 19,
+ getpid = 20,
+ mount = 21,
+ umount = 22,
+ setuid = 23,
+ getuid = 24,
+ stime = 25,
+ ptrace = 26,
+ alarm = 27,
+ oldfstat = 28,
+ pause = 29,
+ utime = 30,
+ stty = 31,
+ gtty = 32,
+ access = 33,
+ nice = 34,
+ ftime = 35,
+ sync = 36,
+ kill = 37,
+ rename = 38,
+ mkdir = 39,
+ rmdir = 40,
+ dup = 41,
+ pipe = 42,
+ times = 43,
+ prof = 44,
+ brk = 45,
+ setgid = 46,
+ getgid = 47,
+ signal = 48,
+ geteuid = 49,
+ getegid = 50,
+ acct = 51,
+ umount2 = 52,
+ lock = 53,
+ ioctl = 54,
+ fcntl = 55,
+ mpx = 56,
+ setpgid = 57,
+ ulimit = 58,
+ oldolduname = 59,
+ umask = 60,
+ chroot = 61,
+ ustat = 62,
+ dup2 = 63,
+ getppid = 64,
+ getpgrp = 65,
+ setsid = 66,
+ sigaction = 67,
+ sgetmask = 68,
+ ssetmask = 69,
+ setreuid = 70,
+ setregid = 71,
+ sigsuspend = 72,
+ sigpending = 73,
+ sethostname = 74,
+ setrlimit = 75,
+ getrlimit = 76,
+ getrusage = 77,
+ gettimeofday = 78,
+ settimeofday = 79,
+ getgroups = 80,
+ setgroups = 81,
+ select = 82,
+ symlink = 83,
+ oldlstat = 84,
+ readlink = 85,
+ uselib = 86,
+ swapon = 87,
+ reboot = 88,
+ readdir = 89,
+ mmap = 90,
+ munmap = 91,
+ truncate = 92,
+ ftruncate = 93,
+ fchmod = 94,
+ fchown = 95,
+ getpriority = 96,
+ setpriority = 97,
+ profil = 98,
+ statfs = 99,
+ fstatfs = 100,
+ ioperm = 101,
+ socketcall = 102,
+ syslog = 103,
+ setitimer = 104,
+ getitimer = 105,
+ stat = 106,
+ lstat = 107,
+ fstat = 108,
+ olduname = 109,
+ iopl = 110,
+ vhangup = 111,
+ idle = 112,
+ vm86old = 113,
+ wait4 = 114,
+ swapoff = 115,
+ sysinfo = 116,
+ ipc = 117,
+ fsync = 118,
+ sigreturn = 119,
+ clone = 120,
+ setdomainname = 121,
+ uname = 122,
+ modify_ldt = 123,
+ adjtimex = 124,
+ mprotect = 125,
+ sigprocmask = 126,
+ create_module = 127,
+ init_module = 128,
+ delete_module = 129,
+ get_kernel_syms = 130,
+ quotactl = 131,
+ getpgid = 132,
+ fchdir = 133,
+ bdflush = 134,
+ sysfs = 135,
+ personality = 136,
+ afs_syscall = 137,
+ setfsuid = 138,
+ setfsgid = 139,
+ _llseek = 140,
+ getdents = 141,
+ _newselect = 142,
+ flock = 143,
+ msync = 144,
+ readv = 145,
+ writev = 146,
+ getsid = 147,
+ fdatasync = 148,
+ _sysctl = 149,
+ mlock = 150,
+ munlock = 151,
+ mlockall = 152,
+ munlockall = 153,
+ sched_setparam = 154,
+ sched_getparam = 155,
+ sched_setscheduler = 156,
+ sched_getscheduler = 157,
+ sched_yield = 158,
+ sched_get_priority_max = 159,
+ sched_get_priority_min = 160,
+ sched_rr_get_interval = 161,
+ nanosleep = 162,
+ mremap = 163,
+ setresuid = 164,
+ getresuid = 165,
+ vm86 = 166,
+ query_module = 167,
+ poll = 168,
+ nfsservctl = 169,
+ setresgid = 170,
+ getresgid = 171,
+ prctl = 172,
+ rt_sigreturn = 173,
+ rt_sigaction = 174,
+ rt_sigprocmask = 175,
+ rt_sigpending = 176,
+ rt_sigtimedwait = 177,
+ rt_sigqueueinfo = 178,
+ rt_sigsuspend = 179,
+ pread64 = 180,
+ pwrite64 = 181,
+ chown = 182,
+ getcwd = 183,
+ capget = 184,
+ capset = 185,
+ sigaltstack = 186,
+ sendfile = 187,
+ getpmsg = 188,
+ putpmsg = 189,
+ vfork = 190,
+ ugetrlimit = 191,
+ mmap2 = 192,
+ truncate64 = 193,
+ ftruncate64 = 194,
+ stat64 = 195,
+ lstat64 = 196,
+ fstat64 = 197,
+ lchown32 = 198,
+ getuid32 = 199,
+ getgid32 = 200,
+ geteuid32 = 201,
+ getegid32 = 202,
+ setreuid32 = 203,
+ setregid32 = 204,
+ getgroups32 = 205,
+ setgroups32 = 206,
+ fchown32 = 207,
+ setresuid32 = 208,
+ getresuid32 = 209,
+ setresgid32 = 210,
+ getresgid32 = 211,
+ chown32 = 212,
+ setuid32 = 213,
+ setgid32 = 214,
+ setfsuid32 = 215,
+ setfsgid32 = 216,
+ pivot_root = 217,
+ mincore = 218,
+ madvise = 219,
+ getdents64 = 220,
+ fcntl64 = 221,
+ gettid = 224,
+ readahead = 225,
+ setxattr = 226,
+ lsetxattr = 227,
+ fsetxattr = 228,
+ getxattr = 229,
+ lgetxattr = 230,
+ fgetxattr = 231,
+ listxattr = 232,
+ llistxattr = 233,
+ flistxattr = 234,
+ removexattr = 235,
+ lremovexattr = 236,
+ fremovexattr = 237,
+ tkill = 238,
+ sendfile64 = 239,
+ futex = 240,
+ sched_setaffinity = 241,
+ sched_getaffinity = 242,
+ set_thread_area = 243,
+ get_thread_area = 244,
+ io_setup = 245,
+ io_destroy = 246,
+ io_getevents = 247,
+ io_submit = 248,
+ io_cancel = 249,
+ fadvise64 = 250,
+ exit_group = 252,
+ lookup_dcookie = 253,
+ epoll_create = 254,
+ epoll_ctl = 255,
+ epoll_wait = 256,
+ remap_file_pages = 257,
+ set_tid_address = 258,
+ timer_create = 259,
+ timer_settime, // SYS_timer_create + 1
+ timer_gettime, // SYS_timer_create + 2
+ timer_getoverrun, // SYS_timer_create + 3
+ timer_delete, // SYS_timer_create + 4
+ clock_settime, // SYS_timer_create + 5
+ clock_gettime, // SYS_timer_create + 6
+ clock_getres, // SYS_timer_create + 7
+ clock_nanosleep, // SYS_timer_create + 8
+ statfs64 = 268,
+ fstatfs64 = 269,
+ tgkill = 270,
+ utimes = 271,
+ fadvise64_64 = 272,
+ vserver = 273,
+ mbind = 274,
+ get_mempolicy = 275,
+ set_mempolicy = 276,
+ mq_open = 277,
+ mq_unlink, // SYS_mq_open + 1
+ mq_timedsend, // SYS_mq_open + 2
+ mq_timedreceive, // SYS_mq_open + 3
+ mq_notify, // SYS_mq_open + 4
+ mq_getsetattr, // SYS_mq_open + 5
+ kexec_load = 283,
+ waitid = 284,
+ add_key = 286,
+ request_key = 287,
+ keyctl = 288,
+ ioprio_set = 289,
+ ioprio_get = 290,
+ inotify_init = 291,
+ inotify_add_watch = 292,
+ inotify_rm_watch = 293,
+ migrate_pages = 294,
+ openat = 295,
+ mkdirat = 296,
+ mknodat = 297,
+ fchownat = 298,
+ futimesat = 299,
+ fstatat64 = 300,
+ unlinkat = 301,
+ renameat = 302,
+ linkat = 303,
+ symlinkat = 304,
+ readlinkat = 305,
+ fchmodat = 306,
+ faccessat = 307,
+ pselect6 = 308,
+ ppoll = 309,
+ unshare = 310,
+ set_robust_list = 311,
+ get_robust_list = 312,
+ splice = 313,
+ sync_file_range = 314,
+ tee = 315,
+ vmsplice = 316,
+ move_pages = 317,
+ getcpu = 318,
+ epoll_pwait = 319,
+ utimensat = 320,
+ signalfd = 321,
+ timerfd_create = 322,
+ eventfd = 323,
+ fallocate = 324,
+ timerfd_settime = 325,
+ timerfd_gettime = 326,
+ signalfd4 = 327,
+ eventfd2 = 328,
+ epoll_create1 = 329,
+ dup3 = 330,
+ pipe2 = 331,
+ inotify_init1 = 332,
+ preadv = 333,
+ pwritev = 334,
+ rt_tgsigqueueinfo = 335,
+ perf_event_open = 336,
+ recvmmsg = 337,
+ fanotify_init = 338,
+ fanotify_mark = 339,
+ prlimit64 = 340,
+ name_to_handle_at = 341,
+ open_by_handle_at = 342,
+ clock_adjtime = 343,
+ syncfs = 344,
+ sendmmsg = 345,
+ setns = 346,
+ process_vm_readv = 347,
+ process_vm_writev = 348,
+ kcmp = 349,
+ finit_module = 350,
+ sched_setattr = 351,
+ sched_getattr = 352,
+ renameat2 = 353,
+ seccomp = 354,
+ getrandom = 355,
+ memfd_create = 356,
+ bpf = 357,
+ execveat = 358,
+ socket = 359,
+ socketpair = 360,
+ bind = 361,
+ connect = 362,
+ listen = 363,
+ accept4 = 364,
+ getsockopt = 365,
+ setsockopt = 366,
+ getsockname = 367,
+ getpeername = 368,
+ sendto = 369,
+ sendmsg = 370,
+ recvfrom = 371,
+ recvmsg = 372,
+ shutdown = 373,
+ userfaultfd = 374,
+ membarrier = 375,
+ mlock2 = 376,
+ copy_file_range = 377,
+ preadv2 = 378,
+ pwritev2 = 379,
+ pkey_mprotect = 380,
+ pkey_alloc = 381,
+ pkey_free = 382,
+ statx = 383,
+ arch_prctl = 384,
+ io_pgetevents = 385,
+ rseq = 386,
+ semget = 393,
+ semctl = 394,
+ shmget = 395,
+ shmctl = 396,
+ shmat = 397,
+ shmdt = 398,
+ msgget = 399,
+ msgsnd = 400,
+ msgrcv = 401,
+ msgctl = 402,
+ clock_gettime64 = 403,
+ clock_settime64 = 404,
+ clock_adjtime64 = 405,
+ clock_getres_time64 = 406,
+ clock_nanosleep_time64 = 407,
+ timer_gettime64 = 408,
+ timer_settime64 = 409,
+ timerfd_gettime64 = 410,
+ timerfd_settime64 = 411,
+ utimensat_time64 = 412,
+ pselect6_time64 = 413,
+ ppoll_time64 = 414,
+ io_pgetevents_time64 = 416,
+ recvmmsg_time64 = 417,
+ mq_timedsend_time64 = 418,
+ mq_timedreceive_time64 = 419,
+ semtimedop_time64 = 420,
+ rt_sigtimedwait_time64 = 421,
+ futex_time64 = 422,
+ sched_rr_get_interval_time64 = 423,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+ epoll_pwait2 = 441,
+
+ _,
+};
+
+pub const O = struct {
+ pub const CREAT = 0o100;
+ pub const EXCL = 0o200;
+ pub const NOCTTY = 0o400;
+ pub const TRUNC = 0o1000;
+ pub const APPEND = 0o2000;
+ pub const NONBLOCK = 0o4000;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0o4010000;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0o200000;
+ pub const NOFOLLOW = 0o400000;
+ pub const CLOEXEC = 0o2000000;
+
+ pub const ASYNC = 0o20000;
+ pub const DIRECT = 0o40000;
+ pub const LARGEFILE = 0o100000;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20200000;
+ pub const NDELAY = NONBLOCK;
+};
+
+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 SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+ pub const GETLK = 12;
+ pub const SETLK = 13;
+ pub const SETLKW = 14;
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+ pub const GETOWNER_UIDS = 17;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const NB = 4;
+ pub const UN = 8;
+};
+
+pub const MAP = struct {
+ pub const NORESERVE = 0x4000;
+ pub const GROWSDOWN = 0x0100;
+ pub const DENYWRITE = 0x0800;
+ pub const EXECUTABLE = 0x1000;
+ pub const LOCKED = 0x2000;
+ pub const @"32BIT" = 0x40;
+};
+
+pub const MMAP2_UNIT = 4096;
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__vdso_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6";
+};
+
+pub const ARCH = struct {};
+
+pub const Flock = extern struct {
+ type: i16,
+ whence: i16,
+ start: off_t,
+ len: off_t,
+ pid: pid_t,
+};
+
+pub const msghdr = extern struct {
+ name: ?*sockaddr,
+ namelen: socklen_t,
+ iov: [*]iovec,
+ iovlen: i32,
+ control: ?*c_void,
+ controllen: socklen_t,
+ flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ name: ?*const sockaddr,
+ namelen: socklen_t,
+ iov: [*]iovec_const,
+ iovlen: i32,
+ control: ?*c_void,
+ controllen: socklen_t,
+ flags: i32,
+};
+
+pub const blksize_t = i32;
+pub const nlink_t = u32;
+pub const time_t = isize;
+pub const mode_t = u32;
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const dev_t = u64;
+pub const blkcnt_t = i64;
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: dev_t,
+ __dev_padding: u32,
+ __ino_truncated: u32,
+ mode: mode_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ __rdev_padding: u32,
+ size: off_t,
+ blksize: blksize_t,
+ blocks: blkcnt_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ ino: ino_t,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: i32,
+ tv_usec: i32,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+pub const mcontext_t = extern struct {
+ gregs: [19]usize,
+ fpregs: [*]u8,
+ oldmask: usize,
+ cr2: usize,
+};
+
+pub const REG = struct {
+ pub const GS = 0;
+ pub const FS = 1;
+ pub const ES = 2;
+ pub const DS = 3;
+ pub const EDI = 4;
+ pub const ESI = 5;
+ pub const EBP = 6;
+ pub const ESP = 7;
+ pub const EBX = 8;
+ pub const EDX = 9;
+ pub const ECX = 10;
+ pub const EAX = 11;
+ pub const TRAPNO = 12;
+ pub const ERR = 13;
+ pub const EIP = 14;
+ pub const CS = 15;
+ pub const EFL = 16;
+ pub const UESP = 17;
+ pub const SS = 18;
+};
+
+pub const ucontext_t = extern struct {
+ flags: usize,
+ link: *ucontext_t,
+ stack: stack_t,
+ mcontext: mcontext_t,
+ sigmask: sigset_t,
+ regspace: [64]u64,
+};
+
+pub const Elf_Symndx = u32;
+
+pub const user_desc = packed struct {
+ entry_number: u32,
+ base_addr: u32,
+ limit: u32,
+ seg_32bit: u1,
+ contents: u2,
+ read_exec_only: u1,
+ limit_in_pages: u1,
+ seg_not_present: u1,
+ useable: u1,
+};
+
+/// socketcall() call numbers
+pub const SC = struct {
+ pub const socket = 1;
+ pub const bind = 2;
+ pub const connect = 3;
+ pub const listen = 4;
+ pub const accept = 5;
+ pub const getsockname = 6;
+ pub const getpeername = 7;
+ pub const socketpair = 8;
+ pub const send = 9;
+ pub const recv = 10;
+ pub const sendto = 11;
+ pub const recvfrom = 12;
+ pub const shutdown = 13;
+ pub const setsockopt = 14;
+ pub const getsockopt = 15;
+ pub const sendmsg = 16;
+ pub const recvmsg = 17;
+ pub const accept4 = 18;
+ pub const recvmmsg = 19;
+ pub const sendmmsg = 20;
+};
diff --git a/lib/std/os/linux/io_uring.zig b/lib/std/os/linux/io_uring.zig
index b74a7da3dd..a98ce009a9 100644
--- a/lib/std/os/linux/io_uring.zig
+++ b/lib/std/os/linux/io_uring.zig
@@ -535,11 +535,11 @@ pub const IO_Uring = struct {
/// `0` if the timeout completed after the specified number of events, or `-ECANCELED` if the
/// timeout was removed before it expired.
///
- /// io_uring timeouts use the `CLOCK_MONOTONIC` clock source.
+ /// io_uring timeouts use the `CLOCK.MONOTONIC` clock source.
pub fn timeout(
self: *IO_Uring,
user_data: u64,
- ts: *const os.__kernel_timespec,
+ ts: *const os.linux.kernel_timespec,
count: u32,
flags: u32,
) !*io_uring_sqe {
@@ -736,8 +736,8 @@ pub const SubmissionQueue = struct {
const mmap = try os.mmap(
null,
size,
- os.PROT_READ | os.PROT_WRITE,
- os.MAP_SHARED | os.MAP_POPULATE,
+ os.PROT.READ | os.PROT.WRITE,
+ os.MAP.SHARED | os.MAP.POPULATE,
fd,
linux.IORING_OFF_SQ_RING,
);
@@ -750,8 +750,8 @@ pub const SubmissionQueue = struct {
const mmap_sqes = try os.mmap(
null,
size_sqes,
- os.PROT_READ | os.PROT_WRITE,
- os.MAP_SHARED | os.MAP_POPULATE,
+ os.PROT.READ | os.PROT.WRITE,
+ os.MAP.SHARED | os.MAP.POPULATE,
fd,
linux.IORING_OFF_SQES,
);
@@ -979,7 +979,7 @@ pub fn io_uring_prep_close(sqe: *io_uring_sqe, fd: os.fd_t) void {
pub fn io_uring_prep_timeout(
sqe: *io_uring_sqe,
- ts: *const os.__kernel_timespec,
+ ts: *const os.linux.kernel_timespec,
count: u32,
flags: u32,
) void {
@@ -1136,7 +1136,7 @@ test "readv" {
};
defer ring.deinit();
- const fd = try os.openZ("/dev/zero", os.O_RDONLY | os.O_CLOEXEC, 0);
+ const fd = try os.openZ("/dev/zero", os.O.RDONLY | os.O.CLOEXEC, 0);
defer os.close(fd);
// Linux Kernel 5.4 supports IORING_REGISTER_FILES but not sparse fd sets (i.e. an fd of -1).
@@ -1295,14 +1295,14 @@ test "openat" {
const path = "test_io_uring_openat";
defer std.fs.cwd().deleteFile(path) catch {};
- const flags: u32 = os.O_CLOEXEC | os.O_RDWR | os.O_CREAT;
+ const flags: u32 = os.O.CLOEXEC | os.O.RDWR | os.O.CREAT;
const mode: os.mode_t = 0o666;
- const sqe_openat = try ring.openat(0x33333333, linux.AT_FDCWD, path, flags, mode);
+ const sqe_openat = try ring.openat(0x33333333, linux.AT.FDCWD, path, flags, mode);
try testing.expectEqual(io_uring_sqe{
.opcode = .OPENAT,
.flags = 0,
.ioprio = 0,
- .fd = linux.AT_FDCWD,
+ .fd = linux.AT.FDCWD,
.off = 0,
.addr = @ptrToInt(path),
.len = mode,
@@ -1318,7 +1318,7 @@ test "openat" {
const cqe_openat = try ring.copy_cqe();
try testing.expectEqual(@as(u64, 0x33333333), cqe_openat.user_data);
if (cqe_openat.err() == .INVAL) return error.SkipZigTest;
- // AT_FDCWD is not fully supported before kernel 5.6:
+ // AT.FDCWD is not fully supported before kernel 5.6:
// See https://lore.kernel.org/io-uring/20200207155039.12819-1-axboe@kernel.dk/T/
// We use IORING_FEAT_RW_CUR_POS to know if we are pre-5.6 since that feature was added in 5.6.
if (cqe_openat.err() == .BADF and (ring.features & linux.IORING_FEAT_RW_CUR_POS) == 0) {
@@ -1372,9 +1372,9 @@ test "accept/connect/send/recv" {
const address = try net.Address.parseIp4("127.0.0.1", 3131);
const kernel_backlog = 1;
- const server = try os.socket(address.any.family, os.SOCK_STREAM | os.SOCK_CLOEXEC, 0);
+ const server = try os.socket(address.any.family, os.SOCK.STREAM | os.SOCK.CLOEXEC, 0);
defer os.close(server);
- try os.setsockopt(server, os.SOL_SOCKET, os.SO_REUSEADDR, &mem.toBytes(@as(c_int, 1)));
+ try os.setsockopt(server, os.SOL.SOCKET, os.SO.REUSEADDR, &mem.toBytes(@as(c_int, 1)));
try os.bind(server, &address.any, address.getOsSockLen());
try os.listen(server, kernel_backlog);
@@ -1386,7 +1386,7 @@ test "accept/connect/send/recv" {
_ = try ring.accept(0xaaaaaaaa, server, &accept_addr, &accept_addr_len, 0);
try testing.expectEqual(@as(u32, 1), try ring.submit());
- const client = try os.socket(address.any.family, os.SOCK_STREAM | os.SOCK_CLOEXEC, 0);
+ const client = try os.socket(address.any.family, os.SOCK.STREAM | os.SOCK.CLOEXEC, 0);
defer os.close(client);
_ = try ring.connect(0xcccccccc, client, &address.any, address.getOsSockLen());
try testing.expectEqual(@as(u32, 1), try ring.submit());
@@ -1450,7 +1450,7 @@ test "timeout (after a relative time)" {
const ms = 10;
const margin = 5;
- const ts = os.__kernel_timespec{ .tv_sec = 0, .tv_nsec = ms * 1000000 };
+ const ts = os.linux.kernel_timespec{ .tv_sec = 0, .tv_nsec = ms * 1000000 };
const started = std.time.milliTimestamp();
const sqe = try ring.timeout(0x55555555, &ts, 0, 0);
@@ -1479,7 +1479,7 @@ test "timeout (after a number of completions)" {
};
defer ring.deinit();
- const ts = os.__kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 };
+ const ts = os.linux.kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 };
const count_completions: u64 = 1;
const sqe_timeout = try ring.timeout(0x66666666, &ts, count_completions, 0);
try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode);
@@ -1512,7 +1512,7 @@ test "timeout_remove" {
};
defer ring.deinit();
- const ts = os.__kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 };
+ const ts = os.linux.kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 };
const sqe_timeout = try ring.timeout(0x88888888, &ts, 0, 0);
try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode);
try testing.expectEqual(@as(u64, 0x88888888), sqe_timeout.user_data);
diff --git a/lib/std/os/linux/mips.zig b/lib/std/os/linux/mips.zig
index f59f04b130..b3697405f7 100644
--- a/lib/std/os/linux/mips.zig
+++ b/lib/std/os/linux/mips.zig
@@ -1,4 +1,13 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const linux = std.os.linux;
+const socklen_t = linux.socklen_t;
+const iovec = linux.iovec;
+const iovec_const = linux.iovec_const;
+const uid_t = linux.uid_t;
+const gid_t = linux.gid_t;
+const pid_t = linux.pid_t;
+const timespec = linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile (
@@ -197,3 +206,562 @@ pub fn restore_rt() callconv(.Naked) void {
: "memory", "cc", "$7"
);
}
+
+pub const SYS = enum(usize) {
+ pub const Linux = 4000;
+
+ syscall = Linux + 0,
+ exit = Linux + 1,
+ fork = Linux + 2,
+ read = Linux + 3,
+ write = Linux + 4,
+ open = Linux + 5,
+ close = Linux + 6,
+ waitpid = Linux + 7,
+ creat = Linux + 8,
+ link = Linux + 9,
+ unlink = Linux + 10,
+ execve = Linux + 11,
+ chdir = Linux + 12,
+ time = Linux + 13,
+ mknod = Linux + 14,
+ chmod = Linux + 15,
+ lchown = Linux + 16,
+ @"break" = Linux + 17,
+ unused18 = Linux + 18,
+ lseek = Linux + 19,
+ getpid = Linux + 20,
+ mount = Linux + 21,
+ umount = Linux + 22,
+ setuid = Linux + 23,
+ getuid = Linux + 24,
+ stime = Linux + 25,
+ ptrace = Linux + 26,
+ alarm = Linux + 27,
+ unused28 = Linux + 28,
+ pause = Linux + 29,
+ utime = Linux + 30,
+ stty = Linux + 31,
+ gtty = Linux + 32,
+ access = Linux + 33,
+ nice = Linux + 34,
+ ftime = Linux + 35,
+ sync = Linux + 36,
+ kill = Linux + 37,
+ rename = Linux + 38,
+ mkdir = Linux + 39,
+ rmdir = Linux + 40,
+ dup = Linux + 41,
+ pipe = Linux + 42,
+ times = Linux + 43,
+ prof = Linux + 44,
+ brk = Linux + 45,
+ setgid = Linux + 46,
+ getgid = Linux + 47,
+ signal = Linux + 48,
+ geteuid = Linux + 49,
+ getegid = Linux + 50,
+ acct = Linux + 51,
+ umount2 = Linux + 52,
+ lock = Linux + 53,
+ ioctl = Linux + 54,
+ fcntl = Linux + 55,
+ mpx = Linux + 56,
+ setpgid = Linux + 57,
+ ulimit = Linux + 58,
+ unused59 = Linux + 59,
+ umask = Linux + 60,
+ chroot = Linux + 61,
+ ustat = Linux + 62,
+ dup2 = Linux + 63,
+ getppid = Linux + 64,
+ getpgrp = Linux + 65,
+ setsid = Linux + 66,
+ sigaction = Linux + 67,
+ sgetmask = Linux + 68,
+ ssetmask = Linux + 69,
+ setreuid = Linux + 70,
+ setregid = Linux + 71,
+ sigsuspend = Linux + 72,
+ sigpending = Linux + 73,
+ sethostname = Linux + 74,
+ setrlimit = Linux + 75,
+ getrlimit = Linux + 76,
+ getrusage = Linux + 77,
+ gettimeofday = Linux + 78,
+ settimeofday = Linux + 79,
+ getgroups = Linux + 80,
+ setgroups = Linux + 81,
+ reserved82 = Linux + 82,
+ symlink = Linux + 83,
+ unused84 = Linux + 84,
+ readlink = Linux + 85,
+ uselib = Linux + 86,
+ swapon = Linux + 87,
+ reboot = Linux + 88,
+ readdir = Linux + 89,
+ mmap = Linux + 90,
+ munmap = Linux + 91,
+ truncate = Linux + 92,
+ ftruncate = Linux + 93,
+ fchmod = Linux + 94,
+ fchown = Linux + 95,
+ getpriority = Linux + 96,
+ setpriority = Linux + 97,
+ profil = Linux + 98,
+ statfs = Linux + 99,
+ fstatfs = Linux + 100,
+ ioperm = Linux + 101,
+ socketcall = Linux + 102,
+ syslog = Linux + 103,
+ setitimer = Linux + 104,
+ getitimer = Linux + 105,
+ stat = Linux + 106,
+ lstat = Linux + 107,
+ fstat = Linux + 108,
+ unused109 = Linux + 109,
+ iopl = Linux + 110,
+ vhangup = Linux + 111,
+ idle = Linux + 112,
+ vm86 = Linux + 113,
+ wait4 = Linux + 114,
+ swapoff = Linux + 115,
+ sysinfo = Linux + 116,
+ ipc = Linux + 117,
+ fsync = Linux + 118,
+ sigreturn = Linux + 119,
+ clone = Linux + 120,
+ setdomainname = Linux + 121,
+ uname = Linux + 122,
+ modify_ldt = Linux + 123,
+ adjtimex = Linux + 124,
+ mprotect = Linux + 125,
+ sigprocmask = Linux + 126,
+ create_module = Linux + 127,
+ init_module = Linux + 128,
+ delete_module = Linux + 129,
+ get_kernel_syms = Linux + 130,
+ quotactl = Linux + 131,
+ getpgid = Linux + 132,
+ fchdir = Linux + 133,
+ bdflush = Linux + 134,
+ sysfs = Linux + 135,
+ personality = Linux + 136,
+ afs_syscall = Linux + 137,
+ setfsuid = Linux + 138,
+ setfsgid = Linux + 139,
+ _llseek = Linux + 140,
+ getdents = Linux + 141,
+ _newselect = Linux + 142,
+ flock = Linux + 143,
+ msync = Linux + 144,
+ readv = Linux + 145,
+ writev = Linux + 146,
+ cacheflush = Linux + 147,
+ cachectl = Linux + 148,
+ sysmips = Linux + 149,
+ unused150 = Linux + 150,
+ getsid = Linux + 151,
+ fdatasync = Linux + 152,
+ _sysctl = Linux + 153,
+ mlock = Linux + 154,
+ munlock = Linux + 155,
+ mlockall = Linux + 156,
+ munlockall = Linux + 157,
+ sched_setparam = Linux + 158,
+ sched_getparam = Linux + 159,
+ sched_setscheduler = Linux + 160,
+ sched_getscheduler = Linux + 161,
+ sched_yield = Linux + 162,
+ sched_get_priority_max = Linux + 163,
+ sched_get_priority_min = Linux + 164,
+ sched_rr_get_interval = Linux + 165,
+ nanosleep = Linux + 166,
+ mremap = Linux + 167,
+ accept = Linux + 168,
+ bind = Linux + 169,
+ connect = Linux + 170,
+ getpeername = Linux + 171,
+ getsockname = Linux + 172,
+ getsockopt = Linux + 173,
+ listen = Linux + 174,
+ recv = Linux + 175,
+ recvfrom = Linux + 176,
+ recvmsg = Linux + 177,
+ send = Linux + 178,
+ sendmsg = Linux + 179,
+ sendto = Linux + 180,
+ setsockopt = Linux + 181,
+ shutdown = Linux + 182,
+ socket = Linux + 183,
+ socketpair = Linux + 184,
+ setresuid = Linux + 185,
+ getresuid = Linux + 186,
+ query_module = Linux + 187,
+ poll = Linux + 188,
+ nfsservctl = Linux + 189,
+ setresgid = Linux + 190,
+ getresgid = Linux + 191,
+ prctl = Linux + 192,
+ rt_sigreturn = Linux + 193,
+ rt_sigaction = Linux + 194,
+ rt_sigprocmask = Linux + 195,
+ rt_sigpending = Linux + 196,
+ rt_sigtimedwait = Linux + 197,
+ rt_sigqueueinfo = Linux + 198,
+ rt_sigsuspend = Linux + 199,
+ pread64 = Linux + 200,
+ pwrite64 = Linux + 201,
+ chown = Linux + 202,
+ getcwd = Linux + 203,
+ capget = Linux + 204,
+ capset = Linux + 205,
+ sigaltstack = Linux + 206,
+ sendfile = Linux + 207,
+ getpmsg = Linux + 208,
+ putpmsg = Linux + 209,
+ mmap2 = Linux + 210,
+ truncate64 = Linux + 211,
+ ftruncate64 = Linux + 212,
+ stat64 = Linux + 213,
+ lstat64 = Linux + 214,
+ fstat64 = Linux + 215,
+ pivot_root = Linux + 216,
+ mincore = Linux + 217,
+ madvise = Linux + 218,
+ getdents64 = Linux + 219,
+ fcntl64 = Linux + 220,
+ reserved221 = Linux + 221,
+ gettid = Linux + 222,
+ readahead = Linux + 223,
+ setxattr = Linux + 224,
+ lsetxattr = Linux + 225,
+ fsetxattr = Linux + 226,
+ getxattr = Linux + 227,
+ lgetxattr = Linux + 228,
+ fgetxattr = Linux + 229,
+ listxattr = Linux + 230,
+ llistxattr = Linux + 231,
+ flistxattr = Linux + 232,
+ removexattr = Linux + 233,
+ lremovexattr = Linux + 234,
+ fremovexattr = Linux + 235,
+ tkill = Linux + 236,
+ sendfile64 = Linux + 237,
+ futex = Linux + 238,
+ sched_setaffinity = Linux + 239,
+ sched_getaffinity = Linux + 240,
+ io_setup = Linux + 241,
+ io_destroy = Linux + 242,
+ io_getevents = Linux + 243,
+ io_submit = Linux + 244,
+ io_cancel = Linux + 245,
+ exit_group = Linux + 246,
+ lookup_dcookie = Linux + 247,
+ epoll_create = Linux + 248,
+ epoll_ctl = Linux + 249,
+ epoll_wait = Linux + 250,
+ remap_file_pages = Linux + 251,
+ set_tid_address = Linux + 252,
+ restart_syscall = Linux + 253,
+ fadvise64 = Linux + 254,
+ statfs64 = Linux + 255,
+ fstatfs64 = Linux + 256,
+ timer_create = Linux + 257,
+ timer_settime = Linux + 258,
+ timer_gettime = Linux + 259,
+ timer_getoverrun = Linux + 260,
+ timer_delete = Linux + 261,
+ clock_settime = Linux + 262,
+ clock_gettime = Linux + 263,
+ clock_getres = Linux + 264,
+ clock_nanosleep = Linux + 265,
+ tgkill = Linux + 266,
+ utimes = Linux + 267,
+ mbind = Linux + 268,
+ get_mempolicy = Linux + 269,
+ set_mempolicy = Linux + 270,
+ mq_open = Linux + 271,
+ mq_unlink = Linux + 272,
+ mq_timedsend = Linux + 273,
+ mq_timedreceive = Linux + 274,
+ mq_notify = Linux + 275,
+ mq_getsetattr = Linux + 276,
+ vserver = Linux + 277,
+ waitid = Linux + 278,
+ add_key = Linux + 280,
+ request_key = Linux + 281,
+ keyctl = Linux + 282,
+ set_thread_area = Linux + 283,
+ inotify_init = Linux + 284,
+ inotify_add_watch = Linux + 285,
+ inotify_rm_watch = Linux + 286,
+ migrate_pages = Linux + 287,
+ openat = Linux + 288,
+ mkdirat = Linux + 289,
+ mknodat = Linux + 290,
+ fchownat = Linux + 291,
+ futimesat = Linux + 292,
+ fstatat64 = Linux + 293,
+ unlinkat = Linux + 294,
+ renameat = Linux + 295,
+ linkat = Linux + 296,
+ symlinkat = Linux + 297,
+ readlinkat = Linux + 298,
+ fchmodat = Linux + 299,
+ faccessat = Linux + 300,
+ pselect6 = Linux + 301,
+ ppoll = Linux + 302,
+ unshare = Linux + 303,
+ splice = Linux + 304,
+ sync_file_range = Linux + 305,
+ tee = Linux + 306,
+ vmsplice = Linux + 307,
+ move_pages = Linux + 308,
+ set_robust_list = Linux + 309,
+ get_robust_list = Linux + 310,
+ kexec_load = Linux + 311,
+ getcpu = Linux + 312,
+ epoll_pwait = Linux + 313,
+ ioprio_set = Linux + 314,
+ ioprio_get = Linux + 315,
+ utimensat = Linux + 316,
+ signalfd = Linux + 317,
+ timerfd = Linux + 318,
+ eventfd = Linux + 319,
+ fallocate = Linux + 320,
+ timerfd_create = Linux + 321,
+ timerfd_gettime = Linux + 322,
+ timerfd_settime = Linux + 323,
+ signalfd4 = Linux + 324,
+ eventfd2 = Linux + 325,
+ epoll_create1 = Linux + 326,
+ dup3 = Linux + 327,
+ pipe2 = Linux + 328,
+ inotify_init1 = Linux + 329,
+ preadv = Linux + 330,
+ pwritev = Linux + 331,
+ rt_tgsigqueueinfo = Linux + 332,
+ perf_event_open = Linux + 333,
+ accept4 = Linux + 334,
+ recvmmsg = Linux + 335,
+ fanotify_init = Linux + 336,
+ fanotify_mark = Linux + 337,
+ prlimit64 = Linux + 338,
+ name_to_handle_at = Linux + 339,
+ open_by_handle_at = Linux + 340,
+ clock_adjtime = Linux + 341,
+ syncfs = Linux + 342,
+ sendmmsg = Linux + 343,
+ setns = Linux + 344,
+ process_vm_readv = Linux + 345,
+ process_vm_writev = Linux + 346,
+ kcmp = Linux + 347,
+ finit_module = Linux + 348,
+ sched_setattr = Linux + 349,
+ sched_getattr = Linux + 350,
+ renameat2 = Linux + 351,
+ seccomp = Linux + 352,
+ getrandom = Linux + 353,
+ memfd_create = Linux + 354,
+ bpf = Linux + 355,
+ execveat = Linux + 356,
+ userfaultfd = Linux + 357,
+ membarrier = Linux + 358,
+ mlock2 = Linux + 359,
+ copy_file_range = Linux + 360,
+ preadv2 = Linux + 361,
+ pwritev2 = Linux + 362,
+ pkey_mprotect = Linux + 363,
+ pkey_alloc = Linux + 364,
+ pkey_free = Linux + 365,
+ statx = Linux + 366,
+ rseq = Linux + 367,
+ io_pgetevents = Linux + 368,
+ semget = Linux + 393,
+ semctl = Linux + 394,
+ shmget = Linux + 395,
+ shmctl = Linux + 396,
+ shmat = Linux + 397,
+ shmdt = Linux + 398,
+ msgget = Linux + 399,
+ msgsnd = Linux + 400,
+ msgrcv = Linux + 401,
+ msgctl = Linux + 402,
+ clock_gettime64 = Linux + 403,
+ clock_settime64 = Linux + 404,
+ clock_adjtime64 = Linux + 405,
+ clock_getres_time64 = Linux + 406,
+ clock_nanosleep_time64 = Linux + 407,
+ timer_gettime64 = Linux + 408,
+ timer_settime64 = Linux + 409,
+ timerfd_gettime64 = Linux + 410,
+ timerfd_settime64 = Linux + 411,
+ utimensat_time64 = Linux + 412,
+ pselect6_time64 = Linux + 413,
+ ppoll_time64 = Linux + 414,
+ io_pgetevents_time64 = Linux + 416,
+ recvmmsg_time64 = Linux + 417,
+ mq_timedsend_time64 = Linux + 418,
+ mq_timedreceive_time64 = Linux + 419,
+ semtimedop_time64 = Linux + 420,
+ rt_sigtimedwait_time64 = Linux + 421,
+ futex_time64 = Linux + 422,
+ sched_rr_get_interval_time64 = Linux + 423,
+ pidfd_send_signal = Linux + 424,
+ io_uring_setup = Linux + 425,
+ io_uring_enter = Linux + 426,
+ io_uring_register = Linux + 427,
+ open_tree = Linux + 428,
+ move_mount = Linux + 429,
+ fsopen = Linux + 430,
+ fsconfig = Linux + 431,
+ fsmount = Linux + 432,
+ fspick = Linux + 433,
+ pidfd_open = Linux + 434,
+ clone3 = Linux + 435,
+ close_range = Linux + 436,
+ openat2 = Linux + 437,
+ pidfd_getfd = Linux + 438,
+ faccessat2 = Linux + 439,
+ process_madvise = Linux + 440,
+ epoll_pwait2 = Linux + 441,
+
+ _,
+};
+
+pub const O = struct {
+ pub const CREAT = 0o0400;
+ pub const EXCL = 0o02000;
+ pub const NOCTTY = 0o04000;
+ pub const TRUNC = 0o01000;
+ pub const APPEND = 0o0010;
+ pub const NONBLOCK = 0o0200;
+ pub const DSYNC = 0o0020;
+ pub const SYNC = 0o040020;
+ pub const RSYNC = 0o040020;
+ pub const DIRECTORY = 0o0200000;
+ pub const NOFOLLOW = 0o0400000;
+ pub const CLOEXEC = 0o02000000;
+
+ pub const ASYNC = 0o010000;
+ pub const DIRECT = 0o0100000;
+ pub const LARGEFILE = 0o020000;
+ pub const NOATIME = 0o01000000;
+ pub const PATH = 0o010000000;
+ pub const TMPFILE = 0o020200000;
+ pub const NDELAY = NONBLOCK;
+};
+
+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 SETOWN = 24;
+ pub const GETOWN = 23;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const GETLK = 33;
+ pub const SETLK = 34;
+ pub const SETLKW = 35;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const MMAP2_UNIT = 4096;
+
+pub const MAP = struct {
+ pub const NORESERVE = 0x0400;
+ pub const GROWSDOWN = 0x1000;
+ pub const DENYWRITE = 0x2000;
+ pub const EXECUTABLE = 0x4000;
+ pub const LOCKED = 0x8000;
+ pub const @"32BIT" = 0x40;
+};
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__kernel_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6.39";
+};
+
+pub const Flock = extern struct {
+ l_type: i16,
+ l_whence: i16,
+ __pad0: [4]u8,
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ __unused: [4]u8,
+};
+
+pub const blksize_t = i32;
+pub const nlink_t = u32;
+pub const time_t = i32;
+pub const mode_t = u32;
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const dev_t = u64;
+pub const blkcnt_t = i64;
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: u32,
+ __pad0: [3]u32, // Reserved for st_dev expansion
+ ino: ino_t,
+ mode: mode_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: u32,
+ __pad1: [3]u32,
+ size: off_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ blksize: blksize_t,
+ __pad3: u32,
+ blocks: blkcnt_t,
+ __pad4: [14]usize,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: isize,
+ tv_usec: isize,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+pub const Elf_Symndx = u32;
diff --git a/lib/std/os/linux/powerpc.zig b/lib/std/os/linux/powerpc.zig
index 760655b5fa..30001c48c6 100644
--- a/lib/std/os/linux/powerpc.zig
+++ b/lib/std/os/linux/powerpc.zig
@@ -1,4 +1,16 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const linux = std.os.linux;
+const socklen_t = linux.socklen_t;
+const iovec = linux.iovec;
+const iovec_const = linux.iovec_const;
+const uid_t = linux.uid_t;
+const gid_t = linux.gid_t;
+const pid_t = linux.pid_t;
+const stack_t = linux.stack_t;
+const sigset_t = linux.sigset_t;
+const sockaddr = linux.sockaddr;
+const timespec = linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile (
@@ -125,3 +137,613 @@ pub fn restore_rt() callconv(.Naked) void {
: "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"
);
}
+
+pub const SYS = enum(usize) {
+ restart_syscall = 0,
+ exit = 1,
+ fork = 2,
+ read = 3,
+ write = 4,
+ open = 5,
+ close = 6,
+ waitpid = 7,
+ creat = 8,
+ link = 9,
+ unlink = 10,
+ execve = 11,
+ chdir = 12,
+ time = 13,
+ mknod = 14,
+ chmod = 15,
+ lchown = 16,
+ @"break" = 17,
+ oldstat = 18,
+ lseek = 19,
+ getpid = 20,
+ mount = 21,
+ umount = 22,
+ setuid = 23,
+ getuid = 24,
+ stime = 25,
+ ptrace = 26,
+ alarm = 27,
+ oldfstat = 28,
+ pause = 29,
+ utime = 30,
+ stty = 31,
+ gtty = 32,
+ access = 33,
+ nice = 34,
+ ftime = 35,
+ sync = 36,
+ kill = 37,
+ rename = 38,
+ mkdir = 39,
+ rmdir = 40,
+ dup = 41,
+ pipe = 42,
+ times = 43,
+ prof = 44,
+ brk = 45,
+ setgid = 46,
+ getgid = 47,
+ signal = 48,
+ geteuid = 49,
+ getegid = 50,
+ acct = 51,
+ umount2 = 52,
+ lock = 53,
+ ioctl = 54,
+ fcntl = 55,
+ mpx = 56,
+ setpgid = 57,
+ ulimit = 58,
+ oldolduname = 59,
+ umask = 60,
+ chroot = 61,
+ ustat = 62,
+ dup2 = 63,
+ getppid = 64,
+ getpgrp = 65,
+ setsid = 66,
+ sigaction = 67,
+ sgetmask = 68,
+ ssetmask = 69,
+ setreuid = 70,
+ setregid = 71,
+ sigsuspend = 72,
+ sigpending = 73,
+ sethostname = 74,
+ setrlimit = 75,
+ getrlimit = 76,
+ getrusage = 77,
+ gettimeofday = 78,
+ settimeofday = 79,
+ getgroups = 80,
+ setgroups = 81,
+ select = 82,
+ symlink = 83,
+ oldlstat = 84,
+ readlink = 85,
+ uselib = 86,
+ swapon = 87,
+ reboot = 88,
+ readdir = 89,
+ mmap = 90,
+ munmap = 91,
+ truncate = 92,
+ ftruncate = 93,
+ fchmod = 94,
+ fchown = 95,
+ getpriority = 96,
+ setpriority = 97,
+ profil = 98,
+ statfs = 99,
+ fstatfs = 100,
+ ioperm = 101,
+ socketcall = 102,
+ syslog = 103,
+ setitimer = 104,
+ getitimer = 105,
+ stat = 106,
+ lstat = 107,
+ fstat = 108,
+ olduname = 109,
+ iopl = 110,
+ vhangup = 111,
+ idle = 112,
+ vm86 = 113,
+ wait4 = 114,
+ swapoff = 115,
+ sysinfo = 116,
+ ipc = 117,
+ fsync = 118,
+ sigreturn = 119,
+ clone = 120,
+ setdomainname = 121,
+ uname = 122,
+ modify_ldt = 123,
+ adjtimex = 124,
+ mprotect = 125,
+ sigprocmask = 126,
+ create_module = 127,
+ init_module = 128,
+ delete_module = 129,
+ get_kernel_syms = 130,
+ quotactl = 131,
+ getpgid = 132,
+ fchdir = 133,
+ bdflush = 134,
+ sysfs = 135,
+ personality = 136,
+ afs_syscall = 137,
+ setfsuid = 138,
+ setfsgid = 139,
+ _llseek = 140,
+ getdents = 141,
+ _newselect = 142,
+ flock = 143,
+ msync = 144,
+ readv = 145,
+ writev = 146,
+ getsid = 147,
+ fdatasync = 148,
+ _sysctl = 149,
+ mlock = 150,
+ munlock = 151,
+ mlockall = 152,
+ munlockall = 153,
+ sched_setparam = 154,
+ sched_getparam = 155,
+ sched_setscheduler = 156,
+ sched_getscheduler = 157,
+ sched_yield = 158,
+ sched_get_priority_max = 159,
+ sched_get_priority_min = 160,
+ sched_rr_get_interval = 161,
+ nanosleep = 162,
+ mremap = 163,
+ setresuid = 164,
+ getresuid = 165,
+ query_module = 166,
+ poll = 167,
+ nfsservctl = 168,
+ setresgid = 169,
+ getresgid = 170,
+ prctl = 171,
+ rt_sigreturn = 172,
+ rt_sigaction = 173,
+ rt_sigprocmask = 174,
+ rt_sigpending = 175,
+ rt_sigtimedwait = 176,
+ rt_sigqueueinfo = 177,
+ rt_sigsuspend = 178,
+ pread64 = 179,
+ pwrite64 = 180,
+ chown = 181,
+ getcwd = 182,
+ capget = 183,
+ capset = 184,
+ sigaltstack = 185,
+ sendfile = 186,
+ getpmsg = 187,
+ putpmsg = 188,
+ vfork = 189,
+ ugetrlimit = 190,
+ readahead = 191,
+ mmap2 = 192,
+ truncate64 = 193,
+ ftruncate64 = 194,
+ stat64 = 195,
+ lstat64 = 196,
+ fstat64 = 197,
+ pciconfig_read = 198,
+ pciconfig_write = 199,
+ pciconfig_iobase = 200,
+ multiplexer = 201,
+ getdents64 = 202,
+ pivot_root = 203,
+ fcntl64 = 204,
+ madvise = 205,
+ mincore = 206,
+ gettid = 207,
+ tkill = 208,
+ setxattr = 209,
+ lsetxattr = 210,
+ fsetxattr = 211,
+ getxattr = 212,
+ lgetxattr = 213,
+ fgetxattr = 214,
+ listxattr = 215,
+ llistxattr = 216,
+ flistxattr = 217,
+ removexattr = 218,
+ lremovexattr = 219,
+ fremovexattr = 220,
+ futex = 221,
+ sched_setaffinity = 222,
+ sched_getaffinity = 223,
+ tuxcall = 225,
+ sendfile64 = 226,
+ io_setup = 227,
+ io_destroy = 228,
+ io_getevents = 229,
+ io_submit = 230,
+ io_cancel = 231,
+ set_tid_address = 232,
+ fadvise64 = 233,
+ exit_group = 234,
+ lookup_dcookie = 235,
+ epoll_create = 236,
+ epoll_ctl = 237,
+ epoll_wait = 238,
+ remap_file_pages = 239,
+ timer_create = 240,
+ timer_settime = 241,
+ timer_gettime = 242,
+ timer_getoverrun = 243,
+ timer_delete = 244,
+ clock_settime = 245,
+ clock_gettime = 246,
+ clock_getres = 247,
+ clock_nanosleep = 248,
+ swapcontext = 249,
+ tgkill = 250,
+ utimes = 251,
+ statfs64 = 252,
+ fstatfs64 = 253,
+ fadvise64_64 = 254,
+ rtas = 255,
+ sys_debug_setcontext = 256,
+ migrate_pages = 258,
+ mbind = 259,
+ get_mempolicy = 260,
+ set_mempolicy = 261,
+ mq_open = 262,
+ mq_unlink = 263,
+ mq_timedsend = 264,
+ mq_timedreceive = 265,
+ mq_notify = 266,
+ mq_getsetattr = 267,
+ kexec_load = 268,
+ add_key = 269,
+ request_key = 270,
+ keyctl = 271,
+ waitid = 272,
+ ioprio_set = 273,
+ ioprio_get = 274,
+ inotify_init = 275,
+ inotify_add_watch = 276,
+ inotify_rm_watch = 277,
+ spu_run = 278,
+ spu_create = 279,
+ pselect6 = 280,
+ ppoll = 281,
+ unshare = 282,
+ splice = 283,
+ tee = 284,
+ vmsplice = 285,
+ openat = 286,
+ mkdirat = 287,
+ mknodat = 288,
+ fchownat = 289,
+ futimesat = 290,
+ fstatat64 = 291,
+ unlinkat = 292,
+ renameat = 293,
+ linkat = 294,
+ symlinkat = 295,
+ readlinkat = 296,
+ fchmodat = 297,
+ faccessat = 298,
+ get_robust_list = 299,
+ set_robust_list = 300,
+ move_pages = 301,
+ getcpu = 302,
+ epoll_pwait = 303,
+ utimensat = 304,
+ signalfd = 305,
+ timerfd_create = 306,
+ eventfd = 307,
+ sync_file_range = 308,
+ fallocate = 309,
+ subpage_prot = 310,
+ timerfd_settime = 311,
+ timerfd_gettime = 312,
+ signalfd4 = 313,
+ eventfd2 = 314,
+ epoll_create1 = 315,
+ dup3 = 316,
+ pipe2 = 317,
+ inotify_init1 = 318,
+ perf_event_open = 319,
+ preadv = 320,
+ pwritev = 321,
+ rt_tgsigqueueinfo = 322,
+ fanotify_init = 323,
+ fanotify_mark = 324,
+ prlimit64 = 325,
+ socket = 326,
+ bind = 327,
+ connect = 328,
+ listen = 329,
+ accept = 330,
+ getsockname = 331,
+ getpeername = 332,
+ socketpair = 333,
+ send = 334,
+ sendto = 335,
+ recv = 336,
+ recvfrom = 337,
+ shutdown = 338,
+ setsockopt = 339,
+ getsockopt = 340,
+ sendmsg = 341,
+ recvmsg = 342,
+ recvmmsg = 343,
+ accept4 = 344,
+ name_to_handle_at = 345,
+ open_by_handle_at = 346,
+ clock_adjtime = 347,
+ syncfs = 348,
+ sendmmsg = 349,
+ setns = 350,
+ process_vm_readv = 351,
+ process_vm_writev = 352,
+ finit_module = 353,
+ kcmp = 354,
+ sched_setattr = 355,
+ sched_getattr = 356,
+ renameat2 = 357,
+ seccomp = 358,
+ getrandom = 359,
+ memfd_create = 360,
+ bpf = 361,
+ execveat = 362,
+ switch_endian = 363,
+ userfaultfd = 364,
+ membarrier = 365,
+ mlock2 = 378,
+ copy_file_range = 379,
+ preadv2 = 380,
+ pwritev2 = 381,
+ kexec_file_load = 382,
+ statx = 383,
+ pkey_alloc = 384,
+ pkey_free = 385,
+ pkey_mprotect = 386,
+ rseq = 387,
+ io_pgetevents = 388,
+ semget = 393,
+ semctl = 394,
+ shmget = 395,
+ shmctl = 396,
+ shmat = 397,
+ shmdt = 398,
+ msgget = 399,
+ msgsnd = 400,
+ msgrcv = 401,
+ msgctl = 402,
+ clock_gettime64 = 403,
+ clock_settime64 = 404,
+ clock_adjtime64 = 405,
+ clock_getres_time64 = 406,
+ clock_nanosleep_time64 = 407,
+ timer_gettime64 = 408,
+ timer_settime64 = 409,
+ timerfd_gettime64 = 410,
+ timerfd_settime64 = 411,
+ utimensat_time64 = 412,
+ pselect6_time64 = 413,
+ ppoll_time64 = 414,
+ io_pgetevents_time64 = 416,
+ recvmmsg_time64 = 417,
+ mq_timedsend_time64 = 418,
+ mq_timedreceive_time64 = 419,
+ semtimedop_time64 = 420,
+ rt_sigtimedwait_time64 = 421,
+ futex_time64 = 422,
+ sched_rr_get_interval_time64 = 423,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+};
+
+pub const O = struct {
+ pub const CREAT = 0o100;
+ pub const EXCL = 0o200;
+ pub const NOCTTY = 0o400;
+ pub const TRUNC = 0o1000;
+ pub const APPEND = 0o2000;
+ pub const NONBLOCK = 0o4000;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0o4010000;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0o40000;
+ pub const NOFOLLOW = 0o100000;
+ pub const CLOEXEC = 0o2000000;
+
+ pub const ASYNC = 0o20000;
+ pub const DIRECT = 0o400000;
+ pub const LARGEFILE = 0o200000;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20040000;
+ pub const NDELAY = NONBLOCK;
+};
+
+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 SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const GETLK = 12;
+ pub const SETLK = 13;
+ pub const SETLKW = 14;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const MAP = struct {
+ /// stack-like segment
+ pub const GROWSDOWN = 0x0100;
+ /// ETXTBSY
+ pub const DENYWRITE = 0x0800;
+ /// mark it as an executable
+ pub const EXECUTABLE = 0x1000;
+ /// pages are locked
+ pub const LOCKED = 0x0080;
+ /// don't check for reservations
+ pub const NORESERVE = 0x0040;
+};
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__kernel_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6.15";
+};
+
+pub const Flock = extern struct {
+ l_type: i16,
+ l_whence: i16,
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+};
+
+pub const msghdr = extern struct {
+ msg_name: ?*sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec,
+ msg_iovlen: usize,
+ msg_control: ?*c_void,
+ msg_controllen: socklen_t,
+ msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ msg_name: ?*const sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec_const,
+ msg_iovlen: usize,
+ msg_control: ?*c_void,
+ msg_controllen: socklen_t,
+ msg_flags: i32,
+};
+
+pub const blksize_t = i32;
+pub const nlink_t = u32;
+pub const time_t = isize;
+pub const mode_t = u32;
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const dev_t = u64;
+pub const blkcnt_t = i64;
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: dev_t,
+ ino: ino_t,
+ mode: mode_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ __rdev_padding: i16,
+ size: off_t,
+ blksize: blksize_t,
+ blocks: blkcnt_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ __unused: [2]u32,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: time_t,
+ tv_usec: isize,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+pub const greg_t = u32;
+pub const gregset_t = [48]greg_t;
+pub const fpregset_t = [33]f64;
+
+pub const vrregset = extern struct {
+ vrregs: [32][4]u32,
+ vrsave: u32,
+ _pad: [2]u32,
+ vscr: u32,
+};
+pub const vrregset_t = vrregset;
+
+pub const mcontext_t = extern struct {
+ gp_regs: gregset_t,
+ fp_regs: fpregset_t,
+ v_regs: vrregset_t align(16),
+};
+
+pub const ucontext_t = extern struct {
+ flags: u32,
+ link: *ucontext_t,
+ stack: stack_t,
+ pad: [7]i32,
+ regs: *mcontext_t,
+ sigmask: sigset_t,
+ pad2: [3]i32,
+ mcontext: mcontext_t,
+};
+
+pub const Elf_Symndx = u32;
+
+pub const MMAP2_UNIT = 4096;
diff --git a/lib/std/os/linux/powerpc64.zig b/lib/std/os/linux/powerpc64.zig
index 760655b5fa..2903df15ef 100644
--- a/lib/std/os/linux/powerpc64.zig
+++ b/lib/std/os/linux/powerpc64.zig
@@ -1,4 +1,16 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const linux = std.os.linux;
+const socklen_t = linux.socklen_t;
+const iovec = linux.iovec;
+const iovec_const = linux.iovec_const;
+const uid_t = linux.uid_t;
+const gid_t = linux.gid_t;
+const pid_t = linux.pid_t;
+const stack_t = linux.stack_t;
+const sigset_t = linux.sigset_t;
+const sockaddr = linux.sockaddr;
+const timespec = linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile (
@@ -125,3 +137,596 @@ pub fn restore_rt() callconv(.Naked) void {
: "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"
);
}
+
+pub const SYS = enum(usize) {
+ restart_syscall = 0,
+ exit = 1,
+ fork = 2,
+ read = 3,
+ write = 4,
+ open = 5,
+ close = 6,
+ waitpid = 7,
+ creat = 8,
+ link = 9,
+ unlink = 10,
+ execve = 11,
+ chdir = 12,
+ time = 13,
+ mknod = 14,
+ chmod = 15,
+ lchown = 16,
+ @"break" = 17,
+ oldstat = 18,
+ lseek = 19,
+ getpid = 20,
+ mount = 21,
+ umount = 22,
+ setuid = 23,
+ getuid = 24,
+ stime = 25,
+ ptrace = 26,
+ alarm = 27,
+ oldfstat = 28,
+ pause = 29,
+ utime = 30,
+ stty = 31,
+ gtty = 32,
+ access = 33,
+ nice = 34,
+ ftime = 35,
+ sync = 36,
+ kill = 37,
+ rename = 38,
+ mkdir = 39,
+ rmdir = 40,
+ dup = 41,
+ pipe = 42,
+ times = 43,
+ prof = 44,
+ brk = 45,
+ setgid = 46,
+ getgid = 47,
+ signal = 48,
+ geteuid = 49,
+ getegid = 50,
+ acct = 51,
+ umount2 = 52,
+ lock = 53,
+ ioctl = 54,
+ fcntl = 55,
+ mpx = 56,
+ setpgid = 57,
+ ulimit = 58,
+ oldolduname = 59,
+ umask = 60,
+ chroot = 61,
+ ustat = 62,
+ dup2 = 63,
+ getppid = 64,
+ getpgrp = 65,
+ setsid = 66,
+ sigaction = 67,
+ sgetmask = 68,
+ ssetmask = 69,
+ setreuid = 70,
+ setregid = 71,
+ sigsuspend = 72,
+ sigpending = 73,
+ sethostname = 74,
+ setrlimit = 75,
+ getrlimit = 76,
+ getrusage = 77,
+ gettimeofday = 78,
+ settimeofday = 79,
+ getgroups = 80,
+ setgroups = 81,
+ select = 82,
+ symlink = 83,
+ oldlstat = 84,
+ readlink = 85,
+ uselib = 86,
+ swapon = 87,
+ reboot = 88,
+ readdir = 89,
+ mmap = 90,
+ munmap = 91,
+ truncate = 92,
+ ftruncate = 93,
+ fchmod = 94,
+ fchown = 95,
+ getpriority = 96,
+ setpriority = 97,
+ profil = 98,
+ statfs = 99,
+ fstatfs = 100,
+ ioperm = 101,
+ socketcall = 102,
+ syslog = 103,
+ setitimer = 104,
+ getitimer = 105,
+ stat = 106,
+ lstat = 107,
+ fstat = 108,
+ olduname = 109,
+ iopl = 110,
+ vhangup = 111,
+ idle = 112,
+ vm86 = 113,
+ wait4 = 114,
+ swapoff = 115,
+ sysinfo = 116,
+ ipc = 117,
+ fsync = 118,
+ sigreturn = 119,
+ clone = 120,
+ setdomainname = 121,
+ uname = 122,
+ modify_ldt = 123,
+ adjtimex = 124,
+ mprotect = 125,
+ sigprocmask = 126,
+ create_module = 127,
+ init_module = 128,
+ delete_module = 129,
+ get_kernel_syms = 130,
+ quotactl = 131,
+ getpgid = 132,
+ fchdir = 133,
+ bdflush = 134,
+ sysfs = 135,
+ personality = 136,
+ afs_syscall = 137,
+ setfsuid = 138,
+ setfsgid = 139,
+ _llseek = 140,
+ getdents = 141,
+ _newselect = 142,
+ flock = 143,
+ msync = 144,
+ readv = 145,
+ writev = 146,
+ getsid = 147,
+ fdatasync = 148,
+ _sysctl = 149,
+ mlock = 150,
+ munlock = 151,
+ mlockall = 152,
+ munlockall = 153,
+ sched_setparam = 154,
+ sched_getparam = 155,
+ sched_setscheduler = 156,
+ sched_getscheduler = 157,
+ sched_yield = 158,
+ sched_get_priority_max = 159,
+ sched_get_priority_min = 160,
+ sched_rr_get_interval = 161,
+ nanosleep = 162,
+ mremap = 163,
+ setresuid = 164,
+ getresuid = 165,
+ query_module = 166,
+ poll = 167,
+ nfsservctl = 168,
+ setresgid = 169,
+ getresgid = 170,
+ prctl = 171,
+ rt_sigreturn = 172,
+ rt_sigaction = 173,
+ rt_sigprocmask = 174,
+ rt_sigpending = 175,
+ rt_sigtimedwait = 176,
+ rt_sigqueueinfo = 177,
+ rt_sigsuspend = 178,
+ pread64 = 179,
+ pwrite64 = 180,
+ chown = 181,
+ getcwd = 182,
+ capget = 183,
+ capset = 184,
+ sigaltstack = 185,
+ sendfile = 186,
+ getpmsg = 187,
+ putpmsg = 188,
+ vfork = 189,
+ ugetrlimit = 190,
+ readahead = 191,
+ pciconfig_read = 198,
+ pciconfig_write = 199,
+ pciconfig_iobase = 200,
+ multiplexer = 201,
+ getdents64 = 202,
+ pivot_root = 203,
+ madvise = 205,
+ mincore = 206,
+ gettid = 207,
+ tkill = 208,
+ setxattr = 209,
+ lsetxattr = 210,
+ fsetxattr = 211,
+ getxattr = 212,
+ lgetxattr = 213,
+ fgetxattr = 214,
+ listxattr = 215,
+ llistxattr = 216,
+ flistxattr = 217,
+ removexattr = 218,
+ lremovexattr = 219,
+ fremovexattr = 220,
+ futex = 221,
+ sched_setaffinity = 222,
+ sched_getaffinity = 223,
+ tuxcall = 225,
+ io_setup = 227,
+ io_destroy = 228,
+ io_getevents = 229,
+ io_submit = 230,
+ io_cancel = 231,
+ set_tid_address = 232,
+ fadvise64 = 233,
+ exit_group = 234,
+ lookup_dcookie = 235,
+ epoll_create = 236,
+ epoll_ctl = 237,
+ epoll_wait = 238,
+ remap_file_pages = 239,
+ timer_create = 240,
+ timer_settime = 241,
+ timer_gettime = 242,
+ timer_getoverrun = 243,
+ timer_delete = 244,
+ clock_settime = 245,
+ clock_gettime = 246,
+ clock_getres = 247,
+ clock_nanosleep = 248,
+ swapcontext = 249,
+ tgkill = 250,
+ utimes = 251,
+ statfs64 = 252,
+ fstatfs64 = 253,
+ rtas = 255,
+ sys_debug_setcontext = 256,
+ migrate_pages = 258,
+ mbind = 259,
+ get_mempolicy = 260,
+ set_mempolicy = 261,
+ mq_open = 262,
+ mq_unlink = 263,
+ mq_timedsend = 264,
+ mq_timedreceive = 265,
+ mq_notify = 266,
+ mq_getsetattr = 267,
+ kexec_load = 268,
+ add_key = 269,
+ request_key = 270,
+ keyctl = 271,
+ waitid = 272,
+ ioprio_set = 273,
+ ioprio_get = 274,
+ inotify_init = 275,
+ inotify_add_watch = 276,
+ inotify_rm_watch = 277,
+ spu_run = 278,
+ spu_create = 279,
+ pselect6 = 280,
+ ppoll = 281,
+ unshare = 282,
+ splice = 283,
+ tee = 284,
+ vmsplice = 285,
+ openat = 286,
+ mkdirat = 287,
+ mknodat = 288,
+ fchownat = 289,
+ futimesat = 290,
+ fstatat = 291,
+ unlinkat = 292,
+ renameat = 293,
+ linkat = 294,
+ symlinkat = 295,
+ readlinkat = 296,
+ fchmodat = 297,
+ faccessat = 298,
+ get_robust_list = 299,
+ set_robust_list = 300,
+ move_pages = 301,
+ getcpu = 302,
+ epoll_pwait = 303,
+ utimensat = 304,
+ signalfd = 305,
+ timerfd_create = 306,
+ eventfd = 307,
+ sync_file_range = 308,
+ fallocate = 309,
+ subpage_prot = 310,
+ timerfd_settime = 311,
+ timerfd_gettime = 312,
+ signalfd4 = 313,
+ eventfd2 = 314,
+ epoll_create1 = 315,
+ dup3 = 316,
+ pipe2 = 317,
+ inotify_init1 = 318,
+ perf_event_open = 319,
+ preadv = 320,
+ pwritev = 321,
+ rt_tgsigqueueinfo = 322,
+ fanotify_init = 323,
+ fanotify_mark = 324,
+ prlimit64 = 325,
+ socket = 326,
+ bind = 327,
+ connect = 328,
+ listen = 329,
+ accept = 330,
+ getsockname = 331,
+ getpeername = 332,
+ socketpair = 333,
+ send = 334,
+ sendto = 335,
+ recv = 336,
+ recvfrom = 337,
+ shutdown = 338,
+ setsockopt = 339,
+ getsockopt = 340,
+ sendmsg = 341,
+ recvmsg = 342,
+ recvmmsg = 343,
+ accept4 = 344,
+ name_to_handle_at = 345,
+ open_by_handle_at = 346,
+ clock_adjtime = 347,
+ syncfs = 348,
+ sendmmsg = 349,
+ setns = 350,
+ process_vm_readv = 351,
+ process_vm_writev = 352,
+ finit_module = 353,
+ kcmp = 354,
+ sched_setattr = 355,
+ sched_getattr = 356,
+ renameat2 = 357,
+ seccomp = 358,
+ getrandom = 359,
+ memfd_create = 360,
+ bpf = 361,
+ execveat = 362,
+ switch_endian = 363,
+ userfaultfd = 364,
+ membarrier = 365,
+ mlock2 = 378,
+ copy_file_range = 379,
+ preadv2 = 380,
+ pwritev2 = 381,
+ kexec_file_load = 382,
+ statx = 383,
+ pkey_alloc = 384,
+ pkey_free = 385,
+ pkey_mprotect = 386,
+ rseq = 387,
+ io_pgetevents = 388,
+ semtimedop = 392,
+ semget = 393,
+ semctl = 394,
+ shmget = 395,
+ shmctl = 396,
+ shmat = 397,
+ shmdt = 398,
+ msgget = 399,
+ msgsnd = 400,
+ msgrcv = 401,
+ msgctl = 402,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+ epoll_pwait2 = 441,
+
+ _,
+};
+
+pub const O = struct {
+ pub const CREAT = 0o100;
+ pub const EXCL = 0o200;
+ pub const NOCTTY = 0o400;
+ pub const TRUNC = 0o1000;
+ pub const APPEND = 0o2000;
+ pub const NONBLOCK = 0o4000;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0o4010000;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0o40000;
+ pub const NOFOLLOW = 0o100000;
+ pub const CLOEXEC = 0o2000000;
+
+ pub const ASYNC = 0o20000;
+ pub const DIRECT = 0o400000;
+ pub const LARGEFILE = 0o200000;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20200000;
+ pub const NDELAY = NONBLOCK;
+};
+
+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 SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const GETLK = 5;
+ pub const SETLK = 6;
+ pub const SETLKW = 7;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const MAP = struct {
+ /// stack-like segment
+ pub const GROWSDOWN = 0x0100;
+ /// ETXTBSY
+ pub const DENYWRITE = 0x0800;
+ /// mark it as an executable
+ pub const EXECUTABLE = 0x1000;
+ /// pages are locked
+ pub const LOCKED = 0x0080;
+ /// don't check for reservations
+ pub const NORESERVE = 0x0040;
+};
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__kernel_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6.15";
+};
+
+pub const Flock = extern struct {
+ l_type: i16,
+ l_whence: i16,
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ __unused: [4]u8,
+};
+
+pub const msghdr = extern struct {
+ msg_name: ?*sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec,
+ msg_iovlen: usize,
+ msg_control: ?*c_void,
+ msg_controllen: usize,
+ msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ msg_name: ?*const sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec_const,
+ msg_iovlen: usize,
+ msg_control: ?*c_void,
+ msg_controllen: usize,
+ msg_flags: i32,
+};
+
+pub const blksize_t = i64;
+pub const nlink_t = u64;
+pub const time_t = i64;
+pub const mode_t = u32;
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const dev_t = u64;
+pub const blkcnt_t = i64;
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: dev_t,
+ ino: ino_t,
+ nlink: nlink_t,
+ mode: mode_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ size: off_t,
+ blksize: blksize_t,
+ blocks: blkcnt_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ __unused: [3]u64,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: isize,
+ tv_usec: isize,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+pub const greg_t = u64;
+pub const gregset_t = [48]greg_t;
+pub const fpregset_t = [33]f64;
+
+/// The position of the vscr register depends on endianness.
+/// On C, macros are used to change vscr_word's offset to
+/// account for this. Here we'll just define vscr_word_le
+/// and vscr_word_be. Code must take care to use the correct one.
+pub const vrregset = extern struct {
+ vrregs: [32][4]u32 align(16),
+ vscr_word_le: u32,
+ _pad1: [2]u32,
+ vscr_word_be: u32,
+ vrsave: u32,
+ _pad2: [3]u32,
+};
+pub const vrregset_t = vrregset;
+
+pub const mcontext_t = extern struct {
+ __unused: [4]u64,
+ signal: i32,
+ _pad0: i32,
+ handler: u64,
+ oldmask: u64,
+ regs: ?*c_void,
+ gp_regs: gregset_t,
+ fp_regs: fpregset_t,
+ v_regs: *vrregset_t,
+ vmx_reserve: [34 + 34 + 32 + 1]i64,
+};
+
+pub const ucontext_t = extern struct {
+ flags: u32,
+ link: *ucontext_t,
+ stack: stack_t,
+ sigmask: sigset_t,
+ mcontext: mcontext_t,
+};
+
+pub const Elf_Symndx = u32;
diff --git a/lib/std/os/linux/riscv64.zig b/lib/std/os/linux/riscv64.zig
index 1448bfe3d3..be78a1bf4e 100644
--- a/lib/std/os/linux/riscv64.zig
+++ b/lib/std/os/linux/riscv64.zig
@@ -1,4 +1,8 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const uid_t = std.os.linux.uid_t;
+const gid_t = std.os.linux.gid_t;
+const pid_t = std.os.linux.pid_t;
+const timespec = std.os.linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile ("ecall"
@@ -96,3 +100,423 @@ pub fn restore_rt() callconv(.Naked) void {
: "memory"
);
}
+
+pub const SYS = enum(usize) {
+ pub const arch_specific_syscall = 244;
+
+ io_setup = 0,
+ io_destroy = 1,
+ io_submit = 2,
+ io_cancel = 3,
+ io_getevents = 4,
+ setxattr = 5,
+ lsetxattr = 6,
+ fsetxattr = 7,
+ getxattr = 8,
+ lgetxattr = 9,
+ fgetxattr = 10,
+ listxattr = 11,
+ llistxattr = 12,
+ flistxattr = 13,
+ removexattr = 14,
+ lremovexattr = 15,
+ fremovexattr = 16,
+ getcwd = 17,
+ lookup_dcookie = 18,
+ eventfd2 = 19,
+ epoll_create1 = 20,
+ epoll_ctl = 21,
+ epoll_pwait = 22,
+ dup = 23,
+ dup3 = 24,
+ fcntl = 25,
+ inotify_init1 = 26,
+ inotify_add_watch = 27,
+ inotify_rm_watch = 28,
+ ioctl = 29,
+ ioprio_set = 30,
+ ioprio_get = 31,
+ flock = 32,
+ mknodat = 33,
+ mkdirat = 34,
+ unlinkat = 35,
+ symlinkat = 36,
+ linkat = 37,
+ umount2 = 39,
+ mount = 40,
+ pivot_root = 41,
+ nfsservctl = 42,
+ statfs = 43,
+ fstatfs = 44,
+ truncate = 45,
+ ftruncate = 46,
+ fallocate = 47,
+ faccessat = 48,
+ chdir = 49,
+ fchdir = 50,
+ chroot = 51,
+ fchmod = 52,
+ fchmodat = 53,
+ fchownat = 54,
+ fchown = 55,
+ openat = 56,
+ close = 57,
+ vhangup = 58,
+ pipe2 = 59,
+ quotactl = 60,
+ getdents64 = 61,
+ lseek = 62,
+ read = 63,
+ write = 64,
+ readv = 65,
+ writev = 66,
+ pread64 = 67,
+ pwrite64 = 68,
+ preadv = 69,
+ pwritev = 70,
+ sendfile = 71,
+ pselect6 = 72,
+ ppoll = 73,
+ signalfd4 = 74,
+ vmsplice = 75,
+ splice = 76,
+ tee = 77,
+ readlinkat = 78,
+ fstatat = 79,
+ fstat = 80,
+ sync = 81,
+ fsync = 82,
+ fdatasync = 83,
+ sync_file_range = 84,
+ timerfd_create = 85,
+ timerfd_settime = 86,
+ timerfd_gettime = 87,
+ utimensat = 88,
+ acct = 89,
+ capget = 90,
+ capset = 91,
+ personality = 92,
+ exit = 93,
+ exit_group = 94,
+ waitid = 95,
+ set_tid_address = 96,
+ unshare = 97,
+ futex = 98,
+ set_robust_list = 99,
+ get_robust_list = 100,
+ nanosleep = 101,
+ getitimer = 102,
+ setitimer = 103,
+ kexec_load = 104,
+ init_module = 105,
+ delete_module = 106,
+ timer_create = 107,
+ timer_gettime = 108,
+ timer_getoverrun = 109,
+ timer_settime = 110,
+ timer_delete = 111,
+ clock_settime = 112,
+ clock_gettime = 113,
+ clock_getres = 114,
+ clock_nanosleep = 115,
+ syslog = 116,
+ ptrace = 117,
+ sched_setparam = 118,
+ sched_setscheduler = 119,
+ sched_getscheduler = 120,
+ sched_getparam = 121,
+ sched_setaffinity = 122,
+ sched_getaffinity = 123,
+ sched_yield = 124,
+ sched_get_priority_max = 125,
+ sched_get_priority_min = 126,
+ sched_rr_get_interval = 127,
+ restart_syscall = 128,
+ kill = 129,
+ tkill = 130,
+ tgkill = 131,
+ sigaltstack = 132,
+ rt_sigsuspend = 133,
+ rt_sigaction = 134,
+ rt_sigprocmask = 135,
+ rt_sigpending = 136,
+ rt_sigtimedwait = 137,
+ rt_sigqueueinfo = 138,
+ rt_sigreturn = 139,
+ setpriority = 140,
+ getpriority = 141,
+ reboot = 142,
+ setregid = 143,
+ setgid = 144,
+ setreuid = 145,
+ setuid = 146,
+ setresuid = 147,
+ getresuid = 148,
+ setresgid = 149,
+ getresgid = 150,
+ setfsuid = 151,
+ setfsgid = 152,
+ times = 153,
+ setpgid = 154,
+ getpgid = 155,
+ getsid = 156,
+ setsid = 157,
+ getgroups = 158,
+ setgroups = 159,
+ uname = 160,
+ sethostname = 161,
+ setdomainname = 162,
+ getrlimit = 163,
+ setrlimit = 164,
+ getrusage = 165,
+ umask = 166,
+ prctl = 167,
+ getcpu = 168,
+ gettimeofday = 169,
+ settimeofday = 170,
+ adjtimex = 171,
+ getpid = 172,
+ getppid = 173,
+ getuid = 174,
+ geteuid = 175,
+ getgid = 176,
+ getegid = 177,
+ gettid = 178,
+ sysinfo = 179,
+ mq_open = 180,
+ mq_unlink = 181,
+ mq_timedsend = 182,
+ mq_timedreceive = 183,
+ mq_notify = 184,
+ mq_getsetattr = 185,
+ msgget = 186,
+ msgctl = 187,
+ msgrcv = 188,
+ msgsnd = 189,
+ semget = 190,
+ semctl = 191,
+ semtimedop = 192,
+ semop = 193,
+ shmget = 194,
+ shmctl = 195,
+ shmat = 196,
+ shmdt = 197,
+ socket = 198,
+ socketpair = 199,
+ bind = 200,
+ listen = 201,
+ accept = 202,
+ connect = 203,
+ getsockname = 204,
+ getpeername = 205,
+ sendto = 206,
+ recvfrom = 207,
+ setsockopt = 208,
+ getsockopt = 209,
+ shutdown = 210,
+ sendmsg = 211,
+ recvmsg = 212,
+ readahead = 213,
+ brk = 214,
+ munmap = 215,
+ mremap = 216,
+ add_key = 217,
+ request_key = 218,
+ keyctl = 219,
+ clone = 220,
+ execve = 221,
+ mmap = 222,
+ fadvise64 = 223,
+ swapon = 224,
+ swapoff = 225,
+ mprotect = 226,
+ msync = 227,
+ mlock = 228,
+ munlock = 229,
+ mlockall = 230,
+ munlockall = 231,
+ mincore = 232,
+ madvise = 233,
+ remap_file_pages = 234,
+ mbind = 235,
+ get_mempolicy = 236,
+ set_mempolicy = 237,
+ migrate_pages = 238,
+ move_pages = 239,
+ rt_tgsigqueueinfo = 240,
+ perf_event_open = 241,
+ accept4 = 242,
+ recvmmsg = 243,
+
+ riscv_flush_icache = arch_specific_syscall + 15,
+
+ wait4 = 260,
+ prlimit64 = 261,
+ fanotify_init = 262,
+ fanotify_mark = 263,
+ name_to_handle_at = 264,
+ open_by_handle_at = 265,
+ clock_adjtime = 266,
+ syncfs = 267,
+ setns = 268,
+ sendmmsg = 269,
+ process_vm_readv = 270,
+ process_vm_writev = 271,
+ kcmp = 272,
+ finit_module = 273,
+ sched_setattr = 274,
+ sched_getattr = 275,
+ renameat2 = 276,
+ seccomp = 277,
+ getrandom = 278,
+ memfd_create = 279,
+ bpf = 280,
+ execveat = 281,
+ userfaultfd = 282,
+ membarrier = 283,
+ mlock2 = 284,
+ copy_file_range = 285,
+ preadv2 = 286,
+ pwritev2 = 287,
+ pkey_mprotect = 288,
+ pkey_alloc = 289,
+ pkey_free = 290,
+ statx = 291,
+ io_pgetevents = 292,
+ rseq = 293,
+ kexec_file_load = 294,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+ epoll_pwait2 = 441,
+
+ _,
+};
+
+pub const O = struct {
+ pub const CREAT = 0o100;
+ pub const EXCL = 0o200;
+ pub const NOCTTY = 0o400;
+ pub const TRUNC = 0o1000;
+ pub const APPEND = 0o2000;
+ pub const NONBLOCK = 0o4000;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0o4010000;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0o200000;
+ pub const NOFOLLOW = 0o400000;
+ pub const CLOEXEC = 0o2000000;
+
+ pub const ASYNC = 0o20000;
+ pub const DIRECT = 0o40000;
+ pub const LARGEFILE = 0o100000;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20200000;
+ pub const NDELAY = NONBLOCK;
+};
+
+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 = 5;
+ pub const SETLK = 6;
+ pub const SETLKW = 7;
+ pub const SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const UN = 8;
+ pub const NB = 4;
+};
+
+pub const blksize_t = i32;
+pub const nlink_t = u32;
+pub const time_t = isize;
+pub const mode_t = u32;
+pub const off_t = isize;
+pub const ino_t = usize;
+pub const dev_t = usize;
+pub const blkcnt_t = isize;
+
+pub const timeval = extern struct {
+ tv_sec: time_t,
+ tv_usec: i64,
+};
+
+pub const Flock = extern struct {
+ l_type: i16,
+ l_whence: i16,
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+ __unused: [4]u8,
+};
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: dev_t,
+ ino: ino_t,
+ mode: mode_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ __pad: usize,
+ size: off_t,
+ blksize: blksize_t,
+ __pad2: i32,
+ blocks: blkcnt_t,
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ __unused: [2]u32,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const Elf_Symndx = u32;
+
+pub const VDSO = struct {};
+pub const MAP = struct {};
diff --git a/lib/std/os/linux/sparc64.zig b/lib/std/os/linux/sparc64.zig
index ce41af40d6..3ae490f5e9 100644
--- a/lib/std/os/linux/sparc64.zig
+++ b/lib/std/os/linux/sparc64.zig
@@ -1,4 +1,17 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const pid_t = linux.pid_t;
+const uid_t = linux.uid_t;
+const clock_t = linux.clock_t;
+const stack_t = linux.stack_t;
+const sigset_t = linux.sigset_t;
+
+const linux = std.os.linux;
+const sockaddr = linux.sockaddr;
+const socklen_t = linux.socklen_t;
+const iovec = linux.iovec;
+const iovec_const = linux.iovec_const;
+const timespec = linux.timespec;
pub fn syscall_pipe(fd: *[2]i32) usize {
return asm volatile (
@@ -178,3 +191,632 @@ pub fn restore_rt() callconv(.C) void {
: "memory", "xcc", "o0", "o1", "o2", "o3", "o4", "o5", "o7"
);
}
+
+pub const SYS = enum(usize) {
+ restart_syscall = 0,
+ exit = 1,
+ fork = 2,
+ read = 3,
+ write = 4,
+ open = 5,
+ close = 6,
+ wait4 = 7,
+ creat = 8,
+ link = 9,
+ unlink = 10,
+ execv = 11,
+ chdir = 12,
+ chown = 13,
+ mknod = 14,
+ chmod = 15,
+ lchown = 16,
+ brk = 17,
+ perfctr = 18,
+ lseek = 19,
+ getpid = 20,
+ capget = 21,
+ capset = 22,
+ setuid = 23,
+ getuid = 24,
+ vmsplice = 25,
+ ptrace = 26,
+ alarm = 27,
+ sigaltstack = 28,
+ pause = 29,
+ utime = 30,
+ access = 33,
+ nice = 34,
+ sync = 36,
+ kill = 37,
+ stat = 38,
+ sendfile = 39,
+ lstat = 40,
+ dup = 41,
+ pipe = 42,
+ times = 43,
+ umount2 = 45,
+ setgid = 46,
+ getgid = 47,
+ signal = 48,
+ geteuid = 49,
+ getegid = 50,
+ acct = 51,
+ memory_ordering = 52,
+ ioctl = 54,
+ reboot = 55,
+ symlink = 57,
+ readlink = 58,
+ execve = 59,
+ umask = 60,
+ chroot = 61,
+ fstat = 62,
+ fstat64 = 63,
+ getpagesize = 64,
+ msync = 65,
+ vfork = 66,
+ pread64 = 67,
+ pwrite64 = 68,
+ mmap = 71,
+ munmap = 73,
+ mprotect = 74,
+ madvise = 75,
+ vhangup = 76,
+ mincore = 78,
+ getgroups = 79,
+ setgroups = 80,
+ getpgrp = 81,
+ setitimer = 83,
+ swapon = 85,
+ getitimer = 86,
+ sethostname = 88,
+ dup2 = 90,
+ fcntl = 92,
+ select = 93,
+ fsync = 95,
+ setpriority = 96,
+ socket = 97,
+ connect = 98,
+ accept = 99,
+ getpriority = 100,
+ rt_sigreturn = 101,
+ rt_sigaction = 102,
+ rt_sigprocmask = 103,
+ rt_sigpending = 104,
+ rt_sigtimedwait = 105,
+ rt_sigqueueinfo = 106,
+ rt_sigsuspend = 107,
+ setresuid = 108,
+ getresuid = 109,
+ setresgid = 110,
+ getresgid = 111,
+ recvmsg = 113,
+ sendmsg = 114,
+ gettimeofday = 116,
+ getrusage = 117,
+ getsockopt = 118,
+ getcwd = 119,
+ readv = 120,
+ writev = 121,
+ settimeofday = 122,
+ fchown = 123,
+ fchmod = 124,
+ recvfrom = 125,
+ setreuid = 126,
+ setregid = 127,
+ rename = 128,
+ truncate = 129,
+ ftruncate = 130,
+ flock = 131,
+ lstat64 = 132,
+ sendto = 133,
+ shutdown = 134,
+ socketpair = 135,
+ mkdir = 136,
+ rmdir = 137,
+ utimes = 138,
+ stat64 = 139,
+ sendfile64 = 140,
+ getpeername = 141,
+ futex = 142,
+ gettid = 143,
+ getrlimit = 144,
+ setrlimit = 145,
+ pivot_root = 146,
+ prctl = 147,
+ pciconfig_read = 148,
+ pciconfig_write = 149,
+ getsockname = 150,
+ inotify_init = 151,
+ inotify_add_watch = 152,
+ poll = 153,
+ getdents64 = 154,
+ inotify_rm_watch = 156,
+ statfs = 157,
+ fstatfs = 158,
+ umount = 159,
+ sched_set_affinity = 160,
+ sched_get_affinity = 161,
+ getdomainname = 162,
+ setdomainname = 163,
+ utrap_install = 164,
+ quotactl = 165,
+ set_tid_address = 166,
+ mount = 167,
+ ustat = 168,
+ setxattr = 169,
+ lsetxattr = 170,
+ fsetxattr = 171,
+ getxattr = 172,
+ lgetxattr = 173,
+ getdents = 174,
+ setsid = 175,
+ fchdir = 176,
+ fgetxattr = 177,
+ listxattr = 178,
+ llistxattr = 179,
+ flistxattr = 180,
+ removexattr = 181,
+ lremovexattr = 182,
+ sigpending = 183,
+ query_module = 184,
+ setpgid = 185,
+ fremovexattr = 186,
+ tkill = 187,
+ exit_group = 188,
+ uname = 189,
+ init_module = 190,
+ personality = 191,
+ remap_file_pages = 192,
+ epoll_create = 193,
+ epoll_ctl = 194,
+ epoll_wait = 195,
+ ioprio_set = 196,
+ getppid = 197,
+ sigaction = 198,
+ sgetmask = 199,
+ ssetmask = 200,
+ sigsuspend = 201,
+ oldlstat = 202,
+ uselib = 203,
+ readdir = 204,
+ readahead = 205,
+ socketcall = 206,
+ syslog = 207,
+ lookup_dcookie = 208,
+ fadvise64 = 209,
+ fadvise64_64 = 210,
+ tgkill = 211,
+ waitpid = 212,
+ swapoff = 213,
+ sysinfo = 214,
+ ipc = 215,
+ sigreturn = 216,
+ clone = 217,
+ ioprio_get = 218,
+ adjtimex = 219,
+ sigprocmask = 220,
+ create_module = 221,
+ delete_module = 222,
+ get_kernel_syms = 223,
+ getpgid = 224,
+ bdflush = 225,
+ sysfs = 226,
+ afs_syscall = 227,
+ setfsuid = 228,
+ setfsgid = 229,
+ _newselect = 230,
+ splice = 232,
+ stime = 233,
+ statfs64 = 234,
+ fstatfs64 = 235,
+ _llseek = 236,
+ mlock = 237,
+ munlock = 238,
+ mlockall = 239,
+ munlockall = 240,
+ sched_setparam = 241,
+ sched_getparam = 242,
+ sched_setscheduler = 243,
+ sched_getscheduler = 244,
+ sched_yield = 245,
+ sched_get_priority_max = 246,
+ sched_get_priority_min = 247,
+ sched_rr_get_interval = 248,
+ nanosleep = 249,
+ mremap = 250,
+ _sysctl = 251,
+ getsid = 252,
+ fdatasync = 253,
+ nfsservctl = 254,
+ sync_file_range = 255,
+ clock_settime = 256,
+ clock_gettime = 257,
+ clock_getres = 258,
+ clock_nanosleep = 259,
+ sched_getaffinity = 260,
+ sched_setaffinity = 261,
+ timer_settime = 262,
+ timer_gettime = 263,
+ timer_getoverrun = 264,
+ timer_delete = 265,
+ timer_create = 266,
+ vserver = 267,
+ io_setup = 268,
+ io_destroy = 269,
+ io_submit = 270,
+ io_cancel = 271,
+ io_getevents = 272,
+ mq_open = 273,
+ mq_unlink = 274,
+ mq_timedsend = 275,
+ mq_timedreceive = 276,
+ mq_notify = 277,
+ mq_getsetattr = 278,
+ waitid = 279,
+ tee = 280,
+ add_key = 281,
+ request_key = 282,
+ keyctl = 283,
+ openat = 284,
+ mkdirat = 285,
+ mknodat = 286,
+ fchownat = 287,
+ futimesat = 288,
+ fstatat64 = 289,
+ unlinkat = 290,
+ renameat = 291,
+ linkat = 292,
+ symlinkat = 293,
+ readlinkat = 294,
+ fchmodat = 295,
+ faccessat = 296,
+ pselect6 = 297,
+ ppoll = 298,
+ unshare = 299,
+ set_robust_list = 300,
+ get_robust_list = 301,
+ migrate_pages = 302,
+ mbind = 303,
+ get_mempolicy = 304,
+ set_mempolicy = 305,
+ kexec_load = 306,
+ move_pages = 307,
+ getcpu = 308,
+ epoll_pwait = 309,
+ utimensat = 310,
+ signalfd = 311,
+ timerfd_create = 312,
+ eventfd = 313,
+ fallocate = 314,
+ timerfd_settime = 315,
+ timerfd_gettime = 316,
+ signalfd4 = 317,
+ eventfd2 = 318,
+ epoll_create1 = 319,
+ dup3 = 320,
+ pipe2 = 321,
+ inotify_init1 = 322,
+ accept4 = 323,
+ preadv = 324,
+ pwritev = 325,
+ rt_tgsigqueueinfo = 326,
+ perf_event_open = 327,
+ recvmmsg = 328,
+ fanotify_init = 329,
+ fanotify_mark = 330,
+ prlimit64 = 331,
+ name_to_handle_at = 332,
+ open_by_handle_at = 333,
+ clock_adjtime = 334,
+ syncfs = 335,
+ sendmmsg = 336,
+ setns = 337,
+ process_vm_readv = 338,
+ process_vm_writev = 339,
+ kern_features = 340,
+ kcmp = 341,
+ finit_module = 342,
+ sched_setattr = 343,
+ sched_getattr = 344,
+ renameat2 = 345,
+ seccomp = 346,
+ getrandom = 347,
+ memfd_create = 348,
+ bpf = 349,
+ execveat = 350,
+ membarrier = 351,
+ userfaultfd = 352,
+ bind = 353,
+ listen = 354,
+ setsockopt = 355,
+ mlock2 = 356,
+ copy_file_range = 357,
+ preadv2 = 358,
+ pwritev2 = 359,
+ statx = 360,
+ io_pgetevents = 361,
+ pkey_mprotect = 362,
+ pkey_alloc = 363,
+ pkey_free = 364,
+ rseq = 365,
+ semtimedop = 392,
+ semget = 393,
+ semctl = 394,
+ shmget = 395,
+ shmctl = 396,
+ shmat = 397,
+ shmdt = 398,
+ msgget = 399,
+ msgsnd = 400,
+ msgrcv = 401,
+ msgctl = 402,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+ epoll_pwait2 = 441,
+
+ _,
+};
+
+pub const O = struct {
+ pub const CREAT = 0x200;
+ pub const EXCL = 0x800;
+ pub const NOCTTY = 0x8000;
+ pub const TRUNC = 0x400;
+ pub const APPEND = 0x8;
+ pub const NONBLOCK = 0x4000;
+ pub const SYNC = 0x802000;
+ pub const DSYNC = 0x2000;
+ pub const RSYNC = SYNC;
+ pub const DIRECTORY = 0x10000;
+ pub const NOFOLLOW = 0x20000;
+ pub const CLOEXEC = 0x400000;
+
+ pub const ASYNC = 0x40;
+ pub const DIRECT = 0x100000;
+ pub const LARGEFILE = 0;
+ pub const NOATIME = 0x200000;
+ pub const PATH = 0x1000000;
+ pub const TMPFILE = 0x2010000;
+ pub const NDELAY = NONBLOCK | 0x4;
+};
+
+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 SETOWN = 5;
+ pub const GETOWN = 6;
+ pub const GETLK = 7;
+ pub const SETLK = 8;
+ pub const SETLKW = 9;
+
+ pub const RDLCK = 1;
+ pub const WRLCK = 2;
+ pub const UNLCK = 3;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const NB = 4;
+ pub const UN = 8;
+};
+
+pub const MAP = struct {
+ /// stack-like segment
+ pub const GROWSDOWN = 0x0200;
+ /// ETXTBSY
+ pub const DENYWRITE = 0x0800;
+ /// mark it as an executable
+ pub const EXECUTABLE = 0x1000;
+ /// pages are locked
+ pub const LOCKED = 0x0100;
+ /// don't check for reservations
+ pub const NORESERVE = 0x0040;
+};
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__vdso_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6";
+};
+
+pub const Flock = extern struct {
+ l_type: i16,
+ l_whence: i16,
+ l_start: off_t,
+ l_len: off_t,
+ l_pid: pid_t,
+};
+
+pub const msghdr = extern struct {
+ msg_name: ?*sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec,
+ msg_iovlen: u64,
+ msg_control: ?*c_void,
+ msg_controllen: u64,
+ msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ msg_name: ?*const sockaddr,
+ msg_namelen: socklen_t,
+ msg_iov: [*]iovec_const,
+ msg_iovlen: u64,
+ msg_control: ?*c_void,
+ msg_controllen: u64,
+ msg_flags: i32,
+};
+
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const mode_t = u32;
+
+// The `stat64` definition used by the kernel.
+pub const Stat = extern struct {
+ dev: u64,
+ ino: u64,
+ nlink: u64,
+
+ mode: u32,
+ uid: u32,
+ gid: u32,
+ __pad0: u32,
+
+ rdev: u64,
+ size: i64,
+ blksize: i64,
+ blocks: i64,
+
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ __unused: [3]u64,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: isize,
+ tv_usec: isize,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+// TODO I'm not sure if the code below is correct, need someone with more
+// knowledge about sparc64 linux internals to look into.
+
+pub const Elf_Symndx = u32;
+
+pub const fpstate = extern struct {
+ regs: [32]u64,
+ fsr: u64,
+ gsr: u64,
+ fprs: u64,
+};
+
+pub const __fpq = extern struct {
+ fpq_addr: *u32,
+ fpq_instr: u32,
+};
+
+pub const __fq = extern struct {
+ FQu: extern union {
+ whole: f64,
+ fpq: __fpq,
+ },
+};
+
+pub const fpregset_t = extern struct {
+ fpu_fr: extern union {
+ fpu_regs: [32]u32,
+ fpu_dregs: [32]f64,
+ fpu_qregs: [16]c_longdouble,
+ },
+ fpu_q: *__fq,
+ fpu_fsr: u64,
+ fpu_qcnt: u8,
+ fpu_q_entrysize: u8,
+ fpu_en: u8,
+};
+
+pub const siginfo_fpu_t = extern struct {
+ float_regs: [64]u32,
+ fsr: u64,
+ gsr: u64,
+ fprs: u64,
+};
+
+pub const sigcontext = extern struct {
+ info: [128]i8,
+ regs: extern struct {
+ u_regs: [16]u64,
+ tstate: u64,
+ tpc: u64,
+ tnpc: u64,
+ y: u64,
+ fprs: u64,
+ },
+ fpu_save: *siginfo_fpu_t,
+ stack: extern struct {
+ sp: usize,
+ flags: i32,
+ size: u64,
+ },
+ mask: u64,
+};
+
+pub const greg_t = u64;
+pub const gregset_t = [19]greg_t;
+
+pub const fq = extern struct {
+ addr: *u64,
+ insn: u32,
+};
+
+pub const fpu_t = extern struct {
+ fregs: extern union {
+ sregs: [32]u32,
+ dregs: [32]u64,
+ qregs: [16]c_longdouble,
+ },
+ fsr: u64,
+ fprs: u64,
+ gsr: u64,
+ fq: *fq,
+ qcnt: u8,
+ qentsz: u8,
+ enab: u8,
+};
+
+pub const mcontext_t = extern struct {
+ gregs: gregset_t,
+ fp: greg_t,
+ @"i7": greg_t,
+ fpregs: fpu_t,
+};
+
+pub const ucontext_t = extern struct {
+ link: *ucontext_t,
+ flags: u64,
+ sigmask: u64,
+ mcontext: mcontext_t,
+ stack: stack_t,
+ sigmask: sigset_t,
+};
diff --git a/lib/std/os/linux/test.zig b/lib/std/os/linux/test.zig
index e45c9dbb99..14ff8ea38d 100644
--- a/lib/std/os/linux/test.zig
+++ b/lib/std/os/linux/test.zig
@@ -35,7 +35,7 @@ test "timer" {
var err: linux.E = linux.getErrno(epoll_fd);
try expect(err == .SUCCESS);
- const timer_fd = linux.timerfd_create(linux.CLOCK_MONOTONIC, 0);
+ const timer_fd = linux.timerfd_create(linux.CLOCK.MONOTONIC, 0);
try expect(linux.getErrno(timer_fd) == .SUCCESS);
const time_interval = linux.timespec{
@@ -52,11 +52,11 @@ test "timer" {
try expect(err == .SUCCESS);
var event = linux.epoll_event{
- .events = linux.EPOLLIN | linux.EPOLLOUT | linux.EPOLLET,
+ .events = linux.EPOLL.IN | linux.EPOLL.OUT | linux.EPOLL.ET,
.data = linux.epoll_data{ .ptr = 0 },
};
- err = linux.getErrno(linux.epoll_ctl(@intCast(i32, epoll_fd), linux.EPOLL_CTL_ADD, @intCast(i32, timer_fd), &event));
+ err = linux.getErrno(linux.epoll_ctl(@intCast(i32, epoll_fd), linux.EPOLL.CTL_ADD, @intCast(i32, timer_fd), &event));
try expect(err == .SUCCESS);
const events_one: linux.epoll_event = undefined;
@@ -75,15 +75,15 @@ test "statx" {
}
var statx_buf: linux.Statx = undefined;
- switch (linux.getErrno(linux.statx(file.handle, "", linux.AT_EMPTY_PATH, linux.STATX_BASIC_STATS, &statx_buf))) {
+ switch (linux.getErrno(linux.statx(file.handle, "", linux.AT.EMPTY_PATH, linux.STATX_BASIC_STATS, &statx_buf))) {
.SUCCESS => {},
// The statx syscall was only introduced in linux 4.11
.NOSYS => return error.SkipZigTest,
else => unreachable,
}
- var stat_buf: linux.kernel_stat = undefined;
- switch (linux.getErrno(linux.fstatat(file.handle, "", &stat_buf, linux.AT_EMPTY_PATH))) {
+ var stat_buf: linux.Stat = undefined;
+ switch (linux.getErrno(linux.fstatat(file.handle, "", &stat_buf, linux.AT.EMPTY_PATH))) {
.SUCCESS => {},
else => unreachable,
}
@@ -119,7 +119,7 @@ test "fadvise" {
file.handle,
0,
0,
- linux.POSIX_FADV_SEQUENTIAL,
+ linux.POSIX_FADV.SEQUENTIAL,
);
try expectEqual(@as(usize, 0), ret);
}
diff --git a/lib/std/os/linux/thumb.zig b/lib/std/os/linux/thumb.zig
index e5d185b8c1..6ac51afb78 100644
--- a/lib/std/os/linux/thumb.zig
+++ b/lib/std/os/linux/thumb.zig
@@ -1,10 +1,11 @@
-usingnamespace @import("../bits/linux.zig");
-
-// The syscall interface is identical to the ARM one but we're facing an extra
-// challenge: r7, the register where the syscall number is stored, may be
-// reserved for the frame pointer.
-// Save and restore r7 around the syscall without touching the stack pointer not
-// to break the frame chain.
+//! The syscall interface is identical to the ARM one but we're facing an extra
+//! challenge: r7, the register where the syscall number is stored, may be
+//! reserved for the frame pointer.
+//! Save and restore r7 around the syscall without touching the stack pointer not
+//! to break the frame chain.
+const std = @import("../../std.zig");
+const linux = std.os.linux;
+const SYS = linux.SYS;
pub fn syscall0(number: SYS) usize {
@setRuntimeSafety(false);
@@ -140,9 +141,6 @@ pub fn syscall6(
);
}
-/// This matches the libc clone function.
-pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
-
pub fn restore() callconv(.Naked) void {
return asm volatile (
\\ mov r7, %[number]
diff --git a/lib/std/os/linux/tls.zig b/lib/std/os/linux/tls.zig
index d04bf24b5f..de9c475083 100644
--- a/lib/std/os/linux/tls.zig
+++ b/lib/std/os/linux/tls.zig
@@ -135,7 +135,7 @@ pub fn setThreadPointer(addr: usize) void {
);
},
.x86_64 => {
- const rc = std.os.linux.syscall2(.arch_prctl, std.os.linux.ARCH_SET_FS, addr);
+ const rc = std.os.linux.syscall2(.arch_prctl, std.os.linux.ARCH.SET_FS, addr);
assert(rc == 0);
},
.aarch64 => {
@@ -319,8 +319,8 @@ pub fn initStaticTLS(phdrs: []elf.Phdr) void {
const alloc_tls_area = os.mmap(
null,
tls_image.alloc_size + tls_image.alloc_align - 1,
- os.PROT_READ | os.PROT_WRITE,
- os.MAP_PRIVATE | os.MAP_ANONYMOUS,
+ os.PROT.READ | os.PROT.WRITE,
+ os.MAP.PRIVATE | os.MAP.ANONYMOUS,
-1,
0,
) catch os.abort();
diff --git a/lib/std/os/linux/x86_64.zig b/lib/std/os/linux/x86_64.zig
index 7398c3afb6..b6a2d2763f 100644
--- a/lib/std/os/linux/x86_64.zig
+++ b/lib/std/os/linux/x86_64.zig
@@ -1,4 +1,18 @@
-usingnamespace @import("../bits/linux.zig");
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+const linux = std.os.linux;
+const iovec = std.os.iovec;
+const iovec_const = std.os.iovec_const;
+
+const pid_t = linux.pid_t;
+const uid_t = linux.uid_t;
+const gid_t = linux.gid_t;
+const clock_t = linux.clock_t;
+const stack_t = linux.stack_t;
+const sigset_t = linux.sigset_t;
+const sockaddr = linux.sockaddr;
+const socklen_t = linux.socklen_t;
+const timespec = linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile ("syscall"
@@ -97,3 +111,629 @@ pub fn restore_rt() callconv(.Naked) void {
: "rcx", "r11", "memory"
);
}
+
+pub const mode_t = usize;
+pub const time_t = isize;
+pub const nlink_t = usize;
+pub const blksize_t = isize;
+pub const blkcnt_t = isize;
+
+pub const SYS = enum(usize) {
+ read = 0,
+ write = 1,
+ open = 2,
+ close = 3,
+ stat = 4,
+ fstat = 5,
+ lstat = 6,
+ poll = 7,
+ lseek = 8,
+ mmap = 9,
+ mprotect = 10,
+ munmap = 11,
+ brk = 12,
+ rt_sigaction = 13,
+ rt_sigprocmask = 14,
+ rt_sigreturn = 15,
+ ioctl = 16,
+ pread = 17,
+ pwrite = 18,
+ readv = 19,
+ writev = 20,
+ access = 21,
+ pipe = 22,
+ select = 23,
+ sched_yield = 24,
+ mremap = 25,
+ msync = 26,
+ mincore = 27,
+ madvise = 28,
+ shmget = 29,
+ shmat = 30,
+ shmctl = 31,
+ dup = 32,
+ dup2 = 33,
+ pause = 34,
+ nanosleep = 35,
+ getitimer = 36,
+ alarm = 37,
+ setitimer = 38,
+ getpid = 39,
+ sendfile = 40,
+ socket = 41,
+ connect = 42,
+ accept = 43,
+ sendto = 44,
+ recvfrom = 45,
+ sendmsg = 46,
+ recvmsg = 47,
+ shutdown = 48,
+ bind = 49,
+ listen = 50,
+ getsockname = 51,
+ getpeername = 52,
+ socketpair = 53,
+ setsockopt = 54,
+ getsockopt = 55,
+ clone = 56,
+ fork = 57,
+ vfork = 58,
+ execve = 59,
+ exit = 60,
+ wait4 = 61,
+ kill = 62,
+ uname = 63,
+ semget = 64,
+ semop = 65,
+ semctl = 66,
+ shmdt = 67,
+ msgget = 68,
+ msgsnd = 69,
+ msgrcv = 70,
+ msgctl = 71,
+ fcntl = 72,
+ flock = 73,
+ fsync = 74,
+ fdatasync = 75,
+ truncate = 76,
+ ftruncate = 77,
+ getdents = 78,
+ getcwd = 79,
+ chdir = 80,
+ fchdir = 81,
+ rename = 82,
+ mkdir = 83,
+ rmdir = 84,
+ creat = 85,
+ link = 86,
+ unlink = 87,
+ symlink = 88,
+ readlink = 89,
+ chmod = 90,
+ fchmod = 91,
+ chown = 92,
+ fchown = 93,
+ lchown = 94,
+ umask = 95,
+ gettimeofday = 96,
+ getrlimit = 97,
+ getrusage = 98,
+ sysinfo = 99,
+ times = 100,
+ ptrace = 101,
+ getuid = 102,
+ syslog = 103,
+ getgid = 104,
+ setuid = 105,
+ setgid = 106,
+ geteuid = 107,
+ getegid = 108,
+ setpgid = 109,
+ getppid = 110,
+ getpgrp = 111,
+ setsid = 112,
+ setreuid = 113,
+ setregid = 114,
+ getgroups = 115,
+ setgroups = 116,
+ setresuid = 117,
+ getresuid = 118,
+ setresgid = 119,
+ getresgid = 120,
+ getpgid = 121,
+ setfsuid = 122,
+ setfsgid = 123,
+ getsid = 124,
+ capget = 125,
+ capset = 126,
+ rt_sigpending = 127,
+ rt_sigtimedwait = 128,
+ rt_sigqueueinfo = 129,
+ rt_sigsuspend = 130,
+ sigaltstack = 131,
+ utime = 132,
+ mknod = 133,
+ uselib = 134,
+ personality = 135,
+ ustat = 136,
+ statfs = 137,
+ fstatfs = 138,
+ sysfs = 139,
+ getpriority = 140,
+ setpriority = 141,
+ sched_setparam = 142,
+ sched_getparam = 143,
+ sched_setscheduler = 144,
+ sched_getscheduler = 145,
+ sched_get_priority_max = 146,
+ sched_get_priority_min = 147,
+ sched_rr_get_interval = 148,
+ mlock = 149,
+ munlock = 150,
+ mlockall = 151,
+ munlockall = 152,
+ vhangup = 153,
+ modify_ldt = 154,
+ pivot_root = 155,
+ _sysctl = 156,
+ prctl = 157,
+ arch_prctl = 158,
+ adjtimex = 159,
+ setrlimit = 160,
+ chroot = 161,
+ sync = 162,
+ acct = 163,
+ settimeofday = 164,
+ mount = 165,
+ umount2 = 166,
+ swapon = 167,
+ swapoff = 168,
+ reboot = 169,
+ sethostname = 170,
+ setdomainname = 171,
+ iopl = 172,
+ ioperm = 173,
+ create_module = 174,
+ init_module = 175,
+ delete_module = 176,
+ get_kernel_syms = 177,
+ query_module = 178,
+ quotactl = 179,
+ nfsservctl = 180,
+ getpmsg = 181,
+ putpmsg = 182,
+ afs_syscall = 183,
+ tuxcall = 184,
+ security = 185,
+ gettid = 186,
+ readahead = 187,
+ setxattr = 188,
+ lsetxattr = 189,
+ fsetxattr = 190,
+ getxattr = 191,
+ lgetxattr = 192,
+ fgetxattr = 193,
+ listxattr = 194,
+ llistxattr = 195,
+ flistxattr = 196,
+ removexattr = 197,
+ lremovexattr = 198,
+ fremovexattr = 199,
+ tkill = 200,
+ time = 201,
+ futex = 202,
+ sched_setaffinity = 203,
+ sched_getaffinity = 204,
+ set_thread_area = 205,
+ io_setup = 206,
+ io_destroy = 207,
+ io_getevents = 208,
+ io_submit = 209,
+ io_cancel = 210,
+ get_thread_area = 211,
+ lookup_dcookie = 212,
+ epoll_create = 213,
+ epoll_ctl_old = 214,
+ epoll_wait_old = 215,
+ remap_file_pages = 216,
+ getdents64 = 217,
+ set_tid_address = 218,
+ restart_syscall = 219,
+ semtimedop = 220,
+ fadvise64 = 221,
+ timer_create = 222,
+ timer_settime = 223,
+ timer_gettime = 224,
+ timer_getoverrun = 225,
+ timer_delete = 226,
+ clock_settime = 227,
+ clock_gettime = 228,
+ clock_getres = 229,
+ clock_nanosleep = 230,
+ exit_group = 231,
+ epoll_wait = 232,
+ epoll_ctl = 233,
+ tgkill = 234,
+ utimes = 235,
+ vserver = 236,
+ mbind = 237,
+ set_mempolicy = 238,
+ get_mempolicy = 239,
+ mq_open = 240,
+ mq_unlink = 241,
+ mq_timedsend = 242,
+ mq_timedreceive = 243,
+ mq_notify = 244,
+ mq_getsetattr = 245,
+ kexec_load = 246,
+ waitid = 247,
+ add_key = 248,
+ request_key = 249,
+ keyctl = 250,
+ ioprio_set = 251,
+ ioprio_get = 252,
+ inotify_init = 253,
+ inotify_add_watch = 254,
+ inotify_rm_watch = 255,
+ migrate_pages = 256,
+ openat = 257,
+ mkdirat = 258,
+ mknodat = 259,
+ fchownat = 260,
+ futimesat = 261,
+ fstatat = 262,
+ unlinkat = 263,
+ renameat = 264,
+ linkat = 265,
+ symlinkat = 266,
+ readlinkat = 267,
+ fchmodat = 268,
+ faccessat = 269,
+ pselect6 = 270,
+ ppoll = 271,
+ unshare = 272,
+ set_robust_list = 273,
+ get_robust_list = 274,
+ splice = 275,
+ tee = 276,
+ sync_file_range = 277,
+ vmsplice = 278,
+ move_pages = 279,
+ utimensat = 280,
+ epoll_pwait = 281,
+ signalfd = 282,
+ timerfd_create = 283,
+ eventfd = 284,
+ fallocate = 285,
+ timerfd_settime = 286,
+ timerfd_gettime = 287,
+ accept4 = 288,
+ signalfd4 = 289,
+ eventfd2 = 290,
+ epoll_create1 = 291,
+ dup3 = 292,
+ pipe2 = 293,
+ inotify_init1 = 294,
+ preadv = 295,
+ pwritev = 296,
+ rt_tgsigqueueinfo = 297,
+ perf_event_open = 298,
+ recvmmsg = 299,
+ fanotify_init = 300,
+ fanotify_mark = 301,
+ prlimit64 = 302,
+ name_to_handle_at = 303,
+ open_by_handle_at = 304,
+ clock_adjtime = 305,
+ syncfs = 306,
+ sendmmsg = 307,
+ setns = 308,
+ getcpu = 309,
+ process_vm_readv = 310,
+ process_vm_writev = 311,
+ kcmp = 312,
+ finit_module = 313,
+ sched_setattr = 314,
+ sched_getattr = 315,
+ renameat2 = 316,
+ seccomp = 317,
+ getrandom = 318,
+ memfd_create = 319,
+ kexec_file_load = 320,
+ bpf = 321,
+ execveat = 322,
+ userfaultfd = 323,
+ membarrier = 324,
+ mlock2 = 325,
+ copy_file_range = 326,
+ preadv2 = 327,
+ pwritev2 = 328,
+ pkey_mprotect = 329,
+ pkey_alloc = 330,
+ pkey_free = 331,
+ statx = 332,
+ io_pgetevents = 333,
+ rseq = 334,
+ pidfd_send_signal = 424,
+ io_uring_setup = 425,
+ io_uring_enter = 426,
+ io_uring_register = 427,
+ open_tree = 428,
+ move_mount = 429,
+ fsopen = 430,
+ fsconfig = 431,
+ fsmount = 432,
+ fspick = 433,
+ pidfd_open = 434,
+ clone3 = 435,
+ close_range = 436,
+ openat2 = 437,
+ pidfd_getfd = 438,
+ faccessat2 = 439,
+ process_madvise = 440,
+ epoll_pwait2 = 441,
+
+ _,
+};
+
+pub const O = struct {
+ pub const CREAT = 0o100;
+ pub const EXCL = 0o200;
+ pub const NOCTTY = 0o400;
+ pub const TRUNC = 0o1000;
+ pub const APPEND = 0o2000;
+ pub const NONBLOCK = 0o4000;
+ pub const DSYNC = 0o10000;
+ pub const SYNC = 0o4010000;
+ pub const RSYNC = 0o4010000;
+ pub const DIRECTORY = 0o200000;
+ pub const NOFOLLOW = 0o400000;
+ pub const CLOEXEC = 0o2000000;
+
+ pub const ASYNC = 0o20000;
+ pub const DIRECT = 0o40000;
+ pub const LARGEFILE = 0;
+ pub const NOATIME = 0o1000000;
+ pub const PATH = 0o10000000;
+ pub const TMPFILE = 0o20200000;
+ pub const NDELAY = NONBLOCK;
+};
+
+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 = 5;
+ pub const SETLK = 6;
+ pub const SETLKW = 7;
+ pub const SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+ pub const GETOWNER_UIDS = 17;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+};
+
+pub const MAP = struct {
+ /// only give out 32bit addresses
+ pub const @"32BIT" = 0x40;
+ /// stack-like segment
+ pub const GROWSDOWN = 0x0100;
+ /// ETXTBSY
+ pub const DENYWRITE = 0x0800;
+ /// mark it as an executable
+ pub const EXECUTABLE = 0x1000;
+ /// pages are locked
+ pub const LOCKED = 0x2000;
+ /// don't check for reservations
+ pub const NORESERVE = 0x4000;
+};
+
+pub const VDSO = struct {
+ pub const CGT_SYM = "__vdso_clock_gettime";
+ pub const CGT_VER = "LINUX_2.6";
+
+ pub const GETCPU_SYM = "__vdso_getcpu";
+ pub const GETCPU_VER = "LINUX_2.6";
+};
+
+pub const ARCH = struct {
+ pub const SET_GS = 0x1001;
+ pub const SET_FS = 0x1002;
+ pub const GET_FS = 0x1003;
+ pub const GET_GS = 0x1004;
+};
+
+pub const REG = struct {
+ pub const R8 = 0;
+ pub const R9 = 1;
+ pub const R10 = 2;
+ pub const R11 = 3;
+ pub const R12 = 4;
+ pub const R13 = 5;
+ pub const R14 = 6;
+ pub const R15 = 7;
+ pub const RDI = 8;
+ pub const RSI = 9;
+ pub const RBP = 10;
+ pub const RBX = 11;
+ pub const RDX = 12;
+ pub const RAX = 13;
+ pub const RCX = 14;
+ pub const RSP = 15;
+ pub const RIP = 16;
+ pub const EFL = 17;
+ pub const CSGSFS = 18;
+ pub const ERR = 19;
+ pub const TRAPNO = 20;
+ pub const OLDMASK = 21;
+ pub const CR2 = 22;
+};
+
+pub const LOCK = struct {
+ pub const SH = 1;
+ pub const EX = 2;
+ pub const NB = 4;
+ pub const UN = 8;
+};
+
+pub const Flock = extern struct {
+ type: i16,
+ whence: i16,
+ start: off_t,
+ len: off_t,
+ pid: pid_t,
+};
+
+pub const msghdr = extern struct {
+ name: ?*sockaddr,
+ namelen: socklen_t,
+ iov: [*]iovec,
+ iovlen: i32,
+ __pad1: i32 = 0,
+ control: ?*c_void,
+ controllen: socklen_t,
+ __pad2: socklen_t = 0,
+ flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+ name: ?*const sockaddr,
+ namelen: socklen_t,
+ iov: [*]iovec_const,
+ iovlen: i32,
+ __pad1: i32 = 0,
+ control: ?*c_void,
+ controllen: socklen_t,
+ __pad2: socklen_t = 0,
+ flags: i32,
+};
+
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const dev_t = u64;
+
+// The `stat` definition used by the Linux kernel.
+pub const Stat = extern struct {
+ dev: dev_t,
+ ino: ino_t,
+ nlink: usize,
+
+ mode: u32,
+ uid: uid_t,
+ gid: gid_t,
+ __pad0: u32,
+ rdev: dev_t,
+ size: off_t,
+ blksize: isize,
+ blocks: i64,
+
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ __unused: [3]isize,
+
+ pub fn atime(self: @This()) timespec {
+ return self.atim;
+ }
+
+ pub fn mtime(self: @This()) timespec {
+ return self.mtim;
+ }
+
+ pub fn ctime(self: @This()) timespec {
+ return self.ctim;
+ }
+};
+
+pub const timeval = extern struct {
+ tv_sec: isize,
+ tv_usec: isize,
+};
+
+pub const timezone = extern struct {
+ tz_minuteswest: i32,
+ tz_dsttime: i32,
+};
+
+pub const Elf_Symndx = u32;
+
+pub const greg_t = usize;
+pub const gregset_t = [23]greg_t;
+pub const fpstate = extern struct {
+ cwd: u16,
+ swd: u16,
+ ftw: u16,
+ fop: u16,
+ rip: usize,
+ rdp: usize,
+ mxcsr: u32,
+ mxcr_mask: u32,
+ st: [8]extern struct {
+ significand: [4]u16,
+ exponent: u16,
+ padding: [3]u16 = undefined,
+ },
+ xmm: [16]extern struct {
+ element: [4]u32,
+ },
+ padding: [24]u32 = undefined,
+};
+pub const fpregset_t = *fpstate;
+pub const sigcontext = extern struct {
+ r8: usize,
+ r9: usize,
+ r10: usize,
+ r11: usize,
+ r12: usize,
+ r13: usize,
+ r14: usize,
+ r15: usize,
+
+ rdi: usize,
+ rsi: usize,
+ rbp: usize,
+ rbx: usize,
+ rdx: usize,
+ rax: usize,
+ rcx: usize,
+ rsp: usize,
+ rip: usize,
+ eflags: usize,
+
+ cs: u16,
+ gs: u16,
+ fs: u16,
+ pad0: u16 = undefined,
+
+ err: usize,
+ trapno: usize,
+ oldmask: usize,
+ cr2: usize,
+
+ fpstate: *fpstate,
+ reserved1: [8]usize = undefined,
+};
+
+pub const mcontext_t = extern struct {
+ gregs: gregset_t,
+ fpregs: fpregset_t,
+ reserved1: [8]usize = undefined,
+};
+
+pub const ucontext_t = extern struct {
+ flags: usize,
+ link: *ucontext_t,
+ stack: stack_t,
+ mcontext: mcontext_t,
+ sigmask: sigset_t,
+ fpregs_mem: [64]usize,
+};