| author | |
| committer | |
| log | 2264fca03e6ce9203baf52d70825ec3bc32f8262 |
| tree | 33cfda1ae8fb44e36cc0b1e6dcdad76063f345d7 |
| parent | 21171fd71b6b3c69a404176e8fe4620b9768d5a6 |
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.11 files changed, 21 insertions(+), 51 deletions(-)
lib/std/os/linux.zig+7-2| ... | ... | @@ -81,7 +81,6 @@ pub const msghdr_const = arch_bits.msghdr_const; |
| 81 | 81 | pub const nlink_t = arch_bits.nlink_t; |
| 82 | 82 | pub const off_t = arch_bits.off_t; |
| 83 | 83 | pub const time_t = arch_bits.time_t; |
| 84 | pub const timespec = arch_bits.timespec; | |
| 85 | 84 | pub const timeval = arch_bits.timeval; |
| 86 | 85 | pub const timezone = arch_bits.timezone; |
| 87 | 86 | pub const ucontext_t = arch_bits.ucontext_t; |
| ... | ... | @@ -4149,11 +4148,17 @@ pub const POSIX_FADV = switch (native_arch) { |
| 4149 | 4148 | }, |
| 4150 | 4149 | }; |
| 4151 | 4150 | |
| 4152 | pub const __kernel_timespec = extern struct { | |
| 4151 | /// The timespec struct used by the kernel. | |
| 4152 | pub const kernel_timespec = if (@sizeOf(usize) >= 8) timespec else extern struct { | |
| 4153 | 4153 | tv_sec: i64, |
| 4154 | 4154 | tv_nsec: i64, |
| 4155 | 4155 | }; |
| 4156 | 4156 | |
| 4157 | pub const timespec = extern struct { | |
| 4158 | tv_sec: isize, | |
| 4159 | tv_nsec: isize, | |
| 4160 | }; | |
| 4161 | ||
| 4157 | 4162 | pub const XDP = struct { |
| 4158 | 4163 | pub const SHARED_UMEM = (1 << 0); |
| 4159 | 4164 | pub const COPY = (1 << 1); |
lib/std/os/linux/arm-eabi.zig+1-5| ... | ... | @@ -10,6 +10,7 @@ const uid_t = linux.uid_t; |
| 10 | 10 | const gid_t = linux.gid_t; |
| 11 | 11 | const pid_t = linux.pid_t; |
| 12 | 12 | const sockaddr = linux.sockaddr; |
| 13 | const timespec = linux.timespec; | |
| 13 | 14 | |
| 14 | 15 | pub fn syscall0(number: SYS) usize { |
| 15 | 16 | return asm volatile ("svc #0" |
| ... | ... | @@ -703,11 +704,6 @@ pub const Stat = extern struct { |
| 703 | 704 | } |
| 704 | 705 | }; |
| 705 | 706 | |
| 706 | pub const timespec = extern struct { | |
| 707 | tv_sec: i32, | |
| 708 | tv_nsec: i32, | |
| 709 | }; | |
| 710 | ||
| 711 | 707 | pub const timeval = extern struct { |
| 712 | 708 | tv_sec: i32, |
| 713 | 709 | tv_usec: i32, |
lib/std/os/linux/arm64.zig+1-5| ... | ... | @@ -10,6 +10,7 @@ const gid_t = linux.gid_t; |
| 10 | 10 | const pid_t = linux.pid_t; |
| 11 | 11 | const stack_t = linux.stack_t; |
| 12 | 12 | const sigset_t = linux.sigset_t; |
| 13 | const timespec = std.os.linux.timespec; | |
| 13 | 14 | |
| 14 | 15 | pub fn syscall0(number: SYS) usize { |
| 15 | 16 | return asm volatile ("svc #0" |
| ... | ... | @@ -558,11 +559,6 @@ pub const Stat = extern struct { |
| 558 | 559 | } |
| 559 | 560 | }; |
| 560 | 561 | |
| 561 | pub const timespec = extern struct { | |
| 562 | tv_sec: time_t, | |
| 563 | tv_nsec: isize, | |
| 564 | }; | |
| 565 | ||
| 566 | 562 | pub const timeval = extern struct { |
| 567 | 563 | tv_sec: isize, |
| 568 | 564 | tv_usec: isize, |
lib/std/os/linux/i386.zig+1-5| ... | ... | @@ -10,6 +10,7 @@ const pid_t = linux.pid_t; |
| 10 | 10 | const stack_t = linux.stack_t; |
| 11 | 11 | const sigset_t = linux.sigset_t; |
| 12 | 12 | const sockaddr = linux.sockaddr; |
| 13 | const timespec = linux.timespec; | |
| 13 | 14 | |
| 14 | 15 | pub fn syscall0(number: SYS) usize { |
| 15 | 16 | return asm volatile ("int $0x80" |
| ... | ... | @@ -710,11 +711,6 @@ pub const Stat = extern struct { |
| 710 | 711 | } |
| 711 | 712 | }; |
| 712 | 713 | |
| 713 | pub const timespec = extern struct { | |
| 714 | tv_sec: i32, | |
| 715 | tv_nsec: i32, | |
| 716 | }; | |
| 717 | ||
| 718 | 714 | pub const timeval = extern struct { |
| 719 | 715 | tv_sec: i32, |
| 720 | 716 | tv_usec: i32, |
lib/std/os/linux/io_uring.zig+5-5| ... | ... | @@ -539,7 +539,7 @@ pub const IO_Uring = struct { |
| 539 | 539 | pub fn timeout( |
| 540 | 540 | self: *IO_Uring, |
| 541 | 541 | user_data: u64, |
| 542 | ts: *const os.linux.timespec, | |
| 542 | ts: *const os.linux.kernel_timespec, | |
| 543 | 543 | count: u32, |
| 544 | 544 | flags: u32, |
| 545 | 545 | ) !*io_uring_sqe { |
| ... | ... | @@ -979,7 +979,7 @@ pub fn io_uring_prep_close(sqe: *io_uring_sqe, fd: os.fd_t) void { |
| 979 | 979 | |
| 980 | 980 | pub fn io_uring_prep_timeout( |
| 981 | 981 | sqe: *io_uring_sqe, |
| 982 | ts: *const os.linux.timespec, | |
| 982 | ts: *const os.linux.kernel_timespec, | |
| 983 | 983 | count: u32, |
| 984 | 984 | flags: u32, |
| 985 | 985 | ) void { |
| ... | ... | @@ -1450,7 +1450,7 @@ test "timeout (after a relative time)" { |
| 1450 | 1450 | |
| 1451 | 1451 | const ms = 10; |
| 1452 | 1452 | const margin = 5; |
| 1453 | const ts = os.linux.timespec{ .tv_sec = 0, .tv_nsec = ms * 1000000 }; | |
| 1453 | const ts = os.linux.kernel_timespec{ .tv_sec = 0, .tv_nsec = ms * 1000000 }; | |
| 1454 | 1454 | |
| 1455 | 1455 | const started = std.time.milliTimestamp(); |
| 1456 | 1456 | const sqe = try ring.timeout(0x55555555, &ts, 0, 0); |
| ... | ... | @@ -1479,7 +1479,7 @@ test "timeout (after a number of completions)" { |
| 1479 | 1479 | }; |
| 1480 | 1480 | defer ring.deinit(); |
| 1481 | 1481 | |
| 1482 | const ts = os.linux.timespec{ .tv_sec = 3, .tv_nsec = 0 }; | |
| 1482 | const ts = os.linux.kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 }; | |
| 1483 | 1483 | const count_completions: u64 = 1; |
| 1484 | 1484 | const sqe_timeout = try ring.timeout(0x66666666, &ts, count_completions, 0); |
| 1485 | 1485 | try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode); |
| ... | ... | @@ -1512,7 +1512,7 @@ test "timeout_remove" { |
| 1512 | 1512 | }; |
| 1513 | 1513 | defer ring.deinit(); |
| 1514 | 1514 | |
| 1515 | const ts = os.linux.timespec{ .tv_sec = 3, .tv_nsec = 0 }; | |
| 1515 | const ts = os.linux.kernel_timespec{ .tv_sec = 3, .tv_nsec = 0 }; | |
| 1516 | 1516 | const sqe_timeout = try ring.timeout(0x88888888, &ts, 0, 0); |
| 1517 | 1517 | try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode); |
| 1518 | 1518 | try testing.expectEqual(@as(u64, 0x88888888), sqe_timeout.user_data); |
lib/std/os/linux/mips.zig+1-5| ... | ... | @@ -7,6 +7,7 @@ const iovec_const = linux.iovec_const; |
| 7 | 7 | const uid_t = linux.uid_t; |
| 8 | 8 | const gid_t = linux.gid_t; |
| 9 | 9 | const pid_t = linux.pid_t; |
| 10 | const timespec = linux.timespec; | |
| 10 | 11 | |
| 11 | 12 | pub fn syscall0(number: SYS) usize { |
| 12 | 13 | return asm volatile ( |
| ... | ... | @@ -753,11 +754,6 @@ pub const Stat = extern struct { |
| 753 | 754 | } |
| 754 | 755 | }; |
| 755 | 756 | |
| 756 | pub const timespec = extern struct { | |
| 757 | tv_sec: isize, | |
| 758 | tv_nsec: isize, | |
| 759 | }; | |
| 760 | ||
| 761 | 757 | pub const timeval = extern struct { |
| 762 | 758 | tv_sec: isize, |
| 763 | 759 | tv_usec: isize, |
lib/std/os/linux/powerpc.zig+1-5| ... | ... | @@ -10,6 +10,7 @@ const pid_t = linux.pid_t; |
| 10 | 10 | const stack_t = linux.stack_t; |
| 11 | 11 | const sigset_t = linux.sigset_t; |
| 12 | 12 | const sockaddr = linux.sockaddr; |
| 13 | const timespec = linux.timespec; | |
| 13 | 14 | |
| 14 | 15 | pub fn syscall0(number: SYS) usize { |
| 15 | 16 | return asm volatile ( |
| ... | ... | @@ -704,11 +705,6 @@ pub const Stat = extern struct { |
| 704 | 705 | } |
| 705 | 706 | }; |
| 706 | 707 | |
| 707 | pub const timespec = extern struct { | |
| 708 | tv_sec: time_t, | |
| 709 | tv_nsec: isize, | |
| 710 | }; | |
| 711 | ||
| 712 | 708 | pub const timeval = extern struct { |
| 713 | 709 | tv_sec: time_t, |
| 714 | 710 | tv_usec: isize, |
lib/std/os/linux/powerpc64.zig+1-5| ... | ... | @@ -10,6 +10,7 @@ const pid_t = linux.pid_t; |
| 10 | 10 | const stack_t = linux.stack_t; |
| 11 | 11 | const sigset_t = linux.sigset_t; |
| 12 | 12 | const sockaddr = linux.sockaddr; |
| 13 | const timespec = linux.timespec; | |
| 13 | 14 | |
| 14 | 15 | pub fn syscall0(number: SYS) usize { |
| 15 | 16 | return asm volatile ( |
| ... | ... | @@ -679,11 +680,6 @@ pub const Stat = extern struct { |
| 679 | 680 | } |
| 680 | 681 | }; |
| 681 | 682 | |
| 682 | pub const timespec = extern struct { | |
| 683 | tv_sec: time_t, | |
| 684 | tv_nsec: isize, | |
| 685 | }; | |
| 686 | ||
| 687 | 683 | pub const timeval = extern struct { |
| 688 | 684 | tv_sec: isize, |
| 689 | 685 | tv_usec: isize, |
lib/std/os/linux/riscv64.zig+1-4| ... | ... | @@ -2,6 +2,7 @@ const std = @import("../../std.zig"); |
| 2 | 2 | const uid_t = std.os.linux.uid_t; |
| 3 | 3 | const gid_t = std.os.linux.gid_t; |
| 4 | 4 | const pid_t = std.os.linux.pid_t; |
| 5 | const timespec = std.os.linux.timespec; | |
| 5 | 6 | |
| 6 | 7 | pub fn syscall0(number: SYS) usize { |
| 7 | 8 | return asm volatile ("ecall" |
| ... | ... | @@ -468,10 +469,6 @@ pub const off_t = isize; |
| 468 | 469 | pub const ino_t = usize; |
| 469 | 470 | pub const dev_t = usize; |
| 470 | 471 | pub const blkcnt_t = isize; |
| 471 | pub const timespec = extern struct { | |
| 472 | tv_sec: time_t, | |
| 473 | tv_nsec: isize, | |
| 474 | }; | |
| 475 | 472 | |
| 476 | 473 | pub const timeval = extern struct { |
| 477 | 474 | tv_sec: time_t, |
lib/std/os/linux/sparc64.zig+1-5| ... | ... | @@ -11,6 +11,7 @@ const sockaddr = linux.sockaddr; |
| 11 | 11 | const socklen_t = linux.socklen_t; |
| 12 | 12 | const iovec = linux.iovec; |
| 13 | 13 | const iovec_const = linux.iovec_const; |
| 14 | const timespec = linux.timespec; | |
| 14 | 15 | |
| 15 | 16 | pub fn syscall_pipe(fd: *[2]i32) usize { |
| 16 | 17 | return asm volatile ( |
| ... | ... | @@ -708,11 +709,6 @@ pub const Stat = extern struct { |
| 708 | 709 | } |
| 709 | 710 | }; |
| 710 | 711 | |
| 711 | pub const timespec = extern struct { | |
| 712 | tv_sec: isize, | |
| 713 | tv_nsec: isize, | |
| 714 | }; | |
| 715 | ||
| 716 | 712 | pub const timeval = extern struct { |
| 717 | 713 | tv_sec: isize, |
| 718 | 714 | tv_usec: isize, |
lib/std/os/linux/x86_64.zig+1-5| ... | ... | @@ -12,6 +12,7 @@ const stack_t = linux.stack_t; |
| 12 | 12 | const sigset_t = linux.sigset_t; |
| 13 | 13 | const sockaddr = linux.sockaddr; |
| 14 | 14 | const socklen_t = linux.socklen_t; |
| 15 | const timespec = linux.timespec; | |
| 15 | 16 | |
| 16 | 17 | pub fn syscall0(number: SYS) usize { |
| 17 | 18 | return asm volatile ("syscall" |
| ... | ... | @@ -653,11 +654,6 @@ pub const Stat = extern struct { |
| 653 | 654 | } |
| 654 | 655 | }; |
| 655 | 656 | |
| 656 | pub const timespec = extern struct { | |
| 657 | tv_sec: isize, | |
| 658 | tv_nsec: isize, | |
| 659 | }; | |
| 660 | ||
| 661 | 657 | pub const timeval = extern struct { |
| 662 | 658 | tv_sec: isize, |
| 663 | 659 | tv_usec: isize, |