Bugfix/bacnet real endian simplify (#89)

* Remove dependence on endian define

* Make use of existing big_endian function if BACNET_BIG_ENDIAN is not defined

* Add efficient endian macro option if available

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2020-05-24 09:36:21 -05:00
committed by GitHub
parent 764e0e8448
commit cbfa74e48d
25 changed files with 354 additions and 257 deletions
+3 -1
View File
@@ -3,8 +3,9 @@
/** @file bigend.c Determination of Endianess */
#include "bigend.h"
#include "bacnet/basic/sys/bigend.h"
#ifndef BACNET_BIG_ENDIAN
/* Big-Endian systems save the most significant byte first. */
/* Sun and Motorola processors, IBM-370s and PDP-10s are big-endian. */
/* "Network Byte Order" is also know as "Big-Endian Byte Order" */
@@ -46,3 +47,4 @@ int big_endian(void)
return (u.c[sizeof(long) - 1] == 1);
}
#endif
+14 -16
View File
@@ -29,26 +29,24 @@
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifndef BACNET_BIG_ENDIAN
/* GCC */
#ifdef __BYTE_ORDER__
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define BACNET_BIG_ENDIAN 1
#else
#define BACNET_BIG_ENDIAN 0
#endif
#endif
#endif
/* Big-Endian systems save the most significant byte first. */
/* Sun and Motorola processors, IBM-370s and PDP-10s are big-endian. */
/* for example, a 4 byte integer 67305985 is 0x04030201 in hexidecimal. */
/* x[0] = 0x04 */
/* x[1] = 0x03 */
/* x[2] = 0x02 */
/* x[3] = 0x01 */
/* Little-Endian systems save the least significant byte first. */
/* The entire Intel x86 family, Vaxes, Alphas and PDP-11s are little-endian. */
/* for example, a 4 byte integer 67305985 is 0x04030201 in hexidecimal. */
/* x[0] = 0x01 */
/* x[1] = 0x02 */
/* x[2] = 0x03 */
/* x[3] = 0x04 */
#ifdef BACNET_BIG_ENDIAN
#define big_endian() BACNET_BIG_ENDIAN
#else
BACNET_STACK_EXPORT
int big_endian(
void);
#endif
#ifdef __cplusplus
}