@@ -7,7 +7,7 @@ use core::any::Any;
77use core:: cmp:: max;
88use core:: ffi:: c_void;
99use core:: mem:: { align_of, size_of} ;
10- use core:: ptr:: { self , drop_in_place, null, null_mut, NonNull } ;
10+ use core:: ptr:: { drop_in_place, null, null_mut, NonNull } ;
1111use core:: slice;
1212use core:: sync:: atomic:: Ordering :: SeqCst ;
1313use core:: sync:: atomic:: { AtomicI32 , AtomicU8 } ;
@@ -328,26 +328,23 @@ pub(super) unsafe fn initialize_main_thread(mem: *mut c_void) {
328328 let tid = rustix:: runtime:: set_tid_address ( thread_id_ptr. cast ( ) ) ;
329329
330330 // Initialize the thread metadata.
331- ptr:: write (
332- metadata,
333- Metadata {
334- abi : Abi {
335- #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
336- this : newtls,
337- #[ cfg( any( target_arch = "aarch64" , target_arch = "arm" ) ) ]
338- dtv : null ( ) ,
339- #[ cfg( any( target_arch = "aarch64" , target_arch = "arm" ) ) ]
340- pad : [ 0_usize ; 1 ] ,
341- } ,
342- thread : ThreadData :: new (
343- Some ( tid) ,
344- stack_least. cast ( ) ,
345- stack_size,
346- guard_size,
347- map_size,
348- ) ,
331+ metadata. write ( Metadata {
332+ abi : Abi {
333+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
334+ this : newtls,
335+ #[ cfg( any( target_arch = "aarch64" , target_arch = "arm" ) ) ]
336+ dtv : null ( ) ,
337+ #[ cfg( any( target_arch = "aarch64" , target_arch = "arm" ) ) ]
338+ pad : [ 0_usize ; 1 ] ,
349339 } ,
350- ) ;
340+ thread : ThreadData :: new (
341+ Some ( tid) ,
342+ stack_least. cast ( ) ,
343+ stack_size,
344+ guard_size,
345+ map_size,
346+ ) ,
347+ } ) ;
351348
352349 // Initialize the TLS data with explicit initializer data.
353350 slice:: from_raw_parts_mut ( tls_data, STARTUP_TLS_INFO . file_size ) . copy_from_slice (
@@ -456,26 +453,23 @@ pub fn create_thread(
456453 let newtls: * mut Abi = & mut ( * metadata) . abi ;
457454
458455 // Initialize the thread metadata.
459- ptr:: write (
460- metadata,
461- Metadata {
462- abi : Abi {
463- #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
464- this : newtls,
465- #[ cfg( any( target_arch = "aarch64" , target_arch = "arm" ) ) ]
466- dtv : null ( ) ,
467- #[ cfg( any( target_arch = "aarch64" , target_arch = "arm" ) ) ]
468- pad : [ 0_usize ; 1 ] ,
469- } ,
470- thread : ThreadData :: new (
471- None , // the real tid will be written by `clone`.
472- stack_least. cast ( ) ,
473- stack_size,
474- guard_size,
475- map_size,
476- ) ,
456+ metadata. write ( Metadata {
457+ abi : Abi {
458+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
459+ this : newtls,
460+ #[ cfg( any( target_arch = "aarch64" , target_arch = "arm" ) ) ]
461+ dtv : null ( ) ,
462+ #[ cfg( any( target_arch = "aarch64" , target_arch = "arm" ) ) ]
463+ pad : [ 0_usize ; 1 ] ,
477464 } ,
478- ) ;
465+ thread : ThreadData :: new (
466+ None , // the real tid will be written by `clone`.
467+ stack_least. cast ( ) ,
468+ stack_size,
469+ guard_size,
470+ map_size,
471+ ) ,
472+ } ) ;
479473
480474 // Initialize the TLS data with explicit initializer data.
481475 slice:: from_raw_parts_mut ( tls_data, STARTUP_TLS_INFO . file_size ) . copy_from_slice (
@@ -576,17 +570,17 @@ pub(super) unsafe extern "C" fn entry(
576570 }
577571
578572 // Check that the incoming stack pointer is where we expect it to be.
579- debug_assert_eq ! ( builtin_return_address( 0 ) , core :: ptr :: null( ) ) ;
580- debug_assert_ne ! ( builtin_frame_address( 0 ) , core :: ptr :: null( ) ) ;
573+ debug_assert_eq ! ( builtin_return_address( 0 ) , null( ) ) ;
574+ debug_assert_ne ! ( builtin_frame_address( 0 ) , null( ) ) ;
581575 #[ cfg( not( any( target_arch = "x86" , target_arch = "arm" ) ) ) ]
582576 debug_assert_eq ! ( builtin_frame_address( 0 ) . addr( ) & 0xf , 0 ) ;
583577 #[ cfg( target_arch = "arm" ) ]
584578 debug_assert_eq ! ( builtin_frame_address( 0 ) . addr( ) & 0x3 , 0 ) ;
585579 #[ cfg( target_arch = "x86" ) ]
586580 debug_assert_eq ! ( builtin_frame_address( 0 ) . addr( ) & 0xf , 8 ) ;
587- debug_assert_eq ! ( builtin_frame_address( 1 ) , core :: ptr :: null( ) ) ;
581+ debug_assert_eq ! ( builtin_frame_address( 1 ) , null( ) ) ;
588582 #[ cfg( target_arch = "aarch64" ) ]
589- debug_assert_ne ! ( builtin_sponentry( ) , core :: ptr :: null( ) ) ;
583+ debug_assert_ne ! ( builtin_sponentry( ) , null( ) ) ;
590584 #[ cfg( target_arch = "aarch64" ) ]
591585 debug_assert_eq ! ( builtin_sponentry( ) . addr( ) & 0xf , 0 ) ;
592586
@@ -754,8 +748,8 @@ unsafe fn wait_for_thread_exit(thread: Thread) {
754748 // Check whether the thread has exited already; we set the
755749 // `CloneFlags::CHILD_CLEARTID` flag on the clone syscall, so we can test
756750 // for `NONE` here.
757- let thread = thread. 0 . as_ref ( ) ;
758- let thread_id = & thread . thread_id ;
751+ let thread_data = thread. 0 . as_ref ( ) ;
752+ let thread_id = & thread_data . thread_id ;
759753 while let Some ( id_value) = ThreadId :: from_raw ( thread_id. load ( SeqCst ) ) {
760754 // This doesn't use any shared memory, but we can't use
761755 // `FutexFlags::PRIVATE` because the wake comes from Linux
0 commit comments