From 05419912e0bdb8c3396044f9eaf1433b574ce606 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Thu, 6 Oct 2016 13:13:10 +0200 Subject: [PATCH] def.h: Provide hton* / ntoh* functions to users by default for compatibility (can be turned off) Add note to UPGRADING document --- UPGRADING | 4 ++++ src/include/lwip/def.h | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/UPGRADING b/UPGRADING index d2cd1f26..c42c67d1 100644 --- a/UPGRADING +++ b/UPGRADING @@ -49,6 +49,10 @@ with newer versions. * Added generalized abstraction for itoa(), strnicmp(), stricmp() and strnstr() in def.h (to be overridden in cc.h) instead of config options for netbiosns, httpd, dns, etc. ... + * New abstraction for hton* and ntoh* functions in def.h. + To override them, use the following in cc.h: + #define lwip_htons(x) + #define lwip_htonl(x) +++ new options: * TODO diff --git a/src/include/lwip/def.h b/src/include/lwip/def.h index aafbd7cc..bb07009c 100644 --- a/src/include/lwip/def.h +++ b/src/include/lwip/def.h @@ -92,6 +92,14 @@ u32_t lwip_htonl(u32_t x); #endif #define lwip_ntohl(x) lwip_htonl(x) +/* Provide usual function names as macros for users, but this can be turned off */ +#ifndef LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS +#define htons(x) lwip_htons(x) +#define ntohs(x) lwip_ntohs(x) +#define htonl(x) lwip_htonl(x) +#define ntohl(x) lwip_ntohl(x) +#endif + /* These macros should be calculated by the preprocessor and are used with compile-time constants only (so that there is no little-endian overhead at runtime). */