motiejus/zig

fork of https://codeberg.org/ziglang/zig
git clone https://git.jakstys.lt/motiejus/zig.git
Log | Tree | Refs | README | LICENSE

commit 75f78bfb77d62ee3e143cb7718a21f492a0d4fa6 (tree)
parent cd5f673cae598decce04bc1d0e85775698ea48d9
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed,  7 Aug 2024 01:18:35 -0700

Merge pull request #20922 from alexrp/vdso

`std.os.linux`: Fix VDSO for mips, add VDSO for riscv
Diffstat:
Mlib/std/os/linux.zig | 2+-
Mlib/std/os/linux/mips.zig | 4++--
Mlib/std/os/linux/mips64.zig | 4++--
Mlib/std/os/linux/riscv32.zig | 5++++-
Mlib/std/os/linux/riscv64.zig | 5++++-
5 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig @@ -1397,7 +1397,7 @@ const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.C) var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime; pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize { - if (@hasDecl(VDSO, "CGT_SYM")) { + if (VDSO != void) { const ptr = @atomicLoad(?VdsoClockGettime, &vdso_clock_gettime, .unordered); if (ptr) |f| { const rc = f(clk_id, tp); diff --git a/lib/std/os/linux/mips.zig b/lib/std/os/linux/mips.zig @@ -242,8 +242,8 @@ pub const F = struct { pub const MMAP2_UNIT = 4096; pub const VDSO = struct { - pub const CGT_SYM = "__kernel_clock_gettime"; - pub const CGT_VER = "LINUX_2.6.39"; + pub const CGT_SYM = "__vdso_clock_gettime"; + pub const CGT_VER = "LINUX_2.6"; }; pub const Flock = extern struct { diff --git a/lib/std/os/linux/mips64.zig b/lib/std/os/linux/mips64.zig @@ -227,8 +227,8 @@ pub const F = struct { pub const MMAP2_UNIT = 4096; pub const VDSO = struct { - pub const CGT_SYM = "__kernel_clock_gettime"; - pub const CGT_VER = "LINUX_2.6.39"; + pub const CGT_SYM = "__vdso_clock_gettime"; + pub const CGT_VER = "LINUX_2.6"; }; pub const Flock = extern struct { diff --git a/lib/std/os/linux/riscv32.zig b/lib/std/os/linux/riscv32.zig @@ -188,7 +188,10 @@ pub const Elf_Symndx = u32; pub const MMAP2_UNIT = 4096; -pub const VDSO = struct {}; +pub const VDSO = struct { + pub const CGT_SYM = "__vdso_clock_gettime"; + pub const CGT_VER = "LINUX_4.15"; +}; /// TODO pub const ucontext_t = void; diff --git a/lib/std/os/linux/riscv64.zig b/lib/std/os/linux/riscv64.zig @@ -215,7 +215,10 @@ pub const Stat = extern struct { pub const Elf_Symndx = u32; -pub const VDSO = struct {}; +pub const VDSO = struct { + pub const CGT_SYM = "__vdso_clock_gettime"; + pub const CGT_VER = "LINUX_4.15"; +}; /// TODO pub const ucontext_t = void;