authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-06 16:21:06+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-06 17:19:07+02:00
log770aa54579130bd539670ebad18534e1bb2f6e80
tree9786e055dd6feda747adeeb25ff522e87bfa2ae1
parentbe5378b03805fa95b3cf36b6727d2c364c155e64
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Target: Fix cTypePreferredAlignment() to always return 1 for avr.

This matches avr-gcc's ABI.

1 files changed, 7 insertions(+), 8 deletions(-)

lib/std/Target.zig+7-8
...@@ -2626,7 +2626,6 @@ pub fn cTypeAlignment(target: Target, c_type: CType) u16 {...@@ -2626,7 +2626,6 @@ pub fn cTypeAlignment(target: Target, c_type: CType) u16 {
2626 },2626 },
26272627
2628 .msp430,2628 .msp430,
2629 .avr,
2630 => 2,2629 => 2,
26312630
2632 .arc,2631 .arc,
...@@ -2675,6 +2674,9 @@ pub fn cTypeAlignment(target: Target, c_type: CType) u16 {...@@ -2675,6 +2674,9 @@ pub fn cTypeAlignment(target: Target, c_type: CType) u16 {
2675 .wasm32,2674 .wasm32,
2676 .wasm64,2675 .wasm64,
2677 => 16,2676 => 16,
2677
2678 .avr,
2679 => unreachable, // Handled above.
2678 }),2680 }),
2679 );2681 );
2680}2682}
...@@ -2709,12 +2711,7 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {...@@ -2709,12 +2711,7 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {
2709 .longdouble => return 4,2711 .longdouble => return 4,
2710 else => {},2712 else => {},
2711 },2713 },
2712 .avr => switch (c_type) {2714 .avr => return 1,
2713 .char, .int, .uint, .long, .ulong, .float, .longdouble => return 1,
2714 .short, .ushort => return 2,
2715 .double => return 4,
2716 .longlong, .ulonglong => return 8,
2717 },
2718 .x86 => switch (target.os.tag) {2715 .x86 => switch (target.os.tag) {
2719 .windows, .uefi => switch (c_type) {2716 .windows, .uefi => switch (c_type) {
2720 .longdouble => switch (target.abi) {2717 .longdouble => switch (target.abi) {
...@@ -2750,7 +2747,6 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {...@@ -2750,7 +2747,6 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {
2750 .arc,2747 .arc,
2751 .arm,2748 .arm,
2752 .armeb,2749 .armeb,
2753 .avr,
2754 .thumb,2750 .thumb,
2755 .thumbeb,2751 .thumbeb,
2756 .amdgcn,2752 .amdgcn,
...@@ -2788,6 +2784,9 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {...@@ -2788,6 +2784,9 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {
2788 .wasm32,2784 .wasm32,
2789 .wasm64,2785 .wasm64,
2790 => 16,2786 => 16,
2787
2788 .avr,
2789 => unreachable, // Handled above.
2791 }),2790 }),
2792 );2791 );
2793}2792}