Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Commit

Permalink
fixed compilation problem with htonll() on 32 bit systems.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Caputi committed Feb 22, 2016
1 parent 8077eca commit 83f64a7
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions include/sys/byteorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,25 @@
(((uint32_t)BE_IN16(xa) << 16) | BE_IN16((uint8_t *)(xa)+2))

#ifdef _BIG_ENDIAN
#define htonll(x) (x)
#define ntohll(x) (x)
static __inline__ uint64_t
htonll(uint64_t n) {
return (n);
}

static __inline__ uint64_t
ntohll(uint64_t n){
return (n);
}
#else
#define htonll(x) ((((uint64_t)htonl(x)) << 32) + htonl((x) >> 32))
#define ntohll(x) ((((uint64_t)ntohl(x)) << 32) + ntohl((x) >> 32))
static __inline__ uint64_t
htonll(uint64_t n) {
return ((((uint64_t)htonl(n)) << 32) + htonl(n >> 32));
}

static __inline__ uint64_t
ntohll(uint64_t n){
return ((((uint64_t)ntohl(n)) << 32) + ntohl(n >> 32));
}
#endif

#endif /* SPL_BYTEORDER_H */

0 comments on commit 83f64a7

Please sign in to comment.