File tree Expand file tree Collapse file tree 4 files changed +81
-0
lines changed
run-make/intrinsic-unreachable Expand file tree Collapse file tree 4 files changed +81
-0
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments