diff --git a/src/sha1.cpp b/src/sha1.cpp index c75def163..8085731b7 100644 --- a/src/sha1.cpp +++ b/src/sha1.cpp @@ -15,6 +15,8 @@ changelog at the end of the file. #include "libtorrent/sha1.hpp" +#include // for BIG_ENDIAN and LITTLE_ENDIAN macros + typedef boost::uint32_t u32; typedef boost::uint8_t u8; diff --git a/src/torrent_peer.cpp b/src/torrent_peer.cpp index 220e5960b..d60df55dc 100644 --- a/src/torrent_peer.cpp +++ b/src/torrent_peer.cpp @@ -37,6 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/crc32c.hpp" #include "libtorrent/ip_voter.hpp" +#include // for BIG_ENDIAN and LITTLE_ENDIAN macros + namespace libtorrent { namespace { @@ -82,8 +84,15 @@ namespace libtorrent if (e1.port() > e2.port()) swap(e1, e2); boost::uint32_t p; - reinterpret_cast(&p)[0] = aux::host_to_network(e1.port()); - reinterpret_cast(&p)[1] = aux::host_to_network(e2.port()); +#if defined BOOST_BIG_ENDIAN + p = e1.port() << 16; + p |= e2.port(); +#elif defined BOOST_LITTLE_ENDIAN + p = aux::host_to_network(e2.port()) << 16; + p |= aux::host_to_network(e1.port()); +#else +#error unsupported endianness +#endif ret = crc32c_32(p); } #if TORRENT_USE_IPV6