os/linux: fix IO_Uring.timeout
According to the io_uring PDF (https://kernel.dk/io_uring.pdf) the timeout struct must be 64 bits on both 32 and 64 bit architectures.
This commit is contained in:
committed by
Veikka Tuominen
parent
f296c95599
commit
3dd8396a55
@@ -2244,3 +2244,8 @@ pub const MADV_COLD = 20;
|
||||
pub const MADV_PAGEOUT = 21;
|
||||
pub const MADV_HWPOISON = 100;
|
||||
pub const MADV_SOFT_OFFLINE = 101;
|
||||
|
||||
pub const __kernel_timespec = extern struct {
|
||||
tv_sec: i64,
|
||||
tv_nsec: i64,
|
||||
};
|
||||
|
||||
@@ -526,7 +526,7 @@ pub const IO_Uring = struct {
|
||||
pub fn timeout(
|
||||
self: *IO_Uring,
|
||||
user_data: u64,
|
||||
ts: *const os.timespec,
|
||||
ts: *const os.__kernel_timespec,
|
||||
count: u32,
|
||||
flags: u32,
|
||||
) !*io_uring_sqe {
|
||||
@@ -884,7 +884,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.timespec,
|
||||
ts: *const os.__kernel_timespec,
|
||||
count: u32,
|
||||
flags: u32,
|
||||
) void {
|
||||
@@ -1339,7 +1339,7 @@ test "timeout (after a relative time)" {
|
||||
|
||||
const ms = 10;
|
||||
const margin = 5;
|
||||
const ts = os.timespec{ .tv_sec = 0, .tv_nsec = ms * 1000000 };
|
||||
const ts = os.__kernel_timespec{ .tv_sec = 0, .tv_nsec = ms * 1000000 };
|
||||
|
||||
const started = std.time.milliTimestamp();
|
||||
const sqe = try ring.timeout(0x55555555, &ts, 0, 0);
|
||||
@@ -1366,7 +1366,7 @@ test "timeout (after a number of completions)" {
|
||||
};
|
||||
defer ring.deinit();
|
||||
|
||||
const ts = os.timespec{ .tv_sec = 3, .tv_nsec = 0 };
|
||||
const ts = os.__kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 };
|
||||
const count_completions: u64 = 1;
|
||||
const sqe_timeout = try ring.timeout(0x66666666, &ts, count_completions, 0);
|
||||
testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode);
|
||||
@@ -1399,7 +1399,7 @@ test "timeout_remove" {
|
||||
};
|
||||
defer ring.deinit();
|
||||
|
||||
const ts = os.timespec{ .tv_sec = 3, .tv_nsec = 0 };
|
||||
const ts = os.__kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 };
|
||||
const sqe_timeout = try ring.timeout(0x88888888, &ts, 0, 0);
|
||||
testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode);
|
||||
testing.expectEqual(@as(u64, 0x88888888), sqe_timeout.user_data);
|
||||
|
||||
Reference in New Issue
Block a user