[committed] libstdc++: Fix __thread_yield for non-gthreads targets
Jonathan Wakely
jwakely@redhat.com
Fri Feb 19 11:14:13 GMT 2021
On 15/02/21 16:13 +0000, Jonathan Wakely wrote:
>The __gthread_yield() function is only defined for gthreads targets, so
>check _GLIBCXX_HAS_GTHREADS before using it.
>
>Also reorder __thread_relax and __thread_yield so that the former can
>use the latter instead of repeating the same preprocessor checks.
>
>libstdc++-v3/ChangeLog:
>
> * include/bits/atomic_wait.h (__thread_yield()): Check
> _GLIBCXX_HAS_GTHREADS before using __gthread_yield.
> (__thread_relax()): Use __thread_yield() instead of repeating
> the preprocessor checks for __gthread_yield.
>--- a/libstdc++-v3/include/bits/atomic_wait.h
>+++ b/libstdc++-v3/include/bits/atomic_wait.h
>@@ -213,24 +213,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> { _M_w._M_do_wait(_M_version); }
> };
>
>- inline void
>- __thread_relax() noexcept
>- {
>-#if defined __i386__ || defined __x86_64__
>- __builtin_ia32_pause();
>-#elif defined _GLIBCXX_USE_SCHED_YIELD
>- __gthread_yield();
>-#endif
>- }
>-
> inline void
> __thread_yield() noexcept
> {
>-#if defined _GLIBCXX_USE_SCHED_YIELD
>+#if defined _GLIBCXX_HAS_GTHREADS && defined _GLIBCXX_USE_SCHED_YIELD
> __gthread_yield();
> #endif
> }
>
>+ inline void
>+ __thread_relax() noexcept
>+ {
>+#if defined __i386__ || defined __x86_64__
>+ __builtin_ia32_pause();
>+#else
>+ __gthread_yield();
As I said in the ChangeLog, this was supposed to be changed from
__gthread_yield to __thread_yield. Fixed by this patch.
Tested powerpc64le-linux. Committed to trunk.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 1453 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20210219/9a3b1772/attachment-0001.bin>
More information about the Libstdc++
mailing list