newlib malloc/memalign

Joel Sherrill joel.sherrill at OARcorp.com
Tue Sep 30 15:29:07 UTC 2003


Chuck Tuffli wrote:

> On Mon, Sep 29, 2003 at 04:52:53PM -0500, Joel Sherrill wrote:
> 
>>Chuck Tuffli wrote:
>>
>>
>>>I saw a posting* in March that talks about switching from using RTEM's
>>>malloc to the one in newlib. I'm interested in using the memalign
>>>function and was wondering what would I need to do to implement this
>>>support.
>>>
>>>* 
>>>http://www.rtems.com/rtems/maillistArchives/rtems-users/2003/march/msg00050.html
>>
>>The first step would be to disable the malloc code in RTEMS,
>>provide the malloc mutex used by newlib (see the gxx_thread_wrappers
>>in RTEMS), and arrange for newlib to use the memory formerly
>>given to our own malloc.
> 
> 
> Ok, I'm probably being dense, 

I must be dense this week because that seems to be a common comment. :)

 >  but I don't see a mutex being taken
> in the malloc code in cpukit/libcsupport/src/malloc.c (unless the
> mutex is part of rtems_region_get_segment()). 

The Region manager uses an internal RTEMS mutex for allocation.  So
it isn't explicit in the RTEMS malloc code.

 > I'm also not finding
> the gxx_thread_wrappers you refered to in either newlib or RTEMS.
> Where am I going wrong?

cpukit/libcsupport/src/gxx_wrappers.c is the set of routines used
by gcc run-time support functions to be thread-safe.

newlib's malloc implementation newlib/libc/stdlib/mallocr.c expect
MALLOC_LOCK and MALLOC_UNLOCK to be defined.  There are other macros
in there to define as well.

> This is building off the CVS tag rtems-ss-20030703, newlib 1.11 and
> gcc 3.2.3
> 
> 
>>>--
>>>Chuck Tuffli
>>>Agilent Technologies
>>
>>
>>-- 
>>Joel Sherrill, Ph.D.             Director of Research & Development
>>joel at OARcorp.com                 On-Line Applications Research
>>Ask me about RTEMS: a free RTOS  Huntsville AL 35805
>>Support Available                (256) 722-9985
> 
> 


-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985




More information about the users mailing list