Skip to content

Commit

Permalink
Merge branch 'master' into feat-capi-cbindgen-0.19
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary authored Jul 7, 2021
2 parents 56f1d5a + cdab1b2 commit 44a83cb
Show file tree
Hide file tree
Showing 23 changed files with 573 additions and 192 deletions.
2 changes: 0 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
rustflags = [
# Put the VM functions in the dynamic symbol table.
"-C", "link-arg=-Wl,-E",
# Fix the SONAME, required by CMake, see https://github.com/wasmerio/wasmer/issues/2429.
"-C", "link-arg=-Wl,-soname,libwasmer.so",
]
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C

## **[Unreleased]**

### Changed
- [#2427](https://github.com/wasmerio/wasmer/pull/2427) Update `loupe` to 0.1.3.

### Fixed
- [#2426](https://github.com/wasmerio/wasmer/pull/2426) Fix the `wax` script generation.

## 2.0.0 - 2020/06/16
## 2.0.0 - 2021/06/16

### Added
- [#2411](https://github.com/wasmerio/wasmer/pull/2411) Extract types from `wasi` to a new `wasi-types` crate.
Expand All @@ -24,12 +27,12 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C
### Fixed
- [#2386](https://github.com/wasmerio/wasmer/pull/2386) Handle properly when a module has no exported functions in the CLI.

## 2.0.0-rc2 - 2020/06/03
## 2.0.0-rc2 - 2021/06/03

### Fixed
- [#2383](https://github.com/wasmerio/wasmer/pull/2383) Fix bugs in the Wasmer CLI tool with the way `--version` and the name of the CLI tool itself were printed.

## 2.0.0-rc1 - 2020/06/02
## 2.0.0-rc1 - 2021/06/02

### Added
- [#2348](https://github.com/wasmerio/wasmer/pull/2348) Make Wasmer available on `aarch64-linux-android`.
Expand Down
20 changes: 16 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,13 @@ install-misc:
install -Dm644 LICENSE "$(DESTDIR)"/share/licenses/wasmer/LICENSE

install-pkgconfig:
unset WASMER_DIR # Make sure WASMER_INSTALL_PREFIX is set during build
target/release/wasmer config --pkg-config | install -Dm644 /dev/stdin "$(DESTDIR)"/lib/pkgconfig/wasmer.pc
# Make sure WASMER_INSTALL_PREFIX is set during build
unset WASMER_DIR; \
if pc="$$(target/release/wasmer config --pkg-config 1>/dev/null 2>/dev/null)"; then \
echo "$$pc" | install -Dm644 /dev/stdin "$(DESTDIR)"/lib/pkgconfig/wasmer.pc; \
else \
echo 1>&2 "WASMER_INSTALL_PREFIX was not set during build, not installing wasmer.pc"; \
fi

install-wasmer-headless-minimal:
install -Dm755 target/release/wasmer-headless $(DESTDIR)/bin/wasmer-headless
Expand Down
4 changes: 3 additions & 1 deletion PACKAGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
with `WASMER_INSTALL_PREFIX`, e.g.:

```sh
$ WASMER_INSTALL_PREFIX=/usr make install
export WASMER_INSTALL_PREFIX=/usr
make
DESTDIR=.../usr make install
```

* In case you must build/install directly with `cargo`, make sure to
Expand Down
149 changes: 149 additions & 0 deletions lib/api/src/cell.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
pub use std::cell::Cell;

use core::cmp::Ordering;
use core::fmt::{self, Debug};
use std::fmt::Pointer;

/// A mutable Wasm-memory location.
#[repr(transparent)]
pub struct WasmCell<'a, T: ?Sized> {
inner: &'a Cell<T>,
}

unsafe impl<T: ?Sized> Send for WasmCell<'_, T> where T: Send {}

unsafe impl<T: ?Sized> Sync for WasmCell<'_, T> {}

impl<'a, T: Copy> Clone for WasmCell<'a, T> {
#[inline]
fn clone(&self) -> WasmCell<'a, T> {
WasmCell { inner: self.inner }
}
}

impl<T: PartialEq + Copy> PartialEq for WasmCell<'_, T> {
#[inline]
fn eq(&self, other: &WasmCell<T>) -> bool {
self.inner.eq(&other.inner)
}
}

impl<T: Eq + Copy> Eq for WasmCell<'_, T> {}

impl<T: PartialOrd + Copy> PartialOrd for WasmCell<'_, T> {
#[inline]
fn partial_cmp(&self, other: &WasmCell<T>) -> Option<Ordering> {
self.inner.partial_cmp(&other.inner)
}

#[inline]
fn lt(&self, other: &WasmCell<T>) -> bool {
self.inner < other.inner
}

#[inline]
fn le(&self, other: &WasmCell<T>) -> bool {
self.inner <= other.inner
}

#[inline]
fn gt(&self, other: &WasmCell<T>) -> bool {
self.inner > other.inner
}

#[inline]
fn ge(&self, other: &WasmCell<T>) -> bool {
self.inner >= other.inner
}
}

impl<T: Ord + Copy> Ord for WasmCell<'_, T> {
#[inline]
fn cmp(&self, other: &WasmCell<T>) -> Ordering {
self.inner.cmp(&other.inner)
}
}

impl<'a, T> WasmCell<'a, T> {
/// Creates a new `WasmCell` containing the given value.
///
/// # Examples
///
/// ```
/// use std::cell::Cell;
/// use wasmer::WasmCell;
///
/// let cell = Cell::new(5);
/// let wasm_cell = WasmCell::new(&cell);
/// ```
#[inline]
pub const fn new(cell: &'a Cell<T>) -> WasmCell<'a, T> {
WasmCell { inner: cell }
}
}

impl<'a, T: Copy> WasmCell<'a, T> {
/// Returns a copy of the contained value.
///
/// # Examples
///
/// ```
/// use std::cell::Cell;
/// use wasmer::WasmCell;
///
/// let cell = Cell::new(5);
/// let wasm_cell = WasmCell::new(&cell);
/// let five = wasm_cell.get();
/// ```
#[inline]
pub fn get(&self) -> T {
self.inner.get()
}

/// Get an unsafe mutable pointer to the inner item
/// in the Cell.
///
/// # Safety
///
/// This method is highly discouraged to use. We have it for
/// compatibility reasons with Emscripten.
/// It is unsafe because changing an item inline will change
/// the underlying memory.
///
/// It's highly encouraged to use the `set` method instead.
#[deprecated(
since = "2.0.0",
note = "Please use the memory-safe set method instead"
)]
#[doc(hidden)]
pub unsafe fn get_mut(&self) -> &'a mut T {
&mut *self.inner.as_ptr()
}
}

