1#![cfg_attr(not(test), no_std)]
2extern crate alloc;
3
4pub mod memory;
5pub use lol_alloc;
6pub use purewasm_proc_macro::purewasm_bindgen;
7pub use purewasm_core;
8pub use serde;
9
10pub mod prelude {
11 pub use crate::memory::WasmMemory;
12 pub use crate::purewasm_core::{Codec, PureError, PureResult};
13 pub use crate::purewasm_bindgen;
14 pub use alloc::{boxed::Box, vec::Vec};
15 #[cfg(target_arch = "wasm32")]
17 use crate::lol_alloc::{AssumeSingleThreaded, FreeListAllocator};
18
19 #[cfg(target_arch = "wasm32")]
21 #[global_allocator]
22 static ALLOCATOR: AssumeSingleThreaded<FreeListAllocator> =
23 unsafe { AssumeSingleThreaded::new(FreeListAllocator::new()) };
24
25 #[cfg(not(test))]
27 #[panic_handler]
28 fn panic(_info: &core::panic::PanicInfo) -> ! {
29 loop { }
30 }
31
32 #[no_mangle]
34 pub extern "C" fn alloc(len: usize) -> *mut u8 {
35 let mut byte_array: Vec<u8> = Vec::with_capacity(len);
36 let ptr = byte_array.as_mut_ptr();
37 core::mem::forget(ptr);
38 ptr
39 }
40
41 #[no_mangle]
43 pub extern "C" fn de_alloc(ptr: *mut u8) {
44 unsafe {
45 drop(Box::from_raw(ptr));
46 }
47 }
48}