OSDN Git Service

2008-09-03 Chris Fairles <chris.fairles@gmail.com>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 3 Sep 2008 17:46:09 +0000 (17:46 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 3 Sep 2008 17:46:09 +0000 (17:46 +0000)
        * include/std/condition_variable: Use new deleted ctors.
        * include/std/mutex: Likewise plus implement timed_mutex,
recursive_timed_mutex and call_once.
* src/condition_variable.cc: Implement wait(). Use gthread types.
Remove _GTHREADS_HAS_COND checks in favor of global
_GLIBCXX_HAS_GTHREADS.
* src/mutex.cc (call_once): Implementation using TLS with mutex
fallback.
* config/abi/pre/gnu.ver: Add exported symbols.
* testsuite/lib/libstdc++.exp (check_v3_target_gthreads): New.
* testsuite/lib/dg-options.exp (dg-require-gthreads): Likewise.
* testsuite/30_threads/lock_guard/requirements/typedefs.cc: Use
dg-require-gthreads and dg-require-cstdint.
* testsuite/30_threads/lock_guard/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/30_threads/mutex/dest/destructor_locked.cc: Likewise.
* testsuite/30_threads/mutex/native_handle/1.cc: Likewise.
* testsuite/30_threads/mutex/cons/1.cc: Likewise.
* testsuite/30_threads/mutex/requirements/typedefs.cc: Likewise.
* testsuite/30_threads/mutex/try_lock/1.cc: Likewise.
* testsuite/30_threads/mutex/try_lock/2.cc: Likewise.
* testsuite/30_threads/mutex/lock/1.cc: Likewise.
* testsuite/30_threads/mutex/unlock/1.cc: Likewise.
* testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc:
Likewise.
        * testsuite/30_threads/recursive_mutex/native_handle/1.cc: Likewise.
* testsuite/30_threads/recursive_mutex/cons/1.cc: Likewise.
        * testsuite/30_threads/recursive_mutex/requirements/typedefs.cc:
Likewise.
        * testsuite/30_threads/recursive_mutex/try_lock/1.cc: Likewise.
        * testsuite/30_threads/recursive_mutex/try_lock/2.cc: Likewise.
        * testsuite/30_threads/recursive_mutex/lock/1.cc: Likewise.
        * testsuite/30_threads/recursive_mutex/unlock/1.cc: Likewise.
* testsuite/30_threads/unique_lock/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/30_threads/unique_lock/requirements/typedefs.cc: Likewise.
        * testsuite/30_threads/mutex/cons/assign_neg.cc: Also adjust dg-error
lines for deleted members.
        * testsuite/30_threads/mutex/cons/copy_neg.cc: Likewise.
        * testsuite/30_threads/recursive_mutex/cons/assign_neg.cc: Likewise.
        * testsuite/30_threads/recursive_mutex/cons/copy_neg.cc: Likewise.
* testsuite/30_threads/call_once/once_flag.cc: New.
* testsuite/30_threads/call_once/call_once1.cc: Likewise.
* testsuite/30_threads/condition_variable/cons/1.cc: Likewise.
* testsuite/30_threads/condition_variable/cons/copy_neg.cc: Likewise
* testsuite/30_threads/condition_variable/cons/assign_neg.cc: Likewise.
* testsuite/30_threads/condition_variable_any/cons/1.cc: Likewise.
* testsuite/30_threads/condition_variable_any/cons/copy_neg.cc:
Likewise.
* testsuite/30_threads/condition_variable_any/cons/assign_neg.cc:
Likewise.
* testsuite/30_threads/timed_mutex/dest/destructor_locked.cc: Likewise.
* testsuite/30_threads/timed_mutex/native_handle/1.cc: Likewise.
* testsuite/30_threads/timed_mutex/try_lock_until/1.cc: Likewise.
* testsuite/30_threads/timed_mutex/try_lock_until/2.cc: Likewise.
* testsuite/30_threads/timed_mutex/cons/assign_neg.cc: Likewise.
* testsuite/30_threads/timed_mutex/cons/1.cc: Likewise.
* testsuite/30_threads/timed_mutex/cons/copy_neg.cc: Likewise.
* testsuite/30_threads/timed_mutex/requirements/typedefs.cc: Likewise.
* testsuite/30_threads/timed_mutex/try_lock/1.cc: Likewise.
* testsuite/30_threads/timed_mutex/try_lock/2.cc: Likewise.
* testsuite/30_threads/timed_mutex/lock/1.cc: Likewise.
* testsuite/30_threads/timed_mutex/unlock/1.cc: Likewise.
* testsuite/30_threads/timed_mutex/try_lock_for/1.cc: Likewise.
* testsuite/30_threads/timed_mutex/try_lock_for/2.cc: Likewise.
* testsuite/30_threads/timed_mutex/try_lock_for/3.cc: Likewise.
* testsuite/30_threads/recursive_timed_mutex/dest/destructor_locked.cc:
Likewise.
* testsuite/30_threads/recursive_timed_mutex/try_lock_until/1.cc:
Likewise.
* testsuite/30_threads/recursive_timed_mutex/try_lock_until/2.cc:
Likewise.
* testsuite/30_threads/recursive_timed_mutex/native_handle/1.cc:
Likewise.
* testsuite/30_threads/recursive_timed_mutex/cons: Likewise.
* testsuite/30_threads/recursive_timed_mutex/cons/assign_neg.cc:
Likewise.
* testsuite/30_threads/recursive_timed_mutex/cons/1.cc: Likewise.
* testsuite/30_threads/recursive_timed_mutex/cons/copy_neg.cc: Likewise.
* testsuite/30_threads/recursive_timed_mutex/requirements/typedefs.cc:
Likewise.
* testsuite/30_threads/recursive_timed_mutex/try_lock/1.cc: Likewise.
* testsuite/30_threads/recursive_timed_mutex/try_lock/2.cc: Likewise.
* testsuite/30_threads/recursive_timed_mutex/lock/1.cc: Likewise.
* testsuite/30_threads/recursive_timed_mutex/lock/2.cc: Likewise.
* testsuite/30_threads/recursive_timed_mutex/unlock/1.cc: Likewise.
* testsuite/30_threads/recursive_timed_mutex/try_lock_for/1.cc:
Likewise.
* testsuite/30_threads/recursive_timed_mutex/try_lock_for/2.cc:
Likewise.
* testsuite/30_threads/recursive_timed_mutex/try_lock_for/3.cc:
Likewise.
* testsuite/30_threads/unique_lock/modifiers/1.cc: Likewise.
* testsuite/30_threads/unique_lock/modifiers/2.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/1.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/2.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/3.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/4.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/5.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/6.cc: Likewise.
* testsuite/30_threads/unique_lock/locking/1.cc: Likewise.
* testsuite/30_threads/unique_lock/locking/2.cc: Likewise.
* testsuite/30_threads/unique_lock/locking/3.cc: Likewise.
* testsuite/30_threads/unique_lock/locking/4.cc: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139943 138bc75d-0d04-0410-961f-82ee72b054a4

69 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/config/abi/pre/gnu.ver
libstdc++-v3/include/std/condition_variable
libstdc++-v3/include/std/mutex
libstdc++-v3/src/condition_variable.cc
libstdc++-v3/src/mutex.cc
libstdc++-v3/testsuite/30_threads/call_once/call_once1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/call_once/once_flag.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/condition_variable/cons/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/condition_variable/cons/assign_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/condition_variable/cons/copy_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/assign_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/copy_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/headers/condition_variable/types_std_c++0x.cc
libstdc++-v3/testsuite/30_threads/headers/mutex/types_std_c++0x.cc
libstdc++-v3/testsuite/30_threads/lock_guard/requirements/explicit_instantiation.cc
libstdc++-v3/testsuite/30_threads/lock_guard/requirements/typedefs.cc
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/requirements/typedefs.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
libstdc++-v3/testsuite/30_threads/recursive_mutex/requirements/typedefs.cc
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/assign_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/copy_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/dest/destructor_locked.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/lock/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/lock/2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/requirements/typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock/2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/3.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/unlock/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/timed_mutex/cons/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/timed_mutex/cons/assign_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/timed_mutex/cons/copy_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/timed_mutex/dest/destructor_locked.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/timed_mutex/lock/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/timed_mutex/requirements/typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock/2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/3.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/timed_mutex/unlock/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/unique_lock/requirements/explicit_instantiation.cc
libstdc++-v3/testsuite/30_threads/unique_lock/requirements/typedefs.cc
libstdc++-v3/testsuite/lib/dg-options.exp
libstdc++-v3/testsuite/lib/libstdc++.exp

index 0b2f5b9..89e0b2a 100644 (file)
@@ -1,3 +1,111 @@
+2008-09-03  Chris Fairles  <chris.fairles@gmail.com>
+
+        * include/std/condition_variable: Use new deleted ctors.
+        * include/std/mutex: Likewise plus implement timed_mutex, 
+       recursive_timed_mutex and call_once.
+       * src/condition_variable.cc: Implement wait(). Use gthread types.
+       Remove _GTHREADS_HAS_COND checks in favor of global
+       _GLIBCXX_HAS_GTHREADS.
+       * src/mutex.cc (call_once): Implementation using TLS with mutex
+       fallback.
+       * config/abi/pre/gnu.ver: Add exported symbols.
+       * testsuite/lib/libstdc++.exp (check_v3_target_gthreads): New.
+       * testsuite/lib/dg-options.exp (dg-require-gthreads): Likewise.
+       * testsuite/30_threads/lock_guard/requirements/typedefs.cc: Use
+       dg-require-gthreads and dg-require-cstdint.
+       * testsuite/30_threads/lock_guard/requirements/
+       explicit_instantiation.cc: Likewise.
+       * testsuite/30_threads/mutex/dest/destructor_locked.cc: Likewise.
+       * testsuite/30_threads/mutex/native_handle/1.cc: Likewise.
+       * testsuite/30_threads/mutex/cons/1.cc: Likewise.
+       * testsuite/30_threads/mutex/requirements/typedefs.cc: Likewise.
+       * testsuite/30_threads/mutex/try_lock/1.cc: Likewise.
+       * testsuite/30_threads/mutex/try_lock/2.cc: Likewise.
+       * testsuite/30_threads/mutex/lock/1.cc: Likewise.
+       * testsuite/30_threads/mutex/unlock/1.cc: Likewise.
+       * testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc:
+       Likewise.
+        * testsuite/30_threads/recursive_mutex/native_handle/1.cc: Likewise.
+       * testsuite/30_threads/recursive_mutex/cons/1.cc: Likewise.
+        * testsuite/30_threads/recursive_mutex/requirements/typedefs.cc:
+       Likewise.
+        * testsuite/30_threads/recursive_mutex/try_lock/1.cc: Likewise.
+        * testsuite/30_threads/recursive_mutex/try_lock/2.cc: Likewise.
+        * testsuite/30_threads/recursive_mutex/lock/1.cc: Likewise.
+        * testsuite/30_threads/recursive_mutex/unlock/1.cc: Likewise.
+       * testsuite/30_threads/unique_lock/requirements/
+       explicit_instantiation.cc: Likewise.
+       * testsuite/30_threads/unique_lock/requirements/typedefs.cc: Likewise.
+        * testsuite/30_threads/mutex/cons/assign_neg.cc: Also adjust dg-error
+       lines for deleted members.
+        * testsuite/30_threads/mutex/cons/copy_neg.cc: Likewise.
+        * testsuite/30_threads/recursive_mutex/cons/assign_neg.cc: Likewise.
+        * testsuite/30_threads/recursive_mutex/cons/copy_neg.cc: Likewise.
+       * testsuite/30_threads/call_once/once_flag.cc: New.
+       * testsuite/30_threads/call_once/call_once1.cc: Likewise.
+       * testsuite/30_threads/condition_variable/cons/1.cc: Likewise.
+       * testsuite/30_threads/condition_variable/cons/copy_neg.cc: Likewise
+       * testsuite/30_threads/condition_variable/cons/assign_neg.cc: Likewise.
+       * testsuite/30_threads/condition_variable_any/cons/1.cc: Likewise.
+       * testsuite/30_threads/condition_variable_any/cons/copy_neg.cc:
+       Likewise.
+       * testsuite/30_threads/condition_variable_any/cons/assign_neg.cc:
+       Likewise.
+       * testsuite/30_threads/timed_mutex/dest/destructor_locked.cc: Likewise.
+       * testsuite/30_threads/timed_mutex/native_handle/1.cc: Likewise.
+       * testsuite/30_threads/timed_mutex/try_lock_until/1.cc: Likewise.
+       * testsuite/30_threads/timed_mutex/try_lock_until/2.cc: Likewise.
+       * testsuite/30_threads/timed_mutex/cons/assign_neg.cc: Likewise.
+       * testsuite/30_threads/timed_mutex/cons/1.cc: Likewise.
+       * testsuite/30_threads/timed_mutex/cons/copy_neg.cc: Likewise.
+       * testsuite/30_threads/timed_mutex/requirements/typedefs.cc: Likewise.
+       * testsuite/30_threads/timed_mutex/try_lock/1.cc: Likewise.
+       * testsuite/30_threads/timed_mutex/try_lock/2.cc: Likewise.
+       * testsuite/30_threads/timed_mutex/lock/1.cc: Likewise.
+       * testsuite/30_threads/timed_mutex/unlock/1.cc: Likewise.
+       * testsuite/30_threads/timed_mutex/try_lock_for/1.cc: Likewise.
+       * testsuite/30_threads/timed_mutex/try_lock_for/2.cc: Likewise.
+       * testsuite/30_threads/timed_mutex/try_lock_for/3.cc: Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/dest/destructor_locked.cc: 
+       Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/try_lock_until/1.cc: 
+       Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/try_lock_until/2.cc: 
+       Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/native_handle/1.cc: 
+       Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/cons: Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/cons/assign_neg.cc: 
+       Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/cons/1.cc: Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/cons/copy_neg.cc:
+       Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/requirements/typedefs.cc:
+       Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/try_lock/1.cc: Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/try_lock/2.cc: Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/lock/1.cc: Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/lock/2.cc: Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/unlock/1.cc: Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/try_lock_for/1.cc:
+       Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/try_lock_for/2.cc:
+       Likewise.
+       * testsuite/30_threads/recursive_timed_mutex/try_lock_for/3.cc:
+       Likewise.
+       * testsuite/30_threads/unique_lock/modifiers/1.cc: Likewise.
+       * testsuite/30_threads/unique_lock/modifiers/2.cc: Likewise.
+       * testsuite/30_threads/unique_lock/cons/1.cc: Likewise.
+       * testsuite/30_threads/unique_lock/cons/2.cc: Likewise.
+       * testsuite/30_threads/unique_lock/cons/3.cc: Likewise.
+       * testsuite/30_threads/unique_lock/cons/4.cc: Likewise.
+       * testsuite/30_threads/unique_lock/cons/5.cc: Likewise.
+       * testsuite/30_threads/unique_lock/cons/6.cc: Likewise.
+       * testsuite/30_threads/unique_lock/locking/1.cc: Likewise.
+       * testsuite/30_threads/unique_lock/locking/2.cc: Likewise.
+       * testsuite/30_threads/unique_lock/locking/3.cc: Likewise.
+       * testsuite/30_threads/unique_lock/locking/4.cc: Likewise.
+
 2008-09-01  Mark Mitchell  <mark@codesourcery.com>
 
        * include/std/type_traits (__make_unsigned_selector<>): Consider
index 0ec4879..7f94012 100644 (file)
@@ -860,13 +860,25 @@ GLIBCXX_3.4.11 {
     _ZTSSt10lock_error;
     _ZNKSt10lock_error4whatEv;
 
+    _ZSt11__once_call;
+    _ZSt15__once_callable;
+    _ZSt14__once_functor;
+    _ZSt11__once_lock;
+    _ZSt12__once_mutex;
+    __once_proxy;
+
     # condition_variable
     _ZNSt18condition_variable10notify_allEv;
     _ZNSt18condition_variable10notify_oneEv;
+    _ZNSt18condition_variable4waitERSt11unique_lockISt5mutexE;
     _ZNSt18condition_variableC1Ev;
     _ZNSt18condition_variableC2Ev;
     _ZNSt18condition_variableD1Ev;
     _ZNSt18condition_variableD2Ev;
+    _ZNSt22condition_variable_anyC1Ev;
+    _ZNSt22condition_variable_anyC2Ev;
+    _ZNSt22condition_variable_anyD1Ev;
+    _ZNSt22condition_variable_anyD2Ev;
 
     # system_error
     _ZSt18get_posix_categoryv;
index 1a7a7cd..f2035d6 100644 (file)
 # include <c++0x_warning.h>
 #else
 
+#include <chrono>
 #include <mutex> // unique_lock
 
+#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
+
 namespace std 
 {
-  namespace chrono
-  {
-    template<typename _Rep, typename _Period>
-      struct duration;
-
-    template<typename _Clock, typename _Duration>
-      struct time_point;
-  }
-
   /// condition_variable
   class condition_variable
   {
   public:
-
-#if __GTHREAD_HAS_COND
-    typedef __gthread_cond_t native_handle_type;
-#else
-    typedef int native_handle_type;
-#endif
+    typedef __gthread_cond_t* native_handle_type;
 
     condition_variable();
     ~condition_variable();
 
+    condition_variable(const condition_variable&) = delete;
+    condition_variable& operator=(const condition_variable&) = delete;
+
     void 
     notify_one();
 
@@ -87,7 +79,23 @@ namespace std
     template<typename _Clock, typename _Duration>
       bool 
       wait_until(unique_lock<mutex>& __lock, 
-                const chrono::time_point<_Clock, _Duration>& __atime);
+                const chrono::time_point<_Clock, _Duration>& __atime)
+      {
+       chrono::time_point<_Clock, chrono::seconds>  __s =
+          chrono::time_point_cast<chrono::seconds>(__atime);
+
+       chrono::nanoseconds __ns =
+          chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
+
+        __gthread_time_t __ts = {
+          static_cast<std::time_t>(__s.time_since_epoch().count()),
+          static_cast<long>(__ns.count())
+        };
+       
+       __gthread_cond_timedwait(&_M_cond, __lock.mutex()->native_handle(), &__ts);
+       
+       return __clock_t::now() < __atime;
+      }
 
     template<typename _Clock, typename _Duration, typename _Predicate>
       bool
@@ -98,7 +106,8 @@ namespace std
     template<typename _Rep, typename _Period>
       bool
       wait_for(unique_lock<mutex>& __lock,
-              const chrono::duration<_Rep, _Period>& __rtime);
+              const chrono::duration<_Rep, _Period>& __rtime)
+      { return __wait_for_impl(__rtime); }
 
     template<typename _Rep, typename _Period, typename _Predicate>
       bool
@@ -107,12 +116,42 @@ namespace std
               _Predicate __p);
 
     native_handle_type 
-    native_handle() { return _M_cond; }
+    native_handle() 
+    { return &_M_cond; }
 
   private:
-    native_handle_type _M_cond;
-    condition_variable(const condition_variable&);
-    condition_variable& operator=(const condition_variable&);
+    __gthread_cond_t _M_cond;
+    mutex _M_internal_mutex;
+
+#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
+    typedef chrono::monotonic_clock __clock_t;
+#else
+    typedef chrono::high_resolution_clock __clock_t;
+#endif
+
+    template<typename _Rep, typename _Period>
+      typename enable_if<
+        ratio_less_equal<__clock_t::period, _Period>::value, bool>::type
+      __wait_for_impl(unique_lock<mutex>& __lock,
+                     const chrono::duration<_Rep, _Period>& __rtime)
+      { 
+       __clock_t::time_point __atime = __clock_t::now()
+         + chrono::duration_cast<__clock_t::duration>(__rtime);
+       
+       return wait_until(__lock, __atime);
+      }
+    
+    template<typename _Rep, typename _Period>
+      typename enable_if<
+        !ratio_less_equal<__clock_t::period, _Period>::value, bool>::type
+      __wait_for_impl(unique_lock<mutex>& __lock,
+                     const chrono::duration<_Rep, _Period>& __rtime)
+      { 
+       __clock_t::time_point __atime = __clock_t::now()
+         + ++chrono::duration_cast<__clock_t::duration>(__rtime);
+       
+       return wait_until(__lock, __atime);
+      }    
   };
 
   /// condition_variable_any
