[Cryptech-Commits] [sw/stm32] 04/11: Do the proper endianness dance for htonl.

git at cryptech.is git at cryptech.is
Mon Nov 16 21:43:06 UTC 2015


This is an automated email from the git hooks/post-receive script.

paul at psgd.org pushed a commit to branch master
in repository sw/stm32.

commit ef3fd926a81ccd99109a0d95a1d79d6ceff3a84c
Author: Paul Selkirk <paul at psgd.org>
Date:   Tue Nov 10 17:31:14 2015 -0500

    Do the proper endianness dance for htonl.
---
 hal_io_fmc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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)



More information about the Commits mailing list