aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/config.h.in
diff options
context:
space:
mode:
authorMike Crowe <mac@mcrowe.com>2019-09-04 22:43:29 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2019-09-04 23:43:29 +0100
commitad4d1d21ad5c515ba90355d13b14cbb74262edd2 (patch)
tree37c354f2ea9e5d08fcd05367233f4cb01e5ddba3 /libstdc++-v3/config.h.in
parent76e0dd66c87720a8a82a6d5f44ba4d8f63a51b1d (diff)
downloadgcc-ad4d1d21ad5c515ba90355d13b14cbb74262edd2.zip
gcc-ad4d1d21ad5c515ba90355d13b14cbb74262edd2.tar.gz
gcc-ad4d1d21ad5c515ba90355d13b14cbb74262edd2.tar.bz2
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/config.h.in')
-rw-r--r--libstdc++-v3/config.h.in3
1 files changed, 3 insertions, 0 deletions
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index 99286e6..3d13402 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -991,6 +991,9 @@
/* Define if pthreads_num_processors_np is available in <pthread.h>. */
#undef _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP
+/* Define if pthread_cond_clockwait is available in <pthread.h>. */
+#undef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT
+
/* Define if POSIX read/write locks are available in <gthr.h>. */
#undef _GLIBCXX_USE_PTHREAD_RWLOCK_T