1//! Byte swap intrinsics.
2#![allow(clippy::module_name_repetitions)]
3
4#[cfg(test)]
5use stdarch_test::assert_instr;
6
7/// Returns an integer with the reversed byte order of x
8///
9/// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_bswap)
10#[inline]
11#[cfg_attr(test, assert_instr(bswap))]
12#[stable(feature = "simd_x86", since = "1.27.0")]
13pub unsafe fn _bswap(x: i32) -> i32 {
14 x.swap_bytes()
15}
16
17#[cfg(test)]
18mod 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}
29