@@ -120,14 +159,13 @@ namespace std
   class condition_variable_any
   {
   public:
-#if __GTHREAD_HAS_COND
-    typedef __gthread_cond_t native_handle_type;
-#else
-    typedef int native_handle_type;
-#endif
+    typedef __gthread_cond_t* native_handle_type;
 
     condition_variable_any();
     ~condition_variable_any();
+    
+    condition_variable_any(const condition_variable_any&) = delete;
+    condition_variable_any& operator=(const condition_variable_any&) = delete;
 
     void 
     notify_one();
@@ -166,16 +204,16 @@ namespace std
               const chrono::duration<_Rep, _Period>& __rtime, _Predicate __p);
 
     native_handle_type 
-    native_handle() { return _M_cond; }
+    native_handle()
+    { return &_M_cond; }
 
   private:
-    native_handle_type _M_cond;
-    condition_variable_any(const condition_variable_any&);
-    condition_variable_any& operator=(const condition_variable_any&);
+    __gthread_cond_t _M_cond;
   };
-
 }
 
+#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
+
 #endif // __GXX_EXPERIMENTAL_CXX0X__
 
 #endif // _GLIBCXX_CONDITION_VARIABLE
index 779394a..5e6ba9c 100644 (file)
 # include <c++0x_warning.h>
 #else
 
