aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@redhat.com>2008-05-15 00:52:48 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2008-05-15 00:52:48 +0000
commit22ac021be44b1e5dc781bcc24339f8c8e189d8e5 (patch)
treeaca599a585439e9a045658d42946ac5f4d22c49d
parent2fa9f315d4fb9a1633d9ed3105a6d256fa21e41f (diff)
downloadgcc-22ac021be44b1e5dc781bcc24339f8c8e189d8e5.zip
gcc-22ac021be44b1e5dc781bcc24339f8c8e189d8e5.tar.gz
gcc-22ac021be44b1e5dc781bcc24339f8c8e189d8e5.tar.bz2
mutex (mutex::try_lock): Eat errors.
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
-rw-r--r--libstdc++-v3/ChangeLog18
-rw-r--r--libstdc++-v3/include/std/mutex38
-rw-r--r--libstdc++-v3/testsuite/30_threads/mutex/cons/1.cc3
-rw-r--r--libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/30_threads/mutex/dest/destructor_locked.cc3
-rw-r--r--libstdc++-v3/testsuite/30_threads/mutex/lock/1.cc9
-rw-r--r--libstdc++-v3/testsuite/30_threads/mutex/native_handle/1.cc3
-rw-r--r--libstdc++-v3/testsuite/30_threads/mutex/try_lock/1.cc3
-rw-r--r--libstdc++-v3/testsuite/30_threads/mutex/try_lock/2.cc5
-rw-r--r--libstdc++-v3/testsuite/30_threads/mutex/unlock/1.cc3
-rw-r--r--libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/1.cc3
-rw-r--r--libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc3
-rw-r--r--libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/1.cc3
16 files changed, 56 insertions, 46 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index bb4e3d6..2f06c8e 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,23 @@
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.
* include/bits/fstream.tcc: Same.
* testsuite/29_atomics/atomic_flag/test_and_set/explicit.c: Add
diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex
index 935b16e..6a75e78 100644
--- a/libstdc++-v3/include/std/mutex
+++ b/libstdc++-v3/include/std/mutex
@@ -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
diff --git a/libstdc++-v3/testsuite/30_threads/mutex/cons/1.cc b/libstdc++-v3/testsuite/30_threads/mutex/cons/1.cc
index fca1ffa..3ed9b6e 100644
--- a/libstdc++-v3/testsuite/30_threads/mutex/cons/1.cc
+++ b/libstdc++-v3/testsuite/30_threads/mutex/cons/1.cc
@@ -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.
//
diff --git a/libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc
index 8a4d413..f365d11 100644
--- a/libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc
+++ b/libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc
@@ -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 }
diff --git a/libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc
index 76bc761..d0a9102 100644
--- a/libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc
+++ b/libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc
@@ -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 }
diff --git a/libstdc++-v3/testsuite/30_threads/mutex/dest/destructor_locked.cc b/libstdc++-v3/testsuite/30_threads/mutex/dest/destructor_locked.cc
index 6fad4b5..3fe33b2 100644
--- a/libstdc++-v3/testsuite/30_threads/mutex/dest/destructor_locked.cc
+++ b/libstdc++-v3/testsuite/30_threads/mutex/dest/destructor_locked.cc
@@ -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.
//
diff --git a/libstdc++-v3/testsuite/30_threads/mutex/lock/1.cc b/libstdc++-v3/testsuite/30_threads/mutex/lock/1.cc
index 3ca6b4a..c63c606 100644
--- a/libstdc++-v3/testsuite/30_threads/mutex/lock/1.cc
+++ b/libstdc++-v3/testsuite/30_threads/mutex/lock/1.cc
@@ -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)
{
diff --git a/libstdc++-v3/testsuite/30_threads/mutex/native_handle/1.cc b/libstdc++-v3/testsuite/30_threads/mutex/native_handle/1.cc
index 8f3034a..d4cd9f7 100644
--- a/libstdc++-v3/testsuite/30_threads/mutex/native_handle/1.cc
+++ b/libstdc++-v3/testsuite/30_threads/mutex/native_handle/1.cc
@@ -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.
//
diff --git a/libstdc++-v3/testsuite/30_threads/mutex/try_lock/1.cc b/libstdc++-v3/testsuite/30_threads/mutex/try_lock/1.cc
index 20a3caa..b7380d6 100644
--- a/libstdc++-v3/testsuite/30_threads/mutex/try_lock/1.cc
+++ b/libstdc++-v3/testsuite/30_threads/mutex/try_lock/1.cc
@@ -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.
//
diff --git a/libstdc++-v3/testsuite/30_threads/mutex/try_lock/2.cc b/libstdc++-v3/testsuite/30_threads/mutex/try_lock/2.cc
index 617a652..7c7845e 100644
--- a/libstdc++-v3/testsuite/30_threads/mutex/try_lock/2.cc
+++ b/libstdc++-v3/testsuite/30_threads/mutex/try_lock/2.cc
@@ -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)
{
diff --git a/libstdc++-v3/testsuite/30_threads/mutex/unlock/1.cc b/libstdc++-v3/testsuite/30_threads/mutex/unlock/1.cc
index 1a15729..4c845fa 100644
--- a/libstdc++-v3/testsuite/30_threads/mutex/unlock/1.cc
+++ b/libstdc++-v3/testsuite/30_threads/mutex/unlock/1.cc
@@ -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.
//
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/1.cc b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/1.cc
index eb76d11..1125ea6 100644
--- a/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/1.cc
+++ b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/1.cc
@@ -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.
//
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc
index 54877e4..ca39974 100644
--- a/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc
+++ b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc
@@ -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 }
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc
index 80a38b3..7f530c3 100644
--- a/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc
+++ b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc
@@ -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 }
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc b/libstdc++-v3/testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc
index 3586cfa..464d1a8 100644
--- a/libstdc++-v3/testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc
+++ b/libstdc++-v3/testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc
@@ -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.
//
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/1.cc b/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/1.cc
index d28513f..fb3be90 100644
--- a/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/1.cc
+++ b/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/1.cc
@@ -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.
//