auto merge of #9860 : thestinger/rust/abort, r=Aatch

This should be preferred to calling the libc `abort` function.
This commit is contained in:
bors 2013-10-14 19:51:34 -07:00
commit 1252ad4092
3 changed files with 9 additions and 0 deletions

View File

@ -222,6 +222,11 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
}
match name {
"abort" => {
let llfn = bcx.ccx().intrinsics.get_copy(&("llvm.trap"));
Call(bcx, llfn, [], []);
RetVoid(bcx);
}
"size_of" => {
let tp_ty = substs.tys[0];
let lltp_ty = type_of::type_of(ccx, tp_ty);

View File

@ -3585,6 +3585,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
} else {
match name {
"abort" => (0, ~[], ty::mk_bot()),
"size_of" |
"pref_align_of" | "min_align_of" => (1u, ~[], ty::mk_uint()),
"init" => (1u, ~[], param(ccx, 0u)),

View File

@ -171,6 +171,9 @@ pub trait TyVisitor {
}
extern "rust-intrinsic" {
/// Abort the execution of the process.
#[cfg(not(stage0))]
pub fn abort() -> !;
/// Atomic compare and exchange, sequentially consistent.
pub fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int;