From 566285fa4be8506305a2bc6b1c492d1fa2c5a41a Mon Sep 17 00:00:00 2001 From: Leandre Gohy Date: Thu, 19 Nov 2020 11:31:56 +0100 Subject: [PATCH] Allows eepdump and eepmake to be compiled on Mac OS Mac OS X doesn't provide `endian.h`. It's only required for the `be32toh` and `htobe32` utility functions. Mac OS X provides similare functions in `libkern/OSByteOrder.h`. Respectively `OSSwapHostToBigInt32` for `htobe32` and `OSSwapBigToHostInt32` for `be32toh`. This adds a preprocessor condition to include `endian.h` on non apple system and to include `libkern/OSByteOrder.h` as well as defining to macro to provide `htobe32` and `be32toh` on apple plateform. --- eepromutils/eepdump.c | 9 ++++++++- eepromutils/eepmake.c | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/eepromutils/eepdump.c b/eepromutils/eepdump.c index bc0c5d1..1a75ed6 100644 --- a/eepromutils/eepdump.c +++ b/eepromutils/eepdump.c @@ -3,7 +3,14 @@ #include #include #include -#include + +#ifndef __APPLE__ + #include +#else + #include + #define htobe32(x) OSSwapHostToBigInt32(x) + #define be32toh(x) OSSwapBigToHostInt32(x) +#endif #include "eeptypes.h" diff --git a/eepromutils/eepmake.c b/eepromutils/eepmake.c index 8cd5369..03531c2 100644 --- a/eepromutils/eepmake.c +++ b/eepromutils/eepmake.c @@ -11,6 +11,14 @@ #include #include +#ifndef __APPLE__ + #include +#else + #include + #define htole32(x) OSSwapHostToLittleInt32(x) + #define be32toh(x) OSSwapBigToHostInt32(x) +#endif + #include "eeptypes.h" //todo: larger initial mallocs