You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

254 lines
9.9 KiB

/**
* \mainpage Wasmtime C API
*
* This documentation is an overview and API reference for the C API of
* Wasmtime. The C API is spread between three different header files:
*
* * \ref wasmtime.h
* * \ref wasi.h
* * \ref wasm.h
*
* The \ref wasmtime.h header file includes all the other header files and is
* the main header file you'll likely be using. The \ref wasm.h header file
* comes directly from the
* [WebAssembly/wasm-c-api](https://github.com/WebAssembly/wasm-c-api)
* repository, and at this time the upstream header file does not have
* documentation so Wasmtime provides documentation here. It should be noted
* some semantics may be Wasmtime-specific and may not be portable to other
* engines.
*
* ## Installing the C API
*
* To install the C API from precompiled binaries you can download the
* appropriate binary from the [releases page of
* Wasmtime](https://github.com/bytecodealliance/wasmtime/releases). Artifacts
* for the C API all end in "-c-api" for the filename.
*
* Each archive contains an `include` directory with necessary headers, as well
* as a `lib` directory with both a static archive and a dynamic library of
* Wasmtime. You can link to either of them as you see fit.
*
* ## Installing the C API through CMake
*
* CMake can be used to make the process of linking and compiling easier. An
* example of this if you have wasmtime as a git submodule at
* `third_party/wasmtime`:
* ```
* add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/wasmtime/crates/c-api
* ${CMAKE_CURRENT_BINARY_DIR}/wasmtime)
* ...
* target_include_directories(YourProject PUBLIC wasmtime)
* target_link_libraries(YourProject PUBLIC wasmtime)
* ```
* `BUILD_SHARED_LIBS` is provided as a define if you would like to build a
* shared library instead. You must distribute the appropriate shared library
* for your platform if you do this.
*
* ## Linking against the C API
*
* You'll want to arrange the `include` directory of the C API to be in your
* compiler's header path (e.g. the `-I` flag). If you're compiling for Windows
* and you're using the static library then you'll also need to pass
* `-DWASM_API_EXTERN=` and `-DWASI_API_EXTERN=` to disable dllimport.
*
* Your final artifact can then be linked with `-lwasmtime`. If you're linking
* against the static library you may need to pass other system libraries
* depending on your platform:
*
* * Linux - `-lpthread -ldl -lm`
* * macOS - no extra flags needed
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>
11 months ago
* * Windows - `ws2_32.lib advapi32.lib userenv.lib ntdll.lib shell32.lib
* ole32.lib bcrypt.lib`
*
* ## Building from Source
*
* The C API is located in the
* [`crates/c-api`](https://github.com/bytecodealliance/wasmtime/tree/main/crates/c-api)
* directory of the [Wasmtime
* repository](https://github.com/bytecodealliance/wasmtime). To build from
* source you'll need a Rust compiler and a checkout of the `wasmtime` project.
* Afterwards you can execute:
*
* ```
* $ cargo build --release -p wasmtime-c-api
* ```
*
* This will place the final artifacts in `target/release`, with names depending
* on what platform you're compiling for.
*
* ## Other resources
*
* Some other handy resources you might find useful when exploring the C API
* documentation are:
*
* * [Rust `wasmtime` crate
* documentation](https://bytecodealliance.github.io/wasmtime/api/wasmtime/) -
* although this documentation is for Rust and not C, you'll find that many
* functions mirror one another and there may be extra documentation in Rust
* you find helpful. If you find yourself having to frequently do this,
* though, please feel free to [file an
* issue](https://github.com/bytecodealliance/wasmtime/issues/new).
*
* * [C embedding
* examples](https://bytecodealliance.github.io/wasmtime/lang-c.html)
* are available online and are tested from the Wasmtime repository itself.
*
* * [Contribution documentation for
* Wasmtime](https://bytecodealliance.github.io/wasmtime/contributing.html) in
* case you're interested in helping out!
*/
/**
* \file wasmtime.h
*
* \brief Wasmtime's C API
*
* This file is the central inclusion point for Wasmtime's C API. There are a
* number of sub-header files but this file includes them all. The C API is
* based on \ref wasm.h but there are many Wasmtime-specific APIs which are
* tailored to Wasmtime's implementation.
*
* The #wasm_config_t and #wasm_engine_t types are used from \ref wasm.h.
* Additionally all type-level information (like #wasm_functype_t) is also
* used from \ref wasm.h. Otherwise, though, all wasm objects (like
* #wasmtime_store_t or #wasmtime_func_t) are used from this header file.
*
* ### Thread Safety
*
* The multithreading story of the C API very closely follows the
* multithreading story of the Rust API for Wasmtime. All objects are safe to
* send to other threads so long as user-specific data is also safe to send to
* other threads. Functions are safe to call from any thread but some functions
* cannot be called concurrently. For example, functions which correspond to
* `&T` in Rust can be called concurrently with any other methods that take
* `&T`. Functions that take `&mut T` in Rust, however, cannot be called
* concurrently with any other function (but can still be invoked on any
* thread).
*
* This generally equates to mutation of internal state. Functions which don't
* mutate anything, such as learning type information through
* #wasmtime_func_type, can be called concurrently. Functions which do require
* mutation, for example #wasmtime_func_call, cannot be called concurrently.
* This is conveyed in the C API with either `const wasmtime_context_t*`
* (concurrency is ok as it's read-only) or `wasmtime_context_t*` (concurrency
* is not ok, mutation may happen).
*
* When in doubt assume that functions cannot be called concurrently with
* aliasing objects.
*
* ### Aliasing
*
* The C API for Wasmtime is intended to be a relatively thin layer over the
* Rust API for Wasmtime. Rust has much more strict rules about aliasing than C
* does, and the Rust API for Wasmtime is designed around these rules to be
* used safely. These same rules must be upheld when using the C API of
* Wasmtime.
*
* The main consequence of this is that the #wasmtime_context_t pointer into
* the #wasmtime_store_t must be carefully used. Since the context is an
* internal pointer into the store it must be used carefully to ensure you're
* not doing something that Rust would otherwise forbid at compile time. A
* #wasmtime_context_t can only be used when you would otherwise have been
* provided access to it. For example in a host function created with
* #wasmtime_func_new you can use #wasmtime_context_t in the host function
* callback. This is because an argument, a #wasmtime_caller_t, provides access
Define garbage collection rooting APIs (#8011) * Define garbage collection rooting APIs Rooting prevents GC objects from being collected while they are actively being used. We have a few sometimes-conflicting goals with our GC rooting APIs: 1. Safety: It should never be possible to get a use-after-free bug because the user misused the rooting APIs, the collector "mistakenly" determined an object was unreachable and collected it, and then the user tried to access the object. This is our highest priority. 2. Moving GC: Our rooting APIs should moving collectors (such as generational and compacting collectors) where an object might get relocated after a collection and we need to update the GC root's pointer to the moved object. This means we either need cooperation and internal mutability from individual GC roots as well as the ability to enumerate all GC roots on the native Rust stack, or we need a level of indirection. 3. Performance: Our rooting APIs should generally be as low-overhead as possible. They definitely shouldn't require synchronization and locking to create, access, and drop GC roots. 4. Ergonomics: Our rooting APIs should be, if not a pleasure, then at least not a burden for users. Additionally, the API's types should be `Sync` and `Send` so that they work well with async Rust. For example, goals (3) and (4) are in conflict when we think about how to support (2). Ideally, for ergonomics, a root would automatically unroot itself when dropped. But in the general case that requires holding a reference to the store's root set, and that root set needs to be held simultaneously by all GC roots, and they each need to mutate the set to unroot themselves. That implies `Rc<RefCell<...>>` or `Arc<Mutex<...>>`! The former makes the store and GC root types not `Send` and not `Sync`. The latter imposes synchronization and locking overhead. So we instead make GC roots indirect and require passing in a store context explicitly to unroot in the general case. This trades worse ergonomics for better performance and support for moving GC and async Rust. Okay, with that out of the way, this module provides two flavors of rooting API. One for the common, scoped lifetime case, and another for the rare case where we really need a GC root with an arbitrary, non-LIFO/non-scoped lifetime: 1. `RootScope` and `Rooted<T>`: These are used for temporarily rooting GC objects for the duration of a scope. Upon exiting the scope, they are automatically unrooted. The internal implementation takes advantage of the LIFO property inherent in scopes, making creating and dropping `Rooted<T>`s and `RootScope`s super fast and roughly equivalent to bump allocation. This type is vaguely similar to V8's [`HandleScope`]. [`HandleScope`]: https://v8.github.io/api/head/classv8_1_1HandleScope.html Note that `Rooted<T>` can't be statically tied to its context scope via a lifetime parameter, unfortunately, as that would allow the creation and use of only one `Rooted<T>` at a time, since the `Rooted<T>` would take a borrow of the whole context. This supports the common use case for rooting and provides good ergonomics. 2. `ManuallyRooted<T>`: This is the fully general rooting API used for holding onto non-LIFO GC roots with arbitrary lifetimes. However, users must manually unroot them. Failure to manually unroot a `ManuallyRooted<T>` before it is dropped will result in the GC object (and everything it transitively references) leaking for the duration of the `Store`'s lifetime. This type is roughly similar to SpiderMonkey's [`PersistentRooted<T>`], although they avoid the manual-unrooting with internal mutation and shared references. (Our constraints mean we can't do those things, as mentioned explained above.) [`PersistentRooted<T>`]: http://devdoc.net/web/developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS::PersistentRooted.html At the end of the day, both `Rooted<T>` and `ManuallyRooted<T>` are just tagged indices into the store's `RootSet`. This indirection allows working with Rust's borrowing discipline (we use `&mut Store` to represent mutable access to the GC heap) while still allowing rooted references to be moved around without tying up the whole store in borrows. Additionally, and crucially, this indirection allows us to update the *actual* GC pointers in the `RootSet` and support moving GCs (again, as mentioned above). * Reorganize GC-related submodules in `wasmtime-runtime` * Reorganize GC-related submodules in `wasmtime` * Use `Into<StoreContext[Mut]<'a, T>` for `Externref::data[_mut]` methods * Run rooting tests under MIRI * Make `into_abi` take an `AutoAssertNoGc` * Don't use atomics to update externref ref counts anymore * Try to make lifetimes/safety more-obviously correct Remove some transmute methods, assert that `VMExternRef`s are the only valid `VMGcRef`, etc. * Update extenref constructor examples * Make `GcRefImpl::transmute_ref` a non-default trait method * Make inline fast paths for GC LIFO scopes * Make `RootSet::unroot_gc_ref` an `unsafe` function * Move Hash and Eq for Rooted, move to impl methods * Remove type parameter from `AutoAssertNoGc` Just wrap a `&mut StoreOpaque` directly. * Make a bunch of internal `ExternRef` methods that deal with raw `VMGcRef`s take `AutoAssertNoGc` instead of `StoreOpaque` * Fix compile after rebase * rustfmt * revert unrelated egraph changes * Fix non-gc build * Mark `AutoAssertNoGc` methods inline * review feedback * Temporarily remove externref support from the C API Until we can add proper GC rooting. * Remove doxygen reference to temp deleted function * Remove need to `allow(private_interfaces)` * Fix call benchmark compilation
8 months ago
* to #wasmtime_context_t.
*
* ### Stores
*
* A foundational construct in this API is the #wasmtime_store_t. A store is a
* collection of host-provided objects and instantiated wasm modules. Stores are
* often treated as a "single unit" and items within a store are all allowed to
* reference one another. References across stores cannot currently be created.
* For example you cannot pass a function from one store into another store.
*
* A store is not intended to be a global long-lived object. Stores provide no
* means of internal garbage collections of wasm objects (such as instances),
* meaning that no memory from a store will be deallocated until you call
* #wasmtime_store_delete. If you're working with a web server, for example,
* then it's recommended to think of a store as a "one per request" sort of
* construct. Globally you'd have one #wasm_engine_t and a cache of
* #wasmtime_module_t instances compiled into that engine. Each request would
* create a new #wasmtime_store_t and then instantiate a #wasmtime_module_t
* into the store. This process of creating a store and instantiating a module
* is expected to be quite fast. When the request is finished you'd delete the
* #wasmtime_store_t keeping memory usage reasonable for the lifetime of the
* server.
*/
#ifndef WASMTIME_API_H
#define WASMTIME_API_H
#include <wasi.h>
Refactor installation of C API and features supported (#8642) * Refactor installation of C API and features supported This commit overhauls and refactors the management of the building of the C API. Instead of this being script-based it&#39;s now done entirely through CMake and CMake is the primary focus for building the C API. For example building the C API release artifacts is now done through CMake instead of through a shell script&#39;s `cargo build` and manually moving artifacts. The benefits that this brings are: * The C API now properly hides symbols in its header files that weren&#39;t enabled at build time. This is done through a new build-time generated `conf.h` templated on a `conf.h.in` file in the source tree. * The C API&#39;s project now supports enabling/disabling Cargo features to have finer-grained support over what&#39;s included (plus auto-management of the header file). * Building the C API and managing it is now exclusively done through CMake. For example invoking `doxygen` now lives in CMake, installation lives there, etc. The `CMakeLists.txt` file for the C API is overhauled in the process of doing this. The build now primarily matches on the Rust target being built rather than the host target. Additionally installation will now install both the static and shared libraries instead of just one. Additionally during this refactoring various bits and pieces of Android-specific code were all removed. Management of the C toolchain feels best left in scope of the caller (e.g. configuring `CC_*` env vars and such) rather than here. prtest:full * Don&#39;t use `option` for optional strings * Invert release build check Also adjust some indentation * Fix more indentation * Remove no-longer-used variable * Reduce duplication in feature macro
6 months ago
#include <wasmtime/conf.h>
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 &lt;rockwood@redpanda.com&gt; * c-api: don&#39;t reorder headers The order here matters Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * fiber: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * runtime: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * examples: apply clang format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * tests: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * ci: add clang-format checks Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * clang-format: keep braces on the same line This is more the existing style Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * remove clang-format Just use the tool defaults (LLVM) Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * Fix ci name Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * manually reformat a couple of comments prtest:full Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * disable formatting for doc-wasm.h Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * manually reformat wasmtime.h Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * disable formatting To prevent a link from being broken Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * examples: fixing build commands Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * fix parameter comment Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; --------- Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt;
11 months ago
// clang-format off
// IWYU pragma: begin_exports
#include <wasmtime/config.h>
Delete historical interruptable support in Wasmtime (#3925) * Delete historical interruptable support in Wasmtime This commit removes the `Config::interruptable` configuration along with the `InterruptHandle` type from the `wasmtime` crate. The original support for adding interruption to WebAssembly was added pretty early on in the history of Wasmtime when there was no other method to prevent an infinite loop from the host. Nowadays, however, there are alternative methods for interruption such as fuel or epoch-based interruption. One of the major downsides of `Config::interruptable` is that even when it&#39;s not enabled it forces an atomic swap to happen when entering WebAssembly code. This technically could be a non-atomic swap if the configuration option isn&#39;t enabled but that produces even more branch-y code on entry into WebAssembly which is already something we try to optimize. Calling into WebAssembly is on the order of a dozens of nanoseconds at this time and an atomic swap, even uncontended, can add up to 5ns on some platforms. The main goal of this PR is to remove this atomic swap on entry into WebAssembly. This is done by removing the `Config::interruptable` field entirely, moving all existing consumers to epochs instead which are suitable for the same purposes. This means that the stack overflow check is no longer entangled with the interruption check and perhaps one day we could continue to optimize that further as well. Some consequences of this change are: * Epochs are now the only method of remote-thread interruption. * There are no more Wasmtime traps that produces the `Interrupted` trap code, although we may wish to move future traps to this so I left it in place. * The C API support for interrupt handles was also removed and bindings for epoch methods were added. * Function-entry checks for interruption are a tiny bit less efficient since one check is performed for the stack limit and a second is performed for the epoch as opposed to the `Config::interruptable` style of bundling the stack limit and the interrupt check in one. It&#39;s expected though that this is likely to not really be measurable. * The old `VMInterrupts` structure is renamed to `VMRuntimeLimits`.
3 years ago
#include <wasmtime/engine.h>
#include <wasmtime/error.h>
#include <wasmtime/extern.h>
#include <wasmtime/func.h>
#include <wasmtime/global.h>
#include <wasmtime/instance.h>
#include <wasmtime/linker.h>
#include <wasmtime/memory.h>
#include <wasmtime/module.h>
#include <wasmtime/profiling.h>
#include <wasmtime/sharedmemory.h>
#include <wasmtime/store.h>
#include <wasmtime/table.h>
#include <wasmtime/trap.h>
#include <wasmtime/val.h>
Async support in the C API (#7106) * c-api: Add a feature for async Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Add support for async config Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Add support for calling async functions Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Add ability to yield execution of Wasm in a store Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Introduce wasmtime_linker_instantiate_async Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Support defining async host functions Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * gitignore: ignore cmake cache for examples Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * examples: Add example of async API in C Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Consolidate async functionality into a single place Put all the async stuff in it&#39;s own header and own rust source file Also remove the wasmtime_async_continuation_new function, users can just allocate it directly. Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Make async function safe Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Remove wasmtime_call_future_get_results Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Simplify CHostCallFuture Move the result translation and hostcall_val_storage usage into an async function Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Simplify C continuation implementation Remove the caller, which means that we don&#39;t need another struct for the future implementation. Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Improve async.h documentation Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Cleanup from previous changes Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * examples: Fix example Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Simplify continuation callback This gives more duality with calling an async function and also means that the implementation can pretty much mirror the sync version. Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Fix async.h documentation Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Fix documentation for async.h Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: Review feedback Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * examples: Downgrade async.cpp example to C++11 Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: initialize continuation with a panic callback Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * prtest:full Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; --------- Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt;
1 year ago
#include <wasmtime/async.h>
// IWYU pragma: end_exports
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 &lt;rockwood@redpanda.com&gt; * c-api: don&#39;t reorder headers The order here matters Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * fiber: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * runtime: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * examples: apply clang format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * tests: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * ci: add clang-format checks Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * clang-format: keep braces on the same line This is more the existing style Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * remove clang-format Just use the tool defaults (LLVM) Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * Fix ci name Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * manually reformat a couple of comments prtest:full Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * disable formatting for doc-wasm.h Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * manually reformat wasmtime.h Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * disable formatting To prevent a link from being broken Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * examples: fixing build commands Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * fix parameter comment Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; --------- Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt;
11 months ago
// clang-format on
/**
* \brief Wasmtime version string.
*/
#define WASMTIME_VERSION "25.0.0"
/**
* \brief Wasmtime major version number.
*/
#define WASMTIME_VERSION_MAJOR 25
/**
* \brief Wasmtime minor version number.
*/
#define WASMTIME_VERSION_MINOR 0
/**
* \brief Wasmtime patch version number.
*/
#define WASMTIME_VERSION_PATCH 0
#ifdef __cplusplus
extern "C" {
#endif
Refactor installation of C API and features supported (#8642) * Refactor installation of C API and features supported This commit overhauls and refactors the management of the building of the C API. Instead of this being script-based it&#39;s now done entirely through CMake and CMake is the primary focus for building the C API. For example building the C API release artifacts is now done through CMake instead of through a shell script&#39;s `cargo build` and manually moving artifacts. The benefits that this brings are: * The C API now properly hides symbols in its header files that weren&#39;t enabled at build time. This is done through a new build-time generated `conf.h` templated on a `conf.h.in` file in the source tree. * The C API&#39;s project now supports enabling/disabling Cargo features to have finer-grained support over what&#39;s included (plus auto-management of the header file). * Building the C API and managing it is now exclusively done through CMake. For example invoking `doxygen` now lives in CMake, installation lives there, etc. The `CMakeLists.txt` file for the C API is overhauled in the process of doing this. The build now primarily matches on the Rust target being built rather than the host target. Additionally installation will now install both the static and shared libraries instead of just one. Additionally during this refactoring various bits and pieces of Android-specific code were all removed. Management of the C toolchain feels best left in scope of the caller (e.g. configuring `CC_*` env vars and such) rather than here. prtest:full * Don&#39;t use `option` for optional strings * Invert release build check Also adjust some indentation * Fix more indentation * Remove no-longer-used variable * Reduce duplication in feature macro
6 months ago
#ifdef WASMTIME_FEATURE_WAT
/**
* \brief Converts from the text format of WebAssembly to the binary format.
*
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 &lt;rockwood@redpanda.com&gt; * c-api: don&#39;t reorder headers The order here matters Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * fiber: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * runtime: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * examples: apply clang format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * tests: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * ci: add clang-format checks Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * clang-format: keep braces on the same line This is more the existing style Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * remove clang-format Just use the tool defaults (LLVM) Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * Fix ci name Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * manually reformat a couple of comments prtest:full Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * disable formatting for doc-wasm.h Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * manually reformat wasmtime.h Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * disable formatting To prevent a link from being broken Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * examples: fixing build commands Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * fix parameter comment Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; --------- Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt;
11 months ago
* \param wat this it the input pointer with the WebAssembly Text Format inside
* of it. This will be parsed and converted to the binary format.
* \param wat_len this it the length of `wat`, in bytes.
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 &lt;rockwood@redpanda.com&gt; * c-api: don&#39;t reorder headers The order here matters Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * fiber: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * runtime: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * examples: apply clang format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * tests: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * ci: add clang-format checks Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * clang-format: keep braces on the same line This is more the existing style Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * remove clang-format Just use the tool defaults (LLVM) Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * Fix ci name Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * manually reformat a couple of comments prtest:full Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * disable formatting for doc-wasm.h Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * manually reformat wasmtime.h Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * disable formatting To prevent a link from being broken Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * examples: fixing build commands Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * fix parameter comment Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; --------- Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt;
11 months ago
* \param ret if the conversion is successful, this byte vector is filled in
* with the WebAssembly binary format.
*
* \return a non-null error if parsing fails, or returns `NULL`. If parsing
* fails then `ret` isn't touched.
*
* This function does not take ownership of `wat`, and the caller is expected to
* deallocate the returned #wasmtime_error_t and #wasm_byte_vec_t.
*/
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 &lt;rockwood@redpanda.com&gt; * c-api: don&#39;t reorder headers The order here matters Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * fiber: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * runtime: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * examples: apply clang format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * tests: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * ci: add clang-format checks Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * clang-format: keep braces on the same line This is more the existing style Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * remove clang-format Just use the tool defaults (LLVM) Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * Fix ci name Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * manually reformat a couple of comments prtest:full Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * disable formatting for doc-wasm.h Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * manually reformat wasmtime.h Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * disable formatting To prevent a link from being broken Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * examples: fixing build commands Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * fix parameter comment Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; --------- Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt;
11 months ago
WASM_API_EXTERN wasmtime_error_t *
wasmtime_wat2wasm(const char *wat, size_t wat_len, wasm_byte_vec_t *ret);
Refactor installation of C API and features supported (#8642) * Refactor installation of C API and features supported This commit overhauls and refactors the management of the building of the C API. Instead of this being script-based it&#39;s now done entirely through CMake and CMake is the primary focus for building the C API. For example building the C API release artifacts is now done through CMake instead of through a shell script&#39;s `cargo build` and manually moving artifacts. The benefits that this brings are: * The C API now properly hides symbols in its header files that weren&#39;t enabled at build time. This is done through a new build-time generated `conf.h` templated on a `conf.h.in` file in the source tree. * The C API&#39;s project now supports enabling/disabling Cargo features to have finer-grained support over what&#39;s included (plus auto-management of the header file). * Building the C API and managing it is now exclusively done through CMake. For example invoking `doxygen` now lives in CMake, installation lives there, etc. The `CMakeLists.txt` file for the C API is overhauled in the process of doing this. The build now primarily matches on the Rust target being built rather than the host target. Additionally installation will now install both the static and shared libraries instead of just one. Additionally during this refactoring various bits and pieces of Android-specific code were all removed. Management of the C toolchain feels best left in scope of the caller (e.g. configuring `CC_*` env vars and such) rather than here. prtest:full * Don&#39;t use `option` for optional strings * Invert release build check Also adjust some indentation * Fix more indentation * Remove no-longer-used variable * Reduce duplication in feature macro
6 months ago
#endif
#ifdef __cplusplus
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 &lt;rockwood@redpanda.com&gt; * c-api: don&#39;t reorder headers The order here matters Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * c-api: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * fiber: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * runtime: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * examples: apply clang format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * tests: apply clang-format Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * ci: add clang-format checks Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * clang-format: keep braces on the same line This is more the existing style Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * remove clang-format Just use the tool defaults (LLVM) Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * Fix ci name Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * manually reformat a couple of comments prtest:full Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * disable formatting for doc-wasm.h Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * manually reformat wasmtime.h Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * disable formatting To prevent a link from being broken Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * examples: fixing build commands Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; * fix parameter comment Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt; --------- Signed-off-by: Tyler Rockwood &lt;rockwood@redpanda.com&gt;
11 months ago
} // extern "C"
#endif
#endif // WASMTIME_API_H