libc_wrapup() and _Thread_Dispatch()

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Apr 23 12:05:35 UTC 2013


Hello,

why is libc_wrapup() a global function.  It is used only inside of newlibc_exit.c.

In libc_wrapup():

   /*
    *  This was already done if the user called exit() directly .
   _wrapup_reent(0);
    */

   if (_REENT != _global_impure_ptr) {
       _wrapup_reent(_global_impure_ptr);
#if 0
       /*  Don't reclaim this one, just in case we do printfs
        *  on the way out to ROM.
        */
       _reclaim_reent(&libc_global_reent);
#endif
       _REENT = _global_impure_ptr;
   }

What is the reason for this code?  The Newlib exit() already calls 
__call_exitprocs() before it calls _exit().  According to POSIX _exit() shall 
not call functions registered with atexit() nor any registered signal handlers.

In _Thread_Dispatch():

     /*
      * Switch libc's task specific data.
      */
     if ( _Thread_libc_reent ) {
       executing->libc_reent = *_Thread_libc_reent;
       *_Thread_libc_reent = heir->libc_reent;
     }

What is the reason for the "executing->libc_reent = *_Thread_libc_reent;" 
assignment.  I think this is a bug since it destroys the value created by 
newlib_create_hook() for the initialization task.  From my point of view are 
the newlib hooks the only entities that should touch thread->libc_reent.

-- 
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 at embedded-brains.de
PGP     : Public key available on request.

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



More information about the devel mailing list