[OpenWrt-Devel] [PATCH] tools: Update endian definitions for Mac OSX

Kevin 'ldir' Darbyshire-Bryant ldir at darbyshire-bryant.me.uk
Tue Dec 18 07:49:28 EST 2018


  - it appears (at least from OS X verison 10.10, Yosemite) that the
    big and little endian defintions have changed.

    the older

       #include <sys/_endian.h>
       #include <architecture/byte_order.h>

    reference yielded the following warning:

         #define __bswap_16(x)      NXSwapShort(x)
                                    ^
       /usr/include/architecture/byte_order.h:45:1: note: 'NXSwapShort' has been explicitly marked deprecated here

    For the new OS X editions, it seems that we need to refer to:

      #include <netinet/in.h>
      #include <libkern/OSByteOrder.h>

    and respectively use 'OSSwapInt16', 'OSSwapInt32', & 'OSSwapInt64', in
    place of 'NXSwapShort', 'NXSwapLong' & 'NXSwapLongLong'.

Signed-off-by: Kevin Darbyshire-Bryant <ldir at darbyshire-bryant.me.uk>
---
 tools/include/endian.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/include/endian.h b/tools/include/endian.h
index bba70abd83..e2ac755667 100644
--- a/tools/include/endian.h
+++ b/tools/include/endian.h
@@ -5,11 +5,11 @@
 #include <byteswap.h>
 #include_next <endian.h>
 #elif defined(__APPLE__)
-#include <machine/endian.h>
-#include <machine/byte_order.h>
-#define bswap_16(x) NXSwapShort(x)
-#define bswap_32(x) NXSwapInt(x)
-#define bswap_64(x) NXSwapLongLong(x)
+#include <netinet/in.h>
+#include <libkern/OSByteOrder.h>
+#define bswap_16(x) OSSwapInt16(x)
+#define bswap_32(x) OSSwapInt32(x)
+#define bswap_64(x) OSSwapInt64(x)
 #elif defined(__FreeBSD__)
 #include <sys/endian.h>
 #define bswap_16(x) bswap16(x)
-- 
2.17.2 (Apple Git-113)


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list