mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
std.os.linux: Define timespec as kernel_timespec (64-bit) for riscv32.
This is kind of a hack because the timespec in UAPI headers is actually still 32-bit while __kernel_timespec is 64-bit. But, importantly, all the syscalls take __kernel_timespec from the get-go (because riscv32 support is so recent). Defining our timespec this way will allow all the syscall wrappers in std.os.linux to do the right thing for riscv32. For other 32-bit architectures, we have to use the 64-bit time syscalls explicitly to solve the Y2038 problem.
This commit is contained in:
parent
cafce8c767
commit
890433e292
@ -6327,12 +6327,13 @@ pub const POSIX_FADV = switch (native_arch) {
|
||||
};
|
||||
|
||||
/// The timespec struct used by the kernel.
|
||||
pub const kernel_timespec = if (@sizeOf(usize) >= 8) timespec else extern struct {
|
||||
pub const kernel_timespec = extern struct {
|
||||
sec: i64,
|
||||
nsec: i64,
|
||||
};
|
||||
|
||||
pub const timespec = extern struct {
|
||||
// https://github.com/ziglang/zig/issues/4726#issuecomment-2190337877
|
||||
pub const timespec = if (!builtin.link_libc and native_arch == .riscv32) kernel_timespec else extern struct {
|
||||
sec: isize,
|
||||
nsec: isize,
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user