[RTEMS Project] #3870: libc_reent set up is broken

RTEMS trac trac at rtems.org
Tue Feb 11 03:44:18 UTC 2020


#3870: libc_reent set up is broken
-------------------------+---------------------
 Reporter:  Chris Johns  |       Owner:  (none)
     Type:  defect       |      Status:  new
 Priority:  high         |   Milestone:  5.1
Component:  score        |     Version:  5
 Severity:  normal       |  Resolution:
 Keywords:               |  Blocked By:
 Blocking:  3859         |
-------------------------+---------------------

Comment (by Chris Johns):

 I see the reent struct is appended to the end of the TCB struct so a
 single allocation is made. This is nice but it is not easy to see.

 The re-entrant struct is initialised the same way in the patch as before
 so the original initialisation is does not allow access to `stdin` or
 `stdout` until after a suitable newlib call has been made.

 There is no public interface to call `__sinit`, a call to newlib has to be
 made. The newlib code uses an internal macro called `CHECK_INIT` and it
 does:

 {{{
      if ((_check_init_ptr) && !(_check_init_ptr)->__sdidinit)   \
         __sinit (_check_init_ptr);
 }}}

 I wonder if our `__getreent` could ...
 {{{
 struct _reent *__getreent(void)
 {
   struct _reent *_reent_ptr = _Thread_Get_executing()->libc_reent;
   if (!_reent_ptr->__sdidinit)
     feof(_reent_ptr->stdout);
   return _reent_ptr;
 }
 }}}
 ?

--
Ticket URL: <http://devel.rtems.org/ticket/3870#comment:1>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list