@@ -318,17 +318,17 @@ fn init_syscall() -> SyscallType {
318
318
/// placeholder type, and cast it as needed.
319
319
struct Function ;
320
320
#[ cfg( feature = "time" ) ]
321
- static mut CLOCK_GETTIME : AtomicPtr < Function > = AtomicPtr :: new ( null_mut ( ) ) ;
321
+ static CLOCK_GETTIME : AtomicPtr < Function > = AtomicPtr :: new ( null_mut ( ) ) ;
322
322
#[ cfg( feature = "process" ) ]
323
323
#[ cfg( any(
324
324
target_arch = "x86_64" ,
325
325
target_arch = "x86" ,
326
326
target_arch = "riscv64" ,
327
327
target_arch = "powerpc64"
328
328
) ) ]
329
- static mut GETCPU : AtomicPtr < Function > = AtomicPtr :: new ( null_mut ( ) ) ;
329
+ static GETCPU : AtomicPtr < Function > = AtomicPtr :: new ( null_mut ( ) ) ;
330
330
#[ cfg( target_arch = "x86" ) ]
331
- static mut SYSCALL : AtomicPtr < Function > = AtomicPtr :: new ( null_mut ( ) ) ;
331
+ static SYSCALL : AtomicPtr < Function > = AtomicPtr :: new ( null_mut ( ) ) ;
332
332
333
333
#[ cfg( feature = "time" ) ]
334
334
unsafe extern "C" fn rustix_clock_gettime_via_syscall (
@@ -435,52 +435,50 @@ rustix_int_0x80:
435
435
) ;
436
436
437
437
fn 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
439
439
// end up making any system calls while we read the vDSO, they'll work. If
440
440
// the memory happens to already be initialized, this is redundant, but not
441
441
// 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
+ }
454
453
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
+ }
472
471
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 ( ) ;
484
482
}
485
483
}
486
484
@@ -530,12 +528,10 @@ fn init() {
530
528
if ok {
531
529
assert ! ( !ptr. is_null( ) ) ;
532
530
533
- // SAFETY: Store the computed function addresses in static
531
+ // Store the computed function addresses in static
534
532
// storage so that we don't need to compute it again (but if
535
533
// we do, it doesn't hurt anything).
536
- unsafe {
537
- CLOCK_GETTIME . store ( ptr. cast ( ) , Relaxed ) ;
538
- }
534
+ CLOCK_GETTIME . store ( ptr. cast ( ) , Relaxed ) ;
539
535
}
540
536
}
541
537
@@ -584,12 +580,10 @@ fn init() {
584
580
if ok {
585
581
assert ! ( !ptr. is_null( ) ) ;
586
582
587
- // SAFETY: Store the computed function addresses in static
583
+ // Store the computed function addresses in static
588
584
// storage so that we don't need to compute it again (but if
589
585
// we do, it doesn't hurt anything).
590
- unsafe {
591
- GETCPU . store ( ptr. cast ( ) , Relaxed ) ;
592
- }
586
+ GETCPU . store ( ptr. cast ( ) , Relaxed ) ;
593
587
}
594
588
}
595
589
@@ -599,11 +593,9 @@ fn init() {
599
593
let ptr = vdso. sym ( cstr ! ( "LINUX_2.5" ) , cstr ! ( "__kernel_vsyscall" ) ) ;
600
594
assert ! ( !ptr. is_null( ) ) ;
601
595
602
- // SAFETY: As above, store the computed function addresses in
596
+ // As above, store the computed function addresses in
603
597
// static storage.
604
- unsafe {
605
- SYSCALL . store ( ptr. cast ( ) , Relaxed ) ;
606
- }
598
+ SYSCALL . store ( ptr. cast ( ) , Relaxed ) ;
607
599
}
608
600
}
609
601
}
0 commit comments