Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / libstdc++-v3 / include / std / mutex
index 34d64c5..67f3418 100644 (file)
@@ -1,7 +1,6 @@
 // <mutex> -*- C++ -*-
 
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-// Free Software Foundation, Inc.
+// Copyright (C) 2003-2013 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -32,7 +31,7 @@
 
 #pragma GCC system_header
 
-#ifndef __GXX_EXPERIMENTAL_CXX0X__
+#if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
 #else
 
 #include <bits/gthr.h>
 #include <bits/move.h> // for std::swap
 
-#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
+#ifdef _GLIBCXX_USE_C99_STDINT_TR1
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#ifdef _GLIBCXX_HAS_GTHREADS
   // Common base class for std::mutex and std::timed_mutex
   class __mutex_base
   {
@@ -101,42 +101,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 
     ~__recursive_mutex_base()
-    { _S_destroy(&_M_mutex); }
-
-  private:
-    // FIXME: gthreads doesn't define __gthread_recursive_mutex_destroy
-    // so we need to obtain a __gthread_mutex_t to destroy
-
-    // matches when there's only one mutex type
-    template<typename _Rm>
-      static
-      typename enable_if<is_same<_Rm, __gthread_mutex_t>::value, void>::type
-      _S_destroy(_Rm* __mx)
-      { __gthread_mutex_destroy(__mx); }
-
-    // matches a recursive mutex with a member 'actual'
-    template<typename _Rm>
-      static typename enable_if<(bool)sizeof(&_Rm::actual), void>::type
-      _S_destroy(_Rm* __mx)
-      { __gthread_mutex_destroy(&__mx->actual); }
-
-    // matches a gthr-win32.h recursive mutex
-    template<typename _Rm>
-      static typename enable_if<(bool)sizeof(&_Rm::sema), void>::type
-      _S_destroy(_Rm* __mx)
-      {
-        __gthread_mutex_t __tmp;
-        _S_destroy_win32(&__tmp, __mx);
-      }
-
-    template<typename _Mx, typename _Rm>
-      static void
-      _S_destroy_win32(_Mx* __mx, _Rm const* __rmx)
-      {
-        __mx->counter = __rmx->counter;
-        __mx->sema = __rmx->sema;
-        __gthread_mutex_destroy(__mx);
-      }
+    { __gthread_recursive_mutex_destroy(&_M_mutex); }
 #endif
   };
 
@@ -420,6 +385,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
   };
 #endif
+#endif // _GLIBCXX_HAS_GTHREADS
 
   /// Do not acquire ownership of the mutex.
   struct defer_lock_t { };
@@ -755,6 +721,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
         }
     }
 
+#ifdef _GLIBCXX_HAS_GTHREADS
   /// once_flag
   struct once_flag
   {
@@ -826,13 +793,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       if (__e)
        __throw_system_error(__e);
     }
+#endif // _GLIBCXX_HAS_GTHREADS
 
   // @} group mutexes
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
+#endif // _GLIBCXX_USE_C99_STDINT_TR1
 
-#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
-
-#endif // __GXX_EXPERIMENTAL_CXX0X__
+#endif // C++11
 
 #endif // _GLIBCXX_MUTEX