This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
Re: newlib newbie wants to malloc
- To: "J. Johnston" <jjohnstn at cygnus dot com>
- Subject: Re: newlib newbie wants to malloc
- From: Christian Groessler <chris at groessler dot org>
- Date: Thu, 11 Oct 2001 13:53:08 +0200 (CEST)
- cc: <newlib at sourceware dot cygnus dot com>
On Tue, 9 Oct 2001, J. Johnston wrote:
> Christian Groessler wrote:
> >
> > Hi,
> >
> > I'm trying to get newlib working on a new system and I've encountered
> > a problem.
> >
> > There is a function _malloc_r used throughout the library, even malloc
> > simply calls _malloc_r.
> >
> > This function is provided in the file newlib/libc/stdlib/mallocr.c.
> > There is a "#define mALLOc _malloc_r".
> >
> > The problem is now that mALLOc() expects one parameter, but _malloc_r
> > is defined to get 2 parameters.
> > The first parameter to _malloc_r is a pointer which is now interpreted
> > by mALLOc as requested size.
> > How should this work? What am I doing wrong?
> >
> > confused,
> > chris
>
> Chris,
>
> Are you using the Makefile.in given to compile the files? You will note
> there is a -DINTERNAL_NEWLIB flag added to the compilation. This make
> mALLOc define to _malloc_r and also adds the extra parameter which points
> to the reentrant structure.
I was wrong. The parameter passed to mALLOc is correct, it's the
requested size. I see the mALLOc define to _malloc_r, but I cannot find
what happens with the reent structure parameter, where does it vanish?
> In addition, please note the comment on the top of libc/include/reent.h
> which discusses the various strategies for supporting reentrancy. You
> should likely be specifying -DREENTRANT_SYSCALLS_PROVIDED for your
> port.
I'm trying to get the lib working on a z8k system, so I copied the
existing z8ksim target and am now replacing the syscalls.
regards,
chris