Skip to content

Instantly share code, notes, and snippets.

@hellertime
Created June 10, 2012 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellertime/2907111 to your computer and use it in GitHub Desktop.
Save hellertime/2907111 to your computer and use it in GitHub Desktop.
Autoconf fragment for normalizing byte-swap functions.
AH_VERBATIM([PORTABLE_BYTE_SWAP_FUNCTIONS],
[/* Standardize on a byte-swap function naming */
#if defined(__linux__)
# include <endian.h>
#elif defined(__FreeBSD__) || defined(__NetBSD__)
# include <sys/endian.h>
#elif defined(__OpenBSD__)
# include <sys/types.h>
# define be16toh(x) betoh16(x)
# define be32toh(x) betoh32(x)
# define be64toh(x) betoh64(x)
#else
# error No suitable byte-swap routines were found
#endif])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment