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).
This commit is contained in:
klutzy 2014-03-08 11:23:06 +09:00
parent a39c294155
commit 7437995b3e
3 changed files with 10 additions and 8 deletions

View File

@ -63,8 +63,14 @@ pub fn compute_abi_info(ccx: &CrateContext,
ret_ty = ArgType::direct(rty, None, None, None);
}
for &a in atys.iter() {
arg_tys.push(ArgType::direct(a, None, None, None));
for &t in atys.iter() {
let ty = match t.kind() {
Struct => {
ArgType::indirect(t, Some(ByValAttribute))
}
_ => ArgType::direct(t, None, None, None),
};
arg_tys.push(ty);
}
return FnType {

View File

@ -8,12 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-test #5744 fails on 32 bit
// Test a foreign function that accepts and returns a struct
// by value.
#[deriving(Eq)]
#[deriving(Eq, Show)]
struct TwoU16s {
one: u16, two: u16
}

View File

@ -8,12 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-test #5744 fails on 32 bit
// Test a foreign function that accepts and returns a struct
// by value.
#[deriving(Eq)]
#[deriving(Eq, Show)]
struct TwoU8s {
one: u8, two: u8
}