| ... | @@ -39,6 +39,7 @@ const arch_bits = switch (native_arch) { | ... | @@ -39,6 +39,7 @@ const arch_bits = switch (native_arch) { |
| 39 | .x86_64 => @import("linux/x86_64.zig"), | 39 | .x86_64 => @import("linux/x86_64.zig"), |
| 40 | .aarch64, .aarch64_be => @import("linux/arm64.zig"), | 40 | .aarch64, .aarch64_be => @import("linux/arm64.zig"), |
| 41 | .arm, .armeb, .thumb, .thumbeb => @import("linux/arm-eabi.zig"), | 41 | .arm, .armeb, .thumb, .thumbeb => @import("linux/arm-eabi.zig"), |
| | 42 | .riscv32 => @import("linux/riscv32.zig"), |
| 42 | .riscv64 => @import("linux/riscv64.zig"), | 43 | .riscv64 => @import("linux/riscv64.zig"), |
| 43 | .sparc64 => @import("linux/sparc64.zig"), | 44 | .sparc64 => @import("linux/sparc64.zig"), |
| 44 | .mips, .mipsel => @import("linux/mips.zig"), | 45 | .mips, .mipsel => @import("linux/mips.zig"), |
| ... | @@ -104,6 +105,7 @@ pub const SYS = switch (@import("builtin").cpu.arch) { | ... | @@ -104,6 +105,7 @@ pub const SYS = switch (@import("builtin").cpu.arch) { |
| 104 | .x86_64 => syscalls.X64, | 105 | .x86_64 => syscalls.X64, |
| 105 | .aarch64, .aarch64_be => syscalls.Arm64, | 106 | .aarch64, .aarch64_be => syscalls.Arm64, |
| 106 | .arm, .armeb, .thumb, .thumbeb => syscalls.Arm, | 107 | .arm, .armeb, .thumb, .thumbeb => syscalls.Arm, |
| | 108 | .riscv32 => syscalls.RiscV32, |
| 107 | .riscv64 => syscalls.RiscV64, | 109 | .riscv64 => syscalls.RiscV64, |
| 108 | .sparc64 => syscalls.Sparc64, | 110 | .sparc64 => syscalls.Sparc64, |
| 109 | .mips, .mipsel => syscalls.Mips, | 111 | .mips, .mipsel => syscalls.Mips, |
| ... | @@ -163,7 +165,7 @@ pub const MAP = switch (native_arch) { | ... | @@ -163,7 +165,7 @@ pub const MAP = switch (native_arch) { |
| 163 | UNINITIALIZED: bool = false, | 165 | UNINITIALIZED: bool = false, |
| 164 | _: u5 = 0, | 166 | _: u5 = 0, |
| 165 | }, | 167 | }, |
| 166 | .riscv64 => packed struct(u32) { | 168 | .riscv32, .riscv64 => packed struct(u32) { |
| 167 | TYPE: MAP_TYPE, | 169 | TYPE: MAP_TYPE, |
| 168 | FIXED: bool = false, | 170 | FIXED: bool = false, |
| 169 | ANONYMOUS: bool = false, | 171 | ANONYMOUS: bool = false, |
| ... | @@ -268,7 +270,7 @@ pub const O = switch (native_arch) { | ... | @@ -268,7 +270,7 @@ pub const O = switch (native_arch) { |
| 268 | TMPFILE: bool = false, | 270 | TMPFILE: bool = false, |
| 269 | _: u9 = 0, | 271 | _: u9 = 0, |
| 270 | }, | 272 | }, |
| 271 | .x86, .riscv64 => packed struct(u32) { | 273 | .x86, .riscv32, .riscv64 => packed struct(u32) { |
| 272 | ACCMODE: ACCMODE = .RDONLY, | 274 | ACCMODE: ACCMODE = .RDONLY, |
| 273 | _2: u4 = 0, | 275 | _2: u4 = 0, |
| 274 | CREAT: bool = false, | 276 | CREAT: bool = false, |
| ... | @@ -1840,7 +1842,11 @@ pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flag | ... | @@ -1840,7 +1842,11 @@ pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flag |
| 1840 | } | 1842 | } |
| 1841 | | 1843 | |
| 1842 | pub fn fstat(fd: i32, stat_buf: *Stat) usize { | 1844 | pub fn fstat(fd: i32, stat_buf: *Stat) usize { |
| 1843 | if (@hasField(SYS, "fstat64")) { | 1845 | if (native_arch == .riscv32) { |
| | 1846 | // riscv32 has made the interesting decision to not implement some of |
| | 1847 | // the older stat syscalls, including this one. |
| | 1848 | @compileError("No fstat syscall on this architecture."); |
| | 1849 | } else if (@hasField(SYS, "fstat64")) { |
| 1844 | return syscall2(.fstat64, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(stat_buf)); | 1850 | return syscall2(.fstat64, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(stat_buf)); |
| 1845 | } else { | 1851 | } else { |
| 1846 | return syscall2(.fstat, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(stat_buf)); | 1852 | return syscall2(.fstat, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(stat_buf)); |
| ... | @@ -1848,7 +1854,11 @@ pub fn fstat(fd: i32, stat_buf: *Stat) usize { | ... | @@ -1848,7 +1854,11 @@ pub fn fstat(fd: i32, stat_buf: *Stat) usize { |
| 1848 | } | 1854 | } |
| 1849 | | 1855 | |
| 1850 | pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize { | 1856 | pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize { |
| 1851 | if (@hasField(SYS, "stat64")) { | 1857 | if (native_arch == .riscv32) { |
| | 1858 | // riscv32 has made the interesting decision to not implement some of |
| | 1859 | // the older stat syscalls, including this one. |
| | 1860 | @compileError("No stat syscall on this architecture."); |
| | 1861 | } else if (@hasField(SYS, "stat64")) { |
| 1852 | return syscall2(.stat64, @intFromPtr(pathname), @intFromPtr(statbuf)); | 1862 | return syscall2(.stat64, @intFromPtr(pathname), @intFromPtr(statbuf)); |
| 1853 | } else { | 1863 | } else { |
| 1854 | return syscall2(.stat, @intFromPtr(pathname), @intFromPtr(statbuf)); | 1864 | return syscall2(.stat, @intFromPtr(pathname), @intFromPtr(statbuf)); |
| ... | @@ -1856,7 +1866,11 @@ pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize { | ... | @@ -1856,7 +1866,11 @@ pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize { |
| 1856 | } | 1866 | } |
| 1857 | | 1867 | |
| 1858 | pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize { | 1868 | pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize { |
| 1859 | if (@hasField(SYS, "lstat64")) { | 1869 | if (native_arch == .riscv32) { |
| | 1870 | // riscv32 has made the interesting decision to not implement some of |
| | 1871 | // the older stat syscalls, including this one. |
| | 1872 | @compileError("No lstat syscall on this architecture."); |
| | 1873 | } else if (@hasField(SYS, "lstat64")) { |
| 1860 | return syscall2(.lstat64, @intFromPtr(pathname), @intFromPtr(statbuf)); | 1874 | return syscall2(.lstat64, @intFromPtr(pathname), @intFromPtr(statbuf)); |
| 1861 | } else { | 1875 | } else { |
| 1862 | return syscall2(.lstat, @intFromPtr(pathname), @intFromPtr(statbuf)); | 1876 | return syscall2(.lstat, @intFromPtr(pathname), @intFromPtr(statbuf)); |
| ... | @@ -1864,7 +1878,11 @@ pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize { | ... | @@ -1864,7 +1878,11 @@ pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize { |
| 1864 | } | 1878 | } |
| 1865 | | 1879 | |
| 1866 | pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *Stat, flags: u32) usize { | 1880 | pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *Stat, flags: u32) usize { |
| 1867 | if (@hasField(SYS, "fstatat64")) { | 1881 | if (native_arch == .riscv32) { |
| | 1882 | // riscv32 has made the interesting decision to not implement some of |
| | 1883 | // the older stat syscalls, including this one. |
| | 1884 | @compileError("No fstatat syscall on this architecture."); |
| | 1885 | } else if (@hasField(SYS, "fstatat64")) { |
| 1868 | return syscall4(.fstatat64, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), @intFromPtr(stat_buf), flags); | 1886 | return syscall4(.fstatat64, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), @intFromPtr(stat_buf), flags); |
| 1869 | } else { | 1887 | } else { |
| 1870 | return syscall4(.fstatat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), @intFromPtr(stat_buf), flags); | 1888 | return syscall4(.fstatat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), @intFromPtr(stat_buf), flags); |
| ... | @@ -7352,6 +7370,7 @@ pub const AUDIT = struct { | ... | @@ -7352,6 +7370,7 @@ pub const AUDIT = struct { |
| 7352 | .x86_64 => .X86_64, | 7370 | .x86_64 => .X86_64, |
| 7353 | .aarch64 => .AARCH64, | 7371 | .aarch64 => .AARCH64, |
| 7354 | .arm, .thumb => .ARM, | 7372 | .arm, .thumb => .ARM, |
| | 7373 | .riscv32 => .RISCV32, |
| 7355 | .riscv64 => .RISCV64, | 7374 | .riscv64 => .RISCV64, |
| 7356 | .sparc64 => .SPARC64, | 7375 | .sparc64 => .SPARC64, |
| 7357 | .mips => .MIPS, | 7376 | .mips => .MIPS, |