Commit Graph

558 Commits

Author SHA1 Message Date
Ivan Enderlin
9fb174e961 doc(c-api) Add more documentation. 2021-01-29 14:41:41 +01:00
Ivan Enderlin
3c5692ca2f doc(c-api) Mark some types as unstable. 2021-01-29 14:39:59 +01:00
Ivan Enderlin
dc9f8fc82c chore(c-api) Update headers. 2021-01-29 14:34:59 +01:00
Ivan Enderlin
e4057469bc chore(c-api) get_default_compiler_config can stay private. 2021-01-29 14:29:50 +01:00
Ivan Enderlin
9fda912f31 feat(c-api) wasm_config_t and wasm_engine_new_with_config handle the target. 2021-01-29 14:27:07 +01:00
Ivan Enderlin
14b8fb0a9a feat(c-api) Implement wasm_config_set_target. 2021-01-29 14:26:52 +01:00
Ivan Enderlin
bc5bbfdeef feat(c-api) Implement Debug for wasm_target_t. 2021-01-29 14:26:38 +01:00
Ivan Enderlin
1eec258550 chore(c-api) Remove warning. 2021-01-29 14:25:47 +01:00
Ivan Enderlin
169fe16f31 doc+test(c-api) Add more tests and more documentation. 2021-01-29 12:34:14 +01:00
Ivan Enderlin
8f42485a49 Merge branch 'master' into feat-c-api-cross-compilation-2 2021-01-29 11:55:14 +01:00
bors[bot]
a0cadcf361 Merge #2071
2071: feat(c-api) Rename the `wasmer` module to `unstable` r=Hywan a=Hywan

# Description

This patch is the first step to prepare more unstable API (like cross-compilation etc.). Nothing changes for the moment from the user perspective, it's not a breaking change. It's just a reorganisation of the code, and better documentation. Basically the `wasmer_c_api::wasm_c_api::wasmer` module has been renamed `unstable`, so that it's super clear :-).

# Review

- [ ] ~Add a short description of the the change to the CHANGELOG.md file~ not necessary


