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)...@@ -1397,7 +1397,7 @@ const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.C)
1397var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime;1397var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime;
13981398
1399pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize {1399pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize {
1400 if (@hasDecl(VDSO, "CGT_SYM")) {1400 if (VDSO != void) {
1401 const ptr = @atomicLoad(?VdsoClockGettime, &vdso_clock_gettime, .unordered);1401 const ptr = @atomicLoad(?VdsoClockGettime, &vdso_clock_gettime, .unordered);
1402 if (ptr) |f| {1402 if (ptr) |f| {
1403 const rc = f(clk_id, tp);1403 const rc = f(clk_id, tp);
lib/std/os/linux/mips.zig+2-2
...@@ -242,8 +242,8 @@ pub const F = struct {...@@ -242,8 +242,8 @@ pub const F = struct {
242pub const MMAP2_UNIT = 4096;242pub const MMAP2_UNIT = 4096;
243243
244pub const VDSO = struct {244pub const VDSO = struct {
245 pub const CGT_SYM = "__kernel_clock_gettime";245 pub const CGT_SYM = "__vdso_clock_gettime";
246 pub const CGT_VER = "LINUX_2.6.39";246 pub const CGT_VER = "LINUX_2.6";
247};247};
248248
249pub const Flock = extern struct {249pub const Flock = extern struct {
lib/std/os/linux/mips64.zig+2-2
...@@ -227,8 +227,8 @@ pub const F = struct {...@@ -227,8 +227,8 @@ pub const F = struct {
227pub const MMAP2_UNIT = 4096;227pub const MMAP2_UNIT = 4096;
228228
229pub const VDSO = struct {229pub const VDSO = struct {
230 pub const CGT_SYM = "__kernel_clock_gettime";230 pub const CGT_SYM = "__vdso_clock_gettime";
231 pub const CGT_VER = "LINUX_2.6.39";231 pub const CGT_VER = "LINUX_2.6";
232};232};
233233
234pub const Flock = extern struct {234pub const Flock = extern struct {
lib/std/os/linux/riscv32.zig+4-1
...@@ -188,7 +188,10 @@ pub const Elf_Symndx = u32;...@@ -188,7 +188,10 @@ pub const Elf_Symndx = u32;
188188
189pub const MMAP2_UNIT = 4096;189pub 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
193/// TODO196/// TODO
194pub const ucontext_t = void;197pub const ucontext_t = void;
lib/std/os/linux/riscv64.zig+4-1
...@@ -215,7 +215,10 @@ pub const Stat = extern struct {...@@ -215,7 +215,10 @@ pub const Stat = extern struct {
215215
216pub const Elf_Symndx = u32;216pub 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
220/// TODO223/// TODO
221pub const ucontext_t = void;224pub const ucontext_t = void;