-#include <exception>
 #include <cstddef>
+#include <chrono>
+#include <exception>
+#include <type_traits>
+#include <functional>
+#include <system_error>
 #include <bits/functexcept.h>
 #include <bits/gthr.h>
+#include <bits/move.h> // for std::swap
+
+#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
 
 namespace std
 {
-  namespace chrono
-  {
-    template<typename _Rep, typename _Period>
-      struct duration;
-
-    template<typename _Clock, typename _Duration>
-      struct time_point;
-  }
-
   /// mutex
   class mutex
   {
   public:
-    typedef __gthread_mutex_t native_handle_type;
+    typedef __gthread_mutex_t* native_handle_type;
 
     mutex()
     {
       // XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may)
-#if defined __GTHREAD_MUTEX_INIT
-      native_handle_type __tmp = __GTHREAD_MUTEX_INIT;
+#ifdef __GTHREAD_MUTEX_INIT
+      __gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
       _M_mutex = __tmp;
 #else
       __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex);
 #endif
     }
 
+    mutex(const mutex&) = delete;
+    mutex& operator=(const mutex&) = delete;
+
     void
     lock()
     {
@@ -100,31 +101,32 @@ namespace std
 
     native_handle_type
     native_handle()
-    { return _M_mutex; }
+    { return &_M_mutex; }
 
   private:
-    native_handle_type _M_mutex;
-    mutex(const mutex&);
-    mutex& operator=(const mutex&);
+    __gthread_mutex_t _M_mutex;
   };
 
   /// recursive_mutex
   class recursive_mutex
   {
   public:
-    typedef __gthread_recursive_mutex_t native_handle_type;
+    typedef __gthread_recursive_mutex_t* native_handle_type;
 
     recursive_mutex()
     {
       // XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may)
-#if defined __GTHREAD_RECURSIVE_MUTEX_INIT
-      native_handle_type __tmp = __GTHREAD_RECURSIVE_MUTEX_INIT;
+#ifdef __GTHREAD_RECURSIVE_MUTEX_INIT
+      __gthread_recursive_mutex_t __tmp = __GTHREAD_RECURSIVE_MUTEX_INIT;
       _M_mutex = __tmp;
 #else
       __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex);
 #endif
     }
 
+    recursive_mutex(const recursive_mutex&) = delete;
+    recursive_mutex& operator=(const recursive_mutex&) = delete;
+
     void
     lock()
     {
@@ -139,85 +141,227 @@ namespace std
     try_lock()
     {
       // XXX EINVAL, EAGAIN, EBUSY
-     return !__gthread_recursive_mutex_trylock(&_M_mutex);
+      return !__gthread_recursive_mutex_trylock(&_M_mutex);
     }
 
     void
     unlock()
     {
       // XXX EINVAL, EAGAIN, EBUSY
-     __gthread_recursive_mutex_unlock(&_M_mutex);
+      __gthread_recursive_mutex_unlock(&_M_mutex);
     }
 
     native_handle_type
     native_handle()
-    { return _M_mutex; }
+    { return &_M_mutex; }
 
   private:
-    native_handle_type _M_mutex;
-
-    recursive_mutex(const recursive_mutex&);
-    recursive_mutex& operator=(const recursive_mutex&);
+    __gthread_recursive_mutex_t  _M_mutex;
   };
 
   /// timed_mutex
   class timed_mutex
-  {
+  {  
   public:
-    typedef __gthread_mutex_t native_handle_type;
+    typedef __gthread_mutex_t* native_handle_type;
 
-    void lock();
-    bool try_lock();
+    timed_mutex()
+    {
+#ifdef __GTHREAD_MUTEX_INIT
+      __gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
+      _M_mutex = __tmp;
+#else
+      __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex);
+#endif
+    }
+
+    timed_mutex(const timed_mutex&) = delete;
+    timed_mutex& operator=(const timed_mutex&) = delete;
+
+    void
+    lock()
+    {
+      int __e = __gthread_mutex_lock(&_M_mutex);
+
+      // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may)
+      if (__e)
+       __throw_system_error(__e);
+    }
+
+    bool
+    try_lock()
+    {
+      // XXX EINVAL, EAGAIN, EBUSY
+      return !__gthread_mutex_trylock(&_M_mutex);
+    }
 
     template <class _Rep, class _Period>
       bool
-      try_lock_for(const chrono::duration<_Rep, _Period>& __rtime);
+      try_lock_for(const chrono::duration<_Rep, _Period>& __rtime)
+      { return __try_lock_for_impl(__rtime); }
 
     template <class _Clock, class _Duration>
       bool
-      try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime);
+      try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime)
+      { 
+       chrono::time_point<_Clock, chrono::seconds> __s =
+          chrono::time_point_cast<chrono::seconds>(__atime);
+
+       chrono::nanoseconds __ns =
+          chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
+
+        __gthread_time_t __ts = {
+          static_cast<std::time_t>(__s.time_since_epoch().count()),
+          static_cast<long>(__ns.count())
+        };
 
-    void unlock();
+       return !__gthread_mutex_timedlock(&_M_mutex, &__ts);    
+      }
+
+    void
+    unlock()
+    {
+      // XXX EINVAL, EAGAIN, EBUSY
+      __gthread_mutex_unlock(&_M_mutex);
+    }
 
     native_handle_type
     native_handle()
