]> gcc.gnu.org Git - gcc.git/commitdiff
libstdc++: Remove #error from <semaphore> implementation [PR 100179]
authorJonathan Wakely <jwakely@redhat.com>
Thu, 22 Apr 2021 10:10:06 +0000 (11:10 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 22 Apr 2021 12:59:32 +0000 (13:59 +0100)
This removes the #error from <bits/semaphore_base.h> for the case where
neither __atomic_semaphore nor __platform_semaphore is defined.

Also rename the _GLIBCXX_REQUIRE_POSIX_SEMAPHORE macro to
_GLIBCXX_USE_POSIX_SEMAPHORE for consistency with the similar
_GLIBCXX_USE_CXX11_ABI macro that can be used to request an alternative
(ABI-changing) implementation.

libstdc++-v3/ChangeLog:

PR libstdc++/100179
* include/bits/semaphore_base.h: Remove #error.
* include/std/semaphore: Do not define anything unless one of
the implementations is available.

libstdc++-v3/include/bits/semaphore_base.h
libstdc++-v3/include/std/semaphore

index 84b33423fff44d02c10efa8873c39c9908a51c4d..4948f0fd0bc0e433716796d589d0eb1d5cbf766f 100644 (file)
@@ -263,14 +263,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   };
 #endif // __cpp_lib_atomic_wait
 
-// Note: the _GLIBCXX_REQUIRE_POSIX_SEMAPHORE macro can be used to force the
+// Note: the _GLIBCXX_USE_POSIX_SEMAPHORE macro can be used to force the
 // use of Posix semaphores (sem_t). Doing so however, alters the ABI.
-#if defined __cpp_lib_atomic_wait && !_GLIBCXX_REQUIRE_POSIX_SEMAPHORE
+#if defined __cpp_lib_atomic_wait && !_GLIBCXX_USE_POSIX_SEMAPHORE
   using __semaphore_impl = __atomic_semaphore;
 #elif _GLIBCXX_HAVE_POSIX_SEMAPHORE
   using __semaphore_impl = __platform_semaphore;
-#else
-#  error "No suitable semaphore implementation available"
 #endif
 
 _GLIBCXX_END_NAMESPACE_VERSION
index a1560915d83b369508f77fa69d3f0b27dbc359fc..52addca742c4eabae2f5ac1f1cd99b5536bab2b8 100644 (file)
@@ -34,6 +34,7 @@
 #if __cplusplus > 201703L
 #include <bits/semaphore_base.h>
 
+#if __cpp_lib_atomic_wait || _GLIBCXX_HAVE_POSIX_SEMAPHORE
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -89,5 +90,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
+#endif // cpp_lib_atomic_wait || _GLIBCXX_HAVE_POSIX_SEMAPHORE
 #endif // C++20
 #endif // _GLIBCXX_SEMAPHORE
This page took 0.068951 seconds and 5 git commands to generate.