diff --git a/ethereum-types/Cargo.toml b/ethereum-types/Cargo.toml index f900f6e..1c52f96 100644 --- a/ethereum-types/Cargo.toml +++ b/ethereum-types/Cargo.toml @@ -3,6 +3,9 @@ name = "ethereum-types" version = "0.1.0" authors = ["debris "] +[build-dependencies] +rustc_version = "0.2" + [dependencies] uint = { path = "../uint", version = "0.1" } fixed-hash = { path = "../fixed-hash", version = "0.1" } diff --git a/ethereum-types/build.rs b/ethereum-types/build.rs new file mode 100644 index 0000000..432acc3 --- /dev/null +++ b/ethereum-types/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/ethereum-types/src/uint.rs b/ethereum-types/src/uint.rs index 6b12c8a..f1595ad 100644 --- a/ethereum-types/src/uint.rs +++ b/ethereum-types/src/uint.rs @@ -7,6 +7,7 @@ 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/uint/src/lib.rs b/uint/src/lib.rs index 4a3dc8a..01d41a7 100644 --- a/uint/src/lib.rs +++ b/uint/src/lib.rs @@ -8,8 +8,6 @@ //! 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 39e7aca..11da94e 100644 --- a/uint/src/uint.rs +++ b/uint/src/uint.rs @@ -77,6 +77,7 @@ 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; @@ -223,6 +224,7 @@ 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; @@ -277,7 +279,7 @@ macro_rules! uint_overflowing_sub { "={al}"(overflow) /* $0 - $4 */ : "{rdi}"(&result[4] as *const u64) /* $5 */ - "{rsi}"(&self_t[4] as *const u64) /* $6 */ + "{rsi}"(&self_t[4] as *const u64) /* $6 */ "0"(self_t[0]), "1"(self_t[1]), "2"(self_t[2]), "3"(self_t[3]), "m"(self_t[4]), "m"(self_t[5]), "m"(self_t[6]), "m"(self_t[7]), /* $7 - $14 */ @@ -298,6 +300,7 @@ 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;