This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] PR libstdc++/52680 define std::this_thread functions without --enable-libstdcxx-time


With this patch we define this_thread::yield() and
this_thread::sleep_for and this_thread::sleep_until unconditionally,
albeit with less functionality than when --enable-libstdcxx-time is
used.

This contains a #error so will fail to build on platforms that support
std::thread but don't provide ::sleep() in <unistd.h>, if any such
platforms exist I'll need to update configure and src/c++11/thread.cc
to use that platform's equivalent.

        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.

Tested x86_64-linux, with and without --enable-libstdcxx-time,  built
(but not tested) on x86_64-netbsd and i386-solaris without
--enable-libstdcxx-time. Committed to trunk.

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]