Fix build on systems that already have ntohll/htonll

BIT-1234 #close
This commit is contained in:
Jon Siwek 2014-08-22 19:56:27 -05:00
parent 66ae2ac72c
commit 4a3434675f
3 changed files with 10 additions and 0 deletions

View file

@ -165,6 +165,8 @@ set(brodeps
include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)
include(CheckSymbolExists)
check_symbol_exists(htonll arpa/inet.h HAVE_BYTEORDER_64)
include(OSSpecific)
include(CheckTypes)

View file

@ -129,6 +129,9 @@
/* whether words are stored with the most significant byte first */
#cmakedefine WORDS_BIGENDIAN
/* whether htonll/ntohll is defined in <arpa/inet.h> */
#cmakedefine HAVE_BYTEORDER_64
/* ultrix can't hack const */
#cmakedefine NEED_ULTRIX_CONST_HACK
#ifdef NEED_ULTRIX_CONST_HACK

View file

@ -180,8 +180,11 @@ extern uint32 extract_uint32(const u_char* data);
inline double ntohd(double d) { return d; }
inline double htond(double d) { return d; }
#ifndef HAVE_BYTEORDER_64
inline uint64 ntohll(uint64 i) { return i; }
inline uint64 htonll(uint64 i) { return i; }
#endif
#else
@ -207,6 +210,7 @@ inline double ntohd(double d)
inline double htond(double d) { return ntohd(d); }
#ifndef HAVE_BYTEORDER_64
inline uint64 ntohll(uint64 i)
{
u_char c;
@ -224,6 +228,7 @@ inline uint64 ntohll(uint64 i)
}
inline uint64 htonll(uint64 i) { return ntohll(i); }
#endif
#endif