diff --git a/src/inspect-apps.c b/src/inspect-apps.c index 20cf00a0d..8fbae9c6f 100644 --- a/src/inspect-apps.c +++ b/src/inspect-apps.c @@ -35,11 +35,22 @@ #include #endif -/* be32toh is usually a macro definend in , but it might be +/* be32toh is usually a macro defined in , but it might be * a function in some system so check both, and if neither is defined * then define be32toh for RHEL 5. */ #if !defined(HAVE_BE32TOH) && !defined(be32toh) + +#if defined __APPLE__ && defined __MACH__ +/* Define/include necessary items on MacOS X */ +#include +#define __BIG_ENDIAN BIG_ENDIAN +#define __LITTLE_ENDIAN LITTLE_ENDIAN +#define __BYTE_ORDER BYTE_ORDER +#include +#define __bswap_32 OSSwapConstInt32 +#endif /* __APPLE__ */ + #if __BYTE_ORDER == __LITTLE_ENDIAN #define be32toh(x) __bswap_32 (x) #else diff --git a/src/inspect-fs-windows.c b/src/inspect-fs-windows.c index 682157ace..421a5b11b 100644 --- a/src/inspect-fs-windows.c +++ b/src/inspect-fs-windows.c @@ -36,6 +36,12 @@ #include #endif +#if defined __APPLE__ && defined __MACH__ +#include +#define le32toh(x) OSSwapLittleToHostInt32(x) +#define le64toh(x) OSSwapLittleToHostInt64(x) +#endif + #include #include "c-ctype.h" diff --git a/src/journal.c b/src/journal.c index 10700674d..c563b7f27 100644 --- a/src/journal.c +++ b/src/journal.c @@ -35,6 +35,11 @@ #include #endif +#if defined __APPLE__ && defined __MACH__ +#include +#define be64toh(x) OSSwapBigToHostInt64(x) +#endif + #include "full-read.h" #include "guestfs.h"