Skip to content

Commit

Permalink
Merge pull request nasa#1218 from jphickey/fix-1217-bit-order
Browse files Browse the repository at this point in the history
Fix nasa#1217, bit order macros
  • Loading branch information
astrogeco authored Mar 18, 2021
2 parents fa10af7 + a00a788 commit b44c4b6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions modules/core_api/fsw/inc/cfe_endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,30 @@
*/
#include "common_types.h"

/*
* SOFTWARE_BIG/LITTLE_BIT_ORDER COMPATIBILITY MACRO -
*
* This is provided only for backward compatibilty. Do not write any new code that
* uses this macro.
*/
#if !defined(SOFTWARE_BIG_BIT_ORDER) && !defined(SOFTWARE_LITTLE_BIT_ORDER)

#if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || \
defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__)
/* It is a big-endian target architecture */
#define SOFTWARE_BIG_BIT_ORDER
#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || \
defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) || \
defined(__i386) || defined(__i386__) || defined(__i686) || defined(__i686__) || defined(__x86_64) || \
defined(__x86_64__)
/* It is a little-endian target architecture */
#define SOFTWARE_LITTLE_BIT_ORDER
#else
#error Unknown byte order on this platform
#endif

#endif /* !defined(SOFTWARE_BIG_BIT_ORDER) && !defined(SOFTWARE_LITTLE_BIT_ORDER) */

/* Macro to convert 16/32 bit types from platform "endianness" to Big Endian */
#ifdef SOFTWARE_BIG_BIT_ORDER
#define CFE_MAKE_BIG16(n) (n)
Expand Down

0 comments on commit b44c4b6

Please sign in to comment.