loci: fix byte swapping on OS X
The endian.h functions don't exist on OS X, so use the LOCI versions instead.
Also change the byte order macro used to one that's defined on both Linux and OS X.
diff --git a/c_gen/c_code_gen.py b/c_gen/c_code_gen.py
index 78a809e..fd6382b 100644
--- a/c_gen/c_code_gen.py
+++ b/c_gen/c_code_gen.py
@@ -731,7 +731,7 @@
#define OF_MATCH_BYTES(length) (((length) + 7) & 0xfff8)
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if __BYTE_ORDER == __ORDER_BIG_ENDIAN
#define U16_NTOH(val) (val)
#define U32_NTOH(val) (val)
#define U64_NTOH(val) (val)
diff --git a/c_gen/templates/_push_wire_types.c b/c_gen/templates/_push_wire_types.c
index 5b16e24..fd2536c 100644
--- a/c_gen/templates/_push_wire_types.c
+++ b/c_gen/templates/_push_wire_types.c
@@ -38,11 +38,11 @@
:: if m.length == 1:
*(uint8_t *)(buf + ${m.offset}) = ${m.value}; /* ${m.name} */
:: elif m.length == 2:
- *(uint16_t *)(buf + ${m.offset}) = htobe16(${m.value}); /* ${m.name} */
+ *(uint16_t *)(buf + ${m.offset}) = U16_HTON(${m.value}); /* ${m.name} */
:: elif m.length == 4:
- *(uint32_t *)(buf + ${m.offset}) = htobe32(${m.value}); /* ${m.name} */
+ *(uint32_t *)(buf + ${m.offset}) = U32_HTON(${m.value}); /* ${m.name} */
:: elif m.length == 8:
- *(uint64_t *)(buf + ${m.offset}) = htobe64(${m.value}); /* ${m.name} */
+ *(uint64_t *)(buf + ${m.offset}) = U64_HTON(${m.value}); /* ${m.name} */
:: else:
:: raise("unsupported push_wire_types length %d" % m.length)
:: #endif