llvm: aarch64 C ABI: pass byref params as mutable pointers
Closes #13597
This commit is contained in:
@@ -833,3 +833,12 @@ struct PD zig_ret_PD();
|
||||
int c_assert_ret_PD(){
|
||||
return c_assert_PD(zig_ret_PD());
|
||||
}
|
||||
|
||||
struct ByRef {
|
||||
int val;
|
||||
int arr[15];
|
||||
};
|
||||
struct ByRef c_modify_by_ref_param(struct ByRef in) {
|
||||
in.val = 42;
|
||||
return in;
|
||||
}
|
||||
|
||||
@@ -988,3 +988,16 @@ pub export fn zig_assert_PD(lv: PD) c_int {
|
||||
if (err != 0) std.debug.print("Received {}", .{lv});
|
||||
return err;
|
||||
}
|
||||
|
||||
const ByRef = extern struct {
|
||||
val: c_int,
|
||||
arr: [15]c_int,
|
||||
};
|
||||
extern fn c_modify_by_ref_param(ByRef) ByRef;
|
||||
|
||||
test "C function modifies by ref param" {
|
||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||
|
||||
const res = c_modify_by_ref_param(.{ .val = 1, .arr = undefined });
|
||||
try expect(res.val == 42);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user