@@ -468,10 +468,6 @@ impl<'a> BootInformation<'a> {
468468 }
469469}
470470
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-
475471impl fmt:: Debug for BootInformation < ' _ > {
476472 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
477473 /// Limit how many Elf-Sections should be debug-formatted.
@@ -528,6 +524,30 @@ mod tests {
528524 use crate :: memory_map:: MemoryAreaType ;
529525 use core:: str:: Utf8Error ;
530526
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+
531551 #[ test]
532552 fn no_tags ( ) {
533553 #[ repr( C , align( 8 ) ) ]
0 commit comments