libstdc++: Fix semaphore to work with system_clock timeouts
authorJonathan Wakely <jwakely@redhat.com>
Thu, 22 Apr 2021 16:26:50 +0000 (17:26 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 22 Apr 2021 16:35:00 +0000 (17:35 +0100)
commit6924588774a02dec63fb4b0ad19aed303accc2d2
tree6cd0ea40f2e93ba7f24da4f44311bfbf7f08775b
parent58871c03318e080962f022f5d77db3c4fde3e351
libstdc++: Fix semaphore to work with system_clock timeouts

The __cond_wait_until_impl function takes a steady_clock timeout, but
then sometimes tries to compare it to a time from the system_clock,
which won't compile.  Additionally, that function gets called with
system_clock timeouts, which also won't compile. This makes the function
accept timeouts for either clock, and compare to the time from the right
clock.

This fixes the compilation error that was causing two tests to fail on
non-futex targets, so we can revert the r12-11 change to disable them.

libstdc++-v3/ChangeLog:

* include/bits/atomic_timed_wait.h (__cond_wait_until_impl):
Handle system_clock as well as steady_clock.
* testsuite/30_threads/semaphore/try_acquire_for.cc: Re-enable.
* testsuite/30_threads/semaphore/try_acquire_until.cc:
Re-enable.
libstdc++-v3/include/bits/atomic_timed_wait.h
libstdc++-v3/testsuite/30_threads/semaphore/try_acquire_for.cc
libstdc++-v3/testsuite/30_threads/semaphore/try_acquire_until.cc