public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r11-5495] libstdc++: Partially revert r11-5314
Date: Fri, 27 Nov 2020 12:25:28 +0000 (GMT)	[thread overview]
Message-ID: <20201127122528.88BE43971C75@sourceware.org> (raw)

https://gcc.gnu.org/g:0d7d69ca4a8c05d883e07ee42058c9c6b0c72370

commit r11-5495-g0d7d69ca4a8c05d883e07ee42058c9c6b0c72370
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Nov 27 11:00:15 2020 +0000

    libstdc++: Partially revert r11-5314
    
    The changes in r11-5314 are broken, because it means we don't use
    __gthread_once for the first few initializations, but after the program
    becomes multi-threaded we will repeat the initialization, using
    __gthread_once once this time. This leads to memory errors.
    
    The use of __is_single_threaded() in locale::id::_M_id() is OK, because
    the side effects are the same either way.
    
    libstdc++-v3/ChangeLog:
    
            * src/c++98/locale.cc (locale::facet::_S_get_c_locale()):
            Revert change to use __is_single_threaded.
            * src/c++98/locale_init.cc (locale::_S_initialize()):
            Likewise.

Diff:
---
 libstdc++-v3/src/c++98/locale.cc      | 2 +-
 libstdc++-v3/src/c++98/locale_init.cc | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/src/c++98/locale.cc b/libstdc++-v3/src/c++98/locale.cc
index 9b3fc351515..4c1612cc5dc 100644
--- a/libstdc++-v3/src/c++98/locale.cc
+++ b/libstdc++-v3/src/c++98/locale.cc
@@ -214,7 +214,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   locale::facet::_S_get_c_locale()
   {
 #ifdef __GTHREADS
-    if (!__gnu_cxx::__is_single_threaded())
+    if (__gthread_active_p())
       __gthread_once(&_S_once, _S_initialize_once);
     else
 #endif
diff --git a/libstdc++-v3/src/c++98/locale_init.cc b/libstdc++-v3/src/c++98/locale_init.cc
index fc8416ba01a..c3841ccbd3c 100644
--- a/libstdc++-v3/src/c++98/locale_init.cc
+++ b/libstdc++-v3/src/c++98/locale_init.cc
@@ -320,7 +320,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   locale::_S_initialize()
   {
 #ifdef __GTHREADS
-    if (!__gnu_cxx::__is_single_threaded())
+    if (__gthread_active_p())
       __gthread_once(&_S_once, _S_initialize_once);
 #endif
     if (!_S_classic)


                 reply	other threads:[~2020-11-27 12:25 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=20201127122528.88BE43971C75@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@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).