12 Commits

Author SHA1 Message Date
Alex Crichton 8f03b22e07 Remove wasm-c-api submodule (#8170)
* Remove wasm-c-api submodule

This submodule hasn't been updated in ~3 years at this point and we
additionally don't need most of the submodule. Instead add a script to
copy the files we need and verify in CI that the files are up-to-date.

This also makes using the C API a bit nicer where you don't have to have
two `include` directories with a Wasmtime source tree, just one
suffices.

* Don't format wasm.h{,h} vendored files
2024-03-18 18:58:11 +00:00
Tyler Rockwood f8fee9385d add clang format (#7601)
* add clang-format

We chose WebKit style because out of all the builtin styles it seems the
closest to what already exists in wasmtime.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* c-api: don't reorder headers

The order here matters

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* c-api: apply clang-format

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* fiber: apply clang-format

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* runtime: apply clang-format

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* examples: apply clang format

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* tests: apply clang-format

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* ci: add clang-format checks

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* clang-format: keep braces on the same line

This is more the existing style

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* remove clang-format

Just use the tool defaults (LLVM)

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* Fix ci name

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* manually reformat a couple of comments

prtest:full

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* disable formatting for doc-wasm.h

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* manually reformat wasmtime.h

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* disable formatting

To prevent a link from being broken

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* examples: fixing build commands

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* fix parameter comment

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

---------

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
2023-11-29 18:39:04 +00:00
TheGreatRambler 2ba3025e67 Add cmake compatibility to c-api (#4369)
* Add cmake compatibility to c-api

* Add CMake documentation to wasmtime.h

* Add CMake instructions in examples

* Modify CI for CMake support

* Use correct rust in CI

* Trigger build

* Refactor run-examples

* Reintroduce example_to_run in run-examples

* Replace run-examples crate with cmake

* Fix markdown formatting in examples readme

* Fix cmake test quotes

* Build rust wasm before cmake tests

* Pass CTEST_OUTPUT_ON_FAILURE

* Another cmake test

* Handle os differences in cmake test

* Fix bugs in memory and multimemory examples
2022-07-22 10:22:36 -07:00
Alex Crichton 7a1b7cdf92 Implement RFC 11: Redesigning Wasmtime's APIs (#2897)
Implement Wasmtime's new API as designed by RFC 11. This is quite a large commit which has had lots of discussion externally, so for more information it's best to read the RFC thread and the PR thread.
2021-06-03 09:10:53 -05:00
Peter Huene f94db6556c Update WebAssembly C API submodule to latest commit. (#2579)
* Update WebAssembly C API submodule to latest commit.

This commit updates the WebAssembly C API submodule (for `wasm.h`) to the
latest commit out of master.

This fixes the behavior of `wasm_name_new_from_string` such that it no longer
copies the null character into the name, which caused unexpected failures when
using the Wasmtime linker as imports wouldn't resolve when the null was
present.

Along with this change were breaking changes to `wasm_func_call`, the host
callback signatures, and `wasm_instance_new` to take a vector type instead of a
pointer to an unsized array.

As a result, Wasmtime language bindings based on the C API will need to be
updated once this change is pulled in.

Fixes #2211.
Fixes #2131.

* Update Doxygen comments for wasm.h changes.
2021-01-14 09:36:12 -06:00
Joshua Warner eb650f6fe0 filesystem example (#2236) 2020-09-29 13:20:14 -05:00
Yury Delendik a817470fab Fix signature of wasmtime_module_new 2020-07-15 14:07:36 -05:00
Alex Crichton cca558cd20 Remove HostRef<T> from the C API (#1926)
This commit removes `HostRef<T>` from the C API which only served the
purpose now of converting each type to a `wasm_ref_t*`. Our
implementation, however, does not guarantee that you'll get the same
`wasm_ref_t*` for each actual underlying item (e.g. if you put a func in
a table and then get the func as an export and from the table then
`same` will report `false`). Additionally the fate of `wasm_ref_t*`
seems somewhat unclear at this point.

The change here is to make the `same` and cast functions all abort
saying they're unimplemented. (similar to the host info functions). If
and when we get around to reimplementing these functions we can ensure
they're implemented uniformly and work well for all intended use cases.
2020-06-26 14:34:34 -05:00
Yury Delendik 15c68f2cc1 Disconnects Store state fields from Compiler (#1761)
*  Moves CodeMemory, VMInterrupts and SignatureRegistry from Compiler
*  CompiledModule holds CodeMemory and GdbJitImageRegistration
*  Store keeps track of its JIT code
*  Makes "jit_int.rs" stuff Send+Sync
*  Adds the threads example.
2020-06-02 13:44:39 -05:00
Alex Crichton bd374fd6fc Add Wasmtime-specific C API functions to return errors (#1467)
* Add Wasmtime-specific C API functions to return errors

This commit adds new `wasmtime_*` symbols to the C API, many of which
mirror the existing counterparts in the `wasm.h` header. These APIs are
enhanced in a number of respects:

* Detailed error information is now available through a
  `wasmtime_error_t`. Currently this only exposes one function which is
  to extract a string version of the error.

* There is a distinction now between traps and errors during
  instantiation and function calling. Traps only happen if wasm traps,
  and errors can happen for things like runtime type errors when
  interacting with the API.

* APIs have improved safety with respect to embedders where the lengths
  of arrays are now taken as explicit parameters rather than assumed
  from other parameters.

* Handle trap updates

* Update C examples

* Fix memory.c compile on MSVC

* Update test assertions

* Refactor C slightly

* Bare-bones .NET update

* Remove bogus nul handling
2020-04-06 15:13:06 -05:00
Peter Huene f40693d9e8 Fix calls to wasmtime_wat2wasm to remove engine argument. 2020-03-25 18:55:54 -07:00
Alex Crichton 3c51d3adb8 Move all examples to a top-level directory (#1286)
* Move all examples to a top-level directory

This commit moves all API examples (Rust and C) to a top-level
`examples` directory. This is intended to make it more discoverable and
conventional as to where examples are located. Additionally all examples
are now available in both Rust and C to see how to execute the example
in the language you're familiar with. The intention is that as more
languages are supported we'd add more languages as examples here too.

Each example is also accompanied by either a `*.wat` file which is
parsed as input, or a Rust project in a `wasm` folder which is compiled
as input.

A simple driver crate was also added to `crates/misc` which executes all
the examples on CI, ensuring the C and Rust examples all execute
successfully.
2020-03-11 15:37:24 -05:00