2004-03-09 Thomas Pfaff <tpfaff@gmx.net>

* libc/stdio/findfp.c (__sfp): Rename lock to __sfp_lock.
        Change __sfp_lock to static global.
        (__fp_lock): New static function.
        (__fp_unlock): Ditto.
        (__fp_lock_all): New function.
        (__fp_unlock_all): Ditto.
This commit is contained in:
Jeff Johnston 2004-03-09 21:27:37 +00:00
parent 58e9df0f91
commit 41c3da6ae1
2 changed files with 55 additions and 5 deletions

View File

@ -1,3 +1,12 @@
2004-03-09 Thomas Pfaff <tpfaff@gmx.net>
* libc/stdio/findfp.c (__sfp): Rename lock to __sfp_lock.
Change __sfp_lock to static global.
(__fp_lock): New static function.
(__fp_unlock): Ditto.
(__fp_lock_all): New function.
(__fp_unlock_all): Ditto.
2004-02-10 Christopher Faylor <cgf@redhat.com> 2004-02-10 Christopher Faylor <cgf@redhat.com>
* libm/mathfp/er_gamma.c (gamma): Add new non-reentrant function. * libm/mathfp/er_gamma.c (gamma): Add new non-reentrant function.

View File

@ -25,6 +25,10 @@
#include <sys/lock.h> #include <sys/lock.h>
#include "local.h" #include "local.h"
#ifndef __SINGLE_THREAD__
__LOCK_INIT(static, __sfp_lock);
#endif
static void static void
std (ptr, flags, file, data) std (ptr, flags, file, data)
FILE *ptr; FILE *ptr;
@ -87,9 +91,7 @@ __sfp (d)
struct _glue *g; struct _glue *g;
#ifndef __SINGLE_THREAD__ #ifndef __SINGLE_THREAD__
__LOCK_INIT(static, lock); __lock_acquire(__sfp_lock);
__lock_acquire(lock);
#endif #endif
if (!_GLOBAL_REENT->__sdidinit) if (!_GLOBAL_REENT->__sdidinit)
@ -104,7 +106,7 @@ __sfp (d)
break; break;
} }
#ifndef __SINGLE_THREAD__ #ifndef __SINGLE_THREAD__
__lock_release(lock); __lock_release(__sfp_lock);
#endif #endif
d->_errno = ENOMEM; d->_errno = ENOMEM;
return NULL; return NULL;
@ -112,7 +114,7 @@ __sfp (d)
found: found:
fp->_flags = 1; /* reserve this slot; caller sets real flags */ fp->_flags = 1; /* reserve this slot; caller sets real flags */
#ifndef __SINGLE_THREAD__ #ifndef __SINGLE_THREAD__
__lock_release(lock); __lock_release(__sfp_lock);
#endif #endif
fp->_p = NULL; /* no current pointer */ fp->_p = NULL; /* no current pointer */
fp->_w = 0; /* nothing to read or write */ fp->_w = 0; /* nothing to read or write */
@ -192,3 +194,42 @@ __sinit (s)
std (s->_stderr, __SWR | __SNBF, 2, s); std (s->_stderr, __SWR | __SNBF, 2, s);
} }
#ifndef __SINGLE_THREAD__
/* Walkable file locking routine. */
static int
__fp_lock (ptr)
FILE * ptr;
{
_flockfile(ptr);
return 0;
}
/* Walkable file unlocking routine. */
static int
__fp_unlock (ptr)
FILE * ptr;
{
_funlockfile(ptr);
return 0;
}
void
__fp_lock_all ()
{
__lock_acquire(__sfp_lock);
(void) _fwalk (_REENT, __fp_lock);
}
void
__fp_unlock_all ()
{
(void) _fwalk (_REENT, __fp_unlock);
__lock_release(__sfp_lock);
}
#endif