diff options
author | Paul Selkirk <paul@psgd.org> | 2015-11-10 17:31:14 -0500 |
---|---|---|
committer | Paul Selkirk <paul@psgd.org> | 2015-11-10 17:31:14 -0500 |
commit | ef3fd926a81ccd99109a0d95a1d79d6ceff3a84c (patch) | |
tree | 4e81d3626cb54751832aa4d293edf645e196cbe9 | |
parent | bce99ca97c0d53db2e0c4eadd23e1a4d5e60ebbc (diff) |
Do the proper endianness dance for htonl.
-rw-r--r-- | hal_io_fmc.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/hal_io_fmc.c b/hal_io_fmc.c index 386e4c8..afbfc6e 100644 --- a/hal_io_fmc.c +++ b/hal_io_fmc.c @@ -47,7 +47,8 @@ static int inited = 0; #endif /* not available in arm-none-eabi libc */ -static uint32_t htonl(uint32_t w) +#ifndef __ARMEB__ // Little endian +static inline uint32_t htonl(uint32_t w) { return ((w & 0x000000ff) << 24) + @@ -55,6 +56,9 @@ static uint32_t htonl(uint32_t w) ((w & 0x00ff0000) >> 8) + ((w & 0xff000000) >> 24); } +#else // Big endian +#define htonl(x) (x) +#endif #define ntohl htonl static hal_error_t init(void) |