authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-08-07 01:18:35-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-08-07 01:18:35-07:00
log75f78bfb77d62ee3e143cb7718a21f492a0d4fa6
treefb326f89a0d56340272c26ede45a5ff308f32ff6
parentcd5f673cae598decce04bc1d0e85775698ea48d9
parent0ad97b41229805fac0e20d88cb24118535fbf056
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #20922 from alexrp/vdso

`std.os.linux`: Fix VDSO for mips, add VDSO for riscv

5 files changed, 13 insertions(+), 7 deletions(-)

lib/std/os/linux.zig+1-1
......@@ -1397,7 +1397,7 @@ const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.C)
13971397var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime;
13981398
13991399pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize {
1400 if (@hasDecl(VDSO, "CGT_SYM")) {
1400 if (VDSO != void) {
14011401 const ptr = @atomicLoad(?VdsoClockGettime, &vdso_clock_gettime, .unordered);
14021402 if (ptr) |f| {
14031403 const rc = f(clk_id, tp);
lib/std/os/linux/mips.zig+2-2
......@@ -242,8 +242,8 @@ pub const F = struct {
242242pub const MMAP2_UNIT = 4096;
243243
244244pub const VDSO = struct {
245 pub const CGT_SYM = "__kernel_clock_gettime";
246 pub const CGT_VER = "LINUX_2.6.39";
245 pub const CGT_SYM = "__vdso_clock_gettime";
246 pub const CGT_VER = "LINUX_2.6";
247247};
248248
249249pub const Flock = extern struct {
lib/std/os/linux/mips64.zig+2-2
......@@ -227,8 +227,8 @@ pub const F = struct {
227227pub const MMAP2_UNIT = 4096;
228228
229229pub const VDSO = struct {
230 pub const CGT_SYM = "__kernel_clock_gettime";
231 pub const CGT_VER = "LINUX_2.6.39";
230 pub const CGT_SYM = "__vdso_clock_gettime";
231 pub const CGT_VER = "LINUX_2.6";
232232};
233233
234234pub const Flock = extern struct {
lib/std/os/linux/riscv32.zig+4-1
......@@ -188,7 +188,10 @@ pub const Elf_Symndx = u32;
188188
189189pub const MMAP2_UNIT = 4096;
190190
191pub const VDSO = struct {};
191pub const VDSO = struct {
192 pub const CGT_SYM = "__vdso_clock_gettime";
193 pub const CGT_VER = "LINUX_4.15";
194};
192195
193196/// TODO
194197pub const ucontext_t = void;
lib/std/os/linux/riscv64.zig+4-1
......@@ -215,7 +215,10 @@ pub const Stat = extern struct {
215215
216216pub const Elf_Symndx = u32;
217217
218pub const VDSO = struct {};
218pub const VDSO = struct {
219 pub const CGT_SYM = "__vdso_clock_gettime";
220 pub const CGT_VER = "LINUX_4.15";
221};
219222
220223/// TODO
221224pub const ucontext_t = void;