From ae49c020d73f9ed8ae3096dd9800421e92c03366 Mon Sep 17 00:00:00 2001 From: davidhaas Date: Tue, 11 Feb 2003 20:59:49 +0000 Subject: [PATCH] sys_thread_new() now returns the thread (request from Marc Boucher). Removed some unused .h files in coldfire port. Support LWIP_DIAG and LWIP_ASSERT in coldfire (sort of). Fix to last api fix to make sure select() is triggered, even when there has been a FIN. Allow build of unixsim from cygwin by specifying "make ARCH=cygwin" or from linux by specifying "make ARCH=linux". --- ports/6502/sys_c64.c | 3 ++- ports/coldfire/include/arch/cc.h | 22 +++++++++++++++- ports/coldfire/include/arch/cpu.h | 43 ------------------------------- ports/coldfire/include/arch/lib.h | 40 ---------------------------- ports/coldfire/sys_arch.c | 4 +-- ports/rtxc/sys_arch.c | 3 ++- ports/unix/proj/unixsim/Makefile | 6 ++++- ports/unix/sys_arch.c | 3 ++- 8 files changed, 34 insertions(+), 90 deletions(-) delete mode 100644 ports/coldfire/include/arch/cpu.h delete mode 100644 ports/coldfire/include/arch/lib.h diff --git a/ports/6502/sys_c64.c b/ports/6502/sys_c64.c index aa0888e..1ed52fd 100644 --- a/ports/6502/sys_c64.c +++ b/ports/6502/sys_c64.c @@ -113,8 +113,9 @@ sys_arch_timeouts(void) return &timeouts; } /*-----------------------------------------------------------------------------------*/ -void +sys_thread_t sys_thread_new(void (* function)(void *arg), void *arg) { + return 0; } /*-----------------------------------------------------------------------------------*/ diff --git a/ports/coldfire/include/arch/cc.h b/ports/coldfire/include/arch/cc.h index 682844b..8797a7b 100644 --- a/ports/coldfire/include/arch/cc.h +++ b/ports/coldfire/include/arch/cc.h @@ -30,13 +30,17 @@ * * Author: Adam Dunkels * - * $Id: cc.h,v 1.1 2003/01/18 18:47:22 jani Exp $ + * $Id: cc.h,v 1.2 2003/02/11 20:59:49 davidhaas Exp $ */ #ifndef __CC_H__ #define __CC_H__ #include +#define BYTE_ORDER BIG_ENDIAN +#define IMM_ADDRESS (0x10000000) +#define FEC_LEVEL 4 + // typedef unsigned char u8_t; // typedef signed char s8_t; // typedef unsigned short u16_t; @@ -46,6 +50,7 @@ typedef u32_t mem_ptr_t; +/* Compiler hints for packing structures */ #define PACK_STRUCT_BEGIN #pragma pack(1,1,0) #define PACK_STRUCT_STRUCT #define ALIGN_STRUCT_8_BEGIN #pragma pack(1,8,0) @@ -83,4 +88,19 @@ typedef struct _types_fd_set { *__tmp++ = 0; \ } while (0) +/* prototypes for printf() and abort() */ +#include +#include +/* Plaform specific diagnostic output */ +#if 0 +#define LWIP_PLATFORM_DIAG(x) {printf x;} + +#define LWIP_PLATFORM_ASSERT(x) {printf("Assertion \"%s\" failed at line %d in %s\n", \ + x, __LINE__, __FILE__); fflush(NULL); abort();} +#endif + +#define LWIP_PLATFORM_DIAG(x) ; + +#define LWIP_PLATFORM_ASSERT(x) ; + #endif /* __CC_H__ */ diff --git a/ports/coldfire/include/arch/cpu.h b/ports/coldfire/include/arch/cpu.h deleted file mode 100644 index c2c6788..0000000 --- a/ports/coldfire/include/arch/cpu.h +++ /dev/null @@ -1,43 +0,0 @@ -/* @(#)cpu.h - * Copyright (c) 2001-2003, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: David Haas - * - */ - -#ifndef _CPU_H -#define _CPU_H 1 - -#define BYTE_ORDER BIG_ENDIAN -#define IMM_ADDRESS (0x10000000) -#define FEC_LEVEL 4 - -#endif /* _CPU_H */ - diff --git a/ports/coldfire/include/arch/lib.h b/ports/coldfire/include/arch/lib.h deleted file mode 100644 index b2c9cea..0000000 --- a/ports/coldfire/include/arch/lib.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2001-2003, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - * $Id: lib.h,v 1.1 2003/01/18 18:47:22 jani Exp $ - */ -#ifndef __LIB_H__ -#define __LIB_H__ - -#include - -#endif /* __LIB_H__ */ diff --git a/ports/coldfire/sys_arch.c b/ports/coldfire/sys_arch.c index 4afaddb..611e339 100644 --- a/ports/coldfire/sys_arch.c +++ b/ports/coldfire/sys_arch.c @@ -126,7 +126,7 @@ introduce_thread(NU_TASK *id, void (*function)(void *arg), void *arg) /*---------------------------------------------------------------------------------*/ /* We use Nucleus task as thread. Create one with a standard size stack at a standard * priority. */ -void +sys_thread_t sys_thread_new(void (*function)(void *arg), void *arg) { NU_TASK *p_thread; @@ -161,7 +161,7 @@ sys_thread_new(void (*function)(void *arg), void *arg) NU_PREEMPT, NU_START); if (status == NU_SUCCESS) - return; + return p_thread; } } diff --git a/ports/rtxc/sys_arch.c b/ports/rtxc/sys_arch.c index f0179ab..b20b27e 100644 --- a/ports/rtxc/sys_arch.c +++ b/ports/rtxc/sys_arch.c @@ -241,7 +241,7 @@ sys_thread(void) KS_terminate(0); } /*-----------------------------------------------------------------------------------*/ -void +sys_thread_t sys_thread_new(void (* function)(void *arg), void *arg) { TASK newtask; @@ -262,6 +262,7 @@ sys_thread_new(void (* function)(void *arg), void *arg) KS_deftask_arg(newtask, &threadarg); KS_execute(newtask); KS_wait(THRDSYNC); + return newtask; } diff --git a/ports/unix/proj/unixsim/Makefile b/ports/unix/proj/unixsim/Makefile index 8424a9c..a78c82d 100644 --- a/ports/unix/proj/unixsim/Makefile +++ b/ports/unix/proj/unixsim/Makefile @@ -31,7 +31,11 @@ CCDEP=gcc CC=gcc -CFLAGS=-g -Wall -DIPv4 -DLWIP_DEBUG -pedantic + +#To Compile for linux: make ARCH=linux +#To Compile for cygwin: make ARCH=cygwin +ARCH=unix +CFLAGS=-g -Wall -D$(ARCH) -DIPv4 -DLWIP_DEBUG -pedantic LDFLAGS=-lpcap CONTRIBDIR=../../../.. LWIPARCH=$(CONTRIBDIR)/ports/unix diff --git a/ports/unix/sys_arch.c b/ports/unix/sys_arch.c index 07e2520..a1e034c 100644 --- a/ports/unix/sys_arch.c +++ b/ports/unix/sys_arch.c @@ -150,7 +150,7 @@ current_thread(void) return st; } /*-----------------------------------------------------------------------------------*/ -void +sys_thread_t sys_thread_new(void (*function)(void *arg), void *arg) { int code; @@ -172,6 +172,7 @@ sys_thread_new(void (*function)(void *arg), void *arg) code, (int)st)); abort(); } + return st; } /*-----------------------------------------------------------------------------------*/ struct sys_mbox *