]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR other/53889 (Gthreads doesn't support destroying recursive mutexes)
authorJonathan Wakely <jwakely.gcc@gmail.com>
Tue, 2 Oct 2012 20:22:32 +0000 (20:22 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 2 Oct 2012 20:22:32 +0000 (21:22 +0100)
libgcc:

PR other/53889
* gthr.h (__gthread_recursive_mutex_destroy): Document new required
function.
* gthr-posix.h (__gthread_recursive_mutex_destroy): Define.
* gthr-single.h (__gthread_recursive_mutex_destroy): Likewise.
* config/gthr-rtems.h (__gthread_recursive_mutex_destroy): Likewise.
* config/gthr-vxworks.h (__gthread_recursive_mutex_destroy): Likewise.
* config/i386/gthr-win32.h (__gthread_recursive_mutex_destroy):
Likewise.
* config/mips/gthr-mipssde.h (__gthread_recursive_mutex_destroy):
Likewise.
* config/pa/gthr-dce.h (__gthread_recursive_mutex_destroy): Likewise.
* config/s390/gthr-tpf.h (__gthread_recursive_mutex_destroy): Likewise.

libstdc++-v3:

PR other/53889
* include/std/mutex (__recursive_mutex_base::~__recursive_mutex_base):
Use __gthread_recursive_mutex_destroy.
(__recursive_mutex_base::_S_destroy): Remove.
(__recursive_mutex_base::_S_destroy_win32): Likewise.
* include/ext/concurrence.h (__recursive_mutex::~__recursive_mutex):
Use __gthread_recursive_mutex_destroy.
(__recursive_mutex::_S_destroy): Remove.
(__recursive_mutex::_S_destroy_win32): Likewise.

From-SVN: r192002

14 files changed:
libgcc/ChangeLog
libgcc/config/gthr-rtems.h
libgcc/config/gthr-vxworks.h
libgcc/config/i386/gthr-win32.c
libgcc/config/i386/gthr-win32.h
libgcc/config/mips/gthr-mipssde.h
libgcc/config/pa/gthr-dce.h
libgcc/config/s390/gthr-tpf.h
libgcc/gthr-posix.h
libgcc/gthr-single.h
libgcc/gthr.h
libstdc++-v3/ChangeLog
libstdc++-v3/include/ext/concurrence.h
libstdc++-v3/include/std/mutex

index 42308dba755603e092f75f4e38aee85cef8ac182..9a92f365b0093888946a64a65c6dfea5a9ffb9cb 100644 (file)
@@ -1,3 +1,19 @@
+2012-10-02  Jonathan Wakely  <jwakely.gcc@gmail.com>
+
+       PR other/53889
+       * gthr.h (__gthread_recursive_mutex_destroy): Document new required
+       function.
+       * gthr-posix.h (__gthread_recursive_mutex_destroy): Define.
+       * gthr-single.h (__gthread_recursive_mutex_destroy): Likewise.
+       * config/gthr-rtems.h (__gthread_recursive_mutex_destroy): Likewise.
+       * config/gthr-vxworks.h (__gthread_recursive_mutex_destroy): Likewise.
+       * config/i386/gthr-win32.h (__gthread_recursive_mutex_destroy):
+       Likewise.
+       * config/mips/gthr-mipssde.h (__gthread_recursive_mutex_destroy):
+       Likewise.
+       * config/pa/gthr-dce.h (__gthread_recursive_mutex_destroy): Likewise.
+       * config/s390/gthr-tpf.h (__gthread_recursive_mutex_destroy): Likewise.
+
 2012-09-19  Mark Kettenis  <kettenis@openbsd.org>
 
         * config.host (hppa-*-openbsd*): New target.
index c5bd52292cf0a8f63714d2da633fe19a3aec8aec..3bfa67bc26cd360b8be4263692db75c44d7069e6 100644 (file)
@@ -1,8 +1,7 @@
 /* RTEMS threads compatibility routines for libgcc2 and libobjc.
    by: Rosimildo da Silva( rdasilva@connecttel.com ) */
 /* Compile this one with gcc.  */
-/* Copyright (C) 1997, 1999, 2000, 2002, 2003, 2005, 2008, 2009
-   Free Software Foundation, Inc.
+/* Copyright (C) 1997-2012 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -150,6 +149,14 @@ __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
     return rtems_gxx_recursive_mutex_unlock( __mutex );
 }
 
+static inline int
+__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
+{
+  /* This requires that recursive and non-recursive mutexes have the same
+     representation.  */
+    return rtems_gxx_mutex_destroy (__mutex );
+}
+
 #ifdef __cplusplus
 }
 #endif
index 63116c460a6694b09a7c0e72afbdf07dec6104a2..b48c5ac4c2e1c0978fe4282b68ce4a1f291be989 100644 (file)
@@ -1,7 +1,6 @@
 /* Threads compatibility routines for libgcc2 and libobjc for VxWorks.  */
 /* Compile this one with gcc.  */
