]> git.proxmox.com Git - rustc.git/blob - src/stdarch/crates/core_arch/src/x86/bswap.rs
New upstream version 1.46.0+dfsg1
[rustc.git] / src / stdarch / crates / core_arch / src / x86 / bswap.rs
1 //! Byte swap intrinsics.
2 #![allow(clippy::module_name_repetitions)]
3
4 #[cfg(test)]
5 use stdarch_test::assert_instr;
6
7 /// Returns an integer with the reversed byte order of x
8 ///
9 /// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_bswap)
10 #[inline]
11 #[cfg_attr(test, assert_instr(bswap))]
12 #[stable(feature = "simd_x86", since = "1.27.0")]
13 pub unsafe fn _bswap(x: i32) -> i32 {
14 x.swap_bytes()
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 }