Skip to content

Commit

Permalink
Fix Windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowNinja committed Apr 22, 2017
1 parent e390874 commit 819c433
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/endian.hpp
Expand Up @@ -29,8 +29,16 @@
#define be16toh(x) ntohs(x)
#define htobe32(x) htonl(x)
#define be32toh(x) ntohl(x)
#define htobe64(x) htonll(x)
#define be64toh(x) ntohll(x)

#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define htobe64(x) (((uint64_t)htonl((uint64_t)(x) & 0xFFFFFFFF) << 32) | htonl((uint64_t)(x) >> 32))
#define be64toh(x) (((uint64_t)ntohl((uint64_t)(x) & 0xFFFFFFFF) << 32) | ntohl((uint64_t)(x) >> 32))
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define htobe64(x) x
#define be64toh(x) x
#else
#error "Only big and little endian supported on Windows!"
#endif
#else
#error Platform not supported!
#endif
Expand Down

0 comments on commit 819c433

Please sign in to comment.