diff options
| author | Veikka Tuominen <git@vexu.eu> | 2023-01-21 23:54:14 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-01-22 01:04:20 +0200 |
| commit | aa626deadddcf26a5789d29d5ba88c978ee53b89 (patch) | |
| tree | fc1823f08bc9d99b124993e258e5c0e56a753943 /test | |
| parent | a28fbf3132b0b12841ecd70518804123149f3ac0 (diff) | |
| download | zig-aa626deadddcf26a5789d29d5ba88c978ee53b89.tar.gz zig-aa626deadddcf26a5789d29d5ba88c978ee53b89.zip | |
llvm: implement explicit Win64 and SysV calling conventions
Diffstat (limited to 'test')
| -rw-r--r-- | test/c_abi/cfuncs.c | 12 | ||||
| -rw-r--r-- | test/c_abi/main.zig | 16 |
2 files changed, 28 insertions, 0 deletions
diff --git a/test/c_abi/cfuncs.c b/test/c_abi/cfuncs.c index bd249335c5..bdf58db335 100644 --- a/test/c_abi/cfuncs.c +++ b/test/c_abi/cfuncs.c @@ -1015,3 +1015,15 @@ void __attribute__((stdcall)) stdcall_big_union(union BigUnion x) { assert_or_panic(x.a.c == 3); assert_or_panic(x.a.d == 4); } + +#ifdef __x86_64__ +struct ByRef __attribute__((ms_abi)) c_explict_win64(struct ByRef in) { + in.val = 42; + return in; +} + +struct ByRef __attribute__((sysv_abi)) c_explict_sys_v(struct ByRef in) { + in.val = 42; + return in; +} +#endif diff --git a/test/c_abi/main.zig b/test/c_abi/main.zig index 358e15a929..db76697473 100644 --- a/test/c_abi/main.zig +++ b/test/c_abi/main.zig @@ -1190,3 +1190,19 @@ test "Stdcall ABI big union" { }; stdcall_big_union(x); } + +extern fn c_explict_win64(ByRef) callconv(.Win64) ByRef; +test "explicit SysV calling convention" { + if (builtin.cpu.arch != .x86_64) return error.SkipZigTest; + + const res = c_explict_win64(.{ .val = 1, .arr = undefined }); + try expect(res.val == 42); +} + +extern fn c_explict_sys_v(ByRef) callconv(.SysV) ByRef; +test "explicit Win64 calling convention" { + if (builtin.cpu.arch != .x86_64) return error.SkipZigTest; + + const res = c_explict_sys_v(.{ .val = 1, .arr = undefined }); + try expect(res.val == 42); +} |
