Repository navigation
Conversation
| // SAFETY: guaranteed by the caller. | ||
| let name = try_c!(unsafe { str(name, name_len) }); | ||
| // SAFETY: guaranteed by the caller. | ||
| let State::Proto(proto) = &mut unsafe { &mut *sandbox }.state else { |
| // SAFETY: guaranteed by the caller. | ||
| let path = try_c!(unsafe { str(path, len) }); | ||
| // SAFETY: guaranteed by the caller. | ||
| load(unsafe { &mut *sandbox }, |s| s.load_module(path)) |
| // SAFETY: guaranteed by the caller. | ||
| let data = unsafe { slice(data, len) }; | ||
| // SAFETY: guaranteed by the caller. | ||
| load(unsafe { &mut *sandbox }, |s| { |
| .map(|a| unsafe { slice(a.data, a.len) }.to_vec()) | ||
| .collect(); | ||
| // SAFETY: guaranteed by the caller. | ||
| let sandbox = unsafe { &mut *sandbox }; |
| out: *mut *mut hlw_snapshot, | ||
| ) -> *mut hlw_error { | ||
| // SAFETY: guaranteed by the caller. | ||
| let loaded = try_c!(loaded(unsafe { &mut *sandbox })); |
| snapshot: *const hlw_snapshot, | ||
| ) -> *mut hlw_error { | ||
| // SAFETY: guaranteed by the caller. | ||
| let loaded = try_c!(loaded(unsafe { &mut *sandbox })); |
| // SAFETY: guaranteed by the caller. | ||
| let loaded = try_c!(loaded(unsafe { &mut *sandbox })); | ||
| // SAFETY: guaranteed by the caller. | ||
| let snapshot = unsafe { &*snapshot }.snapshot.clone(); |
| out: *mut *mut hlw_interrupt_handle, | ||
| ) -> *mut hlw_error { | ||
| // SAFETY: guaranteed by the caller. | ||
| let loaded = try_c!(loaded(unsafe { &mut *sandbox })); |
| #[unsafe(no_mangle)] | ||
| pub unsafe extern "C" fn hlw_interrupt_handle_kill(handle: *const hlw_interrupt_handle) -> bool { | ||
| // SAFETY: guaranteed by the caller. | ||
| unsafe { &*handle }.handle.kill() |
ludfjig
force-pushed
the
hyperlight-0.18-capi
branch
2 times, most recently
from
October 30, 2026 20:01
5783d57 to
bda3ce3
Compare
Build against the hyperlight branch with the component wire format, which names component functions <instance>#<function> and encodes numbers little-endian. Hosts and guests built with earlier versions cannot call each other. Wasm traps go through the undefined instruction hook, which turns a trap into a guest call error instead of a general protection fault. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
SandboxBuilder::with_runtime_file loads the guest runtime from a file instead of the one built into the crate. A host built once can then run components of any world whose runtime was built separately. SandboxBuilder::with_interrupt_vcpu_sigrtmin_offset changes the signal that interrupts a running guest on Linux. Hosts such as .NET use SIGRTMIN themselves. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Add hyperlight-wasm-capi, a C library declared in include/hyperlight_wasm.h. It registers host functions, loads components, calls guest functions, and snapshots, restores and interrupts sandboxes. Arguments and results are byte buffers in hyperlight's component wire format, so the library needs no knowledge of a component's WIT. Host functions take up to 32 parameters. A panic in a guest call becomes an error and leaves the sandbox unusable. just examples-components runs its tests against the component_sample example world. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Hyperlight.Wasm runs components from .NET through the C API. WasmSandbox registers host functions, loads components and calls them, with snapshots, interrupts and CancellationToken support. Host exceptions become the InnerException of the failed call. The interrupt signal defaults to SIGRTMIN + 1, because the .NET runtime suspends threads for garbage collection with SIGRTMIN. With offset 0 a collection can hang. Hyperlight.Wasm.Build generates C# bindings from HyperlightWit items at build time. Its MSBuild task loads hyperlight-wasm-bindgen, a native library around hyperlight's C# generator, so builds need no Rust. just dotnet-test runs the tests against the component_sample example world. just dotnet-pack packs both packages for the build machine's runtime identifier. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
ludfjig
force-pushed
the
hyperlight-0.18-capi
branch
from
October 30, 2026 22:30
bda3ce3 to
fbcf9c8
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.