diff --git a/library/core/src/hint.rs b/library/core/src/hint.rs index 90326e649058b..616bdd9a97b7c 100644 --- a/library/core/src/hint.rs +++ b/library/core/src/hint.rs @@ -300,11 +300,11 @@ pub fn spin_loop() { all(target_feature = "v6", target_feature = "mclass"), ) ) => { - // SAFETY: the `cfg` attr ensures that we only execute this on arm + // The `cfg` attr ensures that we only execute this on arm // targets with support for the this feature. On ARMv6 in Thumb // mode, T2 is required (see Arm DDI0406C Section A8.8.427), // otherwise ARMv6-M or ARMv6K is enough - unsafe { crate::arch::arm::__yield() } + crate::arch::arm::__yield() } target_arch = "loongarch32" => crate::arch::loongarch32::ibar::<0>(), target_arch = "loongarch64" => crate::arch::loongarch64::ibar::<0>(), diff --git a/library/stdarch/crates/core_arch/src/arm_shared/hints.rs b/library/stdarch/crates/core_arch/src/arm_shared/hints.rs index ce64e8341e7eb..a531a0a632321 100644 --- a/library/stdarch/crates/core_arch/src/arm_shared/hints.rs +++ b/library/stdarch/crates/core_arch/src/arm_shared/hints.rs @@ -17,8 +17,11 @@ ))] #[inline(always)] #[unstable(feature = "stdarch_arm_hints", issue = "117218")] -pub unsafe fn __wfi() { - hint(HINT_WFI); +pub fn __wfi() { + // SAFETY: The right HINT_WFI constant is passed to the llvm intrinsic。 + unsafe { + hint(HINT_WFI); + } } /// Generates a WFE (wait for event) hint instruction, or nothing. @@ -36,8 +39,11 @@ pub unsafe fn __wfi() { ))] #[inline(always)] #[unstable(feature = "stdarch_arm_hints", issue = "117218")] -pub unsafe fn __wfe() { - hint(HINT_WFE); +pub fn __wfe() { + // SAFETY: The right HINT_WFE constant is passed to the llvm intrinsic。 + unsafe { + hint(HINT_WFE); + } } /// Generates a SEV (send a global event) hint instruction. @@ -54,8 +60,11 @@ pub unsafe fn __wfe() { ))] #[inline(always)] #[unstable(feature = "stdarch_arm_hints", issue = "117218")] -pub unsafe fn __sev() { - hint(HINT_SEV); +pub fn __sev() { + // SAFETY: The right HINT_SEV constant is passed to the llvm intrinsic。 + unsafe { + hint(HINT_SEV); + } } /// Generates a send a local event hint instruction. @@ -72,8 +81,11 @@ pub unsafe fn __sev() { ))] #[inline(always)] #[unstable(feature = "stdarch_arm_hints", issue = "117218")] -pub unsafe fn __sevl() { - hint(HINT_SEVL); +pub fn __sevl() { + // SAFETY: The right HINT_SEVL constant is passed to the llvm intrinsic。 + unsafe { + hint(HINT_SEVL); + } } /// Generates a YIELD hint instruction. @@ -94,8 +106,11 @@ pub unsafe fn __sevl() { ))] #[inline(always)] #[unstable(feature = "stdarch_arm_hints", issue = "117218")] -pub unsafe fn __yield() { - hint(HINT_YIELD); +pub fn __yield() { + // SAFETY: The right HINT_YIELD constant is passed to the llvm intrinsic。 + unsafe { + hint(HINT_YIELD); + } } /// Generates an unspecified no-op instruction. @@ -106,8 +121,11 @@ pub unsafe fn __yield() { /// will increase execution time. #[inline(always)] #[unstable(feature = "stdarch_arm_hints", issue = "117218")] -pub unsafe fn __nop() { - crate::arch::asm!("nop", options(nomem, nostack, preserves_flags)); +pub fn __nop() { + // SAFETY: `nop` performs no operation. + unsafe { + crate::arch::asm!("nop", options(nomem, nostack, preserves_flags)); + } } unsafe extern "llvm-intrinsic" {