From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) by sourceware.org (Postfix) with ESMTPS id C8B1A383D832 for ; Thu, 12 May 2022 12:11:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C8B1A383D832 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embedded-brains.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embedded-brains.de Received: from sslproxy06.your-server.de ([78.46.172.3]) by dedi548.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1np7fZ-0001Nu-Bs for newlib@sourceware.org; Thu, 12 May 2022 14:11:49 +0200 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1np7fZ-00078P-GB for newlib@sourceware.org; Thu, 12 May 2022 14:11:49 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 3B7B448016D for ; Thu, 12 May 2022 14:11:49 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id TsSuCI1XaZft; Thu, 12 May 2022 14:11:49 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id EAAC848015A; Thu, 12 May 2022 14:11:48 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Up3K_l4GAzAZ; Thu, 12 May 2022 14:11:48 +0200 (CEST) Received: from joyce-tux.eb.localhost (unknown [10.10.171.30]) by mail.embedded-brains.de (Postfix) with ESMTPSA id BBE8348016B; Thu, 12 May 2022 14:11:48 +0200 (CEST) From: Matthew Joyce To: newlib@sourceware.org Subject: [PATCH v2 05/11] Remove __sinit_locks / __sinit_recursive_mutex Date: Thu, 12 May 2022 14:11:37 +0200 Message-Id: <20220512121143.21473-6-matthew.joyce@embedded-brains.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220512121143.21473-1-matthew.joyce@embedded-brains.de> References: <20220512121143.21473-1-matthew.joyce@embedded-brains.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authenticated-Sender: smtp-embedded@poldinet.de X-Virus-Scanned: Clear (ClamAV 0.103.5/26539/Thu May 12 10:04:41 2022) X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2022 12:11:56 -0000 From: Matt Joyce Removed __sinit_lock_acquire() and __sinit_lock_release(). Replace these with __sfp_lock_acquire() and __sfp_lock_release(), respectively. This eliminates a potential deadlock issue between __sinit() and __sfp(). Removed now unused __sinit_recursive_mutex. --- newlib/libc/stdio/findfp.c | 19 +++---------------- newlib/libc/stdio/local.h | 2 -- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index 66867e664..afbdad9b1 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -235,11 +235,11 @@ cleanup_stdio (struct _reent *ptr) void __sinit (struct _reent *s) { - __sinit_lock_acquire (); + __sfp_lock_acquire (); =20 if (s->__cleanup) { - __sinit_lock_release (); + __sfp_lock_release (); return; } =20 @@ -268,13 +268,12 @@ __sinit (struct _reent *s) stderr_init (s->_stderr); #endif /* _REENT_GLOBAL_STDIO_STREAMS */ =20 - __sinit_lock_release (); + __sfp_lock_release (); } =20 #ifndef __SINGLE_THREAD__ =20 __LOCK_INIT_RECURSIVE(static, __sfp_recursive_mutex); -__LOCK_INIT_RECURSIVE(static, __sinit_recursive_mutex); =20 void __sfp_lock_acquire (void) @@ -288,18 +287,6 @@ __sfp_lock_release (void) __lock_release_recursive (__sfp_recursive_mutex); } =20 -void -__sinit_lock_acquire (void) -{ - __lock_acquire_recursive (__sinit_recursive_mutex); -} - -void -__sinit_lock_release (void) -{ - __lock_release_recursive (__sinit_recursive_mutex); -} - /* Walkable file locking routine. */ static int __fp_lock (struct _reent * ptr __unused, FILE * fp) diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h index 30c534dcd..9c6f63fdb 100644 --- a/newlib/libc/stdio/local.h +++ b/newlib/libc/stdio/local.h @@ -287,8 +287,6 @@ char *_llicvt (char *, long long, char); #else void __sfp_lock_acquire (void); void __sfp_lock_release (void); -void __sinit_lock_acquire (void); -void __sinit_lock_release (void); #endif =20 /* Types used in positional argument support in vfprinf/vfwprintf. --=20 2.31.1