Przeglądaj źródła

implement Send for PhysicalMapping (#101)

Tom Dohrmann 3 lat temu
rodzic
commit
306cfe0de0
2 zmienionych plików z 19 dodań i 0 usunięć
  1. 16 0
      rsdp/src/handler.rs
  2. 3 0
      rsdp/src/lib.rs

+ 16 - 0
rsdp/src/handler.rs

@@ -59,6 +59,8 @@ where
     }
 }
 
+unsafe impl<H: AcpiHandler + Send, T: Send> Send for PhysicalMapping<H, T> {}
+
 impl<H, T> Deref for PhysicalMapping<H, T>
 where
     H: AcpiHandler,
@@ -101,3 +103,17 @@ pub trait AcpiHandler: Clone {
     /// Note: A reference to the handler used to construct `region` can be acquired by calling [`PhysicalMapping::handler`].
     fn unmap_physical_region<T>(region: &PhysicalMapping<Self, T>);
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn test_send_sync() {
+        // verify that PhysicalMapping implements Send and Sync
+        fn test_send_sync<T: Send>() {}
+        fn caller<H: AcpiHandler + Send, T: Send>() {
+            test_send_sync::<PhysicalMapping<H, T>>();
+        }
+    }
+}

+ 3 - 0
rsdp/src/lib.rs

@@ -10,6 +10,9 @@
 #![feature(unsafe_block_in_unsafe_fn)]
 #![deny(unsafe_op_in_unsafe_fn)]
 
+#[cfg(test)]
+extern crate std;
+
 pub mod handler;
 
 use core::{mem, ops::Range, slice, str};