Skip to content

Commit 7437995

Browse files
committed
rustc: Fix x86 ffi for struct arguments
This fixes struct passing abi on x86 ffi: Structs are now passed indirectly with byval attribute (as clang does).
1 parent a39c294 commit 7437995

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/librustc/middle/trans/cabi_x86.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,14 @@ pub fn compute_abi_info(ccx: &CrateContext,
6363
ret_ty = ArgType::direct(rty, None, None, None);
6464
}
6565

66-
for &a in atys.iter() {
67-
arg_tys.push(ArgType::direct(a, None, None, None));
66+
for &t in atys.iter() {
67+
let ty = match t.kind() {
68+
Struct => {
69+
ArgType::indirect(t, Some(ByValAttribute))
70+
}
71+
_ => ArgType::direct(t, None, None, None),
72+
};
73+
arg_tys.push(ty);
6874
}
6975

7076
return FnType {

src/test/run-pass/extern-pass-TwoU16s.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-test #5744 fails on 32 bit
12-
1311
// Test a foreign function that accepts and returns a struct
1412
// by value.
1513

16-
#[deriving(Eq)]
14+
#[deriving(Eq, Show)]
1715
struct TwoU16s {
1816
one: u16, two: u16
1917
}

src/test/run-pass/extern-pass-TwoU8s.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-test #5744 fails on 32 bit
12-
1311
// Test a foreign function that accepts and returns a struct
1412
// by value.
1513

16-
#[deriving(Eq)]
14+
#[deriving(Eq, Show)]
1715
struct TwoU8s {
1816
one: u8, two: u8
1917
}

0 commit comments

Comments
 (0)