| author | |
| committer | |
| log | 1f8a72175b5352e77b41ed4d165acccad08ffb16 |
| tree | d573a9ef3ad64fc8e257fe7a736e57e50c2d8e2d |
| parent | 3091efaa1845bf049ce1d4aaacb95e3b1e346453 |
| parent | 29fb9e4da7d60f32f7efe6d280a69e020cd117a7 |
| signature |
`std.os.linux`: some miscellaneous cleanup in arch bits20 files changed, 1155 insertions(+), 1457 deletions(-)
lib/std/os/linux.zig+93-16| ... | ... | @@ -32,21 +32,27 @@ test { |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | const arch_bits = switch (native_arch) { |
| 35 | .x86 => @import("linux/x86.zig"), | |
| 36 | .x86_64 => @import("linux/x86_64.zig"), | |
| 37 | 35 | .aarch64, .aarch64_be => @import("linux/aarch64.zig"), |
| 38 | 36 | .arm, .armeb, .thumb, .thumbeb => @import("linux/arm.zig"), |
| 39 | 37 | .hexagon => @import("linux/hexagon.zig"), |
| 40 | .riscv32 => @import("linux/riscv32.zig"), | |
| 41 | .riscv64 => @import("linux/riscv64.zig"), | |
| 42 | .sparc64 => @import("linux/sparc64.zig"), | |
| 43 | 38 | .loongarch64 => @import("linux/loongarch64.zig"), |
| 44 | 39 | .m68k => @import("linux/m68k.zig"), |
| 45 | 40 | .mips, .mipsel => @import("linux/mips.zig"), |
| 46 | .mips64, .mips64el => @import("linux/mips64.zig"), | |
| 41 | .mips64, .mips64el => switch (builtin.abi) { | |
| 42 | .gnuabin32, .muslabin32 => @import("linux/mipsn32.zig"), | |
| 43 | else => @import("linux/mips64.zig"), | |
| 44 | }, | |
| 47 | 45 | .powerpc, .powerpcle => @import("linux/powerpc.zig"), |
| 48 | 46 | .powerpc64, .powerpc64le => @import("linux/powerpc64.zig"), |
| 47 | .riscv32 => @import("linux/riscv32.zig"), | |
| 48 | .riscv64 => @import("linux/riscv64.zig"), | |
| 49 | 49 | .s390x => @import("linux/s390x.zig"), |
| 50 | .sparc64 => @import("linux/sparc64.zig"), | |
| 51 | .x86 => @import("linux/x86.zig"), | |
| 52 | .x86_64 => switch (builtin.abi) { | |
| 53 | .gnux32, .muslx32 => @import("linux/x32.zig"), | |
| 54 | else => @import("linux/x86_64.zig"), | |
| 55 | }, | |
| 50 | 56 | else => struct {}, |
| 51 | 57 | }; |
| 52 | 58 | |
| ... | ... | @@ -88,9 +94,6 @@ pub fn clone( |
| 88 | 94 | } |
| 89 | 95 | |
| 90 | 96 | pub const ARCH = arch_bits.ARCH; |
| 91 | pub const Elf_Symndx = arch_bits.Elf_Symndx; | |
| 92 | pub const F = arch_bits.F; | |
| 93 | pub const Flock = arch_bits.Flock; | |
| 94 | 97 | pub const HWCAP = arch_bits.HWCAP; |
| 95 | 98 | pub const SC = arch_bits.SC; |
| 96 | 99 | pub const Stat = arch_bits.Stat; |
| ... | ... | @@ -103,8 +106,6 @@ pub const mode_t = arch_bits.mode_t; |
| 103 | 106 | pub const nlink_t = arch_bits.nlink_t; |
| 104 | 107 | pub const off_t = arch_bits.off_t; |
| 105 | 108 | pub const time_t = arch_bits.time_t; |
| 106 | pub const timeval = arch_bits.timeval; | |
| 107 | pub const timezone = arch_bits.timezone; | |
| 108 | 109 | pub const user_desc = arch_bits.user_desc; |
| 109 | 110 | |
| 110 | 111 | pub const tls = @import("linux/tls.zig"); |
| ... | ... | @@ -113,10 +114,10 @@ pub const IOCTL = @import("linux/ioctl.zig"); |
| 113 | 114 | pub const SECCOMP = @import("linux/seccomp.zig"); |
| 114 | 115 | |
| 115 | 116 | pub const syscalls = @import("linux/syscalls.zig"); |
| 116 | pub const SYS = switch (@import("builtin").cpu.arch) { | |
| 117 | pub const SYS = switch (native_arch) { | |
| 117 | 118 | .arc => syscalls.Arc, |
| 118 | .arm, .armeb, .thumb, .thumbeb => syscalls.Arm, | |
| 119 | 119 | .aarch64, .aarch64_be => syscalls.Arm64, |
| 120 | .arm, .armeb, .thumb, .thumbeb => syscalls.Arm, | |
| 120 | 121 | .csky => syscalls.CSky, |
| 121 | 122 | .hexagon => syscalls.Hexagon, |
| 122 | 123 | .loongarch64 => syscalls.LoongArch64, |
| ... | ... | @@ -126,20 +127,20 @@ pub const SYS = switch (@import("builtin").cpu.arch) { |
| 126 | 127 | .gnuabin32, .muslabin32 => syscalls.MipsN32, |
| 127 | 128 | else => syscalls.MipsN64, |
| 128 | 129 | }, |
| 130 | .or1k => syscalls.OpenRisc, | |
| 131 | .powerpc, .powerpcle => syscalls.PowerPC, | |
| 132 | .powerpc64, .powerpc64le => syscalls.PowerPC64, | |
| 129 | 133 | .riscv32 => syscalls.RiscV32, |
| 130 | 134 | .riscv64 => syscalls.RiscV64, |
| 131 | 135 | .s390x => syscalls.S390x, |
| 132 | 136 | .sparc => syscalls.Sparc, |
| 133 | 137 | .sparc64 => syscalls.Sparc64, |
| 134 | .powerpc, .powerpcle => syscalls.PowerPC, | |
| 135 | .powerpc64, .powerpc64le => syscalls.PowerPC64, | |
| 136 | 138 | .x86 => syscalls.X86, |
| 137 | 139 | .x86_64 => switch (builtin.abi) { |
| 138 | 140 | .gnux32, .muslx32 => syscalls.X32, |
| 139 | 141 | else => syscalls.X64, |
| 140 | 142 | }, |
| 141 | 143 | .xtensa => syscalls.Xtensa, |
| 142 | .or1k => syscalls.OpenRisc, | |
| 143 | 144 | else => @compileError("The Zig Standard Library is missing syscall definitions for the target CPU architecture"), |
| 144 | 145 | }; |
| 145 | 146 | |
| ... | ... | @@ -1600,6 +1601,70 @@ pub fn waitid(id_type: P, id: i32, infop: *siginfo_t, flags: u32) usize { |
| 1600 | 1601 | return syscall5(.waitid, @intFromEnum(id_type), @as(usize, @bitCast(@as(isize, id))), @intFromPtr(infop), flags, 0); |
| 1601 | 1602 | } |
| 1602 | 1603 | |
| 1604 | pub const F = struct { | |
| 1605 | pub const DUPFD = 0; | |
| 1606 | pub const GETFD = 1; | |
| 1607 | pub const SETFD = 2; | |
| 1608 | pub const GETFL = 3; | |
| 1609 | pub const SETFL = 4; | |
| 1610 | ||
| 1611 | pub const GETLK = GET_SET_LK.GETLK; | |
| 1612 | pub const SETLK = GET_SET_LK.SETLK; | |
| 1613 | pub const SETLKW = GET_SET_LK.SETLKW; | |
| 1614 | ||
| 1615 | const GET_SET_LK = if (@sizeOf(usize) == 64) extern struct { | |
| 1616 | pub const GETLK = if (is_mips) 14 else if (is_sparc) 7 else 5; | |
| 1617 | pub const SETLK = if (is_mips) 6 else if (is_sparc) 8 else 6; | |
| 1618 | pub const SETLKW = if (is_mips) 7 else if (is_sparc) 9 else 7; | |
| 1619 | } else extern struct { | |
| 1620 | // Ensure that 32-bit code uses the large-file variants (GETLK64, etc). | |
| 1621 | ||
| 1622 | pub const GETLK = if (is_mips) 33 else 12; | |
| 1623 | pub const SETLK = if (is_mips) 34 else 13; | |
| 1624 | pub const SETLKW = if (is_mips) 35 else 14; | |
| 1625 | }; | |
| 1626 | ||
| 1627 | pub const SETOWN = if (is_mips) 24 else if (is_sparc) 6 else 8; | |
| 1628 | pub const GETOWN = if (is_mips) 23 else if (is_sparc) 5 else 9; | |
| 1629 | ||
| 1630 | pub const SETSIG = 10; | |
| 1631 | pub const GETSIG = 11; | |
| 1632 | ||
| 1633 | pub const SETOWN_EX = 15; | |
| 1634 | pub const GETOWN_EX = 16; | |
| 1635 | ||
| 1636 | pub const GETOWNER_UIDS = 17; | |
| 1637 | ||
| 1638 | pub const OFD_GETLK = 36; | |
| 1639 | pub const OFD_SETLK = 37; | |
| 1640 | pub const OFD_SETLKW = 38; | |
| 1641 | ||
| 1642 | pub const RDLCK = if (is_sparc) 1 else 0; | |
| 1643 | pub const WRLCK = if (is_sparc) 2 else 1; | |
| 1644 | pub const UNLCK = if (is_sparc) 3 else 2; | |
| 1645 | }; | |
| 1646 | ||
| 1647 | pub const F_OWNER = enum(i32) { | |
| 1648 | TID = 0, | |
| 1649 | PID = 1, | |
| 1650 | PGRP = 2, | |
| 1651 | _, | |
| 1652 | }; | |
| 1653 | ||
| 1654 | pub const f_owner_ex = extern struct { | |
| 1655 | type: F_OWNER, | |
| 1656 | pid: pid_t, | |
| 1657 | }; | |
| 1658 | ||
| 1659 | pub const Flock = extern struct { | |
| 1660 | type: i16, | |
| 1661 | whence: i16, | |
| 1662 | start: off_t, | |
| 1663 | len: off_t, | |
| 1664 | pid: pid_t, | |
| 1665 | _unused: if (is_sparc) i16 else void, | |
| 1666 | }; | |
| 1667 | ||
| 1603 | 1668 | pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) usize { |
| 1604 | 1669 | if (@hasField(SYS, "fcntl64")) { |
| 1605 | 1670 | return syscall3(.fcntl64, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, cmd))), arg); |
| ... | ... | @@ -1612,6 +1677,8 @@ pub fn flock(fd: fd_t, operation: i32) usize { |
| 1612 | 1677 | return syscall2(.flock, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, operation)))); |
| 1613 | 1678 | } |
| 1614 | 1679 | |
| 1680 | pub const Elf_Symndx = if (native_arch == .s390x) u64 else u32; | |
| 1681 | ||
| 1615 | 1682 | // We must follow the C calling convention when we call into the VDSO |
| 1616 | 1683 | const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.c) usize; |
| 1617 | 1684 | var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime; |
| ... | ... | @@ -8361,6 +8428,16 @@ pub const POSIX_FADV = switch (native_arch) { |
| 8361 | 8428 | }, |
| 8362 | 8429 | }; |
| 8363 | 8430 | |
| 8431 | pub const timeval = extern struct { | |
| 8432 | tv_sec: isize, | |
| 8433 | tv_usec: i64, | |
| 8434 | }; | |
| 8435 | ||
| 8436 | pub const timezone = extern struct { | |
| 8437 | minuteswest: i32, | |
| 8438 | dsttime: i32, | |
| 8439 | }; | |
| 8440 | ||
| 8364 | 8441 | /// The timespec struct used by the kernel. |
| 8365 | 8442 | pub const kernel_timespec = extern struct { |
| 8366 | 8443 | sec: i64, |
lib/std/os/linux/aarch64.zig+38-97| ... | ... | @@ -1,46 +1,34 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("../../std.zig"); |
| 3 | const maxInt = std.math.maxInt; | |
| 4 | const linux = std.os.linux; | |
| 5 | const SYS = linux.SYS; | |
| 6 | const socklen_t = linux.socklen_t; | |
| 7 | const sockaddr = linux.sockaddr; | |
| 8 | const iovec = std.posix.iovec; | |
| 9 | const iovec_const = std.posix.iovec_const; | |
| 10 | const uid_t = linux.uid_t; | |
| 11 | const gid_t = linux.gid_t; | |
| 12 | const pid_t = linux.pid_t; | |
| 13 | const stack_t = linux.stack_t; | |
| 14 | const sigset_t = linux.sigset_t; | |
| 15 | const timespec = std.os.linux.timespec; | |
| 16 | ||
| 17 | pub fn syscall0(number: SYS) usize { | |
| 3 | const SYS = std.os.linux.SYS; | |
| 4 | ||
| 5 | pub fn syscall0(number: SYS) u64 { | |
| 18 | 6 | return asm volatile ("svc #0" |
| 19 | : [ret] "={x0}" (-> usize), | |
| 7 | : [ret] "={x0}" (-> u64), | |
| 20 | 8 | : [number] "{x8}" (@intFromEnum(number)), |
| 21 | 9 | : .{ .memory = true }); |
| 22 | 10 | } |
| 23 | 11 | |
| 24 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 12 | pub fn syscall1(number: SYS, arg1: u64) u64 { | |
| 25 | 13 | return asm volatile ("svc #0" |
| 26 | : [ret] "={x0}" (-> usize), | |
| 14 | : [ret] "={x0}" (-> u64), | |
| 27 | 15 | : [number] "{x8}" (@intFromEnum(number)), |
| 28 | 16 | [arg1] "{x0}" (arg1), |
| 29 | 17 | : .{ .memory = true }); |
| 30 | 18 | } |
| 31 | 19 | |
| 32 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 20 | pub fn syscall2(number: SYS, arg1: u64, arg2: u64) u64 { | |
| 33 | 21 | return asm volatile ("svc #0" |
| 34 | : [ret] "={x0}" (-> usize), | |
| 22 | : [ret] "={x0}" (-> u64), | |
| 35 | 23 | : [number] "{x8}" (@intFromEnum(number)), |
| 36 | 24 | [arg1] "{x0}" (arg1), |
| 37 | 25 | [arg2] "{x1}" (arg2), |
| 38 | 26 | : .{ .memory = true }); |
| 39 | 27 | } |
| 40 | 28 | |
| 41 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 29 | pub fn syscall3(number: SYS, arg1: u64, arg2: u64, arg3: u64) u64 { | |
| 42 | 30 | return asm volatile ("svc #0" |
| 43 | : [ret] "={x0}" (-> usize), | |
| 31 | : [ret] "={x0}" (-> u64), | |
| 44 | 32 | : [number] "{x8}" (@intFromEnum(number)), |
| 45 | 33 | [arg1] "{x0}" (arg1), |
| 46 | 34 | [arg2] "{x1}" (arg2), |
| ... | ... | @@ -48,9 +36,9 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 48 | 36 | : .{ .memory = true }); |
| 49 | 37 | } |
| 50 | 38 | |
| 51 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 39 | pub fn syscall4(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64) u64 { | |
| 52 | 40 | return asm volatile ("svc #0" |
| 53 | : [ret] "={x0}" (-> usize), | |
| 41 | : [ret] "={x0}" (-> u64), | |
| 54 | 42 | : [number] "{x8}" (@intFromEnum(number)), |
| 55 | 43 | [arg1] "{x0}" (arg1), |
| 56 | 44 | [arg2] "{x1}" (arg2), |
| ... | ... | @@ -59,9 +47,9 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 59 | 47 | : .{ .memory = true }); |
| 60 | 48 | } |
| 61 | 49 | |
| 62 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 50 | pub fn syscall5(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) u64 { | |
| 63 | 51 | return asm volatile ("svc #0" |
| 64 | : [ret] "={x0}" (-> usize), | |
| 52 | : [ret] "={x0}" (-> u64), | |
| 65 | 53 | : [number] "{x8}" (@intFromEnum(number)), |
| 66 | 54 | [arg1] "{x0}" (arg1), |
| 67 | 55 | [arg2] "{x1}" (arg2), |
| ... | ... | @@ -73,15 +61,15 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 73 | 61 | |
| 74 | 62 | pub fn syscall6( |
| 75 | 63 | number: SYS, |
| 76 | arg1: usize, | |
| 77 | arg2: usize, | |
| 78 | arg3: usize, | |
| 79 | arg4: usize, | |
| 80 | arg5: usize, | |
| 81 | arg6: usize, | |
| 82 | ) usize { | |
| 64 | arg1: u64, | |
| 65 | arg2: u64, | |
| 66 | arg3: u64, | |
| 67 | arg4: u64, | |
| 68 | arg5: u64, | |
| 69 | arg6: u64, | |
| 70 | ) u64 { | |
| 83 | 71 | return asm volatile ("svc #0" |
| 84 | : [ret] "={x0}" (-> usize), | |
| 72 | : [ret] "={x0}" (-> u64), | |
| 85 | 73 | : [number] "{x8}" (@intFromEnum(number)), |
| 86 | 74 | [arg1] "{x0}" (arg1), |
| 87 | 75 | [arg2] "{x1}" (arg2), |
| ... | ... | @@ -92,7 +80,7 @@ pub fn syscall6( |
| 92 | 80 | : .{ .memory = true }); |
| 93 | 81 | } |
| 94 | 82 | |
| 95 | pub fn clone() callconv(.naked) usize { | |
| 83 | pub fn clone() callconv(.naked) u64 { | |
| 96 | 84 | // __clone(func, stack, flags, arg, ptid, tls, ctid) |
| 97 | 85 | // x0, x1, w2, x3, x4, x5, x6 |
| 98 | 86 | // |
| ... | ... | @@ -135,7 +123,7 @@ pub fn clone() callconv(.naked) usize { |
| 135 | 123 | pub const restore = restore_rt; |
| 136 | 124 | |
| 137 | 125 | pub fn restore_rt() callconv(.naked) noreturn { |
| 138 | switch (@import("builtin").zig_backend) { | |
| 126 | switch (builtin.zig_backend) { | |
| 139 | 127 | .stage2_c => asm volatile ( |
| 140 | 128 | \\ mov x8, %[number] |
| 141 | 129 | \\ svc #0 |
| ... | ... | @@ -150,54 +138,19 @@ pub fn restore_rt() callconv(.naked) noreturn { |
| 150 | 138 | } |
| 151 | 139 | } |
| 152 | 140 | |
| 153 | pub const F = struct { | |
| 154 | pub const DUPFD = 0; | |
| 155 | pub const GETFD = 1; | |
| 156 | pub const SETFD = 2; | |
| 157 | pub const GETFL = 3; | |
| 158 | pub const SETFL = 4; | |
| 159 | ||
| 160 | pub const SETOWN = 8; | |
| 161 | pub const GETOWN = 9; | |
| 162 | pub const SETSIG = 10; | |
| 163 | pub const GETSIG = 11; | |
| 164 | ||
| 165 | pub const GETLK = 5; | |
| 166 | pub const SETLK = 6; | |
| 167 | pub const SETLKW = 7; | |
| 168 | ||
| 169 | pub const RDLCK = 0; | |
| 170 | pub const WRLCK = 1; | |
| 171 | pub const UNLCK = 2; | |
| 172 | ||
| 173 | pub const SETOWN_EX = 15; | |
| 174 | pub const GETOWN_EX = 16; | |
| 175 | ||
| 176 | pub const GETOWNER_UIDS = 17; | |
| 177 | }; | |
| 178 | ||
| 179 | 141 | pub const VDSO = struct { |
| 180 | 142 | pub const CGT_SYM = "__kernel_clock_gettime"; |
| 181 | 143 | pub const CGT_VER = "LINUX_2.6.39"; |
| 182 | 144 | }; |
| 183 | 145 | |
| 184 | pub const Flock = extern struct { | |
| 185 | type: i16, | |
| 186 | whence: i16, | |
| 187 | start: off_t, | |
| 188 | len: off_t, | |
| 189 | pid: pid_t, | |
| 190 | __unused: [4]u8, | |
| 191 | }; | |
| 192 | ||
| 193 | 146 | pub const blksize_t = i32; |
| 194 | 147 | pub const nlink_t = u32; |
| 195 | pub const time_t = isize; | |
| 148 | pub const time_t = i64; | |
| 196 | 149 | pub const mode_t = u32; |
| 197 | pub const off_t = isize; | |
| 198 | pub const ino_t = usize; | |
| 199 | pub const dev_t = usize; | |
| 200 | pub const blkcnt_t = isize; | |
| 150 | pub const off_t = i64; | |
| 151 | pub const ino_t = u64; | |
| 152 | pub const dev_t = u64; | |
| 153 | pub const blkcnt_t = i64; | |
| 201 | 154 | |
| 202 | 155 | // The `stat` definition used by the Linux kernel. |
| 203 | 156 | pub const Stat = extern struct { |
| ... | ... | @@ -205,40 +158,28 @@ pub const Stat = extern struct { |
| 205 | 158 | ino: ino_t, |
| 206 | 159 | mode: mode_t, |
| 207 | 160 | nlink: nlink_t, |
| 208 | uid: uid_t, | |
| 209 | gid: gid_t, | |
| 161 | uid: std.os.linux.uid_t, | |
| 162 | gid: std.os.linux.gid_t, | |
| 210 | 163 | rdev: dev_t, |
| 211 | __pad: usize, | |
| 164 | __pad: u64, | |
| 212 | 165 | size: off_t, |
| 213 | 166 | blksize: blksize_t, |
| 214 | 167 | __pad2: i32, |
| 215 | 168 | blocks: blkcnt_t, |
| 216 | atim: timespec, | |
| 217 | mtim: timespec, | |
| 218 | ctim: timespec, | |
| 169 | atim: std.os.linux.timespec, | |
| 170 | mtim: std.os.linux.timespec, | |
| 171 | ctim: std.os.linux.timespec, | |
| 219 | 172 | __unused: [2]u32, |
| 220 | 173 | |
| 221 | pub fn atime(self: @This()) timespec { | |
| 174 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 222 | 175 | return self.atim; |
| 223 | 176 | } |
| 224 | 177 | |
| 225 | pub fn mtime(self: @This()) timespec { | |
| 178 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 226 | 179 | return self.mtim; |
| 227 | 180 | } |
| 228 | 181 | |
| 229 | pub fn ctime(self: @This()) timespec { | |
| 182 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 230 | 183 | return self.ctim; |
| 231 | 184 | } |
| 232 | 185 | }; |
| 233 | ||
| 234 | pub const timeval = extern struct { | |
| 235 | sec: isize, | |
| 236 | usec: isize, | |
| 237 | }; | |
| 238 | ||
| 239 | pub const timezone = extern struct { | |
| 240 | minuteswest: i32, | |
| 241 | dsttime: i32, | |
| 242 | }; | |
| 243 | ||
| 244 | pub const Elf_Symndx = u32; |
lib/std/os/linux/arm.zig+36-95| ... | ... | @@ -1,45 +1,34 @@ |
| 1 | const builtin = @import("builtin"); | |
| 1 | 2 | const std = @import("../../std.zig"); |
| 2 | const maxInt = std.math.maxInt; | |
| 3 | const linux = std.os.linux; | |
| 4 | const SYS = linux.SYS; | |
| 5 | const iovec = std.posix.iovec; | |
| 6 | const iovec_const = std.posix.iovec_const; | |
| 7 | const socklen_t = linux.socklen_t; | |
| 8 | const stack_t = linux.stack_t; | |
| 9 | const sigset_t = linux.sigset_t; | |
| 10 | const uid_t = linux.uid_t; | |
| 11 | const gid_t = linux.gid_t; | |
| 12 | const pid_t = linux.pid_t; | |
| 13 | const sockaddr = linux.sockaddr; | |
| 14 | const timespec = linux.timespec; | |
| 3 | const SYS = std.os.linux.SYS; | |
| 15 | 4 | |
| 16 | pub fn syscall0(number: SYS) usize { | |
| 5 | pub fn syscall0(number: SYS) u32 { | |
| 17 | 6 | return asm volatile ("svc #0" |
| 18 | : [ret] "={r0}" (-> usize), | |
| 7 | : [ret] "={r0}" (-> u32), | |
| 19 | 8 | : [number] "{r7}" (@intFromEnum(number)), |
| 20 | 9 | : .{ .memory = true }); |
| 21 | 10 | } |
| 22 | 11 | |
| 23 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 12 | pub fn syscall1(number: SYS, arg1: u32) u32 { | |
| 24 | 13 | return asm volatile ("svc #0" |
| 25 | : [ret] "={r0}" (-> usize), | |
| 14 | : [ret] "={r0}" (-> u32), | |
| 26 | 15 | : [number] "{r7}" (@intFromEnum(number)), |
| 27 | 16 | [arg1] "{r0}" (arg1), |
| 28 | 17 | : .{ .memory = true }); |
| 29 | 18 | } |
| 30 | 19 | |
| 31 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 20 | pub fn syscall2(number: SYS, arg1: u32, arg2: u32) u32 { | |
| 32 | 21 | return asm volatile ("svc #0" |
| 33 | : [ret] "={r0}" (-> usize), | |
| 22 | : [ret] "={r0}" (-> u32), | |
| 34 | 23 | : [number] "{r7}" (@intFromEnum(number)), |
| 35 | 24 | [arg1] "{r0}" (arg1), |
| 36 | 25 | [arg2] "{r1}" (arg2), |
| 37 | 26 | : .{ .memory = true }); |
| 38 | 27 | } |
| 39 | 28 | |
| 40 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 29 | pub fn syscall3(number: SYS, arg1: u32, arg2: u32, arg3: u32) u32 { | |
| 41 | 30 | return asm volatile ("svc #0" |
| 42 | : [ret] "={r0}" (-> usize), | |
| 31 | : [ret] "={r0}" (-> u32), | |
| 43 | 32 | : [number] "{r7}" (@intFromEnum(number)), |
| 44 | 33 | [arg1] "{r0}" (arg1), |
| 45 | 34 | [arg2] "{r1}" (arg2), |
| ... | ... | @@ -47,9 +36,9 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 47 | 36 | : .{ .memory = true }); |
| 48 | 37 | } |
| 49 | 38 | |
| 50 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 39 | pub fn syscall4(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32) u32 { | |
| 51 | 40 | return asm volatile ("svc #0" |
| 52 | : [ret] "={r0}" (-> usize), | |
| 41 | : [ret] "={r0}" (-> u32), | |
| 53 | 42 | : [number] "{r7}" (@intFromEnum(number)), |
| 54 | 43 | [arg1] "{r0}" (arg1), |
| 55 | 44 | [arg2] "{r1}" (arg2), |
| ... | ... | @@ -58,9 +47,9 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 58 | 47 | : .{ .memory = true }); |
| 59 | 48 | } |
| 60 | 49 | |
| 61 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 50 | pub fn syscall5(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32, arg5: u32) u32 { | |
| 62 | 51 | return asm volatile ("svc #0" |
| 63 | : [ret] "={r0}" (-> usize), | |
| 52 | : [ret] "={r0}" (-> u32), | |
| 64 | 53 | : [number] "{r7}" (@intFromEnum(number)), |
| 65 | 54 | [arg1] "{r0}" (arg1), |
| 66 | 55 | [arg2] "{r1}" (arg2), |
| ... | ... | @@ -72,15 +61,15 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 72 | 61 | |
| 73 | 62 | pub fn syscall6( |
| 74 | 63 | number: SYS, |
| 75 | arg1: usize, | |
| 76 | arg2: usize, | |
| 77 | arg3: usize, | |
| 78 | arg4: usize, | |
| 79 | arg5: usize, | |
| 80 | arg6: usize, | |
| 81 | ) usize { | |
| 64 | arg1: u32, | |
| 65 | arg2: u32, | |
| 66 | arg3: u32, | |
| 67 | arg4: u32, | |
| 68 | arg5: u32, | |
| 69 | arg6: u32, | |
| 70 | ) u32 { | |
| 82 | 71 | return asm volatile ("svc #0" |
| 83 | : [ret] "={r0}" (-> usize), | |
| 72 | : [ret] "={r0}" (-> u32), | |
| 84 | 73 | : [number] "{r7}" (@intFromEnum(number)), |
| 85 | 74 | [arg1] "{r0}" (arg1), |
| 86 | 75 | [arg2] "{r1}" (arg2), |
| ... | ... | @@ -91,7 +80,7 @@ pub fn syscall6( |
| 91 | 80 | : .{ .memory = true }); |
| 92 | 81 | } |
| 93 | 82 | |
| 94 | pub fn clone() callconv(.naked) usize { | |
| 83 | pub fn clone() callconv(.naked) u32 { | |
| 95 | 84 | // __clone(func, stack, flags, arg, ptid, tls, ctid) |
| 96 | 85 | // r0, r1, r2, r3, +0, +4, +8 |
| 97 | 86 | // |
| ... | ... | @@ -128,23 +117,23 @@ pub fn clone() callconv(.naked) usize { |
| 128 | 117 | } |
| 129 | 118 | |
| 130 | 119 | pub fn restore() callconv(.naked) noreturn { |
| 131 | switch (@import("builtin").zig_backend) { | |
| 120 | switch (builtin.zig_backend) { | |
| 132 | 121 | .stage2_c => asm volatile ( |
| 133 | 122 | \\ mov r7, %[number] |
| 134 | 123 | \\ svc #0 |
| 135 | 124 | : |
| 136 | 125 | : [number] "I" (@intFromEnum(SYS.sigreturn)), |
| 137 | : .{ .memory = true }), | |
| 126 | ), | |
| 138 | 127 | else => asm volatile ( |
| 139 | 128 | \\ svc #0 |
| 140 | 129 | : |
| 141 | 130 | : [number] "{r7}" (@intFromEnum(SYS.sigreturn)), |
| 142 | : .{ .memory = true }), | |
| 131 | ), | |
| 143 | 132 | } |
| 144 | 133 | } |
| 145 | 134 | |
| 146 | 135 | pub fn restore_rt() callconv(.naked) noreturn { |
| 147 | switch (@import("builtin").zig_backend) { | |
| 136 | switch (builtin.zig_backend) { | |
| 148 | 137 | .stage2_c => asm volatile ( |
| 149 | 138 | \\ mov r7, %[number] |
| 150 | 139 | \\ svc #0 |
| ... | ... | @@ -159,32 +148,6 @@ pub fn restore_rt() callconv(.naked) noreturn { |
| 159 | 148 | } |
| 160 | 149 | } |
| 161 | 150 | |
| 162 | pub const F = struct { | |
| 163 | pub const DUPFD = 0; | |
| 164 | pub const GETFD = 1; | |
| 165 | pub const SETFD = 2; | |
| 166 | pub const GETFL = 3; | |
| 167 | pub const SETFL = 4; | |
| 168 | ||
| 169 | pub const SETOWN = 8; | |
| 170 | pub const GETOWN = 9; | |
| 171 | pub const SETSIG = 10; | |
| 172 | pub const GETSIG = 11; | |
| 173 | ||
| 174 | pub const GETLK = 12; | |
| 175 | pub const SETLK = 13; | |
| 176 | pub const SETLKW = 14; | |
| 177 | ||
| 178 | pub const RDLCK = 0; | |
| 179 | pub const WRLCK = 1; | |
| 180 | pub const UNLCK = 2; | |
| 181 | ||
| 182 | pub const SETOWN_EX = 15; | |
| 183 | pub const GETOWN_EX = 16; | |
| 184 | ||
| 185 | pub const GETOWNER_UIDS = 17; | |
| 186 | }; | |
| 187 | ||
| 188 | 151 | pub const VDSO = struct { |
| 189 | 152 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 190 | 153 | pub const CGT_VER = "LINUX_2.6"; |
| ... | ... | @@ -216,19 +179,9 @@ pub const HWCAP = struct { |
| 216 | 179 | pub const EVTSTRM = 1 << 21; |
| 217 | 180 | }; |
| 218 | 181 | |
| 219 | pub const Flock = extern struct { | |
| 220 | type: i16, | |
| 221 | whence: i16, | |
| 222 | __pad0: [4]u8, | |
| 223 | start: off_t, | |
| 224 | len: off_t, | |
| 225 | pid: pid_t, | |
| 226 | __unused: [4]u8, | |
| 227 | }; | |
| 228 | ||
| 229 | 182 | pub const blksize_t = i32; |
| 230 | 183 | pub const nlink_t = u32; |
| 231 | pub const time_t = isize; | |
| 184 | pub const time_t = i32; | |
| 232 | 185 | pub const mode_t = u32; |
| 233 | 186 | pub const off_t = i64; |
| 234 | 187 | pub const ino_t = u64; |
| ... | ... | @@ -242,39 +195,27 @@ pub const Stat = extern struct { |
| 242 | 195 | __ino_truncated: u32, |
| 243 | 196 | mode: mode_t, |
| 244 | 197 | nlink: nlink_t, |
| 245 | uid: uid_t, | |
| 246 | gid: gid_t, | |
| 198 | uid: std.os.linux.uid_t, | |
| 199 | gid: std.os.linux.gid_t, | |
| 247 | 200 | rdev: dev_t, |
| 248 | 201 | __rdev_padding: u32, |
| 249 | 202 | size: off_t, |
| 250 | 203 | blksize: blksize_t, |
| 251 | 204 | blocks: blkcnt_t, |
| 252 | atim: timespec, | |
| 253 | mtim: timespec, | |
| 254 | ctim: timespec, | |
| 205 | atim: std.os.linux.timespec, | |
| 206 | mtim: std.os.linux.timespec, | |
| 207 | ctim: std.os.linux.timespec, | |
| 255 | 208 | ino: ino_t, |
| 256 | 209 | |
| 257 | pub fn atime(self: @This()) timespec { | |
| 210 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 258 | 211 | return self.atim; |
| 259 | 212 | } |
| 260 | 213 | |
| 261 | pub fn mtime(self: @This()) timespec { | |
| 214 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 262 | 215 | return self.mtim; |
| 263 | 216 | } |
| 264 | 217 | |
| 265 | pub fn ctime(self: @This()) timespec { | |
| 218 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 266 | 219 | return self.ctim; |
| 267 | 220 | } |
| 268 | 221 | }; |
| 269 | ||
| 270 | pub const timeval = extern struct { | |
| 271 | sec: i32, | |
| 272 | usec: i32, | |
| 273 | }; | |
| 274 | ||
| 275 | pub const timezone = extern struct { | |
| 276 | minuteswest: i32, | |
| 277 | dsttime: i32, | |
| 278 | }; | |
| 279 | ||
| 280 | pub const Elf_Symndx = u32; |
lib/std/os/linux/hexagon.zig+30-81| ... | ... | @@ -1,45 +1,34 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("../../std.zig"); |
| 3 | const iovec = std.posix.iovec; | |
| 4 | const iovec_const = std.posix.iovec_const; | |
| 5 | const linux = std.os.linux; | |
| 6 | const SYS = linux.SYS; | |
| 7 | const uid_t = std.os.linux.uid_t; | |
| 8 | const gid_t = std.os.linux.gid_t; | |
| 9 | const pid_t = std.os.linux.pid_t; | |
| 10 | const sockaddr = linux.sockaddr; | |
| 11 | const socklen_t = linux.socklen_t; | |
| 12 | const stack_t = linux.stack_t; | |
| 13 | const sigset_t = linux.sigset_t; | |
| 14 | const timespec = std.os.linux.timespec; | |
| 3 | const SYS = std.os.linux.SYS; | |
| 15 | 4 | |
| 16 | pub fn syscall0(number: SYS) usize { | |
| 5 | pub fn syscall0(number: SYS) u32 { | |
| 17 | 6 | return asm volatile ("trap0(#1)" |
| 18 | : [ret] "={r0}" (-> usize), | |
| 7 | : [ret] "={r0}" (-> u32), | |
| 19 | 8 | : [number] "{r6}" (@intFromEnum(number)), |
| 20 | 9 | : .{ .memory = true }); |
| 21 | 10 | } |
| 22 | 11 | |
| 23 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 12 | pub fn syscall1(number: SYS, arg1: u32) u32 { | |
| 24 | 13 | return asm volatile ("trap0(#1)" |
| 25 | : [ret] "={r0}" (-> usize), | |
| 14 | : [ret] "={r0}" (-> u32), | |
| 26 | 15 | : [number] "{r6}" (@intFromEnum(number)), |
| 27 | 16 | [arg1] "{r0}" (arg1), |
| 28 | 17 | : .{ .memory = true }); |
| 29 | 18 | } |
| 30 | 19 | |
| 31 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 20 | pub fn syscall2(number: SYS, arg1: u32, arg2: u32) u32 { | |
| 32 | 21 | return asm volatile ("trap0(#1)" |
| 33 | : [ret] "={r0}" (-> usize), | |
| 22 | : [ret] "={r0}" (-> u32), | |
| 34 | 23 | : [number] "{r6}" (@intFromEnum(number)), |
| 35 | 24 | [arg1] "{r0}" (arg1), |
| 36 | 25 | [arg2] "{r1}" (arg2), |
| 37 | 26 | : .{ .memory = true }); |
| 38 | 27 | } |
| 39 | 28 | |
| 40 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 29 | pub fn syscall3(number: SYS, arg1: u32, arg2: u32, arg3: u32) u32 { | |
| 41 | 30 | return asm volatile ("trap0(#1)" |
| 42 | : [ret] "={r0}" (-> usize), | |
| 31 | : [ret] "={r0}" (-> u32), | |
| 43 | 32 | : [number] "{r6}" (@intFromEnum(number)), |
| 44 | 33 | [arg1] "{r0}" (arg1), |
| 45 | 34 | [arg2] "{r1}" (arg2), |
| ... | ... | @@ -47,9 +36,9 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 47 | 36 | : .{ .memory = true }); |
| 48 | 37 | } |
| 49 | 38 | |
| 50 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 39 | pub fn syscall4(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32) u32 { | |
| 51 | 40 | return asm volatile ("trap0(#1)" |
| 52 | : [ret] "={r0}" (-> usize), | |
| 41 | : [ret] "={r0}" (-> u32), | |
| 53 | 42 | : [number] "{r6}" (@intFromEnum(number)), |
| 54 | 43 | [arg1] "{r0}" (arg1), |
| 55 | 44 | [arg2] "{r1}" (arg2), |
| ... | ... | @@ -58,9 +47,9 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 58 | 47 | : .{ .memory = true }); |
| 59 | 48 | } |
| 60 | 49 | |
| 61 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 50 | pub fn syscall5(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32, arg5: u32) u32 { | |
| 62 | 51 | return asm volatile ("trap0(#1)" |
| 63 | : [ret] "={r0}" (-> usize), | |
| 52 | : [ret] "={r0}" (-> u32), | |
| 64 | 53 | : [number] "{r6}" (@intFromEnum(number)), |
| 65 | 54 | [arg1] "{r0}" (arg1), |
| 66 | 55 | [arg2] "{r1}" (arg2), |
| ... | ... | @@ -72,15 +61,15 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 72 | 61 | |
| 73 | 62 | pub fn syscall6( |
| 74 | 63 | number: SYS, |
| 75 | arg1: usize, | |
| 76 | arg2: usize, | |
| 77 | arg3: usize, | |
| 78 | arg4: usize, | |
| 79 | arg5: usize, | |
| 80 | arg6: usize, | |
| 81 | ) usize { | |
| 64 | arg1: u32, | |
| 65 | arg2: u32, | |
| 66 | arg3: u32, | |
| 67 | arg4: u32, | |
| 68 | arg5: u32, | |
| 69 | arg6: u32, | |
| 70 | ) u32 { | |
| 82 | 71 | return asm volatile ("trap0(#1)" |
| 83 | : [ret] "={r0}" (-> usize), | |
| 72 | : [ret] "={r0}" (-> u32), | |
| 84 | 73 | : [number] "{r6}" (@intFromEnum(number)), |
| 85 | 74 | [arg1] "{r0}" (arg1), |
| 86 | 75 | [arg2] "{r1}" (arg2), |
| ... | ... | @@ -91,7 +80,7 @@ pub fn syscall6( |
| 91 | 80 | : .{ .memory = true }); |
| 92 | 81 | } |
| 93 | 82 | |
| 94 | pub fn clone() callconv(.naked) usize { | |
| 83 | pub fn clone() callconv(.naked) u32 { | |
| 95 | 84 | // __clone(func, stack, flags, arg, ptid, tls, ctid) |
| 96 | 85 | // r0, r1, r2, r3, r4, r5, +0 |
| 97 | 86 | // |
| ... | ... | @@ -130,44 +119,6 @@ pub fn clone() callconv(.naked) usize { |
| 130 | 119 | ); |
| 131 | 120 | } |
| 132 | 121 | |
| 133 | pub const F = struct { | |
| 134 | pub const DUPFD = 0; | |
| 135 | pub const GETFD = 1; | |
| 136 | pub const SETFD = 2; | |
| 137 | pub const GETFL = 3; | |
| 138 | pub const SETFL = 4; | |
| 139 | pub const GETLK = 5; | |
| 140 | pub const SETLK = 6; | |
| 141 | pub const SETLKW = 7; | |
| 142 | pub const SETOWN = 8; | |
| 143 | pub const GETOWN = 9; | |
| 144 | pub const SETSIG = 10; | |
| 145 | pub const GETSIG = 11; | |
| 146 | ||
| 147 | pub const RDLCK = 0; | |
| 148 | pub const WRLCK = 1; | |
| 149 | pub const UNLCK = 2; | |
| 150 | ||
| 151 | pub const SETOWN_EX = 15; | |
| 152 | pub const GETOWN_EX = 16; | |
| 153 | ||
| 154 | pub const GETOWNER_UIDS = 17; | |
| 155 | }; | |
| 156 | ||
| 157 | pub const timeval = extern struct { | |
| 158 | sec: time_t, | |
| 159 | usec: i32, | |
| 160 | }; | |
| 161 | ||
| 162 | pub const Flock = extern struct { | |
| 163 | type: i16, | |
| 164 | whence: i16, | |
| 165 | start: off_t, | |
| 166 | len: off_t, | |
| 167 | pid: pid_t, | |
| 168 | __unused: [4]u8, | |
| 169 | }; | |
| 170 | ||
| 171 | 122 | pub const blksize_t = i32; |
| 172 | 123 | pub const nlink_t = u32; |
| 173 | 124 | pub const time_t = i64; |
| ... | ... | @@ -183,32 +134,30 @@ pub const Stat = extern struct { |
| 183 | 134 | ino: ino_t, |
| 184 | 135 | mode: mode_t, |
| 185 | 136 | nlink: nlink_t, |
| 186 | uid: uid_t, | |
| 187 | gid: gid_t, | |
| 137 | uid: std.os.linux.uid_t, | |
| 138 | gid: std.os.linux.gid_t, | |
| 188 | 139 | rdev: dev_t, |
| 189 | 140 | __pad: u32, |
| 190 | 141 | size: off_t, |
| 191 | 142 | blksize: blksize_t, |
| 192 | 143 | __pad2: i32, |
| 193 | 144 | blocks: blkcnt_t, |
| 194 | atim: timespec, | |
| 195 | mtim: timespec, | |
| 196 | ctim: timespec, | |
| 145 | atim: std.os.linux.timespec, | |
| 146 | mtim: std.os.linux.timespec, | |
| 147 | ctim: std.os.linux.timespec, | |
| 197 | 148 | __unused: [2]u32, |
| 198 | 149 | |
| 199 | pub fn atime(self: @This()) timespec { | |
| 150 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 200 | 151 | return self.atim; |
| 201 | 152 | } |
| 202 | 153 | |
| 203 | pub fn mtime(self: @This()) timespec { | |
| 154 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 204 | 155 | return self.mtim; |
| 205 | 156 | } |
| 206 | 157 | |
| 207 | pub fn ctime(self: @This()) timespec { | |
| 158 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 208 | 159 | return self.ctim; |
| 209 | 160 | } |
| 210 | 161 | }; |
| 211 | 162 | |
| 212 | pub const Elf_Symndx = u32; | |
| 213 | ||
| 214 | 163 | pub const VDSO = void; |
lib/std/os/linux/loongarch64.zig+30-71| ... | ... | @@ -1,48 +1,38 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("../../std.zig"); |
| 3 | const linux = std.os.linux; | |
| 4 | const SYS = linux.SYS; | |
| 5 | const iovec = std.posix.iovec; | |
| 6 | const iovec_const = std.posix.iovec_const; | |
| 7 | const uid_t = linux.uid_t; | |
| 8 | const gid_t = linux.gid_t; | |
| 9 | const stack_t = linux.stack_t; | |
| 10 | const sigset_t = linux.sigset_t; | |
| 11 | const sockaddr = linux.sockaddr; | |
| 12 | const socklen_t = linux.socklen_t; | |
| 13 | const timespec = linux.timespec; | |
| 3 | const SYS = std.os.linux.SYS; | |
| 14 | 4 | |
| 15 | pub fn syscall0(number: SYS) usize { | |
| 5 | pub fn syscall0(number: SYS) u64 { | |
| 16 | 6 | return asm volatile ( |
| 17 | 7 | \\ syscall 0 |
| 18 | : [ret] "={$r4}" (-> usize), | |
| 8 | : [ret] "={$r4}" (-> u64), | |
| 19 | 9 | : [number] "{$r11}" (@intFromEnum(number)), |
| 20 | 10 | : .{ .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r16 = true, .r17 = true, .r18 = true, .r19 = true, .r20 = true, .memory = true }); |
| 21 | 11 | } |
| 22 | 12 | |
| 23 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 13 | pub fn syscall1(number: SYS, arg1: u64) u64 { | |
| 24 | 14 | return asm volatile ( |
| 25 | 15 | \\ syscall 0 |
| 26 | : [ret] "={$r4}" (-> usize), | |
| 16 | : [ret] "={$r4}" (-> u64), | |
| 27 | 17 | : [number] "{$r11}" (@intFromEnum(number)), |
| 28 | 18 | [arg1] "{$r4}" (arg1), |
| 29 | 19 | : .{ .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r16 = true, .r17 = true, .r18 = true, .r19 = true, .r20 = true, .memory = true }); |
| 30 | 20 | } |
| 31 | 21 | |
| 32 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 22 | pub fn syscall2(number: SYS, arg1: u64, arg2: u64) u64 { | |
| 33 | 23 | return asm volatile ( |
| 34 | 24 | \\ syscall 0 |
| 35 | : [ret] "={$r4}" (-> usize), | |
| 25 | : [ret] "={$r4}" (-> u64), | |
| 36 | 26 | : [number] "{$r11}" (@intFromEnum(number)), |
| 37 | 27 | [arg1] "{$r4}" (arg1), |
| 38 | 28 | [arg2] "{$r5}" (arg2), |
| 39 | 29 | : .{ .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r16 = true, .r17 = true, .r18 = true, .r19 = true, .r20 = true, .memory = true }); |
| 40 | 30 | } |
| 41 | 31 | |
| 42 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 32 | pub fn syscall3(number: SYS, arg1: u64, arg2: u64, arg3: u64) u64 { | |
| 43 | 33 | return asm volatile ( |
| 44 | 34 | \\ syscall 0 |
| 45 | : [ret] "={$r4}" (-> usize), | |
| 35 | : [ret] "={$r4}" (-> u64), | |
| 46 | 36 | : [number] "{$r11}" (@intFromEnum(number)), |
| 47 | 37 | [arg1] "{$r4}" (arg1), |
| 48 | 38 | [arg2] "{$r5}" (arg2), |
| ... | ... | @@ -50,10 +40,10 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 50 | 40 | : .{ .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r16 = true, .r17 = true, .r18 = true, .r19 = true, .r20 = true, .memory = true }); |
| 51 | 41 | } |
| 52 | 42 | |
| 53 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 43 | pub fn syscall4(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64) u64 { | |
| 54 | 44 | return asm volatile ( |
| 55 | 45 | \\ syscall 0 |
| 56 | : [ret] "={$r4}" (-> usize), | |
| 46 | : [ret] "={$r4}" (-> u64), | |
| 57 | 47 | : [number] "{$r11}" (@intFromEnum(number)), |
| 58 | 48 | [arg1] "{$r4}" (arg1), |
| 59 | 49 | [arg2] "{$r5}" (arg2), |
| ... | ... | @@ -62,10 +52,10 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 62 | 52 | : .{ .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r16 = true, .r17 = true, .r18 = true, .r19 = true, .r20 = true, .memory = true }); |
| 63 | 53 | } |
| 64 | 54 | |
| 65 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 55 | pub fn syscall5(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) u64 { | |
| 66 | 56 | return asm volatile ( |
| 67 | 57 | \\ syscall 0 |
| 68 | : [ret] "={$r4}" (-> usize), | |
| 58 | : [ret] "={$r4}" (-> u64), | |
| 69 | 59 | : [number] "{$r11}" (@intFromEnum(number)), |
| 70 | 60 | [arg1] "{$r4}" (arg1), |
| 71 | 61 | [arg2] "{$r5}" (arg2), |
| ... | ... | @@ -77,16 +67,16 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 77 | 67 | |
| 78 | 68 | pub fn syscall6( |
| 79 | 69 | number: SYS, |
| 80 | arg1: usize, | |
| 81 | arg2: usize, | |
| 82 | arg3: usize, | |
| 83 | arg4: usize, | |
| 84 | arg5: usize, | |
| 85 | arg6: usize, | |
| 86 | ) usize { | |
| 70 | arg1: u64, | |
| 71 | arg2: u64, | |
| 72 | arg3: u64, | |
| 73 | arg4: u64, | |
| 74 | arg5: u64, | |
| 75 | arg6: u64, | |
| 76 | ) u64 { | |
| 87 | 77 | return asm volatile ( |
| 88 | 78 | \\ syscall 0 |
| 89 | : [ret] "={$r4}" (-> usize), | |
| 79 | : [ret] "={$r4}" (-> u64), | |
| 90 | 80 | : [number] "{$r11}" (@intFromEnum(number)), |
| 91 | 81 | [arg1] "{$r4}" (arg1), |
| 92 | 82 | [arg2] "{$r5}" (arg2), |
| ... | ... | @@ -97,7 +87,7 @@ pub fn syscall6( |
| 97 | 87 | : .{ .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r16 = true, .r17 = true, .r18 = true, .r19 = true, .r20 = true, .memory = true }); |
| 98 | 88 | } |
| 99 | 89 | |
| 100 | pub fn clone() callconv(.naked) usize { | |
| 90 | pub fn clone() callconv(.naked) u64 { | |
| 101 | 91 | // __clone(func, stack, flags, arg, ptid, tls, ctid) |
| 102 | 92 | // a0, a1, a2, a3, a4, a5, a6 |
| 103 | 93 | // sys_clone(flags, stack, ptid, ctid, tls) |
| ... | ... | @@ -150,64 +140,33 @@ pub const Stat = extern struct { |
| 150 | 140 | ino: ino_t, |
| 151 | 141 | mode: mode_t, |
| 152 | 142 | nlink: nlink_t, |
| 153 | uid: uid_t, | |
| 154 | gid: gid_t, | |
| 143 | uid: std.os.linux.uid_t, | |
| 144 | gid: std.os.linux.gid_t, | |
| 155 | 145 | rdev: dev_t, |
| 156 | 146 | _pad1: u64, |
| 157 | 147 | size: off_t, |
| 158 | 148 | blksize: blksize_t, |
| 159 | 149 | _pad2: i32, |
| 160 | 150 | blocks: blkcnt_t, |
| 161 | atim: timespec, | |
| 162 | mtim: timespec, | |
| 163 | ctim: timespec, | |
| 151 | atim: std.os.linux.timespec, | |
| 152 | mtim: std.os.linux.timespec, | |
| 153 | ctim: std.os.linux.timespec, | |
| 164 | 154 | _pad3: [2]u32, |
| 165 | 155 | |
| 166 | pub fn atime(self: @This()) timespec { | |
| 156 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 167 | 157 | return self.atim; |
| 168 | 158 | } |
| 169 | 159 | |
| 170 | pub fn mtime(self: @This()) timespec { | |
| 160 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 171 | 161 | return self.mtim; |
| 172 | 162 | } |
| 173 | 163 | |
| 174 | pub fn ctime(self: @This()) timespec { | |
| 164 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 175 | 165 | return self.ctim; |
| 176 | 166 | } |
| 177 | 167 | }; |
| 178 | 168 | |
| 179 | pub const timeval = extern struct { | |
| 180 | tv_sec: time_t, | |
| 181 | tv_usec: i64, | |
| 182 | }; | |
| 183 | ||
| 184 | pub const F = struct { | |
| 185 | pub const DUPFD = 0; | |
| 186 | pub const GETFD = 1; | |
| 187 | pub const SETFD = 2; | |
| 188 | pub const GETFL = 3; | |
| 189 | pub const SETFL = 4; | |
| 190 | pub const GETLK = 5; | |
| 191 | pub const SETLK = 6; | |
| 192 | pub const SETLKW = 7; | |
| 193 | pub const SETOWN = 8; | |
| 194 | pub const GETOWN = 9; | |
| 195 | pub const SETSIG = 10; | |
| 196 | pub const GETSIG = 11; | |
| 197 | ||
| 198 | pub const RDLCK = 0; | |
| 199 | pub const WRLCK = 1; | |
| 200 | pub const UNLCK = 2; | |
| 201 | ||
| 202 | pub const SETOWN_EX = 15; | |
| 203 | pub const GETOWN_EX = 16; | |
| 204 | ||
| 205 | pub const GETOWNER_UIDS = 17; | |
| 206 | }; | |
| 207 | ||
| 208 | 169 | pub const VDSO = struct { |
| 209 | 170 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 210 | 171 | pub const CGT_VER = "LINUX_5.10"; |
| 211 | 172 | }; |
| 212 | ||
| 213 | pub const Elf_Symndx = u32; |
lib/std/os/linux/m68k.zig+31-81| ... | ... | @@ -1,43 +1,34 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("../../std.zig"); |
| 3 | const iovec = std.posix.iovec; | |
| 4 | const iovec_const = std.posix.iovec_const; | |
| 5 | const linux = std.os.linux; | |
| 6 | const SYS = linux.SYS; | |
| 7 | const uid_t = std.os.linux.uid_t; | |
| 8 | const gid_t = std.os.linux.uid_t; | |
| 9 | const pid_t = std.os.linux.pid_t; | |
| 10 | const sockaddr = linux.sockaddr; | |
| 11 | const socklen_t = linux.socklen_t; | |
| 12 | const timespec = std.os.linux.timespec; | |
| 13 | ||
| 14 | pub fn syscall0(number: SYS) usize { | |
| 3 | const SYS = std.os.linux.SYS; | |
| 4 | ||
| 5 | pub fn syscall0(number: SYS) u32 { | |
| 15 | 6 | return asm volatile ("trap #0" |
| 16 | : [ret] "={d0}" (-> usize), | |
| 7 | : [ret] "={d0}" (-> u32), | |
| 17 | 8 | : [number] "{d0}" (@intFromEnum(number)), |
| 18 | 9 | : .{ .memory = true }); |
| 19 | 10 | } |
| 20 | 11 | |
| 21 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 12 | pub fn syscall1(number: SYS, arg1: u32) u32 { | |
| 22 | 13 | return asm volatile ("trap #0" |
| 23 | : [ret] "={d0}" (-> usize), | |
| 14 | : [ret] "={d0}" (-> u32), | |
| 24 | 15 | : [number] "{d0}" (@intFromEnum(number)), |
| 25 | 16 | [arg1] "{d1}" (arg1), |
| 26 | 17 | : .{ .memory = true }); |
| 27 | 18 | } |
| 28 | 19 | |
| 29 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 20 | pub fn syscall2(number: SYS, arg1: u32, arg2: u32) u32 { | |
| 30 | 21 | return asm volatile ("trap #0" |
| 31 | : [ret] "={d0}" (-> usize), | |
| 22 | : [ret] "={d0}" (-> u32), | |
| 32 | 23 | : [number] "{d0}" (@intFromEnum(number)), |
| 33 | 24 | [arg1] "{d1}" (arg1), |
| 34 | 25 | [arg2] "{d2}" (arg2), |
| 35 | 26 | : .{ .memory = true }); |
| 36 | 27 | } |
| 37 | 28 | |
| 38 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 29 | pub fn syscall3(number: SYS, arg1: u32, arg2: u32, arg3: u32) u32 { | |
| 39 | 30 | return asm volatile ("trap #0" |
| 40 | : [ret] "={d0}" (-> usize), | |
| 31 | : [ret] "={d0}" (-> u32), | |
| 41 | 32 | : [number] "{d0}" (@intFromEnum(number)), |
| 42 | 33 | [arg1] "{d1}" (arg1), |
| 43 | 34 | [arg2] "{d2}" (arg2), |
| ... | ... | @@ -45,9 +36,9 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 45 | 36 | : .{ .memory = true }); |
| 46 | 37 | } |
| 47 | 38 | |
| 48 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 39 | pub fn syscall4(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32) u32 { | |
| 49 | 40 | return asm volatile ("trap #0" |
| 50 | : [ret] "={d0}" (-> usize), | |
| 41 | : [ret] "={d0}" (-> u32), | |
| 51 | 42 | : [number] "{d0}" (@intFromEnum(number)), |
| 52 | 43 | [arg1] "{d1}" (arg1), |
| 53 | 44 | [arg2] "{d2}" (arg2), |
| ... | ... | @@ -56,9 +47,9 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 56 | 47 | : .{ .memory = true }); |
| 57 | 48 | } |
| 58 | 49 | |
| 59 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 50 | pub fn syscall5(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32, arg5: u32) u32 { | |
| 60 | 51 | return asm volatile ("trap #0" |
| 61 | : [ret] "={d0}" (-> usize), | |
| 52 | : [ret] "={d0}" (-> u32), | |
| 62 | 53 | : [number] "{d0}" (@intFromEnum(number)), |
| 63 | 54 | [arg1] "{d1}" (arg1), |
| 64 | 55 | [arg2] "{d2}" (arg2), |
| ... | ... | @@ -70,15 +61,15 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 70 | 61 | |
| 71 | 62 | pub fn syscall6( |
| 72 | 63 | number: SYS, |
| 73 | arg1: usize, | |
| 74 | arg2: usize, | |
| 75 | arg3: usize, | |
| 76 | arg4: usize, | |
| 77 | arg5: usize, | |
| 78 | arg6: usize, | |
| 79 | ) usize { | |
| 64 | arg1: u32, | |
| 65 | arg2: u32, | |
| 66 | arg3: u32, | |
| 67 | arg4: u32, | |
| 68 | arg5: u32, | |
| 69 | arg6: u32, | |
| 70 | ) u32 { | |
| 80 | 71 | return asm volatile ("trap #0" |
| 81 | : [ret] "={d0}" (-> usize), | |
| 72 | : [ret] "={d0}" (-> u32), | |
| 82 | 73 | : [number] "{d0}" (@intFromEnum(number)), |
| 83 | 74 | [arg1] "{d1}" (arg1), |
| 84 | 75 | [arg2] "{d2}" (arg2), |
| ... | ... | @@ -89,7 +80,7 @@ pub fn syscall6( |
| 89 | 80 | : .{ .memory = true }); |
| 90 | 81 | } |
| 91 | 82 | |
| 92 | pub fn clone() callconv(.naked) usize { | |
| 83 | pub fn clone() callconv(.naked) u32 { | |
| 93 | 84 | // __clone(func, stack, flags, arg, ptid, tls, ctid) |
| 94 | 85 | // +4, +8, +12, +16, +20, +24, +28 |
| 95 | 86 | // |
| ... | ... | @@ -151,32 +142,6 @@ pub fn restore_rt() callconv(.naked) noreturn { |
| 151 | 142 | ); |
| 152 | 143 | } |
| 153 | 144 | |
| 154 | pub const F = struct { | |
| 155 | pub const DUPFD = 0; | |
| 156 | pub const GETFD = 1; | |
| 157 | pub const SETFD = 2; | |
| 158 | pub const GETFL = 3; | |
| 159 | pub const SETFL = 4; | |
| 160 | ||
| 161 | pub const SETOWN = 8; | |
| 162 | pub const GETOWN = 9; | |
| 163 | pub const SETSIG = 10; | |
| 164 | pub const GETSIG = 11; | |
| 165 | ||
| 166 | pub const GETLK = 12; | |
| 167 | pub const SETLK = 13; | |
| 168 | pub const SETLKW = 14; | |
| 169 | ||
| 170 | pub const SETOWN_EX = 15; | |
| 171 | pub const GETOWN_EX = 16; | |
| 172 | ||
| 173 | pub const GETOWNER_UIDS = 17; | |
| 174 | ||
| 175 | pub const RDLCK = 0; | |
| 176 | pub const WRLCK = 1; | |
| 177 | pub const UNLCK = 2; | |
| 178 | }; | |
| 179 | ||
| 180 | 145 | pub const blksize_t = i32; |
| 181 | 146 | pub const nlink_t = u32; |
| 182 | 147 | pub const time_t = i32; |
| ... | ... | @@ -186,51 +151,36 @@ pub const ino_t = u64; |
| 186 | 151 | pub const dev_t = u64; |
| 187 | 152 | pub const blkcnt_t = i64; |
| 188 | 153 | |
| 189 | pub const timeval = extern struct { | |
| 190 | sec: time_t, | |
| 191 | usec: i32, | |
| 192 | }; | |
| 193 | ||
| 194 | pub const Flock = extern struct { | |
| 195 | type: i16, | |
| 196 | whence: i16, | |
| 197 | start: off_t, | |
| 198 | len: off_t, | |
| 199 | pid: pid_t, | |
| 200 | }; | |
| 201 | ||
| 202 | 154 | pub const Stat = extern struct { |
| 203 | 155 | dev: dev_t, |
| 204 | 156 | __pad: i16, |
| 205 | 157 | __ino_truncated: i32, |
| 206 | 158 | mode: mode_t, |
| 207 | 159 | nlink: nlink_t, |
| 208 | uid: uid_t, | |
| 209 | gid: gid_t, | |
| 160 | uid: std.os.linux.uid_t, | |
| 161 | gid: std.os.linux.gid_t, | |
| 210 | 162 | rdev: dev_t, |
| 211 | 163 | __pad2: i16, |
| 212 | 164 | size: off_t, |
| 213 | 165 | blksize: blksize_t, |
| 214 | 166 | blocks: blkcnt_t, |
| 215 | atim: timespec, | |
| 216 | mtim: timespec, | |
| 217 | ctim: timespec, | |
| 167 | atim: std.os.linux.timespec, | |
| 168 | mtim: std.os.linux.timespec, | |
| 169 | ctim: std.os.linux.timespec, | |
| 218 | 170 | ino: ino_t, |
| 219 | 171 | |
| 220 | pub fn atime(self: @This()) timespec { | |
| 172 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 221 | 173 | return self.atim; |
| 222 | 174 | } |
| 223 | 175 | |
| 224 | pub fn mtime(self: @This()) timespec { | |
| 176 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 225 | 177 | return self.mtim; |
| 226 | 178 | } |
| 227 | 179 | |
| 228 | pub fn ctime(self: @This()) timespec { | |
| 180 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 229 | 181 | return self.ctim; |
| 230 | 182 | } |
| 231 | 183 | }; |
| 232 | 184 | |
| 233 | pub const Elf_Symndx = u32; | |
| 234 | ||
| 235 | 185 | // No VDSO used as of glibc 112a0ae18b831bf31f44d81b82666980312511d6. |
| 236 | 186 | pub const VDSO = void; |
lib/std/os/linux/mips.zig+44-116| ... | ... | @@ -1,32 +1,20 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("../../std.zig"); |
| 3 | const maxInt = std.math.maxInt; | |
| 4 | const linux = std.os.linux; | |
| 5 | const SYS = linux.SYS; | |
| 6 | const socklen_t = linux.socklen_t; | |
| 7 | const iovec = std.posix.iovec; | |
| 8 | const iovec_const = std.posix.iovec_const; | |
| 9 | const uid_t = linux.uid_t; | |
| 10 | const gid_t = linux.gid_t; | |
| 11 | const pid_t = linux.pid_t; | |
| 12 | const stack_t = linux.stack_t; | |
| 13 | const sigset_t = linux.sigset_t; | |
| 14 | const sockaddr = linux.sockaddr; | |
| 15 | const timespec = linux.timespec; | |
| 3 | const SYS = std.os.linux.SYS; | |
| 16 | 4 | |
| 17 | pub fn syscall0(number: SYS) usize { | |
| 5 | pub fn syscall0(number: SYS) u32 { | |
| 18 | 6 | return asm volatile ( |
| 19 | 7 | \\ syscall |
| 20 | 8 | \\ beq $7, $zero, 1f |
| 21 | 9 | \\ blez $2, 1f |
| 22 | 10 | \\ subu $2, $0, $2 |
| 23 | 11 | \\ 1: |
| 24 | : [ret] "={$2}" (-> usize), | |
| 12 | : [ret] "={$2}" (-> u32), | |
| 25 | 13 | : [number] "{$2}" (@intFromEnum(number)), |
| 26 | 14 | : .{ .r1 = true, .r3 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); |
| 27 | 15 | } |
| 28 | 16 | |
| 29 | pub fn syscall_pipe(fd: *[2]i32) usize { | |
| 17 | pub fn syscall_pipe(fd: *[2]i32) u32 { | |
| 30 | 18 | return asm volatile ( |
| 31 | 19 | \\ .set noat |
| 32 | 20 | \\ .set noreorder |
| ... | ... | @@ -39,47 +27,47 @@ pub fn syscall_pipe(fd: *[2]i32) usize { |
| 39 | 27 | \\ sw $2, 0($4) |
| 40 | 28 | \\ sw $3, 4($4) |
| 41 | 29 | \\ 2: |
| 42 | : [ret] "={$2}" (-> usize), | |
| 30 | : [ret] "={$2}" (-> u32), | |
| 43 | 31 | : [number] "{$2}" (@intFromEnum(SYS.pipe)), |
| 44 | 32 | [fd] "{$4}" (fd), |
| 45 | 33 | : .{ .r1 = true, .r3 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); |
| 46 | 34 | } |
| 47 | 35 | |
| 48 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 36 | pub fn syscall1(number: SYS, arg1: u32) u32 { | |
| 49 | 37 | return asm volatile ( |
| 50 | 38 | \\ syscall |
| 51 | 39 | \\ beq $7, $zero, 1f |
| 52 | 40 | \\ blez $2, 1f |
| 53 | 41 | \\ subu $2, $0, $2 |
| 54 | 42 | \\ 1: |
| 55 | : [ret] "={$2}" (-> usize), | |
| 43 | : [ret] "={$2}" (-> u32), | |
| 56 | 44 | : [number] "{$2}" (@intFromEnum(number)), |
| 57 | 45 | [arg1] "{$4}" (arg1), |
| 58 | 46 | : .{ .r1 = true, .r3 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); |
| 59 | 47 | } |
| 60 | 48 | |
| 61 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 49 | pub fn syscall2(number: SYS, arg1: u32, arg2: u32) u32 { | |
| 62 | 50 | return asm volatile ( |
| 63 | 51 | \\ syscall |
| 64 | 52 | \\ beq $7, $zero, 1f |
| 65 | 53 | \\ blez $2, 1f |
| 66 | 54 | \\ subu $2, $0, $2 |
| 67 | 55 | \\ 1: |
| 68 | : [ret] "={$2}" (-> usize), | |
| 56 | : [ret] "={$2}" (-> u32), | |
| 69 | 57 | : [number] "{$2}" (@intFromEnum(number)), |
| 70 | 58 | [arg1] "{$4}" (arg1), |
| 71 | 59 | [arg2] "{$5}" (arg2), |
| 72 | 60 | : .{ .r1 = true, .r3 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); |
| 73 | 61 | } |
| 74 | 62 | |
| 75 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 63 | pub fn syscall3(number: SYS, arg1: u32, arg2: u32, arg3: u32) u32 { | |
| 76 | 64 | return asm volatile ( |
| 77 | 65 | \\ syscall |
| 78 | 66 | \\ beq $7, $zero, 1f |
| 79 | 67 | \\ blez $2, 1f |
| 80 | 68 | \\ subu $2, $0, $2 |
| 81 | 69 | \\ 1: |
| 82 | : [ret] "={$2}" (-> usize), | |
| 70 | : [ret] "={$2}" (-> u32), | |
| 83 | 71 | : [number] "{$2}" (@intFromEnum(number)), |
| 84 | 72 | [arg1] "{$4}" (arg1), |
| 85 | 73 | [arg2] "{$5}" (arg2), |
| ... | ... | @@ -87,14 +75,14 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 87 | 75 | : .{ .r1 = true, .r3 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); |
| 88 | 76 | } |
| 89 | 77 | |
| 90 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 78 | pub fn syscall4(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32) u32 { | |
| 91 | 79 | return asm volatile ( |
| 92 | 80 | \\ syscall |
| 93 | 81 | \\ beq $7, $zero, 1f |
| 94 | 82 | \\ blez $2, 1f |
| 95 | 83 | \\ subu $2, $0, $2 |
| 96 | 84 | \\ 1: |
| 97 | : [ret] "={$2}" (-> usize), | |
| 85 | : [ret] "={$2}" (-> u32), | |
| 98 | 86 | : [number] "{$2}" (@intFromEnum(number)), |
| 99 | 87 | [arg1] "{$4}" (arg1), |
| 100 | 88 | [arg2] "{$5}" (arg2), |
| ... | ... | @@ -103,7 +91,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 103 | 91 | : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); |
| 104 | 92 | } |
| 105 | 93 | |
| 106 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 94 | pub fn syscall5(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32, arg5: u32) u32 { | |
| 107 | 95 | return asm volatile ( |
| 108 | 96 | \\ .set noat |
| 109 | 97 | \\ subu $sp, $sp, 24 |
| ... | ... | @@ -114,7 +102,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 114 | 102 | \\ blez $2, 1f |
| 115 | 103 | \\ subu $2, $0, $2 |
| 116 | 104 | \\ 1: |
| 117 | : [ret] "={$2}" (-> usize), | |
| 105 | : [ret] "={$2}" (-> u32), | |
| 118 | 106 | : [number] "{$2}" (@intFromEnum(number)), |
| 119 | 107 | [arg1] "{$4}" (arg1), |
| 120 | 108 | [arg2] "{$5}" (arg2), |
| ... | ... | @@ -129,13 +117,13 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 129 | 117 | |
| 130 | 118 | pub fn syscall6( |
| 131 | 119 | number: SYS, |
| 132 | arg1: usize, | |
| 133 | arg2: usize, | |
| 134 | arg3: usize, | |
| 135 | arg4: usize, | |
| 136 | arg5: usize, | |
| 137 | arg6: usize, | |
| 138 | ) usize { | |
| 120 | arg1: u32, | |
| 121 | arg2: u32, | |
| 122 | arg3: u32, | |
| 123 | arg4: u32, | |
| 124 | arg5: u32, | |
| 125 | arg6: u32, | |
| 126 | ) u32 { | |
| 139 | 127 | return asm volatile ( |
| 140 | 128 | \\ .set noat |
| 141 | 129 | \\ subu $sp, $sp, 24 |
| ... | ... | @@ -147,7 +135,7 @@ pub fn syscall6( |
| 147 | 135 | \\ blez $2, 1f |
| 148 | 136 | \\ subu $2, $0, $2 |
| 149 | 137 | \\ 1: |
| 150 | : [ret] "={$2}" (-> usize), | |
| 138 | : [ret] "={$2}" (-> u32), | |
| 151 | 139 | : [number] "{$2}" (@intFromEnum(number)), |
| 152 | 140 | [arg1] "{$4}" (arg1), |
| 153 | 141 | [arg2] "{$5}" (arg2), |
| ... | ... | @@ -160,14 +148,14 @@ pub fn syscall6( |
| 160 | 148 | |
| 161 | 149 | pub fn syscall7( |
| 162 | 150 | number: SYS, |
| 163 | arg1: usize, | |
| 164 | arg2: usize, | |
| 165 | arg3: usize, | |
| 166 | arg4: usize, | |
| 167 | arg5: usize, | |
| 168 | arg6: usize, | |
| 169 | arg7: usize, | |
| 170 | ) usize { | |
| 151 | arg1: u32, | |
| 152 | arg2: u32, | |
| 153 | arg3: u32, | |
| 154 | arg4: u32, | |
| 155 | arg5: u32, | |
| 156 | arg6: u32, | |
| 157 | arg7: u32, | |
| 158 | ) u32 { | |
| 171 | 159 | return asm volatile ( |
| 172 | 160 | \\ .set noat |
| 173 | 161 | \\ subu $sp, $sp, 32 |
| ... | ... | @@ -180,7 +168,7 @@ pub fn syscall7( |
| 180 | 168 | \\ blez $2, 1f |
| 181 | 169 | \\ subu $2, $0, $2 |
| 182 | 170 | \\ 1: |
| 183 | : [ret] "={$2}" (-> usize), | |
| 171 | : [ret] "={$2}" (-> u32), | |
| 184 | 172 | : [number] "{$2}" (@intFromEnum(number)), |
| 185 | 173 | [arg1] "{$4}" (arg1), |
| 186 | 174 | [arg2] "{$5}" (arg2), |
| ... | ... | @@ -192,7 +180,7 @@ pub fn syscall7( |
| 192 | 180 | : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); |
| 193 | 181 | } |
| 194 | 182 | |
| 195 | pub fn clone() callconv(.naked) usize { | |
| 183 | pub fn clone() callconv(.naked) u32 { | |
| 196 | 184 | // __clone(func, stack, flags, arg, ptid, tls, ctid) |
| 197 | 185 | // 3, 4, 5, 6, 7, 8, 9 |
| 198 | 186 | // |
| ... | ... | @@ -243,47 +231,11 @@ pub fn clone() callconv(.naked) usize { |
| 243 | 231 | ); |
| 244 | 232 | } |
| 245 | 233 | |
| 246 | pub const F = struct { | |
| 247 | pub const DUPFD = 0; | |
| 248 | pub const GETFD = 1; | |
| 249 | pub const SETFD = 2; | |
| 250 | pub const GETFL = 3; | |
| 251 | pub const SETFL = 4; | |
| 252 | ||
| 253 | pub const SETOWN = 24; | |
| 254 | pub const GETOWN = 23; | |
| 255 | pub const SETSIG = 10; | |
| 256 | pub const GETSIG = 11; | |
| 257 | ||
| 258 | pub const GETLK = 33; | |
| 259 | pub const SETLK = 34; | |
| 260 | pub const SETLKW = 35; | |
| 261 | ||
| 262 | pub const RDLCK = 0; | |
| 263 | pub const WRLCK = 1; | |
| 264 | pub const UNLCK = 2; | |
| 265 | ||
| 266 | pub const SETOWN_EX = 15; | |
| 267 | pub const GETOWN_EX = 16; | |
| 268 | ||
| 269 | pub const GETOWNER_UIDS = 17; | |
| 270 | }; | |
| 271 | ||
| 272 | 234 | pub const VDSO = struct { |
| 273 | 235 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 274 | 236 | pub const CGT_VER = "LINUX_2.6"; |
| 275 | 237 | }; |
| 276 | 238 | |
| 277 | pub const Flock = extern struct { | |
| 278 | type: i16, | |
| 279 | whence: i16, | |
| 280 | __pad0: [4]u8, | |
| 281 | start: off_t, | |
| 282 | len: off_t, | |
| 283 | pid: pid_t, | |
| 284 | __unused: [4]u8, | |
| 285 | }; | |
| 286 | ||
| 287 | 239 | pub const blksize_t = u32; |
| 288 | 240 | pub const nlink_t = u32; |
| 289 | 241 | pub const time_t = i32; |
| ... | ... | @@ -300,51 +252,27 @@ pub const Stat = extern struct { |
| 300 | 252 | ino: ino_t, |
| 301 | 253 | mode: mode_t, |
| 302 | 254 | nlink: nlink_t, |
| 303 | uid: uid_t, | |
| 304 | gid: gid_t, | |
| 255 | uid: std.os.linux.uid_t, | |
| 256 | gid: std.os.linux.gid_t, | |
| 305 | 257 | rdev: dev_t, |
| 306 | 258 | __pad1: [2]u32, |
| 307 | 259 | size: off_t, |
| 308 | atim: i32, | |
| 309 | atim_nsec: i32, | |
| 310 | mtim: i32, | |
| 311 | mtim_nsec: i32, | |
| 312 | ctim: i32, | |
| 313 | ctim_nsec: i32, | |
| 260 | atim: std.os.linux.timespec, | |
| 261 | mtim: std.os.linux.timespec, | |
| 262 | ctim: std.os.linux.timespec, | |
| 314 | 263 | blksize: blksize_t, |
| 315 | 264 | __pad3: u32, |
| 316 | 265 | blocks: blkcnt_t, |
| 317 | 266 | |
| 318 | pub fn atime(self: @This()) timespec { | |
| 319 | return .{ | |
| 320 | .sec = self.atim, | |
| 321 | .nsec = self.atim_nsec, | |
| 322 | }; | |
| 267 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 268 | return self.atim; | |
| 323 | 269 | } |
| 324 | 270 | |
| 325 | pub fn mtime(self: @This()) timespec { | |
| 326 | return .{ | |
| 327 | .sec = self.mtim, | |
| 328 | .nsec = self.mtim_nsec, | |
| 329 | }; | |
| 271 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 272 | return self.mtim; | |
| 330 | 273 | } |
| 331 | 274 | |
| 332 | pub fn ctime(self: @This()) timespec { | |
| 333 | return .{ | |
| 334 | .sec = self.ctim, | |
| 335 | .nsec = self.ctim_nsec, | |
| 336 | }; | |
| 275 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 276 | return self.ctim; | |
| 337 | 277 | } |
| 338 | 278 | }; |
| 339 | ||
| 340 | pub const timeval = extern struct { | |
| 341 | sec: isize, | |
| 342 | usec: isize, | |
| 343 | }; | |
| 344 | ||
| 345 | pub const timezone = extern struct { | |
| 346 | minuteswest: i32, | |
| 347 | dsttime: i32, | |
| 348 | }; | |
| 349 | ||
| 350 | pub const Elf_Symndx = u32; |
lib/std/os/linux/mips64.zig+38-98| ... | ... | @@ -1,32 +1,20 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("../../std.zig"); |
| 3 | const maxInt = std.math.maxInt; | |
| 4 | const linux = std.os.linux; | |
| 5 | const SYS = linux.SYS; | |
| 6 | const socklen_t = linux.socklen_t; | |
| 7 | const iovec = std.posix.iovec; | |
| 8 | const iovec_const = std.posix.iovec_const; | |
| 9 | const uid_t = linux.uid_t; | |
| 10 | const gid_t = linux.gid_t; | |
| 11 | const pid_t = linux.pid_t; | |
| 12 | const stack_t = linux.stack_t; | |
| 13 | const sigset_t = linux.sigset_t; | |
| 14 | const sockaddr = linux.sockaddr; | |
| 15 | const timespec = linux.timespec; | |
| 3 | const SYS = std.os.linux.SYS; | |
| 16 | 4 | |
| 17 | pub fn syscall0(number: SYS) usize { | |
| 5 | pub fn syscall0(number: SYS) u64 { | |
| 18 | 6 | return asm volatile ( |
| 19 | 7 | \\ syscall |
| 20 | 8 | \\ beq $7, $zero, 1f |
| 21 | 9 | \\ blez $2, 1f |
| 22 | 10 | \\ dsubu $2, $0, $2 |
| 23 | 11 | \\ 1: |
| 24 | : [ret] "={$2}" (-> usize), | |
| 12 | : [ret] "={$2}" (-> u64), | |
| 25 | 13 | : [number] "{$2}" (@intFromEnum(number)), |
| 26 | 14 | : .{ .r1 = true, .r3 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); |
| 27 | 15 | } |
| 28 | 16 | |
| 29 | pub fn syscall_pipe(fd: *[2]i32) usize { | |
| 17 | pub fn syscall_pipe(fd: *[2]i32) u64 { | |
| 30 | 18 | return asm volatile ( |
| 31 | 19 | \\ .set noat |
| 32 | 20 | \\ .set noreorder |
| ... | ... | @@ -39,13 +27,13 @@ pub fn syscall_pipe(fd: *[2]i32) usize { |
| 39 | 27 | \\ sw $2, 0($4) |
| 40 | 28 | \\ sw $3, 4($4) |
| 41 | 29 | \\ 2: |
| 42 | : [ret] "={$2}" (-> usize), | |
| 30 | : [ret] "={$2}" (-> u64), | |
| 43 | 31 | : [number] "{$2}" (@intFromEnum(SYS.pipe)), |
| 44 | 32 | [fd] "{$4}" (fd), |
| 45 | 33 | : .{ .r1 = true, .r3 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); |
| 46 | 34 | } |
| 47 | 35 | |
| 48 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 36 | pub fn syscall1(number: SYS, arg1: u64) u64 { | |
| 49 | 37 | return asm volatile ( |
| 50 | 38 | \\ syscall |
| 51 | 39 | \\ beq $7, $zero, 1f |
| ... | ... | @@ -53,34 +41,34 @@ pub fn syscall1(number: SYS, arg1: usize) usize { |
| 53 | 41 | \\ nop |
| 54 | 42 | \\ dsubu $2, $0, $2 |
| 55 | 43 | \\ 1: |
| 56 | : [ret] "={$2}" (-> usize), | |
| 44 | : [ret] "={$2}" (-> u64), | |
| 57 | 45 | : [number] "{$2}" (@intFromEnum(number)), |
| 58 | 46 | [arg1] "{$4}" (arg1), |
| 59 | 47 | : .{ .r1 = true, .r3 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); |
| 60 | 48 | } |
| 61 | 49 | |
| 62 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 50 | pub fn syscall2(number: SYS, arg1: u64, arg2: u64) u64 { | |
| 63 | 51 | return asm volatile ( |
| 64 | 52 | \\ syscall |
| 65 | 53 | \\ beq $7, $zero, 1f |
| 66 | 54 | \\ blez $2, 1f |
| 67 | 55 | \\ dsubu $2, $0, $2 |
| 68 | 56 | \\ 1: |
| 69 | : [ret] "={$2}" (-> usize), | |
| 57 | : [ret] "={$2}" (-> u64), | |
| 70 | 58 | : [number] "{$2}" (@intFromEnum(number)), |
| 71 | 59 | [arg1] "{$4}" (arg1), |
| 72 | 60 | [arg2] "{$5}" (arg2), |
| 73 | 61 | : .{ .r1 = true, .r3 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); |
| 74 | 62 | } |
| 75 | 63 | |
| 76 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 64 | pub fn syscall3(number: SYS, arg1: u64, arg2: u64, arg3: u64) u64 { | |
| 77 | 65 | return asm volatile ( |
| 78 | 66 | \\ syscall |
| 79 | 67 | \\ beq $7, $zero, 1f |
| 80 | 68 | \\ blez $2, 1f |
| 81 | 69 | \\ dsubu $2, $0, $2 |
| 82 | 70 | \\ 1: |
| 83 | : [ret] "={$2}" (-> usize), | |
| 71 | : [ret] "={$2}" (-> u64), | |
| 84 | 72 | : [number] "{$2}" (@intFromEnum(number)), |
| 85 | 73 | [arg1] "{$4}" (arg1), |
| 86 | 74 | [arg2] "{$5}" (arg2), |
| ... | ... | @@ -88,14 +76,14 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 88 | 76 | : .{ .r1 = true, .r3 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); |
| 89 | 77 | } |
| 90 | 78 | |
| 91 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 79 | pub fn syscall4(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64) u64 { | |
| 92 | 80 | return asm volatile ( |
| 93 | 81 | \\ syscall |
| 94 | 82 | \\ beq $7, $zero, 1f |
| 95 | 83 | \\ blez $2, 1f |
| 96 | 84 | \\ dsubu $2, $0, $2 |
| 97 | 85 | \\ 1: |
| 98 | : [ret] "={$2}" (-> usize), | |
| 86 | : [ret] "={$2}" (-> u64), | |
| 99 | 87 | : [number] "{$2}" (@intFromEnum(number)), |
| 100 | 88 | [arg1] "{$4}" (arg1), |
| 101 | 89 | [arg2] "{$5}" (arg2), |
| ... | ... | @@ -104,14 +92,14 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 104 | 92 | : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); |
| 105 | 93 | } |
| 106 | 94 | |
| 107 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 95 | pub fn syscall5(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) u64 { | |
| 108 | 96 | return asm volatile ( |
| 109 | 97 | \\ syscall |
| 110 | 98 | \\ beq $7, $zero, 1f |
| 111 | 99 | \\ blez $2, 1f |
| 112 | 100 | \\ dsubu $2, $0, $2 |
| 113 | 101 | \\ 1: |
| 114 | : [ret] "={$2}" (-> usize), | |
| 102 | : [ret] "={$2}" (-> u64), | |
| 115 | 103 | : [number] "{$2}" (@intFromEnum(number)), |
| 116 | 104 | [arg1] "{$4}" (arg1), |
| 117 | 105 | [arg2] "{$5}" (arg2), |
| ... | ... | @@ -123,20 +111,20 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 123 | 111 | |
| 124 | 112 | pub fn syscall6( |
| 125 | 113 | number: SYS, |
| 126 | arg1: usize, | |
| 127 | arg2: usize, | |
| 128 | arg3: usize, | |
| 129 | arg4: usize, | |
| 130 | arg5: usize, | |
| 131 | arg6: usize, | |
| 132 | ) usize { | |
| 114 | arg1: u64, | |
| 115 | arg2: u64, | |
| 116 | arg3: u64, | |
| 117 | arg4: u64, | |
| 118 | arg5: u64, | |
| 119 | arg6: u64, | |
| 120 | ) u64 { | |
| 133 | 121 | return asm volatile ( |
| 134 | 122 | \\ syscall |
| 135 | 123 | \\ beq $7, $zero, 1f |
| 136 | 124 | \\ blez $2, 1f |
| 137 | 125 | \\ dsubu $2, $0, $2 |
| 138 | 126 | \\ 1: |
| 139 | : [ret] "={$2}" (-> usize), | |
| 127 | : [ret] "={$2}" (-> u64), | |
| 140 | 128 | : [number] "{$2}" (@intFromEnum(number)), |
| 141 | 129 | [arg1] "{$4}" (arg1), |
| 142 | 130 | [arg2] "{$5}" (arg2), |
| ... | ... | @@ -149,21 +137,21 @@ pub fn syscall6( |
| 149 | 137 | |
| 150 | 138 | pub fn syscall7( |
| 151 | 139 | number: SYS, |
| 152 | arg1: usize, | |
| 153 | arg2: usize, | |
| 154 | arg3: usize, | |
| 155 | arg4: usize, | |
| 156 | arg5: usize, | |
| 157 | arg6: usize, | |
| 158 | arg7: usize, | |
| 159 | ) usize { | |
| 140 | arg1: u64, | |
| 141 | arg2: u64, | |
| 142 | arg3: u64, | |
| 143 | arg4: u64, | |
| 144 | arg5: u64, | |
| 145 | arg6: u64, | |
| 146 | arg7: u64, | |
| 147 | ) u64 { | |
| 160 | 148 | return asm volatile ( |
| 161 | 149 | \\ syscall |
| 162 | 150 | \\ beq $7, $zero, 1f |
| 163 | 151 | \\ blez $2, 1f |
| 164 | 152 | \\ dsubu $2, $0, $2 |
| 165 | 153 | \\ 1: |
| 166 | : [ret] "={$2}" (-> usize), | |
| 154 | : [ret] "={$2}" (-> u64), | |
| 167 | 155 | : [number] "{$2}" (@intFromEnum(number)), |
| 168 | 156 | [arg1] "{$4}" (arg1), |
| 169 | 157 | [arg2] "{$5}" (arg2), |
| ... | ... | @@ -175,7 +163,7 @@ pub fn syscall7( |
| 175 | 163 | : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); |
| 176 | 164 | } |
| 177 | 165 | |
| 178 | pub fn clone() callconv(.naked) usize { | |
| 166 | pub fn clone() callconv(.naked) u64 { | |
| 179 | 167 | // __clone(func, stack, flags, arg, ptid, tls, ctid) |
| 180 | 168 | // 3, 4, 5, 6, 7, 8, 9 |
| 181 | 169 | // |
| ... | ... | @@ -222,47 +210,11 @@ pub fn clone() callconv(.naked) usize { |
| 222 | 210 | ); |
| 223 | 211 | } |
| 224 | 212 | |
| 225 | pub const F = struct { | |
| 226 | pub const DUPFD = 0; | |
| 227 | pub const GETFD = 1; | |
| 228 | pub const SETFD = 2; | |
| 229 | pub const GETFL = 3; | |
| 230 | pub const SETFL = 4; | |
| 231 | ||
| 232 | pub const SETOWN = 24; | |
| 233 | pub const GETOWN = 23; | |
| 234 | pub const SETSIG = 10; | |
| 235 | pub const GETSIG = 11; | |
| 236 | ||
| 237 | pub const GETLK = 33; | |
| 238 | pub const SETLK = 34; | |
| 239 | pub const SETLKW = 35; | |
| 240 | ||
| 241 | pub const RDLCK = 0; | |
| 242 | pub const WRLCK = 1; | |
| 243 | pub const UNLCK = 2; | |
| 244 | ||
| 245 | pub const SETOWN_EX = 15; | |
| 246 | pub const GETOWN_EX = 16; | |
| 247 | ||
| 248 | pub const GETOWNER_UIDS = 17; | |
| 249 | }; | |
| 250 | ||
| 251 | 213 | pub const VDSO = struct { |
| 252 | 214 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 253 | 215 | pub const CGT_VER = "LINUX_2.6"; |
| 254 | 216 | }; |
| 255 | 217 | |
| 256 | pub const Flock = extern struct { | |
| 257 | type: i16, | |
| 258 | whence: i16, | |
| 259 | __pad0: [4]u8, | |
| 260 | start: off_t, | |
| 261 | len: off_t, | |
| 262 | pid: pid_t, | |
| 263 | __unused: [4]u8, | |
| 264 | }; | |
| 265 | ||
| 266 | 218 | pub const blksize_t = u32; |
| 267 | 219 | pub const nlink_t = u32; |
| 268 | 220 | pub const time_t = i32; |
| ... | ... | @@ -279,8 +231,8 @@ pub const Stat = extern struct { |
| 279 | 231 | ino: ino_t, |
| 280 | 232 | mode: mode_t, |
| 281 | 233 | nlink: nlink_t, |
| 282 | uid: uid_t, | |
| 283 | gid: gid_t, | |
| 234 | uid: std.os.linux.uid_t, | |
| 235 | gid: std.os.linux.gid_t, | |
| 284 | 236 | rdev: dev_t, |
| 285 | 237 | __pad1: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32). |
| 286 | 238 | size: off_t, |
| ... | ... | @@ -294,36 +246,24 @@ pub const Stat = extern struct { |
| 294 | 246 | __pad3: u32, |
| 295 | 247 | blocks: blkcnt_t, |
| 296 | 248 | |
| 297 | pub fn atime(self: @This()) timespec { | |
| 249 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 298 | 250 | return .{ |
| 299 | 251 | .sec = self.atim, |
| 300 | 252 | .nsec = self.atim_nsec, |
| 301 | 253 | }; |
| 302 | 254 | } |
| 303 | 255 | |
| 304 | pub fn mtime(self: @This()) timespec { | |
| 256 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 305 | 257 | return .{ |
| 306 | 258 | .sec = self.mtim, |
| 307 | 259 | .nsec = self.mtim_nsec, |
| 308 | 260 | }; |
| 309 | 261 | } |
| 310 | 262 | |
| 311 | pub fn ctime(self: @This()) timespec { | |
| 263 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 312 | 264 | return .{ |
| 313 | 265 | .sec = self.ctim, |
| 314 | 266 | .nsec = self.ctim_nsec, |
| 315 | 267 | }; |
| 316 | 268 | } |
| 317 | 269 | }; |
| 318 | ||
| 319 | pub const timeval = extern struct { | |
| 320 | sec: isize, | |
| 321 | usec: isize, | |
| 322 | }; | |
| 323 | ||
| 324 | pub const timezone = extern struct { | |
| 325 | minuteswest: i32, | |
| 326 | dsttime: i32, | |
| 327 | }; | |
| 328 | ||
| 329 | pub const Elf_Symndx = u32; |
lib/std/os/linux/mipsn32.zig created+271| ... | ... | @@ -0,0 +1,271 @@ |
| 1 | // TODO: A lot of this file is very likely wrong. | |
| 2 | ||
| 3 | const builtin = @import("builtin"); | |
| 4 | const std = @import("../../std.zig"); | |
| 5 | const SYS = std.os.linux.SYS; | |
| 6 | ||
| 7 | pub fn syscall0(number: SYS) u32 { | |
| 8 | return asm volatile ( | |
| 9 | \\ syscall | |
| 10 | \\ beq $7, $zero, 1f | |
| 11 | \\ blez $2, 1f | |
| 12 | \\ dsubu $2, $0, $2 | |
| 13 | \\ 1: | |
| 14 | : [ret] "={$2}" (-> u32), | |
| 15 | : [number] "{$2}" (@intFromEnum(number)), | |
| 16 | : .{ .r1 = true, .r3 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); | |
| 17 | } | |
| 18 | ||
| 19 | pub fn syscall_pipe(fd: *[2]i32) u32 { | |
| 20 | return asm volatile ( | |
| 21 | \\ .set noat | |
| 22 | \\ .set noreorder | |
| 23 | \\ syscall | |
| 24 | \\ beq $7, $zero, 1f | |
| 25 | \\ nop | |
| 26 | \\ b 2f | |
| 27 | \\ subu $2, $0, $2 | |
| 28 | \\ 1: | |
| 29 | \\ sw $2, 0($4) | |
| 30 | \\ sw $3, 4($4) | |
| 31 | \\ 2: | |
| 32 | : [ret] "={$2}" (-> u32), | |
| 33 | : [number] "{$2}" (@intFromEnum(SYS.pipe)), | |
| 34 | [fd] "{$4}" (fd), | |
| 35 | : .{ .r1 = true, .r3 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); | |
| 36 | } | |
| 37 | ||
| 38 | pub fn syscall1(number: SYS, arg1: u32) u32 { | |
| 39 | return asm volatile ( | |
| 40 | \\ syscall | |
| 41 | \\ beq $7, $zero, 1f | |
| 42 | \\ blez $2, 1f | |
| 43 | \\ nop | |
| 44 | \\ dsubu $2, $0, $2 | |
| 45 | \\ 1: | |
| 46 | : [ret] "={$2}" (-> u32), | |
| 47 | : [number] "{$2}" (@intFromEnum(number)), | |
| 48 | [arg1] "{$4}" (arg1), | |
| 49 | : .{ .r1 = true, .r3 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); | |
| 50 | } | |
| 51 | ||
| 52 | pub fn syscall2(number: SYS, arg1: u32, arg2: u32) u32 { | |
| 53 | return asm volatile ( | |
| 54 | \\ syscall | |
| 55 | \\ beq $7, $zero, 1f | |
| 56 | \\ blez $2, 1f | |
| 57 | \\ dsubu $2, $0, $2 | |
| 58 | \\ 1: | |
| 59 | : [ret] "={$2}" (-> u32), | |
| 60 | : [number] "{$2}" (@intFromEnum(number)), | |
| 61 | [arg1] "{$4}" (arg1), | |
| 62 | [arg2] "{$5}" (arg2), | |
| 63 | : .{ .r1 = true, .r3 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); | |
| 64 | } | |
| 65 | ||
| 66 | pub fn syscall3(number: SYS, arg1: u32, arg2: u32, arg3: u32) u32 { | |
| 67 | return asm volatile ( | |
| 68 | \\ syscall | |
| 69 | \\ beq $7, $zero, 1f | |
| 70 | \\ blez $2, 1f | |
| 71 | \\ dsubu $2, $0, $2 | |
| 72 | \\ 1: | |
| 73 | : [ret] "={$2}" (-> u32), | |
| 74 | : [number] "{$2}" (@intFromEnum(number)), | |
| 75 | [arg1] "{$4}" (arg1), | |
| 76 | [arg2] "{$5}" (arg2), | |
| 77 | [arg3] "{$6}" (arg3), | |
| 78 | : .{ .r1 = true, .r3 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); | |
| 79 | } | |
| 80 | ||
| 81 | pub fn syscall4(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32) u32 { | |
| 82 | return asm volatile ( | |
| 83 | \\ syscall | |
| 84 | \\ beq $7, $zero, 1f | |
| 85 | \\ blez $2, 1f | |
| 86 | \\ dsubu $2, $0, $2 | |
| 87 | \\ 1: | |
| 88 | : [ret] "={$2}" (-> u32), | |
| 89 | : [number] "{$2}" (@intFromEnum(number)), | |
| 90 | [arg1] "{$4}" (arg1), | |
| 91 | [arg2] "{$5}" (arg2), | |
| 92 | [arg3] "{$6}" (arg3), | |
| 93 | [arg4] "{$7}" (arg4), | |
| 94 | : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); | |
| 95 | } | |
| 96 | ||
| 97 | pub fn syscall5(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32, arg5: u32) u32 { | |
| 98 | return asm volatile ( | |
| 99 | \\ syscall | |
| 100 | \\ beq $7, $zero, 1f | |
| 101 | \\ blez $2, 1f | |
| 102 | \\ dsubu $2, $0, $2 | |
| 103 | \\ 1: | |
| 104 | : [ret] "={$2}" (-> u32), | |
| 105 | : [number] "{$2}" (@intFromEnum(number)), | |
| 106 | [arg1] "{$4}" (arg1), | |
| 107 | [arg2] "{$5}" (arg2), | |
| 108 | [arg3] "{$6}" (arg3), | |
| 109 | [arg4] "{$7}" (arg4), | |
| 110 | [arg5] "{$8}" (arg5), | |
| 111 | : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); | |
| 112 | } | |
| 113 | ||
| 114 | pub fn syscall6( | |
| 115 | number: SYS, | |
| 116 | arg1: u32, | |
| 117 | arg2: u32, | |
| 118 | arg3: u32, | |
| 119 | arg4: u32, | |
| 120 | arg5: u32, | |
| 121 | arg6: u32, | |
| 122 | ) u32 { | |
| 123 | return asm volatile ( | |
| 124 | \\ syscall | |
| 125 | \\ beq $7, $zero, 1f | |
| 126 | \\ blez $2, 1f | |
| 127 | \\ dsubu $2, $0, $2 | |
| 128 | \\ 1: | |
| 129 | : [ret] "={$2}" (-> u32), | |
| 130 | : [number] "{$2}" (@intFromEnum(number)), | |
| 131 | [arg1] "{$4}" (arg1), | |
| 132 | [arg2] "{$5}" (arg2), | |
| 133 | [arg3] "{$6}" (arg3), | |
| 134 | [arg4] "{$7}" (arg4), | |
| 135 | [arg5] "{$8}" (arg5), | |
| 136 | [arg6] "{$9}" (arg6), | |
| 137 | : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); | |
| 138 | } | |
| 139 | ||
| 140 | pub fn syscall7( | |
| 141 | number: SYS, | |
| 142 | arg1: u32, | |
| 143 | arg2: u32, | |
| 144 | arg3: u32, | |
| 145 | arg4: u32, | |
| 146 | arg5: u32, | |
| 147 | arg6: u32, | |
| 148 | arg7: u32, | |
| 149 | ) u32 { | |
| 150 | return asm volatile ( | |
| 151 | \\ syscall | |
| 152 | \\ beq $7, $zero, 1f | |
| 153 | \\ blez $2, 1f | |
| 154 | \\ dsubu $2, $0, $2 | |
| 155 | \\ 1: | |
| 156 | : [ret] "={$2}" (-> u32), | |
| 157 | : [number] "{$2}" (@intFromEnum(number)), | |
| 158 | [arg1] "{$4}" (arg1), | |
| 159 | [arg2] "{$5}" (arg2), | |
| 160 | [arg3] "{$6}" (arg3), | |
| 161 | [arg4] "{$7}" (arg4), | |
| 162 | [arg5] "{$8}" (arg5), | |
| 163 | [arg6] "{$9}" (arg6), | |
| 164 | [arg7] "{$10}" (arg7), | |
| 165 | : .{ .r1 = true, .r3 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .r13 = true, .r14 = true, .r15 = true, .r24 = true, .r25 = true, .hi = true, .lo = true, .memory = true }); | |
| 166 | } | |
| 167 | ||
| 168 | pub fn clone() callconv(.naked) u32 { | |
| 169 | // __clone(func, stack, flags, arg, ptid, tls, ctid) | |
| 170 | // 3, 4, 5, 6, 7, 8, 9 | |
| 171 | // | |
| 172 | // syscall(SYS_clone, flags, stack, ptid, tls, ctid) | |
| 173 | // 2 4, 5, 6, 7, 8 | |
| 174 | asm volatile ( | |
| 175 | \\ # Save function pointer and argument pointer on new thread stack | |
| 176 | \\ and $5, $5, -16 | |
| 177 | \\ dsubu $5, $5, 16 | |
| 178 | \\ sd $4, 0($5) | |
| 179 | \\ sd $7, 8($5) | |
| 180 | \\ # Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (fl,sp,ptid,tls,ctid) | |
| 181 | \\ move $4, $6 | |
| 182 | \\ move $6, $8 | |
| 183 | \\ move $7, $9 | |
| 184 | \\ move $8, $10 | |
| 185 | \\ li $2, 5055 # SYS_clone | |
| 186 | \\ syscall | |
| 187 | \\ beq $7, $0, 1f | |
| 188 | \\ nop | |
| 189 | \\ jr $ra | |
| 190 | \\ dsubu $2, $0, $2 | |
| 191 | \\1: | |
| 192 | \\ beq $2, $0, 1f | |
| 193 | \\ nop | |
| 194 | \\ jr $ra | |
| 195 | \\ nop | |
| 196 | \\1: | |
| 197 | ); | |
| 198 | if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile ( | |
| 199 | \\ .cfi_undefined $ra | |
| 200 | ); | |
| 201 | asm volatile ( | |
| 202 | \\ move $fp, $zero | |
| 203 | \\ move $ra, $zero | |
| 204 | \\ | |
| 205 | \\ ld $25, 0($sp) | |
| 206 | \\ ld $4, 8($sp) | |
| 207 | \\ jalr $25 | |
| 208 | \\ nop | |
| 209 | \\ move $4, $2 | |
| 210 | \\ li $2, 5058 # SYS_exit | |
| 211 | \\ syscall | |
| 212 | ); | |
| 213 | } | |
| 214 | ||
| 215 | pub const VDSO = struct { | |
| 216 | pub const CGT_SYM = "__vdso_clock_gettime"; | |
| 217 | pub const CGT_VER = "LINUX_2.6"; | |
| 218 | }; | |
| 219 | ||
| 220 | pub const blksize_t = u32; | |
| 221 | pub const nlink_t = u32; | |
| 222 | pub const time_t = i32; | |
| 223 | pub const mode_t = u32; | |
| 224 | pub const off_t = i64; | |
| 225 | pub const ino_t = u64; | |
| 226 | pub const dev_t = u64; | |
| 227 | pub const blkcnt_t = i64; | |
| 228 | ||
| 229 | // The `stat` definition used by the Linux kernel. | |
| 230 | pub const Stat = extern struct { | |
| 231 | dev: dev_t, | |
| 232 | __pad0: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32). | |
| 233 | ino: ino_t, | |
| 234 | mode: mode_t, | |
| 235 | nlink: nlink_t, | |
| 236 | uid: std.os.linux.uid_t, | |
| 237 | gid: std.os.linux.gid_t, | |
| 238 | rdev: dev_t, | |
| 239 | __pad1: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32). | |
| 240 | size: off_t, | |
| 241 | atim: u32, | |
| 242 | atim_nsec: u32, | |
| 243 | mtim: u32, | |
| 244 | mtim_nsec: u32, | |
| 245 | ctim: u32, | |
| 246 | ctim_nsec: u32, | |
| 247 | blksize: blksize_t, | |
| 248 | __pad3: u32, | |
| 249 | blocks: blkcnt_t, | |
| 250 | ||
| 251 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 252 | return .{ | |
| 253 | .sec = self.atim, | |
| 254 | .nsec = self.atim_nsec, | |
| 255 | }; | |
| 256 | } | |
| 257 | ||
| 258 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 259 | return .{ | |
| 260 | .sec = self.mtim, | |
| 261 | .nsec = self.mtim_nsec, | |
| 262 | }; | |
| 263 | } | |
| 264 | ||
| 265 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 266 | return .{ | |
| 267 | .sec = self.ctim, | |
| 268 | .nsec = self.ctim_nsec, | |
| 269 | }; | |
| 270 | } | |
| 271 | }; |
lib/std/os/linux/powerpc.zig+55-113| ... | ... | @@ -1,61 +1,49 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("../../std.zig"); |
| 3 | const maxInt = std.math.maxInt; | |
| 4 | const linux = std.os.linux; | |
| 5 | const SYS = linux.SYS; | |
| 6 | const socklen_t = linux.socklen_t; | |
| 7 | const iovec = std.posix.iovec; | |
| 8 | const iovec_const = std.posix.iovec_const; | |
| 9 | const uid_t = linux.uid_t; | |
| 10 | const gid_t = linux.gid_t; | |
| 11 | const pid_t = linux.pid_t; | |
| 12 | const stack_t = linux.stack_t; | |
| 13 | const sigset_t = linux.sigset_t; | |
| 14 | const sockaddr = linux.sockaddr; | |
| 15 | const timespec = linux.timespec; | |
| 3 | const SYS = std.os.linux.SYS; | |
| 16 | 4 | |
| 17 | pub fn syscall0(number: SYS) usize { | |
| 5 | pub fn syscall0(number: SYS) u32 { | |
| 18 | 6 | // r0 is both an input register and a clobber. musl and glibc achieve this with |
| 19 | 7 | // a "+" constraint, which isn't supported in Zig, so instead we separately list |
| 20 | 8 | // r0 as both an input and an output. (Listing it as an input and a clobber would |
| 21 | 9 | // cause the C backend to emit invalid code; see #25209.) |
| 22 | var r0_out: usize = undefined; | |
| 10 | var r0_out: u32 = undefined; | |
| 23 | 11 | return asm volatile ( |
| 24 | 12 | \\ sc |
| 25 | 13 | \\ bns+ 1f |
| 26 | 14 | \\ neg 3, 3 |
| 27 | 15 | \\ 1: |
| 28 | : [ret] "={r3}" (-> usize), | |
| 16 | : [ret] "={r3}" (-> u32), | |
| 29 | 17 | [r0_out] "={r0}" (r0_out), |
| 30 | 18 | : [number] "{r0}" (@intFromEnum(number)), |
| 31 | 19 | : .{ .memory = true, .cr0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .ctr = true, .xer = true }); |
| 32 | 20 | } |
| 33 | 21 | |
| 34 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 22 | pub fn syscall1(number: SYS, arg1: u32) u32 { | |
| 35 | 23 | // r0 is both an input and a clobber. |
| 36 | var r0_out: usize = undefined; | |
| 24 | var r0_out: u32 = undefined; | |
| 37 | 25 | return asm volatile ( |
| 38 | 26 | \\ sc |
| 39 | 27 | \\ bns+ 1f |
| 40 | 28 | \\ neg 3, 3 |
| 41 | 29 | \\ 1: |
| 42 | : [ret] "={r3}" (-> usize), | |
| 30 | : [ret] "={r3}" (-> u32), | |
| 43 | 31 | [r0_out] "={r0}" (r0_out), |
| 44 | 32 | : [number] "{r0}" (@intFromEnum(number)), |
| 45 | 33 | [arg1] "{r3}" (arg1), |
| 46 | 34 | : .{ .memory = true, .cr0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .ctr = true, .xer = true }); |
| 47 | 35 | } |
| 48 | 36 | |
| 49 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 37 | pub fn syscall2(number: SYS, arg1: u32, arg2: u32) u32 { | |
| 50 | 38 | // These registers are both inputs and clobbers. |
| 51 | var r0_out: usize = undefined; | |
| 52 | var r4_out: usize = undefined; | |
| 39 | var r0_out: u32 = undefined; | |
| 40 | var r4_out: u32 = undefined; | |
| 53 | 41 | return asm volatile ( |
| 54 | 42 | \\ sc |
| 55 | 43 | \\ bns+ 1f |
| 56 | 44 | \\ neg 3, 3 |
| 57 | 45 | \\ 1: |
| 58 | : [ret] "={r3}" (-> usize), | |
| 46 | : [ret] "={r3}" (-> u32), | |
| 59 | 47 | [r0_out] "={r0}" (r0_out), |
| 60 | 48 | [r4_out] "={r4}" (r4_out), |
| 61 | 49 | : [number] "{r0}" (@intFromEnum(number)), |
| ... | ... | @@ -64,17 +52,17 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { |
| 64 | 52 | : .{ .memory = true, .cr0 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .ctr = true, .xer = true }); |
| 65 | 53 | } |
| 66 | 54 | |
| 67 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 55 | pub fn syscall3(number: SYS, arg1: u32, arg2: u32, arg3: u32) u32 { | |
| 68 | 56 | // These registers are both inputs and clobbers. |
| 69 | var r0_out: usize = undefined; | |
| 70 | var r4_out: usize = undefined; | |
| 71 | var r5_out: usize = undefined; | |
| 57 | var r0_out: u32 = undefined; | |
| 58 | var r4_out: u32 = undefined; | |
| 59 | var r5_out: u32 = undefined; | |
| 72 | 60 | return asm volatile ( |
| 73 | 61 | \\ sc |
| 74 | 62 | \\ bns+ 1f |
| 75 | 63 | \\ neg 3, 3 |
| 76 | 64 | \\ 1: |
| 77 | : [ret] "={r3}" (-> usize), | |
| 65 | : [ret] "={r3}" (-> u32), | |
| 78 | 66 | [r0_out] "={r0}" (r0_out), |
| 79 | 67 | [r4_out] "={r4}" (r4_out), |
| 80 | 68 | [r5_out] "={r5}" (r5_out), |
| ... | ... | @@ -85,18 +73,18 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 85 | 73 | : .{ .memory = true, .cr0 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .ctr = true, .xer = true }); |
| 86 | 74 | } |
| 87 | 75 | |
| 88 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 76 | pub fn syscall4(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32) u32 { | |
| 89 | 77 | // These registers are both inputs and clobbers. |
| 90 | var r0_out: usize = undefined; | |
| 91 | var r4_out: usize = undefined; | |
| 92 | var r5_out: usize = undefined; | |
| 93 | var r6_out: usize = undefined; | |
| 78 | var r0_out: u32 = undefined; | |
| 79 | var r4_out: u32 = undefined; | |
| 80 | var r5_out: u32 = undefined; | |
| 81 | var r6_out: u32 = undefined; | |
| 94 | 82 | return asm volatile ( |
| 95 | 83 | \\ sc |
| 96 | 84 | \\ bns+ 1f |
| 97 | 85 | \\ neg 3, 3 |
| 98 | 86 | \\ 1: |
| 99 | : [ret] "={r3}" (-> usize), | |
| 87 | : [ret] "={r3}" (-> u32), | |
| 100 | 88 | [r0_out] "={r0}" (r0_out), |
| 101 | 89 | [r4_out] "={r4}" (r4_out), |
| 102 | 90 | [r5_out] "={r5}" (r5_out), |
| ... | ... | @@ -109,19 +97,19 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 109 | 97 | : .{ .memory = true, .cr0 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .ctr = true, .xer = true }); |
| 110 | 98 | } |
| 111 | 99 | |
| 112 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 100 | pub fn syscall5(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32, arg5: u32) u32 { | |
| 113 | 101 | // These registers are both inputs and clobbers. |
| 114 | var r0_out: usize = undefined; | |
| 115 | var r4_out: usize = undefined; | |
| 116 | var r5_out: usize = undefined; | |
| 117 | var r6_out: usize = undefined; | |
| 118 | var r7_out: usize = undefined; | |
| 102 | var r0_out: u32 = undefined; | |
| 103 | var r4_out: u32 = undefined; | |
| 104 | var r5_out: u32 = undefined; | |
| 105 | var r6_out: u32 = undefined; | |
| 106 | var r7_out: u32 = undefined; | |
| 119 | 107 | return asm volatile ( |
| 120 | 108 | \\ sc |
| 121 | 109 | \\ bns+ 1f |
| 122 | 110 | \\ neg 3, 3 |
| 123 | 111 | \\ 1: |
| 124 | : [ret] "={r3}" (-> usize), | |
| 112 | : [ret] "={r3}" (-> u32), | |
| 125 | 113 | [r0_out] "={r0}" (r0_out), |
| 126 | 114 | [r4_out] "={r4}" (r4_out), |
| 127 | 115 | [r5_out] "={r5}" (r5_out), |
| ... | ... | @@ -138,26 +126,26 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 138 | 126 | |
| 139 | 127 | pub fn syscall6( |
| 140 | 128 | number: SYS, |
| 141 | arg1: usize, | |
| 142 | arg2: usize, | |
| 143 | arg3: usize, | |
| 144 | arg4: usize, | |
| 145 | arg5: usize, | |
| 146 | arg6: usize, | |
| 147 | ) usize { | |
| 129 | arg1: u32, | |
| 130 | arg2: u32, | |
| 131 | arg3: u32, | |
| 132 | arg4: u32, | |
| 133 | arg5: u32, | |
| 134 | arg6: u32, | |
| 135 | ) u32 { | |
| 148 | 136 | // These registers are both inputs and clobbers. |
| 149 | var r0_out: usize = undefined; | |
| 150 | var r4_out: usize = undefined; | |
| 151 | var r5_out: usize = undefined; | |
| 152 | var r6_out: usize = undefined; | |
| 153 | var r7_out: usize = undefined; | |
| 154 | var r8_out: usize = undefined; | |
| 137 | var r0_out: u32 = undefined; | |
| 138 | var r4_out: u32 = undefined; | |
| 139 | var r5_out: u32 = undefined; | |
| 140 | var r6_out: u32 = undefined; | |
| 141 | var r7_out: u32 = undefined; | |
| 142 | var r8_out: u32 = undefined; | |
| 155 | 143 | return asm volatile ( |
| 156 | 144 | \\ sc |
| 157 | 145 | \\ bns+ 1f |
| 158 | 146 | \\ neg 3, 3 |
| 159 | 147 | \\ 1: |
| 160 | : [ret] "={r3}" (-> usize), | |
| 148 | : [ret] "={r3}" (-> u32), | |
| 161 | 149 | [r0_out] "={r0}" (r0_out), |
| 162 | 150 | [r4_out] "={r4}" (r4_out), |
| 163 | 151 | [r5_out] "={r5}" (r5_out), |
| ... | ... | @@ -174,7 +162,7 @@ pub fn syscall6( |
| 174 | 162 | : .{ .memory = true, .cr0 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .ctr = true, .xer = true }); |
| 175 | 163 | } |
| 176 | 164 | |
| 177 | pub fn clone() callconv(.naked) usize { | |
| 165 | pub fn clone() callconv(.naked) u32 { | |
| 178 | 166 | // __clone(func, stack, flags, arg, ptid, tls, ctid) |
| 179 | 167 | // 3, 4, 5, 6, 7, 8, 9 |
| 180 | 168 | // |
| ... | ... | @@ -247,14 +235,14 @@ pub fn clone() callconv(.naked) usize { |
| 247 | 235 | pub const restore = restore_rt; |
| 248 | 236 | |
| 249 | 237 | pub fn restore_rt() callconv(.naked) noreturn { |
| 250 | switch (@import("builtin").zig_backend) { | |
| 238 | switch (builtin.zig_backend) { | |
| 251 | 239 | .stage2_c => asm volatile ( |
| 252 | 240 | \\ li 0, %[number] |
| 253 | 241 | \\ sc |
| 254 | 242 | : |
| 255 | 243 | : [number] "i" (@intFromEnum(SYS.rt_sigreturn)), |
| 256 | 244 | ), |
| 257 | else => _ = asm volatile ( | |
| 245 | else => asm volatile ( | |
| 258 | 246 | \\ sc |
| 259 | 247 | : |
| 260 | 248 | : [number] "{r0}" (@intFromEnum(SYS.rt_sigreturn)), |
| ... | ... | @@ -262,48 +250,14 @@ pub fn restore_rt() callconv(.naked) noreturn { |
| 262 | 250 | } |
| 263 | 251 | } |
| 264 | 252 | |
| 265 | pub const F = struct { | |
| 266 | pub const DUPFD = 0; | |
| 267 | pub const GETFD = 1; | |
| 268 | pub const SETFD = 2; | |
| 269 | pub const GETFL = 3; | |
| 270 | pub const SETFL = 4; | |
| 271 | ||
| 272 | pub const SETOWN = 8; | |
| 273 | pub const GETOWN = 9; | |
| 274 | pub const SETSIG = 10; | |
| 275 | pub const GETSIG = 11; | |
| 276 | ||
| 277 | pub const GETLK = 12; | |
| 278 | pub const SETLK = 13; | |
| 279 | pub const SETLKW = 14; | |
| 280 | ||
| 281 | pub const SETOWN_EX = 15; | |
| 282 | pub const GETOWN_EX = 16; | |
| 283 | ||
| 284 | pub const GETOWNER_UIDS = 17; | |
| 285 | ||
| 286 | pub const RDLCK = 0; | |
| 287 | pub const WRLCK = 1; | |
| 288 | pub const UNLCK = 2; | |
| 289 | }; | |
| 290 | ||
| 291 | 253 | pub const VDSO = struct { |
| 292 | 254 | pub const CGT_SYM = "__kernel_clock_gettime"; |
| 293 | 255 | pub const CGT_VER = "LINUX_2.6.15"; |
| 294 | 256 | }; |
| 295 | 257 | |
| 296 | pub const Flock = extern struct { | |
| 297 | type: i16, | |
| 298 | whence: i16, | |
| 299 | start: off_t, | |
| 300 | len: off_t, | |
| 301 | pid: pid_t, | |
| 302 | }; | |
| 303 | ||
| 304 | 258 | pub const blksize_t = i32; |
| 305 | 259 | pub const nlink_t = u32; |
| 306 | pub const time_t = isize; | |
| 260 | pub const time_t = i32; | |
| 307 | 261 | pub const mode_t = u32; |
| 308 | 262 | pub const off_t = i64; |
| 309 | 263 | pub const ino_t = u64; |
| ... | ... | @@ -316,39 +270,27 @@ pub const Stat = extern struct { |
| 316 | 270 | ino: ino_t, |
| 317 | 271 | mode: mode_t, |
| 318 | 272 | nlink: nlink_t, |
| 319 | uid: uid_t, | |
| 320 | gid: gid_t, | |
| 273 | uid: std.os.linux.uid_t, | |
| 274 | gid: std.os.linux.gid_t, | |
| 321 | 275 | rdev: dev_t, |
| 322 | 276 | __rdev_padding: i16, |
| 323 | 277 | size: off_t, |
| 324 | 278 | blksize: blksize_t, |
| 325 | 279 | blocks: blkcnt_t, |
| 326 | atim: timespec, | |
| 327 | mtim: timespec, | |
| 328 | ctim: timespec, | |
| 280 | atim: std.os.linux.timespec, | |
| 281 | mtim: std.os.linux.timespec, | |
| 282 | ctim: std.os.linux.timespec, | |
| 329 | 283 | __unused: [2]u32, |
| 330 | 284 | |
| 331 | pub fn atime(self: @This()) timespec { | |
| 285 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 332 | 286 | return self.atim; |
| 333 | 287 | } |
| 334 | 288 | |
| 335 | pub fn mtime(self: @This()) timespec { | |
| 289 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 336 | 290 | return self.mtim; |
| 337 | 291 | } |
| 338 | 292 | |
| 339 | pub fn ctime(self: @This()) timespec { | |
| 293 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 340 | 294 | return self.ctim; |
| 341 | 295 | } |
| 342 | 296 | }; |
| 343 | ||
| 344 | pub const timeval = extern struct { | |
| 345 | sec: time_t, | |
| 346 | usec: isize, | |
| 347 | }; | |
| 348 | ||
| 349 | pub const timezone = extern struct { | |
| 350 | minuteswest: i32, | |
| 351 | dsttime: i32, | |
| 352 | }; | |
| 353 | ||
| 354 | pub const Elf_Symndx = u32; |
lib/std/os/linux/powerpc64.zig+54-113| ... | ... | @@ -1,61 +1,49 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("../../std.zig"); |
| 3 | const maxInt = std.math.maxInt; | |
| 4 | const linux = std.os.linux; | |
| 5 | const SYS = linux.SYS; | |
| 6 | const socklen_t = linux.socklen_t; | |
| 7 | const iovec = std.posix.iovec; | |
| 8 | const iovec_const = std.posix.iovec_const; | |
| 9 | const uid_t = linux.uid_t; | |
| 10 | const gid_t = linux.gid_t; | |
| 11 | const pid_t = linux.pid_t; | |
| 12 | const stack_t = linux.stack_t; | |
| 13 | const sigset_t = linux.sigset_t; | |
| 14 | const sockaddr = linux.sockaddr; | |
| 15 | const timespec = linux.timespec; | |
| 3 | const SYS = std.os.linux.SYS; | |
| 16 | 4 | |
| 17 | pub fn syscall0(number: SYS) usize { | |
| 5 | pub fn syscall0(number: SYS) u64 { | |
| 18 | 6 | // r0 is both an input register and a clobber. musl and glibc achieve this with |
| 19 | 7 | // a "+" constraint, which isn't supported in Zig, so instead we separately list |
| 20 | 8 | // r0 as both an input and an output. (Listing it as an input and a clobber would |
| 21 | 9 | // cause the C backend to emit invalid code; see #25209.) |
| 22 | var r0_out: usize = undefined; | |
| 10 | var r0_out: u64 = undefined; | |
| 23 | 11 | return asm volatile ( |
| 24 | 12 | \\ sc |
| 25 | 13 | \\ bns+ 1f |
| 26 | 14 | \\ neg 3, 3 |
| 27 | 15 | \\ 1: |
| 28 | : [ret] "={r3}" (-> usize), | |
| 16 | : [ret] "={r3}" (-> u64), | |
| 29 | 17 | [r0_out] "={r0}" (r0_out), |
| 30 | 18 | : [number] "{r0}" (@intFromEnum(number)), |
| 31 | 19 | : .{ .memory = true, .cr0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .ctr = true, .xer = true }); |
| 32 | 20 | } |
| 33 | 21 | |
| 34 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 22 | pub fn syscall1(number: SYS, arg1: u64) u64 { | |
| 35 | 23 | // r0 is both an input and a clobber. |
| 36 | var r0_out: usize = undefined; | |
| 24 | var r0_out: u64 = undefined; | |
| 37 | 25 | return asm volatile ( |
| 38 | 26 | \\ sc |
| 39 | 27 | \\ bns+ 1f |
| 40 | 28 | \\ neg 3, 3 |
| 41 | 29 | \\ 1: |
| 42 | : [ret] "={r3}" (-> usize), | |
| 30 | : [ret] "={r3}" (-> u64), | |
| 43 | 31 | [r0_out] "={r0}" (r0_out), |
| 44 | 32 | : [number] "{r0}" (@intFromEnum(number)), |
| 45 | 33 | [arg1] "{r3}" (arg1), |
| 46 | 34 | : .{ .memory = true, .cr0 = true, .r4 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .ctr = true, .xer = true }); |
| 47 | 35 | } |
| 48 | 36 | |
| 49 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 37 | pub fn syscall2(number: SYS, arg1: u64, arg2: u64) u64 { | |
| 50 | 38 | // These registers are both inputs and clobbers. |
| 51 | var r0_out: usize = undefined; | |
| 52 | var r4_out: usize = undefined; | |
| 39 | var r0_out: u64 = undefined; | |
| 40 | var r4_out: u64 = undefined; | |
| 53 | 41 | return asm volatile ( |
| 54 | 42 | \\ sc |
| 55 | 43 | \\ bns+ 1f |
| 56 | 44 | \\ neg 3, 3 |
| 57 | 45 | \\ 1: |
| 58 | : [ret] "={r3}" (-> usize), | |
| 46 | : [ret] "={r3}" (-> u64), | |
| 59 | 47 | [r0_out] "={r0}" (r0_out), |
| 60 | 48 | [r4_out] "={r4}" (r4_out), |
| 61 | 49 | : [number] "{r0}" (@intFromEnum(number)), |
| ... | ... | @@ -64,17 +52,17 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { |
| 64 | 52 | : .{ .memory = true, .cr0 = true, .r5 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .ctr = true, .xer = true }); |
| 65 | 53 | } |
| 66 | 54 | |
| 67 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 55 | pub fn syscall3(number: SYS, arg1: u64, arg2: u64, arg3: u64) u64 { | |
| 68 | 56 | // These registers are both inputs and clobbers. |
| 69 | var r0_out: usize = undefined; | |
| 70 | var r4_out: usize = undefined; | |
| 71 | var r5_out: usize = undefined; | |
| 57 | var r0_out: u64 = undefined; | |
| 58 | var r4_out: u64 = undefined; | |
| 59 | var r5_out: u64 = undefined; | |
| 72 | 60 | return asm volatile ( |
| 73 | 61 | \\ sc |
| 74 | 62 | \\ bns+ 1f |
| 75 | 63 | \\ neg 3, 3 |
| 76 | 64 | \\ 1: |
| 77 | : [ret] "={r3}" (-> usize), | |
| 65 | : [ret] "={r3}" (-> u64), | |
| 78 | 66 | [r0_out] "={r0}" (r0_out), |
| 79 | 67 | [r4_out] "={r4}" (r4_out), |
| 80 | 68 | [r5_out] "={r5}" (r5_out), |
| ... | ... | @@ -85,18 +73,18 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 85 | 73 | : .{ .memory = true, .cr0 = true, .r6 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .ctr = true, .xer = true }); |
| 86 | 74 | } |
| 87 | 75 | |
| 88 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 76 | pub fn syscall4(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64) u64 { | |
| 89 | 77 | // These registers are both inputs and clobbers. |
| 90 | var r0_out: usize = undefined; | |
| 91 | var r4_out: usize = undefined; | |
| 92 | var r5_out: usize = undefined; | |
| 93 | var r6_out: usize = undefined; | |
| 78 | var r0_out: u64 = undefined; | |
| 79 | var r4_out: u64 = undefined; | |
| 80 | var r5_out: u64 = undefined; | |
| 81 | var r6_out: u64 = undefined; | |
| 94 | 82 | return asm volatile ( |
| 95 | 83 | \\ sc |
| 96 | 84 | \\ bns+ 1f |
| 97 | 85 | \\ neg 3, 3 |
| 98 | 86 | \\ 1: |
| 99 | : [ret] "={r3}" (-> usize), | |
| 87 | : [ret] "={r3}" (-> u64), | |
| 100 | 88 | [r0_out] "={r0}" (r0_out), |
| 101 | 89 | [r4_out] "={r4}" (r4_out), |
| 102 | 90 | [r5_out] "={r5}" (r5_out), |
| ... | ... | @@ -109,19 +97,19 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 109 | 97 | : .{ .memory = true, .cr0 = true, .r7 = true, .r8 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .ctr = true, .xer = true }); |
| 110 | 98 | } |
| 111 | 99 | |
| 112 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 100 | pub fn syscall5(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) u64 { | |
| 113 | 101 | // These registers are both inputs and clobbers. |
| 114 | var r0_out: usize = undefined; | |
| 115 | var r4_out: usize = undefined; | |
| 116 | var r5_out: usize = undefined; | |
| 117 | var r6_out: usize = undefined; | |
| 118 | var r7_out: usize = undefined; | |
| 102 | var r0_out: u64 = undefined; | |
| 103 | var r4_out: u64 = undefined; | |
| 104 | var r5_out: u64 = undefined; | |
| 105 | var r6_out: u64 = undefined; | |
| 106 | var r7_out: u64 = undefined; | |
| 119 | 107 | return asm volatile ( |
| 120 | 108 | \\ sc |
| 121 | 109 | \\ bns+ 1f |
| 122 | 110 | \\ neg 3, 3 |
| 123 | 111 | \\ 1: |
| 124 | : [ret] "={r3}" (-> usize), | |
| 112 | : [ret] "={r3}" (-> u64), | |
| 125 | 113 | [r0_out] "={r0}" (r0_out), |
| 126 | 114 | [r4_out] "={r4}" (r4_out), |
| 127 | 115 | [r5_out] "={r5}" (r5_out), |
| ... | ... | @@ -138,26 +126,26 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 138 | 126 | |
| 139 | 127 | pub fn syscall6( |
| 140 | 128 | number: SYS, |
| 141 | arg1: usize, | |
| 142 | arg2: usize, | |
| 143 | arg3: usize, | |
| 144 | arg4: usize, | |
| 145 | arg5: usize, | |
| 146 | arg6: usize, | |
| 147 | ) usize { | |
| 129 | arg1: u64, | |
| 130 | arg2: u64, | |
| 131 | arg3: u64, | |
| 132 | arg4: u64, | |
| 133 | arg5: u64, | |
| 134 | arg6: u64, | |
| 135 | ) u64 { | |
| 148 | 136 | // These registers are both inputs and clobbers. |
| 149 | var r0_out: usize = undefined; | |
| 150 | var r4_out: usize = undefined; | |
| 151 | var r5_out: usize = undefined; | |
| 152 | var r6_out: usize = undefined; | |
| 153 | var r7_out: usize = undefined; | |
| 154 | var r8_out: usize = undefined; | |
| 137 | var r0_out: u64 = undefined; | |
| 138 | var r4_out: u64 = undefined; | |
| 139 | var r5_out: u64 = undefined; | |
| 140 | var r6_out: u64 = undefined; | |
| 141 | var r7_out: u64 = undefined; | |
| 142 | var r8_out: u64 = undefined; | |
| 155 | 143 | return asm volatile ( |
| 156 | 144 | \\ sc |
| 157 | 145 | \\ bns+ 1f |
| 158 | 146 | \\ neg 3, 3 |
| 159 | 147 | \\ 1: |
| 160 | : [ret] "={r3}" (-> usize), | |
| 148 | : [ret] "={r3}" (-> u64), | |
| 161 | 149 | [r0_out] "={r0}" (r0_out), |
| 162 | 150 | [r4_out] "={r4}" (r4_out), |
| 163 | 151 | [r5_out] "={r5}" (r5_out), |
| ... | ... | @@ -174,7 +162,7 @@ pub fn syscall6( |
| 174 | 162 | : .{ .memory = true, .cr0 = true, .r9 = true, .r10 = true, .r11 = true, .r12 = true, .ctr = true, .xer = true }); |
| 175 | 163 | } |
| 176 | 164 | |
| 177 | pub fn clone() callconv(.naked) usize { | |
| 165 | pub fn clone() callconv(.naked) u64 { | |
| 178 | 166 | // __clone(func, stack, flags, arg, ptid, tls, ctid) |
| 179 | 167 | // 3, 4, 5, 6, 7, 8, 9 |
| 180 | 168 | // |
| ... | ... | @@ -232,14 +220,14 @@ pub fn clone() callconv(.naked) usize { |
| 232 | 220 | pub const restore = restore_rt; |
| 233 | 221 | |
| 234 | 222 | pub fn restore_rt() callconv(.naked) noreturn { |
| 235 | switch (@import("builtin").zig_backend) { | |
| 223 | switch (builtin.zig_backend) { | |
| 236 | 224 | .stage2_c => asm volatile ( |
| 237 | 225 | \\ li 0, %[number] |
| 238 | 226 | \\ sc |
| 239 | 227 | : |
| 240 | 228 | : [number] "i" (@intFromEnum(SYS.rt_sigreturn)), |
| 241 | 229 | ), |
| 242 | else => _ = asm volatile ( | |
| 230 | else => asm volatile ( | |
| 243 | 231 | \\ sc |
| 244 | 232 | : |
| 245 | 233 | : [number] "{r0}" (@intFromEnum(SYS.rt_sigreturn)), |
| ... | ... | @@ -247,46 +235,11 @@ pub fn restore_rt() callconv(.naked) noreturn { |
| 247 | 235 | } |
| 248 | 236 | } |
| 249 | 237 | |
| 250 | pub const F = struct { | |
| 251 | pub const DUPFD = 0; | |
| 252 | pub const GETFD = 1; | |
| 253 | pub const SETFD = 2; | |
| 254 | pub const GETFL = 3; | |
| 255 | pub const SETFL = 4; | |
| 256 | ||
| 257 | pub const SETOWN = 8; | |
| 258 | pub const GETOWN = 9; | |
| 259 | pub const SETSIG = 10; | |
| 260 | pub const GETSIG = 11; | |
| 261 | ||
| 262 | pub const GETLK = 5; | |
| 263 | pub const SETLK = 6; | |
| 264 | pub const SETLKW = 7; | |
| 265 | ||
| 266 | pub const RDLCK = 0; | |
| 267 | pub const WRLCK = 1; | |
| 268 | pub const UNLCK = 2; | |
| 269 | ||
| 270 | pub const SETOWN_EX = 15; | |
| 271 | pub const GETOWN_EX = 16; | |
| 272 | ||
| 273 | pub const GETOWNER_UIDS = 17; | |
| 274 | }; | |
| 275 | ||
| 276 | 238 | pub const VDSO = struct { |
| 277 | 239 | pub const CGT_SYM = "__kernel_clock_gettime"; |
| 278 | 240 | pub const CGT_VER = "LINUX_2.6.15"; |
| 279 | 241 | }; |
| 280 | 242 | |
| 281 | pub const Flock = extern struct { | |
| 282 | type: i16, | |
| 283 | whence: i16, | |
| 284 | start: off_t, | |
| 285 | len: off_t, | |
| 286 | pid: pid_t, | |
| 287 | __unused: [4]u8, | |
| 288 | }; | |
| 289 | ||
| 290 | 243 | pub const blksize_t = i64; |
| 291 | 244 | pub const nlink_t = u64; |
| 292 | 245 | pub const time_t = i64; |
| ... | ... | @@ -302,38 +255,26 @@ pub const Stat = extern struct { |
| 302 | 255 | ino: ino_t, |
| 303 | 256 | nlink: nlink_t, |
| 304 | 257 | mode: mode_t, |
| 305 | uid: uid_t, | |
| 306 | gid: gid_t, | |
| 258 | uid: std.os.linux.uid_t, | |
| 259 | gid: std.os.linux.gid_t, | |
| 307 | 260 | rdev: dev_t, |
| 308 | 261 | size: off_t, |
| 309 | 262 | blksize: blksize_t, |
| 310 | 263 | blocks: blkcnt_t, |
| 311 | atim: timespec, | |
| 312 | mtim: timespec, | |
| 313 | ctim: timespec, | |
| 264 | atim: std.os.linux.timespec, | |
| 265 | mtim: std.os.linux.timespec, | |
| 266 | ctim: std.os.linux.timespec, | |
| 314 | 267 | __unused: [3]u64, |
| 315 | 268 | |
| 316 | pub fn atime(self: @This()) timespec { | |
| 269 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 317 | 270 | return self.atim; |
| 318 | 271 | } |
| 319 | 272 | |
| 320 | pub fn mtime(self: @This()) timespec { | |
| 273 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 321 | 274 | return self.mtim; |
| 322 | 275 | } |
| 323 | 276 | |
| 324 | pub fn ctime(self: @This()) timespec { | |
| 277 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 325 | 278 | return self.ctim; |
| 326 | 279 | } |
| 327 | 280 | }; |
| 328 | ||
| 329 | pub const timeval = extern struct { | |
| 330 | sec: isize, | |
| 331 | usec: isize, | |
| 332 | }; | |
| 333 | ||
| 334 | pub const timezone = extern struct { | |
| 335 | minuteswest: i32, | |
| 336 | dsttime: i32, | |
| 337 | }; | |
| 338 | ||
| 339 | pub const Elf_Symndx = u32; |
lib/std/os/linux/riscv32.zig+31-82| ... | ... | @@ -1,45 +1,34 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("../../std.zig"); |
| 3 | const iovec = std.posix.iovec; | |
| 4 | const iovec_const = std.posix.iovec_const; | |
| 5 | const linux = std.os.linux; | |
| 6 | const SYS = linux.SYS; | |
| 7 | const uid_t = std.os.linux.uid_t; | |
| 8 | const gid_t = std.os.linux.gid_t; | |
| 9 | const pid_t = std.os.linux.pid_t; | |
| 10 | const stack_t = linux.stack_t; | |
| 11 | const sigset_t = linux.sigset_t; | |
| 12 | const sockaddr = linux.sockaddr; | |
| 13 | const socklen_t = linux.socklen_t; | |
| 14 | const timespec = std.os.linux.timespec; | |
| 3 | const SYS = std.os.linux.SYS; | |
| 15 | 4 | |
| 16 | pub fn syscall0(number: SYS) usize { | |
| 5 | pub fn syscall0(number: SYS) u32 { | |
| 17 | 6 | return asm volatile ("ecall" |
| 18 | : [ret] "={x10}" (-> usize), | |
| 7 | : [ret] "={x10}" (-> u32), | |
| 19 | 8 | : [number] "{x17}" (@intFromEnum(number)), |
| 20 | 9 | : .{ .memory = true }); |
| 21 | 10 | } |
| 22 | 11 | |
| 23 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 12 | pub fn syscall1(number: SYS, arg1: u32) u32 { | |
| 24 | 13 | return asm volatile ("ecall" |
| 25 | : [ret] "={x10}" (-> usize), | |
| 14 | : [ret] "={x10}" (-> u32), | |
| 26 | 15 | : [number] "{x17}" (@intFromEnum(number)), |
| 27 | 16 | [arg1] "{x10}" (arg1), |
| 28 | 17 | : .{ .memory = true }); |
| 29 | 18 | } |
| 30 | 19 | |
| 31 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 20 | pub fn syscall2(number: SYS, arg1: u32, arg2: u32) u32 { | |
| 32 | 21 | return asm volatile ("ecall" |
| 33 | : [ret] "={x10}" (-> usize), | |
| 22 | : [ret] "={x10}" (-> u32), | |
| 34 | 23 | : [number] "{x17}" (@intFromEnum(number)), |
| 35 | 24 | [arg1] "{x10}" (arg1), |
| 36 | 25 | [arg2] "{x11}" (arg2), |
| 37 | 26 | : .{ .memory = true }); |
| 38 | 27 | } |
| 39 | 28 | |
| 40 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 29 | pub fn syscall3(number: SYS, arg1: u32, arg2: u32, arg3: u32) u32 { | |
| 41 | 30 | return asm volatile ("ecall" |
| 42 | : [ret] "={x10}" (-> usize), | |
| 31 | : [ret] "={x10}" (-> u32), | |
| 43 | 32 | : [number] "{x17}" (@intFromEnum(number)), |
| 44 | 33 | [arg1] "{x10}" (arg1), |
| 45 | 34 | [arg2] "{x11}" (arg2), |
| ... | ... | @@ -47,9 +36,9 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 47 | 36 | : .{ .memory = true }); |
| 48 | 37 | } |
| 49 | 38 | |
| 50 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 39 | pub fn syscall4(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32) u32 { | |
| 51 | 40 | return asm volatile ("ecall" |
| 52 | : [ret] "={x10}" (-> usize), | |
| 41 | : [ret] "={x10}" (-> u32), | |
| 53 | 42 | : [number] "{x17}" (@intFromEnum(number)), |
| 54 | 43 | [arg1] "{x10}" (arg1), |
| 55 | 44 | [arg2] "{x11}" (arg2), |
| ... | ... | @@ -58,9 +47,9 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 58 | 47 | : .{ .memory = true }); |
| 59 | 48 | } |
| 60 | 49 | |
| 61 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 50 | pub fn syscall5(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32, arg5: u32) u32 { | |
| 62 | 51 | return asm volatile ("ecall" |
| 63 | : [ret] "={x10}" (-> usize), | |
| 52 | : [ret] "={x10}" (-> u32), | |
| 64 | 53 | : [number] "{x17}" (@intFromEnum(number)), |
| 65 | 54 | [arg1] "{x10}" (arg1), |
| 66 | 55 | [arg2] "{x11}" (arg2), |
| ... | ... | @@ -72,15 +61,15 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 72 | 61 | |
| 73 | 62 | pub fn syscall6( |
| 74 | 63 | number: SYS, |
| 75 | arg1: usize, | |
| 76 | arg2: usize, | |
| 77 | arg3: usize, | |
| 78 | arg4: usize, | |
| 79 | arg5: usize, | |
| 80 | arg6: usize, | |
| 81 | ) usize { | |
| 64 | arg1: u32, | |
| 65 | arg2: u32, | |
| 66 | arg3: u32, | |
| 67 | arg4: u32, | |
| 68 | arg5: u32, | |
| 69 | arg6: u32, | |
| 70 | ) u32 { | |
| 82 | 71 | return asm volatile ("ecall" |
| 83 | : [ret] "={x10}" (-> usize), | |
| 72 | : [ret] "={x10}" (-> u32), | |
| 84 | 73 | : [number] "{x17}" (@intFromEnum(number)), |
| 85 | 74 | [arg1] "{x10}" (arg1), |
| 86 | 75 | [arg2] "{x11}" (arg2), |
| ... | ... | @@ -91,7 +80,7 @@ pub fn syscall6( |
| 91 | 80 | : .{ .memory = true }); |
| 92 | 81 | } |
| 93 | 82 | |
| 94 | pub fn clone() callconv(.naked) usize { | |
| 83 | pub fn clone() callconv(.naked) u32 { | |
| 95 | 84 | // __clone(func, stack, flags, arg, ptid, tls, ctid) |
| 96 | 85 | // a0, a1, a2, a3, a4, a5, a6 |
| 97 | 86 | // |
| ... | ... | @@ -135,30 +124,6 @@ pub fn clone() callconv(.naked) usize { |
| 135 | 124 | ); |
| 136 | 125 | } |
| 137 | 126 | |
| 138 | pub const F = struct { | |
| 139 | pub const DUPFD = 0; | |
| 140 | pub const GETFD = 1; | |
| 141 | pub const SETFD = 2; | |
| 142 | pub const GETFL = 3; | |
| 143 | pub const SETFL = 4; | |
| 144 | pub const GETLK = 5; | |
| 145 | pub const SETLK = 6; | |
| 146 | pub const SETLKW = 7; | |
| 147 | pub const SETOWN = 8; | |
| 148 | pub const GETOWN = 9; | |
| 149 | pub const SETSIG = 10; | |
| 150 | pub const GETSIG = 11; | |
| 151 | ||
| 152 | pub const RDLCK = 0; | |
| 153 | pub const WRLCK = 1; | |
| 154 | pub const UNLCK = 2; | |
| 155 | ||
| 156 | pub const SETOWN_EX = 15; | |
| 157 | pub const GETOWN_EX = 16; | |
| 158 | ||
| 159 | pub const GETOWNER_UIDS = 17; | |
| 160 | }; | |
| 161 | ||
| 162 | 127 | pub const blksize_t = i32; |
| 163 | 128 | pub const nlink_t = u32; |
| 164 | 129 | pub const time_t = i64; |
| ... | ... | @@ -168,54 +133,38 @@ pub const ino_t = u64; |
| 168 | 133 | pub const dev_t = u64; |
| 169 | 134 | pub const blkcnt_t = i64; |
| 170 | 135 | |
| 171 | pub const timeval = extern struct { | |
| 172 | sec: time_t, | |
| 173 | usec: i64, | |
| 174 | }; | |
| 175 | ||
| 176 | pub const Flock = extern struct { | |
| 177 | type: i16, | |
| 178 | whence: i16, | |
| 179 | start: off_t, | |
| 180 | len: off_t, | |
| 181 | pid: pid_t, | |
| 182 | __unused: [4]u8, | |
| 183 | }; | |
| 184 | ||
| 185 | 136 | // The `stat` definition used by the Linux kernel. |
| 186 | 137 | pub const Stat = extern struct { |
| 187 | 138 | dev: dev_t, |
| 188 | 139 | ino: ino_t, |
| 189 | 140 | mode: mode_t, |
| 190 | 141 | nlink: nlink_t, |
| 191 | uid: uid_t, | |
| 192 | gid: gid_t, | |
| 142 | uid: std.os.linux.uid_t, | |
| 143 | gid: std.os.linux.gid_t, | |
| 193 | 144 | rdev: dev_t, |
| 194 | __pad: usize, | |
| 145 | __pad: u32, | |
| 195 | 146 | size: off_t, |
| 196 | 147 | blksize: blksize_t, |
| 197 | 148 | __pad2: i32, |
| 198 | 149 | blocks: blkcnt_t, |
| 199 | atim: timespec, | |
| 200 | mtim: timespec, | |
| 201 | ctim: timespec, | |
| 150 | atim: std.os.linux.timespec, | |
| 151 | mtim: std.os.linux.timespec, | |
| 152 | ctim: std.os.linux.timespec, | |
| 202 | 153 | __unused: [2]u32, |
| 203 | 154 | |
| 204 | pub fn atime(self: @This()) timespec { | |
| 155 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 205 | 156 | return self.atim; |
| 206 | 157 | } |
| 207 | 158 | |
| 208 | pub fn mtime(self: @This()) timespec { | |
| 159 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 209 | 160 | return self.mtim; |
| 210 | 161 | } |
| 211 | 162 | |
| 212 | pub fn ctime(self: @This()) timespec { | |
| 163 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 213 | 164 | return self.ctim; |
| 214 | 165 | } |
| 215 | 166 | }; |
| 216 | 167 | |
| 217 | pub const Elf_Symndx = u32; | |
| 218 | ||
| 219 | 168 | pub const VDSO = struct { |
| 220 | 169 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 221 | 170 | pub const CGT_VER = "LINUX_4.15"; |
lib/std/os/linux/riscv64.zig+31-82| ... | ... | @@ -1,45 +1,34 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("../../std.zig"); |
| 3 | const iovec = std.posix.iovec; | |
| 4 | const iovec_const = std.posix.iovec_const; | |
| 5 | const linux = std.os.linux; | |
| 6 | const SYS = linux.SYS; | |
| 7 | const uid_t = std.os.linux.uid_t; | |
| 8 | const gid_t = std.os.linux.gid_t; | |
| 9 | const pid_t = std.os.linux.pid_t; | |
| 10 | const stack_t = linux.stack_t; | |
| 11 | const sigset_t = linux.sigset_t; | |
| 12 | const sockaddr = linux.sockaddr; | |
| 13 | const socklen_t = linux.socklen_t; | |
| 14 | const timespec = std.os.linux.timespec; | |
| 3 | const SYS = std.os.linux.SYS; | |
| 15 | 4 | |
| 16 | pub fn syscall0(number: SYS) usize { | |
| 5 | pub fn syscall0(number: SYS) u64 { | |
| 17 | 6 | return asm volatile ("ecall" |
| 18 | : [ret] "={x10}" (-> usize), | |
| 7 | : [ret] "={x10}" (-> u64), | |
| 19 | 8 | : [number] "{x17}" (@intFromEnum(number)), |
| 20 | 9 | : .{ .memory = true }); |
| 21 | 10 | } |
| 22 | 11 | |
| 23 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 12 | pub fn syscall1(number: SYS, arg1: u64) u64 { | |
| 24 | 13 | return asm volatile ("ecall" |
| 25 | : [ret] "={x10}" (-> usize), | |
| 14 | : [ret] "={x10}" (-> u64), | |
| 26 | 15 | : [number] "{x17}" (@intFromEnum(number)), |
| 27 | 16 | [arg1] "{x10}" (arg1), |
| 28 | 17 | : .{ .memory = true }); |
| 29 | 18 | } |
| 30 | 19 | |
| 31 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 20 | pub fn syscall2(number: SYS, arg1: u64, arg2: u64) u64 { | |
| 32 | 21 | return asm volatile ("ecall" |
| 33 | : [ret] "={x10}" (-> usize), | |
| 22 | : [ret] "={x10}" (-> u64), | |
| 34 | 23 | : [number] "{x17}" (@intFromEnum(number)), |
| 35 | 24 | [arg1] "{x10}" (arg1), |
| 36 | 25 | [arg2] "{x11}" (arg2), |
| 37 | 26 | : .{ .memory = true }); |
| 38 | 27 | } |
| 39 | 28 | |
| 40 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 29 | pub fn syscall3(number: SYS, arg1: u64, arg2: u64, arg3: u64) u64 { | |
| 41 | 30 | return asm volatile ("ecall" |
| 42 | : [ret] "={x10}" (-> usize), | |
| 31 | : [ret] "={x10}" (-> u64), | |
| 43 | 32 | : [number] "{x17}" (@intFromEnum(number)), |
| 44 | 33 | [arg1] "{x10}" (arg1), |
| 45 | 34 | [arg2] "{x11}" (arg2), |
| ... | ... | @@ -47,9 +36,9 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 47 | 36 | : .{ .memory = true }); |
| 48 | 37 | } |
| 49 | 38 | |
| 50 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 39 | pub fn syscall4(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64) u64 { | |
| 51 | 40 | return asm volatile ("ecall" |
| 52 | : [ret] "={x10}" (-> usize), | |
| 41 | : [ret] "={x10}" (-> u64), | |
| 53 | 42 | : [number] "{x17}" (@intFromEnum(number)), |
| 54 | 43 | [arg1] "{x10}" (arg1), |
| 55 | 44 | [arg2] "{x11}" (arg2), |
| ... | ... | @@ -58,9 +47,9 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 58 | 47 | : .{ .memory = true }); |
| 59 | 48 | } |
| 60 | 49 | |
| 61 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 50 | pub fn syscall5(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) u64 { | |
| 62 | 51 | return asm volatile ("ecall" |
| 63 | : [ret] "={x10}" (-> usize), | |
| 52 | : [ret] "={x10}" (-> u64), | |
| 64 | 53 | : [number] "{x17}" (@intFromEnum(number)), |
| 65 | 54 | [arg1] "{x10}" (arg1), |
| 66 | 55 | [arg2] "{x11}" (arg2), |
| ... | ... | @@ -72,15 +61,15 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 72 | 61 | |
| 73 | 62 | pub fn syscall6( |
| 74 | 63 | number: SYS, |
| 75 | arg1: usize, | |
| 76 | arg2: usize, | |
| 77 | arg3: usize, | |
| 78 | arg4: usize, | |
| 79 | arg5: usize, | |
| 80 | arg6: usize, | |
| 81 | ) usize { | |
| 64 | arg1: u64, | |
| 65 | arg2: u64, | |
| 66 | arg3: u64, | |
| 67 | arg4: u64, | |
| 68 | arg5: u64, | |
| 69 | arg6: u64, | |
| 70 | ) u64 { | |
| 82 | 71 | return asm volatile ("ecall" |
| 83 | : [ret] "={x10}" (-> usize), | |
| 72 | : [ret] "={x10}" (-> u64), | |
| 84 | 73 | : [number] "{x17}" (@intFromEnum(number)), |
| 85 | 74 | [arg1] "{x10}" (arg1), |
| 86 | 75 | [arg2] "{x11}" (arg2), |
| ... | ... | @@ -91,7 +80,7 @@ pub fn syscall6( |
| 91 | 80 | : .{ .memory = true }); |
| 92 | 81 | } |
| 93 | 82 | |
| 94 | pub fn clone() callconv(.naked) usize { | |
| 83 | pub fn clone() callconv(.naked) u64 { | |
| 95 | 84 | // __clone(func, stack, flags, arg, ptid, tls, ctid) |
| 96 | 85 | // a0, a1, a2, a3, a4, a5, a6 |
| 97 | 86 | // |
| ... | ... | @@ -135,30 +124,6 @@ pub fn clone() callconv(.naked) usize { |
| 135 | 124 | ); |
| 136 | 125 | } |
| 137 | 126 | |
| 138 | pub const F = struct { | |
| 139 | pub const DUPFD = 0; | |
| 140 | pub const GETFD = 1; | |
| 141 | pub const SETFD = 2; | |
| 142 | pub const GETFL = 3; | |
| 143 | pub const SETFL = 4; | |
| 144 | pub const GETLK = 5; | |
| 145 | pub const SETLK = 6; | |
| 146 | pub const SETLKW = 7; | |
| 147 | pub const SETOWN = 8; | |
| 148 | pub const GETOWN = 9; | |
| 149 | pub const SETSIG = 10; | |
| 150 | pub const GETSIG = 11; | |
| 151 | ||
| 152 | pub const RDLCK = 0; | |
| 153 | pub const WRLCK = 1; | |
| 154 | pub const UNLCK = 2; | |
| 155 | ||
| 156 | pub const SETOWN_EX = 15; | |
| 157 | pub const GETOWN_EX = 16; | |
| 158 | ||
| 159 | pub const GETOWNER_UIDS = 17; | |
| 160 | }; | |
| 161 | ||
| 162 | 127 | pub const blksize_t = i32; |
| 163 | 128 | pub const nlink_t = u32; |
| 164 | 129 | pub const time_t = i64; |
| ... | ... | @@ -168,54 +133,38 @@ pub const ino_t = u64; |
| 168 | 133 | pub const dev_t = u64; |
| 169 | 134 | pub const blkcnt_t = i64; |
| 170 | 135 | |
| 171 | pub const timeval = extern struct { | |
| 172 | sec: time_t, | |
| 173 | usec: i64, | |
| 174 | }; | |
| 175 | ||
| 176 | pub const Flock = extern struct { | |
| 177 | type: i16, | |
| 178 | whence: i16, | |
| 179 | start: off_t, | |
| 180 | len: off_t, | |
| 181 | pid: pid_t, | |
| 182 | __unused: [4]u8, | |
| 183 | }; | |
| 184 | ||
| 185 | 136 | // The `stat` definition used by the Linux kernel. |
| 186 | 137 | pub const Stat = extern struct { |
| 187 | 138 | dev: dev_t, |
| 188 | 139 | ino: ino_t, |
| 189 | 140 | mode: mode_t, |
| 190 | 141 | nlink: nlink_t, |
| 191 | uid: uid_t, | |
| 192 | gid: gid_t, | |
| 142 | uid: std.os.linux.uid_t, | |
| 143 | gid: std.os.linux.gid_t, | |
| 193 | 144 | rdev: dev_t, |
| 194 | __pad: usize, | |
| 145 | __pad: u64, | |
| 195 | 146 | size: off_t, |
| 196 | 147 | blksize: blksize_t, |
| 197 | 148 | __pad2: i32, |
| 198 | 149 | blocks: blkcnt_t, |
| 199 | atim: timespec, | |
| 200 | mtim: timespec, | |
| 201 | ctim: timespec, | |
| 150 | atim: std.os.linux.timespec, | |
| 151 | mtim: std.os.linux.timespec, | |
| 152 | ctim: std.os.linux.timespec, | |
| 202 | 153 | __unused: [2]u32, |
| 203 | 154 | |
| 204 | pub fn atime(self: @This()) timespec { | |
| 155 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 205 | 156 | return self.atim; |
| 206 | 157 | } |
| 207 | 158 | |
| 208 | pub fn mtime(self: @This()) timespec { | |
| 159 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 209 | 160 | return self.mtim; |
| 210 | 161 | } |
| 211 | 162 | |
| 212 | pub fn ctime(self: @This()) timespec { | |
| 163 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 213 | 164 | return self.ctim; |
| 214 | 165 | } |
| 215 | 166 | }; |
| 216 | 167 | |
| 217 | pub const Elf_Symndx = u32; | |
| 218 | ||
| 219 | 168 | pub const VDSO = struct { |
| 220 | 169 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 221 | 170 | pub const CGT_VER = "LINUX_4.15"; |
lib/std/os/linux/s390x.zig+25-71| ... | ... | @@ -1,45 +1,34 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("../../std.zig"); |
| 3 | const iovec = std.posix.iovec; | |
| 4 | const iovec_const = std.posix.iovec_const; | |
| 5 | const linux = std.os.linux; | |
| 6 | const SYS = linux.SYS; | |
| 7 | const uid_t = std.os.linux.uid_t; | |
| 8 | const gid_t = std.os.linux.gid_t; | |
| 9 | const pid_t = std.os.linux.pid_t; | |
| 10 | const sockaddr = linux.sockaddr; | |
| 11 | const socklen_t = linux.socklen_t; | |
| 12 | const timespec = std.os.linux.timespec; | |
| 13 | const stack_t = std.os.linux.stack_t; | |
| 14 | const sigset_t = std.os.linux.sigset_t; | |
| 15 | ||
| 16 | pub fn syscall0(number: SYS) usize { | |
| 3 | const SYS = std.os.linux.SYS; | |
| 4 | ||
| 5 | pub fn syscall0(number: SYS) u64 { | |
| 17 | 6 | return asm volatile ("svc 0" |
| 18 | : [ret] "={r2}" (-> usize), | |
| 7 | : [ret] "={r2}" (-> u64), | |
| 19 | 8 | : [number] "{r1}" (@intFromEnum(number)), |
| 20 | 9 | : .{ .memory = true }); |
| 21 | 10 | } |
| 22 | 11 | |
| 23 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 12 | pub fn syscall1(number: SYS, arg1: u64) u64 { | |
| 24 | 13 | return asm volatile ("svc 0" |
| 25 | : [ret] "={r2}" (-> usize), | |
| 14 | : [ret] "={r2}" (-> u64), | |
| 26 | 15 | : [number] "{r1}" (@intFromEnum(number)), |
| 27 | 16 | [arg1] "{r2}" (arg1), |
| 28 | 17 | : .{ .memory = true }); |
| 29 | 18 | } |
| 30 | 19 | |
| 31 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 20 | pub fn syscall2(number: SYS, arg1: u64, arg2: u64) u64 { | |
| 32 | 21 | return asm volatile ("svc 0" |
| 33 | : [ret] "={r2}" (-> usize), | |
| 22 | : [ret] "={r2}" (-> u64), | |
| 34 | 23 | : [number] "{r1}" (@intFromEnum(number)), |
| 35 | 24 | [arg1] "{r2}" (arg1), |
| 36 | 25 | [arg2] "{r3}" (arg2), |
| 37 | 26 | : .{ .memory = true }); |
| 38 | 27 | } |
| 39 | 28 | |
| 40 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 29 | pub fn syscall3(number: SYS, arg1: u64, arg2: u64, arg3: u64) u64 { | |
| 41 | 30 | return asm volatile ("svc 0" |
| 42 | : [ret] "={r2}" (-> usize), | |
| 31 | : [ret] "={r2}" (-> u64), | |
| 43 | 32 | : [number] "{r1}" (@intFromEnum(number)), |
| 44 | 33 | [arg1] "{r2}" (arg1), |
| 45 | 34 | [arg2] "{r3}" (arg2), |
| ... | ... | @@ -47,9 +36,9 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 47 | 36 | : .{ .memory = true }); |
| 48 | 37 | } |
| 49 | 38 | |
| 50 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 39 | pub fn syscall4(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64) u64 { | |
| 51 | 40 | return asm volatile ("svc 0" |
| 52 | : [ret] "={r2}" (-> usize), | |
| 41 | : [ret] "={r2}" (-> u64), | |
| 53 | 42 | : [number] "{r1}" (@intFromEnum(number)), |
| 54 | 43 | [arg1] "{r2}" (arg1), |
| 55 | 44 | [arg2] "{r3}" (arg2), |
| ... | ... | @@ -58,9 +47,9 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 58 | 47 | : .{ .memory = true }); |
| 59 | 48 | } |
| 60 | 49 | |
| 61 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 50 | pub fn syscall5(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) u64 { | |
| 62 | 51 | return asm volatile ("svc 0" |
| 63 | : [ret] "={r2}" (-> usize), | |
| 52 | : [ret] "={r2}" (-> u64), | |
| 64 | 53 | : [number] "{r1}" (@intFromEnum(number)), |
| 65 | 54 | [arg1] "{r2}" (arg1), |
| 66 | 55 | [arg2] "{r3}" (arg2), |
| ... | ... | @@ -70,9 +59,9 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 70 | 59 | : .{ .memory = true }); |
| 71 | 60 | } |
| 72 | 61 | |
| 73 | pub fn syscall6(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize, arg6: usize) usize { | |
| 62 | pub fn syscall6(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64, arg6: u64) u64 { | |
| 74 | 63 | return asm volatile ("svc 0" |
| 75 | : [ret] "={r2}" (-> usize), | |
| 64 | : [ret] "={r2}" (-> u64), | |
| 76 | 65 | : [number] "{r1}" (@intFromEnum(number)), |
| 77 | 66 | [arg1] "{r2}" (arg1), |
| 78 | 67 | [arg2] "{r3}" (arg2), |
| ... | ... | @@ -83,7 +72,7 @@ pub fn syscall6(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 83 | 72 | : .{ .memory = true }); |
| 84 | 73 | } |
| 85 | 74 | |
| 86 | pub fn clone() callconv(.naked) usize { | |
| 75 | pub fn clone() callconv(.naked) u64 { | |
| 87 | 76 | asm volatile ( |
| 88 | 77 | \\# int clone( |
| 89 | 78 | \\# fn, a = r2 |
| ... | ... | @@ -157,26 +146,6 @@ pub fn restore_rt() callconv(.naked) noreturn { |
| 157 | 146 | ); |
| 158 | 147 | } |
| 159 | 148 | |
| 160 | pub const F = struct { | |
| 161 | pub const DUPFD = 0; | |
| 162 | pub const GETFD = 1; | |
| 163 | pub const SETFD = 2; | |
| 164 | pub const GETFL = 3; | |
| 165 | pub const SETFL = 4; | |
| 166 | pub const GETLK = 5; | |
| 167 | pub const SETLK = 6; | |
| 168 | pub const SETLKW = 7; | |
| 169 | pub const SETOWN = 8; | |
| 170 | pub const GETOWN = 9; | |
| 171 | pub const SETSIG = 10; | |
| 172 | pub const GETSIG = 11; | |
| 173 | ||
| 174 | pub const SETOWN_EX = 15; | |
| 175 | pub const GETOWN_EX = 16; | |
| 176 | ||
| 177 | pub const GETOWNER_UIDS = 17; | |
| 178 | }; | |
| 179 | ||
| 180 | 149 | pub const blksize_t = i64; |
| 181 | 150 | pub const nlink_t = u64; |
| 182 | 151 | pub const time_t = i64; |
| ... | ... | @@ -186,51 +155,36 @@ pub const ino_t = u64; |
| 186 | 155 | pub const dev_t = u64; |
| 187 | 156 | pub const blkcnt_t = i64; |
| 188 | 157 | |
| 189 | pub const timeval = extern struct { | |
| 190 | sec: time_t, | |
| 191 | usec: i64, | |
| 192 | }; | |
| 193 | ||
| 194 | pub const Flock = extern struct { | |
| 195 | type: i16, | |
| 196 | whence: i16, | |
| 197 | start: off_t, | |
| 198 | len: off_t, | |
| 199 | pid: pid_t, | |
| 200 | }; | |
| 201 | ||
| 202 | 158 | // The `stat` definition used by the Linux kernel. |
| 203 | 159 | pub const Stat = extern struct { |
| 204 | 160 | dev: dev_t, |
| 205 | 161 | ino: ino_t, |
| 206 | 162 | nlink: nlink_t, |
| 207 | 163 | mode: mode_t, |
| 208 | uid: uid_t, | |
| 209 | gid: gid_t, | |
| 164 | uid: std.os.linux.uid_t, | |
| 165 | gid: std.os.linux.gid_t, | |
| 210 | 166 | rdev: dev_t, |
| 211 | 167 | size: off_t, |
| 212 | atim: timespec, | |
| 213 | mtim: timespec, | |
| 214 | ctim: timespec, | |
| 168 | atim: std.os.linux.timespec, | |
| 169 | mtim: std.os.linux.timespec, | |
| 170 | ctim: std.os.linux.timespec, | |
| 215 | 171 | blksize: blksize_t, |
| 216 | 172 | blocks: blkcnt_t, |
| 217 | 173 | __unused: [3]c_ulong, |
| 218 | 174 | |
| 219 | pub fn atime(self: @This()) timespec { | |
| 175 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 220 | 176 | return self.atim; |
| 221 | 177 | } |
| 222 | 178 | |
| 223 | pub fn mtime(self: @This()) timespec { | |
| 179 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 224 | 180 | return self.mtim; |
| 225 | 181 | } |
| 226 | 182 | |
| 227 | pub fn ctime(self: @This()) timespec { | |
| 183 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 228 | 184 | return self.ctim; |
| 229 | 185 | } |
| 230 | 186 | }; |
| 231 | 187 | |
| 232 | pub const Elf_Symndx = u64; | |
| 233 | ||
| 234 | 188 | pub const VDSO = struct { |
| 235 | 189 | pub const CGT_SYM = "__kernel_clock_gettime"; |
| 236 | 190 | pub const CGT_VER = "LINUX_2.6.29"; |
lib/std/os/linux/sparc64.zig+46-101| ... | ... | @@ -1,21 +1,8 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("../../std.zig"); |
| 3 | const maxInt = std.math.maxInt; | |
| 4 | const pid_t = linux.pid_t; | |
| 5 | const uid_t = linux.uid_t; | |
| 6 | const clock_t = linux.clock_t; | |
| 7 | const stack_t = linux.stack_t; | |
| 8 | const sigset_t = linux.sigset_t; | |
| 3 | const SYS = std.os.linux.SYS; | |
| 9 | 4 | |
| 10 | const linux = std.os.linux; | |
| 11 | const SYS = linux.SYS; | |
| 12 | const sockaddr = linux.sockaddr; | |
| 13 | const socklen_t = linux.socklen_t; | |
| 14 | const iovec = std.posix.iovec; | |
| 15 | const iovec_const = std.posix.iovec_const; | |
| 16 | const timespec = linux.timespec; | |
| 17 | ||
| 18 | pub fn syscall_pipe(fd: *[2]i32) usize { | |
| 5 | pub fn syscall_pipe(fd: *[2]i32) u64 { | |
| 19 | 6 | return asm volatile ( |
| 20 | 7 | \\ mov %[arg], %%g3 |
| 21 | 8 | \\ t 0x6d |
| ... | ... | @@ -29,13 +16,13 @@ pub fn syscall_pipe(fd: *[2]i32) usize { |
| 29 | 16 | \\ st %%o1, [%%g3+4] |
| 30 | 17 | \\ clr %%o0 |
| 31 | 18 | \\2: |
| 32 | : [ret] "={o0}" (-> usize), | |
| 19 | : [ret] "={o0}" (-> u64), | |
| 33 | 20 | : [number] "{g1}" (@intFromEnum(SYS.pipe)), |
| 34 | 21 | [arg] "r" (fd), |
| 35 | 22 | : .{ .memory = true, .g3 = true }); |
| 36 | 23 | } |
| 37 | 24 | |
| 38 | pub fn syscall_fork() usize { | |
| 25 | pub fn syscall_fork() u64 { | |
| 39 | 26 | // Linux/sparc64 fork() returns two values in %o0 and %o1: |
| 40 | 27 | // - On the parent's side, %o0 is the child's PID and %o1 is 0. |
| 41 | 28 | // - On the child's side, %o0 is the parent's PID and %o1 is 1. |
| ... | ... | @@ -52,58 +39,58 @@ pub fn syscall_fork() usize { |
| 52 | 39 | \\ dec %%o1 |
| 53 | 40 | \\ and %%o1, %%o0, %%o0 |
| 54 | 41 | \\ 2: |
| 55 | : [ret] "={o0}" (-> usize), | |
| 42 | : [ret] "={o0}" (-> u64), | |
| 56 | 43 | : [number] "{g1}" (@intFromEnum(SYS.fork)), |
| 57 | 44 | : .{ .memory = true, .icc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true }); |
| 58 | 45 | } |
| 59 | 46 | |
| 60 | pub fn syscall0(number: SYS) usize { | |
| 47 | pub fn syscall0(number: SYS) u64 { | |
| 61 | 48 | return asm volatile ( |
| 62 | 49 | \\ t 0x6d |
| 63 | 50 | \\ bcc,pt %%xcc, 1f |
| 64 | 51 | \\ nop |
| 65 | 52 | \\ neg %%o0 |
| 66 | 53 | \\ 1: |
| 67 | : [ret] "={o0}" (-> usize), | |
| 54 | : [ret] "={o0}" (-> u64), | |
| 68 | 55 | : [number] "{g1}" (@intFromEnum(number)), |
| 69 | 56 | : .{ .memory = true, .icc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true }); |
| 70 | 57 | } |
| 71 | 58 | |
| 72 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 59 | pub fn syscall1(number: SYS, arg1: u64) u64 { | |
| 73 | 60 | return asm volatile ( |
| 74 | 61 | \\ t 0x6d |
| 75 | 62 | \\ bcc,pt %%xcc, 1f |
| 76 | 63 | \\ nop |
| 77 | 64 | \\ neg %%o0 |
| 78 | 65 | \\ 1: |
| 79 | : [ret] "={o0}" (-> usize), | |
| 66 | : [ret] "={o0}" (-> u64), | |
| 80 | 67 | : [number] "{g1}" (@intFromEnum(number)), |
| 81 | 68 | [arg1] "{o0}" (arg1), |
| 82 | 69 | : .{ .memory = true, .icc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true }); |
| 83 | 70 | } |
| 84 | 71 | |
| 85 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 72 | pub fn syscall2(number: SYS, arg1: u64, arg2: u64) u64 { | |
| 86 | 73 | return asm volatile ( |
| 87 | 74 | \\ t 0x6d |
| 88 | 75 | \\ bcc,pt %%xcc, 1f |
| 89 | 76 | \\ nop |
| 90 | 77 | \\ neg %%o0 |
| 91 | 78 | \\ 1: |
| 92 | : [ret] "={o0}" (-> usize), | |
| 79 | : [ret] "={o0}" (-> u64), | |
| 93 | 80 | : [number] "{g1}" (@intFromEnum(number)), |
| 94 | 81 | [arg1] "{o0}" (arg1), |
| 95 | 82 | [arg2] "{o1}" (arg2), |
| 96 | 83 | : .{ .memory = true, .icc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true }); |
| 97 | 84 | } |
| 98 | 85 | |
| 99 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 86 | pub fn syscall3(number: SYS, arg1: u64, arg2: u64, arg3: u64) u64 { | |
| 100 | 87 | return asm volatile ( |
| 101 | 88 | \\ t 0x6d |
| 102 | 89 | \\ bcc,pt %%xcc, 1f |
| 103 | 90 | \\ nop |
| 104 | 91 | \\ neg %%o0 |
| 105 | 92 | \\ 1: |
| 106 | : [ret] "={o0}" (-> usize), | |
| 93 | : [ret] "={o0}" (-> u64), | |
| 107 | 94 | : [number] "{g1}" (@intFromEnum(number)), |
| 108 | 95 | [arg1] "{o0}" (arg1), |
| 109 | 96 | [arg2] "{o1}" (arg2), |
| ... | ... | @@ -111,14 +98,14 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 111 | 98 | : .{ .memory = true, .icc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true }); |
| 112 | 99 | } |
| 113 | 100 | |
| 114 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 101 | pub fn syscall4(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64) u64 { | |
| 115 | 102 | return asm volatile ( |
| 116 | 103 | \\ t 0x6d |
| 117 | 104 | \\ bcc,pt %%xcc, 1f |
| 118 | 105 | \\ nop |
| 119 | 106 | \\ neg %%o0 |
| 120 | 107 | \\ 1: |
| 121 | : [ret] "={o0}" (-> usize), | |
| 108 | : [ret] "={o0}" (-> u64), | |
| 122 | 109 | : [number] "{g1}" (@intFromEnum(number)), |
| 123 | 110 | [arg1] "{o0}" (arg1), |
| 124 | 111 | [arg2] "{o1}" (arg2), |
| ... | ... | @@ -127,14 +114,14 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 127 | 114 | : .{ .memory = true, .icc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true }); |
| 128 | 115 | } |
| 129 | 116 | |
| 130 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 117 | pub fn syscall5(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) u64 { | |
| 131 | 118 | return asm volatile ( |
| 132 | 119 | \\ t 0x6d |
| 133 | 120 | \\ bcc,pt %%xcc, 1f |
| 134 | 121 | \\ nop |
| 135 | 122 | \\ neg %%o0 |
| 136 | 123 | \\ 1: |
| 137 | : [ret] "={o0}" (-> usize), | |
| 124 | : [ret] "={o0}" (-> u64), | |
| 138 | 125 | : [number] "{g1}" (@intFromEnum(number)), |
| 139 | 126 | [arg1] "{o0}" (arg1), |
| 140 | 127 | [arg2] "{o1}" (arg2), |
| ... | ... | @@ -146,20 +133,20 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 146 | 133 | |
| 147 | 134 | pub fn syscall6( |
| 148 | 135 | number: SYS, |
| 149 | arg1: usize, | |
| 150 | arg2: usize, | |
| 151 | arg3: usize, | |
| 152 | arg4: usize, | |
| 153 | arg5: usize, | |
| 154 | arg6: usize, | |
| 155 | ) usize { | |
| 136 | arg1: u64, | |
| 137 | arg2: u64, | |
| 138 | arg3: u64, | |
| 139 | arg4: u64, | |
| 140 | arg5: u64, | |
| 141 | arg6: u64, | |
| 142 | ) u64 { | |
| 156 | 143 | return asm volatile ( |
| 157 | 144 | \\ t 0x6d |
| 158 | 145 | \\ bcc,pt %%xcc, 1f |
| 159 | 146 | \\ nop |
| 160 | 147 | \\ neg %%o0 |
| 161 | 148 | \\ 1: |
| 162 | : [ret] "={o0}" (-> usize), | |
| 149 | : [ret] "={o0}" (-> u64), | |
| 163 | 150 | : [number] "{g1}" (@intFromEnum(number)), |
| 164 | 151 | [arg1] "{o0}" (arg1), |
| 165 | 152 | [arg2] "{o1}" (arg2), |
| ... | ... | @@ -170,7 +157,7 @@ pub fn syscall6( |
| 170 | 157 | : .{ .memory = true, .icc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true }); |
| 171 | 158 | } |
| 172 | 159 | |
| 173 | pub fn clone() callconv(.naked) usize { | |
| 160 | pub fn clone() callconv(.naked) u64 { | |
| 174 | 161 | // __clone(func, stack, flags, arg, ptid, tls, ctid) |
| 175 | 162 | // i0, i1, i2, i3, i4, i5, sp |
| 176 | 163 | // |
| ... | ... | @@ -236,93 +223,51 @@ pub fn restore_rt() callconv(.c) void { |
| 236 | 223 | : .{ .memory = true, .icc = true, .o0 = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true }); |
| 237 | 224 | } |
| 238 | 225 | |
| 239 | pub const F = struct { | |
| 240 | pub const DUPFD = 0; | |
| 241 | pub const GETFD = 1; | |
| 242 | pub const SETFD = 2; | |
| 243 | pub const GETFL = 3; | |
| 244 | pub const SETFL = 4; | |
| 245 | ||
| 246 | pub const SETOWN = 5; | |
| 247 | pub const GETOWN = 6; | |
| 248 | pub const GETLK = 7; | |
| 249 | pub const SETLK = 8; | |
| 250 | pub const SETLKW = 9; | |
| 251 | ||
| 252 | pub const RDLCK = 1; | |
| 253 | pub const WRLCK = 2; | |
| 254 | pub const UNLCK = 3; | |
| 255 | ||
| 256 | pub const SETOWN_EX = 15; | |
| 257 | pub const GETOWN_EX = 16; | |
| 258 | ||
| 259 | pub const GETOWNER_UIDS = 17; | |
| 260 | }; | |
| 261 | ||
| 262 | 226 | pub const VDSO = struct { |
| 263 | 227 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 264 | 228 | pub const CGT_VER = "LINUX_2.6"; |
| 265 | 229 | }; |
| 266 | 230 | |
| 267 | pub const Flock = extern struct { | |
| 268 | type: i16, | |
| 269 | whence: i16, | |
| 270 | start: off_t, | |
| 271 | len: off_t, | |
| 272 | pid: pid_t, | |
| 273 | }; | |
| 274 | ||
| 275 | 231 | pub const off_t = i64; |
| 276 | 232 | pub const ino_t = u64; |
| 277 | pub const time_t = isize; | |
| 233 | pub const time_t = i64; | |
| 278 | 234 | pub const mode_t = u32; |
| 279 | pub const dev_t = usize; | |
| 235 | pub const dev_t = u64; | |
| 280 | 236 | pub const nlink_t = u32; |
| 281 | pub const blksize_t = isize; | |
| 282 | pub const blkcnt_t = isize; | |
| 237 | pub const blksize_t = i64; | |
| 238 | pub const blkcnt_t = i64; | |
| 283 | 239 | |
| 284 | 240 | // The `stat64` definition used by the kernel. |
| 285 | 241 | pub const Stat = extern struct { |
| 286 | dev: u64, | |
| 287 | ino: u64, | |
| 288 | nlink: u64, | |
| 242 | dev: dev_t, | |
| 243 | ino: ino_t, | |
| 244 | nlink: nlink_t, | |
| 245 | _pad: i32, | |
| 289 | 246 | |
| 290 | mode: u32, | |
| 291 | uid: u32, | |
| 292 | gid: u32, | |
| 247 | mode: mode_t, | |
| 248 | uid: std.os.linux.uid_t, | |
| 249 | gid: std.os.linux.gid_t, | |
| 293 | 250 | __pad0: u32, |
| 294 | 251 | |
| 295 | rdev: u64, | |
| 252 | rdev: dev_t, | |
| 296 | 253 | size: i64, |
| 297 | blksize: i64, | |
| 298 | blocks: i64, | |
| 254 | blksize: blksize_t, | |
| 255 | blocks: blkcnt_t, | |
| 299 | 256 | |
| 300 | atim: timespec, | |
| 301 | mtim: timespec, | |
| 302 | ctim: timespec, | |
| 257 | atim: std.os.linux.timespec, | |
| 258 | mtim: std.os.linux.timespec, | |
| 259 | ctim: std.os.linux.timespec, | |
| 303 | 260 | __unused: [3]u64, |
| 304 | 261 | |
| 305 | pub fn atime(self: @This()) timespec { | |
| 262 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 306 | 263 | return self.atim; |
| 307 | 264 | } |
| 308 | 265 | |
| 309 | pub fn mtime(self: @This()) timespec { | |
| 266 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 310 | 267 | return self.mtim; |
| 311 | 268 | } |
| 312 | 269 | |
| 313 | pub fn ctime(self: @This()) timespec { | |
| 270 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 314 | 271 | return self.ctim; |
| 315 | 272 | } |
| 316 | 273 | }; |
| 317 | ||
| 318 | pub const timeval = extern struct { | |
| 319 | sec: isize, | |
| 320 | usec: i32, | |
| 321 | }; | |
| 322 | ||
| 323 | pub const timezone = extern struct { | |
| 324 | minuteswest: i32, | |
| 325 | dsttime: i32, | |
| 326 | }; | |
| 327 | ||
| 328 | pub const Elf_Symndx = u32; |
lib/std/os/linux/thumb.zig+28-43| ... | ... | @@ -4,64 +4,55 @@ |
| 4 | 4 | //! Save and restore r7 around the syscall without touching the stack pointer not |
| 5 | 5 | //! to break the frame chain. |
| 6 | 6 | const std = @import("../../std.zig"); |
| 7 | const linux = std.os.linux; | |
| 8 | const SYS = linux.SYS; | |
| 7 | const SYS = std.os.linux.SYS; | |
| 9 | 8 | |
| 10 | pub fn syscall0(number: SYS) usize { | |
| 11 | @setRuntimeSafety(false); | |
| 12 | ||
| 13 | var buf: [2]usize = .{ @intFromEnum(number), undefined }; | |
| 9 | pub fn syscall0(number: SYS) u32 { | |
| 10 | var buf: [2]u32 = .{ @intFromEnum(number), undefined }; | |
| 14 | 11 | return asm volatile ( |
| 15 | 12 | \\ str r7, [%[tmp], #4] |
| 16 | 13 | \\ ldr r7, [%[tmp]] |
| 17 | 14 | \\ svc #0 |
| 18 | 15 | \\ ldr r7, [%[tmp], #4] |
| 19 | : [ret] "={r0}" (-> usize), | |
| 16 | : [ret] "={r0}" (-> u32), | |
| 20 | 17 | : [tmp] "{r1}" (&buf), |
| 21 | 18 | : .{ .memory = true }); |
| 22 | 19 | } |
| 23 | 20 | |
| 24 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 25 | @setRuntimeSafety(false); | |
| 26 | ||
| 27 | var buf: [2]usize = .{ @intFromEnum(number), undefined }; | |
| 21 | pub fn syscall1(number: SYS, arg1: u32) u32 { | |
| 22 | var buf: [2]u32 = .{ @intFromEnum(number), undefined }; | |
| 28 | 23 | return asm volatile ( |
| 29 | 24 | \\ str r7, [%[tmp], #4] |
| 30 | 25 | \\ ldr r7, [%[tmp]] |
| 31 | 26 | \\ svc #0 |
| 32 | 27 | \\ ldr r7, [%[tmp], #4] |
| 33 | : [ret] "={r0}" (-> usize), | |
| 28 | : [ret] "={r0}" (-> u32), | |
| 34 | 29 | : [tmp] "{r1}" (&buf), |
| 35 | 30 | [arg1] "{r0}" (arg1), |
| 36 | 31 | : .{ .memory = true }); |
| 37 | 32 | } |
| 38 | 33 | |
| 39 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 40 | @setRuntimeSafety(false); | |
| 41 | ||
| 42 | var buf: [2]usize = .{ @intFromEnum(number), undefined }; | |
| 34 | pub fn syscall2(number: SYS, arg1: u32, arg2: u32) u32 { | |
| 35 | var buf: [2]u32 = .{ @intFromEnum(number), undefined }; | |
| 43 | 36 | return asm volatile ( |
| 44 | 37 | \\ str r7, [%[tmp], #4] |
| 45 | 38 | \\ ldr r7, [%[tmp]] |
| 46 | 39 | \\ svc #0 |
| 47 | 40 | \\ ldr r7, [%[tmp], #4] |
| 48 | : [ret] "={r0}" (-> usize), | |
| 41 | : [ret] "={r0}" (-> u32), | |
| 49 | 42 | : [tmp] "{r2}" (&buf), |
| 50 | 43 | [arg1] "{r0}" (arg1), |
| 51 | 44 | [arg2] "{r1}" (arg2), |
| 52 | 45 | : .{ .memory = true }); |
| 53 | 46 | } |
| 54 | 47 | |
| 55 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 56 | @setRuntimeSafety(false); | |
| 57 | ||
| 58 | var buf: [2]usize = .{ @intFromEnum(number), undefined }; | |
| 48 | pub fn syscall3(number: SYS, arg1: u32, arg2: u32, arg3: u32) u32 { | |
| 49 | var buf: [2]u32 = .{ @intFromEnum(number), undefined }; | |
| 59 | 50 | return asm volatile ( |
| 60 | 51 | \\ str r7, [%[tmp], #4] |
| 61 | 52 | \\ ldr r7, [%[tmp]] |
| 62 | 53 | \\ svc #0 |
| 63 | 54 | \\ ldr r7, [%[tmp], #4] |
| 64 | : [ret] "={r0}" (-> usize), | |
| 55 | : [ret] "={r0}" (-> u32), | |
| 65 | 56 | : [tmp] "{r3}" (&buf), |
| 66 | 57 | [arg1] "{r0}" (arg1), |
| 67 | 58 | [arg2] "{r1}" (arg2), |
| ... | ... | @@ -69,16 +60,14 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 69 | 60 | : .{ .memory = true }); |
| 70 | 61 | } |
| 71 | 62 | |
| 72 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 73 | @setRuntimeSafety(false); | |
| 74 | ||
| 75 | var buf: [2]usize = .{ @intFromEnum(number), undefined }; | |
| 63 | pub fn syscall4(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32) u32 { | |
| 64 | var buf: [2]u32 = .{ @intFromEnum(number), undefined }; | |
| 76 | 65 | return asm volatile ( |
| 77 | 66 | \\ str r7, [%[tmp], #4] |
| 78 | 67 | \\ ldr r7, [%[tmp]] |
| 79 | 68 | \\ svc #0 |
| 80 | 69 | \\ ldr r7, [%[tmp], #4] |
| 81 | : [ret] "={r0}" (-> usize), | |
| 70 | : [ret] "={r0}" (-> u32), | |
| 82 | 71 | : [tmp] "{r4}" (&buf), |
| 83 | 72 | [arg1] "{r0}" (arg1), |
| 84 | 73 | [arg2] "{r1}" (arg2), |
| ... | ... | @@ -87,16 +76,14 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 87 | 76 | : .{ .memory = true }); |
| 88 | 77 | } |
| 89 | 78 | |
| 90 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 91 | @setRuntimeSafety(false); | |
| 92 | ||
| 93 | var buf: [2]usize = .{ @intFromEnum(number), undefined }; | |
| 79 | pub fn syscall5(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32, arg5: u32) u32 { | |
| 80 | var buf: [2]u32 = .{ @intFromEnum(number), undefined }; | |
| 94 | 81 | return asm volatile ( |
| 95 | 82 | \\ str r7, [%[tmp], #4] |
| 96 | 83 | \\ ldr r7, [%[tmp]] |
| 97 | 84 | \\ svc #0 |
| 98 | 85 | \\ ldr r7, [%[tmp], #4] |
| 99 | : [ret] "={r0}" (-> usize), | |
| 86 | : [ret] "={r0}" (-> u32), | |
| 100 | 87 | : [tmp] "{r5}" (&buf), |
| 101 | 88 | [arg1] "{r0}" (arg1), |
| 102 | 89 | [arg2] "{r1}" (arg2), |
| ... | ... | @@ -108,22 +95,20 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 108 | 95 | |
| 109 | 96 | pub fn syscall6( |
| 110 | 97 | number: SYS, |
| 111 | arg1: usize, | |
| 112 | arg2: usize, | |
| 113 | arg3: usize, | |
| 114 | arg4: usize, | |
| 115 | arg5: usize, | |
| 116 | arg6: usize, | |
| 117 | ) usize { | |
| 118 | @setRuntimeSafety(false); | |
| 119 | ||
| 120 | var buf: [2]usize = .{ @intFromEnum(number), undefined }; | |
| 98 | arg1: u32, | |
| 99 | arg2: u32, | |
| 100 | arg3: u32, | |
| 101 | arg4: u32, | |
| 102 | arg5: u32, | |
| 103 | arg6: u32, | |
| 104 | ) u32 { | |
| 105 | var buf: [2]u32 = .{ @intFromEnum(number), undefined }; | |
| 121 | 106 | return asm volatile ( |
| 122 | 107 | \\ str r7, [%[tmp], #4] |
| 123 | 108 | \\ ldr r7, [%[tmp]] |
| 124 | 109 | \\ svc #0 |
| 125 | 110 | \\ ldr r7, [%[tmp], #4] |
| 126 | : [ret] "={r0}" (-> usize), | |
| 111 | : [ret] "={r0}" (-> u32), | |
| 127 | 112 | : [tmp] "{r6}" (&buf), |
| 128 | 113 | [arg1] "{r0}" (arg1), |
| 129 | 114 | [arg2] "{r1}" (arg2), |
lib/std/os/linux/tls.zig+1-2| ... | ... | @@ -16,7 +16,6 @@ const math = std.math; |
| 16 | 16 | const assert = std.debug.assert; |
| 17 | 17 | const native_arch = @import("builtin").cpu.arch; |
| 18 | 18 | const linux = std.os.linux; |
| 19 | const posix = std.posix; | |
| 20 | 19 | const page_size_min = std.heap.page_size_min; |
| 21 | 20 | |
| 22 | 21 | /// Represents an ELF TLS variant. |
| ... | ... | @@ -523,7 +522,7 @@ pub fn initStatic(phdrs: []elf.Phdr) void { |
| 523 | 522 | } |
| 524 | 523 | |
| 525 | 524 | inline fn mmap_tls(length: usize) usize { |
| 526 | const prot = posix.PROT.READ | posix.PROT.WRITE; | |
| 525 | const prot = linux.PROT.READ | linux.PROT.WRITE; | |
| 527 | 526 | const flags: linux.MAP = .{ .TYPE = .PRIVATE, .ANONYMOUS = true }; |
| 528 | 527 | |
| 529 | 528 | if (@hasField(linux.SYS, "mmap2")) { |
lib/std/os/linux/x32.zig created+192| ... | ... | @@ -0,0 +1,192 @@ |
| 1 | // TODO: A lot of this file is very likely wrong. | |
| 2 | ||
| 3 | const builtin = @import("builtin"); | |
| 4 | const std = @import("../../std.zig"); | |
| 5 | const SYS = std.os.linux.SYS; | |
| 6 | ||
| 7 | pub fn syscall0(number: SYS) u32 { | |
| 8 | return asm volatile ("syscall" | |
| 9 | : [ret] "={rax}" (-> u32), | |
| 10 | : [number] "{rax}" (@intFromEnum(number)), | |
| 11 | : .{ .rcx = true, .r11 = true, .memory = true }); | |
| 12 | } | |
| 13 | ||
| 14 | pub fn syscall1(number: SYS, arg1: u32) u32 { | |
| 15 | return asm volatile ("syscall" | |
| 16 | : [ret] "={rax}" (-> u32), | |
| 17 | : [number] "{rax}" (@intFromEnum(number)), | |
| 18 | [arg1] "{rdi}" (arg1), | |
| 19 | : .{ .rcx = true, .r11 = true, .memory = true }); | |
| 20 | } | |
| 21 | ||
| 22 | pub fn syscall2(number: SYS, arg1: u32, arg2: u32) u32 { | |
| 23 | return asm volatile ("syscall" | |
| 24 | : [ret] "={rax}" (-> u32), | |
| 25 | : [number] "{rax}" (@intFromEnum(number)), | |
| 26 | [arg1] "{rdi}" (arg1), | |
| 27 | [arg2] "{rsi}" (arg2), | |
| 28 | : .{ .rcx = true, .r11 = true, .memory = true }); | |
| 29 | } | |
| 30 | ||
| 31 | pub fn syscall3(number: SYS, arg1: u32, arg2: u32, arg3: u32) u32 { | |
| 32 | return asm volatile ("syscall" | |
| 33 | : [ret] "={rax}" (-> u32), | |
| 34 | : [number] "{rax}" (@intFromEnum(number)), | |
| 35 | [arg1] "{rdi}" (arg1), | |
| 36 | [arg2] "{rsi}" (arg2), | |
| 37 | [arg3] "{rdx}" (arg3), | |
| 38 | : .{ .rcx = true, .r11 = true, .memory = true }); | |
| 39 | } | |
| 40 | ||
| 41 | pub fn syscall4(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32) u32 { | |
| 42 | return asm volatile ("syscall" | |
| 43 | : [ret] "={rax}" (-> u32), | |
| 44 | : [number] "{rax}" (@intFromEnum(number)), | |
| 45 | [arg1] "{rdi}" (arg1), | |
| 46 | [arg2] "{rsi}" (arg2), | |
| 47 | [arg3] "{rdx}" (arg3), | |
| 48 | [arg4] "{r10}" (arg4), | |
| 49 | : .{ .rcx = true, .r11 = true, .memory = true }); | |
| 50 | } | |
| 51 | ||
| 52 | pub fn syscall5(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32, arg5: u32) u32 { | |
| 53 | return asm volatile ("syscall" | |
| 54 | : [ret] "={rax}" (-> u32), | |
| 55 | : [number] "{rax}" (@intFromEnum(number)), | |
| 56 | [arg1] "{rdi}" (arg1), | |
| 57 | [arg2] "{rsi}" (arg2), | |
| 58 | [arg3] "{rdx}" (arg3), | |
| 59 | [arg4] "{r10}" (arg4), | |
| 60 | [arg5] "{r8}" (arg5), | |
| 61 | : .{ .rcx = true, .r11 = true, .memory = true }); | |
| 62 | } | |
| 63 | ||
| 64 | pub fn syscall6( | |
| 65 | number: SYS, | |
| 66 | arg1: u32, | |
| 67 | arg2: u32, | |
| 68 | arg3: u32, | |
| 69 | arg4: u32, | |
| 70 | arg5: u32, | |
| 71 | arg6: u32, | |
| 72 | ) u32 { | |
| 73 | return asm volatile ("syscall" | |
| 74 | : [ret] "={rax}" (-> u32), | |
| 75 | : [number] "{rax}" (@intFromEnum(number)), | |
| 76 | [arg1] "{rdi}" (arg1), | |
| 77 | [arg2] "{rsi}" (arg2), | |
| 78 | [arg3] "{rdx}" (arg3), | |
| 79 | [arg4] "{r10}" (arg4), | |
| 80 | [arg5] "{r8}" (arg5), | |
| 81 | [arg6] "{r9}" (arg6), | |
| 82 | : .{ .rcx = true, .r11 = true, .memory = true }); | |
| 83 | } | |
| 84 | ||
| 85 | pub fn clone() callconv(.naked) u32 { | |
| 86 | asm volatile ( | |
| 87 | \\ movl $56,%%eax // SYS_clone | |
| 88 | \\ movq %%rdi,%%r11 | |
| 89 | \\ movq %%rdx,%%rdi | |
| 90 | \\ movq %%r8,%%rdx | |
| 91 | \\ movq %%r9,%%r8 | |
| 92 | \\ movq 8(%%rsp),%%r10 | |
| 93 | \\ movq %%r11,%%r9 | |
| 94 | \\ andq $-16,%%rsi | |
| 95 | \\ subq $8,%%rsi | |
| 96 | \\ movq %%rcx,(%%rsi) | |
| 97 | \\ syscall | |
| 98 | \\ testq %%rax,%%rax | |
| 99 | \\ jz 1f | |
| 100 | \\ retq | |
| 101 | \\ | |
| 102 | \\1: | |
| 103 | ); | |
| 104 | if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile ( | |
| 105 | \\ .cfi_undefined %%rip | |
| 106 | ); | |
| 107 | asm volatile ( | |
| 108 | \\ xorl %%ebp,%%ebp | |
| 109 | \\ | |
| 110 | \\ popq %%rdi | |
| 111 | \\ callq *%%r9 | |
| 112 | \\ movl %%eax,%%edi | |
| 113 | \\ movl $60,%%eax // SYS_exit | |
| 114 | \\ syscall | |
| 115 | \\ | |
| 116 | ); | |
| 117 | } | |
| 118 | ||
| 119 | pub const restore = restore_rt; | |
| 120 | ||
| 121 | pub fn restore_rt() callconv(.naked) noreturn { | |
| 122 | switch (builtin.zig_backend) { | |
| 123 | .stage2_c => asm volatile ( | |
| 124 | \\ movl %[number], %%eax | |
| 125 | \\ syscall | |
| 126 | : | |
| 127 | : [number] "i" (@intFromEnum(SYS.rt_sigreturn)), | |
| 128 | ), | |
| 129 | else => asm volatile ( | |
| 130 | \\ syscall | |
| 131 | : | |
| 132 | : [number] "{rax}" (@intFromEnum(SYS.rt_sigreturn)), | |
| 133 | ), | |
| 134 | } | |
| 135 | } | |
| 136 | ||
| 137 | pub const mode_t = u32; | |
| 138 | pub const time_t = i32; | |
| 139 | pub const nlink_t = u32; | |
| 140 | pub const blksize_t = i32; | |
| 141 | pub const blkcnt_t = i32; | |
| 142 | pub const off_t = i64; | |
| 143 | pub const ino_t = u64; | |
| 144 | pub const dev_t = u64; | |
| 145 | ||
| 146 | pub const VDSO = struct { | |
| 147 | pub const CGT_SYM = "__vdso_clock_gettime"; | |
| 148 | pub const CGT_VER = "LINUX_2.6"; | |
| 149 | ||
| 150 | pub const GETCPU_SYM = "__vdso_getcpu"; | |
| 151 | pub const GETCPU_VER = "LINUX_2.6"; | |
| 152 | }; | |
| 153 | ||
| 154 | pub const ARCH = struct { | |
| 155 | pub const SET_GS = 0x1001; | |
| 156 | pub const SET_FS = 0x1002; | |
| 157 | pub const GET_FS = 0x1003; | |
| 158 | pub const GET_GS = 0x1004; | |
| 159 | }; | |
| 160 | ||
| 161 | // The `stat` definition used by the Linux kernel. | |
| 162 | pub const Stat = extern struct { | |
| 163 | dev: dev_t, | |
| 164 | ino: ino_t, | |
| 165 | nlink: nlink_t, | |
| 166 | ||
| 167 | mode: mode_t, | |
| 168 | uid: std.os.linux.uid_t, | |
| 169 | gid: std.os.linux.gid_t, | |
| 170 | __pad0: u32, | |
| 171 | rdev: dev_t, | |
| 172 | size: off_t, | |
| 173 | blksize: blksize_t, | |
| 174 | blocks: i64, | |
| 175 | ||
| 176 | atim: std.os.linux.timespec, | |
| 177 | mtim: std.os.linux.timespec, | |
| 178 | ctim: std.os.linux.timespec, | |
| 179 | __unused: [3]i32, | |
| 180 | ||
| 181 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 182 | return self.atim; | |
| 183 | } | |
| 184 | ||
| 185 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 186 | return self.mtim; | |
| 187 | } | |
| 188 | ||
| 189 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 190 | return self.ctim; | |
| 191 | } | |
| 192 | }; |
lib/std/os/linux/x86.zig+38-94| ... | ... | @@ -1,46 +1,34 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("../../std.zig"); |
| 3 | const maxInt = std.math.maxInt; | |
| 4 | const linux = std.os.linux; | |
| 5 | const SYS = linux.SYS; | |
| 6 | const socklen_t = linux.socklen_t; | |
| 7 | const iovec = std.posix.iovec; | |
| 8 | const iovec_const = std.posix.iovec_const; | |
| 9 | const uid_t = linux.uid_t; | |
| 10 | const gid_t = linux.gid_t; | |
| 11 | const pid_t = linux.pid_t; | |
| 12 | const stack_t = linux.stack_t; | |
| 13 | const sigset_t = linux.sigset_t; | |
| 14 | const sockaddr = linux.sockaddr; | |
| 15 | const timespec = linux.timespec; | |
| 3 | const SYS = std.os.linux.SYS; | |
| 16 | 4 | |
| 17 | pub fn syscall0(number: SYS) usize { | |
| 5 | pub fn syscall0(number: SYS) u32 { | |
| 18 | 6 | return asm volatile ("int $0x80" |
| 19 | : [ret] "={eax}" (-> usize), | |
| 7 | : [ret] "={eax}" (-> u32), | |
| 20 | 8 | : [number] "{eax}" (@intFromEnum(number)), |
| 21 | 9 | : .{ .memory = true }); |
| 22 | 10 | } |
| 23 | 11 | |
| 24 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 12 | pub fn syscall1(number: SYS, arg1: u32) u32 { | |
| 25 | 13 | return asm volatile ("int $0x80" |
| 26 | : [ret] "={eax}" (-> usize), | |
| 14 | : [ret] "={eax}" (-> u32), | |
| 27 | 15 | : [number] "{eax}" (@intFromEnum(number)), |
| 28 | 16 | [arg1] "{ebx}" (arg1), |
| 29 | 17 | : .{ .memory = true }); |
| 30 | 18 | } |
| 31 | 19 | |
| 32 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 20 | pub fn syscall2(number: SYS, arg1: u32, arg2: u32) u32 { | |
| 33 | 21 | return asm volatile ("int $0x80" |
| 34 | : [ret] "={eax}" (-> usize), | |
| 22 | : [ret] "={eax}" (-> u32), | |
| 35 | 23 | : [number] "{eax}" (@intFromEnum(number)), |
| 36 | 24 | [arg1] "{ebx}" (arg1), |
| 37 | 25 | [arg2] "{ecx}" (arg2), |
| 38 | 26 | : .{ .memory = true }); |
| 39 | 27 | } |
| 40 | 28 | |
| 41 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 29 | pub fn syscall3(number: SYS, arg1: u32, arg2: u32, arg3: u32) u32 { | |
| 42 | 30 | return asm volatile ("int $0x80" |
| 43 | : [ret] "={eax}" (-> usize), | |
| 31 | : [ret] "={eax}" (-> u32), | |
| 44 | 32 | : [number] "{eax}" (@intFromEnum(number)), |
| 45 | 33 | [arg1] "{ebx}" (arg1), |
| 46 | 34 | [arg2] "{ecx}" (arg2), |
| ... | ... | @@ -48,9 +36,9 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 48 | 36 | : .{ .memory = true }); |
| 49 | 37 | } |
| 50 | 38 | |
| 51 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 39 | pub fn syscall4(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32) u32 { | |
| 52 | 40 | return asm volatile ("int $0x80" |
| 53 | : [ret] "={eax}" (-> usize), | |
| 41 | : [ret] "={eax}" (-> u32), | |
| 54 | 42 | : [number] "{eax}" (@intFromEnum(number)), |
| 55 | 43 | [arg1] "{ebx}" (arg1), |
| 56 | 44 | [arg2] "{ecx}" (arg2), |
| ... | ... | @@ -59,9 +47,9 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 59 | 47 | : .{ .memory = true }); |
| 60 | 48 | } |
| 61 | 49 | |
| 62 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 50 | pub fn syscall5(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32, arg5: u32) u32 { | |
| 63 | 51 | return asm volatile ("int $0x80" |
| 64 | : [ret] "={eax}" (-> usize), | |
| 52 | : [ret] "={eax}" (-> u32), | |
| 65 | 53 | : [number] "{eax}" (@intFromEnum(number)), |
| 66 | 54 | [arg1] "{ebx}" (arg1), |
| 67 | 55 | [arg2] "{ecx}" (arg2), |
| ... | ... | @@ -73,20 +61,20 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 73 | 61 | |
| 74 | 62 | pub fn syscall6( |
| 75 | 63 | number: SYS, |
| 76 | arg1: usize, | |
| 77 | arg2: usize, | |
| 78 | arg3: usize, | |
| 79 | arg4: usize, | |
| 80 | arg5: usize, | |
| 81 | arg6: usize, | |
| 82 | ) usize { | |
| 64 | arg1: u32, | |
| 65 | arg2: u32, | |
| 66 | arg3: u32, | |
| 67 | arg4: u32, | |
| 68 | arg5: u32, | |
| 69 | arg6: u32, | |
| 70 | ) u32 { | |
| 83 | 71 | // arg6 can't be passed to asm in a register because ebp might be reserved as the frame pointer |
| 84 | 72 | // and there are no more GPRs available; so we'll need a memory operand for it. Adding that |
| 85 | 73 | // memory operand means that on PIC we might need a reference to the GOT, which in turn needs |
| 86 | 74 | // *its* own GPR, so we need to pass another arg in memory too! This is surprisingly hard to get |
| 87 | 75 | // right, because we can't touch esp or ebp until we're done with the memory input (as that |
| 88 | 76 | // input could be relative to esp or ebp). |
| 89 | const args56: [2]usize = .{ arg5, arg6 }; | |
| 77 | const args56: [2]u32 = .{ arg5, arg6 }; | |
| 90 | 78 | return asm volatile ( |
| 91 | 79 | \\ push %[args56] |
| 92 | 80 | \\ push %%ebp |
| ... | ... | @@ -99,7 +87,7 @@ pub fn syscall6( |
| 99 | 87 | \\ int $0x80 |
| 100 | 88 | \\ pop %%ebp |
| 101 | 89 | \\ pop %%edi |
| 102 | : [ret] "={eax}" (-> usize), | |
| 90 | : [ret] "={eax}" (-> u32), | |
| 103 | 91 | : [number] "{eax}" (@intFromEnum(number)), |
| 104 | 92 | [arg1] "{ebx}" (arg1), |
| 105 | 93 | [arg2] "{ecx}" (arg2), |
| ... | ... | @@ -109,16 +97,16 @@ pub fn syscall6( |
| 109 | 97 | : .{ .memory = true }); |
| 110 | 98 | } |
| 111 | 99 | |
| 112 | pub fn socketcall(call: usize, args: [*]const usize) usize { | |
| 100 | pub fn socketcall(call: u32, args: [*]const u32) u32 { | |
| 113 | 101 | return asm volatile ("int $0x80" |
| 114 | : [ret] "={eax}" (-> usize), | |
| 102 | : [ret] "={eax}" (-> u32), | |
| 115 | 103 | : [number] "{eax}" (@intFromEnum(SYS.socketcall)), |
| 116 | 104 | [arg1] "{ebx}" (call), |
| 117 | 105 | [arg2] "{ecx}" (@intFromPtr(args)), |
| 118 | 106 | : .{ .memory = true }); |
| 119 | 107 | } |
| 120 | 108 | |
| 121 | pub fn clone() callconv(.naked) usize { | |
| 109 | pub fn clone() callconv(.naked) u32 { | |
| 122 | 110 | // __clone(func, stack, flags, arg, ptid, tls, ctid) |
| 123 | 111 | // +8, +12, +16, +20, +24, +28, +32 |
| 124 | 112 | // |
| ... | ... | @@ -169,23 +157,23 @@ pub fn clone() callconv(.naked) usize { |
| 169 | 157 | } |
| 170 | 158 | |
| 171 | 159 | pub fn restore() callconv(.naked) noreturn { |
| 172 | switch (@import("builtin").zig_backend) { | |
| 160 | switch (builtin.zig_backend) { | |
| 173 | 161 | .stage2_c => asm volatile ( |
| 174 | 162 | \\ movl %[number], %%eax |
| 175 | 163 | \\ int $0x80 |
| 176 | 164 | : |
| 177 | 165 | : [number] "i" (@intFromEnum(SYS.sigreturn)), |
| 178 | : .{ .memory = true }), | |
| 166 | ), | |
| 179 | 167 | else => asm volatile ( |
| 180 | 168 | \\ int $0x80 |
| 181 | 169 | : |
| 182 | 170 | : [number] "{eax}" (@intFromEnum(SYS.sigreturn)), |
| 183 | : .{ .memory = true }), | |
| 171 | ), | |
| 184 | 172 | } |
| 185 | 173 | } |
| 186 | 174 | |
| 187 | 175 | pub fn restore_rt() callconv(.naked) noreturn { |
| 188 | switch (@import("builtin").zig_backend) { | |
| 176 | switch (builtin.zig_backend) { | |
| 189 | 177 | .stage2_c => asm volatile ( |
| 190 | 178 | \\ movl %[number], %%eax |
| 191 | 179 | \\ int $0x80 |
| ... | ... | @@ -200,46 +188,14 @@ pub fn restore_rt() callconv(.naked) noreturn { |
| 200 | 188 | } |
| 201 | 189 | } |
| 202 | 190 | |
| 203 | pub const F = struct { | |
| 204 | pub const DUPFD = 0; | |
| 205 | pub const GETFD = 1; | |
| 206 | pub const SETFD = 2; | |
| 207 | pub const GETFL = 3; | |
| 208 | pub const SETFL = 4; | |
| 209 | pub const SETOWN = 8; | |
| 210 | pub const GETOWN = 9; | |
| 211 | pub const SETSIG = 10; | |
| 212 | pub const GETSIG = 11; | |
| 213 | pub const GETLK = 12; | |
| 214 | pub const SETLK = 13; | |
| 215 | pub const SETLKW = 14; | |
| 216 | pub const SETOWN_EX = 15; | |
| 217 | pub const GETOWN_EX = 16; | |
| 218 | pub const GETOWNER_UIDS = 17; | |
| 219 | ||
| 220 | pub const RDLCK = 0; | |
| 221 | pub const WRLCK = 1; | |
| 222 | pub const UNLCK = 2; | |
| 223 | }; | |
| 224 | ||
| 225 | 191 | pub const VDSO = struct { |
| 226 | 192 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 227 | 193 | pub const CGT_VER = "LINUX_2.6"; |
| 228 | 194 | }; |
| 229 | 195 | |
| 230 | pub const ARCH = struct {}; | |
| 231 | ||
| 232 | pub const Flock = extern struct { | |
| 233 | type: i16, | |
| 234 | whence: i16, | |
| 235 | start: off_t, | |
| 236 | len: off_t, | |
| 237 | pid: pid_t, | |
| 238 | }; | |
| 239 | ||
| 240 | 196 | pub const blksize_t = i32; |
| 241 | 197 | pub const nlink_t = u32; |
| 242 | pub const time_t = isize; | |
| 198 | pub const time_t = i32; | |
| 243 | 199 | pub const mode_t = u32; |
| 244 | 200 | pub const off_t = i64; |
| 245 | 201 | pub const ino_t = u64; |
| ... | ... | @@ -253,43 +209,31 @@ pub const Stat = extern struct { |
| 253 | 209 | __ino_truncated: u32, |
| 254 | 210 | mode: mode_t, |
| 255 | 211 | nlink: nlink_t, |
| 256 | uid: uid_t, | |
| 257 | gid: gid_t, | |
| 212 | uid: std.os.linux.uid_t, | |
| 213 | gid: std.os.linux.gid_t, | |
| 258 | 214 | rdev: dev_t, |
| 259 | 215 | __rdev_padding: u32, |
| 260 | 216 | size: off_t, |
| 261 | 217 | blksize: blksize_t, |
| 262 | 218 | blocks: blkcnt_t, |
| 263 | atim: timespec, | |
| 264 | mtim: timespec, | |
| 265 | ctim: timespec, | |
| 219 | atim: std.os.linux.timespec, | |
| 220 | mtim: std.os.linux.timespec, | |
| 221 | ctim: std.os.linux.timespec, | |
| 266 | 222 | ino: ino_t, |
| 267 | 223 | |
| 268 | pub fn atime(self: @This()) timespec { | |
| 224 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 269 | 225 | return self.atim; |
| 270 | 226 | } |
| 271 | 227 | |
| 272 | pub fn mtime(self: @This()) timespec { | |
| 228 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 273 | 229 | return self.mtim; |
| 274 | 230 | } |
| 275 | 231 | |
| 276 | pub fn ctime(self: @This()) timespec { | |
| 232 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 277 | 233 | return self.ctim; |
| 278 | 234 | } |
| 279 | 235 | }; |
| 280 | 236 | |
| 281 | pub const timeval = extern struct { | |
| 282 | sec: i32, | |
| 283 | usec: i32, | |
| 284 | }; | |
| 285 | ||
| 286 | pub const timezone = extern struct { | |
| 287 | minuteswest: i32, | |
| 288 | dsttime: i32, | |
| 289 | }; | |
| 290 | ||
| 291 | pub const Elf_Symndx = u32; | |
| 292 | ||
| 293 | 237 | pub const user_desc = extern struct { |
| 294 | 238 | entry_number: u32, |
| 295 | 239 | base_addr: u32, |
lib/std/os/linux/x86_64.zig+43-101| ... | ... | @@ -1,48 +1,34 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("../../std.zig"); |
| 3 | const maxInt = std.math.maxInt; | |
| 4 | const linux = std.os.linux; | |
| 5 | const SYS = linux.SYS; | |
| 6 | const iovec = std.posix.iovec; | |
| 7 | const iovec_const = std.posix.iovec_const; | |
| 8 | ||
| 9 | const pid_t = linux.pid_t; | |
| 10 | const uid_t = linux.uid_t; | |
| 11 | const gid_t = linux.gid_t; | |
| 12 | const clock_t = linux.clock_t; | |
| 13 | const stack_t = linux.stack_t; | |
| 14 | const sigset_t = linux.sigset_t; | |
| 15 | const sockaddr = linux.sockaddr; | |
| 16 | const socklen_t = linux.socklen_t; | |
| 17 | const timespec = linux.timespec; | |
| 18 | ||
| 19 | pub fn syscall0(number: SYS) usize { | |
| 3 | const SYS = std.os.linux.SYS; | |
| 4 | ||
| 5 | pub fn syscall0(number: SYS) u64 { | |
| 20 | 6 | return asm volatile ("syscall" |
| 21 | : [ret] "={rax}" (-> usize), | |
| 7 | : [ret] "={rax}" (-> u64), | |
| 22 | 8 | : [number] "{rax}" (@intFromEnum(number)), |
| 23 | 9 | : .{ .rcx = true, .r11 = true, .memory = true }); |
| 24 | 10 | } |
| 25 | 11 | |
| 26 | pub fn syscall1(number: SYS, arg1: usize) usize { | |
| 12 | pub fn syscall1(number: SYS, arg1: u64) u64 { | |
| 27 | 13 | return asm volatile ("syscall" |
| 28 | : [ret] "={rax}" (-> usize), | |
| 14 | : [ret] "={rax}" (-> u64), | |
| 29 | 15 | : [number] "{rax}" (@intFromEnum(number)), |
| 30 | 16 | [arg1] "{rdi}" (arg1), |
| 31 | 17 | : .{ .rcx = true, .r11 = true, .memory = true }); |
| 32 | 18 | } |
| 33 | 19 | |
| 34 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | |
| 20 | pub fn syscall2(number: SYS, arg1: u64, arg2: u64) u64 { | |
| 35 | 21 | return asm volatile ("syscall" |
| 36 | : [ret] "={rax}" (-> usize), | |
| 22 | : [ret] "={rax}" (-> u64), | |
| 37 | 23 | : [number] "{rax}" (@intFromEnum(number)), |
| 38 | 24 | [arg1] "{rdi}" (arg1), |
| 39 | 25 | [arg2] "{rsi}" (arg2), |
| 40 | 26 | : .{ .rcx = true, .r11 = true, .memory = true }); |
| 41 | 27 | } |
| 42 | 28 | |
| 43 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 29 | pub fn syscall3(number: SYS, arg1: u64, arg2: u64, arg3: u64) u64 { | |
| 44 | 30 | return asm volatile ("syscall" |
| 45 | : [ret] "={rax}" (-> usize), | |
| 31 | : [ret] "={rax}" (-> u64), | |
| 46 | 32 | : [number] "{rax}" (@intFromEnum(number)), |
| 47 | 33 | [arg1] "{rdi}" (arg1), |
| 48 | 34 | [arg2] "{rsi}" (arg2), |
| ... | ... | @@ -50,9 +36,9 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 50 | 36 | : .{ .rcx = true, .r11 = true, .memory = true }); |
| 51 | 37 | } |
| 52 | 38 | |
| 53 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 39 | pub fn syscall4(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64) u64 { | |
| 54 | 40 | return asm volatile ("syscall" |
| 55 | : [ret] "={rax}" (-> usize), | |
| 41 | : [ret] "={rax}" (-> u64), | |
| 56 | 42 | : [number] "{rax}" (@intFromEnum(number)), |
| 57 | 43 | [arg1] "{rdi}" (arg1), |
| 58 | 44 | [arg2] "{rsi}" (arg2), |
| ... | ... | @@ -61,9 +47,9 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 61 | 47 | : .{ .rcx = true, .r11 = true, .memory = true }); |
| 62 | 48 | } |
| 63 | 49 | |
| 64 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 50 | pub fn syscall5(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) u64 { | |
| 65 | 51 | return asm volatile ("syscall" |
| 66 | : [ret] "={rax}" (-> usize), | |
| 52 | : [ret] "={rax}" (-> u64), | |
| 67 | 53 | : [number] "{rax}" (@intFromEnum(number)), |
| 68 | 54 | [arg1] "{rdi}" (arg1), |
| 69 | 55 | [arg2] "{rsi}" (arg2), |
| ... | ... | @@ -75,15 +61,15 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 75 | 61 | |
| 76 | 62 | pub fn syscall6( |
| 77 | 63 | number: SYS, |
| 78 | arg1: usize, | |
| 79 | arg2: usize, | |
| 80 | arg3: usize, | |
| 81 | arg4: usize, | |
| 82 | arg5: usize, | |
| 83 | arg6: usize, | |
| 84 | ) usize { | |
| 64 | arg1: u64, | |
| 65 | arg2: u64, | |
| 66 | arg3: u64, | |
| 67 | arg4: u64, | |
| 68 | arg5: u64, | |
| 69 | arg6: u64, | |
| 70 | ) u64 { | |
| 85 | 71 | return asm volatile ("syscall" |
| 86 | : [ret] "={rax}" (-> usize), | |
| 72 | : [ret] "={rax}" (-> u64), | |
| 87 | 73 | : [number] "{rax}" (@intFromEnum(number)), |
| 88 | 74 | [arg1] "{rdi}" (arg1), |
| 89 | 75 | [arg2] "{rsi}" (arg2), |
| ... | ... | @@ -94,7 +80,7 @@ pub fn syscall6( |
| 94 | 80 | : .{ .rcx = true, .r11 = true, .memory = true }); |
| 95 | 81 | } |
| 96 | 82 | |
| 97 | pub fn clone() callconv(.naked) usize { | |
| 83 | pub fn clone() callconv(.naked) u64 { | |
| 98 | 84 | asm volatile ( |
| 99 | 85 | \\ movl $56,%%eax // SYS_clone |
| 100 | 86 | \\ movq %%rdi,%%r11 |
| ... | ... | @@ -131,7 +117,7 @@ pub fn clone() callconv(.naked) usize { |
| 131 | 117 | pub const restore = restore_rt; |
| 132 | 118 | |
| 133 | 119 | pub fn restore_rt() callconv(.naked) noreturn { |
| 134 | switch (@import("builtin").zig_backend) { | |
| 120 | switch (builtin.zig_backend) { | |
| 135 | 121 | .stage2_c => asm volatile ( |
| 136 | 122 | \\ movl %[number], %%eax |
| 137 | 123 | \\ syscall |
| ... | ... | @@ -146,34 +132,14 @@ pub fn restore_rt() callconv(.naked) noreturn { |
| 146 | 132 | } |
| 147 | 133 | } |
| 148 | 134 | |
| 149 | pub const mode_t = usize; | |
| 150 | pub const time_t = isize; | |
| 151 | pub const nlink_t = usize; | |
| 152 | pub const blksize_t = isize; | |
| 153 | pub const blkcnt_t = isize; | |
| 154 | ||
| 155 | pub const F = struct { | |
| 156 | pub const DUPFD = 0; | |
| 157 | pub const GETFD = 1; | |
| 158 | pub const SETFD = 2; | |
| 159 | pub const GETFL = 3; | |
| 160 | pub const SETFL = 4; | |
| 161 | pub const GETLK = 5; | |
| 162 | pub const SETLK = 6; | |
| 163 | pub const SETLKW = 7; | |
| 164 | pub const SETOWN = 8; | |
| 165 | pub const GETOWN = 9; | |
| 166 | pub const SETSIG = 10; | |
| 167 | pub const GETSIG = 11; | |
| 168 | ||
| 169 | pub const SETOWN_EX = 15; | |
| 170 | pub const GETOWN_EX = 16; | |
| 171 | pub const GETOWNER_UIDS = 17; | |
| 172 | ||
| 173 | pub const RDLCK = 0; | |
| 174 | pub const WRLCK = 1; | |
| 175 | pub const UNLCK = 2; | |
| 176 | }; | |
| 135 | pub const mode_t = u64; | |
| 136 | pub const time_t = i64; | |
| 137 | pub const nlink_t = u64; | |
| 138 | pub const blksize_t = i64; | |
| 139 | pub const blkcnt_t = i64; | |
| 140 | pub const off_t = i64; | |
| 141 | pub const ino_t = u64; | |
| 142 | pub const dev_t = u64; | |
| 177 | 143 | |
| 178 | 144 | pub const VDSO = struct { |
| 179 | 145 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| ... | ... | @@ -190,59 +156,35 @@ pub const ARCH = struct { |
| 190 | 156 | pub const GET_GS = 0x1004; |
| 191 | 157 | }; |
| 192 | 158 | |
| 193 | pub const Flock = extern struct { | |
| 194 | type: i16, | |
| 195 | whence: i16, | |
| 196 | start: off_t, | |
| 197 | len: off_t, | |
| 198 | pid: pid_t, | |
| 199 | }; | |
| 200 | ||
| 201 | pub const off_t = i64; | |
| 202 | pub const ino_t = u64; | |
| 203 | pub const dev_t = u64; | |
| 204 | ||
| 205 | 159 | // The `stat` definition used by the Linux kernel. |
| 206 | 160 | pub const Stat = extern struct { |
| 207 | 161 | dev: dev_t, |
| 208 | 162 | ino: ino_t, |
| 209 | nlink: usize, | |
| 163 | nlink: u64, | |
| 210 | 164 | |
| 211 | 165 | mode: u32, |
| 212 | uid: uid_t, | |
| 213 | gid: gid_t, | |
| 166 | uid: std.os.linux.uid_t, | |
| 167 | gid: std.os.linux.gid_t, | |
| 214 | 168 | __pad0: u32, |
| 215 | 169 | rdev: dev_t, |
| 216 | 170 | size: off_t, |
| 217 | blksize: isize, | |
| 171 | blksize: i64, | |
| 218 | 172 | blocks: i64, |
| 219 | 173 | |
| 220 | atim: timespec, | |
| 221 | mtim: timespec, | |
| 222 | ctim: timespec, | |
| 223 | __unused: [3]isize, | |
| 174 | atim: std.os.linux.timespec, | |
| 175 | mtim: std.os.linux.timespec, | |
| 176 | ctim: std.os.linux.timespec, | |
| 177 | __unused: [3]i64, | |
| 224 | 178 | |
| 225 | pub fn atime(self: @This()) timespec { | |
| 179 | pub fn atime(self: @This()) std.os.linux.timespec { | |
| 226 | 180 | return self.atim; |
| 227 | 181 | } |
| 228 | 182 | |
| 229 | pub fn mtime(self: @This()) timespec { | |
| 183 | pub fn mtime(self: @This()) std.os.linux.timespec { | |
| 230 | 184 | return self.mtim; |
| 231 | 185 | } |
| 232 | 186 | |
| 233 | pub fn ctime(self: @This()) timespec { | |
| 187 | pub fn ctime(self: @This()) std.os.linux.timespec { | |
| 234 | 188 | return self.ctim; |
| 235 | 189 | } |
| 236 | 190 | }; |
| 237 | ||
| 238 | pub const timeval = extern struct { | |
| 239 | sec: isize, | |
| 240 | usec: isize, | |
| 241 | }; | |
| 242 | ||
| 243 | pub const timezone = extern struct { | |
| 244 | minuteswest: i32, | |
| 245 | dsttime: i32, | |
| 246 | }; | |
| 247 | ||
| 248 | pub const Elf_Symndx = u32; |