laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ggsn/+/43582?usp=email )
Change subject: gtp: define htobe64 and be64toh on Darwin ......................................................................
gtp: define htobe64 and be64toh on Darwin
gtp/gtp.c converts the GTPv0 TID with htobe64() and be64toh(). glibc declares both in <endian.h>, FreeBSD in <sys/endian.h>, and the file already has a branch for the FreeBSD spelling. Darwin has neither header, so the build of libgtp stops with "call to undeclared function 'be64toh'".
Add an __APPLE__ branch next to the existing FreeBSD one, mapping both names to the OSSwap macros from <libkern/OSByteOrder.h>, which is where Darwin keeps the fixed-width byte swaps. Nothing outside the new branch changes.
Change-Id: I8a687ab94315878f1eaa8a4e68628084fd385c75 Signed-off-by: Andrei Gosman andrei.gosman@gmail.com --- M gtp/gtp.c 1 file changed, 6 insertions(+), 0 deletions(-)
Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve laforge: Looks good to me, approved
diff --git a/gtp/gtp.c b/gtp/gtp.c index f378c17..f5adccd 100644 --- a/gtp/gtp.c +++ b/gtp/gtp.c @@ -30,6 +30,12 @@
#if defined(__FreeBSD__) #include <sys/endian.h> +#elif defined(__APPLE__) +/* Darwin has neither <endian.h> nor <sys/endian.h>; the 64 bit swaps + * used for the GTPv0 TID come from libkern. */ +#include <libkern/OSByteOrder.h> +#define htobe64(x) OSSwapHostToBigInt64(x) +#define be64toh(x) OSSwapBigToHostInt64(x) #endif
#include "../config.h"