mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-10 14:48:27 +00:00
Fix errors in make test-capi
This commit is contained in:
@@ -386,10 +386,8 @@ unsafe extern "C" fn wasi_console_out_seek_memory(
|
|||||||
unsafe extern "C" fn wasi_console_out_delete_memory(
|
unsafe extern "C" fn wasi_console_out_delete_memory(
|
||||||
ptr: *const c_void, /* = *Pipe */
|
ptr: *const c_void, /* = *Pipe */
|
||||||
) -> i64 {
|
) -> i64 {
|
||||||
let ptr = ptr as *mut Pipe;
|
let ptr = ptr as *const Pipe;
|
||||||
let ptr = &mut *ptr;
|
let _: Pipe = std::mem::transmute_copy(&*ptr); // dropped here, destructors run here
|
||||||
let _ = Box::from_raw(ptr); // TODO: correct?
|
|
||||||
// dropped here, destructors run here
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,9 +395,12 @@ unsafe extern "C" fn wasi_console_out_delete_memory(
|
|||||||
/// for backing stdin / stdout / stderr
|
/// for backing stdin / stdout / stderr
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasi_console_out_new_memory() -> *mut wasi_console_out_t {
|
pub unsafe extern "C" fn wasi_console_out_new_memory() -> *mut wasi_console_out_t {
|
||||||
|
|
||||||
|
use std::mem::ManuallyDrop;
|
||||||
|
|
||||||
let data = Box::new(Pipe::new());
|
let data = Pipe::new();
|
||||||
let ptr = Box::leak(data);
|
let mut data = ManuallyDrop::new(data);
|
||||||
|
let ptr: &mut Pipe = &mut data;
|
||||||
|
|
||||||
wasi_console_out_new(
|
wasi_console_out_new(
|
||||||
wasi_console_out_read_memory,
|
wasi_console_out_read_memory,
|
||||||
@@ -1244,26 +1245,18 @@ mod tests {
|
|||||||
} CustomWasiStdin;
|
} CustomWasiStdin;
|
||||||
|
|
||||||
int64_t CustomWasiStdin_destructor(
|
int64_t CustomWasiStdin_destructor(
|
||||||
const void* env,
|
const void* env
|
||||||
uintptr_t sz,
|
|
||||||
uintptr_t ao
|
|
||||||
) {
|
) {
|
||||||
(void)env;
|
(void)env;
|
||||||
(void)sz;
|
|
||||||
(void)ao;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t CustomWasiStdin_onStdIn(
|
int64_t CustomWasiStdin_onStdIn(
|
||||||
const void* env,
|
const void* env,
|
||||||
uintptr_t sz,
|
|
||||||
uintptr_t ao,
|
|
||||||
uintptr_t maxwrite,
|
uintptr_t maxwrite,
|
||||||
wasi_console_stdin_response_t* in
|
wasi_console_stdin_response_t* in
|
||||||
) {
|
) {
|
||||||
CustomWasiStdin* ptr = (CustomWasiStdin*)env;
|
CustomWasiStdin* ptr = (CustomWasiStdin*)env;
|
||||||
(void)sz;
|
|
||||||
(void)ao;
|
|
||||||
(void)maxwrite;
|
(void)maxwrite;
|
||||||
if (ptr->invocation == 0) {
|
if (ptr->invocation == 0) {
|
||||||
wasi_console_stdin_response_write_str(in, "hello");
|
wasi_console_stdin_response_write_str(in, "hello");
|
||||||
@@ -1287,8 +1280,7 @@ mod tests {
|
|||||||
CustomWasiStdin_onStdIn,
|
CustomWasiStdin_onStdIn,
|
||||||
CustomWasiStdin_destructor,
|
CustomWasiStdin_destructor,
|
||||||
&stdin,
|
&stdin,
|
||||||
sizeof(stdin),
|
sizeof(stdin)
|
||||||
8 // alignof(stdin)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Cloning the `wasi_console_out_t` does not deep-clone the
|
// Cloning the `wasi_console_out_t` does not deep-clone the
|
||||||
|
|||||||
Reference in New Issue
Block a user