From 95f6dc70118ea711e13de79300a8a052bbd7e0ed Mon Sep 17 00:00:00 2001 From: goldsimon Date: Wed, 6 May 2009 17:35:50 +0000 Subject: [PATCH] On little endian architectures, use LWIP_PLATFORM_HTONS (if defined) for SWAP_BYTES_IN_WORD to speed up checksumming. --- CHANGELOG | 4 ++++ src/core/ipv4/inet_chksum.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index ce0f6960..0207262d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -99,6 +99,10 @@ HISTORY ++ Bugfixes: + 2009-05-06 Simon Goldschmidt + * inet_chksum.c: On little endian architectures, use LWIP_PLATFORM_HTONS (if + defined) for SWAP_BYTES_IN_WORD to speed up checksumming. + 2009-05-05 Simon Goldschmidt * sockets.c: bug #26405: Prematurely released semaphore causes lwip_select() to crash diff --git a/src/core/ipv4/inet_chksum.c b/src/core/ipv4/inet_chksum.c index 439c9760..a30a1834 100644 --- a/src/core/ipv4/inet_chksum.c +++ b/src/core/ipv4/inet_chksum.c @@ -64,7 +64,14 @@ #endif /** Like the name says... */ +#if LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) +/* little endian and PLATFORM_BYTESWAP defined */ +#define SWAP_BYTES_IN_WORD(w) LWIP_PLATFORM_HTONS(x) +#else +/* can't use htons on big endian (or PLATFORM_BYTESWAP not defined)... */ #define SWAP_BYTES_IN_WORD(w) ((w & 0xff) << 8) | ((w & 0xff00) >> 8) +#endif + /** Split an u32_t in two u16_ts and add them up */ #define FOLD_U32T(u) ((u >> 16) + (u & 0x0000ffffUL))