On 11/09/20 16:58 -0700, Thomas Rodgers wrote:
From: Thomas Rodgers <trodg...@redhat.com>
This patch supercedes both the Add C++2a synchronization support patch
being replied to *and* the patch adding wait/notify_* to atomic_flag.
Add support for -
* atomic_flag::wait/notify_one/notify_all
* atomic::wait/notify_one/notify_all
* counting_semaphore
* binary_semaphore
* latch
libstdc++-v3/ChangeLog:
* include/Makefile.am (bits_headers): Add new header.
* include/Makefile.in: Regenerate.
* include/bits/atomic_base.h (__atomic_flag::wait): Define.
(__atomic_flag::notify_one): Likewise.
(__atomic_flag::notify_all): Likewise.
(__atomic_base<_Itp>::wait): Likewise.
(__atomic_base<_Itp>::notify_one): Likewise.
(__atomic_base<_Itp>::notify_all): Likewise.
(__atomic_base<_Ptp*>::wait): Likewise.
(__atomic_base<_Ptp*>::notify_one): Likewise.
(__atomic_base<_Ptp*>::notify_all): Likewise.
(__atomic_impl::wait): Likewise.
(__atomic_impl::notify_one): Likewise.
(__atomic_impl::notify_all): Likewise.
(__atomic_float<_Fp>::wait): Likewise.
(__atomic_float<_Fp>::notify_one): Likewise.
(__atomic_float<_Fp>::notify_all): Likewise.
(__atomic_ref<_Tp>::wait): Likewise.
(__atomic_ref<_Tp>::notify_one): Likewise.
(__atomic_ref<_Tp>::notify_all): Likewise.
(atomic_wait<_Tp>): Likewise.
(atomic_wait_explicit<_Tp>): Likewise.
(atomic_notify_one<_Tp>): Likewise.
(atomic_notify_all<_Tp>): Likewise.
* include/bits/atomic_wait.h: New file.
* include/bits/atomic_timed_wait.h: New file.
* include/bits/semaphore_base.h: New file.
* include/std/atomic (atomic<bool>::wait): Define.
(atomic<bool>::wait_one): Likewise.
(atomic<bool>::wait_all): Likewise.
(atomic<_Tp>::wait): Likewise.
(atomic<_Tp>::wait_one): Likewise.
(atomic<_Tp>::wait_all): Likewise.
(atomic<_Tp*>::wait): Likewise.
(atomic<_Tp*>::wait_one): Likewise.
(atomic<_Tp*>::wait_all): Likewise.
* include/std/latch: New file.
* include/std/semaphore: New file.
* include/std/version: Add __cpp_lib_semaphore and
__cpp_lib_latch defines.
* testsuite/29_atomic/atomic/wait_notify/atomic_refs.cc: New test.
* testsuite/29_atomic/atomic/wait_notify/bool.cc: Likewise.
* testsuite/29_atomic/atomic/wait_notify/integrals.cc: Likewise.
* testsuite/29_atomic/atomic/wait_notify/floats.cc: Likewise.
* testsuite/29_atomic/atomic/wait_notify/pointers.cc: Likewise.
* testsuite/29_atomic/atomic/wait_notify/generic.cc: Liekwise.
* testsuite/29_atomic/atomic/wait_notify/generic.h: New File.
* testsuite/29_atomics/atomic_flag/wait_notify/1.cc: New test.
* testsuite/30_thread/semaphore/1.cc: New test.
* testsuite/30_thread/semaphore/2.cc: Likewise.
* testsuite/30_thread/semaphore/least_max_value_neg.cc: Likewise.
* testsuite/30_thread/semaphore/try_acquire.cc: Likewise.
* testsuite/30_thread/semaphore/try_acquire_for.cc: Likewise.
* testsuite/30_thread/semaphore/try_acquire_posix.cc: Likewise.
* testsuite/30_thread/semaphore/try_acquire_until.cc: Likewise.
* testsuite/30_thread/latch/1.cc: New test.
* testsuite/30_thread/latch/2.cc: New test.
* testsuite/30_thread/latch/3.cc: New test.
---
libstdc++-v3/include/Makefile.am | 5 +
libstdc++-v3/include/Makefile.in | 5 +
libstdc++-v3/include/bits/atomic_base.h | 195 +++++++++++-
libstdc++-v3/include/bits/atomic_timed_wait.h | 281 ++++++++++++++++
libstdc++-v3/include/bits/atomic_wait.h | 301 ++++++++++++++++++
libstdc++-v3/include/bits/semaphore_base.h | 283 ++++++++++++++++
libstdc++-v3/include/std/atomic | 73 +++++
libstdc++-v3/include/std/latch | 90 ++++++
libstdc++-v3/include/std/semaphore | 92 ++++++
libstdc++-v3/include/std/version | 2 +
.../atomic/wait_notify/atomic_refs.cc | 103 ++++++
.../29_atomics/atomic/wait_notify/bool.cc | 59 ++++
.../29_atomics/atomic/wait_notify/floats.cc | 32 ++
.../29_atomics/atomic/wait_notify/generic.cc | 31 ++
.../29_atomics/atomic/wait_notify/generic.h | 160 ++++++++++
.../atomic/wait_notify/integrals.cc | 65 ++++
.../29_atomics/atomic/wait_notify/pointers.cc | 59 ++++
.../29_atomics/atomic_flag/wait_notify/1.cc | 61 ++++
libstdc++-v3/testsuite/30_threads/latch/1.cc | 27 ++
libstdc++-v3/testsuite/30_threads/latch/2.cc | 27 ++
libstdc++-v3/testsuite/30_threads/latch/3.cc | 50 +++
.../testsuite/30_threads/semaphore/1.cc | 27 ++
.../testsuite/30_threads/semaphore/2.cc | 27 ++
.../semaphore/least_max_value_neg.cc | 30 ++
.../30_threads/semaphore/try_acquire.cc | 55 ++++
.../30_threads/semaphore/try_acquire_for.cc | 85 +++++
.../30_threads/semaphore/try_acquire_posix.cc | 153 +++++++++
.../30_threads/semaphore/try_acquire_until.cc | 94 ++++++
28 files changed, 2471 insertions(+), 1 deletion(-)
create mode 100644 libstdc++-v3/include/bits/atomic_timed_wait.h
create mode 100644 libstdc++-v3/include/bits/atomic_wait.h
create mode 100644 libstdc++-v3/include/bits/semaphore_base.h
create mode 100644 libstdc++-v3/include/std/latch
create mode 100644 libstdc++-v3/include/std/semaphore
create mode 100644
libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/atomic_refs.cc
create mode 100644 libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/bool.cc
create mode 100644
libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/floats.cc
create mode 100644
libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/generic.cc
create mode 100644
libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/generic.h
create mode 100644
libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/integrals.cc
create mode 100644
libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/pointers.cc
create mode 100644
libstdc++-v3/testsuite/29_atomics/atomic_flag/wait_notify/1.cc
create mode 100644 libstdc++-v3/testsuite/30_threads/latch/1.cc
create mode 100644 libstdc++-v3/testsuite/30_threads/latch/2.cc
create mode 100644 libstdc++-v3/testsuite/30_threads/latch/3.cc
create mode 100644 libstdc++-v3/testsuite/30_threads/semaphore/1.cc
create mode 100644 libstdc++-v3/testsuite/30_threads/semaphore/2.cc
create mode 100644
libstdc++-v3/testsuite/30_threads/semaphore/least_max_value_neg.cc
create mode 100644 libstdc++-v3/testsuite/30_threads/semaphore/try_acquire.cc
create mode 100644
libstdc++-v3/testsuite/30_threads/semaphore/try_acquire_for.cc
create mode 100644
libstdc++-v3/testsuite/30_threads/semaphore/try_acquire_posix.cc
create mode 100644
libstdc++-v3/testsuite/30_threads/semaphore/try_acquire_until.cc
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index c9df9a9d6c6..9b5b6ed0005 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -52,6 +52,7 @@ std_headers = \
${std_srcdir}/iostream \
${std_srcdir}/istream \
${std_srcdir}/iterator \
+ ${std_srcdir}/latch \
${std_srcdir}/limits \
${std_srcdir}/list \
${std_srcdir}/locale \
@@ -69,6 +70,7 @@ std_headers = \
${std_srcdir}/ratio \
${std_srcdir}/regex \
${std_srcdir}/scoped_allocator \
+ ${std_srcdir}/semaphore \
${std_srcdir}/set \
${std_srcdir}/shared_mutex \
${std_srcdir}/span \
@@ -101,6 +103,8 @@ bits_headers = \
${bits_srcdir}/allocated_ptr.h \
${bits_srcdir}/allocator.h \
${bits_srcdir}/atomic_base.h \
+ ${bits_srcdir}/atomic_wait.h \
+ ${bits_srcdir}/atomic_timed_wait.h \
${bits_srcdir}/atomic_futex.h \
These should be kept in alphabetical order.
${bits_srcdir}/basic_ios.h \
${bits_srcdir}/basic_ios.tcc \