Skip to content

Commit c94e320

Browse files
committed
Make the fence intrinsics and _mm_pause safe
1 parent ffd9c65 commit c94e320

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

crates/core_arch/src/x86/sse.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,8 +1445,8 @@ pub fn _mm_move_ss(a: __m128, b: __m128) -> __m128 {
14451445
#[target_feature(enable = "sse")]
14461446
#[cfg_attr(test, assert_instr(sfence))]
14471447
#[stable(feature = "simd_x86", since = "1.27.0")]
1448-
pub unsafe fn _mm_sfence() {
1449-
sfence()
1448+
pub fn _mm_sfence() {
1449+
unsafe { sfence() }
14501450
}
14511451

14521452
/// Gets the unsigned 32-bit value of the MXCSR control and status register.

crates/core_arch/src/x86/sse2.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ use crate::{
1919
#[inline]
2020
#[cfg_attr(all(test, target_feature = "sse2"), assert_instr(pause))]
2121
#[stable(feature = "simd_x86", since = "1.27.0")]
22-
pub unsafe fn _mm_pause() {
22+
pub fn _mm_pause() {
2323
// note: `pause` is guaranteed to be interpreted as a `nop` by CPUs without
2424
// the SSE2 target-feature - therefore it does not require any target features
25-
pause()
25+
unsafe { pause() }
2626
}
2727

2828
/// Invalidates and flushes the cache line that contains `p` from all levels of
@@ -49,8 +49,8 @@ pub unsafe fn _mm_clflush(p: *const u8) {
4949
#[target_feature(enable = "sse2")]
5050
#[cfg_attr(test, assert_instr(lfence))]
5151
#[stable(feature = "simd_x86", since = "1.27.0")]
52-
pub unsafe fn _mm_lfence() {
53-
lfence()
52+
pub fn _mm_lfence() {
53+
unsafe { lfence() }
5454
}
5555

5656
/// Performs a serializing operation on all load-from-memory and store-to-memory
@@ -65,8 +65,8 @@ pub unsafe fn _mm_lfence() {
6565
#[target_feature(enable = "sse2")]
6666
#[cfg_attr(test, assert_instr(mfence))]
6767
#[stable(feature = "simd_x86", since = "1.27.0")]
68-
pub unsafe fn _mm_mfence() {
69-
mfence()
68+
pub fn _mm_mfence() {
69+
unsafe { mfence() }
7070
}
7171

7272
/// Adds packed 8-bit integers in `a` and `b`.
@@ -3142,7 +3142,7 @@ mod tests {
31423142

31433143
#[test]
31443144
fn test_mm_pause() {
3145-
unsafe { _mm_pause() }
3145+
_mm_pause()
31463146
}
31473147

31483148
#[simd_test(enable = "sse2")]

0 commit comments

Comments
 (0)