]>
Commit | Line | Data |
---|---|---|
0531ce1d | 1 | //! Byte swap intrinsics. |
48663c56 | 2 | #![allow(clippy::module_name_repetitions)] |
0531ce1d XL |
3 | |
4 | #[cfg(test)] | |
416331ca | 5 | use stdarch_test::assert_instr; |
0531ce1d | 6 | |
532ac7d7 | 7 | /// Returns an integer with the reversed byte order of x |
83c7162d XL |
8 | /// |
9 | /// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_bswap) | |
0531ce1d XL |
10 | #[inline] |
11 | #[cfg_attr(test, assert_instr(bswap))] | |
83c7162d | 12 | #[stable(feature = "simd_x86", since = "1.27.0")] |
0531ce1d | 13 | pub unsafe fn _bswap(x: i32) -> i32 { |
74b04a01 | 14 | x.swap_bytes() |
0531ce1d XL |
15 | } |
16 | ||
17 | #[cfg(test)] | |
18 | mod tests { | |
19 | use super::*; | |
20 | ||
21 | #[test] | |
22 | fn test_bswap() { | |
23 | unsafe { | |
24 | assert_eq!(_bswap(0x0EADBE0F), 0x0FBEAD0E); | |
25 | assert_eq!(_bswap(0x00000000), 0x00000000); | |
26 | } | |
27 | } | |
28 | } |