[PATCH] Fix __fp_lock_all() and __fp_unlock_all()

Sebastian Huber sebastian.huber@embedded-brains.de
Wed May 18 17:13:05 GMT 2022


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



More information about the Newlib mailing list