This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 5/5] Add single-threaded path to _int_malloc
On 24/10/17 14:49, Wilco Dijkstra wrote:
> DJ Delorie wrote:
>>
>> Looks good to me.
>
> OK it's all committed now. Thanks for the reviews!
>
>>> We could use the ifunc mechanism to decide between different variants -
>>> including for example for the single-thread optimization.
>>
>> I suspect ifuncs are chosen before we know if the program will spawn any
>> threads, though.
>
> I was thinking of dynamically updating the ifunc, for example if we want to trace,
> hook or enable more expensive checking. That way there is no need to check
> for all special cases on every call, and additional code can be enabled or
> disabled at runtime by swapping to a different variant of malloc/free.
>
the address of malloc must be const during the lifetime of a
process, since it can be saved in a variable that can be later
used as func ptr.
you would need an additional indirection for this to work.
(e.g. implement it as void *malloc(size_t n){ return fptr(n); }
where fptr is a global that's updated at thread creation time)
at which point it has not much to do with ifunc.