diff options
| author | Veikka Tuominen <git@vexu.eu> | 2023-01-19 16:13:52 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-01-19 16:13:52 +0200 |
| commit | 2b7678bc421e2efbdbce60d0f25ac68ffa20e100 (patch) | |
| tree | ec68858f064a42ce790db3dd787434564fde876c /test | |
| parent | 5949851074597dbc315476237f42fa67a0b6770a (diff) | |
| download | zig-2b7678bc421e2efbdbce60d0f25ac68ffa20e100.tar.gz zig-2b7678bc421e2efbdbce60d0f25ac68ffa20e100.zip | |
llvm: implement Stdcall return types
Diffstat (limited to 'test')
| -rw-r--r-- | test/c_abi/cfuncs.c | 3 | ||||
| -rw-r--r-- | test/c_abi/main.zig | 12 |
2 files changed, 12 insertions, 3 deletions
diff --git a/test/c_abi/cfuncs.c b/test/c_abi/cfuncs.c index 50e58c508e..bd249335c5 100644 --- a/test/c_abi/cfuncs.c +++ b/test/c_abi/cfuncs.c @@ -999,13 +999,14 @@ typedef struct { short y; } Coord2; -void __attribute__((stdcall)) stdcall_coord2(Coord2 a, Coord2 b, Coord2 c) { +Coord2 __attribute__((stdcall)) stdcall_coord2(Coord2 a, Coord2 b, Coord2 c) { assert_or_panic(a.x == 0x1111); assert_or_panic(a.y == 0x2222); assert_or_panic(b.x == 0x3333); assert_or_panic(b.y == 0x4444); assert_or_panic(c.x == 0x5555); assert_or_panic(c.y == 0x6666); + return (Coord2){123, 456}; } void __attribute__((stdcall)) stdcall_big_union(union BigUnion x) { diff --git a/test/c_abi/main.zig b/test/c_abi/main.zig index 5511094487..e9543c4e7e 100644 --- a/test/c_abi/main.zig +++ b/test/c_abi/main.zig @@ -1161,17 +1161,25 @@ const Coord2 = extern struct { y: i16, }; -extern fn stdcall_coord2(Coord2, Coord2, Coord2) callconv(stdcall_callconv) void; +extern fn stdcall_coord2(Coord2, Coord2, Coord2) callconv(stdcall_callconv) Coord2; test "Stdcall ABI structs" { - stdcall_coord2( + if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; + if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; + if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; + + const res = stdcall_coord2( .{ .x = 0x1111, .y = 0x2222 }, .{ .x = 0x3333, .y = 0x4444 }, .{ .x = 0x5555, .y = 0x6666 }, ); + try expect(res.x == 123); + try expect(res.y == 456); } extern fn stdcall_big_union(BigUnion) callconv(stdcall_callconv) void; test "Stdcall ABI big union" { + if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; + var x = BigUnion{ .a = BigStruct{ .a = 1, |
