diff options
author | Wan-Teh Chang <wtc@google.com> | 2016-10-04 11:58:31 +0200 |
---|---|---|
committer | Wan-Teh Chang <wtc@google.com> | 2016-10-04 11:58:31 +0200 |
commit | 2344212e44850df3b4cf142d2312dd5b088fb916 (patch) | |
tree | 3051c79fec700999cef3c264ac907283c8367229 | |
parent | 3831c9992b0fd06061e10d285c7a13eccd548075 (diff) | |
download | nspr-hg-2344212e44850df3b4cf142d2312dd5b088fb916.tar.gz |
Bug 1306955 - Fix little-endian to big-endian conversion r=ttaubert
-rw-r--r-- | pr/src/misc/prnetdb.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/pr/src/misc/prnetdb.c b/pr/src/misc/prnetdb.c index b2f6e435..d7c69581 100644 --- a/pr/src/misc/prnetdb.c +++ b/pr/src/misc/prnetdb.c @@ -1777,18 +1777,12 @@ PR_IMPLEMENT(PRUint64) PR_ntohll(PRUint64 n) #ifdef IS_BIG_ENDIAN return n; #else - PRUint64 tmp; PRUint32 hi, lo; - LL_L2UI(lo, n); - LL_SHR(tmp, n, 32); - LL_L2UI(hi, tmp); + lo = (PRUint32)n; + hi = (PRUint32)(n >> 32); hi = PR_ntohl(hi); lo = PR_ntohl(lo); - LL_UI2L(n, lo); - LL_SHL(n, n, 32); - LL_UI2L(tmp, hi); - LL_ADD(n, n, tmp); - return n; + return ((PRUint64)lo << 32) + (PRUint64)hi; #endif } /* ntohll */ @@ -1797,18 +1791,12 @@ PR_IMPLEMENT(PRUint64) PR_htonll(PRUint64 n) #ifdef IS_BIG_ENDIAN return n; #else - PRUint64 tmp; PRUint32 hi, lo; - LL_L2UI(lo, n); - LL_SHR(tmp, n, 32); - LL_L2UI(hi, tmp); + lo = (PRUint32)n; + hi = (PRUint32)(n >> 32); hi = htonl(hi); lo = htonl(lo); - LL_UI2L(n, lo); - LL_SHL(n, n, 32); - LL_UI2L(tmp, hi); - LL_ADD(n, n, tmp); - return n; + return ((PRUint64)lo << 32) + (PRUint64)hi; #endif } /* htonll */ |