diff --git a/newlib/ChangeLog b/newlib/ChangeLog index eed9838c3..32306dc46 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,11 @@ +2005-02-07 Jeff Johnston + + * libc/stdio/findfp.c (__sinit): Protect with new lock. + (__sinit_lock): New lock. + (__sinit_lock_acquire, __sinit_lock_release): New functions. + * libc/stdio/local.h: Add reference to new __sinit locking + functions. + 2005-02-07 Jeff Johnston * libc/include/math.h (isfinite, isnormal, isunordered): Change diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index a9695ffff..e3270af38 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -163,6 +163,14 @@ _VOID _DEFUN(__sinit, (s), struct _reent *s) { + __sinit_lock_acquire (); + + if (s->__sdidinit) + { + __sinit_lock_release (); + return; + } + /* make sure we clean up on exit */ s->__cleanup = _cleanup_r; /* conservative */ s->__sdidinit = 1; @@ -192,11 +200,13 @@ _DEFUN(__sinit, (s), std (s->_stderr, __SWR | __SNBF, 2, s); + __sinit_lock_release (); } #ifndef __SINGLE_THREAD__ __LOCK_INIT_RECURSIVE(static, __sfp_lock); +__LOCK_INIT_RECURSIVE(static, __sinit_lock); _VOID _DEFUN_VOID(__sfp_lock_acquire) @@ -210,6 +220,18 @@ _DEFUN_VOID(__sfp_lock_release) __lock_release_recursive (__sfp_lock); } +_VOID +_DEFUN_VOID(__sinit_lock_acquire) +{ + __lock_acquire_recursive (__sinit_lock); +} + +_VOID +_DEFUN_VOID(__sinit_lock_release) +{ + __lock_release_recursive (__sinit_lock); +} + /* Walkable file locking routine. */ static int _DEFUN(__fp_lock, (ptr), diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h index 76c260473..1e132a5d5 100644 --- a/newlib/libc/stdio/local.h +++ b/newlib/libc/stdio/local.h @@ -95,7 +95,11 @@ char *_EXFUN(_llicvt,(char *, long long, char)); #ifdef __SINGLE_THREAD__ #define __sfp_lock_acquire() #define __sfp_lock_release() +#define __sinit_lock_acquire() +#define __sinit_lock_release() #else _VOID _EXFUN(__sfp_lock_acquire,(_VOID)); _VOID _EXFUN(__sfp_lock_release,(_VOID)); +_VOID _EXFUN(__sinit_lock_acquire,(_VOID)); +_VOID _EXFUN(__sinit_lock_release,(_VOID)); #endif