diff options
| author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-11-23 22:11:23 +0000 |
|---|---|---|
| committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-11-23 22:11:23 +0000 |
| commit | a2bb721d8e1a576841fb80f1c78f0694014d4e8b (patch) | |
| tree | bd11ed625b040c97f7b7dc87865300f4d68dbf00 /libstdc++-v3/include/std/thread | |
| parent | 66ee291faa52558caedbc214d662b7b7742eca7e (diff) | |
| download | ppe42-gcc-a2bb721d8e1a576841fb80f1c78f0694014d4e8b.tar.gz ppe42-gcc-a2bb721d8e1a576841fb80f1c78f0694014d4e8b.zip | |
PR libstdc++/52680
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Check for usleep and
sleep if nanosleep is not available. Bump libtool revision.
* config.h.in: Regenerate.
* configure: Likewise.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.18): Add __sleep_for.
* include/std/thread (this_thread::__sleep_for): Add.
(this_thread::yield, this_thread::sleep_until, this_thread::sleep_for):
Declare unconditionally.
* src/c++11/thread.cc (this_thread::__sleep_for): Define.
* testsuite/lib/libstdc++.exp (check_v3_target_nanosleep): Rename to
check_v3_target_sleep.
* testsuite/lib/dg-options.exp (dg-require-nanosleep): Rename to
dg-require-sleep.
* testsuite/30_threads/condition_variable_any/53830.cc: Update.
* testsuite/30_threads/this_thread/2.cc: Likewise.
* testsuite/30_threads/this_thread/3.cc: Likewise.
* testsuite/30_threads/this_thread/4.cc: Likewise.
* testsuite/30_threads/async/54297.cc: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193769 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/std/thread')
| -rw-r--r-- | libstdc++-v3/include/std/thread | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread index 718c192c76d..6ca40cd266a 100644 --- a/libstdc++-v3/include/std/thread +++ b/libstdc++-v3/include/std/thread @@ -251,32 +251,35 @@ _GLIBCXX_END_NAMESPACE_VERSION inline thread::id get_id() noexcept { return thread::id(__gthread_self()); } -#ifdef _GLIBCXX_USE_SCHED_YIELD /// yield inline void yield() noexcept - { __gthread_yield(); } + { +#ifdef _GLIBCXX_USE_SCHED_YIELD + __gthread_yield(); #endif + } + + void + __sleep_for(chrono::seconds, chrono::nanoseconds); -#ifdef _GLIBCXX_USE_NANOSLEEP /// sleep_for template<typename _Rep, typename _Period> inline void sleep_for(const chrono::duration<_Rep, _Period>& __rtime) { - chrono::seconds __s = - chrono::duration_cast<chrono::seconds>(__rtime); - - chrono::nanoseconds __ns = - chrono::duration_cast<chrono::nanoseconds>(__rtime - __s); - + auto __s = chrono::duration_cast<chrono::seconds>(__rtime); + auto __ns = chrono::duration_cast<chrono::nanoseconds>(__rtime - __s); +#ifdef _GLIBCXX_USE_NANOSLEEP __gthread_time_t __ts = { static_cast<std::time_t>(__s.count()), static_cast<long>(__ns.count()) }; - ::nanosleep(&__ts, 0); +#else + __sleep_for(__s, __ns); +#endif } /// sleep_until @@ -284,7 +287,6 @@ _GLIBCXX_END_NAMESPACE_VERSION inline void sleep_until(const chrono::time_point<_Clock, _Duration>& __atime) { sleep_for(__atime - _Clock::now()); } -#endif _GLIBCXX_END_NAMESPACE_VERSION } |

