diff options
author | Mike Crowe <mac@mcrowe.com> | 2020-10-05 11:12:38 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2020-10-05 11:32:10 +0100 |
commit | f33a43f9f7eab7482837662821abb7fd02cb4350 (patch) | |
tree | ef6c5a6fe39f3d02ec61799440b7a4199ee6679c /libstdc++-v3/include | |
parent | d5243c46266f92f8e5373c3f314aa2abc15c9db4 (diff) | |
download | gcc-f33a43f9f7eab7482837662821abb7fd02cb4350.zip gcc-f33a43f9f7eab7482837662821abb7fd02cb4350.tar.gz gcc-f33a43f9f7eab7482837662821abb7fd02cb4350.tar.bz2 |
libstdc++: Use correct duration for atomic_futex wait on custom clock [PR 91486]
As Jonathan Wakely pointed out[1], my change in commit
f9ddb696a289cc48d24d3d23c0b324cb88de9573 should have been rounding to
the target clock duration type rather than the input clock duration type
in __atomic_futex_unsigned::_M_load_when_equal_until just as (e.g.)
condition_variable does.
As well as fixing this, let's create a rather contrived test that fails
with the previous code, but unfortunately only when run on a machine
with an uptime of over 208.5 days, and even then not always.
[1] https://gcc.gnu.org/pipermail/libstdc++/2020-September/051004.html
libstdc++-v3/ChangeLog:
PR libstdc++/91486
* include/bits/atomic_futex.h:
(__atomic_futex_unsigned::_M_load_when_equal_until): Use target
clock duration type when rounding.
* testsuite/30_threads/async/async.cc (test_pr91486_wait_for):
Rename from test_pr91486.
(float_steady_clock): New class for test.
(test_pr91486_wait_until): New test.
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/bits/atomic_futex.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libstdc++-v3/include/bits/atomic_futex.h b/libstdc++-v3/include/bits/atomic_futex.h index aa137a7..6093be0 100644 --- a/libstdc++-v3/include/bits/atomic_futex.h +++ b/libstdc++-v3/include/bits/atomic_futex.h @@ -235,7 +235,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const __clock_t::time_point __s_entry = __clock_t::now(); const auto __delta = __atime - __c_entry; const auto __s_atime = __s_entry + - chrono::__detail::ceil<_Duration>(__delta); + chrono::__detail::ceil<__clock_t::duration>(__delta); if (_M_load_when_equal_until(__val, __mo, __s_atime)) return true; __c_entry = _Clock::now(); |