1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! Core entrypoints shared by all module types
use Pod;
use Zeroable;
/// `ark_initialize` - Initialize module
///
/// This gets called once when a module is started and enables the module to prepare its state and resources.
/// If something goes wrong, the module can communicate that by panicking, and then it will be unloaded.
///
/// # Example
///
/// ```
/// #[no_mangle]
/// pub unsafe fn ark_initialize() {
/// }
/// ```
pub type InitializeFn = fn;
/// `ark_alloc` - Allocate a raw buffer in the module
///
/// This is called from the host to be able to allocate and write memory
/// in a module that it then can pass in as a pointer when calling other
/// entrypoint functions in the module
///
/// # Example
///
/// ```
/// #[no_mangle]
/// pub unsafe fn ark_alloc(size: usize, alignment: usize) -> *mut u8 {
/// std::ptr::null_mut()
/// }
/// ```
pub type AllocFn = fn ;
/// `ark_free` - Free a raw buffer in the module
///
/// This is intended to be used on memory allocated with `ark_alloc`
///
/// # Example
///
/// ```
/// #[no_mangle]
/// pub unsafe fn ark_free(ptr: *mut u8, size: usize, alignment: usize) {
/// }
/// ```
pub type FreeFn = fn;
/// `ark_register_panic_hook` - Register module specific panic hook
///
/// This gets called once when a module is started (or possibly by tests), and
/// enables the module to catch panics and report them back to the host.
pub type RegisterPanicHookFn = fn;
/// Type for the data pointed to by the return value of `ark_get_alloc_stats`.
// Utilities to compute some common stats from the cumulative sums.
/// `ark_get_alloc_stats` - Returns a pointer into Wasm memory to an instance of the `AllocStats` data structure.
///
/// `AllocStats` counts allocations and frees, so the host can get an idea of current
/// memory use in a module.
pub type GetAllocStatsFn = fn ;
pub const INITIALIZE: &str = "ark_initialize";
pub const ALLOC: &str = "ark_alloc";
pub const FREE: &str = "ark_free";
pub const REGISTER_PANIC_HOOK: &str = "ark_register_panic_hook";
pub const GET_ALLOC_STATS: &str = "ark_get_alloc_stats";