-    { return _M_mutex; }
+    { return &_M_mutex; }
     
   private:
-    native_handle_type _M_mutex;
+    __gthread_mutex_t _M_mutex;
+    
+#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
+    typedef chrono::monotonic_clock __clock_t;
+#else
+    typedef chrono::high_resolution_clock __clock_t;
+#endif
 
-    timed_mutex(const timed_mutex&);
-    timed_mutex& operator=(const timed_mutex&);
+    template<typename _Rep, typename _Period>
+      typename enable_if<
+        ratio_less_equal<__clock_t::period, _Period>::value, bool>::type
+      __try_lock_for_impl(const chrono::duration<_Rep, _Period>& __rtime)
+      {
+        __clock_t::time_point __atime = __clock_t::now()
+          + chrono::duration_cast<__clock_t::duration>(__rtime);
+
+        return try_lock_until(__atime);
+      }
+
+    template <typename _Rep, typename _Period>
+      typename enable_if<
+        !ratio_less_equal<__clock_t::period, _Period>::value, bool>::type
+      __try_lock_for_impl(const chrono::duration<_Rep, _Period>& __rtime)
+      {
+        __clock_t::time_point __atime = __clock_t::now()
+         + ++chrono::duration_cast<__clock_t::duration>(__rtime);
+
+        return try_lock_until(__atime);
+      }
   };
 
   /// recursive_timed_mutex
   class recursive_timed_mutex
   {
   public:
-    typedef __gthread_mutex_t native_handle_type;
+    typedef __gthread_recursive_mutex_t* native_handle_type;
+
+    recursive_timed_mutex()
+    {
+      // XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may)
+#ifdef __GTHREAD_RECURSIVE_MUTEX_INIT
+      __gthread_recursive_mutex_t __tmp = __GTHREAD_RECURSIVE_MUTEX_INIT;
+      _M_mutex = __tmp;
+#else
+      __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex);
+#endif
+    }
+
+    recursive_timed_mutex(const recursive_timed_mutex&) = delete;
+    recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
+
+    void
+    lock()
+    {
+      int __e = __gthread_recursive_mutex_lock(&_M_mutex);
+
+      // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may)
+      if (__e)
+       __throw_system_error(__e);
+    }
 
-    void lock();
-    bool try_lock();
+    bool
+    try_lock()
+    {
+      // XXX EINVAL, EAGAIN, EBUSY
+      return !__gthread_recursive_mutex_trylock(&_M_mutex);
+    }
 
     template <class _Rep, class _Period>
       bool
-      try_lock_for(const chrono::duration<_Rep, _Period>& __rtime);
+      try_lock_for(const chrono::duration<_Rep, _Period>& __rtime)
+      { return __try_lock_for_impl(__rtime); }
 
     template <class _Clock, class _Duration>
       bool
-      try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime);
+      try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime)
+      { 
+       chrono::time_point<_Clock, chrono::seconds>  __s =
+          chrono::time_point_cast<chrono::seconds>(__atime);
+
+       chrono::nanoseconds __ns =
+          chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
 
-    void unlock();
+        __gthread_time_t __ts = {
+          static_cast<std::time_t>(__s.time_since_epoch().count()),
+          static_cast<long>(__ns.count())
+        };
+
+        return !__gthread_recursive_mutex_timedlock(&_M_mutex, &__ts);
+      }
+
+    void
+    unlock()
+    {
+      // XXX EINVAL, EAGAIN, EBUSY
+      __gthread_recursive_mutex_unlock(&_M_mutex);
+    }
 
     native_handle_type
     native_handle()
-    { return _M_mutex; }
-    
+    { return &_M_mutex; }
+
   private:
-    native_handle_type _M_mutex;
+    __gthread_recursive_mutex_t _M_mutex;
 
-    recursive_timed_mutex(const recursive_timed_mutex&);
-    recursive_timed_mutex& operator=(const recursive_timed_mutex&);
+#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
+    typedef chrono::monotonic_clock __clock_t;
+#else
+    typedef chrono::high_resolution_clock __clock_t;
+#endif
+
+    template<typename _Rep, typename _Period>
+      typename enable_if<
+        ratio_less_equal<__clock_t::period, _Period>::value, bool>::type
+      __try_lock_for_impl(const chrono::duration<_Rep, _Period>& __rtime)
+      {
+        __clock_t::time_point __atime = __clock_t::now()
+          + chrono::duration_cast<__clock_t::duration>(__rtime);
+
+        return try_lock_until(__atime);
+      }
+
+    template <typename _Rep, typename _Period>
+      typename enable_if<
+        !ratio_less_equal<__clock_t::period, _Period>::value, bool>::type
+      __try_lock_for_impl(const chrono::duration<_Rep, _Period>& __rtime)
+      {
+        __clock_t::time_point __atime = __clock_t::now()
+         + ++chrono::duration_cast<__clock_t::duration>(__rtime);
+
+        return try_lock_until(__atime);
+      }
   };
 
   /// Do not acquire ownership of the mutex.
@@ -260,10 +404,11 @@ namespace std
       ~lock_guard()
       { _M_device.unlock(); }
 
+      lock_guard(const lock_guard&) = delete;
+      lock_guard& operator=(const lock_guard&) = delete;
+
     private:
       mutex_type&  _M_device;
-      lock_guard(lock_guard const&);
-      lock_guard& operator=(lock_guard const&);
     };
 
   /// unique_lock
@@ -272,13 +417,13 @@ namespace std
     {
     public:
       typedef _Mutex mutex_type;
-
+      
       unique_lock()
-      : _M_device(NULL), _M_owns(false)
+      : _M_device(0), _M_owns(false)
       { }
 
       explicit unique_lock(mutex_type& __m)
-      : _M_device(&__m)
+      : _M_device(&__m), _M_owns(false)
       {
        lock();
        _M_owns = true;
@@ -300,11 +445,15 @@ namespace std
 
       template<typename _Clock, typename _Duration>
        unique_lock(mutex_type& __m, 
-                   const chrono::time_point<_Clock, _Duration>& __atime);
+                   const chrono::time_point<_Clock, _Duration>& __atime)
+       : _M_device(&__m), _M_owns(_M_device->try_lock_until(__atime))
+       { }
 
       template<typename _Rep, typename _Period>
        unique_lock(mutex_type& __m, 
-                   const chrono::duration<_Rep, _Period>& __rtime);
+                   const chrono::duration<_Rep, _Period>& __rtime)
+       : _M_device(&__m), _M_owns(_M_device->try_lock_for(__rtime))
+       { }
 
       ~unique_lock()
       {
@@ -312,55 +461,111 @@ namespace std
          unlock();
       }
 
