Skip to content

Commit 93a1853

Browse files
committed
Make usage of unstable asm! macro optional.
1 parent 49f2c4a commit 93a1853

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ version = "0.1.0"
44
authors = ["The Rust Project Developers"]
55
license = "MIT OR Apache-2.0"
66

7+
[features]
8+
asm_black_box = []
9+
710
[dependencies]
811
libc = "0.2"
912
getopts = "0.2"

src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
// build off of.
2525

2626
#![crate_name = "test"]
27-
#![unstable(feature = "test", issue = "27812")]
2827
#![crate_type = "rlib"]
2928
#![crate_type = "dylib"]
3029
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
@@ -33,9 +32,8 @@
3332
test(attr(deny(warnings))))]
3433
#![cfg_attr(not(stage0), deny(warnings))]
3534

36-
#![feature(asm)]
35+
#![cfg_attr(feature = "asm_black_box", feature(asm))]
3736
#![feature(set_stdio)]
38-
#![feature(staged_api)]
3937
#![feature(time2)]
4038

4139
extern crate getopts;
@@ -1187,14 +1185,14 @@ impl MetricMap {
11871185
/// elimination.
11881186
///
11891187
/// This function is a no-op, and does not even read from `dummy`.
1190-
#[cfg(not(all(target_os = "nacl", target_arch = "le32")))]
1188+
#[cfg(all(feature = "asm_black_box", not(all(target_os = "nacl", target_arch = "le32"))))]
11911189
pub fn black_box<T>(dummy: T) -> T {
11921190
// we need to "use" the argument in some way LLVM can't
11931191
// introspect.
11941192
unsafe { asm!("" : : "r"(&dummy)) }
11951193
dummy
11961194
}
1197-
#[cfg(all(target_os = "nacl", target_arch = "le32"))]
1195+
#[cfg(not(all(feature = "asm_black_box", not(all(target_os = "nacl", target_arch = "le32")))))]
11981196
#[inline(never)]
11991197
pub fn black_box<T>(dummy: T) -> T {
12001198
dummy

0 commit comments

Comments
 (0)