First of all;
Code: Select all
caddr_t sbrk(int incr)
Second question:
Code: Select all
int execve(char *name, char **argv, char **env)
int fork()
Code: Select all
caddr_t sbrk(int incr)
Code: Select all
int execve(char *name, char **argv, char **env)
int fork()
Code: Select all
int fork()
{
errno = ENOSYS;
return -1;
}
How do I know when to clean up? I'm assuming newlib calls sbrk() to get memory from the OS for it's malloc/free implementation, but what call does it make to release memory?pcmattman wrote:As for freeing memory - I've never had the newlib sbrk() called with a negative incr variable. Generally it's left up to the OS to clean up.
To release memory newlib calls sbrk with a negative argument, to move the breakpoint lower in memory.MessiahAndrw wrote:How do I know when to clean up? I'm assuming newlib calls sbrk() to get memory from the OS for it's malloc/free implementation, but what call does it make to release memory?pcmattman wrote:As for freeing memory - I've never had the newlib sbrk() called with a negative incr variable. Generally it's left up to the OS to clean up.
You've convinced me on adding fork.
I don't even have an sbrk/brk function. I replaced the malloc implementation in newlib with a dlmalloc that uses mmap and friends by placing some files in my system target directory in the source tree. IIRC there's another port, probably the Linux one, that does the same - have a look at it to see how its done.MessiahAndrw wrote:I would still really like to swap malloc/free with another (nedmalloc) which should be easy enough (find out where newlib's allocator is and remove it, then link with mine).
So I was wondering if anything else relies on sbrk or there's something people in a similar situation can tell me will break?
IIRC there's a MALLOC_PROVIDED flag of some sort that you can set, in which case it will skip compiling its own malloc.AlexExtreme wrote:I don't even have an sbrk/brk function. I replaced the malloc implementation in newlib with a dlmalloc that uses mmap and friends by placing some files in my system target directory in the source tree. IIRC there's another port, probably the Linux one, that does the same - have a look at it to see how its done.MessiahAndrw wrote:I would still really like to swap malloc/free with another (nedmalloc) which should be easy enough (find out where newlib's allocator is and remove it, then link with mine).
So I was wondering if anything else relies on sbrk or there's something people in a similar situation can tell me will break?