Skip to content

Commit

Permalink
move byte-order macros to portable header file
Browse files Browse the repository at this point in the history
This allows to share the macros accross multiple compile
units.

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
  • Loading branch information
Stefan Agner committed Apr 25, 2018
1 parent 04cd5c4 commit aea7afa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
13 changes: 0 additions & 13 deletions imx_sdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,6 @@

int debugmode = 0;

#ifdef __GNUC__
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define BE32(x) __builtin_bswap32(x)
#define BE16(x) __builtin_bswap16(x)
#else
#define BE32(x) x
#define BE16(x) x
#endif
#elif _MSC_VER // assume little endian...
#define BE32(x) _byteswap_ulong(x)
#define BE16(x) _byteswap_ushort(x)
#endif

#define get_min(a, b) (((a) < (b)) ? (a) : (b))
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))

Expand Down
13 changes: 13 additions & 0 deletions portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,17 @@ extern int debugmode;
#define getcwd(buffer, maxlen) _getcwd(buffer, maxlen)
#endif

#ifdef __GNUC__
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define BE32(x) __builtin_bswap32(x)
#define BE16(x) __builtin_bswap16(x)
#else
#define BE32(x) x
#define BE16(x) x
#endif
#elif _MSC_VER // assume little endian...
#define BE32(x) _byteswap_ulong(x)
#define BE16(x) _byteswap_ushort(x)
#endif

#endif /* __PORTABLE_H__ */

0 comments on commit aea7afa

Please sign in to comment.