From dc8a2a2fc716e30ebfe2fa9ce14761ba3dce4ed4 Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Tue, 19 Sep 2006 22:20:18 +0000 Subject: [PATCH] Use GNU Net implementation of htnoll and ntohll Reviewed By: shire git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664798 13f79535-47bb-0310-9956-ffa450edef68 --- lib/cpp/src/protocol/TProtocol.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/cpp/src/protocol/TProtocol.h b/lib/cpp/src/protocol/TProtocol.h index 89c7f48c..60d85dcd 100644 --- a/lib/cpp/src/protocol/TProtocol.h +++ b/lib/cpp/src/protocol/TProtocol.h @@ -16,9 +16,13 @@ using namespace boost; using namespace facebook::thrift::transport; -#define ntohll(x) (((uint64_t)(ntohl((int)((x & 0x00000000FFFFFFFF)))) << 32) | (uint32_t)ntohl(((int)(x >> 32 & 0x00000000FFFFFFFF)))) - -#define htonll(x) ntohll(x) +#if __BYTE_ORDER == __BIG_ENDIAN +#define ntohll(n) (n) +#define htonll(n) (n) +#else +#define ntohll(n) ( (((unsigned long long)ntohl(n)) << 32) + ntohl(n >> 32) ) +#define htonll(n) ( (((unsigned long long)htonl(n)) << 32) + htonl(n >> 32) ) +#endif // Forward declaration for TProtocol struct TBuf; -- 2.17.1