From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Add missing return and use reserved name
Date: Mon, 15 Feb 2021 15:52:44 +0000 [thread overview]
Message-ID: <YCqYzG2QKBM+R93r@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 571 bytes --]
The once_flag::_M_activate() function is only ever called immediately
after a call to once_flag::_M_passive(), and so in the non-gthreads case
it is impossible for _M_passive() to be true in the body of
_M_activate(). Add a check for it anyway, to avoid warnings about
missing return.
Also replace a non-reserved name with a reserved one.
libstdc++-v3/ChangeLog:
* include/std/mutex (once_flag::_M_activate()): Add explicit
return statement for passive case.
(once_flag::_M_finish(bool)): Use reserved name for parameter.
Tested x86_64-linux. Committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2036 bytes --]
commit d27153f038c2f39ed1b7e6ba9dab59f88b8ca245
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Mon Feb 15 14:00:36 2021
libstdc++: Add missing return and use reserved name
The once_flag::_M_activate() function is only ever called immediately
after a call to once_flag::_M_passive(), and so in the non-gthreads case
it is impossible for _M_passive() to be true in the body of
_M_activate(). Add a check for it anyway, to avoid warnings about
missing return.
Also replace a non-reserved name with a reserved one.
libstdc++-v3/ChangeLog:
* include/std/mutex (once_flag::_M_activate()): Add explicit
return statement for passive case.
(once_flag::_M_finish(bool)): Use reserved name for parameter.
diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex
index 25e580cf0fc..f96c48e88ec 100644
--- a/libstdc++-v3/include/std/mutex
+++ b/libstdc++-v3/include/std/mutex
@@ -706,6 +706,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool _M_activate();
// Must be called to complete an active execution.
+ // The argument is true if the active execution was a returning execution,
+ // false if it was an exceptional execution.
void _M_finish(bool __returning) noexcept;
// RAII helper to call _M_finish.
@@ -742,18 +744,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
inline bool
once_flag::_M_activate()
{
- if (_M_once == _Bits::_Init)
+ if (_M_once == _Bits::_Init) [[__likely__]]
{
_M_once = _Bits::_Active;
return true;
}
- else if (!_M_passive())
+ else if (_M_passive()) // Caller should have checked this already.
+ return false;
+ else
__throw_system_error(EDEADLK);
}
inline void
- once_flag::_M_finish(bool returning) noexcept
- { _M_once = returning ? _Bits::_Done : _Bits::_Init; }
+ once_flag::_M_finish(bool __returning) noexcept
+ { _M_once = __returning ? _Bits::_Done : _Bits::_Init; }
#elif defined _GLIBCXX_HAVE_LINUX_FUTEX
reply other threads:[~2021-02-15 15:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=YCqYzG2QKBM+R93r@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.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).