@@ -318,17 +318,17 @@ fn init_syscall() -> SyscallType {
318318/// placeholder type, and cast it as needed.
319319struct Function ;
320320#[ cfg( feature = "time" ) ]
321- static mut CLOCK_GETTIME : AtomicPtr < Function > = AtomicPtr :: new ( null_mut ( ) ) ;
321+ static CLOCK_GETTIME : AtomicPtr < Function > = AtomicPtr :: new ( null_mut ( ) ) ;
322322#[ cfg( feature = "process" ) ]
323323#[ cfg( any(
324324 target_arch = "x86_64" ,
325325 target_arch = "x86" ,
326326 target_arch = "riscv64" ,
327327 target_arch = "powerpc64"
328328) ) ]
329- static mut GETCPU : AtomicPtr < Function > = AtomicPtr :: new ( null_mut ( ) ) ;
329+ static GETCPU : AtomicPtr < Function > = AtomicPtr :: new ( null_mut ( ) ) ;
330330#[ cfg( target_arch = "x86" ) ]
331- static mut SYSCALL : AtomicPtr < Function > = AtomicPtr :: new ( null_mut ( ) ) ;
331+ static SYSCALL : AtomicPtr < Function > = AtomicPtr :: new ( null_mut ( ) ) ;
332332
333333#[ cfg( feature = "time" ) ]
334334unsafe extern "C" fn rustix_clock_gettime_via_syscall (
@@ -435,52 +435,50 @@ rustix_int_0x80:
435435) ;
436436
437437fn minimal_init ( ) {
438- // SAFETY: Store default function addresses in static storage so that if we
438+ // Store default function addresses in static storage so that if we
439439 // end up making any system calls while we read the vDSO, they'll work. If
440440 // the memory happens to already be initialized, this is redundant, but not
441441 // harmful.
442- unsafe {
443- #[ cfg( feature = "time" ) ]
444- {
445- CLOCK_GETTIME
446- . compare_exchange (
447- null_mut ( ) ,
448- rustix_clock_gettime_via_syscall as * mut Function ,
449- Relaxed ,
450- Relaxed ,
451- )
452- . ok ( ) ;
453- }
442+ #[ cfg( feature = "time" ) ]
443+ {
444+ CLOCK_GETTIME
445+ . compare_exchange (
446+ null_mut ( ) ,
447+ rustix_clock_gettime_via_syscall as * mut Function ,
448+ Relaxed ,
449+ Relaxed ,
450+ )
451+ . ok ( ) ;
452+ }
454453
455- #[ cfg( feature = "process" ) ]
456- #[ cfg( any(
457- target_arch = "x86_64" ,
458- target_arch = "x86" ,
459- target_arch = "riscv64" ,
460- target_arch = "powerpc64"
461- ) ) ]
462- {
463- GETCPU
464- . compare_exchange (
465- null_mut ( ) ,
466- rustix_getcpu_via_syscall as * mut Function ,
467- Relaxed ,
468- Relaxed ,
469- )
470- . ok ( ) ;
471- }
454+ #[ cfg( feature = "process" ) ]
455+ #[ cfg( any(
456+ target_arch = "x86_64" ,
457+ target_arch = "x86" ,
458+ target_arch = "riscv64" ,
459+ target_arch = "powerpc64"
460+ ) ) ]
461+ {
462+ GETCPU
463+ . compare_exchange (
464+ null_mut ( ) ,
465+ rustix_getcpu_via_syscall as * mut Function ,
466+ Relaxed ,
467+ Relaxed ,
468+ )
469+ . ok ( ) ;
470+ }
472471
473- #[ cfg( target_arch = "x86" ) ]
474- {
475- SYSCALL
476- . compare_exchange (
477- null_mut ( ) ,
478- rustix_int_0x80 as * mut Function ,
479- Relaxed ,
480- Relaxed ,
481- )
482- . ok ( ) ;
483- }
472+ #[ cfg( target_arch = "x86" ) ]
473+ {
474+ SYSCALL
475+ . compare_exchange (
476+ null_mut ( ) ,
477+ rustix_int_0x80 as * mut Function ,
478+ Relaxed ,
479+ Relaxed ,
480+ )
481+ . ok ( ) ;
484482 }
485483}
486484
@@ -530,12 +528,10 @@ fn init() {
530528 if ok {
531529 assert ! ( !ptr. is_null( ) ) ;
532530
533- // SAFETY: Store the computed function addresses in static
531+ // Store the computed function addresses in static
534532 // storage so that we don't need to compute it again (but if
535533 // we do, it doesn't hurt anything).
536- unsafe {
537- CLOCK_GETTIME . store ( ptr. cast ( ) , Relaxed ) ;
538- }
534+ CLOCK_GETTIME . store ( ptr. cast ( ) , Relaxed ) ;
539535 }
540536 }
541537
@@ -584,12 +580,10 @@ fn init() {
584580 if ok {
585581 assert ! ( !ptr. is_null( ) ) ;
586582
587- // SAFETY: Store the computed function addresses in static
583+ // Store the computed function addresses in static
588584 // storage so that we don't need to compute it again (but if
589585 // we do, it doesn't hurt anything).
590- unsafe {
591- GETCPU . store ( ptr. cast ( ) , Relaxed ) ;
592- }
586+ GETCPU . store ( ptr. cast ( ) , Relaxed ) ;
593587 }
594588 }
595589
@@ -599,11 +593,9 @@ fn init() {
599593 let ptr = vdso. sym ( cstr ! ( "LINUX_2.5" ) , cstr ! ( "__kernel_vsyscall" ) ) ;
600594 assert ! ( !ptr. is_null( ) ) ;
601595
602- // SAFETY: As above, store the computed function addresses in
596+ // As above, store the computed function addresses in
603597 // static storage.
604- unsafe {
605- SYSCALL . store ( ptr. cast ( ) , Relaxed ) ;
606- }
598+ SYSCALL . store ( ptr. cast ( ) , Relaxed ) ;
607599 }
608600 }
609601}
0 commit comments