[PATCH] Fix __fp_lock_all() and __fp_unlock_all()

Sebastian Huber <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
For _REENT_GLOBAL_STDIO_STREAMS, lock/unlock all FILE objects.  In the
repository, this function is only used by Cygwin during process forks.  Since
Cygwin enabled _REENT_GLOBAL_STDIO_STREAMS recently, without this fix no FILE
object at all was locked.
---
 newlib/libc/stdio/findfp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c
index 6933ff1db..a39082387 100644
--- a/newlib/libc/stdio/findfp.c
+++ b/newlib/libc/stdio/findfp.c
@@ -333,6 +333,8 @@ __fp_lock_all (void)
 #ifndef _REENT_GLOBAL_STDIO_STREAMS
   ptr = _REENT;
   (void) _fwalk_sglue (ptr, __fp_lock, &ptr->__sglue);
+#else
+  (void) _fwalk_sglue (NULL, __fp_lock, &__sglue);
 #endif
 }
 
@@ -344,6 +346,8 @@ __fp_unlock_all (void)
 
   ptr = _REENT;
   (void) _fwalk_sglue (ptr, __fp_unlock, &ptr->__sglue);
+#else
+  (void) _fwalk_sglue (NULL, __fp_unlock, &__sglue);
 #endif
 
   __sfp_lock_release ();
-- 
2.35.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.