From 05bcc73f8d4c53b115252926cf29b39cb4cfcc34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Nadeau?= Date: Mon, 18 Mar 2019 21:52:33 -0400 Subject: [PATCH] Add REVERSED bitfield definition for big endian processors #170 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Frédéric Nadeau --- MQTTPacket/src/MQTTConnect.h | 9 ++++++++- MQTTPacket/src/MQTTPacket.h | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/MQTTPacket/src/MQTTConnect.h b/MQTTPacket/src/MQTTConnect.h index 98c2c164..2c83b5b3 100644 --- a/MQTTPacket/src/MQTTConnect.h +++ b/MQTTPacket/src/MQTTConnect.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2017 IBM Corp. + * Copyright (c) 2014, 2019 IBM Corp. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -37,6 +37,13 @@ enum connack_return_codes #define DLLExport #endif +#if defined(__linux__) +#include +#if __BYTE_ORDER == __BIG_ENDIAN + #define REVERSED 1 +#endif +#endif + typedef union { diff --git a/MQTTPacket/src/MQTTPacket.h b/MQTTPacket/src/MQTTPacket.h index 0ee46231..ea4346a0 100644 --- a/MQTTPacket/src/MQTTPacket.h +++ b/MQTTPacket/src/MQTTPacket.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014 IBM Corp. + * Copyright (c) 2014, 2019 IBM Corp. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -13,6 +13,7 @@ * Contributors: * Ian Craggs - initial API and implementation and/or initial documentation * Xiang Rong - 442039 Add makefile to Embedded C client + * Ian Craggs - big endian Linux reversed definition *******************************************************************************/ #ifndef MQTTPACKET_H_ @@ -33,6 +34,14 @@ extern "C" { #define DLLExport #endif +#if defined(__linux__) +#include +#if __BYTE_ORDER == __BIG_ENDIAN + #define REVERSED 1 +#endif +#endif + + enum errors { MQTTPACKET_BUFFER_TOO_SHORT = -2,