From 6a150987938abfef78f72d0bf4ed6b427b25e040 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Thu, 15 Jan 2004 19:12:17 +0000 Subject: [PATCH] 2004-01-15 Thomas Pfaff * libc/stdio/fclose.c: Include sys/lock.h. (fclose): Destroy lock when file is closed. * libc/stdio/findfp.c (__sfp): Initialize file pointers _lock member. * libc/stdio/freopen.c: Include sys/lock.h. (_freopen_r): Destroy lock when file is closed. * libc/stdio/vfprintf.c (__sbprintf): Initialize file pointers _lock member. --- newlib/ChangeLog | 11 +++++++++++ newlib/libc/stdio/fclose.c | 5 +++++ newlib/libc/stdio/findfp.c | 4 ++++ newlib/libc/stdio/freopen.c | 4 ++++ newlib/libc/stdio/vfprintf.c | 3 +++ 5 files changed, 27 insertions(+) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 5927e5701..4d84d5062 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,14 @@ +2004-01-15 Thomas Pfaff + + * libc/stdio/fclose.c: Include sys/lock.h. + (fclose): Destroy lock when file is closed. + * libc/stdio/findfp.c (__sfp): Initialize file pointers _lock + member. + * libc/stdio/freopen.c: Include sys/lock.h. + (_freopen_r): Destroy lock when file is closed. + * libc/stdio/vfprintf.c (__sbprintf): Initialize file pointers + _lock member. + 2004-01-08 Joel Sherrill * libc/ctype/iswctype.c, include/sys/reent.h, libc/stdlib/a64l.c: diff --git a/newlib/libc/stdio/fclose.c b/newlib/libc/stdio/fclose.c index b8cd51dc1..630cd4192 100644 --- a/newlib/libc/stdio/fclose.c +++ b/newlib/libc/stdio/fclose.c @@ -50,6 +50,7 @@ Required OS subroutines: <>, <>, <>, <>, #include #include #include "local.h" +#include /* * Close a file. @@ -84,5 +85,9 @@ _DEFUN (fclose, (fp), FREELB (fp); fp->_flags = 0; /* release this FILE for reuse */ _funlockfile(fp); +#ifndef __SINGLE_THREAD__ + __lock_close_recursive (*(_LOCK_RECURSIVE_T *)&fp->_lock); +#endif + return (r); } diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index 2a907bb6d..efbb62561 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -114,6 +114,10 @@ found: fp->_ub._size = 0; fp->_lb._base = NULL; /* no line buffer */ fp->_lb._size = 0; +#ifndef __SINGLE_THREAD__ + memset (&fp->_lock, 0, sizeof(fp->_lock)); +#endif + return fp; } diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c index 9010adcf7..6d54789da 100644 --- a/newlib/libc/stdio/freopen.c +++ b/newlib/libc/stdio/freopen.c @@ -71,6 +71,7 @@ Supporting OS subroutines required: <>, <>, <>, #include #include #include "local.h" +#include /* * Re-direct an existing, open (probably) file to some other file. @@ -150,6 +151,9 @@ _DEFUN (_freopen_r, (ptr, file, mode, fp), fp->_flags = 0; /* set it free */ ptr->_errno = e; /* restore in case _close clobbered */ _funlockfile(fp); +#ifndef __SINGLE_THREAD__ + __lock_close_recursive (*(_LOCK_RECURSIVE_T *)&fp->_lock); +#endif return NULL; } diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index 7015740e0..c13a7f70f 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -252,6 +252,9 @@ __sbprintf(fp, fmt, ap) fake._bf._base = fake._p = buf; fake._bf._size = fake._w = sizeof(buf); fake._lbfsize = 0; /* not actually used, but Just In Case */ +#ifndef __SINGLE_THREAD__ + memset (&fake._lock, 0, sizeof(fake._lock)); +#endif /* do the work, then copy any error status */ ret = VFPRINTF(&fake, fmt, ap); -- 2.43.5