Skip to content

Instantly share code, notes, and snippets.

@anarazel
Created September 22, 2017 18:49
Show Gist options
  • Save anarazel/25803f926254747ff80d32ec25749a7e to your computer and use it in GitHub Desktop.
Save anarazel/25803f926254747ff80d32ec25749a7e to your computer and use it in GitHub Desktop.
#ifdef HAVE__BUILTIN_BSWAP64
#define BSWAP64(x) __builtin_bswap64(x)
#else
#define BSWAP64(x) ((((x) << 56) & UINT64CONST(0xff00000000000000)) | \
(((x) << 40) & UINT64CONST(0x00ff000000000000)) | \
(((x) << 24) & UINT64CONST(0x0000ff0000000000)) | \
(((x) << 8) & UINT64CONST(0x000000ff00000000)) | \
(((x) >> 8) & UINT64CONST(0x00000000ff000000)) | \
(((x) >> 24) & UINT64CONST(0x0000000000ff0000)) | \
(((x) >> 40) & UINT64CONST(0x000000000000ff00)) | \
(((x) >> 56) & UINT64CONST(0x00000000000000ff)))
#endif /* HAVE__BUILTIN_BSWAP64 */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment