diff options
author | Mike Crowe <mac@mcrowe.com> | 2019-09-04 22:43:29 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2019-09-04 23:43:29 +0100 |
commit | ad4d1d21ad5c515ba90355d13b14cbb74262edd2 (patch) | |
tree | 37c354f2ea9e5d08fcd05367233f4cb01e5ddba3 /libstdc++-v3/configure.ac | |
parent | 76e0dd66c87720a8a82a6d5f44ba4d8f63a51b1d (diff) | |
download | gcc-ad4d1d21ad5c515ba90355d13b14cbb74262edd2.tar.gz |
PR libstdc++/41861 Add full steady_clock support to condition_variable
The pthread_cond_clockwait function is available in glibc since the 2.30
release. If this function is available in the C library it can be used
to fix PR libstdc++/41861 by supporting std::chrono::steady_clock
properly with std::condition_variable.
This means that code using std::condition_variable::wait_for or
std::condition_variable::wait_until with std::chrono::steady_clock is no
longer subject to timing out early or potentially waiting for much
longer if the system clock is warped at an inopportune moment.
If pthread_cond_clockwait is available then std::chrono::steady_clock is
deemed to be the "best" clock available which means that it is used for
the relative wait_for calls and absolute wait_until calls using
user-defined clocks. Calls explicitly using std::chrono::system_clock
continue to use CLOCK_REALTIME via __gthread_cond_timedwait.
If pthread_cond_clockwait is not available then
std::chrono::system_clock is deemed to be the "best" clock available
which means that the previous suboptimal behaviour remains.
2019-09-04 Mike Crowe <mac@mcrowe.com>
PR libstdc++/41861
* acinclude.m4 (GLIBCXX_CHECK_PTHREAD_COND_CLOCKWAIT): Check for new
pthread_cond_clockwait function.
* configure.ac: Use GLIBCXX_CHECK_PTHREAD_COND_CLOCKWAIT.
* configure: Regenerate.
* config.h.in: Regenerate.
* include/std/condition_variable: (condition_variable): Rename
__steady_clock_t typedef and add system_clock. Change __clock_t to be
a typedef for the preferred clock to convert arbitrary other clocks to.
[_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT] (wait_until): Add a steady_clock
overload.
(wait_until): Change __clock_t overload to use system_clock.
[_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT] (__wait_until_impl): Add
steady_clock overload that calls pthread_cond_clockwait.
(__wait_until_impl): Change __clock_t overload to use system_clock.
(condition_variable_any) [_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT]: Use
steady_clock for __clock_t if pthread_cond_clockwait is available.
From-SVN: r275390
Diffstat (limited to 'libstdc++-v3/configure.ac')
-rw-r--r-- | libstdc++-v3/configure.ac | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index 80d8202c337..ad4ae0c3b7d 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -220,6 +220,9 @@ GLIBCXX_ENABLE_LIBSTDCXX_TIME # Check for tmpnam which is obsolescent in POSIX.1-2008 GLIBCXX_CHECK_TMPNAM +# For pthread_cond_clockwait +GLIBCXX_CHECK_PTHREAD_COND_CLOCKWAIT + AC_LC_MESSAGES # For hardware_concurrency |