Browse Source

Tidy up some headers related to shared memory (#8366)

* Tidy up some headers related to shared memory

* Don't declare an anonymous `struct wasmtime_sharedmemory`, instead
  `#include` the actual definition.
* Fix an issue where a header in `sharedmemory.h` referred to a type in
  `extern.h` which wasn't `#include`'d. This function,
  `wasmtime_sharedmemory_into_extern`, additionally isn't necessary as
  it's no different than manually constructing it. Fix this by removing
  this function.

* Run clang-format
pull/8370/head
Alex Crichton 7 months ago
committed by GitHub
parent
commit
ca5f1bb627
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 3
      crates/c-api/include/wasmtime/extern.h
  2. 12
      crates/c-api/include/wasmtime/sharedmemory.h
  3. 13
      crates/c-api/src/sharedmemory.rs

3
crates/c-api/include/wasmtime/extern.h

@ -8,6 +8,7 @@
#define WASMTIME_EXTERN_H #define WASMTIME_EXTERN_H
#include <wasmtime/module.h> #include <wasmtime/module.h>
#include <wasmtime/sharedmemory.h>
#include <wasmtime/store.h> #include <wasmtime/store.h>
#ifdef __cplusplus #ifdef __cplusplus
@ -89,8 +90,6 @@ typedef uint8_t wasmtime_extern_kind_t;
/// shared memory /// shared memory
#define WASMTIME_EXTERN_SHAREDMEMORY 4 #define WASMTIME_EXTERN_SHAREDMEMORY 4
struct wasmtime_sharedmemory;
/** /**
* \typedef wasmtime_extern_union_t * \typedef wasmtime_extern_union_t
* \brief Convenience alias for #wasmtime_extern_union * \brief Convenience alias for #wasmtime_extern_union

12
crates/c-api/include/wasmtime/sharedmemory.h

@ -56,18 +56,6 @@ wasmtime_sharedmemory_delete(wasmtime_sharedmemory_t *memory);
WASM_API_EXTERN wasmtime_sharedmemory_t * WASM_API_EXTERN wasmtime_sharedmemory_t *
wasmtime_sharedmemory_clone(const wasmtime_sharedmemory_t *memory); wasmtime_sharedmemory_clone(const wasmtime_sharedmemory_t *memory);
/**
* \brief Moves shared linear memory into wasmtime_extern_t object
*
* \param memory memory to be moved
* \param out where to store resulting `wasmtime_extern_t`
*
* This function moves ownership of `memory` into resulting `wasmtime_extern_t`.
*/
WASM_API_EXTERN void
wasmtime_sharedmemory_into_extern(wasmtime_sharedmemory_t *memory,
wasmtime_extern_t *out);
/** /**
* \brief Returns the type of the shared memory specified * \brief Returns the type of the shared memory specified
*/ */

13
crates/c-api/src/sharedmemory.rs

@ -1,7 +1,6 @@
use crate::{handle_result, wasm_memorytype_t, wasmtime_error_t, wasmtime_extern_t}; use crate::{handle_result, wasm_memorytype_t, wasmtime_error_t};
use std::cell::UnsafeCell; use std::cell::UnsafeCell;
use std::mem::MaybeUninit; use wasmtime::SharedMemory;
use wasmtime::{Extern, SharedMemory};
type wasmtime_sharedmemory_t = SharedMemory; type wasmtime_sharedmemory_t = SharedMemory;
@ -27,14 +26,6 @@ pub extern "C" fn wasmtime_sharedmemory_clone(
Box::new(mem.clone()) Box::new(mem.clone())
} }
#[no_mangle]
pub extern "C" fn wasmtime_sharedmemory_into_extern(
mem: Box<wasmtime_sharedmemory_t>,
ext: &mut MaybeUninit<wasmtime_extern_t>,
) {
crate::initialize(ext, Extern::from(*mem).into());
}
#[no_mangle] #[no_mangle]
pub extern "C" fn wasmtime_sharedmemory_type( pub extern "C" fn wasmtime_sharedmemory_type(
mem: &wasmtime_sharedmemory_t, mem: &wasmtime_sharedmemory_t,

Loading…
Cancel
Save