Commit 1c1cfe1533

Cody Tapscott <topolarity@tapscott.me>
2022-04-09 04:48:24
Skip `@rem`/`@mod` tests on stage2, due to missing `fmodl` implementation
1 parent b5d5685
Changed files (2)
lib
std
test
behavior
lib/std/special/compiler_rt.zig
@@ -721,11 +721,12 @@ comptime {
         @export(_aullrem, .{ .name = "\x01__aullrem", .linkage = strong_linkage });
     }
 
-    const fmodq = @import("compiler_rt/floatfmodq.zig").fmodq;
     if (!is_test) {
-        @export(fmodq, .{ .name = "fmodq", .linkage = linkage });
+        @export(fmodl, .{ .name = "fmodl", .linkage = linkage });
         if (long_double_is_f128) {
-            @export(fmodq, .{ .name = "fmodl", .linkage = linkage });
+            @export(fmodl, .{ .name = "fmodq", .linkage = linkage });
+        } else {
+            @export(fmodq, .{ .name = "fmodq", .linkage = linkage });
         }
 
         @export(floorf, .{ .name = "floorf", .linkage = linkage });
@@ -880,6 +881,14 @@ fn ceill(x: c_longdouble) callconv(.C) c_longdouble {
     return math.ceil(x);
 }
 
+const fmodq = @import("compiler_rt/floatfmodq.zig").fmodq;
+fn fmodl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble {
+    if (!long_double_is_f128) {
+        @panic("TODO implement this");
+    }
+    return @floatCast(c_longdouble, fmodq(x, y));
+}
+
 // Avoid dragging in the runtime safety mechanisms into this .o file,
 // unless we're trying to test this file.
 pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {
test/behavior/math.zig
@@ -923,6 +923,8 @@ test "comptime float rem int" {
 }
 
 test "remainder division" {
+    if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
+
     comptime try remdiv(f16);
     comptime try remdiv(f32);
     comptime try remdiv(f64);
@@ -938,11 +940,7 @@ fn remdiv(comptime T: type) !void {
 }
 
 test "float remainder division using @rem" {
-    if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
-    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
-    if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
-    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
-    if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
+    if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
 
     comptime try frem(f16);
     comptime try frem(f32);
@@ -973,11 +971,7 @@ fn frem(comptime T: type) !void {
 }
 
 test "float modulo division using @mod" {
-    if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
-    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
-    if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
-    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
-    if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
+    if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
 
     comptime try fmod(f16);
     comptime try fmod(f32);