| 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,6 +6593,8 @@ pub const CType = enum { |
| 6593 | .powerpcle, | 6593 | .powerpcle, |
| 6594 | .powerpc64, | 6594 | .powerpc64, |
| 6595 | .powerpc64le, | 6595 | .powerpc64le, |
| 6596 | .wasm32, | ||
| 6597 | .wasm64, | ||
| 6596 | => return 128, | 6598 | => return 128, |
| 6597 | 6599 | ||
| 6598 | else => return 64, | 6600 | else => return 64, |
| ... | @@ -6641,6 +6643,8 @@ pub const CType = enum { | ... | @@ -6641,6 +6643,8 @@ pub const CType = enum { |
| 6641 | .powerpcle, | 6643 | .powerpcle, |
| 6642 | .powerpc64, | 6644 | .powerpc64, |
| 6643 | .powerpc64le, | 6645 | .powerpc64le, |
| 6646 | .wasm32, | ||
| 6647 | .wasm64, | ||
| 6644 | => return 128, | 6648 | => return 128, |
| 6645 | 6649 | ||
| 6646 | else => return 64, | 6650 | else => return 64, |
test/behavior/cast.zig+1| ... | @@ -1430,6 +1430,7 @@ test "coerce between pointers of compatible differently-named floats" { | ... | @@ -1430,6 +1430,7 @@ test "coerce between pointers of compatible differently-named floats" { |
| 1430 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | 1430 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 1431 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 1431 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 1432 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | 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 | if (builtin.os.tag == .windows) { | 1435 | if (builtin.os.tag == .windows) { |
| 1435 | // https://github.com/ziglang/zig/issues/12396 | 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,6 +33,7 @@ void zig_five_integers(int32_t, int32_t, int32_t, int32_t, int32_t); |
| 33 | 33 | ||
| 34 | void zig_f32(float); | 34 | void zig_f32(float); |
| 35 | void zig_f64(double); | 35 | void zig_f64(double); |
| 36 | void zig_longdouble(long double); | ||
| 36 | void zig_five_floats(float, float, float, float, float); | 37 | void zig_five_floats(float, float, float, float, float); |
| 37 | 38 | ||
| 38 | bool zig_ret_bool(); | 39 | bool zig_ret_bool(); |
| ... | @@ -157,6 +158,7 @@ void run_c_tests(void) { | ... | @@ -157,6 +158,7 @@ void run_c_tests(void) { |
| 157 | 158 | ||
| 158 | zig_f32(12.34f); | 159 | zig_f32(12.34f); |
| 159 | zig_f64(56.78); | 160 | zig_f64(56.78); |
| 161 | zig_longdouble(12.34l); | ||
| 160 | zig_five_floats(1.0f, 2.0f, 3.0f, 4.0f, 5.0f); | 162 | zig_five_floats(1.0f, 2.0f, 3.0f, 4.0f, 5.0f); |
| 161 | 163 | ||
| 162 | zig_ptr((void*)0xdeadbeefL); | 164 | zig_ptr((void*)0xdeadbeefL); |
| ... | @@ -271,6 +273,10 @@ void c_f64(double x) { | ... | @@ -271,6 +273,10 @@ void c_f64(double x) { |
| 271 | assert_or_panic(x == 56.78); | 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 | void c_ptr(void *x) { | 280 | void c_ptr(void *x) { |
| 275 | assert_or_panic(x == (void*)0xdeadbeefL); | 281 | assert_or_panic(x == (void*)0xdeadbeefL); |
| 276 | } | 282 | } |
test/c_abi/main.zig+11| ... | @@ -1,4 +1,5 @@ | ... | @@ -1,4 +1,5 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | ||
| 2 | const print = std.debug.print; | 3 | const print = std.debug.print; |
| 3 | const expect = std.testing.expect; | 4 | const expect = std.testing.expect; |
| 4 | 5 | ||
| ... | @@ -89,6 +90,7 @@ export fn zig_struct_u128(a: U128) void { | ... | @@ -89,6 +90,7 @@ export fn zig_struct_u128(a: U128) void { |
| 89 | 90 | ||
| 90 | extern fn c_f32(f32) void; | 91 | extern fn c_f32(f32) void; |
| 91 | extern fn c_f64(f64) void; | 92 | extern fn c_f64(f64) void; |
| 93 | extern fn c_long_double(c_longdouble) void; | ||
| 92 | 94 | ||
| 93 | // On windows x64, the first 4 are passed via registers, others on the stack. | 95 | // On windows x64, the first 4 are passed via registers, others on the stack. |
| 94 | extern fn c_five_floats(f32, f32, f32, f32, f32) void; | 96 | extern fn c_five_floats(f32, f32, f32, f32, f32) void; |
| ... | @@ -107,12 +109,21 @@ test "C ABI floats" { | ... | @@ -107,12 +109,21 @@ test "C ABI floats" { |
| 107 | c_five_floats(1.0, 2.0, 3.0, 4.0, 5.0); | 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 | export fn zig_f32(x: f32) void { | 117 | export fn zig_f32(x: f32) void { |
| 111 | expect(x == 12.34) catch @panic("test failure: zig_f32"); | 118 | expect(x == 12.34) catch @panic("test failure: zig_f32"); |
| 112 | } | 119 | } |
| 113 | export fn zig_f64(x: f64) void { | 120 | export fn zig_f64(x: f64) void { |
| 114 | expect(x == 56.78) catch @panic("test failure: zig_f64"); | 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 | extern fn c_ptr(*anyopaque) void; | 128 | extern fn c_ptr(*anyopaque) void; |
| 118 | 129 |