File tree Expand file tree Collapse file tree 5 files changed +82
-1
lines changed
branches/release-prep/src/test
run-make/intrinsic-unreachable Expand file tree Collapse file tree 5 files changed +82
-1
lines changed Original file line number Diff line number Diff line change @@ -29,4 +29,4 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
29
29
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
30
30
refs/heads/libuv-update-temp-branch: 6ed22c618766f1f2a2e108eef8ce3f51be0f70b7
31
31
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
32
- refs/heads/release-prep: 401aeaf6d3a6ec712ee46151faf574adaa5ff3c6
32
+ refs/heads/release-prep: 675aa7692dd1b75e63b11cd991be5efddbdb2acd
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