diff options
Diffstat (limited to 'newlib/libc/stdio/findfp.c')
-rw-r--r-- | newlib/libc/stdio/findfp.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index 0beb1e5b0..570fd457e 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -108,7 +108,7 @@ _DEFUN(__sfp, (d), int n; struct _glue *g; - _newlib_sfp_lock_start (); + __sfp_lock_acquire (); if (!_GLOBAL_REENT->__sdidinit) __sinit (_GLOBAL_REENT); @@ -121,7 +121,7 @@ _DEFUN(__sfp, (d), (g->_next = __sfmoreglue (d, NDYNAMIC)) == NULL) break; } - _newlib_sfp_lock_exit (); + __sfp_lock_release (); d->_errno = ENOMEM; return NULL; @@ -132,7 +132,7 @@ found: #ifndef __SINGLE_THREAD__ __lock_init_recursive (fp->_lock); #endif - _newlib_sfp_lock_end (); + __sfp_lock_release (); fp->_p = NULL; /* no current pointer */ fp->_w = 0; /* nothing to read or write */ @@ -192,6 +192,7 @@ _DEFUN(__sinit, (s), /* make sure we clean up on exit */ s->__cleanup = _cleanup_r; /* conservative */ + s->__sdidinit = 1; s->__sglue._next = NULL; #ifndef _REENT_SMALL @@ -200,11 +201,6 @@ _DEFUN(__sinit, (s), #else s->__sglue._niobs = 0; s->__sglue._iobs = NULL; - /* Avoid infinite recursion when calling __sfp for _GLOBAL_REENT. The - problem is that __sfp checks for _GLOBAL_REENT->__sdidinit and calls - __sinit if it's 0. */ - if (s == _GLOBAL_REENT) - s->__sdidinit = 1; s->_stdin = __sfp(s); s->_stdout = __sfp(s); s->_stderr = __sfp(s); @@ -228,8 +224,6 @@ _DEFUN(__sinit, (s), when the underlying fd 2 is write-only. */ std (s->_stderr, __SRW | __SNBF, 2, s); - s->__sdidinit = 1; - __sinit_lock_release (); } |