zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 537cb49eb241521bf58df8510c1c86aea60eb84f (tree)
parent e084c46ed6906dc51724d99b29f0992272384f5a
Author: Alex Rønne Petersen <alex@alexrp.com>
Date:   Sat, 31 Aug 2024 03:27:07 +0200

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.

Diffstat:
Mlib/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 @@ -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;