From bcde0fc7217091410941eb53267ebf4faac395fd Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Tue, 7 Aug 2012 00:18:34 +0000 Subject: [PATCH] move OSX compatible exception to a common "endian_compat.h" header --- fel.c | 10 +--------- include/endian_compat.h | 14 ++++++++++++++ phoenix_info.c | 3 ++- pio.c | 2 +- 4 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 include/endian_compat.h diff --git a/fel.c b/fel.c index 6187ec0..5813935 100644 --- a/fel.c +++ b/fel.c @@ -29,15 +29,7 @@ #include #include -#ifdef __APPLE__ -#include -#define htole32(x) CFSwapInt32HostToLittle(x) -#define le32toh(x) CFSwapInt32LittleToHost(x) -#define htole16(x) CFSwapInt16HostToLittle(x) -#define le16toh(x) CFSwapInt16LittleToHost(x) -#else -#include -#endif +#include "endian_compat.h" int errno; diff --git a/include/endian_compat.h b/include/endian_compat.h new file mode 100644 index 0000000..f141371 --- /dev/null +++ b/include/endian_compat.h @@ -0,0 +1,14 @@ +#ifndef SUNXI_ENDIAN_COMPAT_H_ +#define SUNXI_ENDIAN_COMPAT_H_ + +#ifdef __APPLE__ +#include +#define htole32(x) CFSwapInt32HostToLittle(x) +#define le32toh(x) CFSwapInt32LittleToHost(x) +#define htole16(x) CFSwapInt16HostToLittle(x) +#define le16toh(x) CFSwapInt16LittleToHost(x) +#else +#include +#endif + +#endif diff --git a/phoenix_info.c b/phoenix_info.c index 5264c3f..b76c5e4 100644 --- a/phoenix_info.c +++ b/phoenix_info.c @@ -21,9 +21,10 @@ #include #include #include -#include #include +#include "endian_compat.h" + struct phoenix_ptable { char signature[16]; /* "PHOENIX_CARD_IMG" */ unsigned int unknown1; /* 0x00200100 */ diff --git a/pio.c b/pio.c index 7f0afb6..f8827e1 100644 --- a/pio.c +++ b/pio.c @@ -9,7 +9,7 @@ #include #include -#include +#include "endian_compat.h" #define PIO_REG_SIZE 0x228 /*0x300*/ #define PIO_PORT_SIZE 0x24