| author | |
| committer | |
| log | f2a7aba586157482131611c57a283f3b4cfee98d |
| tree | 9885b007a1e1c7ccfd1d8ea3f21e106fd0a952e4 |
| parent | be10f95994d077f9b8137bb58d0349f78f408219 |
Closes #132114 files changed, 31 insertions(+), 6 deletions(-)
src/codegen/llvm.zig-5| ... | @@ -10432,11 +10432,6 @@ const ParamTypeIterator = struct { | ... | @@ -10432,11 +10432,6 @@ const ParamTypeIterator = struct { |
| 10432 | it.llvm_index += 1; | 10432 | it.llvm_index += 1; |
| 10433 | return .abi_sized_int; | 10433 | return .abi_sized_int; |
| 10434 | } | 10434 | } |
| 10435 | if (classes[0] == .sse and classes[1] == .none) { | ||
| 10436 | it.zig_index += 1; | ||
| 10437 | it.llvm_index += 1; | ||
| 10438 | return .byval; | ||
| 10439 | } | ||
| 10440 | it.llvm_types_buffer = llvm_types_buffer; | 10435 | it.llvm_types_buffer = llvm_types_buffer; |
| 10441 | it.llvm_types_len = llvm_types_index; | 10436 | it.llvm_types_len = llvm_types_index; |
| 10442 | it.llvm_index += llvm_types_index; | 10437 | it.llvm_index += llvm_types_index; |
test/c_abi/cfuncs.c+12| ... | @@ -758,3 +758,15 @@ void c_big_vec(BigVec vec) { | ... | @@ -758,3 +758,15 @@ void c_big_vec(BigVec vec) { |
| 758 | BigVec c_ret_big_vec(void) { | 758 | BigVec c_ret_big_vec(void) { |
| 759 | return (BigVec){9, 10, 11, 12, 13, 14, 15, 16}; | 759 | return (BigVec){9, 10, 11, 12, 13, 14, 15, 16}; |
| 760 | } | 760 | } |
| 761 | |||
| 762 | typedef struct { | ||
| 763 | float x, y; | ||
| 764 | } Vector2; | ||
| 765 | |||
| 766 | void c_ptr_size_float_struct(Vector2 vec) { | ||
| 767 | assert_or_panic(vec.x == 1); | ||
| 768 | assert_or_panic(vec.y == 2); | ||
| 769 | } | ||
| 770 | Vector2 c_ret_ptr_size_float_struct(void) { | ||
| 771 | return (Vector2){3, 4}; | ||
| 772 | } |
test/c_abi/main.zig+18| ... | @@ -813,3 +813,21 @@ test "big simd vector" { | ... | @@ -813,3 +813,21 @@ test "big simd vector" { |
| 813 | try expect(x[6] == 15); | 813 | try expect(x[6] == 15); |
| 814 | try expect(x[7] == 16); | 814 | try expect(x[7] == 16); |
| 815 | } | 815 | } |
| 816 | |||
| 817 | const Vector2 = extern struct { x: f32, y: f32 }; | ||
| 818 | |||
| 819 | extern fn c_ptr_size_float_struct(Vector2) void; | ||
| 820 | extern fn c_ret_ptr_size_float_struct() Vector2; | ||
| 821 | |||
| 822 | test "C ABI pointer sized float struct" { | ||
| 823 | if (builtin.cpu.arch == .i386) return error.SkipZigTest; | ||
| 824 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; | ||
| 825 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; | ||
| 826 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; | ||
| 827 | |||
| 828 | c_ptr_size_float_struct(.{ .x = 1, .y = 2 }); | ||
| 829 | |||
| 830 | var x = c_ret_ptr_size_float_struct(); | ||
| 831 | try expect(x.x == 3); | ||
| 832 | try expect(x.y == 4); | ||
| 833 | } |
test/tests.zig+1-1| ... | @@ -1314,7 +1314,7 @@ const c_abi_targets = [_]CrossTarget{ | ... | @@ -1314,7 +1314,7 @@ const c_abi_targets = [_]CrossTarget{ |
| 1314 | .{ | 1314 | .{ |
| 1315 | .cpu_arch = .powerpc64le, | 1315 | .cpu_arch = .powerpc64le, |
| 1316 | .os_tag = .linux, | 1316 | .os_tag = .linux, |
| 1317 | .abi = .none, | 1317 | .abi = .musl, |
| 1318 | }, | 1318 | }, |
| 1319 | }; | 1319 | }; |
| 1320 | 1320 |