diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-08-29 18:21:38 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-29 18:21:38 -0400 |
| commit | d2d42cf7ba5d965786d4bfb2fdc61dbd9a0d2ae5 (patch) | |
| tree | f5134d76c873b485f831881c3b28ef897a21f4b3 /test | |
| parent | e8edc4cf831229f9acfa07001f385bac7fec89b0 (diff) | |
| parent | 1eb22e7ad6f700a72d34cdb36e614c95bdab0464 (diff) | |
| download | zig-d2d42cf7ba5d965786d4bfb2fdc61dbd9a0d2ae5.tar.gz zig-d2d42cf7ba5d965786d4bfb2fdc61dbd9a0d2ae5.zip | |
Merge pull request #12641 from Luukdegram/wasm-c-types
stage2: fix size of c_longdouble for Wasm target
Diffstat (limited to 'test')
| -rw-r--r-- | test/behavior/cast.zig | 1 | ||||
| -rw-r--r-- | test/c_abi/cfuncs.c | 6 | ||||
| -rw-r--r-- | test/c_abi/main.zig | 11 |
3 files changed, 18 insertions, 0 deletions
diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig index fa0877258c..4c6dab2dbb 100644 --- a/test/behavior/cast.zig +++ b/test/behavior/cast.zig @@ -1430,6 +1430,7 @@ test "coerce between pointers of compatible differently-named floats" { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.os.tag == .windows) { // https://github.com/ziglang/zig/issues/12396 diff --git a/test/c_abi/cfuncs.c b/test/c_abi/cfuncs.c index f5c90adba0..391e87fc67 100644 --- a/test/c_abi/cfuncs.c +++ b/test/c_abi/cfuncs.c @@ -33,6 +33,7 @@ void zig_five_integers(int32_t, int32_t, int32_t, int32_t, int32_t); void zig_f32(float); void zig_f64(double); +void zig_longdouble(long double); void zig_five_floats(float, float, float, float, float); bool zig_ret_bool(); @@ -157,6 +158,7 @@ void run_c_tests(void) { zig_f32(12.34f); zig_f64(56.78); + zig_longdouble(12.34l); zig_five_floats(1.0f, 2.0f, 3.0f, 4.0f, 5.0f); zig_ptr((void*)0xdeadbeefL); @@ -271,6 +273,10 @@ void c_f64(double x) { assert_or_panic(x == 56.78); } +void c_long_double(long double x) { + assert_or_panic(x == 12.34l); +} + void c_ptr(void *x) { assert_or_panic(x == (void*)0xdeadbeefL); } diff --git a/test/c_abi/main.zig b/test/c_abi/main.zig index 71a53bedea..145bbc384a 100644 --- a/test/c_abi/main.zig +++ b/test/c_abi/main.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const builtin = @import("builtin"); const print = std.debug.print; const expect = std.testing.expect; @@ -89,6 +90,7 @@ export fn zig_struct_u128(a: U128) void { extern fn c_f32(f32) void; extern fn c_f64(f64) void; +extern fn c_long_double(c_longdouble) void; // On windows x64, the first 4 are passed via registers, others on the stack. extern fn c_five_floats(f32, f32, f32, f32, f32) void; @@ -107,12 +109,21 @@ test "C ABI floats" { c_five_floats(1.0, 2.0, 3.0, 4.0, 5.0); } +test "C ABI long double" { + if (!builtin.cpu.arch.isWasm()) return error.SkipZigTest; + c_long_double(12.34); +} + export fn zig_f32(x: f32) void { expect(x == 12.34) catch @panic("test failure: zig_f32"); } export fn zig_f64(x: f64) void { expect(x == 56.78) catch @panic("test failure: zig_f64"); } +export fn zig_longdouble(x: c_longdouble) void { + if (!builtin.cpu.arch.isWasm()) return; // waiting for #1481 + expect(x == 12.34) catch @panic("test failure: zig_longdouble"); +} extern fn c_ptr(*anyopaque) void; |
