diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-02-27 12:15:49 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-02-27 12:15:49 +0200 |
| commit | 1bbca4f9350ffd7ebbfc5c54a307f54d448f5929 (patch) | |
| tree | f3094718637cad2daffd4a0a9f3fb623e6591996 /lib/std/os/linux.zig | |
| parent | 950d840be66deb9239c0effa90ee41a7c0884f95 (diff) | |
| download | zig-1bbca4f9350ffd7ebbfc5c54a307f54d448f5929.tar.gz zig-1bbca4f9350ffd7ebbfc5c54a307f54d448f5929.zip | |
stage2: fix bitcast to optional ptr in llvm backend; omit safety check for intToPtr on optional ptr
Diffstat (limited to 'lib/std/os/linux.zig')
| -rw-r--r-- | lib/std/os/linux.zig | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 95f6222e97..7232bcfcd2 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -865,13 +865,19 @@ pub fn flock(fd: fd_t, operation: i32) usize { return syscall2(.flock, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, operation))); } -var vdso_clock_gettime = @ptrCast(?*const anyopaque, init_vdso_clock_gettime); +var vdso_clock_gettime = if (builtin.zig_backend == .stage1) + @ptrCast(?*const anyopaque, init_vdso_clock_gettime) +else + @ptrCast(?*const anyopaque, &init_vdso_clock_gettime); // We must follow the C calling convention when we call into the VDSO -const vdso_clock_gettime_ty = fn (i32, *timespec) callconv(.C) usize; +const vdso_clock_gettime_ty = if (builtin.zig_backend == .stage1) + fn (i32, *timespec) callconv(.C) usize +else + *const fn (i32, *timespec) callconv(.C) usize; pub fn clock_gettime(clk_id: i32, tp: *timespec) usize { - if (@hasDecl(VDSO, "CGT_SYM") and builtin.zig_backend == .stage1) { + if (@hasDecl(VDSO, "CGT_SYM")) { const ptr = @atomicLoad(?*const anyopaque, &vdso_clock_gettime, .Unordered); if (ptr) |fn_ptr| { const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr); |
