Skip to content

Commit 75f78bf

Browse files
authored
Merge pull request #20922 from alexrp/vdso
`std.os.linux`: Fix VDSO for mips, add VDSO for riscv
2 parents cd5f673 + 0ad97b4 commit 75f78bf

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

lib/std/os/linux.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.C)
13971397
var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime;
13981398

13991399
pub 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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ pub const F = struct {
242242
pub const MMAP2_UNIT = 4096;
243243

244244
pub 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

249249
pub const Flock = extern struct {

lib/std/os/linux/mips64.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ pub const F = struct {
227227
pub const MMAP2_UNIT = 4096;
228228

229229
pub 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

234234
pub const Flock = extern struct {

lib/std/os/linux/riscv32.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ pub const Elf_Symndx = u32;
188188

189189
pub const MMAP2_UNIT = 4096;
190190

191-
pub const VDSO = struct {};
191+
pub const VDSO = struct {
192+
pub const CGT_SYM = "__vdso_clock_gettime";
193+
pub const CGT_VER = "LINUX_4.15";
194+
};
192195

193196
/// TODO
194197
pub const ucontext_t = void;

lib/std/os/linux/riscv64.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,10 @@ pub const Stat = extern struct {
215215

216216
pub const Elf_Symndx = u32;
217217

218-
pub const VDSO = struct {};
218+
pub const VDSO = struct {
219+
pub const CGT_SYM = "__vdso_clock_gettime";
220+
pub const CGT_VER = "LINUX_4.15";
221+
};
219222

220223
/// TODO
221224
pub const ucontext_t = void;

0 commit comments

Comments
 (0)