72 |
|
|
73 |
/* i/o functions. */ |
/* i/o functions. */ |
74 |
|
|
|
static inline uint64_t |
|
|
htonll (uint64_t x) |
|
|
{ |
|
75 |
#if BYTE_ORDER == BIG_ENDIAN |
#if BYTE_ORDER == BIG_ENDIAN |
76 |
return x; |
# define htonll(x) (x) |
77 |
#elif BYTE_ORDER == LITTLE_ENDIAN |
#elif BYTE_ORDER == LITTLE_ENDIAN |
78 |
union { uint64_t ll; uint32_t l[2]; } u; |
# include <byteswap.h> |
79 |
u.l[0] = htonl ((uint32_t) (x >> 32)); |
# define htonll(x) (bswap_64 (x)) |
|
u.l[1] = htonl ((uint32_t) x); |
|
|
return u.ll; |
|
80 |
#else |
#else |
81 |
# error what endian? |
# error what endian? |
82 |
#endif |
#endif |
|
} |
|
83 |
#define ntohll htonll |
#define ntohll htonll |
84 |
|
|
85 |
|
|