Skip to content

Instantly share code, notes, and snippets.

@hailinzeng
Last active October 6, 2018 04:21
Show Gist options
  • Save hailinzeng/5604057 to your computer and use it in GitHub Desktop.
Save hailinzeng/5604057 to your computer and use it in GitHub Desktop.
convert host order uint64_t to network order uint64_t
#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