diff --git a/ethereum-types/src/lib.rs b/ethereum-types/src/lib.rs index c10128b..62229c2 100644 --- a/ethereum-types/src/lib.rs +++ b/ethereum-types/src/lib.rs @@ -1,5 +1,7 @@ #![cfg_attr(not(feature="std"), no_std)] +#![cfg_attr(asm_available, feature(asm))] + #[cfg(feature="std")] extern crate core; #[macro_use] diff --git a/ethereum-types/src/uint.rs b/ethereum-types/src/uint.rs index f1595ad..6b12c8a 100644 --- a/ethereum-types/src/uint.rs +++ b/ethereum-types/src/uint.rs @@ -7,7 +7,6 @@ impl U256 { /// No overflow possible #[cfg(all(asm_available, target_arch="x86_64"))] pub fn full_mul(self, other: U256) -> U512 { - #![feature(asm)] let self_t: &[u64; 4] = &self.0; let other_t: &[u64; 4] = &other.0; let mut result: [u64; 8] = unsafe { ::core::mem::uninitialized() }; diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 6734e37..4450162 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -3,6 +3,9 @@ name = "tests" version = "0.1.0" authors = ["debris "] +[build-dependencies] +rustc_version = "0.2" + [dependencies] crunchy = "0.1.5" ethereum-types = { path ="../ethereum-types", features = ["std", "heapsizeof"] } diff --git a/tests/build.rs b/tests/build.rs new file mode 100644 index 0000000..432acc3 --- /dev/null +++ b/tests/build.rs @@ -0,0 +1,17 @@ +// Copyright 2015-2017 Parity Technologies +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate rustc_version; + +use rustc_version::{version_meta, Channel}; + +fn main() { + if let Channel::Nightly = version_meta().unwrap().channel { + println!("cargo:rustc-cfg=asm_available"); + } +} diff --git a/tests/src/lib.rs b/tests/src/lib.rs index 2e0befa..342dbef 100644 --- a/tests/src/lib.rs +++ b/tests/src/lib.rs @@ -1,3 +1,5 @@ +#![cfg_attr(asm_available, feature(asm))] + extern crate core; #[cfg(test)] #[macro_use] diff --git a/uint/src/lib.rs b/uint/src/lib.rs index 01d41a7..4a3dc8a 100644 --- a/uint/src/lib.rs +++ b/uint/src/lib.rs @@ -8,6 +8,8 @@ //! Efficient large, fixed-size big integers and hashes. +#![cfg_attr(asm_available, feature(asm))] + #[doc(hidden)] pub extern crate byteorder; diff --git a/uint/src/uint.rs b/uint/src/uint.rs index 11da94e..e3260bd 100644 --- a/uint/src/uint.rs +++ b/uint/src/uint.rs @@ -77,7 +77,6 @@ macro_rules! uint_overflowing_add_reg { #[macro_export] #[doc(hidden)] macro_rules! uint_overflowing_add { - #![feature(asm)] (U256, $n_words:tt, $self_expr: expr, $other: expr) => ({ let mut result: [u64; $n_words] = unsafe { ::core::mem::uninitialized() }; let self_t: &[u64; $n_words] = &$self_expr.0; @@ -224,7 +223,6 @@ macro_rules! uint_overflowing_sub_reg { #[macro_export] #[doc(hidden)] macro_rules! uint_overflowing_sub { - #![feature(asm)] (U256, $n_words:tt, $self_expr: expr, $other: expr) => ({ let mut result: [u64; $n_words] = unsafe { ::core::mem::uninitialized() }; let self_t: &[u64; $n_words] = &$self_expr.0; @@ -300,7 +298,6 @@ macro_rules! uint_overflowing_sub { #[cfg(all(asm_available, target_arch="x86_64"))] #[macro_export] macro_rules! uint_overflowing_mul { - #![feature(asm)] (U256, $n_words: expr, $self_expr: expr, $other: expr) => ({ let mut result: [u64; $n_words] = unsafe { ::core::mem::uninitialized() }; let self_t: &[u64; $n_words] = &$self_expr.0;