Mercurial > hg > orthanc
diff Core/Endianness.h @ 2448:862d943115f9
working on linux standard base
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 02 Jan 2018 18:04:11 +0100 |
parents | 878b59270859 |
children | 98a04e75f15e |
line wrap: on
line diff
--- a/Core/Endianness.h Tue Jan 02 09:35:07 2018 +0100 +++ b/Core/Endianness.h Tue Jan 02 18:04:11 2018 +0100 @@ -38,7 +38,12 @@ ** LINUX-LIKE ARCHITECTURES ********************************************************************/ -#if defined(__linux__) || defined(__EMSCRIPTEN__) +#if defined(__LSB_VERSION__) +// Linux Standard Base (LSB) does not come with be16toh, be32toh, and +// be64toh +# define ORTHANC_HAS_BUILTIN_BYTE_SWAP 0 +# include <endian.h> +#elif defined(__linux__) || defined(__EMSCRIPTEN__) # define ORTHANC_HAS_BUILTIN_BYTE_SWAP 1 # include <endian.h> #endif @@ -155,4 +160,38 @@ static_cast<uint64_t>(p[7])); } +#if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && defined(__BIG_ENDIAN) +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define be16toh(x) __orthanc_bswap16(x) +# define be32toh(x) __orthanc_bswap32(x) +# define be64toh(x) __orthanc_bswap64(x) +# define htobe16(x) __orthanc_bswap16(x) +# define htobe32(x) __orthanc_bswap32(x) +# define htobe64(x) __orthanc_bswap64(x) +# define htole16(x) x +# define htole32(x) x +# define htole64(x) x +# define le16toh(x) x +# define le32toh(x) x +# define le64toh(x) x +# elif __BYTE_ORDER == __BIG_ENDIAN +# define be16toh(x) x +# define be32toh(x) x +# define be64toh(x) x +# define htobe16(x) x +# define htobe32(x) x +# define htobe64(x) x +# define htole16(x) __orthanc_bswap16(x) +# define htole32(x) __orthanc_bswap32(x) +# define htole64(x) __orthanc_bswap64(x) +# define le16toh(x) __orthanc_bswap16(x) +# define le32toh(x) __orthanc_bswap32(x) +# define le64toh(x) __orthanc_bswap64(x) +# else +# error Please support your platform here +# endif +#else +# error Please support your platform here #endif + +#endif