mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-01 12:24:22 +00:00
Added LWIP_PLATFORM_BYTESWAP optimalisation flag and macro glue.
This commit is contained in:
parent
d9b4ab1658
commit
94abf9d935
@ -19,7 +19,10 @@ HISTORY
|
|||||||
|
|
||||||
(CVS HEAD)
|
(CVS HEAD)
|
||||||
|
|
||||||
* [New changes go here]
|
2006-03-29 Christiaan Simons
|
||||||
|
* inet.c, inet.h: Added platform byteswap support.
|
||||||
|
Added LWIP_PLATFORM_BYTESWAP define (defaults to 0) and
|
||||||
|
optional LWIP_PLATFORM_HTONS(), LWIP_PLATFORM_HTONL() macros.
|
||||||
|
|
||||||
(STABLE-1_1_1)
|
(STABLE-1_1_1)
|
||||||
|
|
||||||
|
@ -489,11 +489,23 @@ char *inet_ntoa(struct in_addr addr)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These are reference implementations of the byte swapping functions.
|
||||||
|
* Again with the aim of being simple, correct and fully portable.
|
||||||
|
* Byte swapping is the second thing you would want to optimize. You will
|
||||||
|
* need to port it to your architecture and in your cc.h:
|
||||||
|
*
|
||||||
|
* #define LWIP_PLATFORM_BYTESWAP 1
|
||||||
|
* #define LWIP_PLATFORM_HTONS(x) <your_htons>
|
||||||
|
* #define LWIP_PLATFORM_HTONL(x) <your_htonl>
|
||||||
|
*
|
||||||
|
* Note ntohs() and ntohl() are merely references to the htonx counterparts.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef BYTE_ORDER
|
#ifndef BYTE_ORDER
|
||||||
#error BYTE_ORDER is not defined
|
#error BYTE_ORDER is not defined
|
||||||
#endif
|
#endif
|
||||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
#if (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN)
|
||||||
|
|
||||||
u16_t
|
u16_t
|
||||||
htons(u16_t n)
|
htons(u16_t n)
|
||||||
@ -522,4 +534,4 @@ ntohl(u32_t n)
|
|||||||
return htonl(n);
|
return htonl(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* BYTE_ORDER == LITTLE_ENDIAN */
|
#endif /* (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) */
|
||||||
|
@ -64,12 +64,16 @@ char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reent
|
|||||||
#undef ntohl
|
#undef ntohl
|
||||||
#endif /* ntohl */
|
#endif /* ntohl */
|
||||||
|
|
||||||
|
#ifndef LWIP_PLATFORM_BYTESWAP
|
||||||
|
#define LWIP_PLATFORM_BYTESWAP 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#if BYTE_ORDER == BIG_ENDIAN
|
#if BYTE_ORDER == BIG_ENDIAN
|
||||||
#define htons(x) (x)
|
#define htons(x) (x)
|
||||||
#define ntohs(x) (x)
|
#define ntohs(x) (x)
|
||||||
#define htonl(x) (x)
|
#define htonl(x) (x)
|
||||||
#define ntohl(x) (x)
|
#define ntohl(x) (x)
|
||||||
#else
|
#else /* BYTE_ORDER != BIG_ENDIAN */
|
||||||
#ifdef LWIP_PREFIX_BYTEORDER_FUNCS
|
#ifdef LWIP_PREFIX_BYTEORDER_FUNCS
|
||||||
/* workaround for naming collisions on some platforms */
|
/* workaround for naming collisions on some platforms */
|
||||||
#define htons lwip_htons
|
#define htons lwip_htons
|
||||||
@ -77,11 +81,19 @@ char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reent
|
|||||||
#define htonl lwip_htonl
|
#define htonl lwip_htonl
|
||||||
#define ntohl lwip_ntohl
|
#define ntohl lwip_ntohl
|
||||||
#endif
|
#endif
|
||||||
|
#if LWIP_PLATFORM_BYTESWAP
|
||||||
|
#define htons(x) LWIP_PLATFORM_HTONS(x)
|
||||||
|
#define ntohs(x) LWIP_PLATFORM_HTONS(x)
|
||||||
|
#define htonl(x) LWIP_PLATFORM_HTONL(x)
|
||||||
|
#define ntohl(x) LWIP_PLATFORM_HTONL(x)
|
||||||
|
#else
|
||||||
u16_t htons(u16_t x);
|
u16_t htons(u16_t x);
|
||||||
u16_t ntohs(u16_t x);
|
u16_t ntohs(u16_t x);
|
||||||
u32_t htonl(u32_t x);
|
u32_t htonl(u32_t x);
|
||||||
u32_t ntohl(u32_t x);
|
u32_t ntohl(u32_t x);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __LWIP_INET_H__ */
|
#endif /* __LWIP_INET_H__ */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user