feature(asm) is only allowed in crate (#8)

* feature(asm) is only allowed in crate

* add tests/build.rs again - haven't found a way around it
This commit is contained in:
snd 2017-12-05 14:44:36 +01:00 committed by Tomasz Drwięga
parent 8a14926f6d
commit 6c98370236
7 changed files with 26 additions and 4 deletions

View File

@ -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]

View File

@ -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() };

View File

@ -3,6 +3,9 @@ name = "tests"
version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
[build-dependencies]
rustc_version = "0.2"
[dependencies]
crunchy = "0.1.5"
ethereum-types = { path ="../ethereum-types", features = ["std", "heapsizeof"] }

17
tests/build.rs Normal file
View File

@ -0,0 +1,17 @@
// Copyright 2015-2017 Parity Technologies
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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");
}
}

View File

@ -1,3 +1,5 @@
#![cfg_attr(asm_available, feature(asm))]
extern crate core;
#[cfg(test)]
#[macro_use]

View File

@ -8,6 +8,8 @@
//! Efficient large, fixed-size big integers and hashes.
#![cfg_attr(asm_available, feature(asm))]
#[doc(hidden)]
pub extern crate byteorder;

View File

@ -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;