Skip to content

Commit

Permalink
Assume little-endian unless otherwise determined
Browse files Browse the repository at this point in the history
Big-endian is almost gone from the world, so this is the safer default.
  • Loading branch information
dfandrich committed Sep 21, 2023
1 parent 2feac84 commit 540adee
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cbmarcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@
#endif
#endif

#if ((defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) \
|| (defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN)) \
&& !defined(IS_BIG_ENDIAN)
/* little-endian conversion macros */
#define CF_LE_W(n) (n)
#define CF_LE_L(n) (n)
#else
#if (defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN) \
|| (defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN) \
|| defined(IS_BIG_ENDIAN)
/* big-endian conversion macros */
#define CF_LE_W(n) ((((n) & 0xff) << 8) | (((n) & 0xff00) >> 8))
#define CF_LE_L(n) ((((n) & 0xff) << 24) | (((n) & 0xff00) << 8) | \
(((n) & 0xff0000L) >> 8) | (((n) & 0xff000000L) >> 24))
#else
/* little-endian conversion macros */
#define CF_LE_W(n) (n)
#define CF_LE_L(n) (n)
#endif

#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
Expand Down

0 comments on commit 540adee

Please sign in to comment.