-      unique_lock(unique_lock&&);
+      unique_lock(const unique_lock&) = delete;
+      unique_lock& operator=(const unique_lock&) = delete;
+
+      unique_lock(unique_lock&& __u)
+      : _M_device(__u._M_device), _M_owns(__u._M_owns)
+      {
+       __u._M_device = 0;
+       __u._M_owns = false;
+      }
+
+      unique_lock& operator=(unique_lock&& __u)
+      {
+        if(_M_owns)
+         unlock();
+       
+       unique_lock(std::move(__u)).swap(*this);
 
-      unique_lock& operator=(unique_lock&&);
+       __u._M_device = 0;
+       __u._M_owns = false;
+       
+       return *this;
+      }
 
       void
       lock()
       {
-       if (_M_device && !_M_owns)
-         _M_device->lock();
+       if (!_M_device)
+         __throw_system_error(posix_error::operation_not_permitted);
+       else if (_M_owns)
+         __throw_system_error(posix_error::resource_deadlock_would_occur);
        else
-         throw lock_error();
+         {
+           _M_device->lock();
+           _M_owns = true;
+         }
       }
 
       bool
       try_lock()
       {
-       bool __ret = false;
-       if (_M_device && !_M_owns)
-         __ret = _M_device->try_lock();
-       else
-         throw lock_error();
-       return __ret;
+       if (!_M_device)
+          __throw_system_error(posix_error::operation_not_permitted);
+        else if (_M_owns)
+          __throw_system_error(posix_error::resource_deadlock_would_occur);
+        else
+         {
+           _M_owns = _M_device->try_lock();        
+           return _M_owns;
+         }
       }
 
+      template<typename _Clock, typename _Duration>
+        bool
+        try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime)
+        {
+         if (!_M_device)
+           __throw_system_error(posix_error::operation_not_permitted);
+         else if (_M_owns)
+           __throw_system_error(posix_error::resource_deadlock_would_occur);
+         else
+           {
+             _M_owns = _M_device->try_lock_until(__atime);
+             return _M_owns;
+           }
+       }
+      
+      template<typename _Rep, typename _Period>
+       bool
+       try_lock_for(const chrono::duration<_Rep, _Period>& __rtime)
+        {
+         if (!_M_device)
+           __throw_system_error(posix_error::operation_not_permitted);
+         else if (_M_owns)
+           __throw_system_error(posix_error::resource_deadlock_would_occur);
+         else
+           {
+             _M_owns = _M_device->try_lock_for(__rtime);
+             return _M_owns;
+           }
+        }
+
       void
       unlock()
       {
-       if (_M_device && _M_owns)
-         _M_device->unlock();
-       else
-         throw lock_error();
+        if (!_M_owns)
+          __throw_system_error(posix_error::operation_not_permitted);
+        else if (_M_device)
+          {
+            _M_device->unlock();
+            _M_owns = false;
+          }
       }
-
-      template<typename _Rep, typename _Period>
-       bool
-       try_lock_for(const chrono::duration<_Rep, _Period>& __rtime);
-
-      template<typename _Clock, typename _Duration>
-       bool
-       try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime);
-
+      
       void
-      swap(unique_lock&& __u);
+      swap(unique_lock&& __u)
+      {
+       std::swap(_M_device, __u._M_device);
+       std::swap(_M_owns, __u._M_owns);
+      }
 
       mutex_type*
       release()
       {
        mutex_type* __ret = _M_device;
-       _M_device = NULL;
+       _M_device = 0;
        _M_owns = false;
        return __ret;
       }
@@ -369,7 +574,7 @@ namespace std
       owns_lock() const
       { return _M_owns; }
 
-      operator bool () const
+      /* explicit */ operator bool () const
       { return owns_lock(); }
 
       mutex_type*
@@ -377,28 +582,28 @@ namespace std
       { return _M_device; }
 
     private:
-      unique_lock(unique_lock const&);
-      unique_lock& operator=(unique_lock const&);
-
       mutex_type*      _M_device;
       bool             _M_owns; // XXX use atomic_bool
     };
 
   template<typename _Mutex>
-    void
-    swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y);
+    inline void
+    swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y)
+    { __x.swap(__y); }
 
   template<typename _Mutex>
-    void
-    swap(unique_lock<_Mutex>&& __x, unique_lock<_Mutex>& __y);
+    inline void
+    swap(unique_lock<_Mutex>&& __x, unique_lock<_Mutex>& __y)
+    { __x.swap(__y); }
 
   template<typename _Mutex>
-    void
-    swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>&& __y);
+    inline void
+    swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>&& __y)
+    { __x.swap(__y); }
 
   template<typename _L1, typename _L2, typename ..._L3>
     int
-    try_lock(_L1&, _L2&, _L3&...);
+    try_lock(_L1& __l1, _L2& __l2, _L3&... __l3);
 
   template<typename _L1, typename _L2, typename ..._L3>
     void
@@ -410,30 +615,63 @@ namespace std
     typedef __gthread_once_t __native_type;
 
     once_flag()
-    {
-      __native_type __tmp = __GTHREAD_ONCE_INIT;
-      _M_once = __tmp;
-    }
+    : _M_once(__GTHREAD_ONCE_INIT)
+    { }
+    
+    once_flag(const once_flag&) = delete;
+    once_flag& operator=(const once_flag&) = delete;
 
-    __native_type&
-    _M_get() { return _M_once; }
+    template<typename _Callable, typename... _Args>
+      friend void
+      call_once(once_flag& __once, _Callable __f, _Args&&... __args);
 
   private:
     __native_type  _M_once;
-    once_flag(const once_flag&);
-    once_flag& operator=(const once_flag&);
   };
 
+#ifdef _GLIBCXX_HAVE_TLS
+  extern __thread void* __once_callable;
+  extern __thread void (*__once_call)();
+
+  template<typename _Callable>
+    void __once_call_impl()
+    {
+      (*(_Callable*)__once_callable)();
+    }
+#else
+  extern function<void()> __once_functor;
+  extern unique_lock<mutex> __once_functor_lock;
+#endif
+
+  extern "C" void __once_proxy();
+
   template<typename _Callable, typename... _Args>
     void
     call_once(once_flag& __once, _Callable __f, _Args&&... __args)
     {
-      int __e = __gthread_once(&(__once._M_get()), __f(__args...));
+#ifdef _GLIBCXX_HAVE_TLS
+      auto __bound_functor = bind(__f, __args...);
+      __once_callable = &__bound_functor;
+      __once_call = &__once_call_impl<decltype(__bound_functor)>;
+#else
+      __once_functor_lock.lock();
+      __once_functor = bind(__f, __args...);
+#endif
+     
+      int __e = __gthread_once(&(__once._M_once), &__once_proxy);
+
+#ifndef _GLIBCXX_HAVE_TLS      
+      if (__once_functor_lock)
+       __once_functor_lock.unlock();
+#endif
+
       if (__e)
        __throw_system_error(__e);
     }
 }
 
+#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
+
 #endif // __GXX_EXPERIMENTAL_CXX0X__
 
 #endif // _GLIBCXX_MUTEX
index c3caa59..f1ae33a 100644 (file)
 
 #include <condition_variable>
 
