GCC 11.1 Release Candidate available from gcc.gnu.org

Jonathan Wakely jwakely@redhat.com
Wed Apr 21 14:30:19 GMT 2021


On 21/04/21 13:12 +0100, Jonathan Wakely wrote:
>On 21/04/21 12:38 +0100, Jonathan Wakely wrote:
>>On 20/04/21 22:12 -0700, Thomas Rodgers wrote:
>>>@@ -86,6 +88,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>>>	}
>>>   }
>>>
>>>+    _GLIBCXX_ALWAYS_INLINE bool
>>>+    _M_try_acquire() noexcept
>>>+    {
>>>+      for (;;)
>>>+	{
>>>+	  auto __err = sem_trywait(&_M_semaphore);
>>>+	  if (__err && (errno == EINTR))
>>>+	    continue;
>>>+	  else if (__err && (errno == EAGAIN))
>>>+	    return false;
>>>+	  else if (__err)
>>>+	    std::terminate();
>>>+	  else
>>>+	    break;
>>>+	}
>>>+      return true;
>>>+    }
>>>+
>>>   _GLIBCXX_ALWAYS_INLINE void
>>>   _M_release(std::ptrdiff_t __update) noexcept
>>>   {
>>
>>Please just commit this part to trunk and gcc-11, not the macro
>>renaming (as that's been fixed by Jakub already).
>
>I think on trunk I'd prefer to do the attached. WDYT?

In fact I think something like this is neded even on gcc-11 branch,
otherwise anything that tries to include <semaphore> without atomics
or sem_t gets hard errors:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100179

And <thread> includes <stop_token> which includes <semaphore>, meaning
<thread> is unusable on those targets.

So I think removing this #error is essential:
  
>-// Note: the _GLIBCXX_REQUIRE_POSIX_SEMAPHORE macro can be used to force the
>-// use of Posix semaphores (sem_t). Doing so however, alters the ABI.
>-#if defined __cpp_lib_atomic_wait && !_GLIBCXX_REQUIRE_POSIX_SEMAPHORE
>   using __semaphore_impl = __atomic_semaphore;
>-#elif _GLIBCXX_HAVE_POSIX_SEMAPHORE
>-  using __semaphore_impl = __platform_semaphore;
>-#else
>-#  error "No suitable semaphore implementation available"
>-#endif
>+#endif // __cpp_lib_atomic_wait



More information about the Libstdc++ mailing list