public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc(refs/users/aoliva/heads/testbase)] Implent C++20 std::atomic_flag::test
Date: Tue, 19 May 2020 08:59:01 +0000 (GMT)	[thread overview]
Message-ID: <20200519085901.8DEE13895470@sourceware.org> (raw)

https://gcc.gnu.org/g:491ba663e05887c0353edf571be36e8f04183df3

commit 491ba663e05887c0353edf571be36e8f04183df3
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Tue May 12 07:37:09 2020 +0200

    Implent C++20 std::atomic_flag::test
    
            * include/bits/atomic_base.h (atomic_flag): Implement test member
            function.
            * include/std/version: Define __cpp_lib_atomic_flag_test.
            * testsuite/29_atomics/atomic_flag/test/explicit.cc: New file.
            * testsuite/29_atomics/atomic_flag/test/implicit.cc: New file.

Diff:
---
 libstdc++-v3/ChangeLog                  |  8 ++++++++
 libstdc++-v3/include/bits/atomic_base.h | 20 ++++++++++++++++++++
 libstdc++-v3/include/std/version        |  1 +
 3 files changed, 29 insertions(+)

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index a2ff49d9e51..3264fd4c481 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,11 @@
+2020-05-08  Ulrich Drepper  <drepper@redhat.com>
+
+	* include/bits/atomic_base.h (atomic_flag): Implement test member
+	function.
+	* include/std/version: Define __cpp_lib_atomic_flag_test.
+	* testsuite/29_atomics/atomic_flag/test/explicit.cc: New file.
+	* testsuite/29_atomics/atomic_flag/test/implicit.cc: New file.
+
 2020-05-07  Jonathan Wakely  <jwakely@redhat.com>
 
 	PR libstdc++/94971 (partial)
diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h
index 87fe0bd6000..3b66b040976 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -208,6 +208,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return __atomic_test_and_set (&_M_i, int(__m));
     }
 
+#if __cplusplus > 201703L
+#define __cpp_lib_atomic_flag_test 201907L
+
+    _GLIBCXX_ALWAYS_INLINE bool
+    test(memory_order __m = memory_order_seq_cst) noexcept
+    {
+      __atomic_flag_data_type __v;
+      __atomic_load(&_M_i, &__v, int(__m));
+      return __v == __GCC_ATOMIC_TEST_AND_SET_TRUEVAL;
+    }
+
+    _GLIBCXX_ALWAYS_INLINE bool
+    test(memory_order __m = memory_order_seq_cst) volatile noexcept
+    {
+      __atomic_flag_data_type __v;
+      __atomic_load(&_M_i, &__v, int(__m));
+      return __v == __GCC_ATOMIC_TEST_AND_SET_TRUEVAL;
+    }
+#endif // C++20
+
     _GLIBCXX_ALWAYS_INLINE void
     clear(memory_order __m = memory_order_seq_cst) noexcept
     {
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index c3a5bd26e63..c6bde2cfbda 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -164,6 +164,7 @@
 
 #if __cplusplus > 201703L
 // c++2a
+#define __cpp_lib_atomic_flag_test 201907L
 #define __cpp_lib_atomic_float 201711L
 #define __cpp_lib_atomic_ref 201806L
 #define __cpp_lib_atomic_value_initialization 201911L


                 reply	other threads:[~2020-05-19  8:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200519085901.8DEE13895470@sourceware.org \
    --to=aoliva@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).