Skip to content

Commit cfef9fb

Browse files
authored
Enable warnings if threads is disabled (bytecodealliance#10136)
Continuation of work in bytecodealliance#10131
1 parent 94f21bc commit cfef9fb

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

crates/wasmtime/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@
294294
not(feature = "pooling-allocator"),
295295
not(feature = "runtime"),
296296
not(feature = "component-model"),
297-
not(feature = "threads"),
298297
not(feature = "std"),
299298
),
300299
allow(dead_code, unused_imports)

crates/wasmtime/src/runtime/vm/memory.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ use crate::prelude::*;
7878
use crate::runtime::vm::vmcontext::VMMemoryDefinition;
7979
#[cfg(has_virtual_memory)]
8080
use crate::runtime::vm::{HostAlignedByteCount, MmapOffset};
81-
use crate::runtime::vm::{MemoryImage, MemoryImageSlot, SendSyncPtr, VMStore, WaitResult};
81+
use crate::runtime::vm::{MemoryImage, MemoryImageSlot, SendSyncPtr, VMStore};
8282
use alloc::sync::Arc;
83-
use core::time::Duration;
8483
use core::{ops::Range, ptr::NonNull};
85-
use wasmtime_environ::{Trap, Tunables};
84+
use wasmtime_environ::Tunables;
85+
86+
#[cfg(feature = "threads")]
87+
use wasmtime_environ::Trap;
8688

8789
#[cfg(has_virtual_memory)]
8890
mod mmap;
@@ -434,6 +436,7 @@ impl Memory {
434436
}
435437

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

447450
/// Implementation of `memory.atomic.wait32` for all memories.
451+
#[cfg(feature = "threads")]
448452
pub fn atomic_wait32(
449453
&mut self,
450454
addr: u64,
451455
expected: u32,
452-
timeout: Option<Duration>,
453-
) -> Result<WaitResult, Trap> {
456+
timeout: Option<core::time::Duration>,
457+
) -> Result<crate::WaitResult, Trap> {
454458
match self.as_shared_memory() {
455459
Some(m) => m.atomic_wait32(addr, expected, timeout),
456460
None => {
@@ -461,12 +465,13 @@ impl Memory {
461465
}
462466

463467
/// Implementation of `memory.atomic.wait64` for all memories.
468+
#[cfg(feature = "threads")]
464469
pub fn atomic_wait64(
465470
&mut self,
466471
addr: u64,
467472
expected: u64,
468-
timeout: Option<Duration>,
469-
) -> Result<WaitResult, Trap> {
473+
timeout: Option<core::time::Duration>,
474+
) -> Result<crate::WaitResult, Trap> {
470475
match self.as_shared_memory() {
471476
Some(m) => m.atomic_wait64(addr, expected, timeout),
472477
None => {
@@ -736,6 +741,7 @@ impl LocalMemory {
736741
/// we are using static memories with virtual memory guard pages) this manual
737742
/// check is here so we don't segfault from Rust. For other configurations,
738743
/// these checks are required anyways.
744+
#[cfg(feature = "threads")]
739745
pub fn validate_atomic_addr(
740746
def: &VMMemoryDefinition,
741747
addr: u64,

crates/wasmtime/src/runtime/vm/memory/shared_memory_disabled.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::runtime::vm::{VMMemoryDefinition, VMStore, WaitResult};
66
use core::ops::Range;
77
use core::ptr::NonNull;
88
use core::time::Duration;
9-
use wasmtime_environ::{Trap, Tunables};
9+
use wasmtime_environ::Trap;
1010

1111
#[derive(Clone)]
1212
pub enum SharedMemory {}
@@ -66,14 +66,6 @@ impl SharedMemory {
6666
match *self {}
6767
}
6868

69-
pub(crate) fn grow_to(&mut self, _size: usize) -> Result<()> {
70-
match *self {}
71-
}
72-
73-
pub(crate) fn vmmemory(&mut self) -> VMMemoryDefinition {
74-
match *self {}
75-
}
76-
7769
pub(crate) fn needs_init(&self) -> bool {
7870
match *self {}
7971
}

0 commit comments

Comments
 (0)