Changeset 12981


Ignore:
Timestamp:
Oct 14, 2011, 12:02:36 AM (10 years ago)
Author:
jordan
Message:

(trunk libT) #4556 "Transmission 2.40 fails to connect with UDP trackers on big endian systems" -- fixed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.c

    r12940 r12981  
    16061606    return htonll( x );
    16071607#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;
    16121614#endif
    16131615}
     
    16191621    return ntohll( x );
    16201622#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]);
    16251628#endif
    16261629}
Note: See TracChangeset for help on using the changeset viewer.