From d3e55185c6b34d2d51c780af3c1ee77474572ba3 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Thu, 30 Jun 2016 20:15:22 +0200 Subject: [PATCH] Apply patch #9034: Use stdint.h and inttypes.h in lwip/arch.h Ports now only need to define datatypes and format strings on compilers that do not provide these two headers. Known good: GCC, IAR. Known bad: MSVC 2010. --- src/include/lwip/arch.h | 69 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 8 deletions(-) diff --git a/src/include/lwip/arch.h b/src/include/lwip/arch.h index 261cf8b1..6b541d89 100644 --- a/src/include/lwip/arch.h +++ b/src/include/lwip/arch.h @@ -47,15 +47,68 @@ #include "arch/cc.h" -/** Temporary: define format string for size_t if not defined in cc.h */ -#ifndef SZT_F -#define SZT_F U32_F -#endif /* SZT_F */ -/** Temporary upgrade helper: define format string for u8_t as hex if not - defined in cc.h */ +/** Define this to 1 in arch/cc.h of your port if your compiler does not provide + * the stdint.h header. This cannot be #defined in lwipopts.h since + * this is not an option of lwIP itself, but an option of the lwIP port + * to your system. + * Additionally, this header is meant to be #included in lwipopts.h + * (you may need to declare function prototypes in there). + */ +#ifndef LWIP_NO_STDINT_H +#define LWIP_NO_STDINT_H 0 +#endif + +/* Define generic types used in lwIP */ +#if !LWIP_NO_STDINT_H +#include +typedef uint8_t u8_t; +typedef int8_t s8_t; +typedef uint16_t u16_t; +typedef int16_t s16_t; +typedef uint32_t u32_t; +typedef int32_t s32_t; +typedef uintptr_t mem_ptr_t; +#endif + +/** Define this to 1 in arch/cc.h of your port if your compiler does not provide + * the inttypes.h header. This cannot be #defined in lwipopts.h since + * this is not an option of lwIP itself, but an option of the lwIP port + * to your system. + * Additionally, this header is meant to be #included in lwipopts.h + * (you may need to declare function prototypes in there). + */ +#ifndef LWIP_NO_INTTYPES_H +#define LWIP_NO_INTTYPES_H 0 +#endif + +/* Define (sn)printf formatters for these lwIP types */ +#if !LWIP_NO_INTTYPES_H +#include #ifndef X8_F -#define X8_F "02x" -#endif /* X8_F */ +#define X8_F "02"PRIx8 +#endif +#ifndef U16_F +#define U16_F PRIu16 +#endif +#ifndef S16_F +#define S16_F PRId16 +#endif +#ifndef X16_F +#define X16_F PRIx16 +#endif +#ifndef U32_F +#define U32_F PRIu32 +#endif +#ifndef S32_F +#define S32_F PRId32 +#endif +#ifndef X32_F +#define X32_F PRIx32 +#endif +#ifndef SZT_F +#define SZT_F PRIuMAX +#endif +#endif #ifdef __cplusplus extern "C" {