Byte-Swapping Builtins (Using the GNU Compiler Collection (GCC))

#### 7.2.3 Byte-Swapping Builtins ¶

Built-in Function: `uint16_t` __builtin_bswap16 `(uint16_t x)` ¶

  Returns x with the order of the bytes reversed; for example, `0xabcd` becomes `0xcdab`. Byte here always means exactly 8 bits.

Built-in Function: `uint32_t` __builtin_bswap32 `(uint32_t x)` ¶

  Similar to `__builtin_bswap16`, except the argument and return types are 32-bit.

Built-in Function: `uint64_t` __builtin_bswap64 `(uint64_t x)` ¶

  Similar to `__builtin_bswap32`, except the argument and return types are 64-bit.

Built-in Function: `uint128_t` __builtin_bswap128 `(uint128_t x)` ¶

  Similar to `__builtin_bswap64`, except the argument and return types are 128-bit. Only supported on targets when 128-bit types are supported.

Built-in Function: `uint8_t` __builtin_bitreverse8 `(uint8_t x)` ¶

  Returns x with all bits reversed.

Built-in Function: `uint16_t` __builtin_bitreverse16 `(uint16_t x)` ¶

  Similar to `__builtin_bitreverse8`, except the argument and return types are 16-bit.

Built-in Function: `uint32_t` __builtin_bitreverse32 `(uint32_t x)` ¶

  Similar to `__builtin_bitreverse16`, except the argument and return types are 32-bit.

Built-in Function: `uint64_t` __builtin_bitreverse64 `(uint64_t x)` ¶

  Similar to `__builtin_bitreverse32`, except the argument and return types are 64-bit.

Built-in Function: `uint128_t` __builtin_bitreverse128 `(uint128_t x)` ¶

  Similar to `__builtin_bitreverse64`, except the argument and return types are 128-bit. Only supported on targets when 128-bit types are supported.