[PATCH] libstdc++: Add C++2a synchronization support

Jonathan Wakely jwakely@redhat.com
Tue Sep 29 09:44:46 GMT 2020


On 28/09/20 14:29 -0700, Thomas Rodgers wrote:
>>>+    template<typename _Duration>
>>>+      __atomic_wait_status
>>>+      __platform_wait_until_impl(__platform_wait_t* __addr,
>>>+				 __platform_wait_t __val,
>>>+				 const chrono::time_point<__platform_wait_clock_t,
>>>+							  _Duration>& __atime) noexcept
>>>+      {
>>>+	auto __s = chrono::time_point_cast<chrono::seconds>(__atime);
>>>+	auto __ns = chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
>>>+
>>>+	struct timespec __rt =
>>>+	{
>>>+	  static_cast<std::time_t>(__s.time_since_epoch().count()),
>>>+	  static_cast<long>(__ns.count())
>>>+	};
>>>+
>>>+	auto __e = syscall (SYS_futex, __addr,
>>>+			      static_cast<int>(__futex_wait_flags::__wait_bitset_private),
>>>+			      __val, &__rt, nullptr,
>>>+			      static_cast<int>(__futex_wait_flags::__bitset_match_any));
>>>+	if (__e && !(errno == EINTR || errno == EAGAIN || errno == ETIMEDOUT))
>>>+	    std::terminate();
>>>+	return (__platform_wait_clock_t::now() < __atime)
>>>+	       ? __atomic_wait_status::no_timeout : __atomic_wait_status::timeout;
>>>+      }
>>>+
>>>+    template<typename _Clock, typename _Duration>
>>>+      __atomic_wait_status
>>>+      __platform_wait_until(__platform_wait_t* __addr, __platform_wait_t __val,
>>>+			    const chrono::time_point<_Clock, _Duration>& __atime)
>>>+      {
>>>+	if constexpr (is_same_v<__platform_wait_clock_t, _Clock>)
>>
>> This case is impossible, since the other overload would be selected
>> if the clock is the __platform_wait_clock_t (unless the caller says
>> __platform_wait_until<__platform_wait_until> to explicitly call this
>> overload, but users can't call this function, and we won't do that).
>>
>
>Which overload?


I must have misread __platform_wait_until_impl above as
__platform_wait_until. Ignore this comment, sorry!




More information about the Gcc-patches mailing list