+#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
+
 namespace std
 {
   condition_variable::condition_variable()
   {
-#if __GTHREAD_HAS_COND
-# if defined __GTHREAD_COND_INIT
-    native_handle_type __tmp = __GTHREAD_COND_INIT;
+#ifdef __GTHREAD_COND_INIT
+    __gthread_cond_t __tmp = __GTHREAD_COND_INIT;
     _M_cond = __tmp;
-# else
+#else
     int __e = __gthread_cond_init(&_M_cond, NULL);
-    if ( __e)
+
+    if (__e)
       __throw_system_error(__e);
-# endif
 #endif
   }
 
   condition_variable::~condition_variable()
   {
-#if __GTHREAD_HAS_COND
     // XXX no thread blocked
-    /* int __e = */ pthread_cond_destroy(&_M_cond);
+    /* int __e = */ __gthread_cond_destroy(&_M_cond);
     // if __e == EBUSY then blocked
-#endif
   }
 
+  void
+  condition_variable::wait(unique_lock<mutex>& __lock)
+  {
+    int __e = __gthread_cond_wait(&_M_cond, __lock.mutex()->native_handle());
+
+    if (__e)
+      __throw_system_error(__e);    
+  }
+  
   void 
   condition_variable::notify_one()
   { 
-#if __GTHREAD_HAS_COND
-    int __e = pthread_cond_signal(&_M_cond);
+    lock_guard<mutex> __lock(_M_internal_mutex);
+    int __e = __gthread_cond_signal(&_M_cond);
 
     // XXX not in spec
     // EINVAL
-    if ( __e)
+    if (__e)
       __throw_system_error(__e);
-#endif
   }
 
   void 
   condition_variable::notify_all()
   { 
-#if __GTHREAD_HAS_COND
-    int __e = pthread_cond_broadcast(&_M_cond);
+    lock_guard<mutex> __lock(_M_internal_mutex);
+    int __e = __gthread_cond_broadcast(&_M_cond);
 
     // XXX not in spec
     // EINVAL
-    if ( __e)
+    if (__e)
       __throw_system_error(__e);
-#endif
   }
 
+  condition_variable_any::condition_variable_any()
+  {
+#ifdef __GTHREAD_COND_INIT
+    __gthread_cond_t __tmp = __GTHREAD_COND_INIT;
+    _M_cond = __tmp;
+#else
+    int __e = __gthread_cond_init(&_M_cond, NULL);
+
+    if (__e)
+      __throw_system_error(__e);
+#endif
+  }
+  
+  condition_variable_any::~condition_variable_any()
+  {
+    __gthread_cond_destroy(&_M_cond);
+  } 
 }
 
+#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
index a1c74aa..8fae030 100644 (file)
@@ -29,6 +29,8 @@
 
 #include <mutex>
 
+#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
+
 namespace std
 {
   const defer_lock_t defer_lock = defer_lock_t();
@@ -38,5 +40,29 @@ namespace std
   const char*
   lock_error::what() const throw()
   { return "std::lock_error"; }
+
+#ifdef _GLIBCXX_HAVE_TLS
+  __thread void* __once_callable;
+  __thread void (*__once_call)();
+#else
+  // explicit instantiation due to -fno-implicit-instantiation
+  template class function<void()>;
+  function<void()> __once_functor;
+  mutex __once_mutex;
+  unique_lock<mutex> __once_functor_lock(__once_mutex, defer_lock);
+#endif
+
+  extern "C"
+  {
+    void __once_proxy()
+    {
+#ifndef _GLIBCXX_HAVE_TLS
+      function<void()> __once_call = std::move(__once_functor);
+      __once_functor_lock.unlock();
+#endif
+      __once_call();
+    }
+  }
 }
 
