lwIP 2.0.0  lwIP 2.0.0
LightweightIPstack
arch.h File Reference
#include "arch/cc.h"
#include <stdint.h>
#include <inttypes.h>

Macros

#define LWIP_NO_STDINT_H   0
 
#define LWIP_NO_INTTYPES_H   0
 
#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size)   u8_t variable_name[LWIP_MEM_ALIGN_BUFFER(size)]
 
#define LWIP_MEM_ALIGN_SIZE(size)   (((size) + MEM_ALIGNMENT - 1U) & ~(MEM_ALIGNMENT-1U))
 
#define LWIP_MEM_ALIGN_BUFFER(size)   (((size) + MEM_ALIGNMENT - 1U))
 
#define LWIP_MEM_ALIGN(addr)   ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1)))
 

Detailed Description

Support for different processor and compiler architectures

Macro Definition Documentation

#define LWIP_DECLARE_MEMORY_ALIGNED (   variable_name,
  size 
)    u8_t variable_name[LWIP_MEM_ALIGN_BUFFER(size)]

Allocates a memory buffer of specified size that is of sufficient size to align its start address using LWIP_MEM_ALIGN. You can declare your own version here e.g. to enforce alignment without adding trailing padding bytes (see LWIP_MEM_ALIGN_BUFFER) or your own section placement requirements. e.g. if you use gcc and need 32 bit alignment: #define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u8_t variable_name[size] attribute((aligned(4))) or more portable: #define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u32_t variable_name[(size + sizeof(u32_t) - 1) / sizeof(u32_t)]

#define LWIP_MEM_ALIGN (   addr)    ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1)))

Align a memory pointer to the alignment defined by MEM_ALIGNMENT so that ADDR % MEM_ALIGNMENT == 0

#define LWIP_MEM_ALIGN_BUFFER (   size)    (((size) + MEM_ALIGNMENT - 1U))

Calculate safe memory size for an aligned buffer when using an unaligned type as storage. This includes a safety-margin on (MEM_ALIGNMENT - 1) at the start (e.g. if buffer is u8_t[] and actual data will be u32_t*)

#define LWIP_MEM_ALIGN_SIZE (   size)    (((size) + MEM_ALIGNMENT - 1U) & ~(MEM_ALIGNMENT-1U))

Calculate memory size for an aligned buffer - returns the next highest multiple of MEM_ALIGNMENT (e.g. LWIP_MEM_ALIGN_SIZE(3) and LWIP_MEM_ALIGN_SIZE(4) will both yield 4 for MEM_ALIGNMENT == 4).

#define LWIP_NO_INTTYPES_H   0

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).

#define LWIP_NO_STDINT_H   0

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).