mirror of
https://github.com/transmission/transmission
synced 2025-02-22 22:20:39 +00:00
Portability fix (platforms such as sparc64 need uint32_t pointers to be
32-bits aligned) Patch by Christian Weisgerber
This commit is contained in:
parent
0cc1576999
commit
d598822024
1 changed files with 14 additions and 2 deletions
|
@ -68,8 +68,20 @@
|
|||
|
||||
/* Convenient macros to perform uint32_t endian conversions with
|
||||
char pointers */
|
||||
#define TR_NTOHL(p,a) (a) = ntohl(*((uint32_t*)(p)))
|
||||
#define TR_HTONL(a,p) *((uint32_t*)(p)) = htonl((a))
|
||||
#define TR_NTOHL(p,a) (a) = tr_ntohl((p))
|
||||
#define TR_HTONL(a,p) tr_htonl((a), (p))
|
||||
static inline uint32_t tr_ntohl( uint8_t * p )
|
||||
{
|
||||
uint32_t u;
|
||||
memcpy( &u, p, sizeof( uint32_t ) );
|
||||
return ntohl( u );
|
||||
}
|
||||
static inline void tr_htonl( uint32_t a, uint8_t * p )
|
||||
{
|
||||
uint32_t u;
|
||||
u = htonl( a );
|
||||
memcpy ( p, &u, sizeof( uint32_t ) );
|
||||
}
|
||||
|
||||
/* Sometimes the system defines MAX/MIN, sometimes not. In the latter
|
||||
case, define those here since we will use them */
|
||||
|
|
Loading…
Reference in a new issue