-
- Downloads
libstdc++: Make std::this_thread functions work without gthreads
The only function in namespace std::this_thread that actually depends on thread support being present is this_thread::get_id(). The other functions (yield, sleep_for and sleep_until) can be defined for targets without gthreads. A small change is needed in std::this_thread::sleep_for which currently uses the __gthread_time_t typedef. Since it just calls nanosleep directly, it should use timespec directly instead of the typedef. Even std::this_thread::get_id() could be made to work, the only difficulty is that it returns a value of type std::thread::id and std::thread is only defined when gthreads support exists. libstdc++-v3/ChangeLog: * include/std/thread [!_GLIBCXX_HAS_GTHREADS] (this_thread::yield) (this_thread::sleep_until): Define. [!_GLIBCXX_HAS_GTHREADS] (this_thread::sleep_for): Define. Replace use of __gthread_time_t typedef with timespec. * src/c++11/thread.cc [!_GLIBCXX_HAS_GTHREADS] (__sleep_for): Likewise. * testsuite/30_threads/this_thread/2.cc: Moved to... * testsuite/30_threads/this_thread/yield.cc: ...here. * testsuite/30_threads/this_thread/3.cc: Moved to... * testsuite/30_threads/this_thread/sleep_for-mt.cc: ...here. * testsuite/30_threads/this_thread/4.cc: Moved to... * testsuite/30_threads/this_thread/sleep_until-mt.cc: ...here. * testsuite/30_threads/this_thread/58038.cc: Add dg-require-sleep. * testsuite/30_threads/this_thread/60421.cc: Likewise. * testsuite/30_threads/this_thread/sleep_for.cc: New test. * testsuite/30_threads/this_thread/sleep_until.cc: New test.
Showing
- libstdc++-v3/include/std/thread 17 additions, 12 deletionslibstdc++-v3/include/std/thread
- libstdc++-v3/src/c++11/thread.cc 19 additions, 14 deletionslibstdc++-v3/src/c++11/thread.cc
- libstdc++-v3/testsuite/30_threads/this_thread/58038.cc 1 addition, 0 deletionslibstdc++-v3/testsuite/30_threads/this_thread/58038.cc
- libstdc++-v3/testsuite/30_threads/this_thread/60421.cc 1 addition, 0 deletionslibstdc++-v3/testsuite/30_threads/this_thread/60421.cc
- libstdc++-v3/testsuite/30_threads/this_thread/sleep_for-mt.cc 0 additions, 0 deletions...tdc++-v3/testsuite/30_threads/this_thread/sleep_for-mt.cc
- libstdc++-v3/testsuite/30_threads/this_thread/sleep_for.cc 43 additions, 0 deletionslibstdc++-v3/testsuite/30_threads/this_thread/sleep_for.cc
- libstdc++-v3/testsuite/30_threads/this_thread/sleep_until-mt.cc 0 additions, 0 deletions...c++-v3/testsuite/30_threads/this_thread/sleep_until-mt.cc
- libstdc++-v3/testsuite/30_threads/this_thread/sleep_until.cc 43 additions, 0 deletionslibstdc++-v3/testsuite/30_threads/this_thread/sleep_until.cc
- libstdc++-v3/testsuite/30_threads/this_thread/yield.cc 3 additions, 6 deletionslibstdc++-v3/testsuite/30_threads/this_thread/yield.cc
Loading
Please register or sign in to comment