mutex (mutex::try_lock): Eat errors.
authorBenjamin Kosnik <bkoz@redhat.com>
Thu, 15 May 2008 00:52:48 +0000 (00:52 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Thu, 15 May 2008 00:52:48 +0000 (00:52 +0000)
2008-05-14  Benjamin Kosnik  <bkoz@redhat.com>

* include/std/mutex (mutex::try_lock): Eat errors.
(mutex::unlock): Same.
(recursive_mutex::try_lock): Eat errors.
(recursive_mutex::unlock): Same.
* testsuite/30_threads/mutex/dest/destructor_locked.cc: Add
-pthreads, adjust line numbers.
* testsuite/30_threads/mutex/native_handle/1.cc: Same.
* testsuite/30_threads/mutex/cons/1.cc: Same.
* testsuite/30_threads/mutex/try_lock/1.cc: Same.
* testsuite/30_threads/mutex/try_lock/2.cc: Same.
* testsuite/30_threads/mutex/lock/1.cc: Same.
* testsuite/30_threads/mutex/unlock/1.cc: Same.
* testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc: Same.
* testsuite/30_threads/recursive_mutex/native_handle/1.cc: Same.
* testsuite/30_threads/recursive_mutex/cons/1.cc: Same.

From-SVN: r135321

16 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/std/mutex
libstdc++-v3/testsuite/30_threads/mutex/cons/1.cc
libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc
libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc
libstdc++-v3/testsuite/30_threads/mutex/dest/destructor_locked.cc
libstdc++-v3/testsuite/30_threads/mutex/lock/1.cc
libstdc++-v3/testsuite/30_threads/mutex/native_handle/1.cc
libstdc++-v3/testsuite/30_threads/mutex/try_lock/1.cc
libstdc++-v3/testsuite/30_threads/mutex/try_lock/2.cc
libstdc++-v3/testsuite/30_threads/mutex/unlock/1.cc
libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/1.cc
libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc
libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc
libstdc++-v3/testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc
libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/1.cc

index bb4e3d62ec918c256ab8fefde331271ca5a26fbc..2f06c8e92a04c435181dff553d1babbf76b2a4d8 100644 (file)
@@ -1,3 +1,21 @@
+2008-05-14  Benjamin Kosnik  <bkoz@redhat.com>
+
+       * include/std/mutex (mutex::try_lock): Eat errors.
+       (mutex::unlock): Same.
+       (recursive_mutex::try_lock): Eat errors.
+       (recursive_mutex::unlock): Same.
+       * testsuite/30_threads/mutex/dest/destructor_locked.cc: Add
+       -pthreads, adjust line numbers.
+       * testsuite/30_threads/mutex/native_handle/1.cc: Same.
+       * testsuite/30_threads/mutex/cons/1.cc: Same.
+       * testsuite/30_threads/mutex/try_lock/1.cc: Same.
+       * testsuite/30_threads/mutex/try_lock/2.cc: Same.
+       * testsuite/30_threads/mutex/lock/1.cc: Same.
+       * testsuite/30_threads/mutex/unlock/1.cc: Same.
+       * testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc: Same.
+       * testsuite/30_threads/recursive_mutex/native_handle/1.cc: Same.
+       * testsuite/30_threads/recursive_mutex/cons/1.cc: Same.
+
 2008-05-14  Benjamin Kosnik  <bkoz@redhat.com>
 
        * include/std/sstream: Adjust braces.
index 935b16e57c29435c9b32e340c3ff717ed72e81cb..6a75e7824164e81f888a8ae56736efbc68b9d1d2 100644 (file)
@@ -59,14 +59,13 @@ namespace std
 
     mutex()
     {
+      // XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may)
 #if defined __GTHREAD_MUTEX_INIT
       native_handle_type __tmp = __GTHREAD_MUTEX_INIT;
       _M_mutex = __tmp;
 #else
       __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex);
 #endif
-
-      // EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may)
     }
 
     void
@@ -82,23 +81,15 @@ namespace std
     bool
     try_lock()
     {
-      int __e = __gthread_mutex_trylock(&_M_mutex);
-
-      // EINVAL, EAGAIN, EBUSY
-     if (__e)
-       __throw_system_error(__e);
-     else
-       return true;
+     // XXX EINVAL, EAGAIN, EBUSY
+     return !__gthread_mutex_trylock(&_M_mutex);
     }
 
     void
     unlock()
     {
-      int __e = __gthread_mutex_unlock(&_M_mutex);
-
-      // EINVAL, EAGAIN, EPERM
-     if (__e)
-       __throw_system_error(__e);
+      // XXX EINVAL, EAGAIN, EPERM
+     __gthread_mutex_unlock(&_M_mutex);
     }
 
     native_handle_type
@@ -120,14 +111,13 @@ namespace std
 
     recursive_mutex()
     {
+      // XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may)
 #if defined __GTHREAD_RECURSIVE_MUTEX_INIT
       native_handle_type __tmp = __GTHREAD_RECURSIVE_MUTEX_INIT;
       _M_mutex = __tmp;
 #else
       __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex);
 #endif
-
-      // EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may)
     }
 
 
@@ -144,23 +134,15 @@ namespace std
     bool
     try_lock()
     {
-      int __e = __gthread_recursive_mutex_trylock(&_M_mutex);
-
-      // EINVAL, EAGAIN, EBUSY
-     if (__e)
-       __throw_system_error(__e);
-     else
-       return true;
+      // XXX EINVAL, EAGAIN, EBUSY
+     return !__gthread_recursive_mutex_trylock(&_M_mutex);
     }
 
     void
     unlock()
     {
-      int __e = __gthread_recursive_mutex_unlock(&_M_mutex);
-
-      // EINVAL, EAGAIN, EBUSY
-     if (__e)
-       __throw_system_error(__e);
+      // XXX EINVAL, EAGAIN, EBUSY
+     __gthread_recursive_mutex_unlock(&_M_mutex);
     }
 
     native_handle_type
