diff mbox

[v2,4/4] tests/rtas-test.c: fix Apple endian.h include

Message ID 20171031204330.14803-5-danielhb@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Henrique Barboza Oct. 31, 2017, 8:43 p.m. UTC
Recent rtas-test.c changes added a call to 'be32toh', a function
from the header 'endian.h' in Linux. This caused QEMU Travis build
to break because be32toh is undefined in Mac OS (even using the
machine/endian.h header).

This patch makes a conditional code to include the proper header
file if we're compiling in an __APPLE__ env.

Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
---
 tests/rtas-test.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox

Patch

diff --git a/tests/rtas-test.c b/tests/rtas-test.c
index b3538bf878..511980ad17 100644
--- a/tests/rtas-test.c
+++ b/tests/rtas-test.c
@@ -5,6 +5,17 @@ 
 #include "libqos/libqos-spapr.h"
 #include "libqos/rtas.h"
 
+#if defined(__APPLE__)
+#    include <libkern/OSByteOrder.h>
+
+#    define be32toh(x) OSSwapBigToHostInt32(x)
+#    define __BYTE_ORDER    BYTE_ORDER
+#    define __BIG_ENDIAN    BIG_ENDIAN
+#    define __LITTLE_ENDIAN LITTLE_ENDIAN
+#else
+#    include <endian.h>
+#endif
+
 #define EVENT_MASK_EPOW (1 << 30)
 #define EVENT_LOG_LEN 2048