[coldfire-gnu-discuss] Making malloc threadsafe
Daniel McLean
daniel.mclean at optusnet.com.au
Mon Mar 12 02:34:01 UTC 2007
It seems I may have partially solved this problem myself. If I don't
replace malloc_lock/unlock in one of my own utility libraries that I
link in, but instead implement them in the main.c file it seems to stop
the linker saying that they have been redefined..
Is there a better way of doing this however (a function attribute or
linker option) that tells the compiler or linker that I want to use my
version (implemented in a library or otherwise) of these functions?
Thanks
Daniel
Daniel McLean wrote:
> Hi,
>
> I was just wondering if it is possible to make malloc thread safe with
> Sourcery G++ Lite? It seems that libc defines _malloc_lock and
> _malloc_unlock already. If I make sure that all my calls to malloc in
> my code are thread safe (using mutual exclusion) will this ensure that
> memory allocation is in fact thread safe? Or are there places that
> malloc is called inside the C library such that without implementing
> _malloc_lock and _malloc_unlock malloc it won't be thread safe?
>
> If so how can I make sure that malloc is thread safe?
> Thanks
> Daniel
>
>
More information about the coldfire-gnu-discuss
mailing list