ReactOS 0.4.16-dev-258-g81860b4
Compiler/platform abstraction
Collaboration diagram for Compiler/platform abstraction:

Macros

#define BYTE_ORDER   LITTLE_ENDIAN
 
#define LWIP_PLATFORM_DIAG(x)   do {printf x;} while(0)
 
#define LWIP_PLATFORM_ASSERT(x)
 
#define LWIP_NO_STDDEF_H   0
 
#define LWIP_NO_STDINT_H   0
 
#define LWIP_NO_INTTYPES_H   0
 
#define X8_F   "02" PRIx8
 
#define U16_F   PRIu16
 
#define S16_F   PRId16
 
#define X16_F   PRIx16
 
#define U32_F   PRIu32
 
#define S32_F   PRId32
 
#define X32_F   PRIx32
 
#define SZT_F   PRIuPTR
 
#define LWIP_NO_LIMITS_H   0
 
#define SSIZE_MAX   INT_MAX
 
#define LWIP_UINT32_MAX   0xffffffff
 
#define LWIP_NO_CTYPE_H   0
 
#define lwip_isdigit(c)   isdigit((unsigned char)(c))
 
#define lwip_isxdigit(c)   isxdigit((unsigned char)(c))
 
#define lwip_islower(c)   islower((unsigned char)(c))
 
#define lwip_isspace(c)   isspace((unsigned char)(c))
 
#define lwip_isupper(c)   isupper((unsigned char)(c))
 
#define lwip_tolower(c)   tolower((unsigned char)(c))
 
#define lwip_toupper(c)   toupper((unsigned char)(c))
 
#define LWIP_CONST_CAST(target_type, val)   ((target_type)((ptrdiff_t)val))
 
#define LWIP_ALIGNMENT_CAST(target_type, val)   LWIP_CONST_CAST(target_type, val)
 
#define LWIP_PTR_NUMERIC_CAST(target_type, val)   LWIP_CONST_CAST(target_type, val)
 
#define LWIP_PACKED_CAST(target_type, val)   LWIP_CONST_CAST(target_type, val)
 
#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)))
 
#define PACK_STRUCT_BEGIN
 
#define PACK_STRUCT_END
 
#define PACK_STRUCT_STRUCT
 
#define PACK_STRUCT_FIELD(x)   x
 
#define PACK_STRUCT_FLD_8(x)   PACK_STRUCT_FIELD(x)
 
#define PACK_STRUCT_FLD_S(x)   PACK_STRUCT_FIELD(x)
 
#define LWIP_UNUSED_ARG(x)   (void)x
 

Typedefs

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
 
typedef int ssize_t
 

Detailed Description

All defines related to this section must not be placed in lwipopts.h, but in arch/cc.h! If the compiler does not provide memset() this file must include a definition of it, or include a file which defines it. These options cannot be #defined in lwipopts.h since they are not options of lwIP itself, but options of the lwIP port to your system.

Macro Definition Documentation

◆ BYTE_ORDER

#define BYTE_ORDER   LITTLE_ENDIAN

Define the byte order of the system. Needed for conversion of network data to host byte order. Allowed values: LITTLE_ENDIAN and BIG_ENDIAN

Definition at line 67 of file arch.h.

◆ LWIP_ALIGNMENT_CAST

#define LWIP_ALIGNMENT_CAST (   target_type,
  val 
)    LWIP_CONST_CAST(target_type, val)

Get rid of alignment cast warnings (GCC -Wcast-align)

Definition at line 245 of file arch.h.

◆ LWIP_CONST_CAST

#define LWIP_CONST_CAST (   target_type,
  val 
)    ((target_type)((ptrdiff_t)val))

C++ const_cast<target_type>(val) equivalent to remove constness from a value (GCC -Wcast-qual)

Definition at line 240 of file arch.h.

◆ LWIP_DECLARE_MEMORY_ALIGNED

#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)]

Definition at line 271 of file arch.h.

◆ lwip_isdigit

#define lwip_isdigit (   c)    isdigit((unsigned char)(c))

Definition at line 229 of file arch.h.

◆ lwip_islower

#define lwip_islower (   c)    islower((unsigned char)(c))

Definition at line 231 of file arch.h.

◆ lwip_isspace

#define lwip_isspace (   c)    isspace((unsigned char)(c))

Definition at line 232 of file arch.h.

◆ lwip_isupper

#define lwip_isupper (   c)    isupper((unsigned char)(c))

Definition at line 233 of file arch.h.

◆ lwip_isxdigit

#define lwip_isxdigit (   c)    isxdigit((unsigned char)(c))

Definition at line 230 of file arch.h.

◆ LWIP_MEM_ALIGN

#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

Definition at line 294 of file arch.h.

◆ LWIP_MEM_ALIGN_BUFFER

#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*)

Definition at line 287 of file arch.h.

◆ LWIP_MEM_ALIGN_SIZE

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

Definition at line 279 of file arch.h.

◆ LWIP_NO_CTYPE_H

#define LWIP_NO_CTYPE_H   0

Define this to 1 in arch/cc.h of your port if your compiler does not provide the ctype.h header. If ctype.h is available, a few character functions are mapped to the appropriate functions (lwip_islower, lwip_isdigit...), if not, a private implementation is provided.

Definition at line 215 of file arch.h.

◆ LWIP_NO_INTTYPES_H

#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. You need to define the format strings listed in lwip/arch.h yourself in this case (X8_F, U16_F...).

Definition at line 143 of file arch.h.

◆ LWIP_NO_LIMITS_H

#define LWIP_NO_LIMITS_H   0

Define this to 1 in arch/cc.h of your port if your compiler does not provide the limits.h header. You need to define the type limits yourself in this case (e.g. INT_MAX, SSIZE_MAX).

Definition at line 180 of file arch.h.

◆ LWIP_NO_STDDEF_H

#define LWIP_NO_STDDEF_H   0

Define this to 1 in arch/cc.h of your port if you do not want to include stddef.h header to get size_t. You need to typedef size_t by yourself in this case.

Definition at line 103 of file arch.h.

◆ LWIP_NO_STDINT_H

#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. You need to typedef the generic types listed in lwip/arch.h yourself in this case (u8_t, u16_t...).

Definition at line 115 of file arch.h.

◆ LWIP_PACKED_CAST

#define LWIP_PACKED_CAST (   target_type,
  val 
)    LWIP_CONST_CAST(target_type, val)

Avoid warnings/errors related to implicitly casting away packed attributes by doing a explicit cast

Definition at line 257 of file arch.h.

◆ LWIP_PLATFORM_ASSERT

#define LWIP_PLATFORM_ASSERT (   x)
Value:
do {printf("Assertion \"%s\" failed at line %d in %s\n", \
x, __LINE__, __FILE__); fflush(NULL); abort();} while(0)
#define NULL
Definition: types.h:112
#define printf
Definition: freeldr.h:97
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define abort()
Definition: i386-dis.c:34
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)

Platform specific assertion handling.
Note the default implementation pulls in printf, fflush and abort, which may in turn pull in a lot of standard library code. In resource-constrained systems, this should be defined to something less resource-consuming.

Definition at line 92 of file arch.h.

◆ LWIP_PLATFORM_DIAG

#define LWIP_PLATFORM_DIAG (   x)    do {printf x;} while(0)

Define random number generator function of your system Platform specific diagnostic output.
Note the default implementation pulls in printf, which may in turn pull in a lot of standard library code. In resource-constrained systems, this should be defined to something less resource-consuming.

Definition at line 81 of file arch.h.

◆ LWIP_PTR_NUMERIC_CAST

#define LWIP_PTR_NUMERIC_CAST (   target_type,
  val 
)    LWIP_CONST_CAST(target_type, val)

Get rid of warnings related to pointer-to-numeric and vice-versa casts, e.g. "conversion from 'u8_t' to 'void *' of greater size"

Definition at line 252 of file arch.h.

◆ lwip_tolower

#define lwip_tolower (   c)    tolower((unsigned char)(c))

Definition at line 234 of file arch.h.

◆ lwip_toupper

#define lwip_toupper (   c)    toupper((unsigned char)(c))

Definition at line 235 of file arch.h.

◆ LWIP_UINT32_MAX

#define LWIP_UINT32_MAX   0xffffffff

Definition at line 207 of file arch.h.

◆ LWIP_UNUSED_ARG

#define LWIP_UNUSED_ARG (   x)    (void)x

PACK_STRUCT_USE_INCLUDES==1: Packed structs support using #include files before and after struct to be packed.
The file included BEFORE the struct is "arch/bpstruct.h".
The file included AFTER the struct is "arch/epstruct.h".
This can be used to implement struct packing on MS Visual C compilers, see the Win32 port in the lwIP/contrib subdir for reference. For examples of packed struct declarations, see include/lwip/prot/ subfolder.
A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here. Eliminates compiler warning about unused arguments (GCC -Wextra -Wunused).

Definition at line 373 of file arch.h.

◆ PACK_STRUCT_BEGIN

#define PACK_STRUCT_BEGIN

Packed structs support. Placed BEFORE declaration of a packed struct.
For examples of packed struct declarations, see include/lwip/prot/ subfolder.
A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here.

Definition at line 307 of file arch.h.

◆ PACK_STRUCT_END

#define PACK_STRUCT_END

Packed structs support. Placed AFTER declaration of a packed struct.
For examples of packed struct declarations, see include/lwip/prot/ subfolder.
A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here.

Definition at line 316 of file arch.h.

◆ PACK_STRUCT_FIELD

#define PACK_STRUCT_FIELD (   x)    x

Packed structs support. Wraps u32_t and u16_t members.
For examples of packed struct declarations, see include/lwip/prot/ subfolder.
A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here.

Definition at line 338 of file arch.h.

◆ PACK_STRUCT_FLD_8

#define PACK_STRUCT_FLD_8 (   x)    PACK_STRUCT_FIELD(x)

Packed structs support. Wraps u8_t members, where some compilers warn that packing is not necessary.
For examples of packed struct declarations, see include/lwip/prot/ subfolder.
A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here.

Definition at line 347 of file arch.h.

◆ PACK_STRUCT_FLD_S

#define PACK_STRUCT_FLD_S (   x)    PACK_STRUCT_FIELD(x)

Packed structs support. Wraps members that are packed structs themselves, where some compilers warn that packing is not necessary.
For examples of packed struct declarations, see include/lwip/prot/ subfolder.
A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here.

Definition at line 356 of file arch.h.

◆ PACK_STRUCT_STRUCT

#define PACK_STRUCT_STRUCT

Packed structs support. Placed between end of declaration of a packed struct and trailing semicolon.
For examples of packed struct declarations, see include/lwip/prot/ subfolder.
A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here.

Definition at line 328 of file arch.h.

◆ S16_F

#define S16_F   PRId16

Definition at line 156 of file arch.h.

◆ S32_F

#define S32_F   PRId32

Definition at line 165 of file arch.h.

◆ SSIZE_MAX

#define SSIZE_MAX   INT_MAX

Definition at line 203 of file arch.h.

◆ SZT_F

#define SZT_F   PRIuPTR

Definition at line 171 of file arch.h.

◆ U16_F

#define U16_F   PRIu16

Definition at line 153 of file arch.h.

◆ U32_F

#define U32_F   PRIu32

Definition at line 162 of file arch.h.

◆ X16_F

#define X16_F   PRIx16

Definition at line 159 of file arch.h.

◆ X32_F

#define X32_F   PRIx32

Definition at line 168 of file arch.h.

◆ X8_F

#define X8_F   "02" PRIx8

Definition at line 150 of file arch.h.

Typedef Documentation

◆ mem_ptr_t

Definition at line 135 of file arch.h.

◆ s16_t

typedef int16_t s16_t

Definition at line 128 of file arch.h.

◆ s32_t

typedef int32_t s32_t

Definition at line 130 of file arch.h.

◆ s8_t

typedef int8_t s8_t

Definition at line 126 of file arch.h.

◆ ssize_t

typedef int ssize_t

Definition at line 202 of file arch.h.

◆ u16_t

typedef uint16_t u16_t

Definition at line 127 of file arch.h.

◆ u32_t

typedef uint32_t u32_t

Definition at line 129 of file arch.h.

◆ u8_t

typedef uint8_t u8_t

Definition at line 125 of file arch.h.