/* This is the replacement for newlib's _REENT_INIT_PTR and __sinit. The problem with __sinit is that it allocates three FILE structures (stdin, stdout, stderr). Having individual standard streams for each task is a bit too much on a small embedded system. So we point streams to the streams of the global struct _reent, which are initialized in startup code.  */
void IRAM_ATTR esp_reent_init(struct _reent *r)
/* This is the replacement for newlib's _REENT_INIT_PTR and __sinit. The problem with __sinit is that it allocates three FILE structures (stdin, stdout, stderr). Having individual standard streams for each task is a bit too much on a small embedded system. So we point streams to the streams of the global struct _reent, which are initialized in startup code.  */
void IRAM_ATTR esp_reent_init(struct _reent *r)
{
    memset(r, 0, sizeof(*r));
    r->_stdout = _GLOBAL_REENT->_stdout;
    r->_stderr = _GLOBAL_REENT->_stderr;
    r->_stdin  = _GLOBAL_REENT->_stdin;
    r->__cleanup = &_cleanup_r;
    r->__sdidinit = 1;
    r->__sglue._next = NULL;
    r->__sglue._niobs = 0;
    r->__sglue._iobs = NULL;
    r->_current_locale = "C";
}