Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/gcc/dist/libstdc++-v3 Add a walkaround for TLS...



details:   https://anonhg.NetBSD.org/src/rev/e2c6b12058a6
branches:  trunk
changeset: 819889:e2c6b12058a6
user:      kamil <kamil%NetBSD.org@localhost>
date:      Wed Dec 21 21:55:46 2016 +0000

description:
Add a walkaround for TLS bug in libstdc++ exposed with std::call_once

Currently std::call_once with libstdc++ works only with static linking.
Disable code path using __thread types and introduce FIXME_PR_51139.
Problem discussed in PR 51139

Functional std::call_once is required in LLVM and LLDB codebase.

Example code to test std::call_once:
#include <iostream>
#include <thread>
#include <mutex>
#include <cstdlib>
std::once_flag flag;
int main(int argc, char **argv)
{
        std::call_once(flag, [](){ std::cout << "Simple example: called once\n"; });
        return EXIT_SUCCESS;
}

Sponsored by <The NetBSD Foundation>

diffstat:

 external/gpl3/gcc/dist/libstdc++-v3/include/std/mutex  |  6 +++---
 external/gpl3/gcc/dist/libstdc++-v3/src/c++11/mutex.cc |  6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diffs (60 lines):

diff -r e5991fbc4405 -r e2c6b12058a6 external/gpl3/gcc/dist/libstdc++-v3/include/std/mutex
--- a/external/gpl3/gcc/dist/libstdc++-v3/include/std/mutex     Wed Dec 21 21:28:30 2016 +0000
+++ b/external/gpl3/gcc/dist/libstdc++-v3/include/std/mutex     Wed Dec 21 21:55:46 2016 +0000
@@ -695,7 +695,7 @@
       call_once(once_flag& __once, _Callable&& __f, _Args&&... __args);
   };
 
-#ifdef _GLIBCXX_HAVE_TLS
+#if defined(_GLIBCXX_HAVE_TLS) && defined(FIXME_PR_51139)
   extern __thread void* __once_callable;
   extern __thread void (*__once_call)();
 
@@ -722,7 +722,7 @@
     void
     call_once(once_flag& __once, _Callable&& __f, _Args&&... __args)
     {
-#ifdef _GLIBCXX_HAVE_TLS
+#if defined(_GLIBCXX_HAVE_TLS) && defined(FIXME_PR_51139)
       auto __bound_functor = std::__bind_simple(std::forward<_Callable>(__f),
           std::forward<_Args>(__args)...);
       __once_callable = std::__addressof(__bound_functor);
@@ -737,7 +737,7 @@
 
       int __e = __gthread_once(&__once._M_once, &__once_proxy);
 
-#ifndef _GLIBCXX_HAVE_TLS
+#if !defined(_GLIBCXX_HAVE_TLS) || !defined(FIXME_PR_51139)
       if (__functor_lock)
         __set_once_functor_lock_ptr(0);
 #endif
diff -r e5991fbc4405 -r e2c6b12058a6 external/gpl3/gcc/dist/libstdc++-v3/src/c++11/mutex.cc
--- a/external/gpl3/gcc/dist/libstdc++-v3/src/c++11/mutex.cc    Wed Dec 21 21:28:30 2016 +0000
+++ b/external/gpl3/gcc/dist/libstdc++-v3/src/c++11/mutex.cc    Wed Dec 21 21:55:46 2016 +0000
@@ -25,7 +25,7 @@
 #include <mutex>
 
 #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
-#ifndef _GLIBCXX_HAVE_TLS
+#if !defined(_GLIBCXX_HAVE_TLS) || !defined(FIXME_PR_51139)
 namespace
 {
   inline std::unique_lock<std::mutex>*&
@@ -41,7 +41,7 @@
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-#ifdef _GLIBCXX_HAVE_TLS
+#if defined(_GLIBCXX_HAVE_TLS) && defined(FIXME_PR_51139)
   __thread void* __once_callable;
   __thread void (*__once_call)();
 #else
@@ -76,7 +76,7 @@
   {
     void __once_proxy()
     {
-#ifndef _GLIBCXX_HAVE_TLS
+#if !defined(_GLIBCXX_HAVE_TLS) || !defined(FIXME_PR_51139)
       function<void()> __once_call = std::move(__once_functor);
       if (unique_lock<mutex>* __lock = __get_once_functor_lock_ptr())
       {



Home | Main Index | Thread Index | Old Index