diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2005-02-08 01:05:50 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2005-02-08 01:05:50 +0000 |
commit | 3d915670882af692d4a10e1f2559fb7e37194b6b (patch) | |
tree | a5950d0c7fb3ec1ca2f079e779990cc1ce9911a6 /newlib/libc | |
parent | b59cab1e2e90ca4ffb19eaf073f03917dc8eb0e9 (diff) | |
download | newlib-3d915670882af692d4a10e1f2559fb7e37194b6b.zip newlib-3d915670882af692d4a10e1f2559fb7e37194b6b.tar.gz newlib-3d915670882af692d4a10e1f2559fb7e37194b6b.tar.bz2 |
2005-02-07 Jeff Johnston <jjohnstn@redhat.com>
* 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.
Diffstat (limited to 'newlib/libc')
-rw-r--r-- | newlib/libc/stdio/findfp.c | 22 | ||||
-rw-r--r-- | newlib/libc/stdio/local.h | 4 |
2 files changed, 26 insertions, 0 deletions
diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index a9695ff..e3270af 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 76c2604..1e132a5 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 |