[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Re: [lwip] Problem with timeouts
From: |
Martin Glunz |
Subject: |
[lwip-users] Re: [lwip] Problem with timeouts |
Date: |
Thu, 09 Jan 2003 00:08:26 -0000 |
This is a multi-part message in MIME format.
--------------F5584BF7F2F01EA274EDB31F
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
David Haas wrote:
> =
=2E.. =
> Now can solve this by creating a special thread just to do the
> initialization which will then always wait for a semaphore it will
> never get, but I think this points out some deeper weakness with
> lwip's interaction with an rtos. =
At the moment, I've done this exactly this way. But my simple
cooperative OS has a timer facility, I'd like to use this for
the timeouts.
> =
> On a similar note, I think there should be an option for users to have
> their own malloc as part of a port and use of mem_malloc should be
> optional. (where perhaps an conditional compile calls a sys_malloc
> function instead of mem_malloc).
This is easily done by replacing the mem.c module with your own. Just
include such a module in your source, and link it before the lwip
library gets linked. Declare MEM_SIZE in lwipopts.h to zero. =
I've attached my mem.c source for example.
Note that I increase the size of the allocated memory a bit, otherwise
I get CPU address errors from the SH. There seems to be a problem with
the memory sizes, but I haven't found this yet.
-- =
Martin Glunz
fortune says today:
Q: Why do ducks have flat feet?
A: To stamp out forest fires.
Q: Why do elephants have flat feet?
A: To stamp out flaming ducks.
WANTED: Schr=F6dinger's Cat. Dead or Alive.
There are only 10 kinds of people. Those who
understand binary and those who don't.
--------------F5584BF7F2F01EA274EDB31F
Content-Type: text/plain; charset=us-ascii;
name="mem.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="mem.c"
/*-----------------------------------------------------------------------------------*/
/* mem.c
*
* Memory manager.
*
*/
/*-----------------------------------------------------------------------------------*/
#include <stdlib.h>
#include "lwip/debug.h"
#include "lwip/arch.h"
#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/sys.h"
#include "lwip/stats.h"
void
mem_init(void)
{ }
/*-----------------------------------------------------------------------------------*/
void *
mem_malloc(mem_size_t size)
{
void *xx;
int new_sz=size+32-(size & 0x0f);
xx=malloc(new_sz);
DEBUGF(MEM_DEBUG,("malloc %d %08X\n",new_sz,(int)xx));
return xx;
}
/*-----------------------------------------------------------------------------------*/
void
mem_free(void *rmem)
{
DEBUGF(MEM_DEBUG,("free %08X\n",(int)rmem));
free(rmem);
}
/*-----------------------------------------------------------------------------------*/
void *
mem_reallocm(void *rmem, mem_size_t newsize)
{
void *xx;
int new_sz=newsize+32-(newsize & 0x0f);
xx=realloc(rmem, new_sz);
DEBUGF(MEM_DEBUG,("reallocm %d %08X\n",new_sz,(int)xx));
return xx;
}
/*-----------------------------------------------------------------------------------*/
void *
mem_realloc(void *rmem, mem_size_t newsize)
{
void *xx;
int new_sz=newsize+32-(newsize & 0x0f);
xx=realloc(rmem, new_sz);
DEBUGF(MEM_DEBUG,("realloc %d %08X\n",new_sz,(int)xx));
return xx;
}
/*-----------------------------------------------------------------------------------*/
--------------F5584BF7F2F01EA274EDB31F--
[This message was sent through the lwip discussion list.]