public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: "Torbjörn SVENSSON" <torbjorn.svensson@foss.st.com>
To: <newlib@sourceware.org>
Cc: "Torbjörn SVENSSON" <torbjorn.svensson@foss.st.com>
Subject: [PATCH] Restore _lock initialization in single threaded mode
Date: Mon, 29 Aug 2022 17:10:49 +0200	[thread overview]
Message-ID: <20220829151049.3320719-1-torbjorn.svensson@foss.st.com> (raw)

When __SINGLE_THREAD__ is defined, stdin, stdout and stderr needs to
have their _lock instance initialized. The __sfp() method is not
invoked for the 3 mentioned fds thus, the std() method needs to handle
the initialization of the lock.

This is more or less a revert of 382550072b49430f8c69adee937a0ba07bd385e6

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
---
 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 c43028209..f7249f6d7 100644
--- a/newlib/libc/stdio/findfp.c
+++ b/newlib/libc/stdio/findfp.c
@@ -88,6 +88,10 @@ std (FILE *ptr,
 #else /* _STDIO_CLOSE_STD_STREAMS */
   ptr->_close = NULL;
 #endif /* _STDIO_CLOSE_STD_STREAMS */
+#ifndef __SINGLE_THREAD__
+  if (ptr == &__sf[0] || ptr == &__sf[1] || ptr == &__sf[2])
+    __lock_init_recursive (&ptr->_lock);
+#endif
 #ifdef __SCLE
   if (__stextmode (ptr->_file))
     ptr->_flags |= __SCLE;
-- 
2.25.1


             reply	other threads:[~2022-08-29 15:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-29 15:10 Torbjörn SVENSSON [this message]
2022-08-29 19:33 ` Jeff Johnston
2022-08-29 19:35   ` Torbjorn SVENSSON
2022-08-29 18:18 Torbjörn SVENSSON
2022-08-29 18:18 ` Torbjörn SVENSSON

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220829151049.3320719-1-torbjorn.svensson@foss.st.com \
    --to=torbjorn.svensson@foss.st.com \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).