mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 14:43:24 +00:00
rustc: Hack around some FFI bustage. Unbreak servo
This commit is contained in:
parent
1e410f6206
commit
11354963b3
@ -766,6 +766,7 @@ native mod llvm {
|
|||||||
fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
|
fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
|
||||||
/** Returns the size of a type. FIXME: rv is actually a C_Ulonglong! */
|
/** Returns the size of a type. FIXME: rv is actually a C_Ulonglong! */
|
||||||
fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
|
fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
|
||||||
|
fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
|
||||||
/** Returns the preferred alignment of a type. */
|
/** Returns the preferred alignment of a type. */
|
||||||
fn LLVMPreferredAlignmentOfType(TD: TargetDataRef,
|
fn LLVMPreferredAlignmentOfType(TD: TargetDataRef,
|
||||||
Ty: TypeRef) -> c_uint;
|
Ty: TypeRef) -> c_uint;
|
||||||
|
@ -81,6 +81,10 @@ fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] {
|
|||||||
uint::max(a, ty_align(t))
|
uint::max(a, ty_align(t))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11 /* array */ {
|
||||||
|
let elt = llvm::LLVMGetElementType(ty);
|
||||||
|
ty_align(elt)
|
||||||
|
}
|
||||||
_ {
|
_ {
|
||||||
fail "ty_size: unhandled type"
|
fail "ty_size: unhandled type"
|
||||||
}
|
}
|
||||||
@ -100,6 +104,12 @@ fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] {
|
|||||||
s + ty_size(t)
|
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"
|
fail "ty_size: unhandled type"
|
||||||
}
|
}
|
||||||
@ -187,6 +197,16 @@ fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] {
|
|||||||
10 /* struct */ {
|
10 /* struct */ {
|
||||||
classify_struct(struct_tys(ty), cls, i, off);
|
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";
|
fail "classify: unhandled type";
|
||||||
}
|
}
|
||||||
|
@ -630,6 +630,10 @@ fn llsize_of_real(cx: @crate_ctxt, t: TypeRef) -> uint {
|
|||||||
ret llvm::LLVMStoreSizeOfType(cx.td.lltd, t) as 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.
|
// Returns the preferred alignment of the given type for the current target.
|
||||||
// The preffered alignment may be larger than the alignment used when
|
// The preffered alignment may be larger than the alignment used when
|
||||||
// packing the type into structs
|
// packing the type into structs
|
||||||
|
10
src/test/run-pass/native-struct.rs
Normal file
10
src/test/run-pass/native-struct.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// Passing enums by value
|
||||||
|
|
||||||
|
enum void { }
|
||||||
|
|
||||||
|
#[nolink]
|
||||||
|
native mod bindgen {
|
||||||
|
fn printf(++v: void);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() { }
|
Loading…
Reference in New Issue
Block a user