From f5d9bc8ae81abe46640477bc9e655aa093947f5f Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 22 Oct 2020 18:42:03 +0100 Subject: [PATCH] libstdc++: Only include in if needed The header is not small, so should not include it unless it actually needs std::condition_variable, which is only the case when we don't have pthread_rwlock_t and the POSIX Timers option. The header would be even smaller if we had a header for std::condition_variable (separate from std::condition_variable_any). That's already planned for a future change. And would be even smaller if it was possible to get std::shared_mutex without std::shared_timed_mutex (which depends on ). For that to be effective, the synchronized_pool_resource would have to create its own simpler version of std::shared_lock without the timed waiting functions. I have no plans to do that. libstdc++-v3/ChangeLog: * include/std/shared_mutex: Only include when pthread_rwlock_t and POSIX timers are not available. (__cpp_lib_shared_mutex, __cpp_lib_shared_timed_mutex): Change value to be type 'long'. * include/std/version (__cpp_lib_shared_mutex) (__cpp_lib_shared_timed_mutex): Likewise. --- libstdc++-v3/include/std/shared_mutex | 17 +++++++++++------ libstdc++-v3/include/std/version | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/libstdc++-v3/include/std/shared_mutex b/libstdc++-v3/include/std/shared_mutex index 414dce3..7d683a0 100644 --- a/libstdc++-v3/include/std/shared_mutex +++ b/libstdc++-v3/include/std/shared_mutex @@ -33,9 +33,14 @@ #if __cplusplus >= 201402L -#include -#include +#include #include +#include // move, __exchange +#include // defer_lock_t + +#if ! (_GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK) +# include +#endif namespace std _GLIBCXX_VISIBILITY(default) { @@ -49,11 +54,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef _GLIBCXX_HAS_GTHREADS #if __cplusplus >= 201703L -#define __cpp_lib_shared_mutex 201505 +#define __cpp_lib_shared_mutex 201505L class shared_mutex; #endif -#define __cpp_lib_shared_timed_mutex 201402 +#define __cpp_lib_shared_timed_mutex 201402L class shared_timed_mutex; /// @cond undocumented @@ -399,7 +404,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif /// @endcond -#if __cplusplus > 201402L +#if __cplusplus >= 201703L /// The standard shared mutex type. class shared_mutex { @@ -814,7 +819,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION release() noexcept { _M_owns = false; - return std::exchange(_M_pm, nullptr); + return std::__exchange(_M_pm, nullptr); } // Getters diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index 9c16f2c..ebb50a0 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -89,7 +89,7 @@ # define __cpp_lib_quoted_string_io 201304 # define __cpp_lib_robust_nonmodifying_seq_ops 201304 # ifdef _GLIBCXX_HAS_GTHREADS -# define __cpp_lib_shared_timed_mutex 201402 +# define __cpp_lib_shared_timed_mutex 201402L # endif # define __cpp_lib_string_udls 201304 # define __cpp_lib_transparent_operators 201510 @@ -157,7 +157,7 @@ #define __cpp_lib_sample 201603 #ifdef _GLIBCXX_HAS_GTHREADS # define __cpp_lib_scoped_lock 201703 -# define __cpp_lib_shared_mutex 201505 +# define __cpp_lib_shared_mutex 201505L #endif #define __cpp_lib_shared_ptr_weak_type 201606 #define __cpp_lib_string_view 201803L -- 2.7.4