-/* Copyright (C) 1997, 1999, 2000, 2008, 2009, 2011
-   Free Software Foundation, Inc.
+/* Copyright (C) 1997-2012 Free Software Foundation, Inc.
    Contributed by Mike Stump <mrs@wrs.com>.
 
 This file is part of GCC.
@@ -111,6 +110,12 @@ __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
   return __gthread_mutex_unlock (mutex);
 }
 
+static inline int
+__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
+{
+  return __gthread_mutex_destroy (__mutex);
+}
+
 /* pthread_once is complicated enough that it's implemented
    out-of-line.  See config/vxlib.c.  */
 
index ab1b69fd4cf411bec7170966a66631179703255a..fcb15df1dd2dfd2d0bffa14d64d60edb95079e8e 100644 (file)
@@ -1,8 +1,7 @@
 /* Implementation of W32-specific threads compatibility routines for
    libgcc2.  */
 
-/* Copyright (C) 1999, 2000, 2002, 2004, 2008, 2009, 2011
-   Free Software Foundation, Inc.
+/* Copyright (C) 1999-2012 Free Software Foundation, Inc.
    Contributed by Mumit Khan <khan@xraylith.wisc.edu>.
    Modified and moved to separate file by Danny Smith
    <dannysmith@users.sourceforge.net>.
@@ -259,3 +258,10 @@ __gthr_win32_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
 
   return 0;
 }
+
+int
+__gthr_win32_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex)
+{
+  CloseHandle ((HANDLE) mutex->sema);
+  return 0;
+}
index 53f8396cc8135ae24e2be3eaa69647a9d5fc3a12..965614841c5779cc8a4cf953da9fbb9f9625837d 100644 (file)
@@ -1,8 +1,7 @@
 /* Threads compatibility routines for libgcc2 and libobjc.  */
 /* Compile this one with gcc.  */
 
-/* Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2008, 2009
-   Free Software Foundation, Inc.
+/* Copyright (C) 1999-2012 Free Software Foundation, Inc.
    Contributed by Mumit Khan <khan@xraylith.wisc.edu>.
 
 This file is part of GCC.
@@ -430,6 +429,8 @@ extern int
   __gthr_win32_recursive_mutex_trylock (__gthread_recursive_mutex_t *);
 extern int __gthr_win32_recursive_mutex_unlock (__gthread_recursive_mutex_t *);
 extern void __gthr_win32_mutex_destroy (__gthread_mutex_t *);
+extern int
+  __gthr_win32_recursive_mutex_destroy (__gthread_recursive_mutex_t *);
 
 static inline int
 __gthread_once (__gthread_once_t *__once, void (*__func) (void))
@@ -536,6 +537,12 @@ __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
     return 0;
 }
 
+static inline int
+__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex)
+{
+  return __gthr_win32_recursive_mutex_destroy (__mutex);
+}
+
 #else /* ! __GTHREAD_HIDE_WIN32API */
 
 #include <windows.h>
@@ -761,6 +768,13 @@ __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
   return 0;
 }
 
+static inline int
+__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex)
+{
+  CloseHandle ((HANDLE) mutex->sema);
+  return 0;
+}
+
 #endif /*  __GTHREAD_HIDE_WIN32API */
 
 #ifdef __cplusplus
index 34f9b6cf54b5c2d089827ccc91f45e1a3fb0f00c..2ce22580b90403a00d7d7f46640a37160f5da71d 100644 (file)
@@ -1,6 +1,6 @@
 /* MIPS SDE threads compatibility routines for libgcc2 and libobjc.  */
 /* Compile this one with gcc.  */
-/* Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2006-2012 Free Software Foundation, Inc.
    Contributed by Nigel Stephens <nigel@mips.com>
 
 This file is part of GCC.
@@ -223,6 +223,13 @@ __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
   return 0;
 }
 
+static inline int
+__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t
+                                   * UNUSED(__mutex))
+{
+  return 0;
+}
+
 #ifdef __cplusplus
 }
 #endif
index d32155a9352b581a9ef67ef487400aa3cd2d4deb..3ba43a187c6a6cc333bf56f8cb32d2e1ee0b87db 100644 (file)
@@ -1,7 +1,6 @@
 /* Threads compatibility routines for libgcc2 and libobjc.  */
 /* Compile this one with gcc.  */
-/* Copyright (C) 1997, 1999, 2000, 2001, 2004, 2005, 2008, 2009
-   Free Software Foundation, Inc.
+/* Copyright (C) 1997-2012 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -557,6 +556,12 @@ __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
   return __gthread_mutex_unlock (__mutex);
 }
 
+static inline int
+__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
+{
+  return __gthread_mutex_destroy (__mutex);
+}
+
 #endif /* _LIBOBJC */
 
 #endif
