Changeset 12981
- Timestamp:
- Oct 14, 2011, 12:02:36 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/utils.c
r12940 r12981 1606 1606 return htonll( x ); 1607 1607 #else 1608 /* fallback code by Runner and Juan Carlos Cobas at 1609 * http://www.codeproject.com/KB/cpp/endianness.aspx */ 1610 return (((uint64_t)(htonl((int)((x << 32) >> 32))) << 32) | 1611 (unsigned int)htonl(((int)(x >> 32)))); 1608 /* fallback code by bdonlan at 1609 * http://stackoverflow.com/questions/809902/64-bit-ntohl-in-c/875505#875505 */ 1610 union { uint32_t lx[2]; uint64_t llx; } u; 1611 u.lx[0] = htonl(x >> 32); 1612 u.lx[1] = htonl(x & 0xFFFFFFFFULL); 1613 return u.llx; 1612 1614 #endif 1613 1615 } … … 1619 1621 return ntohll( x ); 1620 1622 #else 1621 /* fallback code by Runner and Juan Carlos Cobas at 1622 * http://www.codeproject.com/KB/cpp/endianness.aspx */ 1623 return (((uint64_t)(ntohl((int)((x << 32) >> 32))) << 32) | 1624 (unsigned int)ntohl(((int)(x >> 32)))); 1623 /* fallback code by bdonlan at 1624 * http://stackoverflow.com/questions/809902/64-bit-ntohl-in-c/875505#875505 */ 1625 union { uint32_t lx[2]; uint64_t llx; } u; 1626 u.llx = x; 1627 return ((uint64_t)ntohl(u.lx[0]) << 32) | (uint64_t)ntohl(u.lx[1]); 1625 1628 #endif 1626 1629 }
Note: See TracChangeset
for help on using the changeset viewer.