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
#![forbid(unused_must_use)]
#![forbid(clippy::missing_safety_doc)]
#![deny(clippy::undocumented_unsafe_blocks)]
#![deny(clippy::exhaustive_structs)]

#[cfg(all(
    not(miri),
    target_arch = "x86_64",
    any(target_os = "linux", target_os = "macos", target_os = "freebsd")
))]
macro_rules! if_compiler_is_supported {
    ({
        $($if_true:tt)*
    } else {
        $($if_false:tt)*
    }) => {
        $($if_true)*
    };

    ($($if_true:tt)*) => {
        $($if_true)*
    }
}

#[cfg(not(all(
    not(miri),
    target_arch = "x86_64",
    any(target_os = "linux", target_os = "macos", target_os = "freebsd")
)))]
macro_rules! if_compiler_is_supported {
    ({
        $($if_true:tt)*
    } else {
        $($if_false:tt)*
    }) => {
        $($if_false)*
    };

    ($($if_true:tt)*) => {}
}

mod error;

mod api;
mod caller;
mod config;
mod interpreter;
mod source_cache;
mod tracer;
mod utils;

if_compiler_is_supported! {
    mod compiler;
    mod sandbox;
}

pub use polkavm_common::{
    abi::MemoryMap,
    error::{ExecutionError, Trap},
    program::{ProgramBlob, ProgramParseError, Reg},
    utils::{AsUninitSliceMut, Gas},
};

pub use crate::api::{CallArgs, Engine, ExportIndex, Instance, InstancePre, Linker, Module, StateArgs};
pub use crate::caller::{Caller, CallerRef};
pub use crate::config::{BackendKind, Config, GasMeteringKind, ModuleConfig, SandboxKind};
pub use crate::error::Error;

#[cfg(test)]
mod tests;