use a single >>32 instead of "(value / 65536) / 65536", just make sure that

the shift is done on a 64bit type
This commit is contained in:
Daniel Stenberg 2008-12-22 22:33:03 +00:00
parent 079d20aca8
commit 5a35edcb9a

View File

@ -51,8 +51,7 @@ libssh2_ntohu32(const unsigned char *buf)
/* }}} */
/* {{{ libssh2_ntohu64
* Note: Some 32-bit platforms have issues with bitops on long longs
* Work around this by doing expensive (but safer) arithmetic ops with optimization defying parentheses
*
*/
libssh2_uint64_t
libssh2_ntohu64(const unsigned char *buf)
@ -85,7 +84,7 @@ libssh2_htonu32(unsigned char *buf, unsigned long value)
void
libssh2_htonu64(unsigned char *buf, libssh2_uint64_t value)
{
unsigned long msl = (value / 65536) / 65536;
unsigned long msl = ((libssh2_uint64_t)value >> 32);
buf[0] = (msl >> 24) & 0xFF;
buf[1] = (msl >> 16) & 0xFF;