]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Tweak some preprocessor conditions for feature tests
authorJonathan Wakely <jwakely@redhat.com>
Thu, 17 Aug 2023 23:13:51 +0000 (00:13 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 24 Aug 2023 12:44:38 +0000 (13:44 +0100)
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
libstdc++-v3/include/std/ostream
libstdc++-v3/include/std/thread

index da99169cab5d2c9e0ddf69ddda0386e4bd25e969..713ee2cc53971eb33674c5a9b5ff8cdc5a0d8008 100644 (file)
@@ -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
 
     };
index 4711b8a3d966539ccd2bc236be85bbba39bb5434..5f973fa11ed6b2915ebd37e824afea60e44b153a 100644 (file)
@@ -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
 
index 2c049edcbd602ac1daedeeb7d1d5417fade7963b..28582c9df5ce91dfcaefac97698db75fa375d0d1 100644 (file)
@@ -106,7 +106,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
   /// @}
 
-#ifdef __cpp_lib_jthread
+#ifdef __cpp_lib_jthread // C++ >= 20
 
   /// @cond undocumented
 #ifndef __STRICT_ANSI__