19 #ifndef TORC_COMMON_ENDIAN_HPP
20 #define TORC_COMMON_ENDIAN_HPP
22 #include <boost/cstdint.hpp>
23 #include <boost/detail/endian.hpp>
29 #include <netinet/in.h>
40 boost::uint64_t
inline ntohll(
const boost::uint64_t& x) {
41 #ifdef BOOST_BIG_ENDIAN
46 ((x<<40) & 0x00FF000000000000ull) |
47 ((x<<24) & 0x0000FF0000000000ull) |
48 ((x<<8) & 0x000000FF00000000ull) |
49 ((x>>8) & 0x00000000FF000000ull) |
50 ((x>>24) & 0x0000000000FF0000ull) |
51 ((x>>40) & 0x000000000000FF00ull) |
61 boost::uint64_t
inline htonll(
const boost::uint64_t& x) {
62 #ifdef BOOST_BIG_ENDIAN
67 ((x<<40) & 0x00FF000000000000ull) |
68 ((x<<24) & 0x0000FF0000000000ull) |
69 ((x<<8) & 0x000000FF00000000ull) |
70 ((x>>8) & 0x00000000FF000000ull) |
71 ((x>>24) & 0x0000000000FF0000ull) |
72 ((x>>40) & 0x000000000000FF00ull) |
80 #endif // TORC_COMMON_ENDIAN_HPP
boost::uint64_t ntohll(const boost::uint64_t &x)
Convert 64-bit types from network to host byte order.
boost::uint64_t htonll(const boost::uint64_t &x)
Convert 64-bit types from host to network byte order.