-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
756: feat(runtime-c-api) Allow to call `wasmer_export_func_call` with null inputs and a 0 arity r=syrusakbary a=Hywan Fix #753 This PR allows to call `wasmer_export_func_call` with inputs set to NULL, and an arity of 0. It avoids to create an empty inputs array. So basically: ```c wasmer_export_func_call(exported_function, NULL, 0, …, …); ``` instead of: ```c wasmer_value_t inputs = {}; wasmer_export_func_call(exported_function, inputs, 0, …, …); ``` This PR also updates the test suite for exports. Instead of just the famous `sum` function, we now test more functions, so that all Wasm types are covered, including void functions. Finally, this PR updates the `wasmer_export_func_call` signature to forbid negative arities. Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
- Loading branch information
Showing
6 changed files
with
592 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#[no_mangle] | ||
pub extern "C" fn sum(x: i32, y: i32) -> i32 { | ||
x + y | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn arity_0() -> i32 { | ||
42 | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn i32_i32(x: i32) -> i32 { | ||
x | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn i64_i64(x: i64) -> i64 { | ||
x | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn f32_f32(x: f32) -> f32 { | ||
x | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn f64_f64(x: f64) -> f64 { | ||
x | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn string() -> *const u8 { | ||
b"Hello, World!\0".as_ptr() | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn void() {} |
Binary file not shown.
Oops, something went wrong.