Commit 1bbca4f935
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);
src/codegen/llvm.zig
@@ -3892,7 +3892,7 @@ pub const FuncGen = struct {
return self.builder.buildBitCast(operand, llvm_dest_ty.pointerType(0), "");
}
- if (operand_ty.zigTypeTag() == .Int and inst_ty.zigTypeTag() == .Pointer) {
+ if (operand_ty.zigTypeTag() == .Int and inst_ty.isPtrAtRuntime()) {
return self.builder.buildIntToPtr(operand, llvm_dest_ty, "");
}
src/type.zig
@@ -2602,7 +2602,7 @@ pub const Type = extern union {
const payload = self.castTag(.pointer).?.data;
return payload.@"allowzero";
},
- else => false,
+ else => return self.zigTypeTag() == .Optional,
};
}