@@ -468,10 +468,6 @@ impl<'a> BootInformation<'a> {
468
468
}
469
469
}
470
470
471
- // SAFETY: BootInformation contains a const ptr to memory that is never mutated.
472
- // Sending this pointer to other threads is sound.
473
- unsafe impl Send for BootInformation < ' _ > { }
474
-
475
471
impl fmt:: Debug for BootInformation < ' _ > {
476
472
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
477
473
/// Limit how many Elf-Sections should be debug-formatted.
@@ -528,6 +524,30 @@ mod tests {
528
524
use crate :: memory_map:: MemoryAreaType ;
529
525
use core:: str:: Utf8Error ;
530
526
527
+ /// Compile time test to check if the boot information is Send and Sync.
528
+ /// This test is relevant to give library users flexebility in passing the
529
+ /// struct around.
530
+ #[ test]
531
+ fn boot_information_is_send_and_sync ( ) {
532
+ fn accept < T : Send + Sync > ( _: T ) { }
533
+
534
+ #[ repr( C , align( 8 ) ) ]
535
+ struct Bytes ( [ u8 ; 16 ] ) ;
536
+ let bytes: Bytes = Bytes ( [
537
+ 16 , 0 , 0 , 0 , // total_size
538
+ 0 , 0 , 0 , 0 , // reserved
539
+ 0 , 0 , 0 , 0 , // end tag type
540
+ 8 , 0 , 0 , 0 , // end tag size
541
+ ] ) ;
542
+ let ptr = bytes. 0 . as_ptr ( ) ;
543
+ let addr = ptr as usize ;
544
+ let bi = unsafe { BootInformation :: load ( ptr. cast ( ) ) } ;
545
+ let bi = bi. unwrap ( ) ;
546
+
547
+ // compile time test
548
+ accept ( bi) ;
549
+ }
550
+
531
551
#[ test]
532
552
fn no_tags ( ) {
533
553
#[ repr( C , align( 8 ) ) ]
0 commit comments