From c09ba8796c64a0bd3a39d6545b852c1b2e91f473 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 24 Aug 2021 18:35:01 -0700 Subject: [PATCH] std.os.linux: remove the "bits" namespace altogether Now there is only 1 architecture-specific file for Linux kernel bits. --- lib/std/c/generic.zig | 1 + lib/std/os/bits/linux/arm-eabi.zig | 633 ------------------------ lib/std/os/bits/linux/arm64.zig | 492 ------------------- lib/std/os/bits/linux/i386.zig | 722 ---------------------------- lib/std/os/bits/linux/mips.zig | 590 ----------------------- lib/std/os/bits/linux/powerpc.zig | 618 ------------------------ lib/std/os/bits/linux/powerpc64.zig | 601 ----------------------- lib/std/os/bits/linux/riscv64.zig | 420 ---------------- lib/std/os/bits/linux/sparc64.zig | 641 ------------------------ lib/std/os/linux.zig | 25 +- lib/std/os/linux/arm-eabi.zig | 643 ++++++++++++++++++++++++- lib/std/os/linux/arm64.zig | 491 +++++++++++++++++++ lib/std/os/linux/bpf.zig | 1 - lib/std/os/linux/i386.zig | 720 +++++++++++++++++++++++++++ lib/std/os/linux/mips.zig | 591 +++++++++++++++++++++++ lib/std/os/linux/powerpc.zig | 620 ++++++++++++++++++++++++ lib/std/os/linux/powerpc64.zig | 603 +++++++++++++++++++++++ lib/std/os/linux/riscv64.zig | 420 ++++++++++++++++ lib/std/os/linux/sparc64.zig | 641 ++++++++++++++++++++++++ lib/std/os/linux/thumb.zig | 15 +- lib/std/os/linux/x86_64.zig | 4 +- 21 files changed, 4751 insertions(+), 4741 deletions(-) delete mode 100644 lib/std/os/bits/linux/arm-eabi.zig delete mode 100644 lib/std/os/bits/linux/arm64.zig delete mode 100644 lib/std/os/bits/linux/i386.zig delete mode 100644 lib/std/os/bits/linux/mips.zig delete mode 100644 lib/std/os/bits/linux/powerpc.zig delete mode 100644 lib/std/os/bits/linux/powerpc64.zig delete mode 100644 lib/std/os/bits/linux/riscv64.zig delete mode 100644 lib/std/os/bits/linux/sparc64.zig diff --git a/lib/std/c/generic.zig b/lib/std/c/generic.zig index cf374d195c..6580eee520 100644 --- a/lib/std/c/generic.zig +++ b/lib/std/c/generic.zig @@ -3,6 +3,7 @@ const Stat = std.c.Stat; const timespec = std.c.timespec; const Sigaction = std.c.Sigaction; const sigset_t = std.c.sigset_t; +const rusage = std.c.rusage; pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; pub extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int; diff --git a/lib/std/os/bits/linux/arm-eabi.zig b/lib/std/os/bits/linux/arm-eabi.zig deleted file mode 100644 index c948700e83..0000000000 --- a/lib/std/os/bits/linux/arm-eabi.zig +++ /dev/null @@ -1,633 +0,0 @@ -// arm-eabi-specific declarations that are intended to be imported into the POSIX namespace. -const std = @import("../../../std.zig"); -const linux = std.os.linux; -const socklen_t = linux.socklen_t; -const iovec = linux.iovec; -const iovec_const = linux.iovec_const; -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; - -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_CREAT = 0o100; -pub const O_EXCL = 0o200; -pub const O_NOCTTY = 0o400; -pub const O_TRUNC = 0o1000; -pub const O_APPEND = 0o2000; -pub const O_NONBLOCK = 0o4000; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0o4010000; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o40000; -pub const O_NOFOLLOW = 0o100000; -pub const O_CLOEXEC = 0o2000000; - -pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o200000; -pub const O_LARGEFILE = 0o400000; -pub const O_NOATIME = 0o1000000; -pub const O_PATH = 0o10000000; -pub const O_TMPFILE = 0o20040000; -pub const O_NDELAY = O_NONBLOCK; - -pub const F_DUPFD = 0; -pub const F_GETFD = 1; -pub const F_SETFD = 2; -pub const F_GETFL = 3; -pub const F_SETFL = 4; - -pub const F_SETOWN = 8; -pub const F_GETOWN = 9; -pub const F_SETSIG = 10; -pub const F_GETSIG = 11; - -pub const F_GETLK = 12; -pub const F_SETLK = 13; -pub const F_SETLKW = 14; - -pub const F_RDLCK = 0; -pub const F_WRLCK = 1; -pub const F_UNLCK = 2; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -/// stack-like segment -pub const MAP_GROWSDOWN = 0x0100; - -/// ETXTBSY -pub const MAP_DENYWRITE = 0x0800; - -/// mark it as an executable -pub const MAP_EXECUTABLE = 0x1000; - -/// pages are locked -pub const MAP_LOCKED = 0x2000; - -/// don't check for reservations -pub const MAP_NORESERVE = 0x4000; - -pub const VDSO_CGT_SYM = "__vdso_clock_gettime"; -pub const VDSO_CGT_VER = "LINUX_2.6"; - -pub const HWCAP_SWP = 1 << 0; -pub const HWCAP_HALF = 1 << 1; -pub const HWCAP_THUMB = 1 << 2; -pub const HWCAP_26BIT = 1 << 3; -pub const HWCAP_FAST_MULT = 1 << 4; -pub const HWCAP_FPA = 1 << 5; -pub const HWCAP_VFP = 1 << 6; -pub const HWCAP_EDSP = 1 << 7; -pub const HWCAP_JAVA = 1 << 8; -pub const HWCAP_IWMMXT = 1 << 9; -pub const HWCAP_CRUNCH = 1 << 10; -pub const HWCAP_THUMBEE = 1 << 11; -pub const HWCAP_NEON = 1 << 12; -pub const HWCAP_VFPv3 = 1 << 13; -pub const HWCAP_VFPv3D16 = 1 << 14; -pub const HWCAP_TLS = 1 << 15; -pub const HWCAP_VFPv4 = 1 << 16; -pub const HWCAP_IDIVA = 1 << 17; -pub const HWCAP_IDIVT = 1 << 18; -pub const HWCAP_VFPD32 = 1 << 19; -pub const HWCAP_IDIV = HWCAP_IDIVA | HWCAP_IDIVT; -pub const HWCAP_LPAE = 1 << 20; -pub const HWCAP_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 timespec = extern struct { - tv_sec: i32, - tv_nsec: i32, -}; - -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/bits/linux/arm64.zig b/lib/std/os/bits/linux/arm64.zig deleted file mode 100644 index 46d730d441..0000000000 --- a/lib/std/os/bits/linux/arm64.zig +++ /dev/null @@ -1,492 +0,0 @@ -// arm64-specific declarations that are intended to be imported into the POSIX namespace. -// This does include Linux-only APIs. - -const std = @import("../../../std.zig"); -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; -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_CREAT = 0o100; -pub const O_EXCL = 0o200; -pub const O_NOCTTY = 0o400; -pub const O_TRUNC = 0o1000; -pub const O_APPEND = 0o2000; -pub const O_NONBLOCK = 0o4000; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0o4010000; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o40000; -pub const O_NOFOLLOW = 0o100000; -pub const O_CLOEXEC = 0o2000000; - -pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o200000; -pub const O_LARGEFILE = 0o400000; -pub const O_NOATIME = 0o1000000; -pub const O_PATH = 0o10000000; -pub const O_TMPFILE = 0o20040000; -pub const O_NDELAY = O_NONBLOCK; - -pub const F_DUPFD = 0; -pub const F_GETFD = 1; -pub const F_SETFD = 2; -pub const F_GETFL = 3; -pub const F_SETFL = 4; - -pub const F_SETOWN = 8; -pub const F_GETOWN = 9; -pub const F_SETSIG = 10; -pub const F_GETSIG = 11; - -pub const F_GETLK = 5; -pub const F_SETLK = 6; -pub const F_SETLKW = 7; - -pub const F_RDLCK = 0; -pub const F_WRLCK = 1; -pub const F_UNLCK = 2; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -/// stack-like segment -pub const MAP_GROWSDOWN = 0x0100; - -/// ETXTBSY -pub const MAP_DENYWRITE = 0x0800; - -/// mark it as an executable -pub const MAP_EXECUTABLE = 0x1000; - -/// pages are locked -pub const MAP_LOCKED = 0x2000; - -/// don't check for reservations -pub const MAP_NORESERVE = 0x4000; - -pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; -pub const VDSO_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 timespec = extern struct { - tv_sec: time_t, - tv_nsec: isize, -}; - -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/bits/linux/i386.zig b/lib/std/os/bits/linux/i386.zig deleted file mode 100644 index 5c197e070a..0000000000 --- a/lib/std/os/bits/linux/i386.zig +++ /dev/null @@ -1,722 +0,0 @@ -// i386-specific declarations that are intended to be imported into the POSIX namespace. -// This does include Linux-only APIs. - -const std = @import("../../../std.zig"); -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; - -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 RDONLY = 0o0; - pub const WRONLY = 0o1; - pub const RDWR = 0o2; - - 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 { - /// Share changes - pub const SHARED = 0x01; - - /// Changes are private - pub const PRIVATE = 0x02; - - /// share + validate extension flags - pub const SHARED_VALIDATE = 0x03; - - /// Mask for type of mapping - pub const TYPE = 0x0f; - - /// Interpret addr exactly - pub const FIXED = 0x10; - - /// don't use a file - pub const ANONYMOUS = if (is_mips) 0x800 else 0x20; - - /// populate (prefault) pagetables - pub const POPULATE = if (is_mips) 0x10000 else 0x8000; - - /// do not block on IO - pub const NONBLOCK = if (is_mips) 0x20000 else 0x10000; - - /// give out an address that is best suited for process/thread stacks - pub const STACK = if (is_mips) 0x40000 else 0x20000; - - /// create a huge page mapping - pub const HUGETLB = if (is_mips) 0x80000 else 0x40000; - - /// perform synchronous page faults for the mapping - pub const SYNC = 0x80000; - - /// FIXED which doesn't unmap underlying mapping - pub const FIXED_NOREPLACE = 0x100000; - - /// For anonymous mmap, memory could be uninitialized - pub const UNINITIALIZED = 0x4000000; - - 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 timespec = extern struct { - tv_sec: i32, - tv_nsec: i32, -}; - -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/bits/linux/mips.zig b/lib/std/os/bits/linux/mips.zig deleted file mode 100644 index 14c686575a..0000000000 --- a/lib/std/os/bits/linux/mips.zig +++ /dev/null @@ -1,590 +0,0 @@ -const std = @import("../../../std.zig"); -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; - -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_CREAT = 0o0400; -pub const O_EXCL = 0o02000; -pub const O_NOCTTY = 0o04000; -pub const O_TRUNC = 0o01000; -pub const O_APPEND = 0o0010; -pub const O_NONBLOCK = 0o0200; -pub const O_DSYNC = 0o0020; -pub const O_SYNC = 0o040020; -pub const O_RSYNC = 0o040020; -pub const O_DIRECTORY = 0o0200000; -pub const O_NOFOLLOW = 0o0400000; -pub const O_CLOEXEC = 0o02000000; - -pub const O_ASYNC = 0o010000; -pub const O_DIRECT = 0o0100000; -pub const O_LARGEFILE = 0o020000; -pub const O_NOATIME = 0o01000000; -pub const O_PATH = 0o010000000; -pub const O_TMPFILE = 0o020200000; -pub const O_NDELAY = O_NONBLOCK; - -pub const F_DUPFD = 0; -pub const F_GETFD = 1; -pub const F_SETFD = 2; -pub const F_GETFL = 3; -pub const F_SETFL = 4; - -pub const F_SETOWN = 24; -pub const F_GETOWN = 23; -pub const F_SETSIG = 10; -pub const F_GETSIG = 11; - -pub const F_GETLK = 33; -pub const F_SETLK = 34; -pub const F_SETLKW = 35; - -pub const F_RDLCK = 0; -pub const F_WRLCK = 1; -pub const F_UNLCK = 2; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -pub const MMAP2_UNIT = 4096; - -pub const MAP_NORESERVE = 0x0400; -pub const MAP_GROWSDOWN = 0x1000; -pub const MAP_DENYWRITE = 0x2000; -pub const MAP_EXECUTABLE = 0x4000; -pub const MAP_LOCKED = 0x8000; -pub const MAP_32BIT = 0x40; - -pub const SO_DEBUG = 1; -pub const SO_REUSEADDR = 0x0004; -pub const SO_KEEPALIVE = 0x0008; -pub const SO_DONTROUTE = 0x0010; -pub const SO_BROADCAST = 0x0020; -pub const SO_LINGER = 0x0080; -pub const SO_OOBINLINE = 0x0100; -pub const SO_REUSEPORT = 0x0200; -pub const SO_SNDBUF = 0x1001; -pub const SO_RCVBUF = 0x1002; -pub const SO_SNDLOWAT = 0x1003; -pub const SO_RCVLOWAT = 0x1004; -pub const SO_RCVTIMEO = 0x1006; -pub const SO_SNDTIMEO = 0x1005; -pub const SO_ERROR = 0x1007; -pub const SO_TYPE = 0x1008; -pub const SO_ACCEPTCONN = 0x1009; -pub const SO_PROTOCOL = 0x1028; -pub const SO_DOMAIN = 0x1029; -pub const SO_NO_CHECK = 11; -pub const SO_PRIORITY = 12; -pub const SO_BSDCOMPAT = 14; -pub const SO_PASSCRED = 17; -pub const SO_PEERCRED = 18; -pub const SO_PEERSEC = 30; -pub const SO_SNDBUFFORCE = 31; -pub const SO_RCVBUFFORCE = 33; - -pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; -pub const VDSO_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 timespec = extern struct { - tv_sec: isize, - tv_nsec: isize, -}; - -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/bits/linux/powerpc.zig b/lib/std/os/bits/linux/powerpc.zig deleted file mode 100644 index 9c11de9ed5..0000000000 --- a/lib/std/os/bits/linux/powerpc.zig +++ /dev/null @@ -1,618 +0,0 @@ -const std = @import("../../../std.zig"); -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; -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_CREAT = 0o100; -pub const O_EXCL = 0o200; -pub const O_NOCTTY = 0o400; -pub const O_TRUNC = 0o1000; -pub const O_APPEND = 0o2000; -pub const O_NONBLOCK = 0o4000; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0o4010000; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o40000; -pub const O_NOFOLLOW = 0o100000; -pub const O_CLOEXEC = 0o2000000; - -pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o400000; -pub const O_LARGEFILE = 0o200000; -pub const O_NOATIME = 0o1000000; -pub const O_PATH = 0o10000000; -pub const O_TMPFILE = 0o20040000; -pub const O_NDELAY = O_NONBLOCK; - -pub const F_DUPFD = 0; -pub const F_GETFD = 1; -pub const F_SETFD = 2; -pub const F_GETFL = 3; -pub const F_SETFL = 4; - -pub const F_SETOWN = 8; -pub const F_GETOWN = 9; -pub const F_SETSIG = 10; -pub const F_GETSIG = 11; - -pub const F_GETLK = 12; -pub const F_SETLK = 13; -pub const F_SETLKW = 14; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -pub const F_RDLCK = 0; -pub const F_WRLCK = 1; -pub const F_UNLCK = 2; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -/// stack-like segment -pub const MAP_GROWSDOWN = 0x0100; - -/// ETXTBSY -pub const MAP_DENYWRITE = 0x0800; - -/// mark it as an executable -pub const MAP_EXECUTABLE = 0x1000; - -/// pages are locked -pub const MAP_LOCKED = 0x0080; - -/// don't check for reservations -pub const MAP_NORESERVE = 0x0040; - -pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; -pub const VDSO_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 timespec = extern struct { - tv_sec: time_t, - tv_nsec: isize, -}; - -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/bits/linux/powerpc64.zig b/lib/std/os/bits/linux/powerpc64.zig deleted file mode 100644 index 5f1307d1fa..0000000000 --- a/lib/std/os/bits/linux/powerpc64.zig +++ /dev/null @@ -1,601 +0,0 @@ -const std = @import("../../../std.zig"); -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; -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_CREAT = 0o100; -pub const O_EXCL = 0o200; -pub const O_NOCTTY = 0o400; -pub const O_TRUNC = 0o1000; -pub const O_APPEND = 0o2000; -pub const O_NONBLOCK = 0o4000; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0o4010000; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o40000; -pub const O_NOFOLLOW = 0o100000; -pub const O_CLOEXEC = 0o2000000; - -pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o400000; -pub const O_LARGEFILE = 0o200000; -pub const O_NOATIME = 0o1000000; -pub const O_PATH = 0o10000000; -pub const O_TMPFILE = 0o20200000; -pub const O_NDELAY = O_NONBLOCK; - -pub const F_DUPFD = 0; -pub const F_GETFD = 1; -pub const F_SETFD = 2; -pub const F_GETFL = 3; -pub const F_SETFL = 4; - -pub const F_SETOWN = 8; -pub const F_GETOWN = 9; -pub const F_SETSIG = 10; -pub const F_GETSIG = 11; - -pub const F_GETLK = 5; -pub const F_SETLK = 6; -pub const F_SETLKW = 7; - -pub const F_RDLCK = 0; -pub const F_WRLCK = 1; -pub const F_UNLCK = 2; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -/// stack-like segment -pub const MAP_GROWSDOWN = 0x0100; - -/// ETXTBSY -pub const MAP_DENYWRITE = 0x0800; - -/// mark it as an executable -pub const MAP_EXECUTABLE = 0x1000; - -/// pages are locked -pub const MAP_LOCKED = 0x0080; - -/// don't check for reservations -pub const MAP_NORESERVE = 0x0040; - -pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; -pub const VDSO_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 timespec = extern struct { - tv_sec: time_t, - tv_nsec: isize, -}; - -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/bits/linux/riscv64.zig b/lib/std/os/bits/linux/riscv64.zig deleted file mode 100644 index 5e392cd817..0000000000 --- a/lib/std/os/bits/linux/riscv64.zig +++ /dev/null @@ -1,420 +0,0 @@ -// riscv64-specific declarations that are intended to be imported into the POSIX namespace. -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; - -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_CREAT = 0o100; -pub const O_EXCL = 0o200; -pub const O_NOCTTY = 0o400; -pub const O_TRUNC = 0o1000; -pub const O_APPEND = 0o2000; -pub const O_NONBLOCK = 0o4000; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0o4010000; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o200000; -pub const O_NOFOLLOW = 0o400000; -pub const O_CLOEXEC = 0o2000000; - -pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o40000; -pub const O_LARGEFILE = 0o100000; -pub const O_NOATIME = 0o1000000; -pub const O_PATH = 0o10000000; -pub const O_TMPFILE = 0o20200000; -pub const O_NDELAY = O_NONBLOCK; - -pub const F_DUPFD = 0; -pub const F_GETFD = 1; -pub const F_SETFD = 2; -pub const F_GETFL = 3; -pub const F_SETFL = 4; -pub const F_GETLK = 5; -pub const F_SETLK = 6; -pub const F_SETLKW = 7; -pub const F_SETOWN = 8; -pub const F_GETOWN = 9; -pub const F_SETSIG = 10; -pub const F_GETSIG = 11; - -pub const F_RDLCK = 0; -pub const F_WRLCK = 1; -pub const F_UNLCK = 2; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -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 timespec = extern struct { - tv_sec: time_t, - tv_nsec: 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; diff --git a/lib/std/os/bits/linux/sparc64.zig b/lib/std/os/bits/linux/sparc64.zig deleted file mode 100644 index 39b061080e..0000000000 --- a/lib/std/os/bits/linux/sparc64.zig +++ /dev/null @@ -1,641 +0,0 @@ -// sparc64-specific declarations that are intended to be imported into the POSIX namespace. -const std = @import("../../../std.zig"); -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; - -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_CREAT = 0x200; -pub const O_EXCL = 0x800; -pub const O_NOCTTY = 0x8000; -pub const O_TRUNC = 0x400; -pub const O_APPEND = 0x8; -pub const O_NONBLOCK = 0x4000; -pub const O_SYNC = 0x802000; -pub const O_DSYNC = 0x2000; -pub const O_RSYNC = O_SYNC; -pub const O_DIRECTORY = 0x10000; -pub const O_NOFOLLOW = 0x20000; -pub const O_CLOEXEC = 0x400000; - -pub const O_ASYNC = 0x40; -pub const O_DIRECT = 0x100000; -pub const O_LARGEFILE = 0; -pub const O_NOATIME = 0x200000; -pub const O_PATH = 0x1000000; -pub const O_TMPFILE = 0x2010000; -pub const O_NDELAY = O_NONBLOCK | 0x4; - -pub const F_DUPFD = 0; -pub const F_GETFD = 1; -pub const F_SETFD = 2; -pub const F_GETFL = 3; -pub const F_SETFL = 4; - -pub const F_SETOWN = 5; -pub const F_GETOWN = 6; -pub const F_GETLK = 7; -pub const F_SETLK = 8; -pub const F_SETLKW = 9; - -pub const F_RDLCK = 1; -pub const F_WRLCK = 2; -pub const F_UNLCK = 3; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_NB = 4; -pub const LOCK_UN = 8; - -/// stack-like segment -pub const MAP_GROWSDOWN = 0x0200; - -/// ETXTBSY -pub const MAP_DENYWRITE = 0x0800; - -/// mark it as an executable -pub const MAP_EXECUTABLE = 0x1000; - -/// pages are locked -pub const MAP_LOCKED = 0x0100; - -/// don't check for reservations -pub const MAP_NORESERVE = 0x0040; - -pub const VDSO_CGT_SYM = "__vdso_clock_gettime"; -pub const VDSO_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 timespec = extern struct { - tv_sec: isize, - tv_nsec: isize, -}; - -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.zig b/lib/std/os/linux.zig index 37c00280e3..e022a9002c 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -24,6 +24,11 @@ test { } } +const syscall_bits = switch (native_arch) { + .thumb => @import("linux/thumb.zig"), + else => arch_bits, +}; + const arch_bits = switch (native_arch) { .i386 => @import("linux/i386.zig"), .x86_64 => @import("linux/x86_64.zig"), @@ -36,17 +41,17 @@ const arch_bits = switch (native_arch) { .powerpc64, .powerpc64le => @import("linux/powerpc64.zig"), else => struct {}, }; -pub const syscall0 = arch_bits.syscall0; -pub const syscall1 = arch_bits.syscall1; -pub const syscall2 = arch_bits.syscall2; -pub const syscall3 = arch_bits.syscall3; -pub const syscall4 = arch_bits.syscall4; -pub const syscall5 = arch_bits.syscall5; -pub const syscall6 = arch_bits.syscall6; -pub const clone = arch_bits.clone; -pub const restore = arch_bits.restore; -pub const restore_rt = arch_bits.restore_rt; +pub const syscall0 = syscall_bits.syscall0; +pub const syscall1 = syscall_bits.syscall1; +pub const syscall2 = syscall_bits.syscall2; +pub const syscall3 = syscall_bits.syscall3; +pub const syscall4 = syscall_bits.syscall4; +pub const syscall5 = syscall_bits.syscall5; +pub const syscall6 = syscall_bits.syscall6; +pub const restore = syscall_bits.restore; +pub const restore_rt = syscall_bits.restore_rt; +pub const clone = arch_bits.clone; pub const ARCH = arch_bits.ARCH; pub const Elf_Symndx = arch_bits.Elf_Symndx; pub const F = arch_bits.F; diff --git a/lib/std/os/linux/arm-eabi.zig b/lib/std/os/linux/arm-eabi.zig index 9c50f8494c..d4f25dba61 100644 --- a/lib/std/os/linux/arm-eabi.zig +++ b/lib/std/os/linux/arm-eabi.zig @@ -1,3 +1,14 @@ +const std = @import("../../std.zig"); +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; + pub fn syscall0(number: SYS) usize { return asm volatile ("svc #0" : [ret] "={r0}" (-> usize), @@ -84,7 +95,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" @@ -101,3 +120,625 @@ 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_CREAT = 0o100; +pub const O_EXCL = 0o200; +pub const O_NOCTTY = 0o400; +pub const O_TRUNC = 0o1000; +pub const O_APPEND = 0o2000; +pub const O_NONBLOCK = 0o4000; +pub const O_DSYNC = 0o10000; +pub const O_SYNC = 0o4010000; +pub const O_RSYNC = 0o4010000; +pub const O_DIRECTORY = 0o40000; +pub const O_NOFOLLOW = 0o100000; +pub const O_CLOEXEC = 0o2000000; + +pub const O_ASYNC = 0o20000; +pub const O_DIRECT = 0o200000; +pub const O_LARGEFILE = 0o400000; +pub const O_NOATIME = 0o1000000; +pub const O_PATH = 0o10000000; +pub const O_TMPFILE = 0o20040000; +pub const O_NDELAY = O_NONBLOCK; + +pub const F_DUPFD = 0; +pub const F_GETFD = 1; +pub const F_SETFD = 2; +pub const F_GETFL = 3; +pub const F_SETFL = 4; + +pub const F_SETOWN = 8; +pub const F_GETOWN = 9; +pub const F_SETSIG = 10; +pub const F_GETSIG = 11; + +pub const F_GETLK = 12; +pub const F_SETLK = 13; +pub const F_SETLKW = 14; + +pub const F_RDLCK = 0; +pub const F_WRLCK = 1; +pub const F_UNLCK = 2; + +pub const F_SETOWN_EX = 15; +pub const F_GETOWN_EX = 16; + +pub const F_GETOWNER_UIDS = 17; + +pub const LOCK_SH = 1; +pub const LOCK_EX = 2; +pub const LOCK_UN = 8; +pub const LOCK_NB = 4; + +/// stack-like segment +pub const MAP_GROWSDOWN = 0x0100; + +/// ETXTBSY +pub const MAP_DENYWRITE = 0x0800; + +/// mark it as an executable +pub const MAP_EXECUTABLE = 0x1000; + +/// pages are locked +pub const MAP_LOCKED = 0x2000; + +/// don't check for reservations +pub const MAP_NORESERVE = 0x4000; + +pub const VDSO_CGT_SYM = "__vdso_clock_gettime"; +pub const VDSO_CGT_VER = "LINUX_2.6"; + +pub const HWCAP_SWP = 1 << 0; +pub const HWCAP_HALF = 1 << 1; +pub const HWCAP_THUMB = 1 << 2; +pub const HWCAP_26BIT = 1 << 3; +pub const HWCAP_FAST_MULT = 1 << 4; +pub const HWCAP_FPA = 1 << 5; +pub const HWCAP_VFP = 1 << 6; +pub const HWCAP_EDSP = 1 << 7; +pub const HWCAP_JAVA = 1 << 8; +pub const HWCAP_IWMMXT = 1 << 9; +pub const HWCAP_CRUNCH = 1 << 10; +pub const HWCAP_THUMBEE = 1 << 11; +pub const HWCAP_NEON = 1 << 12; +pub const HWCAP_VFPv3 = 1 << 13; +pub const HWCAP_VFPv3D16 = 1 << 14; +pub const HWCAP_TLS = 1 << 15; +pub const HWCAP_VFPv4 = 1 << 16; +pub const HWCAP_IDIVA = 1 << 17; +pub const HWCAP_IDIVT = 1 << 18; +pub const HWCAP_VFPD32 = 1 << 19; +pub const HWCAP_IDIV = HWCAP_IDIVA | HWCAP_IDIVT; +pub const HWCAP_LPAE = 1 << 20; +pub const HWCAP_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 timespec = extern struct { + tv_sec: i32, + tv_nsec: i32, +}; + +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 c9d95ecc18..892de725eb 100644 --- a/lib/std/os/linux/arm64.zig +++ b/lib/std/os/linux/arm64.zig @@ -1,3 +1,15 @@ +const std = @import("../../std.zig"); +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; + pub fn syscall0(number: SYS) usize { return asm volatile ("svc #0" : [ret] "={x0}" (-> usize), @@ -95,3 +107,482 @@ 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_CREAT = 0o100; +pub const O_EXCL = 0o200; +pub const O_NOCTTY = 0o400; +pub const O_TRUNC = 0o1000; +pub const O_APPEND = 0o2000; +pub const O_NONBLOCK = 0o4000; +pub const O_DSYNC = 0o10000; +pub const O_SYNC = 0o4010000; +pub const O_RSYNC = 0o4010000; +pub const O_DIRECTORY = 0o40000; +pub const O_NOFOLLOW = 0o100000; +pub const O_CLOEXEC = 0o2000000; + +pub const O_ASYNC = 0o20000; +pub const O_DIRECT = 0o200000; +pub const O_LARGEFILE = 0o400000; +pub const O_NOATIME = 0o1000000; +pub const O_PATH = 0o10000000; +pub const O_TMPFILE = 0o20040000; +pub const O_NDELAY = O_NONBLOCK; + +pub const F_DUPFD = 0; +pub const F_GETFD = 1; +pub const F_SETFD = 2; +pub const F_GETFL = 3; +pub const F_SETFL = 4; + +pub const F_SETOWN = 8; +pub const F_GETOWN = 9; +pub const F_SETSIG = 10; +pub const F_GETSIG = 11; + +pub const F_GETLK = 5; +pub const F_SETLK = 6; +pub const F_SETLKW = 7; + +pub const F_RDLCK = 0; +pub const F_WRLCK = 1; +pub const F_UNLCK = 2; + +pub const LOCK_SH = 1; +pub const LOCK_EX = 2; +pub const LOCK_UN = 8; +pub const LOCK_NB = 4; + +pub const F_SETOWN_EX = 15; +pub const F_GETOWN_EX = 16; + +pub const F_GETOWNER_UIDS = 17; + +/// stack-like segment +pub const MAP_GROWSDOWN = 0x0100; + +/// ETXTBSY +pub const MAP_DENYWRITE = 0x0800; + +/// mark it as an executable +pub const MAP_EXECUTABLE = 0x1000; + +/// pages are locked +pub const MAP_LOCKED = 0x2000; + +/// don't check for reservations +pub const MAP_NORESERVE = 0x4000; + +pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; +pub const VDSO_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 timespec = extern struct { + tv_sec: time_t, + tv_nsec: isize, +}; + +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..a1d2a86bb6 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; diff --git a/lib/std/os/linux/i386.zig b/lib/std/os/linux/i386.zig index c40a438563..ed56d9b922 100644 --- a/lib/std/os/linux/i386.zig +++ b/lib/std/os/linux/i386.zig @@ -1,3 +1,14 @@ +const std = @import("../../std.zig"); +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; + pub fn syscall0(number: SYS) usize { return asm volatile ("int $0x80" : [ret] "={eax}" (-> usize), @@ -121,3 +132,712 @@ 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 RDONLY = 0o0; + pub const WRONLY = 0o1; + pub const RDWR = 0o2; + + 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 { + /// Share changes + pub const SHARED = 0x01; + + /// Changes are private + pub const PRIVATE = 0x02; + + /// share + validate extension flags + pub const SHARED_VALIDATE = 0x03; + + /// Mask for type of mapping + pub const TYPE = 0x0f; + + /// Interpret addr exactly + pub const FIXED = 0x10; + + /// don't use a file + pub const ANONYMOUS = if (is_mips) 0x800 else 0x20; + + /// populate (prefault) pagetables + pub const POPULATE = if (is_mips) 0x10000 else 0x8000; + + /// do not block on IO + pub const NONBLOCK = if (is_mips) 0x20000 else 0x10000; + + /// give out an address that is best suited for process/thread stacks + pub const STACK = if (is_mips) 0x40000 else 0x20000; + + /// create a huge page mapping + pub const HUGETLB = if (is_mips) 0x80000 else 0x40000; + + /// perform synchronous page faults for the mapping + pub const SYNC = 0x80000; + + /// FIXED which doesn't unmap underlying mapping + pub const FIXED_NOREPLACE = 0x100000; + + /// For anonymous mmap, memory could be uninitialized + pub const UNINITIALIZED = 0x4000000; + + 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 timespec = extern struct { + tv_sec: i32, + tv_nsec: i32, +}; + +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/mips.zig b/lib/std/os/linux/mips.zig index bc1ebede1a..ef2688b10c 100644 --- a/lib/std/os/linux/mips.zig +++ b/lib/std/os/linux/mips.zig @@ -1,3 +1,12 @@ +const std = @import("../../std.zig"); +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; + pub fn syscall0(number: SYS) usize { return asm volatile ( \\ syscall @@ -195,3 +204,585 @@ 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_CREAT = 0o0400; +pub const O_EXCL = 0o02000; +pub const O_NOCTTY = 0o04000; +pub const O_TRUNC = 0o01000; +pub const O_APPEND = 0o0010; +pub const O_NONBLOCK = 0o0200; +pub const O_DSYNC = 0o0020; +pub const O_SYNC = 0o040020; +pub const O_RSYNC = 0o040020; +pub const O_DIRECTORY = 0o0200000; +pub const O_NOFOLLOW = 0o0400000; +pub const O_CLOEXEC = 0o02000000; + +pub const O_ASYNC = 0o010000; +pub const O_DIRECT = 0o0100000; +pub const O_LARGEFILE = 0o020000; +pub const O_NOATIME = 0o01000000; +pub const O_PATH = 0o010000000; +pub const O_TMPFILE = 0o020200000; +pub const O_NDELAY = O_NONBLOCK; + +pub const F_DUPFD = 0; +pub const F_GETFD = 1; +pub const F_SETFD = 2; +pub const F_GETFL = 3; +pub const F_SETFL = 4; + +pub const F_SETOWN = 24; +pub const F_GETOWN = 23; +pub const F_SETSIG = 10; +pub const F_GETSIG = 11; + +pub const F_GETLK = 33; +pub const F_SETLK = 34; +pub const F_SETLKW = 35; + +pub const F_RDLCK = 0; +pub const F_WRLCK = 1; +pub const F_UNLCK = 2; + +pub const LOCK_SH = 1; +pub const LOCK_EX = 2; +pub const LOCK_UN = 8; +pub const LOCK_NB = 4; + +pub const F_SETOWN_EX = 15; +pub const F_GETOWN_EX = 16; + +pub const F_GETOWNER_UIDS = 17; + +pub const MMAP2_UNIT = 4096; + +pub const MAP_NORESERVE = 0x0400; +pub const MAP_GROWSDOWN = 0x1000; +pub const MAP_DENYWRITE = 0x2000; +pub const MAP_EXECUTABLE = 0x4000; +pub const MAP_LOCKED = 0x8000; +pub const MAP_32BIT = 0x40; + +pub const SO_DEBUG = 1; +pub const SO_REUSEADDR = 0x0004; +pub const SO_KEEPALIVE = 0x0008; +pub const SO_DONTROUTE = 0x0010; +pub const SO_BROADCAST = 0x0020; +pub const SO_LINGER = 0x0080; +pub const SO_OOBINLINE = 0x0100; +pub const SO_REUSEPORT = 0x0200; +pub const SO_SNDBUF = 0x1001; +pub const SO_RCVBUF = 0x1002; +pub const SO_SNDLOWAT = 0x1003; +pub const SO_RCVLOWAT = 0x1004; +pub const SO_RCVTIMEO = 0x1006; +pub const SO_SNDTIMEO = 0x1005; +pub const SO_ERROR = 0x1007; +pub const SO_TYPE = 0x1008; +pub const SO_ACCEPTCONN = 0x1009; +pub const SO_PROTOCOL = 0x1028; +pub const SO_DOMAIN = 0x1029; +pub const SO_NO_CHECK = 11; +pub const SO_PRIORITY = 12; +pub const SO_BSDCOMPAT = 14; +pub const SO_PASSCRED = 17; +pub const SO_PEERCRED = 18; +pub const SO_PEERSEC = 30; +pub const SO_SNDBUFFORCE = 31; +pub const SO_RCVBUFFORCE = 33; + +pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; +pub const VDSO_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 timespec = extern struct { + tv_sec: isize, + tv_nsec: isize, +}; + +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 0bcc311f58..9bdcd33b4c 100644 --- a/lib/std/os/linux/powerpc.zig +++ b/lib/std/os/linux/powerpc.zig @@ -1,3 +1,14 @@ +const std = @import("../../std.zig"); +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; + pub fn syscall0(number: SYS) usize { return asm volatile ( \\ sc @@ -123,3 +134,612 @@ 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_CREAT = 0o100; +pub const O_EXCL = 0o200; +pub const O_NOCTTY = 0o400; +pub const O_TRUNC = 0o1000; +pub const O_APPEND = 0o2000; +pub const O_NONBLOCK = 0o4000; +pub const O_DSYNC = 0o10000; +pub const O_SYNC = 0o4010000; +pub const O_RSYNC = 0o4010000; +pub const O_DIRECTORY = 0o40000; +pub const O_NOFOLLOW = 0o100000; +pub const O_CLOEXEC = 0o2000000; + +pub const O_ASYNC = 0o20000; +pub const O_DIRECT = 0o400000; +pub const O_LARGEFILE = 0o200000; +pub const O_NOATIME = 0o1000000; +pub const O_PATH = 0o10000000; +pub const O_TMPFILE = 0o20040000; +pub const O_NDELAY = O_NONBLOCK; + +pub const F_DUPFD = 0; +pub const F_GETFD = 1; +pub const F_SETFD = 2; +pub const F_GETFL = 3; +pub const F_SETFL = 4; + +pub const F_SETOWN = 8; +pub const F_GETOWN = 9; +pub const F_SETSIG = 10; +pub const F_GETSIG = 11; + +pub const F_GETLK = 12; +pub const F_SETLK = 13; +pub const F_SETLKW = 14; + +pub const F_SETOWN_EX = 15; +pub const F_GETOWN_EX = 16; + +pub const F_GETOWNER_UIDS = 17; + +pub const F_RDLCK = 0; +pub const F_WRLCK = 1; +pub const F_UNLCK = 2; + +pub const LOCK_SH = 1; +pub const LOCK_EX = 2; +pub const LOCK_UN = 8; +pub const LOCK_NB = 4; + +/// stack-like segment +pub const MAP_GROWSDOWN = 0x0100; + +/// ETXTBSY +pub const MAP_DENYWRITE = 0x0800; + +/// mark it as an executable +pub const MAP_EXECUTABLE = 0x1000; + +/// pages are locked +pub const MAP_LOCKED = 0x0080; + +/// don't check for reservations +pub const MAP_NORESERVE = 0x0040; + +pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; +pub const VDSO_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 timespec = extern struct { + tv_sec: time_t, + tv_nsec: isize, +}; + +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 0bcc311f58..586063d609 100644 --- a/lib/std/os/linux/powerpc64.zig +++ b/lib/std/os/linux/powerpc64.zig @@ -1,3 +1,14 @@ +const std = @import("../../std.zig"); +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; + pub fn syscall0(number: SYS) usize { return asm volatile ( \\ sc @@ -123,3 +134,595 @@ 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_CREAT = 0o100; +pub const O_EXCL = 0o200; +pub const O_NOCTTY = 0o400; +pub const O_TRUNC = 0o1000; +pub const O_APPEND = 0o2000; +pub const O_NONBLOCK = 0o4000; +pub const O_DSYNC = 0o10000; +pub const O_SYNC = 0o4010000; +pub const O_RSYNC = 0o4010000; +pub const O_DIRECTORY = 0o40000; +pub const O_NOFOLLOW = 0o100000; +pub const O_CLOEXEC = 0o2000000; + +pub const O_ASYNC = 0o20000; +pub const O_DIRECT = 0o400000; +pub const O_LARGEFILE = 0o200000; +pub const O_NOATIME = 0o1000000; +pub const O_PATH = 0o10000000; +pub const O_TMPFILE = 0o20200000; +pub const O_NDELAY = O_NONBLOCK; + +pub const F_DUPFD = 0; +pub const F_GETFD = 1; +pub const F_SETFD = 2; +pub const F_GETFL = 3; +pub const F_SETFL = 4; + +pub const F_SETOWN = 8; +pub const F_GETOWN = 9; +pub const F_SETSIG = 10; +pub const F_GETSIG = 11; + +pub const F_GETLK = 5; +pub const F_SETLK = 6; +pub const F_SETLKW = 7; + +pub const F_RDLCK = 0; +pub const F_WRLCK = 1; +pub const F_UNLCK = 2; + +pub const LOCK_SH = 1; +pub const LOCK_EX = 2; +pub const LOCK_UN = 8; +pub const LOCK_NB = 4; + +pub const F_SETOWN_EX = 15; +pub const F_GETOWN_EX = 16; + +pub const F_GETOWNER_UIDS = 17; + +/// stack-like segment +pub const MAP_GROWSDOWN = 0x0100; + +/// ETXTBSY +pub const MAP_DENYWRITE = 0x0800; + +/// mark it as an executable +pub const MAP_EXECUTABLE = 0x1000; + +/// pages are locked +pub const MAP_LOCKED = 0x0080; + +/// don't check for reservations +pub const MAP_NORESERVE = 0x0040; + +pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; +pub const VDSO_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 timespec = extern struct { + tv_sec: time_t, + tv_nsec: isize, +}; + +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 e0aaa2a2ed..e070f3ef90 100644 --- a/lib/std/os/linux/riscv64.zig +++ b/lib/std/os/linux/riscv64.zig @@ -1,3 +1,8 @@ +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; + pub fn syscall0(number: SYS) usize { return asm volatile ("ecall" : [ret] "={x10}" (-> usize), @@ -94,3 +99,418 @@ 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_CREAT = 0o100; +pub const O_EXCL = 0o200; +pub const O_NOCTTY = 0o400; +pub const O_TRUNC = 0o1000; +pub const O_APPEND = 0o2000; +pub const O_NONBLOCK = 0o4000; +pub const O_DSYNC = 0o10000; +pub const O_SYNC = 0o4010000; +pub const O_RSYNC = 0o4010000; +pub const O_DIRECTORY = 0o200000; +pub const O_NOFOLLOW = 0o400000; +pub const O_CLOEXEC = 0o2000000; + +pub const O_ASYNC = 0o20000; +pub const O_DIRECT = 0o40000; +pub const O_LARGEFILE = 0o100000; +pub const O_NOATIME = 0o1000000; +pub const O_PATH = 0o10000000; +pub const O_TMPFILE = 0o20200000; +pub const O_NDELAY = O_NONBLOCK; + +pub const F_DUPFD = 0; +pub const F_GETFD = 1; +pub const F_SETFD = 2; +pub const F_GETFL = 3; +pub const F_SETFL = 4; +pub const F_GETLK = 5; +pub const F_SETLK = 6; +pub const F_SETLKW = 7; +pub const F_SETOWN = 8; +pub const F_GETOWN = 9; +pub const F_SETSIG = 10; +pub const F_GETSIG = 11; + +pub const F_RDLCK = 0; +pub const F_WRLCK = 1; +pub const F_UNLCK = 2; + +pub const LOCK_SH = 1; +pub const LOCK_EX = 2; +pub const LOCK_UN = 8; +pub const LOCK_NB = 4; + +pub const F_SETOWN_EX = 15; +pub const F_GETOWN_EX = 16; + +pub const F_GETOWNER_UIDS = 17; + +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 timespec = extern struct { + tv_sec: time_t, + tv_nsec: 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; diff --git a/lib/std/os/linux/sparc64.zig b/lib/std/os/linux/sparc64.zig index d5fdcb6993..741901ec2d 100644 --- a/lib/std/os/linux/sparc64.zig +++ b/lib/std/os/linux/sparc64.zig @@ -1,3 +1,16 @@ +const std = @import("../../std.zig"); +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; + pub fn syscall_pipe(fd: *[2]i32) usize { return asm volatile ( \\ mov %[arg], %%g3 @@ -176,3 +189,631 @@ 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_CREAT = 0x200; +pub const O_EXCL = 0x800; +pub const O_NOCTTY = 0x8000; +pub const O_TRUNC = 0x400; +pub const O_APPEND = 0x8; +pub const O_NONBLOCK = 0x4000; +pub const O_SYNC = 0x802000; +pub const O_DSYNC = 0x2000; +pub const O_RSYNC = O_SYNC; +pub const O_DIRECTORY = 0x10000; +pub const O_NOFOLLOW = 0x20000; +pub const O_CLOEXEC = 0x400000; + +pub const O_ASYNC = 0x40; +pub const O_DIRECT = 0x100000; +pub const O_LARGEFILE = 0; +pub const O_NOATIME = 0x200000; +pub const O_PATH = 0x1000000; +pub const O_TMPFILE = 0x2010000; +pub const O_NDELAY = O_NONBLOCK | 0x4; + +pub const F_DUPFD = 0; +pub const F_GETFD = 1; +pub const F_SETFD = 2; +pub const F_GETFL = 3; +pub const F_SETFL = 4; + +pub const F_SETOWN = 5; +pub const F_GETOWN = 6; +pub const F_GETLK = 7; +pub const F_SETLK = 8; +pub const F_SETLKW = 9; + +pub const F_RDLCK = 1; +pub const F_WRLCK = 2; +pub const F_UNLCK = 3; + +pub const F_SETOWN_EX = 15; +pub const F_GETOWN_EX = 16; + +pub const F_GETOWNER_UIDS = 17; + +pub const LOCK_SH = 1; +pub const LOCK_EX = 2; +pub const LOCK_NB = 4; +pub const LOCK_UN = 8; + +/// stack-like segment +pub const MAP_GROWSDOWN = 0x0200; + +/// ETXTBSY +pub const MAP_DENYWRITE = 0x0800; + +/// mark it as an executable +pub const MAP_EXECUTABLE = 0x1000; + +/// pages are locked +pub const MAP_LOCKED = 0x0100; + +/// don't check for reservations +pub const MAP_NORESERVE = 0x0040; + +pub const VDSO_CGT_SYM = "__vdso_clock_gettime"; +pub const VDSO_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 timespec = extern struct { + tv_sec: isize, + tv_nsec: isize, +}; + +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/thumb.zig b/lib/std/os/linux/thumb.zig index e5d185b8c1..3d38ca85b9 100644 --- a/lib/std/os/linux/thumb.zig +++ b/lib/std/os/linux/thumb.zig @@ -1,10 +1,8 @@ -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. pub fn syscall0(number: SYS) usize { @setRuntimeSafety(false); @@ -140,9 +138,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/x86_64.zig b/lib/std/os/linux/x86_64.zig index bca222d77c..4be94dfc01 100644 --- a/lib/std/os/linux/x86_64.zig +++ b/lib/std/os/linux/x86_64.zig @@ -1,5 +1,7 @@ const std = @import("../../std.zig"); 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; @@ -9,8 +11,6 @@ const stack_t = linux.stack_t; const sigset_t = linux.sigset_t; const sockaddr = linux.sockaddr; const socklen_t = linux.socklen_t; -const iovec = linux.iovec; -const iovec_const = linux.iovec_const; pub fn syscall0(number: SYS) usize { return asm volatile ("syscall"