Move "wasm" allocator into its own crate (#4716)

This moves the wasm-allocator (`FreeingBumpHeapAllocator`) into its own
crate `sp-allocator`. This new crate can theoretically provide multiple
different allocators. Besides moving the allocator, this pr also makes
`FreeingBumpHeapAllocator` compile on `no_std`.
This commit is contained in:
Bastian Köcher
2020-01-22 18:13:17 +01:00
committed by Sergei Pepyakin
parent 670ce71009
commit 5bd6e94e64
21 changed files with 230 additions and 70 deletions
+5 -23
View File
@@ -458,36 +458,18 @@ impl<H: PartialEq + Eq + Debug> CheckEqual for super::generic::DigestItem<H> whe
}
}
macro_rules! impl_maybe_marker {
( $( $(#[$doc:meta])+ $trait_name:ident: $($trait_bound:path),+ );+ ) => {
$(
$(#[$doc])+
#[cfg(feature = "std")]
pub trait $trait_name: $($trait_bound +)+ {}
#[cfg(feature = "std")]
impl<T: $($trait_bound +)+> $trait_name for T {}
$(#[$doc])+
#[cfg(not(feature = "std"))]
pub trait $trait_name {}
#[cfg(not(feature = "std"))]
impl<T> $trait_name for T {}
)+
}
}
impl_maybe_marker!(
sp_core::impl_maybe_marker!(
/// A type that implements Display when in std environment.
MaybeDisplay: Display;
trait MaybeDisplay: Display;
/// A type that implements Hash when in std environment.
MaybeHash: sp_std::hash::Hash;
trait MaybeHash: sp_std::hash::Hash;
/// A type that implements Serialize when in std environment.
MaybeSerialize: Serialize;
trait MaybeSerialize: Serialize;
/// A type that implements Serialize, DeserializeOwned and Debug when in std environment.
MaybeSerializeDeserialize: DeserializeOwned, Serialize
trait MaybeSerializeDeserialize: DeserializeOwned, Serialize;
);
/// A type that provides a randomness beacon.