diff options
| author | Marc Tiehuis <marctiehuis@gmail.com> | 2018-06-14 21:18:36 +1200 |
|---|---|---|
| committer | Marc Tiehuis <marctiehuis@gmail.com> | 2018-06-14 21:18:36 +1200 |
| commit | a369d69c5144c2a4186e4f8d20bfda0c3f86605a (patch) | |
| tree | 22a69c778dbb066c972705ca3153b05eb78f4c7f /std | |
| parent | 911014051487e83177689893e57491b86e72589b (diff) | |
| download | zig-a369d69c5144c2a4186e4f8d20bfda0c3f86605a.tar.gz zig-a369d69c5144c2a4186e4f8d20bfda0c3f86605a.zip | |
Add windows x86_64 i128 abi workaround
Diffstat (limited to 'std')
| -rw-r--r-- | std/special/compiler_rt/divti3.zig | 10 | ||||
| -rw-r--r-- | std/special/compiler_rt/index.zig | 7 | ||||
| -rw-r--r-- | std/special/compiler_rt/muloti4.zig | 10 | ||||
| -rw-r--r-- | std/special/compiler_rt/muloti4_test.zig | 2 |
4 files changed, 25 insertions, 4 deletions
diff --git a/std/special/compiler_rt/divti3.zig b/std/special/compiler_rt/divti3.zig index f3fccf3746..60460ea62d 100644 --- a/std/special/compiler_rt/divti3.zig +++ b/std/special/compiler_rt/divti3.zig @@ -1,5 +1,6 @@ const udivmod = @import("udivmod.zig").udivmod; const builtin = @import("builtin"); +const compiler_rt = @import("index.zig"); pub extern fn __divti3(a: i128, b: i128) i128 { @setRuntimeSafety(builtin.is_test); @@ -14,3 +15,12 @@ pub extern fn __divti3(a: i128, b: i128) i128 { const s = s_a ^ s_b; return (i128(r) ^ s) -% s; } + +pub extern fn __divti3_windows_x86_64(a: *const i128, b: *const i128) void { + @setRuntimeSafety(builtin.is_test); + compiler_rt.setXmm0(i128, __divti3(a.*, b.*)); +} + +test "import divti3" { + _ = @import("divti3_test.zig"); +} diff --git a/std/special/compiler_rt/index.zig b/std/special/compiler_rt/index.zig index 0573854c91..f952730353 100644 --- a/std/special/compiler_rt/index.zig +++ b/std/special/compiler_rt/index.zig @@ -38,9 +38,6 @@ comptime { @export("__umoddi3", __umoddi3, linkage); @export("__udivmodsi4", __udivmodsi4, linkage); - @export("__divti3", @import("divti3.zig").__divti3, linkage); - @export("__muloti4", @import("muloti4.zig").__muloti4, linkage); - if (isArmArch()) { @export("__aeabi_uldivmod", __aeabi_uldivmod, linkage); @export("__aeabi_uidivmod", __aeabi_uidivmod, linkage); @@ -61,6 +58,8 @@ comptime { @export("__chkstk", __chkstk, strong_linkage); @export("___chkstk_ms", ___chkstk_ms, linkage); } + @export("__divti3", @import("divti3.zig").__divti3_windows_x86_64, linkage); + @export("__muloti4", @import("muloti4.zig").__muloti4_windows_x86_64, linkage); @export("__udivti3", @import("udivti3.zig").__udivti3_windows_x86_64, linkage); @export("__udivmodti4", @import("udivmodti4.zig").__udivmodti4_windows_x86_64, linkage); @export("__umodti3", @import("umodti3.zig").__umodti3_windows_x86_64, linkage); @@ -68,6 +67,8 @@ comptime { else => {}, } } else { + @export("__divti3", @import("divti3.zig").__divti3, linkage); + @export("__muloti4", @import("muloti4.zig").__muloti4, linkage); @export("__udivti3", @import("udivti3.zig").__udivti3, linkage); @export("__udivmodti4", @import("udivmodti4.zig").__udivmodti4, linkage); @export("__umodti3", @import("umodti3.zig").__umodti3, linkage); diff --git a/std/special/compiler_rt/muloti4.zig b/std/special/compiler_rt/muloti4.zig index 35d33f4ad4..866077c80c 100644 --- a/std/special/compiler_rt/muloti4.zig +++ b/std/special/compiler_rt/muloti4.zig @@ -1,5 +1,6 @@ const udivmod = @import("udivmod.zig").udivmod; const builtin = @import("builtin"); +const compiler_rt = @import("index.zig"); pub extern fn __muloti4(a: i128, b: i128, overflow: *c_int) i128 { @setRuntimeSafety(builtin.is_test); @@ -43,3 +44,12 @@ pub extern fn __muloti4(a: i128, b: i128, overflow: *c_int) i128 { return r; } + +pub extern fn __muloti4_windows_x86_64(a: *const i128, b: *const i128, overflow: *c_int) void { + @setRuntimeSafety(builtin.is_test); + compiler_rt.setXmm0(i128, __muloti4(a.*, b.*, overflow)); +} + +test "import muloti4" { + _ = @import("muloti4_test.zig"); +} diff --git a/std/special/compiler_rt/muloti4_test.zig b/std/special/compiler_rt/muloti4_test.zig index b61655aaec..6b3671323f 100644 --- a/std/special/compiler_rt/muloti4_test.zig +++ b/std/special/compiler_rt/muloti4_test.zig @@ -4,7 +4,7 @@ const assert = @import("std").debug.assert; fn test__muloti4(a: i128, b: i128, expected: i128, expected_overflow: c_int) void { var overflow: c_int = undefined; const x = __muloti4(a, b, &overflow); - assert(overflow == expected_overflow and (overflow != 0 or x == expected)); + assert(overflow == expected_overflow and (expected_overflow != 0 or x == expected)); } test "muloti4" { |