impl<T: Debug> Debug for WasmCell<'_, T> {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.inner.fmt(f)
}
}

impl<T: Sized> WasmCell<'_, T> {
/// Sets the contained value.
///
/// # Examples
///
/// ```
/// use std::cell::Cell;
/// use wasmer::WasmCell;
///
/// let cell = Cell::new(5);
/// let wasm_cell = WasmCell::new(&cell);
/// wasm_cell.set(10);
/// assert_eq!(cell.get(), 10);
/// ```
#[inline]
pub fn set(&self, val: T) {
self.inner.set(val);
}
}
2 changes: 2 additions & 0 deletions lib/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
//! [wasmer-llvm]: https://docs.rs/wasmer-compiler-llvm/*/wasmer_compiler_llvm/
//! [wasmer-wasi]: https://docs.rs/wasmer-wasi/*/wasmer_wasi/
mod cell;
mod env;
mod exports;
mod externals;
Expand Down Expand Up @@ -281,6 +282,7 @@ pub mod internals {
pub use crate::externals::{WithEnv, WithoutEnv};
}

pub use crate::cell::WasmCell;
pub use crate::env::{HostEnvInitError, LazyInit, WasmerEnv};
pub use crate::exports::{ExportError, Exportable, Exports, ExportsIterator};
pub use crate::externals::{
Expand Down
Loading

0 comments on commit 44a83cb

Please sign in to comment.