diff --git a/lib/std/os/linux/tls.zig b/lib/std/os/linux/tls.zig index 614f5b4395..757e77bff3 100644 --- a/lib/std/os/linux/tls.zig +++ b/lib/std/os/linux/tls.zig @@ -69,7 +69,7 @@ const tls_tcb_size = switch (builtin.arch) { // Controls if the TP points to the end of the TCB instead of its beginning const tls_tp_points_past_tcb = switch (builtin.arch) { - .riscv32, .riscv64, .mips, .mipsel, .powerpc64, .powerpc64le => true, + .riscv32, .riscv64, .mips, .mipsel, .powerpc, .powerpc64, .powerpc64le => true, else => false, }; @@ -165,7 +165,14 @@ pub fn setThreadPointer(addr: usize) void { const rc = std.os.linux.syscall1(.set_thread_area, addr); assert(rc == 0); }, - .powerpc, .powerpc64, .powerpc64le => { + .powerpc => { + asm volatile ( + \\ mr 2, %[addr] + : + : [addr] "r" (addr) + ); + }, + .powerpc64, .powerpc64le => { asm volatile ( \\ mr 13, %[addr] : diff --git a/lib/std/special/c.zig b/lib/std/special/c.zig index 4e1b237d0d..f2f55e508e 100644 --- a/lib/std/special/c.zig +++ b/lib/std/special/c.zig @@ -939,7 +939,7 @@ export fn sqrt(x: f64) f64 { r = sign; while (r != 0) { - t = s1 +% r; + t1 = s1 +% r; t = s0; if (t < ix0 or (t == ix0 and t1 <= ix1)) { s1 = t1 +% r; diff --git a/lib/std/special/compiler_rt.zig b/lib/std/special/compiler_rt.zig index 4f12d21957..3a7457a4fd 100644 --- a/lib/std/special/compiler_rt.zig +++ b/lib/std/special/compiler_rt.zig @@ -296,6 +296,33 @@ comptime { @export(@import("compiler_rt/sparc.zig")._Qp_qtod, .{ .name = "_Qp_qtod", .linkage = linkage }); } + if (builtin.arch == .powerpc or builtin.arch.isPPC64()) { + @export(@import("compiler_rt/addXf3.zig").__addtf3, .{ .name = "__addkf3", .linkage = linkage }); + @export(@import("compiler_rt/addXf3.zig").__subtf3, .{ .name = "__subkf3", .linkage = linkage }); + @export(@import("compiler_rt/mulXf3.zig").__multf3, .{ .name = "__mulkf3", .linkage = linkage }); + @export(@import("compiler_rt/divtf3.zig").__divtf3, .{ .name = "__divkf3", .linkage = linkage }); + @export(@import("compiler_rt/extendXfYf2.zig").__extendsftf2, .{ .name = "__extendsfkf2", .linkage = linkage }); + @export(@import("compiler_rt/extendXfYf2.zig").__extenddftf2, .{ .name = "__extenddfkf2", .linkage = linkage }); + @export(@import("compiler_rt/truncXfYf2.zig").__trunctfsf2, .{ .name = "__trunckfsf2", .linkage = linkage }); + @export(@import("compiler_rt/truncXfYf2.zig").__trunctfdf2, .{ .name = "__trunckfdf2", .linkage = linkage }); + @export(@import("compiler_rt/fixtfdi.zig").__fixtfdi, .{ .name = "__fixkfdi", .linkage = linkage }); + @export(@import("compiler_rt/fixtfsi.zig").__fixtfsi, .{ .name = "__fixkfsi", .linkage = linkage }); + @export(@import("compiler_rt/fixunstfsi.zig").__fixunstfsi, .{ .name = "__fixunskfsi", .linkage = linkage }); + @export(@import("compiler_rt/fixunstfdi.zig").__fixunstfdi, .{ .name = "__fixunskfdi", .linkage = linkage }); + @export(@import("compiler_rt/floatsiXf.zig").__floatsitf, .{ .name = "__floatsikf", .linkage = linkage }); + @export(@import("compiler_rt/floatditf.zig").__floatditf, .{ .name = "__floatdikf", .linkage = linkage }); + @export(@import("compiler_rt/floatunditf.zig").__floatunditf, .{ .name = "__floatundikf", .linkage = linkage }); + @export(@import("compiler_rt/floatunsitf.zig").__floatunsitf, .{ .name = "__floatunsikf", .linkage = linkage }); + + @export(@import("compiler_rt/compareXf2.zig").__letf2, .{ .name = "__eqkf2", .linkage = linkage }); + @export(@import("compiler_rt/compareXf2.zig").__letf2, .{ .name = "__nekf2", .linkage = linkage }); + @export(@import("compiler_rt/compareXf2.zig").__getf2, .{ .name = "__gekf2", .linkage = linkage }); + @export(@import("compiler_rt/compareXf2.zig").__letf2, .{ .name = "__ltkf2", .linkage = linkage }); + @export(@import("compiler_rt/compareXf2.zig").__letf2, .{ .name = "__lekf2", .linkage = linkage }); + @export(@import("compiler_rt/compareXf2.zig").__getf2, .{ .name = "__gtkf2", .linkage = linkage }); + @export(@import("compiler_rt/compareXf2.zig").__unordtf2, .{ .name = "__unordkf2", .linkage = linkage }); + } + if (builtin.os.tag == .windows) { // Default stack-probe functions emitted by LLVM if (is_mingw) { diff --git a/test/stage1/behavior/bugs/920.zig b/test/stage1/behavior/bugs/920.zig index 10c002f6ba..72854956a1 100644 --- a/test/stage1/behavior/bugs/920.zig +++ b/test/stage1/behavior/bugs/920.zig @@ -60,6 +60,6 @@ test "bug 920 fixed" { }; for (NormalDist1.f) |_, i| { - std.testing.expect(NormalDist1.f[i] == NormalDist.f[i]); + std.testing.expectEqual(NormalDist1.f[i], NormalDist.f[i]); } } diff --git a/test/stage1/behavior/cast.zig b/test/stage1/behavior/cast.zig index 6fa44085e0..94ba2636b7 100644 --- a/test/stage1/behavior/cast.zig +++ b/test/stage1/behavior/cast.zig @@ -17,14 +17,15 @@ test "integer literal to pointer cast" { } test "pointer reinterpret const float to int" { - // https://github.com/ziglang/zig/issues/3345 - if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; - + // The hex representation is 0x3fe3333333333303. const float: f64 = 5.99999999999994648725e-01; const float_ptr = &float; const int_ptr = @ptrCast(*const i32, float_ptr); const int_val = int_ptr.*; - expect(int_val == 858993411); + if (std.builtin.endian == .Little) + expect(int_val == 0x33333303) + else + expect(int_val == 0x3fe33333); } test "implicitly cast indirect pointer to maybe-indirect pointer" {