diff options
author | Mike Crowe <mac@mcrowe.com> | 2020-09-11 14:25:00 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2020-09-11 14:28:50 +0100 |
commit | e05ff30078e80869f2bf3af6dbdbea134c252158 (patch) | |
tree | 6c76570dc68fb584ed2a54c7d05007fda53b4347 /gcc/genconstants.c | |
parent | f9ddb696a289cc48d24d3d23c0b324cb88de9573 (diff) | |
download | gcc-e05ff30078e80869f2bf3af6dbdbea134c252158.zip gcc-e05ff30078e80869f2bf3af6dbdbea134c252158.tar.gz gcc-e05ff30078e80869f2bf3af6dbdbea134c252158.tar.bz2 |
libstdc++: Avoid rounding errors on custom clocks in condition_variable
The fix for PR68519 in 83fd5e73b3c16296e0d7ba54f6c547e01c7eae7b only
applied to condition_variable::wait_for. This problem can also apply to
condition_variable::wait_until but only if the custom clock is using a
more recent epoch so that a small enough delta can be calculated. let's
use the newly-added chrono::__detail::ceil to fix this and also make use
of that function to simplify the previous wait_for fixes.
Also, simplify the existing test case for PR68519 a little and make its
variables local so we can add a new test case for the above problem.
Unfortunately, the test would have only started failing if sufficient
time has passed since the chrono::steady_clock epoch had passed anyway,
but it's better than nothing.
libstdc++-v3/ChangeLog:
* include/std/condition_variable (condition_variable::wait_until):
Convert delta to steady_clock duration before adding to current
steady_clock time to avoid rounding errors described in PR68519.
(condition_variable::wait_for): Simplify calculation of absolute
time by using chrono::__detail::ceil in both overloads.
* testsuite/30_threads/condition_variable/members/68519.cc:
(test_wait_for): Renamed from test01. Replace unassigned val
variable with constant false. Reduce scope of mx and cv
variables to just test_wait_for function.
(test_wait_until): Add new test case.
Diffstat (limited to 'gcc/genconstants.c')
0 files changed, 0 insertions, 0 deletions