libstdc++: Fix __thread_relax for non-gthreads non-x86 targets
authorJonathan Wakely <jwakely@redhat.com>
Fri, 19 Feb 2021 09:54:04 +0000 (09:54 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 19 Feb 2021 09:56:36 +0000 (09:56 +0000)
My recent change to the preprocessor conditions in __thread_relax() was
supposed to also change the __gthread_yield() call to __thread_yield(),
which has the right preprocessor checks. Instead I just removed the
check for _GLIBCXX_USE_SCHED_YIELD which means the __gthread_yield()
call will be ill-formed for non-gthreads targets, and targets without
sched_yield(). This fixes it properly.

libstdc++-v3/ChangeLog:

* include/bits/atomic_wait.h (__thread_relax()): Call
__thread_yield() not __gthread_yield().

libstdc++-v3/include/bits/atomic_wait.h

index 37085ae8e50e63f8d48a894663c9f7606b435038..424fccbe4c5d090ba3154f4770919cbf0f346d26 100644 (file)
@@ -217,7 +217,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __thread_yield() noexcept
     {
 #if defined _GLIBCXX_HAS_GTHREADS && defined _GLIBCXX_USE_SCHED_YIELD
-     __gthread_yield();
+      __gthread_yield();
 #endif
     }
 
@@ -227,7 +227,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #if defined __i386__ || defined __x86_64__
       __builtin_ia32_pause();
 #else
-      __gthread_yield();
+      __thread_yield();
 #endif
     }
   } // namespace __detail