laforge submitted this change.

View Change

Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve laforge: Looks good to me, approved
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(-)

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"

To view, visit change 43582. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: I8a687ab94315878f1eaa8a4e68628084fd385c75
Gerrit-Change-Number: 43582
Gerrit-PatchSet: 2
Gerrit-Owner: Andrei G <andrei.gosman@gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>