]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Make std::thread::_State private
authorJonathan Wakely <jwakely@redhat.com>
Thu, 12 May 2022 19:46:55 +0000 (20:46 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 13 May 2022 19:40:05 +0000 (20:40 +0100)
* include/bits/std_thread.h (thread::_State, thread::_State_ptr):
Declare as private unless _GLIBCXX_THREAD_IMPL is defined.
* src/c++11/thread.cc (_GLIBCXX_THREAD_IMPL): Define.

libstdc++-v3/include/bits/std_thread.h
libstdc++-v3/src/c++11/thread.cc

index f67bc114591f43190a2ae4f076f4538d671e8a1e..d7fc0123564ad46cfed5daf253213d485c0af5cc 100644 (file)
@@ -79,15 +79,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   {
   public:
 #ifdef _GLIBCXX_HAS_GTHREADS
-    // Abstract base class for types that wrap arbitrary functors to be
-    // invoked in the new thread of execution.
-    struct _State
-    {
-      virtual ~_State();
-      virtual void _M_run() = 0;
-    };
-    using _State_ptr = unique_ptr<_State>;
-
     using native_handle_type = __gthread_t;
 #else
     using native_handle_type = int;
@@ -216,6 +207,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     hardware_concurrency() noexcept;
 
 #ifdef _GLIBCXX_HAS_GTHREADS
+#ifndef _GLIBCXX_THREAD_IMPL
+  private:
+#endif
+    // Abstract base class for types that wrap arbitrary functors to be
+    // invoked in the new thread of execution.
+    struct _State
+    {
+      virtual ~_State();
+      virtual void _M_run() = 0;
+    };
+    using _State_ptr = unique_ptr<_State>;
+
   private:
     template<typename _Callable>
       struct _State_impl : public _State
index 669fbb045e2e7c30dcb5af3d01b2b3f767892c3a..707a4ad415b935d27aac5b5dcbe10622d7e85932 100644 (file)
@@ -24,6 +24,7 @@
 
 
 #define _GLIBCXX_THREAD_ABI_COMPAT 1
+#define _GLIBCXX_THREAD_IMPL 1
 #include <memory> // include this first so <thread> can use shared_ptr
 #include <thread>
 #include <system_error>