Last active
October 6, 2018 04:21
-
-
Save hailinzeng/5604057 to your computer and use it in GitHub Desktop.
convert host order uint64_t to network order uint64_t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/param.h> | |
uint64_t htonll(uint64_t n) | |
{ | |
#if __BYTE_ORDER == __BIG_ENDIAN | |
return n; | |
#else | |
return (((uint64_t)htonl(n)) << 32) + htonl(n >> 32); | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment