#![feature(vec_into_raw_parts)] #![no_std] use cultivar_common::{prelude::*, std_bis::*}; //use cultivar_runtime_interface::prelude::*; use parity_scale_codec::Decode; #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; //static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc; /// # Safety /// The pointer given in argument must be valid, or undefined data will be read. #[export_name = "run"] pub unsafe fn run(ptr: *mut u8, len: usize) -> u64 { let data = unsafe { Vec::from_raw_parts(ptr, len, len) }; let sim_id = SimId::decode(&mut &data[..]).unwrap(); run_inner(sim_id); let (ptr, len, _) = data.into_raw_parts(); (len as u64) << 32 | ptr as u64 } fn run_inner(sim_id: SimId) { say(&format!("{:?}", walk(sim_id, EntityId(0), Direction::East))); }