Changeset 233 for trunk/libtransmission


Ignore:
Timestamp:
Apr 22, 2006, 2:27:09 PM (16 years ago)
Author:
titer
Message:

Portability fix (platforms such as sparc64 need uint32_t pointers to be
32-bits aligned)

Patch by Christian Weisgerber

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/internal.h

    r162 r233  
    6969/* Convenient macros to perform uint32_t endian conversions with
    7070   char pointers */
    71 #define TR_NTOHL(p,a) (a) = ntohl(*((uint32_t*)(p)))
    72 #define TR_HTONL(a,p) *((uint32_t*)(p)) = htonl((a))
     71#define TR_NTOHL(p,a) (a) = tr_ntohl((p))
     72#define TR_HTONL(a,p) tr_htonl((a), (p))
     73static inline uint32_t tr_ntohl( uint8_t * p )
     74{
     75        uint32_t u;
     76        memcpy( &u, p, sizeof( uint32_t ) );
     77        return ntohl( u );
     78}
     79static inline void tr_htonl( uint32_t a, uint8_t * p )
     80{
     81        uint32_t u;
     82        u = htonl( a );
     83        memcpy ( p, &u, sizeof( uint32_t ) );
     84}
    7385
    7486/* Sometimes the system defines MAX/MIN, sometimes not. In the latter
Note: See TracChangeset for help on using the changeset viewer.