From f20b51608dfee450510b56835b63afea565b5baa Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 29 May 2019 12:10:16 +0100 Subject: [PATCH 1/2] Turn debug module into macros --- src/debug.rs | 58 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/src/debug.rs b/src/debug.rs index ae2e659..ca8f5d2 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -16,31 +16,77 @@ mod native { } /// Prints an unsigned 32-bit int. -pub fn print32(value: u32) { +fn print32(value: u32) { unsafe { native::debug_print32(value) } } /// Prints an unsigned 64-bit int. -pub fn print64(value: u64) { +fn print64(value: u64) { unsafe { native::debug_print64(value) } } /// Prints the contents of a slice. -pub fn print_mem(slice: &[u8]) { +fn print_mem(slice: &[u8]) { unsafe { native::debug_printMem(slice.as_ptr() as *const u32, slice.len() as u32) } } /// Prints the contents of a slice in hexadecimal format. -pub fn print_mem_hex(slice: &[u8]) { +fn print_mem_hex(slice: &[u8]) { unsafe { native::debug_printMemHex(slice.as_ptr() as *const u32, slice.len() as u32) } } /// Prints the value of a storage key. -pub fn print_storage(key: &StorageKey) { +fn print_storage(key: &StorageKey) { unsafe { native::debug_printStorage(key.bytes.as_ptr() as *const u32) } } /// Prints the value of a storage key in hexadecimal format. -pub fn print_storage_hex(key: &StorageKey) { +fn print_storage_hex(key: &StorageKey) { unsafe { native::debug_printStorageHex(key.bytes.as_ptr() as *const u32) } } + +#[macro_export] +macro_rules! print32 { + ($e:expr) => { + #[cfg(debug_assertions)] + $crate::debug::native::print32($e) + }; +} + +#[macro_export] +macro_rules! print64 { + ($e:expr) => { + #[cfg(debug_assertions)] + $crate::debug::native::print64($e) + }; +} + +#[macro_export] +macro_rules! print_mem { + ($e:expr) => { + #[cfg(debug_assertions)] + $crate::debug::native::print_mem($e) + }; +} + +#[macro_export] +macro_rules! print_mem_hex { + ($e:expr) => { + #[cfg(debug_assertions)] + $crate::debug::native::print_mem_hex($e) + }; +} +#[macro_export] +macro_rules! print_storage { + ($e:expr) => { + #[cfg(debug_assertions)] + $crate::debug::native::print_storage($e) + }; +} +#[macro_export] +macro_rules! print_storage_hex { + ($e:expr) => { + #[cfg(debug_assertions)] + $crate::debug::native::print_storage_hex($e) + }; +} From b1f0da75e01b51d56981596af798e3a2138bf5e5 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 30 May 2019 11:17:41 +0100 Subject: [PATCH 2/2] Remove debug feature --- Cargo.toml | 1 - README.md | 1 - circle.yml | 6 ++---- src/lib.rs | 3 --- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dc575a9..c4839d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,5 @@ qimalloc = { version = "0.1", optional = true } [features] default = ["std", "wee_alloc"] std = [] -debug = [] experimental = [] eth2 = [] diff --git a/README.md b/README.md index 1ce4205..aff29b7 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,6 @@ Other modules are available as well, outside of the prelude. Refer to the docume `ewasm-rust-api` builds with various feature sets: - `default`: Builds with `wee_alloc` as the global allocator and with the Rust standard library. - `qimalloc`: Builds with [qimalloc](https://github.com/wasmx/qimalloc) as the global allocator. -- `debug`: Exposes the debugging interface. - `experimental`: Exposes the experimental bignum system library API. To enable specific features include the dependency as follows: diff --git a/circle.yml b/circle.yml index 6e8ab55..3176d95 100644 --- a/circle.yml +++ b/circle.yml @@ -37,11 +37,9 @@ jobs: cargo build --release --no-default-features --features qimalloc # different feature sets cargo build --release --no-default-features - cargo build --release --features debug - cargo build --release --no-default-features --features debug cargo build --release --features experimental cargo build --release --no-default-features --features experimental - cargo build --release --features experimental,debug - cargo build --release --no-default-features --features experimental,debug cargo build --release --features eth2 cargo build --release --no-default-features --features eth2 + cargo build --release --features experimental,eth2 + cargo build --release --no-default-features --features experimental,eth2 diff --git a/src/lib.rs b/src/lib.rs index 9e7e48c..5912664 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,6 @@ //! library. //! - `qimalloc`: Builds with [qimalloc](https://github.com/wasmx/qimalloc) as the global //! allocator. -//! - `debug`: Exposes the debugging interface. //! - `experimental`: Exposes the experimental bignum system library API. //! //! # Examples @@ -58,7 +57,6 @@ mod utils; pub mod types; -#[cfg(feature = "debug")] pub mod debug; #[cfg(feature = "experimental")] @@ -86,7 +84,6 @@ pub mod prelude { #[cfg(not(feature = "std"))] pub use crate::convert::*; - #[cfg(feature = "debug")] pub use crate::debug; #[cfg(feature = "experimental")]