From 71988274865bf049c7705ce33350661b75f0af74 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 26 Nov 2020 21:54:46 +0000 Subject: [PATCH] libstdc++: Only define std::latch if atomic waiting is available libstdc++-v3/ChangeLog: * include/std/latch: Depend on _GLIBCXX_HAS_GTHREADS and _GLIBCXX_HAVE_LINUX_FUTEX. * include/std/version (__cpp_lib_latch): Define conditionally. --- libstdc++-v3/include/std/latch | 7 +++++-- libstdc++-v3/include/std/version | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/std/latch b/libstdc++-v3/include/std/latch index 9d9c880a88b..3af295b4eb4 100644 --- a/libstdc++-v3/include/std/latch +++ b/libstdc++-v3/include/std/latch @@ -27,20 +27,22 @@ */ #ifndef _GLIBCXX_LATCH -#define _GLIBCXX_LATCH +#define _GLIBCXX_LATCH 1 #pragma GCC system_header #if __cplusplus > 201703L -#define __cpp_lib_latch 201907L #include #include +#if defined _GLIBCXX_HAS_GTHREADS || _GLIBCXX_HAVE_LINUX_FUTEX namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION +#define __cpp_lib_latch 201907L + class latch { public: @@ -87,5 +89,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace +#endif // GTHREADS || LINUX_FUTEX #endif // __cplusplus > 201703L #endif // _GLIBCXX_LATCH diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index cf0454dbaf8..0f2da8a5ddd 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -216,7 +216,9 @@ #ifdef _GLIBCXX_HAS_GTHREADS # define __cpp_lib_jthread 201911L #endif -#define __cpp_lib_latch 201907L +#if defined _GLIBCXX_HAS_GTHREADS || defined _GLIBCXX_HAVE_LINUX_FUTEX +# define __cpp_lib_latch 201907L +#endif #define __cpp_lib_list_remove_return_type 201806L #if __cpp_lib_concepts # define __cpp_lib_make_obj_using_allocator 201811L @@ -226,7 +228,7 @@ #if __cpp_lib_concepts # define __cpp_lib_ranges 201911L #endif -#if defined _GLIBCXX_HAS_GTHREADS || _GLIBCXX_HAVE_LINUX_FUTEX +#if defined _GLIBCXX_HAS_GTHREADS || defined _GLIBCXX_HAVE_LINUX_FUTEX # define __cpp_lib_semaphore 201907L #endif #define __cpp_lib_shift 201806L -- 2.30.2