| author | |
| committer | |
| log | d2d42cf7ba5d965786d4bfb2fdc61dbd9a0d2ae5 |
| tree | f5134d76c873b485f831881c3b28ef897a21f4b3 |
| parent | e8edc4cf831229f9acfa07001f385bac7fec89b0 |
| parent | 1eb22e7ad6f700a72d34cdb36e614c95bdab0464 |
| signature |
stage2: fix size of c_longdouble for Wasm target4 files changed, 22 insertions(+), 0 deletions(-)
src/type.zig+4| ... | ... | @@ -6593,6 +6593,8 @@ pub const CType = enum { |
| 6593 | 6593 | .powerpcle, |
| 6594 | 6594 | .powerpc64, |
| 6595 | 6595 | .powerpc64le, |
| 6596 | .wasm32, | |
| 6597 | .wasm64, | |
| 6596 | 6598 | => return 128, |
| 6597 | 6599 | |
| 6598 | 6600 | else => return 64, |
| ... | ... | @@ -6641,6 +6643,8 @@ pub const CType = enum { |
| 6641 | 6643 | .powerpcle, |
| 6642 | 6644 | .powerpc64, |
| 6643 | 6645 | .powerpc64le, |
| 6646 | .wasm32, | |
| 6647 | .wasm64, | |
| 6644 | 6648 | => return 128, |
| 6645 | 6649 | |
| 6646 | 6650 | else => return 64, |
test/behavior/cast.zig+1| ... | ... | @@ -1430,6 +1430,7 @@ test "coerce between pointers of compatible differently-named floats" { |
| 1430 | 1430 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 1431 | 1431 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 1432 | 1432 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO |
| 1433 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | |
| 1433 | 1434 | |
| 1434 | 1435 | if (builtin.os.tag == .windows) { |
| 1435 | 1436 | // https://github.com/ziglang/zig/issues/12396 |
test/c_abi/cfuncs.c+6| ... | ... | @@ -33,6 +33,7 @@ void zig_five_integers(int32_t, int32_t, int32_t, int32_t, int32_t); |
| 33 | 33 | |
| 34 | 34 | void zig_f32(float); |
| 35 | 35 | void zig_f64(double); |
| 36 | void zig_longdouble(long double); | |
| 36 | 37 | void zig_five_floats(float, float, float, float, float); |
| 37 | 38 | |
| 38 | 39 | bool zig_ret_bool(); |
| ... | ... | @@ -157,6 +158,7 @@ void run_c_tests(void) { |
| 157 | 158 | |
| 158 | 159 | zig_f32(12.34f); |
| 159 | 160 | zig_f64(56.78); |
| 161 | zig_longdouble(12.34l); | |
| 160 | 162 | zig_five_floats(1.0f, 2.0f, 3.0f, 4.0f, 5.0f); |
| 161 | 163 | |
| 162 | 164 | zig_ptr((void*)0xdeadbeefL); |
| ... | ... | @@ -271,6 +273,10 @@ void c_f64(double x) { |
| 271 | 273 | assert_or_panic(x == 56.78); |
| 272 | 274 | } |
| 273 | 275 | |
| 276 | void c_long_double(long double x) { | |
| 277 | assert_or_panic(x == 12.34l); | |
| 278 | } | |
| 279 | ||
| 274 | 280 | void c_ptr(void *x) { |
| 275 | 281 | assert_or_panic(x == (void*)0xdeadbeefL); |
| 276 | 282 | } |
test/c_abi/main.zig+11| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const print = std.debug.print; |
| 3 | 4 | const expect = std.testing.expect; |
| 4 | 5 | |
| ... | ... | @@ -89,6 +90,7 @@ export fn zig_struct_u128(a: U128) void { |
| 89 | 90 | |
| 90 | 91 | extern fn c_f32(f32) void; |
| 91 | 92 | extern fn c_f64(f64) void; |
| 93 | extern fn c_long_double(c_longdouble) void; | |
| 92 | 94 | |
| 93 | 95 | // On windows x64, the first 4 are passed via registers, others on the stack. |
| 94 | 96 | extern fn c_five_floats(f32, f32, f32, f32, f32) void; |
| ... | ... | @@ -107,12 +109,21 @@ test "C ABI floats" { |
| 107 | 109 | c_five_floats(1.0, 2.0, 3.0, 4.0, 5.0); |
| 108 | 110 | } |
| 109 | 111 | |
| 112 | test "C ABI long double" { | |
| 113 | if (!builtin.cpu.arch.isWasm()) return error.SkipZigTest; | |
| 114 | c_long_double(12.34); | |
| 115 | } | |
| 116 | ||
| 110 | 117 | export fn zig_f32(x: f32) void { |
| 111 | 118 | expect(x == 12.34) catch @panic("test failure: zig_f32"); |
| 112 | 119 | } |
| 113 | 120 | export fn zig_f64(x: f64) void { |
| 114 | 121 | expect(x == 56.78) catch @panic("test failure: zig_f64"); |
| 115 | 122 | } |
| 123 | export fn zig_longdouble(x: c_longdouble) void { | |
| 124 | if (!builtin.cpu.arch.isWasm()) return; // waiting for #1481 | |
| 125 | expect(x == 12.34) catch @panic("test failure: zig_longdouble"); | |
| 126 | } | |
| 116 | 127 | |
| 117 | 128 | extern fn c_ptr(*anyopaque) void; |
| 118 | 129 |