mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 22:35:24 +00:00
fix regression on linux with kernel_timespec
I incorrectly assumed that __kernel_timespec was used when not linking libc, however that is not the case. `std.os.timespec` is used both for libc and non-libc cases. `__kernel_timespec` is a special struct that is used only for io_uring.
This commit is contained in:
parent
21171fd71b
commit
2264fca03e
@ -81,7 +81,6 @@ pub const msghdr_const = arch_bits.msghdr_const;
|
||||
pub const nlink_t = arch_bits.nlink_t;
|
||||
pub const off_t = arch_bits.off_t;
|
||||
pub const time_t = arch_bits.time_t;
|
||||
pub const timespec = arch_bits.timespec;
|
||||
pub const timeval = arch_bits.timeval;
|
||||
pub const timezone = arch_bits.timezone;
|
||||
pub const ucontext_t = arch_bits.ucontext_t;
|
||||
@ -4149,11 +4148,17 @@ pub const POSIX_FADV = switch (native_arch) {
|
||||
},
|
||||
};
|
||||
|
||||
pub const __kernel_timespec = extern struct {
|
||||
/// The timespec struct used by the kernel.
|
||||
pub const kernel_timespec = if (@sizeOf(usize) >= 8) timespec else extern struct {
|
||||
tv_sec: i64,
|
||||
tv_nsec: i64,
|
||||
};
|
||||
|
||||
pub const timespec = extern struct {
|
||||
tv_sec: isize,
|
||||
tv_nsec: isize,
|
||||
};
|
||||
|
||||
pub const XDP = struct {
|
||||
pub const SHARED_UMEM = (1 << 0);
|
||||
pub const COPY = (1 << 1);
|
||||
|
||||
@ -10,6 +10,7 @@ const uid_t = linux.uid_t;
|
||||
const gid_t = linux.gid_t;
|
||||
const pid_t = linux.pid_t;
|
||||
const sockaddr = linux.sockaddr;
|
||||
const timespec = linux.timespec;
|
||||
|
||||
pub fn syscall0(number: SYS) usize {
|
||||
return asm volatile ("svc #0"
|
||||
@ -703,11 +704,6 @@ pub const Stat = extern struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub const timespec = extern struct {
|
||||
tv_sec: i32,
|
||||
tv_nsec: i32,
|
||||
};
|
||||
|
||||
pub const timeval = extern struct {
|
||||
tv_sec: i32,
|
||||
tv_usec: i32,
|
||||
|
||||
@ -10,6 +10,7 @@ const gid_t = linux.gid_t;
|
||||
const pid_t = linux.pid_t;
|
||||
const stack_t = linux.stack_t;
|
||||
const sigset_t = linux.sigset_t;
|
||||
const timespec = std.os.linux.timespec;
|
||||
|
||||
pub fn syscall0(number: SYS) usize {
|
||||
return asm volatile ("svc #0"
|
||||
@ -558,11 +559,6 @@ pub const Stat = extern struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub const timespec = extern struct {
|
||||
tv_sec: time_t,
|
||||
tv_nsec: isize,
|
||||
};
|
||||
|
||||
pub const timeval = extern struct {
|
||||
tv_sec: isize,
|
||||
tv_usec: isize,
|
||||
|
||||
@ -10,6 +10,7 @@ const pid_t = linux.pid_t;
|
||||
const stack_t = linux.stack_t;
|
||||
const sigset_t = linux.sigset_t;
|
||||
const sockaddr = linux.sockaddr;
|
||||
const timespec = linux.timespec;
|
||||
|
||||
pub fn syscall0(number: SYS) usize {
|
||||
return asm volatile ("int $0x80"
|
||||
@ -710,11 +711,6 @@ pub const Stat = extern struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub const timespec = extern struct {
|
||||
tv_sec: i32,
|
||||
tv_nsec: i32,
|
||||
};
|
||||
|
||||
pub const timeval = extern struct {
|
||||
tv_sec: i32,
|
||||
tv_usec: i32,
|
||||
|
||||
@ -539,7 +539,7 @@ pub const IO_Uring = struct {
|
||||
pub fn timeout(
|
||||
self: *IO_Uring,
|
||||
user_data: u64,
|
||||
ts: *const os.linux.timespec,
|
||||
ts: *const os.linux.kernel_timespec,
|
||||
count: u32,
|
||||
flags: u32,
|
||||
) !*io_uring_sqe {
|
||||
@ -979,7 +979,7 @@ pub fn io_uring_prep_close(sqe: *io_uring_sqe, fd: os.fd_t) void {
|
||||
|
||||
pub fn io_uring_prep_timeout(
|
||||
sqe: *io_uring_sqe,
|
||||
ts: *const os.linux.timespec,
|
||||
ts: *const os.linux.kernel_timespec,
|
||||
count: u32,
|
||||
flags: u32,
|
||||
) void {
|
||||
@ -1450,7 +1450,7 @@ test "timeout (after a relative time)" {
|
||||
|
||||
const ms = 10;
|
||||
const margin = 5;
|
||||
const ts = os.linux.timespec{ .tv_sec = 0, .tv_nsec = ms * 1000000 };
|
||||
const ts = os.linux.kernel_timespec{ .tv_sec = 0, .tv_nsec = ms * 1000000 };
|
||||
|
||||
const started = std.time.milliTimestamp();
|
||||
const sqe = try ring.timeout(0x55555555, &ts, 0, 0);
|
||||
@ -1479,7 +1479,7 @@ test "timeout (after a number of completions)" {
|
||||
};
|
||||
defer ring.deinit();
|
||||
|
||||
const ts = os.linux.timespec{ .tv_sec = 3, .tv_nsec = 0 };
|
||||
const ts = os.linux.kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 };
|
||||
const count_completions: u64 = 1;
|
||||
const sqe_timeout = try ring.timeout(0x66666666, &ts, count_completions, 0);
|
||||
try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode);
|
||||
@ -1512,7 +1512,7 @@ test "timeout_remove" {
|
||||
};
|
||||
defer ring.deinit();
|
||||
|
||||
const ts = os.linux.timespec{ .tv_sec = 3, .tv_nsec = 0 };
|
||||
const ts = os.linux.kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 };
|
||||
const sqe_timeout = try ring.timeout(0x88888888, &ts, 0, 0);
|
||||
try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode);
|
||||
try testing.expectEqual(@as(u64, 0x88888888), sqe_timeout.user_data);
|
||||
|
||||
@ -7,6 +7,7 @@ const iovec_const = linux.iovec_const;
|
||||
const uid_t = linux.uid_t;
|
||||
const gid_t = linux.gid_t;
|
||||
const pid_t = linux.pid_t;
|
||||
const timespec = linux.timespec;
|
||||
|
||||
pub fn syscall0(number: SYS) usize {
|
||||
return asm volatile (
|
||||
@ -753,11 +754,6 @@ pub const Stat = extern struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub const timespec = extern struct {
|
||||
tv_sec: isize,
|
||||
tv_nsec: isize,
|
||||
};
|
||||
|
||||
pub const timeval = extern struct {
|
||||
tv_sec: isize,
|
||||
tv_usec: isize,
|
||||
|
||||
@ -10,6 +10,7 @@ const pid_t = linux.pid_t;
|
||||
const stack_t = linux.stack_t;
|
||||
const sigset_t = linux.sigset_t;
|
||||
const sockaddr = linux.sockaddr;
|
||||
const timespec = linux.timespec;
|
||||
|
||||
pub fn syscall0(number: SYS) usize {
|
||||
return asm volatile (
|
||||
@ -704,11 +705,6 @@ pub const Stat = extern struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub const timespec = extern struct {
|
||||
tv_sec: time_t,
|
||||
tv_nsec: isize,
|
||||
};
|
||||
|
||||
pub const timeval = extern struct {
|
||||
tv_sec: time_t,
|
||||
tv_usec: isize,
|
||||
|
||||
@ -10,6 +10,7 @@ const pid_t = linux.pid_t;
|
||||
const stack_t = linux.stack_t;
|
||||
const sigset_t = linux.sigset_t;
|
||||
const sockaddr = linux.sockaddr;
|
||||
const timespec = linux.timespec;
|
||||
|
||||
pub fn syscall0(number: SYS) usize {
|
||||
return asm volatile (
|
||||
@ -679,11 +680,6 @@ pub const Stat = extern struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub const timespec = extern struct {
|
||||
tv_sec: time_t,
|
||||
tv_nsec: isize,
|
||||
};
|
||||
|
||||
pub const timeval = extern struct {
|
||||
tv_sec: isize,
|
||||
tv_usec: isize,
|
||||
|
||||
@ -2,6 +2,7 @@ const std = @import("../../std.zig");
|
||||
const uid_t = std.os.linux.uid_t;
|
||||
const gid_t = std.os.linux.gid_t;
|
||||
const pid_t = std.os.linux.pid_t;
|
||||
const timespec = std.os.linux.timespec;
|
||||
|
||||
pub fn syscall0(number: SYS) usize {
|
||||
return asm volatile ("ecall"
|
||||
@ -468,10 +469,6 @@ pub const off_t = isize;
|
||||
pub const ino_t = usize;
|
||||
pub const dev_t = usize;
|
||||
pub const blkcnt_t = isize;
|
||||
pub const timespec = extern struct {
|
||||
tv_sec: time_t,
|
||||
tv_nsec: isize,
|
||||
};
|
||||
|
||||
pub const timeval = extern struct {
|
||||
tv_sec: time_t,
|
||||
|
||||
@ -11,6 +11,7 @@ const sockaddr = linux.sockaddr;
|
||||
const socklen_t = linux.socklen_t;
|
||||
const iovec = linux.iovec;
|
||||
const iovec_const = linux.iovec_const;
|
||||
const timespec = linux.timespec;
|
||||
|
||||
pub fn syscall_pipe(fd: *[2]i32) usize {
|
||||
return asm volatile (
|
||||
@ -708,11 +709,6 @@ pub const Stat = extern struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub const timespec = extern struct {
|
||||
tv_sec: isize,
|
||||
tv_nsec: isize,
|
||||
};
|
||||
|
||||
pub const timeval = extern struct {
|
||||
tv_sec: isize,
|
||||
tv_usec: isize,
|
||||
|
||||
@ -12,6 +12,7 @@ const stack_t = linux.stack_t;
|
||||
const sigset_t = linux.sigset_t;
|
||||
const sockaddr = linux.sockaddr;
|
||||
const socklen_t = linux.socklen_t;
|
||||
const timespec = linux.timespec;
|
||||
|
||||
pub fn syscall0(number: SYS) usize {
|
||||
return asm volatile ("syscall"
|
||||
@ -653,11 +654,6 @@ pub const Stat = extern struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub const timespec = extern struct {
|
||||
tv_sec: isize,
|
||||
tv_nsec: isize,
|
||||
};
|
||||
|
||||
pub const timeval = extern struct {
|
||||
tv_sec: isize,
|
||||
tv_usec: isize,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user