From 537cb49eb241521bf58df8510c1c86aea60eb84f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sat, 31 Aug 2024 03:27:07 +0200 Subject: [PATCH] std.os.linux: Define the Stat struct for riscv32. The kernel does define the struct, it just doesn't use it. Yet both glibc and musl expose it directly as their public stat struct, and std.c takes it from std.os.linux. So just define it after all. --- lib/std/os/linux/riscv32.zig | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/lib/std/os/linux/riscv32.zig b/lib/std/os/linux/riscv32.zig index 08288d45e5bf5cfdeb8497ffa4463367ca92ccc0..457d7e50b4b445a0bf433d4007f067b8e5afa2d4 100644 --- a/lib/std/os/linux/riscv32.zig +++ b/lib/std/os/linux/riscv32.zig @@ -212,8 +212,37 @@ pub const msghdr_const = extern struct { flags: i32, }; -/// No `Stat` structure on this platform, only `Statx`. -pub const Stat = void; +// The `stat` definition used by the Linux kernel. +pub const Stat = extern struct { + dev: dev_t, + ino: ino_t, + mode: mode_t, + nlink: nlink_t, + uid: uid_t, + gid: gid_t, + rdev: dev_t, + __pad: usize, + size: off_t, + blksize: blksize_t, + __pad2: i32, + blocks: blkcnt_t, + atim: timespec, + mtim: timespec, + ctim: timespec, + __unused: [2]u32, + + pub fn atime(self: @This()) timespec { + return self.atim; + } + + pub fn mtime(self: @This()) timespec { + return self.mtim; + } + + pub fn ctime(self: @This()) timespec { + return self.ctim; + } +}; pub const Elf_Symndx = u32; -- 2.54.0