Co-authored-by: Ivan Enderlin <ivan@mnt.io>
2021-01-28 17:54:24 +00:00
Ivan Enderlin
b201f12494 feat(c-api) Start implementing wasm_target_t, wasm_triple_t and wasm_cpu_features_t. 2021-01-28 17:26:15 +01:00
Ivan Enderlin
2f82d5536f feat(c-api) Rename the wasmer module to unstable. 2021-01-28 15:35:51 +01:00
Ivan Enderlin
2df343dc70 test(c-api) Test WASI captured stdout API. 2021-01-28 11:25:42 +01:00
Ivan Enderlin
7f79fcc373 Merge branch 'master' into fix-c-api-wasi-read-captured-stream 2021-01-28 10:45:16 +01:00
Ivan Enderlin
ef1328e1d7 fix(c-api) Don't drain the entire captured stream when reading a small range.
We use `VecDeque::drain` to read the captured stream, zipped with the
given buffer. We could expect that only the yielded items from the
`drain` will be removed, but actually no. Reading [the
documentation](https://doc.rust-lang.org/std/collections/struct.VecDeque.html#method.drain):

> Note 1: The element `range` is removed even if the iterator is not
> consumed until the end.

So by using a range like `..` will drain the entire captured stream,
whatever we read from it. Said differently, if the given buffer length
is smaller than the captured stream, the first read will drain the
entire captured stream.

This patch fixes the problem by specifying a better range:
`..min(inner_buffer.len(), oc.buffer.len())`.

With this new range, it's actually useless to increment
`num_bytes_written`, we already know ahead of time the amount of bytes
we are going to read. Consequently, the patch simplifies this code a
little bit more.
2021-01-28 10:28:49 +01:00
Ivan Enderlin
ca7fc908b5 chore(c-api) Update headers. 2021-01-28 09:23:56 +01:00
Ivan Enderlin
1828d8ecff Merge branch 'master' into fix-c-api-wasi-version 2021-01-28 09:18:30 +01:00
Ivan Enderlin
af5052598a chore(c-api) Update headers. 2021-01-28 09:15:25 +01:00
Ivan Enderlin
7a435ef740 feat(c-api) wasi_version_t has a C representation now.
On Windows, using a `u32` representation for `wasi_version_t` fails if
a C++ compiler is used to treat a C program. So we change our strategy
here. We use a C representation to be FFI-safe, and the
`INVALID_VERSION` variant is now set to -1 instead of `u32::MAX`.

This patch also adds unit tests for `wasi_get_wasi_version` so that we
are sure of the behavior of this `type` on all platforms.
2021-01-28 09:12:10 +01:00
Ivan Enderlin
c03d61b78a test(c-api) Simplify wat2wasm test cases. 2021-01-28 09:11:50 +01:00
Nick Lewycky
95887af4da Include 'extern "C"' in our C header files when included in a C++ build. 2021-01-27 11:41:31 -08:00
bors[bot]
2d57f31037 Merge #2054
2054: Add `wasm_config_delete` to the Wasm C API r=MarkMcCaskey a=MarkMcCaskey

Fixes 1 missing import reported in #2052 

This function is relatively new to the Wasm C API and its implementation is trivial

Co-authored-by: Mark McCaskey <mark@wasmer.io>
2021-01-26 16:38:47 +00:00
Ivan Enderlin
4688d9b369 chore(c-api) Disable wasi_config_capture_stdin for the moment`. 2021-01-26 16:21:55 +01:00
Ivan Enderlin
79e55927b4 chore(c-api) Update headers. 2021-01-26 14:28:12 +01:00
Ivan Enderlin
70c31068be fix(wasi) Fix the logic behind inherited/captured stdin, stdout and stderr.
First, let's no longer derive from `Default` for `wasi_config_t`. By
default, we want to inherit `stdin`, `stdout` and `stderr`. The
default for `bool` is `false`; we want `true` here.

Second, let's update `wasi_config_new` to correctly set `inherit_*`
fields to `true`.

Third, lets' create `wasi_config_capture_*` functions. By default,
`std*` are inherited, so we need functions to capture them. That's the
new feature this patch introduces. The `wasi_config_inherit_*`
functions are kept for the sake of backward compatibility. Ideally, we
would want an API like `wasi_config_capture_*(capture: bool)`, but it
would duplicate the API somehow.

Fourth, let's fix `wasi_env_new`. We want to capture `stdout` and
`stderr` if and only if the `inherit_*` fields are set to
`false`. There was bug here. That's why everything was working
correctly by the way: `bool::default()` is `false`, and we have this
inverted condition here, so everything was working as expected because
of a double error. The only bug was that it wasn't possible to capture
`std*` before.
2021-01-26 14:12:48 +01:00
Ivan Enderlin
361ea40042 chore(c-api) Update headers. 2021-01-26 13:19:20 +01:00
Ivan Enderlin
af2b8d5923 doc(c-api) Document wasi_version_t. 2021-01-26 13:19:04 +01:00
Ivan Enderlin
434285c0f9 fix(c-api) Use uppercase enum variants for constants of wasi_version_t. 2021-01-26 13:11:44 +01:00
Mark McCaskey
0c13314179 Add wasm_config_delete to the Wasm C API 2021-01-25 07:54:49 -08:00
Ivan Enderlin
70858eb201 feat(c-api) Do not build C headers if the env var DOCS_RS exists. 2021-01-22 14:22:28 +01:00
Syrus Akbary
e8344c56ae Fixed integration examples link 2021-01-20 14:48:13 -08:00
Mark McCaskey
924ffd8797 Prepare for 1.0.1 release 2021-01-12 08:08:19 -08:00
Mark McCaskey
bc73789cc0 Prepare for 1.0.0 release 2021-01-05 06:21:03 -08:00
Simon Warta
010f5fb597 Fix spelling Web Assembly -> WebAssembly 2021-01-03 22:01:26 +01:00
Simon Warta
82e9c0c18f Fix spelling WASM -> Wasm 2021-01-03 21:59:11 +01:00
Mark McCaskey
2d1c03bea0 Prepare for 1.0.0-rc1 release 2020-12-23 11:17:07 -08:00
Mark McCaskey
8724ed963d Merge branch 'master' into feature/multi-example-wasm-c-api 2020-12-21 07:51:28 -08:00
Mark McCaskey
89132dde61 Add _ back to unused variable 2020-12-18 14:52:52 -08:00
Mark McCaskey
9bc43c4d83 Revert wasmer_wasm.h to be correct 2020-12-18 14:41:52 -08:00
Mark McCaskey
800c6685e6 Ensure we print what the offending files are 2020-12-18 14:36:21 -08:00
Mark McCaskey
de0d78204b Merge branch 'master' into feature/assert-no-files-change-in-lint 2020-12-18 13:53:44 -08:00
Mark McCaskey
918554dd4c Assert that no files changed during lint 2020-12-18 12:56:35 -08:00
Mark McCaskey
cdf9825d62 Merge branch 'master' into feature/multi-example-wasm-c-api 2020-12-18 12:42:45 -08:00
Mark McCaskey
8025f8c1fa Make jit a default feature for wasmer-wasm-c-api 2020-12-18 09:51:15 -08:00
Ivan Enderlin
b9afb6e956 fix(c-api) Remove Box from wasm_functype_new. 2020-12-18 17:35:21 +01:00
Mark McCaskey
d44116251f Remove debug code from multi.c 2020-12-18 07:13:38 -08:00
Ivan Enderlin
2ca30fe634 fix(c-api) Ensure that uninitialized boxed vec are zeroed.
This patch updates how `wasm_$name_vec_new_uninitialized` creates the
vector. The vector is now fully allocated with `null` pointer for each
item, instead of having an empty vector with the initial capacity set
to `length`. That way, we are sure the vector is zeroed correctly.
2020-12-18 11:47:04 +01:00
Ivan Enderlin
40fa9c08c7 fix(c-api) UPdate wasm_functype_new according to previous commit. 2020-12-18 11:42:34 +01:00
Ivan Enderlin
a68a1e67f4 feat(c-api) Transmute boxed vecs to Vec<Option<Box<T>>> when deleting.
It's a safer way to handle partially uninitialized boxed vector, since
it protects against based deletion for every item.
2020-12-18 11:40:32 +01:00