index fb23e91cfcd4d37f5a18eb2c1f8514a392b95676..49bce4c20100f87518b9822ea9031a43a0de80a9 100644 (file)
@@ -1,6 +1,6 @@
 /* Threads compatibility routines for libgcc2 and libobjc.
    Compile this one with gcc.
-   Copyright (C) 2004, 2005, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2004-2012 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -225,5 +225,10 @@ __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
   return 0;
 }
 
+static inline int
+__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
+{
+  return __gthread_mutex_destroy (__mutex);
+}
 
 #endif /* ! GCC_GTHR_TPF_H */
index cc4e518f5b9907db18cdfc0a37fbeb67451b63d5..1e7ddfeb2f4076e3057cf45b4acbc5641cb77f54 100644 (file)
@@ -832,6 +832,12 @@ __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
   return __gthread_mutex_unlock (__mutex);
 }
 
+static inline int
+__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
+{
+  return __gthread_mutex_destroy (__mutex);
+}
+
 #ifdef _GTHREAD_USE_COND_INIT_FUNC
 static inline void
 __gthread_cond_init_function (__gthread_cond_t *__cond)
index 4e3967977852e1aa6ab486e4a469924c4cc6244e..717e6cb37b368917b34a33aeeb0c926b490bf3d0 100644 (file)
@@ -1,7 +1,6 @@
 /* Threads compatibility routines for libgcc2 and libobjc.  */
 /* Compile this one with gcc.  */
-/* Copyright (C) 1997, 1999, 2000, 2004, 2008, 2009
-   Free Software Foundation, Inc.
+/* Copyright (C) 1997-2012 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -286,6 +285,12 @@ __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
   return __gthread_mutex_unlock (__mutex);
 }
 
+static inline int
+__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
+{
+  return __gthread_mutex_destroy (__mutex);
+}
+
 #endif /* _LIBOBJC */
 
 #undef UNUSED
index 813abe1e57e39ddda9e1924bfa862a022beac184..9f2b53d2368b0804fe29c35b337b3a4954419cbb 100644 (file)
@@ -1,7 +1,6 @@
 /* Threads compatibility routines for libgcc2.  */
 /* Compile this one with gcc.  */
-/* Copyright (C) 1997, 1998, 2004, 2008, 2009, 2011
-   Free Software Foundation, Inc.
+/* Copyright (C) 1997-2012 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -73,6 +72,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
      int __gthread_setspecific (__gthread_key_t key, const void *ptr)
 
      int __gthread_mutex_destroy (__gthread_mutex_t *mutex);
+     int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex);
 
      int __gthread_mutex_lock (__gthread_mutex_t *mutex);
      int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
index 32f82a7d44edc2eab2f581b17d68e96c9311a426..c02a660a23065548599ff4eea0bbbbf6fcd91210 100644 (file)
@@ -1,3 +1,15 @@
+2012-10-02  Jonathan Wakely  <jwakely.gcc@gmail.com>
+
+       PR other/53889
+       * include/std/mutex (__recursive_mutex_base::~__recursive_mutex_base):
+       Use __gthread_recursive_mutex_destroy.
+       (__recursive_mutex_base::_S_destroy): Remove.
+       (__recursive_mutex_base::_S_destroy_win32): Likewise.
+       * include/ext/concurrence.h (__recursive_mutex::~__recursive_mutex):
+       Use __gthread_recursive_mutex_destroy.
+       (__recursive_mutex::_S_destroy): Remove.
+       (__recursive_mutex::_S_destroy_win32): Likewise.
+
 2012-10-01  Benjamin Kosnik  <bkoz@redhat.com>
 
        * config/abi/pre/gnu-versioned-namespace.ver: Add more
index ad028398be1af25193031b741beabc8682189785..68c679c6b0652563b64dea4ee660340dbcfd474a 100644 (file)
@@ -219,7 +219,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     ~__recursive_mutex()
     {
       if (__gthread_active_p())
-       _S_destroy(&_M_mutex);
+       __gthread_recursive_mutex_destroy(&_M_mutex);
     }
 #endif
 
@@ -247,43 +247,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     __gthread_recursive_mutex_t* gthread_recursive_mutex(void)
     { return &_M_mutex; }
-
-#if __GTHREADS && ! defined __GTHREAD_RECURSIVE_MUTEX_INIT
-    // FIXME: gthreads doesn't define __gthread_recursive_mutex_destroy
-    // so we need to obtain a __gthread_mutex_t to destroy
-  private:
-    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);
-      }
-
-    // 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);
-      }
-
-    // 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 when there's only one mutex type
-    template<typename _Rm>
-      static typename
-      __enable_if<std::__are_same<_Rm, __gthread_mutex_t>::__value,
-        void>::__type
-      _S_destroy(_Rm* __mx)
-      { __gthread_mutex_destroy(__mx); }
-#endif
   };
 
   /// Scoped lock idiom.
index 34d64c5b65f2f8ab9f79124427419e0bd18d7798..77faf739ce682c591d0aea1b2f36859a3be60c46 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-2012 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
@@ -101,42 +100,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
   };