Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ spinning_top = { version = "0.3.0", optional = true, public = true }
pci_types = { version = "0.10.0", public = true }
byteorder = { version = "1.5.0", optional = true, default-features = false }
smallvec = { version = "1.15.2", optional = true, default-features = false, public = true }
static_assertions = "1.1.0"

[dev-dependencies]
aml-test-tools = { path = "tools/aml-test-tools" }
lock_api = "0.4.14"
parking_lot = "0.12.5"
pretty_env_logger = "0.5.0"
serial_test = "4.0.1"
static_assertions = "1.1.0"

[features]
default = ["alloc", "aml"]
Expand Down
4 changes: 0 additions & 4 deletions src/aml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ pub type NoSendInterpreter<H> = BaseInterpreter<H, dyn RegionHandler>;
/// An Interpreter that is known to be Send + Sync. The version you should prefer by default.
pub type Interpreter<H> = BaseInterpreter<H, dyn RegionHandler + Send + Sync>;

// TODO: Make sure to remove these two lines after Interpreter really is Send + Sync.
unsafe impl<H> Send for Interpreter<H> where H: Handler + Send {}
unsafe impl<H> Sync for Interpreter<H> where H: Handler + Send {}

/// The value returned by the `Revision` opcode.
const INTERPRETER_REVISION: u64 = 1;

Expand Down
11 changes: 9 additions & 2 deletions src/aml/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ use alloc::{
};
use bit_field::BitField;
use core::{cell::UnsafeCell, cmp::Ordering, fmt, ops, sync::atomic::AtomicU64};
use static_assertions::assert_impl_all;

type NativeMethod = dyn Fn(&[WrappedObject]) -> Result<WrappedObject, AmlError>;
type NativeMethod = dyn Fn(&[WrappedObject]) -> Result<WrappedObject, AmlError> + Send + Sync;

#[derive(Clone)]
pub enum Object {
Expand Down Expand Up @@ -37,7 +38,7 @@ pub enum Object {
impl Object {
pub fn native_method<F>(num_args: u8, f: F) -> Object
where
F: Fn(&[WrappedObject]) -> Result<WrappedObject, AmlError> + 'static,
F: Fn(&[WrappedObject]) -> Result<WrappedObject, AmlError> + 'static + Send + Sync,
{
let mut flags = 0;
flags.set_bits(0..3, num_args);
Expand Down Expand Up @@ -104,9 +105,15 @@ impl ObjectToken {
}
}

// In order for us to assert WrappedObject is Send + Sync, Object must be.
assert_impl_all!(Object: Send, Sync);

#[derive(Clone, Debug)]
pub struct WrappedObject(Arc<UnsafeCell<Object>>);

unsafe impl Send for WrappedObject {}
unsafe impl Sync for WrappedObject {}

impl WrappedObject {
pub fn new(object: Object) -> WrappedObject {
#[allow(clippy::arc_with_non_send_sync)]
Expand Down
Loading