rustc: Hack around some FFI bustage. Unbreak servo

This commit is contained in:
Brian Anderson 2012-05-02 18:33:57 -07:00
parent 1e410f6206
commit 11354963b3
4 changed files with 35 additions and 0 deletions

View File

@ -766,6 +766,7 @@ native mod llvm {
fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
/** Returns the size of a type. FIXME: rv is actually a C_Ulonglong! */
fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
/** Returns the preferred alignment of a type. */
fn LLVMPreferredAlignmentOfType(TD: TargetDataRef,
Ty: TypeRef) -> c_uint;

View File

@ -81,6 +81,10 @@ fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] {
uint::max(a, ty_align(t))
}
}
11 /* array */ {
let elt = llvm::LLVMGetElementType(ty);
ty_align(elt)
}
_ {
fail "ty_size: unhandled type"
}
@ -100,6 +104,12 @@ fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] {
s + ty_size(t)
}
}
11 /* array */ {
let len = llvm::LLVMGetArrayLength(ty) as uint;
let elt = llvm::LLVMGetElementType(ty);
let eltsz = ty_size(elt);
len * eltsz
}
_ {
fail "ty_size: unhandled type"
}
@ -187,6 +197,16 @@ fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] {
10 /* struct */ {
classify_struct(struct_tys(ty), cls, i, off);
}
11 /* array */ {
// FIXME: I HAVE NO IDEA WHAT I AM DOING THIS MUST BE WRONG
let len = llvm::LLVMGetArrayLength(ty) as uint;
if len == 0u {
} else {
let elt = llvm::LLVMGetElementType(ty);
let tys = vec::from_elem(len, elt);
classify_struct(tys, cls, i, off);
}
}
_ {
fail "classify: unhandled type";
}

View File

@ -630,6 +630,10 @@ fn llsize_of_real(cx: @crate_ctxt, t: TypeRef) -> uint {
ret llvm::LLVMStoreSizeOfType(cx.td.lltd, t) as uint;
}
fn llsize_of_alloc(cx: @crate_ctxt, t: TypeRef) -> uint {
ret llvm::LLVMABISizeOfType(cx.td.lltd, t) as uint;
}
// Returns the preferred alignment of the given type for the current target.
// The preffered alignment may be larger than the alignment used when
// packing the type into structs

View File

@ -0,0 +1,10 @@
// Passing enums by value
enum void { }
#[nolink]
native mod bindgen {
fn printf(++v: void);
}
fn main() { }