add an abort intrinsic

This should be preferred to the libc `abort` function.
This commit is contained in:
Daniel Micay 2013-10-14 21:51:03 -04:00
parent a7e8957c59
commit 45e2cf39a2
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;