mirror of
https://github.com/transmission/transmission
synced 2025-01-31 11:23:40 +00:00
(trunk libT) better implementation of tr_htonll() and tr_ntohll()
This commit is contained in:
parent
cdff3aa090
commit
58c084fbda
1 changed files with 10 additions and 14 deletions
|
@ -1653,28 +1653,24 @@ tr_realpath( const char * path, char * resolved_path )
|
|||
***/
|
||||
|
||||
uint64_t
|
||||
tr_ntohll( uint64_t v )
|
||||
tr_htonll( uint64_t x )
|
||||
{
|
||||
#ifdef HAVE_NTOHLL
|
||||
return ntohll( v );
|
||||
#ifdef HAVE_HTONLL
|
||||
return htonll( x );
|
||||
#else
|
||||
union { unsigned long lv[2]; unsigned long long llv; } u;
|
||||
u.lv[0] = ntohl(v >> 32);
|
||||
u.lv[1] = ntohl(v & 0xFFFFFFFFULL);
|
||||
return u.llv;
|
||||
return (((uint64_t)(htonl((int)((x << 32) >> 32))) << 32) |
|
||||
(unsigned int)htonl(((int)(x >> 32))));
|
||||
#endif
|
||||
}
|
||||
|
||||
uint64_t
|
||||
tr_htonll( uint64_t v )
|
||||
tr_ntohll( uint64_t x )
|
||||
{
|
||||
#ifdef HAVE_HTONLL
|
||||
return htonll( v );
|
||||
#ifdef HAVE_NTOHLL
|
||||
return ntohll( x );
|
||||
#else
|
||||
union { unsigned long lv[2]; unsigned long long llv; } u;
|
||||
u.lv[0] = htonl(v >> 32);
|
||||
u.lv[1] = htonl(v & 0xFFFFFFFFULL);
|
||||
return u.llv;
|
||||
return (((uint64_t)(ntohl((int)((x << 32) >> 32))) << 32) |
|
||||
(unsigned int)ntohl(((int)(x >> 32))));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue