74 lines
1.6 KiB
C
74 lines
1.6 KiB
C
/*
|
|
* Nexus Membrane: Userspace LwIP Configuration
|
|
* Provides compiler-specific definitions for NPL networking.
|
|
*/
|
|
|
|
#ifndef LWIP_ARCH_CC_H
|
|
#define LWIP_ARCH_CC_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
// Freestanding: Declare what stdlib misses
|
|
extern int rand(void);
|
|
extern int printf(const char *format, ...);
|
|
|
|
#define LWIP_NO_INTTYPES_H 1
|
|
|
|
/* Byte Order */
|
|
#ifndef BYTE_ORDER
|
|
#define LITTLE_ENDIAN 1234
|
|
#define BIG_ENDIAN 4321
|
|
#define BYTE_ORDER LITTLE_ENDIAN
|
|
#endif
|
|
|
|
/* Types */
|
|
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;
|
|
|
|
/* Sys Prot Type (Critical Section) */
|
|
typedef u32_t sys_prot_t;
|
|
|
|
/* Error code */
|
|
#define LWIP_ERR_T s8_t
|
|
|
|
/* Printf formatters */
|
|
#define U16_F "u"
|
|
#define S16_F "d"
|
|
#define X16_F "x"
|
|
#define U32_F "u"
|
|
#define S32_F "d"
|
|
#define X32_F "x"
|
|
#define SZT_F "zu"
|
|
|
|
/* Structure packing */
|
|
#if defined(__GNUC__) || defined(__clang__)
|
|
#define PACK_STRUCT_FIELD(x) x
|
|
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
|
#define PACK_STRUCT_BEGIN
|
|
#define PACK_STRUCT_END
|
|
#else
|
|
#define PACK_STRUCT_FIELD(x) x
|
|
#define PACK_STRUCT_STRUCT
|
|
#define PACK_STRUCT_BEGIN
|
|
#define PACK_STRUCT_END
|
|
#endif
|
|
|
|
/* Diagnostic output */
|
|
#define LWIP_PLATFORM_DIAG(x) do { printf x; } while(0)
|
|
|
|
#define LWIP_PLATFORM_ASSERT(x) do { \
|
|
printf("[LwIP] Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__); \
|
|
while(1) asm("wfi"); \
|
|
} while(0)
|
|
|
|
#define LWIP_RAND() ((u32_t)rand())
|
|
|
|
#endif /* LWIP_ARCH_CC_H */
|