| ... | @@ -961,11 +961,14 @@ pub fn waitpid(pid: i32, status: *i32, options: i32) usize { | ... | @@ -961,11 +961,14 @@ pub fn waitpid(pid: i32, status: *i32, options: i32) usize { |
| 961 | | 961 | |
| 962 | var vdso_clock_gettime = @ptrCast(?*const c_void, init_vdso_clock_gettime); | 962 | var vdso_clock_gettime = @ptrCast(?*const c_void, init_vdso_clock_gettime); |
| 963 | | 963 | |
| | 964 | // We must follow the C calling convention when we call into the VDSO |
| | 965 | const vdso_clock_gettime_ty = extern fn (i32, *timespec) usize; |
| | 966 | |
| 964 | pub fn clock_gettime(clk_id: i32, tp: *timespec) usize { | 967 | pub fn clock_gettime(clk_id: i32, tp: *timespec) usize { |
| 965 | if (VDSO_CGT_SYM.len != 0) { | 968 | if (VDSO_CGT_SYM.len != 0) { |
| 966 | const ptr = @atomicLoad(?*const c_void, &vdso_clock_gettime, .Unordered); | 969 | const ptr = @atomicLoad(?*const c_void, &vdso_clock_gettime, .Unordered); |
| 967 | if (ptr) |fn_ptr| { | 970 | if (ptr) |fn_ptr| { |
| 968 | const f = @ptrCast(@typeOf(clock_gettime), fn_ptr); | 971 | const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr); |
| 969 | const rc = f(clk_id, tp); | 972 | const rc = f(clk_id, tp); |
| 970 | switch (rc) { | 973 | switch (rc) { |
| 971 | 0, @bitCast(usize, isize(-EINVAL)) => return rc, | 974 | 0, @bitCast(usize, isize(-EINVAL)) => return rc, |
| ... | @@ -983,7 +986,7 @@ extern fn init_vdso_clock_gettime(clk: i32, ts: *timespec) usize { | ... | @@ -983,7 +986,7 @@ extern fn init_vdso_clock_gettime(clk: i32, ts: *timespec) usize { |
| 983 | _ = @cmpxchgStrong(?*const c_void, &vdso_clock_gettime, &init_vdso_clock_gettime, ptr, .Monotonic, .Monotonic); | 986 | _ = @cmpxchgStrong(?*const c_void, &vdso_clock_gettime, &init_vdso_clock_gettime, ptr, .Monotonic, .Monotonic); |
| 984 | // Call into the VDSO if available | 987 | // Call into the VDSO if available |
| 985 | if (ptr) |fn_ptr| { | 988 | if (ptr) |fn_ptr| { |
| 986 | const f = @ptrCast(@typeOf(clock_gettime), fn_ptr); | 989 | const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr); |
| 987 | return f(clk, ts); | 990 | return f(clk, ts); |
| 988 | } | 991 | } |
| 989 | return @bitCast(usize, isize(-ENOSYS)); | 992 | return @bitCast(usize, isize(-ENOSYS)); |