Skip to content

Commit 47e0d61

Browse files
committed
mark SHA intrinsics as safe
Mark all SHA intrinsics as safe.
1 parent 2cdd170 commit 47e0d61

File tree

1 file changed

+14
-14
lines changed
  • crates/core_arch/src/x86

1 file changed

+14
-14
lines changed

Diff for: crates/core_arch/src/x86/sha.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ use stdarch_test::assert_instr;
3030
#[target_feature(enable = "sha")]
3131
#[cfg_attr(test, assert_instr(sha1msg1))]
3232
#[stable(feature = "simd_x86", since = "1.27.0")]
33-
pub unsafe fn _mm_sha1msg1_epu32(a: __m128i, b: __m128i) -> __m128i {
34-
transmute(sha1msg1(a.as_i32x4(), b.as_i32x4()))
33+
pub fn _mm_sha1msg1_epu32(a: __m128i, b: __m128i) -> __m128i {
34+
unsafe { transmute(sha1msg1(a.as_i32x4(), b.as_i32x4())) }
3535
}
3636

3737
/// Performs the final calculation for the next four SHA1 message values
@@ -43,8 +43,8 @@ pub unsafe fn _mm_sha1msg1_epu32(a: __m128i, b: __m128i) -> __m128i {
4343
#[target_feature(enable = "sha")]
4444
#[cfg_attr(test, assert_instr(sha1msg2))]
4545
#[stable(feature = "simd_x86", since = "1.27.0")]
46-
pub unsafe fn _mm_sha1msg2_epu32(a: __m128i, b: __m128i) -> __m128i {
47-
transmute(sha1msg2(a.as_i32x4(), b.as_i32x4()))
46+
pub fn _mm_sha1msg2_epu32(a: __m128i, b: __m128i) -> __m128i {
47+
unsafe { transmute(sha1msg2(a.as_i32x4(), b.as_i32x4())) }
4848
}
4949

5050
/// Calculate SHA1 state variable E after four rounds of operation from the
@@ -56,8 +56,8 @@ pub unsafe fn _mm_sha1msg2_epu32(a: __m128i, b: __m128i) -> __m128i {
5656
#[target_feature(enable = "sha")]
5757
#[cfg_attr(test, assert_instr(sha1nexte))]
5858
#[stable(feature = "simd_x86", since = "1.27.0")]
59-
pub unsafe fn _mm_sha1nexte_epu32(a: __m128i, b: __m128i) -> __m128i {
60-
transmute(sha1nexte(a.as_i32x4(), b.as_i32x4()))
59+
pub fn _mm_sha1nexte_epu32(a: __m128i, b: __m128i) -> __m128i {
60+
unsafe { transmute(sha1nexte(a.as_i32x4(), b.as_i32x4())) }
6161
}
6262

6363
/// Performs four rounds of SHA1 operation using an initial SHA1 state (A,B,C,D)
@@ -72,9 +72,9 @@ pub unsafe fn _mm_sha1nexte_epu32(a: __m128i, b: __m128i) -> __m128i {
7272
#[cfg_attr(test, assert_instr(sha1rnds4, FUNC = 0))]
7373
#[rustc_legacy_const_generics(2)]
7474
#[stable(feature = "simd_x86", since = "1.27.0")]
75-
pub unsafe fn _mm_sha1rnds4_epu32<const FUNC: i32>(a: __m128i, b: __m128i) -> __m128i {
75+
pub fn _mm_sha1rnds4_epu32<const FUNC: i32>(a: __m128i, b: __m128i) -> __m128i {
7676
static_assert_uimm_bits!(FUNC, 2);
77-
transmute(sha1rnds4(a.as_i32x4(), b.as_i32x4(), FUNC as i8))
77+
unsafe { transmute(sha1rnds4(a.as_i32x4(), b.as_i32x4(), FUNC as i8)) }
7878
}
7979

8080
/// Performs an intermediate calculation for the next four SHA256 message values
@@ -86,8 +86,8 @@ pub unsafe fn _mm_sha1rnds4_epu32<const FUNC: i32>(a: __m128i, b: __m128i) -> __
8686
#[target_feature(enable = "sha")]
8787
#[cfg_attr(test, assert_instr(sha256msg1))]
8888
#[stable(feature = "simd_x86", since = "1.27.0")]
89-
pub unsafe fn _mm_sha256msg1_epu32(a: __m128i, b: __m128i) -> __m128i {
90-
transmute(sha256msg1(a.as_i32x4(), b.as_i32x4()))
89+
pub fn _mm_sha256msg1_epu32(a: __m128i, b: __m128i) -> __m128i {
90+
unsafe { transmute(sha256msg1(a.as_i32x4(), b.as_i32x4())) }
9191
}
9292

9393
/// Performs the final calculation for the next four SHA256 message values
@@ -99,8 +99,8 @@ pub unsafe fn _mm_sha256msg1_epu32(a: __m128i, b: __m128i) -> __m128i {
9999
#[target_feature(enable = "sha")]
100100
#[cfg_attr(test, assert_instr(sha256msg2))]
101101
#[stable(feature = "simd_x86", since = "1.27.0")]
102-
pub unsafe fn _mm_sha256msg2_epu32(a: __m128i, b: __m128i) -> __m128i {
103-
transmute(sha256msg2(a.as_i32x4(), b.as_i32x4()))
102+
pub fn _mm_sha256msg2_epu32(a: __m128i, b: __m128i) -> __m128i {
103+
unsafe { transmute(sha256msg2(a.as_i32x4(), b.as_i32x4())) }
104104
}
105105

106106
/// Performs 2 rounds of SHA256 operation using an initial SHA256 state
@@ -114,8 +114,8 @@ pub unsafe fn _mm_sha256msg2_epu32(a: __m128i, b: __m128i) -> __m128i {
114114
#[target_feature(enable = "sha")]
115115
#[cfg_attr(test, assert_instr(sha256rnds2))]
116116
#[stable(feature = "simd_x86", since = "1.27.0")]
117-
pub unsafe fn _mm_sha256rnds2_epu32(a: __m128i, b: __m128i, k: __m128i) -> __m128i {
118-
transmute(sha256rnds2(a.as_i32x4(), b.as_i32x4(), k.as_i32x4()))
117+
pub fn _mm_sha256rnds2_epu32(a: __m128i, b: __m128i, k: __m128i) -> __m128i {
118+
unsafe { transmute(sha256rnds2(a.as_i32x4(), b.as_i32x4(), k.as_i32x4())) }
119119
}
120120

121121
#[cfg(test)]

0 commit comments

Comments
 (0)