Issue 6 (#7)
* add rustc_version to build deps of ether types (needed by build script) * ethereum-types: add build script that sets cargo:rustc-cfg=asm_available on nightly * ethereum-types: #![cfg_attr(asm_available, feature(asm))] * tests: add the whole feature asm build script to make it pass on nightly CI * add #![cfg_attr(asm_available, feature(asm))] directly where needed so users don't have to add it * remove tests/build.rs since it should not be needed anymore * move inner cfg_attr attributes to the right allowed position * remove check for asm_available in contexts that already have check for that
This commit is contained in:
parent
d910e92888
commit
8a14926f6d
|
@ -3,6 +3,9 @@ name = "ethereum-types"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["debris <marek.kotewicz@gmail.com>"]
|
authors = ["debris <marek.kotewicz@gmail.com>"]
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
rustc_version = "0.2"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
uint = { path = "../uint", version = "0.1" }
|
uint = { path = "../uint", version = "0.1" }
|
||||||
fixed-hash = { path = "../fixed-hash", version = "0.1" }
|
fixed-hash = { path = "../fixed-hash", version = "0.1" }
|
||||||
|
|
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ impl U256 {
|
||||||
/// No overflow possible
|
/// No overflow possible
|
||||||
#[cfg(all(asm_available, target_arch="x86_64"))]
|
#[cfg(all(asm_available, target_arch="x86_64"))]
|
||||||
pub fn full_mul(self, other: U256) -> U512 {
|
pub fn full_mul(self, other: U256) -> U512 {
|
||||||
|
#![feature(asm)]
|
||||||
let self_t: &[u64; 4] = &self.0;
|
let self_t: &[u64; 4] = &self.0;
|
||||||
let other_t: &[u64; 4] = &other.0;
|
let other_t: &[u64; 4] = &other.0;
|
||||||
let mut result: [u64; 8] = unsafe { ::core::mem::uninitialized() };
|
let mut result: [u64; 8] = unsafe { ::core::mem::uninitialized() };
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
//! Efficient large, fixed-size big integers and hashes.
|
//! Efficient large, fixed-size big integers and hashes.
|
||||||
|
|
||||||
#![cfg_attr(asm_available, feature(asm))]
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub extern crate byteorder;
|
pub extern crate byteorder;
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,7 @@ macro_rules! uint_overflowing_add_reg {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
macro_rules! uint_overflowing_add {
|
macro_rules! uint_overflowing_add {
|
||||||
|
#![feature(asm)]
|
||||||
(U256, $n_words:tt, $self_expr: expr, $other: expr) => ({
|
(U256, $n_words:tt, $self_expr: expr, $other: expr) => ({
|
||||||
let mut result: [u64; $n_words] = unsafe { ::core::mem::uninitialized() };
|
let mut result: [u64; $n_words] = unsafe { ::core::mem::uninitialized() };
|
||||||
let self_t: &[u64; $n_words] = &$self_expr.0;
|
let self_t: &[u64; $n_words] = &$self_expr.0;
|
||||||
|
@ -223,6 +224,7 @@ macro_rules! uint_overflowing_sub_reg {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
macro_rules! uint_overflowing_sub {
|
macro_rules! uint_overflowing_sub {
|
||||||
|
#![feature(asm)]
|
||||||
(U256, $n_words:tt, $self_expr: expr, $other: expr) => ({
|
(U256, $n_words:tt, $self_expr: expr, $other: expr) => ({
|
||||||
let mut result: [u64; $n_words] = unsafe { ::core::mem::uninitialized() };
|
let mut result: [u64; $n_words] = unsafe { ::core::mem::uninitialized() };
|
||||||
let self_t: &[u64; $n_words] = &$self_expr.0;
|
let self_t: &[u64; $n_words] = &$self_expr.0;
|
||||||
|
@ -277,7 +279,7 @@ macro_rules! uint_overflowing_sub {
|
||||||
"={al}"(overflow) /* $0 - $4 */
|
"={al}"(overflow) /* $0 - $4 */
|
||||||
|
|
||||||
: "{rdi}"(&result[4] as *const u64) /* $5 */
|
: "{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]),
|
"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]),
|
"m"(self_t[4]), "m"(self_t[5]), "m"(self_t[6]), "m"(self_t[7]),
|
||||||
/* $7 - $14 */
|
/* $7 - $14 */
|
||||||
|
@ -298,6 +300,7 @@ macro_rules! uint_overflowing_sub {
|
||||||
#[cfg(all(asm_available, target_arch="x86_64"))]
|
#[cfg(all(asm_available, target_arch="x86_64"))]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! uint_overflowing_mul {
|
macro_rules! uint_overflowing_mul {
|
||||||
|
#![feature(asm)]
|
||||||
(U256, $n_words: expr, $self_expr: expr, $other: expr) => ({
|
(U256, $n_words: expr, $self_expr: expr, $other: expr) => ({
|
||||||
let mut result: [u64; $n_words] = unsafe { ::core::mem::uninitialized() };
|
let mut result: [u64; $n_words] = unsafe { ::core::mem::uninitialized() };
|
||||||
let self_t: &[u64; $n_words] = &$self_expr.0;
|
let self_t: &[u64; $n_words] = &$self_expr.0;
|
||||||
|
|
Loading…
Reference in New Issue