mirror of
git://git.openwrt.org/openwrt/openwrt.git
synced 2024-12-18 21:05:26 +00:00
99ddff0c7f
- 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@darbyshire-bryant.me.uk>
41 lines
952 B
C
41 lines
952 B
C
#ifndef __endian_compat_h
|
|
#define __endian_compat_h
|
|
|
|
#if defined(__linux__) || defined(__CYGWIN__)
|
|
#include <byteswap.h>
|
|
#include_next <endian.h>
|
|
#elif defined(__APPLE__)
|
|
#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)
|
|
#define bswap_32(x) bswap32(x)
|
|
#define bswap_64(x) bswap64(x)
|
|
#elif defined(__OpenBSD__)
|
|
#include <sys/types.h>
|
|
#define bswap_16(x) __swap16(x)
|
|
#define bswap_32(x) __swap32(x)
|
|
#define bswap_64(x) __swap64(x)
|
|
#else
|
|
#include <machine/endian.h>
|
|
#define bswap_16(x) swap16(x)
|
|
#define bswap_32(x) swap32(x)
|
|
#define bswap_64(x) swap64(x)
|
|
#endif
|
|
|
|
#ifndef __BYTE_ORDER
|
|
#define __BYTE_ORDER BYTE_ORDER
|
|
#endif
|
|
#ifndef __BIG_ENDIAN
|
|
#define __BIG_ENDIAN BIG_ENDIAN
|
|
#endif
|
|
#ifndef __LITTLE_ENDIAN
|
|
#define __LITTLE_ENDIAN LITTLE_ENDIAN
|
|
#endif
|
|
|
|
#endif
|