1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-30 13:01:23 +03:00

misc: Improve byte swapping of ntohll().

Fixes sparse warnings.
This commit is contained in:
Andreas Schneider
2012-02-18 12:15:22 +01:00
parent 3582e386b7
commit 66aaa6f573

View File

@@ -288,12 +288,14 @@ uint64_t ntohll(uint64_t a) {
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
return a; return a;
#else /* WORDS_BIGENDIAN */ #else /* WORDS_BIGENDIAN */
uint32_t low = (uint32_t)(a & 0xffffffff); return (((uint64_t)(a) << 56) | \
uint32_t high = (uint32_t)(a >> 32); (((uint64_t)(a) << 40) & 0xff000000000000ULL) | \
low = ntohl(low); (((uint64_t)(a) << 24) & 0xff0000000000ULL) | \
high = ntohl(high); (((uint64_t)(a) << 8) & 0xff00000000ULL) | \
(((uint64_t)(a) >> 8) & 0xff000000ULL) | \
return ((((uint64_t) low) << 32) | ( high)); (((uint64_t)(a) >> 24) & 0xff0000ULL) | \
(((uint64_t)(a) >> 40) & 0xff00ULL) | \
((uint64_t)(a) >> 56));
#endif /* WORDS_BIGENDIAN */ #endif /* WORDS_BIGENDIAN */
} }
#endif /* HAVE_NTOHLL */ #endif /* HAVE_NTOHLL */