Skip to content

Commit 1252ad4

Browse files
committed
auto merge of #9860 : thestinger/rust/abort, r=Aatch
This should be preferred to calling the libc `abort` function.
2 parents a7e8957 + 45e2cf3 commit 1252ad4

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/librustc/middle/trans/intrinsic.rs

+5
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
222222
}
223223

224224
match name {
225+
"abort" => {
226+
let llfn = bcx.ccx().intrinsics.get_copy(&("llvm.trap"));
227+
Call(bcx, llfn, [], []);
228+
RetVoid(bcx);
229+
}
225230
"size_of" => {
226231
let tp_ty = substs.tys[0];
227232
let lltp_ty = type_of::type_of(ccx, tp_ty);

src/librustc/middle/typeck/check/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3585,6 +3585,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
35853585

35863586
} else {
35873587
match name {
3588+
"abort" => (0, ~[], ty::mk_bot()),
35883589
"size_of" |
35893590
"pref_align_of" | "min_align_of" => (1u, ~[], ty::mk_uint()),
35903591
"init" => (1u, ~[], param(ccx, 0u)),

src/libstd/unstable/intrinsics.rs

+3
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ pub trait TyVisitor {
171171
}
172172

173173
extern "rust-intrinsic" {
174+
/// Abort the execution of the process.
175+
#[cfg(not(stage0))]
176+
pub fn abort() -> !;
174177

175178
/// Atomic compare and exchange, sequentially consistent.
176179
pub fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int;

0 commit comments

Comments
 (0)