Commit 9b3d3426 authored by Hero Bird's avatar Hero Bird

[pdsl_core] Move panic handlers and global allocator def to pdsl_core

parent 57ddb7bc
......@@ -9,7 +9,6 @@ pdsl_core = { path = "../../pdsl_core" }
parity-codec = { version = "2.0.4", default-features = false }
parity-codec-derive = { version = "2.0.4", default-features = false }
wee_alloc = "0.4"
lazy_static = "1.2"
spin = { version = "0.4", default-features = false }
......
......@@ -6,6 +6,7 @@
#[cfg(all(test, feature = "test-env"))]
mod tests;
mod utils;
#[cfg_attr(test, macro_use)]
extern crate alloc;
......@@ -13,15 +14,9 @@ extern crate alloc;
use alloc::string::String;
use alloc::vec::Vec;
pub mod utils;
use pdsl_core::storage;
use parity_codec_derive::{Encode, Decode};
// Use `wee_alloc` as the global allocator.
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
/// A peep done by a registered user.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Encode, Decode)]
......
......@@ -18,21 +18,6 @@ use spin::Mutex;
use alloc::string::String;
#[panic_handler]
#[no_mangle]
pub fn panic(_info: &::core::panic::PanicInfo) -> ! {
unsafe {
core::intrinsics::abort()
}
}
#[alloc_error_handler]
pub extern fn oom(_: ::core::alloc::Layout) -> ! {
unsafe {
core::intrinsics::abort();
}
}
pub type Address = [u8; 32];
/// Return current contract caller as 32-bytes array.
......
......@@ -23,6 +23,7 @@ parity-codec-derive = { version = "2.0" }
tiny-keccak = "1.4"
log = "0.4"
hashbrown = "0.1.7"
wee_alloc = "0.4"
[dev-dependencies]
env_logger = { version = "0.6", default-features = false }
......
......@@ -15,16 +15,28 @@
// along with pDSL. If not, see <http://www.gnu.org/licenses/>.
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(alloc))]
#![cfg_attr(not(feature = "std"), feature(
alloc,
core_intrinsics,
lang_items,
alloc_error_handler,
))]
#[cfg(not(feature = "std"))]
// #[macro_use]
extern crate alloc;
// Use `wee_alloc` as the global allocator.
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
#[cfg(all(test, feature = "std"))]
#[macro_use]
mod test_utils;
#[cfg(not(feature = "std"))]
mod panic_handler;
pub mod memory;
mod byte_utils;
pub mod env;
......
use core::panic::PanicInfo;
use core::alloc::Layout;
#[panic_handler]
#[no_mangle]
pub fn panic(_info: &PanicInfo) -> ! {
unsafe { core::intrinsics::abort() }
}
#[alloc_error_handler]
pub extern fn oom(_: Layout) -> ! {
unsafe { core::intrinsics::abort(); }
}
#[lang = "eh_personality"]
extern fn eh_personality() {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment