From 4a3434675f8a22c67dae3e36cdf289881d0b262e Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Fri, 22 Aug 2014 19:56:27 -0500 Subject: [PATCH] Fix build on systems that already have ntohll/htonll BIT-1234 #close --- CMakeLists.txt | 2 ++ config.h.in | 3 +++ src/net_util.h | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87b99271c5..a261e38ffc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/config.h.in b/config.h.in index 2d065f755e..eb7a14b219 100644 --- a/config.h.in +++ b/config.h.in @@ -129,6 +129,9 @@ /* whether words are stored with the most significant byte first */ #cmakedefine WORDS_BIGENDIAN +/* whether htonll/ntohll is defined in */ +#cmakedefine HAVE_BYTEORDER_64 + /* ultrix can't hack const */ #cmakedefine NEED_ULTRIX_CONST_HACK #ifdef NEED_ULTRIX_CONST_HACK diff --git a/src/net_util.h b/src/net_util.h index 0f34335267..d68a7110ce 100644 --- a/src/net_util.h +++ b/src/net_util.h @@ -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