+#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
diff --git a/libstdc++-v3/testsuite/30_threads/call_once/call_once1.cc b/libstdc++-v3/testsuite/30_threads/call_once/call_once1.cc
new file mode 100644 (file)
index 0000000..00e4502
--- /dev/null
@@ -0,0 +1,68 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+std::once_flag value_flag;
+int value = 1;
+
+void add_to_value(int i)
+{
+  value += i;
+}
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  try 
+    {
+      std::call_once(value_flag, add_to_value, 2);
+      std::call_once(value_flag, add_to_value, 2);
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  VERIFY( value == 3 );
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/call_once/once_flag.cc b/libstdc++-v3/testsuite/30_threads/call_once/once_flag.cc
new file mode 100644 (file)
index 0000000..d972c3c
--- /dev/null
@@ -0,0 +1,38 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+
+void test01()
+{
+  std::once_flag once_flag;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable/cons/1.cc b/libstdc++-v3/testsuite/30_threads/condition_variable/cons/1.cc
new file mode 100644 (file)
index 0000000..4ddbd7e
--- /dev/null
@@ -0,0 +1,57 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <condition_variable>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  try 
+    {
+      std::condition_variable c1;
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/condition_variable/cons/assign_neg.cc
new file mode 100644 (file)
index 0000000..331a814
--- /dev/null
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <condition_variable>
+
+void test01()
+{
+  // assign
+  std::condition_variable c1;
+  std::condition_variable c2;
+  c1 = c2;
+}
+
+// { dg-error "used here" "" { target *-*-* } 40 }
+// { dg-error "deleted function" "" { target *-*-* } 60 }
diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/condition_variable/cons/copy_neg.cc
new file mode 100644 (file)
index 0000000..329279f
--- /dev/null
@@ -0,0 +1,43 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <condition_variable>
+
+void test01()
+{
+  // copy
+  std::condition_variable c1;
+  std::condition_variable c2(c1);
+}
+
+// { dg-error "used here" "" { target *-*-* } 39 }
+// { dg-error "deleted function" "" { target *-*-* } 59 }
diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/1.cc b/libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/1.cc
new file mode 100644 (file)
index 0000000..d69ed76
--- /dev/null
@@ -0,0 +1,57 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <condition_variable>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  try 
+    {
+      std::condition_variable_any c1;
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/assign_neg.cc
new file mode 100644 (file)
index 0000000..7cdd252
--- /dev/null
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <condition_variable>
+
+void test01()
+{
+  // assign
+  std::condition_variable_any c1;
+  std::condition_variable_any c2;
+  c1 = c2;
+}
+
+// { dg-error "used here" "" { target *-*-* } 40 }
+// { dg-error "deleted function" "" { target *-*-* } 168 }
diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/copy_neg.cc
new file mode 100644 (file)
index 0000000..d71e955
--- /dev/null
@@ -0,0 +1,43 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <condition_variable>
+
+void test01()
+{
+  // copy
+  std::condition_variable_any c1;
+  std::condition_variable_any c2(c1);
+}
+
+// { dg-error "used here" "" { target *-*-* } 39 }
+// { dg-error "deleted function" "" { target *-*-* } 167 }
index 8c15bb5..7c30499 100644 (file)
@@ -1,5 +1,7 @@
-// { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index 6296f92..c5ef406 100644 (file)
@@ -1,5 +1,7 @@
-// { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" } 
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index 51bee1b..ec95987 100644 (file)
@@ -1,5 +1,8 @@
-// { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" } 
+// { dg-require-gthreads "" }
+
 // 2008-03-14 Benjamin Kosnik <bkoz@redhat.com>
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
index f38ee5d..e4be75e 100644 (file)
@@ -1,5 +1,8 @@
-// { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" } 
+// { dg-require-gthreads "" }
+
 // 2008-03-14 Benjamin Kosnik <bkoz@redhat.com>
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
index 3ed9b6e..1f5f086 100644 (file)
@@ -1,5 +1,9 @@
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
-// { dg-options "-pthread -std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index 8c66bb5..388743d 100644 (file)
@@ -1,5 +1,7 @@
-// { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
@@ -38,5 +40,6 @@ void test01()
   mutex_type m2;
   m1 = m2;
 }
-// { dg-error "within this context" "" { target *-*-* } 39 } 
-// { dg-error "is private" "" { target *-*-* } 108 } 
+
+// { dg-error "used here" "" { target *-*-* } 41 }
+// { dg-error "deleted function" "" { target *-*-* } 76 }
index 666506a..37daed3 100644 (file)
@@ -1,5 +1,7 @@
-// { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
@@ -37,5 +39,6 @@ void test01()
   mutex_type m1;
   mutex_type m2(m1);
 }
-// { dg-error "within this context" "" { target *-*-* } 38 } 
-// { dg-error "is private" "" { target *-*-* } 107 } 
+
+// { dg-error "used here" "" { target *-*-* } 40 }
+// { dg-error "deleted function" "" { target *-*-* } 75 }
index 3fe33b2..76a585c 100644 (file)
@@ -1,5 +1,9 @@
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
-// { dg-options "-pthread -std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index c63c606..3b22953 100644 (file)
@@ -1,5 +1,9 @@
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
-// { dg-options "-pthread -std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index d4cd9f7..97eadb5 100644 (file)
@@ -1,5 +1,9 @@
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
-// { dg-options "-pthread -std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
@@ -41,6 +45,7 @@ int main()
     {
       mutex_type m;
       mutex_type::native_handle_type n = m.native_handle();
+      (void)n;
     }
   catch (const std::system_error& e)
     {
index 2255399..358e8f3 100644 (file)
@@ -1,5 +1,7 @@
-// { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 // 2008-03-18 Benjamin Kosnik <bkoz@redhat.com>
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
index b7380d6..d67e356 100644 (file)
@@ -1,5 +1,9 @@
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
-// { dg-options "-pthread -std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index 7c7845e..e5d43cd 100644 (file)
@@ -1,5 +1,9 @@
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
-// { dg-options "-pthread -std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index 4c845fa..695b69b 100644 (file)
@@ -1,5 +1,9 @@
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
-// { dg-options "-pthread -std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index 1125ea6..f322eda 100644 (file)
@@ -1,5 +1,9 @@
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
-// { dg-options "-pthread -std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index b7e2784..1ca7f1c 100644 (file)
@@ -1,5 +1,7 @@
-// { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
@@ -38,5 +40,6 @@ void test01()
   mutex_type m2;
   m1 = m2;
 }
-// { dg-error "within this context" "" { target *-*-* } 39 } 
-// { dg-error "is private" "" { target *-*-* } 160 } 
+
+// { dg-error "used here" "" { target *-*-* } 41 } 
+// { dg-error "deleted function" "" { target *-*-* } 128 }
index 2d20cb9..d732245 100644 (file)
@@ -1,5 +1,7 @@
-// { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
@@ -37,5 +39,6 @@ void test01()
   mutex_type m1;
   mutex_type m2(m1);
 }
-// { dg-error "within this context" "" { target *-*-* } 38 } 
-// { dg-error "is private" "" { target *-*-* } 159 } 
+
+// { dg-error "used here" "" { target *-*-* } 40 } 
+// { dg-error "deleted function" "" { target *-*-* } 127 }
index 464d1a8..ac22512 100644 (file)
@@ -1,5 +1,9 @@
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
-// { dg-options "-pthread -std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
index fb3be90..ba495ff 100644 (file)
@@ -1,5 +1,9 @@
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
-// { dg-options "-pthread -std=gnu++0x" }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
 //
@@ -41,6 +45,7 @@ int main()
     {
       mutex_type m;
       mutex_type::native_handle_type n = m.native_handle();
+      (void)n;
     }
   catch (const std::system_error& e)
     {
index 6b7c3cf..81ce7c3 100644 (file)
@@ -1,5 +1,8 @@
-// { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
 // 2008-03-18 Benjamin Kosnik <bkoz@redhat.com>
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/1.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/1.cc
new file mode 100644 (file)
index 0000000..20f7f07
--- /dev/null
@@ -0,0 +1,58 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::recursive_timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m1;
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/assign_neg.cc
new file mode 100644 (file)
index 0000000..2832093
--- /dev/null
@@ -0,0 +1,45 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+
+void test01()
+{
+  // assign
+  typedef std::recursive_timed_mutex mutex_type;
+  mutex_type m1;
+  mutex_type m2;
+  m1 = m2;
+}
+
+// { dg-error "used here" "" { target *-*-* } 41 } 
+// { dg-error "deleted function" "" { target *-*-* } 282 }
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/copy_neg.cc
new file mode 100644 (file)
index 0000000..95eda1f
--- /dev/null
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+
+void test01()
+{
+  // assign
+  typedef std::recursive_timed_mutex mutex_type;
+  mutex_type m1;
+  mutex_type m2(m1);
+}
+
+// { dg-error "used here" "" { target *-*-* } 40 } 
+// { dg-error "deleted function" "" { target *-*-* } 281 }
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/dest/destructor_locked.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/dest/destructor_locked.cc
new file mode 100644 (file)
index 0000000..df9588c
--- /dev/null
@@ -0,0 +1,60 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::recursive_timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m;
+      m.lock();
+    }
+  catch (const std::system_error& e)
+    {
+      // Destroying locked mutex raises system error, or undefined.
+      // POSIX == may fail with EBUSY.
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/lock/1.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/lock/1.cc
new file mode 100644 (file)
index 0000000..0599797
--- /dev/null
@@ -0,0 +1,72 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::recursive_timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m;
+      m.lock();
+
+      // Lock already locked mutex.
+      try
+       {
+         // XXX Will block.
+         // m.lock();
+       }
+      catch (const std::system_error& e)
+       {
+         VERIFY( false );
+       }
+
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/lock/2.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/lock/2.cc
new file mode 100644 (file)
index 0000000..3111493
--- /dev/null
@@ -0,0 +1,72 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::recursive_timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m;
+      m.lock();
+
+      // Lock already locked mutex.
+      try
+       {
+         // XXX Will not block.
+         // m.lock();
+       }
+      catch (const std::system_error& e)
+       {
+         VERIFY( false );
+       }
+
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/1.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/1.cc
new file mode 100644 (file)
index 0000000..39c67ef
--- /dev/null
@@ -0,0 +1,60 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::recursive_timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m;
+      mutex_type::native_handle_type n = m.native_handle();
+      (void)n;
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/requirements/typedefs.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/requirements/typedefs.cc
new file mode 100644 (file)
index 0000000..fd323fe
--- /dev/null
@@ -0,0 +1,42 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// 2008-03-18 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+
+void test01()
+{
+  // Check for required typedefs
+  typedef std::recursive_timed_mutex test_type;
+  typedef test_type::native_handle_type type;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock/1.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock/1.cc
new file mode 100644 (file)
index 0000000..9653648
--- /dev/null
@@ -0,0 +1,61 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::recursive_timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m;
+      bool b = m.try_lock();
+      VERIFY( b );
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock/2.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock/2.cc
new file mode 100644 (file)
index 0000000..36ca9c0
--- /dev/null
@@ -0,0 +1,73 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options "-std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options "-std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options "-std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::recursive_timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m;
+      m.lock();
+      bool b;
+
+      try
+       {
+         b = m.try_lock();
+         VERIFY( b );
+       }
+      catch (const std::system_error& e)
+       {
+         VERIFY( false );
+       }
+
+      m.unlock();
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/1.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/1.cc
new file mode 100644 (file)
index 0000000..3f278a6
--- /dev/null
@@ -0,0 +1,62 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <chrono>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::recursive_timed_mutex mutex_type;
+  
+  try 
+    {
+      mutex_type m;
+      bool b = m.try_lock_for(std::chrono::seconds(1));
+      VERIFY( b );
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/2.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/2.cc
new file mode 100644 (file)
index 0000000..f93a8b6
--- /dev/null
@@ -0,0 +1,63 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <chrono>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::recursive_timed_mutex mutex_type;
+  typedef std::chrono::duration<int64_t, std::pico> picoseconds;
+
+  try 
+    {
+      mutex_type m;
+      bool b = m.try_lock_for(picoseconds(1));
+      VERIFY( b );
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/3.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/3.cc
new file mode 100644 (file)
index 0000000..530a084
--- /dev/null
@@ -0,0 +1,79 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::recursive_timed_mutex mutex_type;
+
+  std::chrono::seconds s(1);
+  
+  try 
+    {
+      mutex_type m;
+      m.lock();
+      bool b;
+
+      try
+       {
+         b = m.try_lock_for(s);
+         VERIFY( b );
+         m.unlock();
+       }
+      catch (const std::system_error& e)
+       {
+         VERIFY( false );
+       }
+      catch(...)
+       {
+         VERIFY( false );
+       }
+
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/1.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/1.cc
new file mode 100644 (file)
index 0000000..9653648
--- /dev/null
@@ -0,0 +1,61 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::recursive_timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m;
+      bool b = m.try_lock();
+      VERIFY( b );
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/2.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/2.cc
new file mode 100644 (file)
index 0000000..d3eda2f
--- /dev/null
@@ -0,0 +1,72 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::recursive_timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m;
+      m.lock();
+      bool b;
+
+      try
+       {
+         b = m.try_lock();
+         VERIFY( b );
+       }
+      catch (const std::system_error& e)
+       {
+         VERIFY( false );
+       }
+
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/unlock/1.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/unlock/1.cc
new file mode 100644 (file)
index 0000000..c713685
--- /dev/null
@@ -0,0 +1,61 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::recursive_timed_mutex mutex_type;
+
+  try 
+    {
+      // Unlock mutex that hasn't been locked.
+      mutex_type m;
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      // POSIX == EPERM
+      VERIFY( true );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/cons/1.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/cons/1.cc
new file mode 100644 (file)
index 0000000..4d36b83
--- /dev/null
@@ -0,0 +1,58 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m1;
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/cons/assign_neg.cc
new file mode 100644 (file)
index 0000000..719ef0c
--- /dev/null
@@ -0,0 +1,45 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+
+void test01()
+{
+  // assign
+  typedef std::timed_mutex mutex_type;
+  mutex_type m1;
+  mutex_type m2;
+  m1 = m2;
+}
+
+// { dg-error "used here" "" { target *-*-* } 41 } 
+// { dg-error "deleted function" "" { target *-*-* } 179 }
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/cons/copy_neg.cc
new file mode 100644 (file)
index 0000000..20f309e
--- /dev/null
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+
+void test01()
+{
+  // assign
+  typedef std::timed_mutex mutex_type;
+  mutex_type m1;
+  mutex_type m2(m1);
+}
+
+// { dg-error "used here" "" { target *-*-* } 40 } 
+// { dg-error "deleted function" "" { target *-*-* } 178 }
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/dest/destructor_locked.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/dest/destructor_locked.cc
new file mode 100644 (file)
index 0000000..9f78c63
--- /dev/null
@@ -0,0 +1,60 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m;
+      m.lock();
+    }
+  catch (const std::system_error& e)
+    {
+      // Destroying locked mutex raises system error, or undefined.
+      // POSIX == may fail with EBUSY.
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/lock/1.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/lock/1.cc
new file mode 100644 (file)
index 0000000..c94760d
--- /dev/null
@@ -0,0 +1,72 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m;
+      m.lock();
+
+      // Lock already locked mutex.
+      try
+       {
+         // XXX Will block.
+         // m.lock();
+       }
+      catch (const std::system_error& e)
+       {
+         VERIFY( false );
+       }
+
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/1.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/1.cc
new file mode 100644 (file)
index 0000000..34db1e9
--- /dev/null
@@ -0,0 +1,60 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m;
+      mutex_type::native_handle_type n = m.native_handle();
+      (void)n;
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/requirements/typedefs.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/requirements/typedefs.cc
new file mode 100644 (file)
index 0000000..2447c95
--- /dev/null
@@ -0,0 +1,42 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// 2008-07-23 Chris Fairles <chris.fairles@gmail.com>
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+
+void test01()
+{
+  // Check for required typedefs
+  typedef std::timed_mutex test_type;
+  typedef test_type::native_handle_type type;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock/1.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock/1.cc
new file mode 100644 (file)
index 0000000..2823c37
--- /dev/null
@@ -0,0 +1,61 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m;
+      bool b = m.try_lock();
+      VERIFY( b );
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock/2.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock/2.cc
new file mode 100644 (file)
index 0000000..4c26467
--- /dev/null
@@ -0,0 +1,72 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m;
+      m.lock();
+      bool b;
+
+      try
+       {
+         b = m.try_lock();
+         VERIFY( !b );
+       }
+      catch (const std::system_error& e)
+       {
+         VERIFY( false );
+       }
+
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/1.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/1.cc
new file mode 100644 (file)
index 0000000..9d761b9
--- /dev/null
@@ -0,0 +1,62 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <chrono>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::timed_mutex mutex_type;
+  
+  try 
+    {
+      mutex_type m;
+      bool b = m.try_lock_for(std::chrono::seconds(1));
+      VERIFY( b );
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/2.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/2.cc
new file mode 100644 (file)
index 0000000..6463281
--- /dev/null
@@ -0,0 +1,63 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <chrono>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::timed_mutex mutex_type;
+  typedef std::chrono::duration<int64_t, std::pico> picoseconds;
+
+  try 
+    {
+      mutex_type m;
+      bool b = m.try_lock_for(picoseconds(1));
+      VERIFY( b );
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/3.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/3.cc
new file mode 100644 (file)
index 0000000..eeb330d
--- /dev/null
@@ -0,0 +1,74 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::timed_mutex mutex_type;
+
+  std::chrono::seconds s(1);
+  
+  try 
+    {
+      mutex_type m;
+      m.lock();
+      bool b;
+
+      try
+       {
+         b = m.try_lock_for(s);
+         VERIFY( !b );
+       }
+      catch (const std::system_error& e)
+       {
+         VERIFY( false );
+       }
+
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/1.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/1.cc
new file mode 100644 (file)
index 0000000..2823c37
--- /dev/null
@@ -0,0 +1,61 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m;
+      bool b = m.try_lock();
+      VERIFY( b );
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/2.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/2.cc
new file mode 100644 (file)
index 0000000..4c26467
--- /dev/null
@@ -0,0 +1,72 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::timed_mutex mutex_type;
+
+  try 
+    {
+      mutex_type m;
+      m.lock();
+      bool b;
+
+      try
+       {
+         b = m.try_lock();
+         VERIFY( !b );
+       }
+      catch (const std::system_error& e)
+       {
+         VERIFY( false );
+       }
+
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/unlock/1.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/unlock/1.cc
new file mode 100644 (file)
index 0000000..7c118bf
--- /dev/null
@@ -0,0 +1,61 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <mutex>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  typedef std::timed_mutex mutex_type;
+
+  try 
+    {
+      // Unlock mutex that hasn't been locked.
+      mutex_type m;
+      m.unlock();
+    }
+  catch (const std::system_error& e)
+    {
+      // POSIX == EPERM
+      VERIFY( true );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
index 594d829..5e92729 100644 (file)
@@ -1,5 +1,8 @@
-// { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
 // 2008-03-14 Benjamin Kosnik <bkoz@redhat.com>
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
index 5933afe..a493987 100644 (file)
@@ -1,5 +1,8 @@
-// { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
 // 2008-03-14 Benjamin Kosnik <bkoz@redhat.com>
 
 // Copyright (C) 2008 Free Software Foundation, Inc.
index 44dea80..927aa47 100644 (file)
@@ -106,3 +106,12 @@ proc dg-require-atomic-builtins { args } {
     }
     return
 }
+
+proc dg-require-gthreads { args } {
+    if { ![ check_v3_target_gthreads ] } {
+        upvar dg-do-what dg-do-what
+        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+        return
+    }
+    return
+}
index 45b6fb2..23060b4 100644 (file)
@@ -1091,7 +1091,7 @@ proc check_v3_target_atomic_builtins { } {
        set et_atomic_builtins 0
 
        # Set up and compile a C++0x test program that depends
-       # on the C99 stdint facilities to be available.
+       # on the atomic builtin facilities to be available.
        set src atomic_builtins[pid].cc
        set exe atomic_builtins[pid].exe
 
@@ -1120,3 +1120,61 @@ proc check_v3_target_atomic_builtins { } {
     verbose "check_v3_target_atomic_builtins: $et_atomic_builtins" 2
     return $et_atomic_builtins
 }
+
+proc check_v3_target_gthreads { } {
+    global cxxflags
+    global DEFAULT_CXXFLAGS
+    global et_gthreads
+
+    global tool
+
+    if { ![info exists et_gthreads_target_name] } {
+        set et_gthreads_target_name ""
+    }
+
+    # If the target has changed since we set the cached value, clear it.
+    set current_target [current_target_name]
+    if { $current_target != $et_gthreads_target_name } {
+        verbose "check_v3_target_gthreads: `$et_gthreads_target_name'" 2
+        set et_gthreads_target_name $current_target
+        if [info exists et_gthreads] {
+            verbose "check_v3_target_gthreads: removing cached result" 2
+            unset et_gthreads
+        }
+    }
+
+    if [info exists et_gthreads] {
+        verbose "check_v3_target_gthreads: using cached result" 2
+    } else {
+        set et_gthreads 0
+
+        # Set up and compile a C++0x test program that depends
+        # on the gthreads facilities to be available.
+        set src gthreads[pid].cc
+        set exe gthreads[pid].exe
+
+        set f [open $src "w"]
+       puts $f "#include <bits/c++config.h>"
+        puts $f "int main()"
+        puts $f "#ifdef _GLIBCXX_HAS_GTHREADS"
+        puts $f "{ return 0; }"
+        puts $f "#endif"
+        close $f
+
+        set cxxflags_saved $cxxflags
+        set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
+
+        set lines [v3_target_compile $src $exe executable ""]
+        set cxxflags $cxxflags_saved
+        file delete $src
+
+        if [string match "" $lines] {
+            # No error message, compilation succeeded.
+            set et_gthreads 1
+        } else {
+            verbose "check_v3_target_gthreads: compilation failed" 2
+        }
+    }
+    verbose "check_v3_target_gthreads: $et_gthreads" 2
+    return $et_gthreads
+}