Add fuel related functions to c-api (#2643)

Co-authored-by: Shu <me@wadza.fr>
This commit is contained in:
Shu
2021-02-08 17:03:25 +01:00
committed by GitHub
parent 1fe58fe9a4
commit 8ee0f09983
3 changed files with 47 additions and 0 deletions

View File

@@ -55,6 +55,11 @@ pub extern "C" fn wasmtime_config_interruptable_set(c: &mut wasm_config_t, enabl
c.config.interruptable(enable);
}
#[no_mangle]
pub extern "C" fn wasmtime_config_consume_fuel_set(c: &mut wasm_config_t, enable: bool) {
c.config.consume_fuel(enable);
}
#[no_mangle]
pub extern "C" fn wasmtime_config_max_wasm_stack_set(c: &mut wasm_config_t, size: usize) {
c.config.max_wasm_stack(size);

View File

@@ -42,3 +42,13 @@ pub extern "C" fn wasmtime_interrupt_handle_new(
pub extern "C" fn wasmtime_interrupt_handle_interrupt(handle: &wasmtime_interrupt_handle_t) {
handle.handle.interrupt();
}
#[no_mangle]
pub extern "C" fn wasmtime_add_fuel(store: &wasm_store_t, fuel: u64) {
store.store.add_fuel(fuel);
}
#[no_mangle]
pub extern "C" fn wasmtime_fuel_consumed(store: &wasm_store_t) -> u64 {
store.store.fuel_consumed().unwrap_or(0)
}