From e0675d8b8243fbe53490f347816deea7ba7d6777 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Mon, 27 Apr 2009 20:14:04 +0000 Subject: [PATCH] Adapted win32 port to changes in sys.h (for NO_SYS=1 only) --- ports/win32/include/arch/cc.h | 8 +++++ ports/win32/include/arch/sys_arch.h | 2 -- ports/win32/sys_arch.c | 45 +++++++++++++++++------------ ports/win32/test.c | 4 +-- 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/ports/win32/include/arch/cc.h b/ports/win32/include/arch/cc.h index 508df8a..7faaabc 100644 --- a/ports/win32/include/arch/cc.h +++ b/ports/win32/include/arch/cc.h @@ -62,6 +62,7 @@ typedef unsigned long u32_t; typedef signed long s32_t; typedef size_t mem_ptr_t; +typedef u32_t sys_prot_t; /* Define (sn)printf formatters for these lwIP types */ #define U16_F "hu" @@ -70,6 +71,7 @@ typedef size_t mem_ptr_t; #define U32_F "lu" #define S32_F "ld" #define X32_F "lx" +#define SZT_F U32_F /* Compiler hints for packing structures */ #define PACK_STRUCT_STRUCT @@ -81,7 +83,13 @@ typedef size_t mem_ptr_t; #define LWIP_PLATFORM_ASSERT(x) do {printf("Assertion \"%s\" failed at line %d in %s\n", \ x, __LINE__, __FILE__); fflush(NULL); abort();} while(0) +#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ + printf("Assertion \"%s\" failed at line %d in %s\n", expression, __LINE__, __FILE__); \ + fflush(NULL);handler;}} while(0) + /* C runtime functions redefined */ #define snprintf _snprintf +u32_t dns_lookup_external_hosts_file(const char *name); + #endif /* __ARCH_CC_H__ */ diff --git a/ports/win32/include/arch/sys_arch.h b/ports/win32/include/arch/sys_arch.h index f21eacd..30c920a 100644 --- a/ports/win32/include/arch/sys_arch.h +++ b/ports/win32/include/arch/sys_arch.h @@ -32,8 +32,6 @@ #ifndef __ARCH_SYS_ARCH_H__ #define __ARCH_SYS_ARCH_H__ -typedef u32_t sys_prot_t; - /* HANDLE is used for sys_sem_t but we won't include windows.h */ typedef void* sys_sem_t; #define SYS_SEM_NULL NULL diff --git a/ports/win32/sys_arch.c b/ports/win32/sys_arch.c index 066d356..2f12e16 100644 --- a/ports/win32/sys_arch.c +++ b/ports/win32/sys_arch.c @@ -65,6 +65,29 @@ u32_t sys_now() return sys_get_ms_longlong(); } +CRITICAL_SECTION critSec; + +void InitSysArchProtect() +{ + InitializeCriticalSection(&critSec); +} +u32_t sys_arch_protect() +{ + EnterCriticalSection(&critSec); + return 0; +} +void sys_arch_unprotect(u32_t pval) +{ + LWIP_UNUSED_ARG(pval); + LeaveCriticalSection(&critSec); +} + +void msvc_sys_init() +{ + sys_init_timing(); + InitSysArchProtect(); +} + #if !NO_SYS #define MAX_QUEUE_ENTRIES 100 @@ -82,33 +105,17 @@ struct lwip_mbox { }; struct threadlist *lwip_win32_threads = NULL; -CRITICAL_SECTION critSec; -void InitSysArchProtect() +void sys_init() { - InitializeCriticalSection(&critSec); -} -u32_t sys_arch_protect() -{ - EnterCriticalSection(&critSec); - return 0; -} -void sys_arch_unprotect(u32_t pval) -{ - LWIP_UNUSED_ARG(pval); - LeaveCriticalSection(&critSec); + msvc_sys_init(); } + void do_sleep(int ms) { Sleep(ms); } -void sys_init(void) -{ - sys_init_timing(); - InitSysArchProtect(); -} - sys_sem_t sys_sem_new(u8_t count) { HANDLE new_sem = NULL; diff --git a/ports/win32/test.c b/ports/win32/test.c index 0322ebf..a2c5e90 100644 --- a/ports/win32/test.c +++ b/ports/win32/test.c @@ -84,7 +84,7 @@ #if NO_SYS /* port-defined functions used for timer execution */ -void sys_init_timing(); +void msvc_sys_init(); u32_t sys_now(); #endif /* NO_SYS */ @@ -135,7 +135,7 @@ static timers_infos timers_table[] = { static void nosys_init() { - sys_init_timing(); + msvc_sys_init(); lwip_init(); }