From c321f6150e7ca5bab1f4f57d7cfa09e6cbff3997 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Thu, 30 Jul 2020 22:27:38 -0400 Subject: [PATCH] Add byte order swapping macros to configure Changes: * Make ./configure generate src/config.h, which will contain the appropriate #include for endian.h, or #defines to provide alternatives * Make sure to include config.h in src/frame.c to allow compiling on macOS --- configure | 19 +++++++++++++++---- src/frame.c | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/configure b/configure index cb952bf..f806682 100755 --- a/configure +++ b/configure @@ -17,11 +17,22 @@ create_darwin_config_h() { cat < src/config.h #ifndef _CONFIG_H #define _CONFIG_H -#include +#include -#ifdef __LITTLE_ENDIAN__ -#define __DO_SWAP_BYTES -#endif /* _DO_SWAP_BYTES */ +#define htobe16(n) OSSwapHostToBigInt16(n) +#define htole16(n) OSSwapHostToLittleInt16(n) +#define be16toh(n) OSSwapBigToHostInt16(n) +#define le16toh(n) OSSwapLittleToHostInt16(n) + +#define htobe32(n) OSSwapHostToBigInt32(n) +#define htole32(n) OSSwapHostToLittleInt32(n) +#define be32toh(n) OSSwapBigToHostInt32(n) +#define le32toh(n) OSSwapLittleToHostInt32(n) + +#define htobe64(n) OSSwapHostToBigInt64(n) +#define htole64(n) OSSwapHostToLittleInt64(n) +#define be64toh(n) OSSwapBigToHostInt64(n) +#define le64toh(n) OSSwapLittleToHostInt64(n) #endif /* _CONFIG_H */ EOF } diff --git a/src/frame.c b/src/frame.c index e4cd565..0886182 100644 --- a/src/frame.c +++ b/src/frame.c @@ -3,6 +3,7 @@ #include #include +#include "config.h" static ssize_t decode_station(patty_ax25_addr *addr, void *data,