index fca1ffa4740c470b48a7b44a833bc727d4415fda..3ed9b6ebecc678ffe9d0ac6681e687bb877a258a 100644 (file)
@@ -1,4 +1,5 @@
-// { dg-options "-std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
+// { dg-options "-pthread -std=gnu++0x" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index 8a4d413c58693d28135557e00897b2f2c0ede9b7..f365d1167c1c5b7e14ed3258b19e42d1005d17ef 100644 (file)
@@ -39,4 +39,4 @@ void test01()
   m1 = m2;
 }
 // { dg-error "within this context" "" { target *-*-* } 39 } 
-// { dg-error "is private" "" { target *-*-* } 111 } 
+// { dg-error "is private" "" { target *-*-* } 102 } 
index 76bc7614391f13e452338a3629232ea8c9d891a1..d0a91025b54d9db177f73486608c039cc1021891 100644 (file)
@@ -38,4 +38,4 @@ void test01()
   mutex_type m2(m1);
 }
 // { dg-error "within this context" "" { target *-*-* } 38 } 
-// { dg-error "is private" "" { target *-*-* } 110 } 
+// { dg-error "is private" "" { target *-*-* } 101 } 
index 6fad4b5a69455ef1d1750512d809adbd75c33272..3fe33b2ca34097837ccf281828d946dffcc14004 100644 (file)
@@ -1,4 +1,5 @@
-// { dg-options "-std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
+// { dg-options "-pthread -std=gnu++0x" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index 3ca6b4af880b89507e68cea36213bbea96d6b423..c63c606ebc06c826d5d594fc4250eb754499431f 100644 (file)
@@ -1,4 +1,5 @@
-// { dg-options "-std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
+// { dg-options "-pthread -std=gnu++0x" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
@@ -41,11 +42,11 @@ int main()
       mutex_type m;
       m.lock();
 
-      // Lock already locked mutex, should be ok.
-      // XXX
+      // Lock already locked mutex.
       try
        {
-         m.lock();
+         // XXX Will block.
+         // m.lock();
        }
       catch (const std::system_error& e)
        {
index 8f3034a291dd76f62f51d705c18470d398342f40..d4cd9f7a2e428c6dffe31ce7cf903aef8167e0c6 100644 (file)
@@ -1,4 +1,5 @@
-// { dg-options "-std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
+// { dg-options "-pthread -std=gnu++0x" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index 20a3caa39e3cf59730053c497cd0cd6cc43742f7..b7380d65717d7cf19ec629ba3c4a85184374c7fe 100644 (file)
@@ -1,4 +1,5 @@
-// { dg-options "-std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
+// { dg-options "-pthread -std=gnu++0x" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index 617a6525615084b23a6f481392b59aae4b631966..7c7845edf5b687666b941c2441ce7b0ad2270a3b 100644 (file)
@@ -1,4 +1,5 @@
-// { dg-options "-std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
+// { dg-options "-pthread -std=gnu++0x" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
@@ -45,7 +46,7 @@ int main()
       try
        {
          b = m.try_lock();
-         VERIFY( b );
+         VERIFY( !b );
        }
       catch (const std::system_error& e)
        {
index 1a157290ee7592945217a427bc8fd8e41b052218..4c845fa4592182b3a0bcc258e1b0706b8e2f0d1b 100644 (file)
@@ -1,4 +1,5 @@
-// { dg-options "-std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
+// { dg-options "-pthread -std=gnu++0x" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index eb76d11a3296bbdc33bf419a3d72788486f3f1fe..1125ea624001c0d8d056e6aa41128f22cc5daa62 100644 (file)
@@ -1,4 +1,5 @@
-// { dg-options "-std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
+// { dg-options "-pthread -std=gnu++0x" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index 54877e427e19523125fe13629b2bc56086d3db55..ca3997422870cbf95c2d79dedb04b51fb75178ce 100644 (file)
@@ -39,4 +39,4 @@ void test01()
   m1 = m2;
 }
 // { dg-error "within this context" "" { target *-*-* } 39 } 
-// { dg-error "is private" "" { target *-*-* } 173 } 
+// { dg-error "is private" "" { target *-*-* } 155 } 
index 80a38b3e6eb71c475ab2dc408049f6bf4b71ca2d..7f530c36e38fd0629e2da02f3b7efc3371156657 100644 (file)
@@ -38,4 +38,4 @@ void test01()
   mutex_type m2(m1);
 }
 // { dg-error "within this context" "" { target *-*-* } 38 } 
-// { dg-error "is private" "" { target *-*-* } 172 } 
+// { dg-error "is private" "" { target *-*-* } 154 } 
index 3586cfa5398c719a89df92926fedd9b5e29562ea..464d1a80035377b68b6808d0352297350cba3b48 100644 (file)
@@ -1,4 +1,5 @@
-// { dg-options "-std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
+// { dg-options "-pthread -std=gnu++0x" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index d28513fc628296179fd271e0145d690e4114bec1..fb3be90deb3ca688c8287f6ae2cc741fc0e0f32d 100644 (file)
@@ -1,4 +1,5 @@
-// { dg-options "-std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
+// { dg-options "-pthread -std=gnu++0x" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //