libstdc++: Fix <stop_token> to compile without gthreads
authorJonathan Wakely <jwakely@redhat.com>
Tue, 11 Aug 2020 15:16:21 +0000 (16:16 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 11 Aug 2020 15:16:21 +0000 (16:16 +0100)
libstdc++-v3/ChangeLog:

* include/std/stop_token: Check _GLIBCXX_HAS_GTHREADS using
#ifdef instead of #if.
(stop_token::_S_yield()): Check _GLIBCXX_HAS_GTHREADS before
using __gthread_yield.

libstdc++-v3/include/std/stop_token

index 847d12f7454e6ef0d7c415d1c07c4d5783f02448..ccec6fab15cf648e401cc687c70130f765fbd060 100644 (file)
@@ -105,7 +105,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
 #if defined __i386__ || defined __x86_64__
       __builtin_ia32_pause();
-#elif defined _GLIBCXX_USE_SCHED_YIELD
+#elif defined _GLIBCXX_HAS_GTHREADS && defined _GLIBCXX_USE_SCHED_YIELD
       __gthread_yield();
 #endif
     }
@@ -162,7 +162,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       std::atomic<value_type> _M_owners{1};
       std::atomic<value_type> _M_value{_S_ssrc_counter_inc};
       _Stop_cb* _M_head = nullptr;
-#if _GLIBCXX_HAS_GTHREADS
+#ifdef _GLIBCXX_HAS_GTHREADS
       __gthread_t _M_requester;
 #endif
 
@@ -237,7 +237,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
          }
        while (!_M_try_lock_and_stop(__old));
 
-#if _GLIBCXX_HAS_GTHREADS
+#ifdef _GLIBCXX_HAS_GTHREADS
        _M_requester = __gthread_self();
 #endif
 
@@ -266,7 +266,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
            if (!__destroyed)
              {
                __cb->_M_destroyed = nullptr;
-#if _GLIBCXX_HAS_GTHREADS
+#ifdef _GLIBCXX_HAS_GTHREADS
                // synchronize with destructor of stop_callback that owns *__cb
                __cb->_M_done.release();
 #endif
@@ -343,7 +343,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        // Callback is not in the list, so must have been removed by a call to
        // _M_request_stop.
 
-#if _GLIBCXX_HAS_GTHREADS
+#ifdef _GLIBCXX_HAS_GTHREADS
        // Despite appearances there is no data race on _M_requester. The only
        // write to it happens before the callback is removed from the list,
        // and removing it from the list happens before this read.