[][src]Macro lucet_runtime_internals::lucet_hostcalls

macro_rules! lucet_hostcalls {
    {
        $(
            $(#[$attr:meta])*
            pub unsafe extern "C" fn $name:ident(
                &mut $vmctx:ident
                $(, $arg:ident : $arg_ty:ty )*,
            ) -> $ret_ty:ty {
                $($body:tt)*
            }
        )*
    } => { ... };
}
Deprecated since 0.5.0:

Use the #[lucet_hostcall] attribute instead

The macro that surrounds definitions of Lucet hostcalls in Rust.

Note: this macro has been deprecated and replaced by the #[lucet_hostcall] attribute.

It is important to use this macro for hostcalls, rather than exporting them directly, as it installs unwind protection that prevents panics from unwinding into the guest stack.

Since this is not a proc macro, the syntax is unfortunately fairly brittle. The functions it encloses must be of the form:

This example is not tested
#[$attr1]
#[$attr2]
... // any number of attributes are supported; in most cases you will want `#[no_mangle]`
pub unsafe extern "C" fn $name( // must be `pub unsafe extern "C"`
    &mut $vmctx,
    $arg1: $arg1_ty,
    $arg2: $arg2_ty,
    ... , // trailing comma must always be present
) -> $ret_ty { // return type must always be present even if it is `()`
    // body
}