authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-04-07 16:01:41+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-04-07 16:03:22+02:00
log9423712519040c4f7313ccb7fc703b55e2666c45
tree7a44615e2e47be4dd03ab2b48d7a4485c6b82d04
parent6880d2c4a3ef4834c662d2cee86dd0660842f5b1
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std: Disable usage of fstat() and friends on loongarch.

Like riscv32, loongarch exclusively uses statx().

3 files changed, 13 insertions(+), 13 deletions(-)

lib/std/os/linux.zig+8-8
...@@ -1992,8 +1992,8 @@ pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flag...@@ -1992,8 +1992,8 @@ pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flag
1992}1992}
19931993
1994pub fn fstat(fd: i32, stat_buf: *Stat) usize {1994pub fn fstat(fd: i32, stat_buf: *Stat) usize {
1995 if (native_arch == .riscv32) {1995 if (native_arch == .riscv32 or native_arch.isLoongArch()) {
1996 // riscv32 has made the interesting decision to not implement some of1996 // riscv32 and loongarch have made the interesting decision to not implement some of
1997 // the older stat syscalls, including this one.1997 // the older stat syscalls, including this one.
1998 @compileError("No fstat syscall on this architecture.");1998 @compileError("No fstat syscall on this architecture.");
1999 } else if (@hasField(SYS, "fstat64")) {1999 } else if (@hasField(SYS, "fstat64")) {
...@@ -2004,8 +2004,8 @@ pub fn fstat(fd: i32, stat_buf: *Stat) usize {...@@ -2004,8 +2004,8 @@ pub fn fstat(fd: i32, stat_buf: *Stat) usize {
2004}2004}
20052005
2006pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize {2006pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize {
2007 if (native_arch == .riscv32) {2007 if (native_arch == .riscv32 or native_arch.isLoongArch()) {
2008 // riscv32 has made the interesting decision to not implement some of2008 // riscv32 and loongarch have made the interesting decision to not implement some of
2009 // the older stat syscalls, including this one.2009 // the older stat syscalls, including this one.
2010 @compileError("No stat syscall on this architecture.");2010 @compileError("No stat syscall on this architecture.");
2011 } else if (@hasField(SYS, "stat64")) {2011 } else if (@hasField(SYS, "stat64")) {
...@@ -2016,8 +2016,8 @@ pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize {...@@ -2016,8 +2016,8 @@ pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize {
2016}2016}
20172017
2018pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize {2018pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize {
2019 if (native_arch == .riscv32) {2019 if (native_arch == .riscv32 or native_arch.isLoongArch()) {
2020 // riscv32 has made the interesting decision to not implement some of2020 // riscv32 and loongarch have made the interesting decision to not implement some of
2021 // the older stat syscalls, including this one.2021 // the older stat syscalls, including this one.
2022 @compileError("No lstat syscall on this architecture.");2022 @compileError("No lstat syscall on this architecture.");
2023 } else if (@hasField(SYS, "lstat64")) {2023 } else if (@hasField(SYS, "lstat64")) {
...@@ -2028,8 +2028,8 @@ pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize {...@@ -2028,8 +2028,8 @@ pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize {
2028}2028}
20292029
2030pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *Stat, flags: u32) usize {2030pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *Stat, flags: u32) usize {
2031 if (native_arch == .riscv32) {2031 if (native_arch == .riscv32 or native_arch.isLoongArch()) {
2032 // riscv32 has made the interesting decision to not implement some of2032 // riscv32 and loongarch have made the interesting decision to not implement some of
2033 // the older stat syscalls, including this one.2033 // the older stat syscalls, including this one.
2034 @compileError("No fstatat syscall on this architecture.");2034 @compileError("No fstatat syscall on this architecture.");
2035 } else if (@hasField(SYS, "fstatat64")) {2035 } else if (@hasField(SYS, "fstatat64")) {
lib/std/os/linux/test.zig+1-1
...@@ -86,7 +86,7 @@ test "statx" {...@@ -86,7 +86,7 @@ test "statx" {
86 else => unreachable,86 else => unreachable,
87 }87 }
8888
89 if (builtin.cpu.arch == .riscv32) return error.SkipZigTest; // No fstatat, so the rest of the test is meaningless.89 if (builtin.cpu.arch == .riscv32 or builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; // No fstatat, so the rest of the test is meaningless.
9090
91 var stat_buf: linux.Stat = undefined;91 var stat_buf: linux.Stat = undefined;
92 switch (linux.E.init(linux.fstatat(file.handle, "", &stat_buf, linux.AT.EMPTY_PATH))) {92 switch (linux.E.init(linux.fstatat(file.handle, "", &stat_buf, linux.AT.EMPTY_PATH))) {
lib/std/posix/test.zig+4-4
...@@ -283,7 +283,7 @@ fn testReadlink(target_path: []const u8, symlink_path: []const u8) !void {...@@ -283,7 +283,7 @@ fn testReadlink(target_path: []const u8, symlink_path: []const u8) !void {
283283
284test "link with relative paths" {284test "link with relative paths" {
285 if (native_os == .wasi) return error.SkipZigTest; // Can link, but can't change into tmpDir285 if (native_os == .wasi) return error.SkipZigTest; // Can link, but can't change into tmpDir
286 if (builtin.cpu.arch == .riscv32 and builtin.os.tag == .linux and !builtin.link_libc) return error.SkipZigTest; // No `fstat()`.286 if ((builtin.cpu.arch == .riscv32 or builtin.cpu.arch.isLoongArch()) and builtin.os.tag == .linux and !builtin.link_libc) return error.SkipZigTest; // No `fstat()`.
287 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; // `nstat.nlink` assertion is failing with LLVM 20+ for unclear reasons.287 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; // `nstat.nlink` assertion is failing with LLVM 20+ for unclear reasons.
288288
289 switch (native_os) {289 switch (native_os) {
...@@ -331,7 +331,7 @@ test "link with relative paths" {...@@ -331,7 +331,7 @@ test "link with relative paths" {
331}331}
332332
333test "linkat with different directories" {333test "linkat with different directories" {
334 if (builtin.cpu.arch == .riscv32 and builtin.os.tag == .linux and !builtin.link_libc) return error.SkipZigTest; // No `fstatat()`.334 if ((builtin.cpu.arch == .riscv32 or builtin.cpu.arch.isLoongArch()) and builtin.os.tag == .linux and !builtin.link_libc) return error.SkipZigTest; // No `fstatat()`.
335 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; // `nstat.nlink` assertion is failing with LLVM 20+ for unclear reasons.335 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; // `nstat.nlink` assertion is failing with LLVM 20+ for unclear reasons.
336336
337 switch (native_os) {337 switch (native_os) {
...@@ -376,7 +376,7 @@ test "linkat with different directories" {...@@ -376,7 +376,7 @@ test "linkat with different directories" {
376}376}
377377
378test "fstatat" {378test "fstatat" {
379 if (builtin.cpu.arch == .riscv32 and builtin.os.tag == .linux and !builtin.link_libc) return error.SkipZigTest; // No `fstatat()`.379 if ((builtin.cpu.arch == .riscv32 or builtin.cpu.arch.isLoongArch()) and builtin.os.tag == .linux and !builtin.link_libc) return error.SkipZigTest; // No `fstatat()`.
380 // enable when `fstat` and `fstatat` are implemented on Windows380 // enable when `fstat` and `fstatat` are implemented on Windows
381 if (native_os == .windows) return error.SkipZigTest;381 if (native_os == .windows) return error.SkipZigTest;
382382
...@@ -1265,7 +1265,7 @@ test "fchmodat smoke test" {...@@ -1265,7 +1265,7 @@ test "fchmodat smoke test" {
1265 );1265 );
1266 posix.close(fd);1266 posix.close(fd);
12671267
1268 if (builtin.cpu.arch == .riscv32 and builtin.os.tag == .linux and !builtin.link_libc) return error.SkipZigTest; // No `fstatat()`.1268 if ((builtin.cpu.arch == .riscv32 or builtin.cpu.arch.isLoongArch()) and builtin.os.tag == .linux and !builtin.link_libc) return error.SkipZigTest; // No `fstatat()`.
12691269
1270 try posix.symlinkat("regfile", tmp.dir.fd, "symlink");1270 try posix.symlinkat("regfile", tmp.dir.fd, "symlink");
1271 const sym_mode = blk: {1271 const sym_mode = blk: {