Skip to content

Commit

Permalink
Enable warnings if threads is disabled
Browse files Browse the repository at this point in the history
Continuation of work in bytecodealliance#10131
  • Loading branch information
alexcrichton committed Jan 28, 2025
1 parent 23fc0c1 commit 599ea95
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
1 change: 0 additions & 1 deletion crates/wasmtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@
not(feature = "coredump"),
not(feature = "runtime"),
not(feature = "component-model"),
not(feature = "threads"),
not(feature = "std"),
),
allow(dead_code, unused_imports)
Expand Down
20 changes: 13 additions & 7 deletions crates/wasmtime/src/runtime/vm/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ use crate::prelude::*;
use crate::runtime::vm::vmcontext::VMMemoryDefinition;
#[cfg(has_virtual_memory)]
use crate::runtime::vm::{HostAlignedByteCount, MmapOffset};
use crate::runtime::vm::{MemoryImage, MemoryImageSlot, SendSyncPtr, VMStore, WaitResult};
use crate::runtime::vm::{MemoryImage, MemoryImageSlot, SendSyncPtr, VMStore};
use alloc::sync::Arc;
use core::time::Duration;
use core::{ops::Range, ptr::NonNull};
use wasmtime_environ::{Trap, Tunables};
use wasmtime_environ::Tunables;

#[cfg(feature = "threads")]
use wasmtime_environ::Trap;

#[cfg(has_virtual_memory)]
mod mmap;
Expand Down Expand Up @@ -434,6 +436,7 @@ impl Memory {
}

/// Implementation of `memory.atomic.notify` for all memories.
#[cfg(feature = "threads")]
pub fn atomic_notify(&mut self, addr: u64, count: u32) -> Result<u32, Trap> {
match self.as_shared_memory() {
Some(m) => m.atomic_notify(addr, count),
Expand All @@ -445,12 +448,13 @@ impl Memory {
}

/// Implementation of `memory.atomic.wait32` for all memories.
#[cfg(feature = "threads")]
pub fn atomic_wait32(
&mut self,
addr: u64,
expected: u32,
timeout: Option<Duration>,
) -> Result<WaitResult, Trap> {
timeout: Option<core::time::Duration>,
) -> Result<crate::WaitResult, Trap> {
match self.as_shared_memory() {
Some(m) => m.atomic_wait32(addr, expected, timeout),
None => {
Expand All @@ -461,12 +465,13 @@ impl Memory {
}

/// Implementation of `memory.atomic.wait64` for all memories.
#[cfg(feature = "threads")]
pub fn atomic_wait64(
&mut self,
addr: u64,
expected: u64,
timeout: Option<Duration>,
) -> Result<WaitResult, Trap> {
timeout: Option<core::time::Duration>,
) -> Result<crate::WaitResult, Trap> {
match self.as_shared_memory() {
Some(m) => m.atomic_wait64(addr, expected, timeout),
None => {
Expand Down Expand Up @@ -736,6 +741,7 @@ impl LocalMemory {
/// we are using static memories with virtual memory guard pages) this manual
/// check is here so we don't segfault from Rust. For other configurations,
/// these checks are required anyways.
#[cfg(feature = "threads")]
pub fn validate_atomic_addr(
def: &VMMemoryDefinition,
addr: u64,
Expand Down
10 changes: 1 addition & 9 deletions crates/wasmtime/src/runtime/vm/memory/shared_memory_disabled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::runtime::vm::{VMMemoryDefinition, VMStore, WaitResult};
use core::ops::Range;
use core::ptr::NonNull;
use core::time::Duration;
use wasmtime_environ::{Trap, Tunables};
use wasmtime_environ::Trap;

#[derive(Clone)]
pub enum SharedMemory {}
Expand Down Expand Up @@ -66,14 +66,6 @@ impl SharedMemory {
match *self {}
}

pub(crate) fn grow_to(&mut self, _size: usize) -> Result<()> {
match *self {}
}

pub(crate) fn vmmemory(&mut self) -> VMMemoryDefinition {
match *self {}
}

pub(crate) fn needs_init(&self) -> bool {
match *self {}
}
Expand Down

0 comments on commit 599ea95

Please sign in to comment.