This is the mail archive of the
mailing list for the newlib project.
Re: How to destroy _reent structure
- From: Corinna Vinschen <vinschen at redhat dot com>
- To: newlib at sourceware dot org
- Date: Wed, 24 Apr 2013 17:40:19 +0200
- Subject: Re: How to destroy _reent structure
- References: <5177920B dot 4040100 at embedded-brains dot de> <20130424102604 dot GK26397 at calimero dot vinschen dot de> <5177BD89 dot 8050608 at embedded-brains dot de> <20130424125530 dot GP26397 at calimero dot vinschen dot de> <5177F16E dot 5010205 at oarcorp dot com>
- Reply-to: newlib at sourceware dot org
On Apr 24 09:51, Joel Sherrill wrote:
> On 4/24/2013 7:55 AM, Corinna Vinschen wrote:
> >On Apr 24 13:10, Sebastian Huber wrote:
> >>What is the purpose of _wrapup_reent()? Its not called from within
> >>Newlib and I don't find a function that can register an atexit
> >>handler in a non-global _reent structure. There is also no public
> >>header file for this function.
> >Sorry, I can't answer this question. This code predates my involvement
> >in newlib and I never looked deeper into this. Cygwin also uses
> >_reclaim_reent to get rid of the per-pthread reent structure.
> We are looking at ancient history code. The RTEMS code that uses
> our extensions
> on thread create, delete, restart, and switch for newlib dates back
> to the 1992-3
> time frame.
> My vague recollection is that newlib had leaks. Looking at the comments in
> reent.c, my impression is that the code and comments don't match.
> _wrapup_reent() has a comment being run at "task exit" but task is undefined
> in POSIX. For RTEMS task is synonymous with thread but this routine is
> invoking atexit() methods.
> _reclaim_reent() frees a lot and also invokes the atexit() but has comments
> like this that indicate it is at process exit():
> /* Malloc memory not reclaimed; no good way to return memory
> anyway. */
> Looking at this again, I still don't see a clear indication of what
> should be invoked
> at thread exit and what should be invoked at process exit.
> What does Cygwin do at thread exit and process exit?
Nothing much. It calls atexit at process exit and _reclaim_reent
at pthread exit. reeent::_atexit is not used for pthreads.
> Any other insight? Except that the names don't add insight. :)
Not really, no.