// SPDX-License-Identifier: LSL-1.0 // Copyright (c) 2026 Markus Maiwald // Stewardship: Self Sovereign Society Foundation // // This file is part of the Nexus Sovereign Core. // See legal/LICENSE_SOVEREIGN.md for license terms. /** * @file cc.h * @brief lwIP Compiler/Platform Compatibility Layer * * This file defines compiler-specific macros and types required by lwIP. * Tailored for GCC/Clang in a freestanding environment. */ #ifndef LWIP_ARCH_CC_H #define LWIP_ARCH_CC_H #include #include // ========================================================= // Basic Types (Fixed-width integers) // ========================================================= 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; // Memory pointer types typedef uintptr_t mem_ptr_t; // Protection type (required for SYS_LIGHTWEIGHT_PROT even in NO_SYS mode) typedef uint32_t sys_prot_t; // ========================================================= // Compiler Hints // ========================================================= // Packing structures (for protocol headers) #define PACK_STRUCT_FIELD(x) x #define PACK_STRUCT_STRUCT __attribute__((packed)) #define PACK_STRUCT_BEGIN #define PACK_STRUCT_END // Alignment #define LWIP_PLATFORM_BYTESWAP 0 // We'll use lwIP's portable functions // ========================================================= // Diagnostics and Assertions // ========================================================= // Platform diagnostics (unconditionally disabled for now) #define LWIP_PLATFORM_DIAG(x) do {} while(0) // Platform assertions (disabled for now) #define LWIP_PLATFORM_ASSERT(x) do {} while(0) // ========================================================= // Random Number Generation // ========================================================= // lwIP needs a random number source for things like TCP ISN // We'll use the kernel's crypto subsystem extern uint32_t syscall_get_random(void); #define LWIP_RAND() syscall_get_random() // ========================================================= // Printf Format Specifiers // ========================================================= // For 64-bit architectures #define X8_F "02x" #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" #endif /* LWIP_ARCH_CC_H */