This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: atexit() stuff in thread-local reent?


On 04/29/2013 11:26 PM, Jeff Johnston wrote:
On 04/27/2013 07:52 AM, Sebastian Huber wrote:
Hello,

currently the struct _reent contains some atexit() stuff:

struct _reent {
   [...]
   /* atexit stuff */
   struct _atexit *_atexit;
   struct _atexit _atexit0;
   [...]
};

on PowerPC for example this accounts for 400 of 1088 bytes of the
structure.  From my point of view the atexit() stuff belongs to the
global state and is not thread-specific.  I think all atexit() related
functions (in __call_atexit.c and  __atexit.c, are there more?) use
_GLOBAL_REENT.  This is related to the possibly unused _wrapup_reent()
function.  Maybe we should introduce two structures.  One for the global
state (contains thread-specific state + atexit() stuff) and one for the
thread-specific state.  This might save 400 bytes (37% of current
_reent) per thread.


Instead, I might suggest that _atexit0 be removed from struct _reent and we
simply declare a variable in reent/impure.c which is _global_atexit0 and add a
define which is _GLOBAL_ATEXIT0.  The __atexit.c can be changed to use
_GLOBAL_ATEXIT0 instead of _GLOBAL_REENT->_atexit0.

This is a good solution. I will provide a patch for this in the next couple of days.

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]