feat(c-api) Introduce the wasmer_features_t unstable API.

This API is a wrapper around the `wasmer_types::Features` API. A new
function `wasm_config_set_features` allows to define features for the
engine and the compiler.
This commit is contained in:
Ivan Enderlin
2021-03-01 16:02:43 +01:00
parent 64baed9337
commit d1fc49d9c2
4 changed files with 440 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
//! `wasm_engine_t` and siblings.
use super::super::engine::{wasm_config_t, wasmer_compiler_t, wasmer_engine_t};
use super::features::wasmer_features_t;
use super::target_lexicon::wasmer_target_t;
/// Unstable non-standard Wasmer-specific API to update the
@@ -48,6 +49,52 @@ pub extern "C" fn wasm_config_set_target(config: &mut wasm_config_t, target: Box
config.target = Some(target);
}
/// Unstable non-standard Wasmer-specific API to update the
/// configuration to specify particular features for the engine.
///
/// # Example
///
/// ```rust
/// # use inline_c::assert_c;
/// # fn main() {
/// # (assert_c! {
/// # #include "tests/wasmer_wasm.h"
/// #
/// int main() {
/// // Create the configuration.
/// wasm_config_t* config = wasm_config_new();
///
/// // Set the target.
/// {
/// wasmer_features_t* features = wasmer_features_new();
/// wasmer_features_simd(features, true);
///
/// wasm_config_set_features(config, features);
/// }
///
/// // Create the engine.
/// wasm_engine_t* engine = wasm_engine_new_with_config(config);
///
/// // Check we have an engine!
/// assert(engine);
///
/// // Free everything.
/// wasm_engine_delete(engine);
///
/// return 0;
/// }
/// # })
/// # .success();
/// # }
/// ```
#[no_mangle]
pub extern "C" fn wasm_config_set_features(
config: &mut wasm_config_t,
features: Box<wasmer_features_t>,
) {
config.features = Some(features);
}
/// Check whether the given compiler is available, i.e. part of this
/// compiled library.
#[no_mangle]