public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Tweak some preprocessor conditions for feature tests
Date: Thu, 24 Aug 2023 13:45:25 +0100	[thread overview]
Message-ID: <20230824124536.443669-1-jwakely@redhat.com> (raw)

Tested x86_64-linux. Pushed to trunk.

-- >8 --

Update a preprocessor condition using __cplusplus and _GLIBCXX_HOSTED
to use the relevant feature test macro for <syncstream>.

Also add comments to some conditions saying which C++ standard revision
the check corresponds to.

libstdc++-v3/ChangeLog:

	* include/std/atomic: Add comment to #ifdef and fix indentation.
	* include/std/ostream: Check __glibcxx_syncbuf instead of
	__cplusplus and _GLIBCXX_HOSTED.
	* include/std/thread: Add comment to #ifdef.
---
 libstdc++-v3/include/std/atomic  | 28 ++++++++++++++--------------
 libstdc++-v3/include/std/ostream |  6 +++---
 libstdc++-v3/include/std/thread  |  2 +-
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
index da99169cab5..713ee2cc539 100644
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -388,23 +388,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       { return compare_exchange_strong(__e, __i, __m,
                                        __cmpexch_failure_order(__m)); }
 
-#if __cpp_lib_atomic_wait
-    void
-    wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept
-    {
-      std::__atomic_wait_address_v(&_M_i, __old,
-			 [__m, this] { return this->load(__m); });
-    }
+#if __cpp_lib_atomic_wait // C++ >= 20
+      void
+      wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept
+      {
+	std::__atomic_wait_address_v(&_M_i, __old,
+			   [__m, this] { return this->load(__m); });
+      }
 
-    // TODO add const volatile overload
+      // TODO add const volatile overload
 
-    void
-    notify_one() noexcept
-    { std::__atomic_notify_address(&_M_i, false); }
+      void
+      notify_one() noexcept
+      { std::__atomic_notify_address(&_M_i, false); }
 
-    void
-    notify_all() noexcept
-    { std::__atomic_notify_address(&_M_i, true); }
+      void
+      notify_all() noexcept
+      { std::__atomic_notify_address(&_M_i, true); }
 #endif // __cpp_lib_atomic_wait
 
     };
diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream
index 4711b8a3d96..5f973fa11ed 100644
--- a/libstdc++-v3/include/std/ostream
+++ b/libstdc++-v3/include/std/ostream
@@ -39,6 +39,7 @@
 
 #include <ios>
 #include <bits/ostream_insert.h>
+#include <bits/version.h> // __glibcxx_syncbuf
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -804,7 +805,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return std::move(__os);
     }
 
-#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+#ifdef __glibcxx_syncbuf // C++ >= 20 && HOSTED && CXX11ABI
   template<typename _CharT, typename _Traits>
     class __syncbuf_base : public basic_streambuf<_CharT, _Traits>
     {
@@ -869,8 +870,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __os.flush();
       return __os;
     }
-
-#endif // C++20
+#endif // __glibcxx_syncbuf
 
 #endif // C++11
 
diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread
index 2c049edcbd6..28582c9df5c 100644
--- a/libstdc++-v3/include/std/thread
+++ b/libstdc++-v3/include/std/thread
@@ -106,7 +106,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
   /// @}
 
-#ifdef __cpp_lib_jthread
+#ifdef __cpp_lib_jthread // C++ >= 20
 
   /// @cond undocumented
 #ifndef __STRICT_ANSI__
-- 
2.41.0


                 reply	other threads:[~2023-08-24 12:45 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=20230824124536.443669-1-jwakely@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@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).