#if __cplusplus >= 201402L
 
-#include <bits/c++config.h>
-#include <condition_variable>
+#include <chrono>
 #include <bits/functexcept.h>
+#include <bits/move.h>        // move, __exchange
+#include <bits/std_mutex.h>   // defer_lock_t
+
+#if ! (_GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK)
+# include <condition_variable>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 #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
 #endif
   /// @endcond
 
-#if __cplusplus > 201402L
+#if __cplusplus >= 201703L
   /// The standard shared mutex type.
   class shared_mutex
   {
       release() noexcept
       {
        _M_owns = false;
-       return std::exchange(_M_pm, nullptr);
+       return std::__exchange(_M_pm, nullptr);
       }
 
       // Getters
 
 # 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
 #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