Skip to content

Commit f7b77d5

Browse files
author
Keegan McAllister
committed
---
yaml --- r: 137202 b: refs/heads/release-prep c: 675aa76 h: refs/heads/master v: v3
1 parent 2b8ac38 commit f7b77d5

File tree

5 files changed

+82
-1
lines changed

5 files changed

+82
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2929
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
3030
refs/heads/libuv-update-temp-branch: 6ed22c618766f1f2a2e108eef8ce3f51be0f70b7
3131
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
32-
refs/heads/release-prep: 401aeaf6d3a6ec712ee46151faf574adaa5ff3c6
32+
refs/heads/release-prep: 675aa7692dd1b75e63b11cd991be5efddbdb2acd
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-include ../tools.mk
2+
3+
ifndef IS_WINDOWS
4+
# The assembly for exit-unreachable.rs should be shorter because it's missing
5+
# (at minimum) a return instruction.
6+
7+
all:
8+
$(RUSTC) -O --emit asm exit-ret.rs
9+
$(RUSTC) -O --emit asm exit-unreachable.rs
10+
test `wc -l < $(TMPDIR)/exit-unreachable.s` -lt `wc -l < $(TMPDIR)/exit-ret.s`
11+
else
12+
# Because of Windows exception handling, the code is not necessarily any shorter.
13+
# https://github.com/llvm-mirror/llvm/commit/64b2297786f7fd6f5fa24cdd4db0298fbf211466
14+
all:
15+
endif
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(asm)]
12+
#![crate_type="lib"]
13+
14+
pub fn exit(n: uint) {
15+
unsafe {
16+
// Pretend this asm is an exit() syscall.
17+
asm!("" :: "r"(n) :: "volatile");
18+
// Can't actually reach this point, but rustc doesn't know that.
19+
}
20+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(asm)]
12+
#![crate_type="lib"]
13+
14+
use std::intrinsics;
15+
16+
pub fn exit(n: uint) -> ! {
17+
unsafe {
18+
// Pretend this asm is an exit() syscall.
19+
asm!("" :: "r"(n) :: "volatile");
20+
intrinsics::unreachable()
21+
}
22+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::intrinsics;
12+
13+
// See also src/test/run-make/intrinsic-unreachable.
14+
15+
unsafe fn f(x: uint) -> uint {
16+
match x {
17+
17 => 23,
18+
_ => intrinsics::unreachable(),
19+
}
20+
}
21+
22+
fn main() {
23+
assert_eq!(unsafe { f(17) }, 23);
24+
}

0 commit comments

Comments
 (0)