From 7a031e5669994a4ceb16b291330d5931a3269ee1 Mon Sep 17 00:00:00 2001
From: Thomas Eichinger <thomas.eichinger1@gmail.com>
Date: Wed, 14 May 2014 16:06:58 +0200
Subject: [PATCH] net: handle macro redefinitions for OS X

undefine macros and reorder header includes to get rid of system
defined macros on OS X

fixes #1165
---
 cpu/native/include/clang_compat.h    | 20 ++++++++++++++++++++
 sys/net/include/net_help.h           |  4 ++++
 sys/net/include/sixlowpan/ip.h       |  2 +-
 sys/net/link_layer/net_if/net_if.c   |  2 +-
 sys/net/network_layer/sixlowpan/ip.c |  1 -
 5 files changed, 26 insertions(+), 3 deletions(-)
 create mode 100644 cpu/native/include/clang_compat.h

diff --git a/cpu/native/include/clang_compat.h b/cpu/native/include/clang_compat.h
new file mode 100644
index 0000000000..0a92e60bec
--- /dev/null
+++ b/cpu/native/include/clang_compat.h
@@ -0,0 +1,20 @@
+/*
+ * clang_compat.h Undefines macros of clang on OSX to use RIOT's macros
+ *
+ * Copyright (C) 2014 Thomas Eichinger <thomas.eichinger@fu-berlin.de>
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser General
+ * Public License. See the file LICENSE in the top level directory for more
+ * details.
+ */
+
+#ifndef __CLANG_COMPAT_H
+
+#undef HTONS
+#undef HTONL
+#undef HTONLL
+#undef NTOHS
+#undef NTOHL
+#undef NTOHLL
+
+#endif
diff --git a/sys/net/include/net_help.h b/sys/net/include/net_help.h
index 03d890b711..25cc78c069 100644
--- a/sys/net/include/net_help.h
+++ b/sys/net/include/net_help.h
@@ -15,6 +15,10 @@
 #include <string.h>
 #include <stdint.h>
 
+#if defined(__MACH__)
+#include "clang_compat.h"
+#endif
+
 #define BITSET(var,pos) ((var) & (1<<(pos)))
 #define HTONS(a) ((((uint16_t) (a) >> 8) & 0xff) | ((((uint16_t) (a)) & 0xff) << 8))
 #define HTONL(a) ((((uint32_t) (a) & 0xff000000) >> 24) | \
diff --git a/sys/net/include/sixlowpan/ip.h b/sys/net/include/sixlowpan/ip.h
index aaf41c44ac..a6782aa395 100644
--- a/sys/net/include/sixlowpan/ip.h
+++ b/sys/net/include/sixlowpan/ip.h
@@ -25,8 +25,8 @@
 #include <stdint.h>
 
 #include "inet_ntop.h"
-#include "net_help.h"
 #include "net_if.h"
+#include "net_help.h"
 #include "sixlowpan/types.h"
 
 /**
diff --git a/sys/net/link_layer/net_if/net_if.c b/sys/net/link_layer/net_if/net_if.c
index 4ded2494a5..533bb095d0 100644
--- a/sys/net/link_layer/net_if/net_if.c
+++ b/sys/net/link_layer/net_if/net_if.c
@@ -18,10 +18,10 @@
 #include "ieee802154_frame.h"
 #include "msg.h"
 #include "mutex.h"
-#include "net_help.h"
 #include "transceiver.h"
 
 #include "net_if.h"
+#include "net_help.h"
 
 #define ENABLE_DEBUG    (0)
 #if ENABLE_DEBUG
diff --git a/sys/net/network_layer/sixlowpan/ip.c b/sys/net/network_layer/sixlowpan/ip.c
index 5ef2b6761c..1c7d6928af 100644
--- a/sys/net/network_layer/sixlowpan/ip.c
+++ b/sys/net/network_layer/sixlowpan/ip.c
@@ -25,7 +25,6 @@
 #include "vtimer.h"
 #include "mutex.h"
 #include "msg.h"
-#include "net_help.h"
 #include "net_if.h"
 #include "sixlowpan/mac.h"
 
-- 
GitLab