#20 mac osx needs machine/endian.h inclusion

open
nobody
core (9)
5
2014-08-23
2008-03-19
Sebastian Spaeth
No

src/endianness.h contains #include <endian.h> which is machine/endian.h on Mac OSX. It also includes byteswap.h which does not exist at all on Mac OSX, making compilation impossible.

I found this patch that works around it (http://wiki.openmoko.org/wiki/User:SNMoore#Patch_to_work_around_byteswap.h_and_endian.h_errors_on_OS_X)

Patch to work around byteswap.h and endian.h errors on OS X

-#include <byteswap.h>
-#include <endian.h>
+
+#ifndef _BYTESWAP_H
+#define _BYTESWAP_H
+
+//#warning "byteswap.h is an unportable GNU extension! Don't use!"
+
+static inline unsigned short bswap_16(unsigned short x) {
+ return (x>>8) | (x<<8);
+}
+
+static inline unsigned int bswap_32(unsigned int x) {
+ return (bswap_16(x&0xffff)<<16) | (bswap_16(x>>16));
+}
+
+static inline unsigned long long bswap_64(unsigned long long x) {
+ return (((unsigned long long)bswap_32(x&0xffffffffull))<<32) |
+(bswap_32(x>>32));
+}
+
+#endif
+
+
+#include <machine/endian.h>

Discussion