The macros in ip6_addr.c are duplicated from ip4_addr.c, so move them to lwIPs portability layer

...didn't see that in the first place...
This commit is contained in:
Dirk Ziegelmeier
2017-11-05 10:27:46 +01:00
parent 93f4245e89
commit 849dfb17c7
3 changed files with 28 additions and 22 deletions

View File

@@ -203,6 +203,29 @@ typedef int ssize_t;
#define SSIZE_MAX INT_MAX
#endif /* SSIZE_MAX */
/** Define this to 1 in arch/cc.h of your port if your compiler does not provide
* the cytype.h header. If ctype.h is available, a few few character functions
* are mapped to the appropriate functions (lwip_islower, lwip_isdigit...), if
* not, a private implementation is provided.
*/
#ifndef LWIP_NO_CTYPE_H
#define LWIP_NO_CTYPE_H 0
#endif
#if LWIP_NO_CTYPE_H
#define lwip_in_range(c, lo, up) ((u8_t)c >= lo && (u8_t)c <= up)
#define lwip_isdigit(c) lwip_in_range(c, '0', '9')
#define lwip_isxdigit(c) (lwip_isdigit(c) || lwip_in_range(c, 'a', 'f') || lwip_in_range(c, 'A', 'F'))
#define lwip_islower(c) lwip_in_range(c, 'a', 'z')
#define lwip_isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v')
#else
#include <ctype.h>
#define lwip_isdigit(c) isdigit(c)
#define lwip_isxdigit(c) isxdigit(c)
#define lwip_islower(c) islower(c)
#define lwip_isspace(c) isspace(c)
#endif
/** C++ const_cast<target_type>(val) equivalent to remove constness from a value (GCC -Wcast-qual) */
#ifndef LWIP_CONST_CAST
#define LWIP_CONST_CAST(target_type, val) ((target_type)((ptrdiff_t)val))