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
This commit is contained in:
XANTRONIX Development 2020-07-30 22:27:38 -04:00 committed by XANTRONIX Industrial
parent 09df948871
commit c321f6150e
2 changed files with 16 additions and 4 deletions

19
configure vendored
View file

@ -17,11 +17,22 @@ create_darwin_config_h() {
cat <<EOF > src/config.h
#ifndef _CONFIG_H
#define _CONFIG_H
#include <architecture/byte_order.h>
#include <libkern/OSByteOrder.h>
#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
}

View file

@ -3,6 +3,7 @@
#include <errno.h>
#include <patty/ax25.h>
#include "config.h"
static ssize_t decode_station(patty_ax25_addr *addr,
void *data,