summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2009-02-13 00:14:42 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2009-02-13 00:14:42 +0000
commit2db33624f391c82b513ef3e94d9d38ad0c629d0d (patch)
treede53cbcabda834eb408ab487451764762c75ad0a /libstdc++-v3/testsuite
parenteaf91eaf8fe31a8ec953f80e27bada7b2aee313b (diff)
downloadgcc-2db33624f391c82b513ef3e94d9d38ad0c629d0d.tar.gz
2009-02-12 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/util/thread/all.h (compare_type_to_native_type_sizes): To... (compare_type_to_native_type): ...this, add alignment check. * testsuite/30_threads/condition_variable_any/native_handle/ typesizes.cc: Modify as above. * testsuite/30_threads/mutex/native_handle/typesizes.cc: Same. * testsuite/30_threads/timed_mutex/native_handle/typesizes.cc: Same. * testsuite/30_threads/thread/native_handle/typesizes.cc: Same. * testsuite/30_threads/recursive_mutex/native_handle/typesizes.cc: Same. * testsuite/30_threads/condition_variable/native_handle/ typesizes.cc: Same. * testsuite/30_threads/recursive_timed_mutex/native_handle/ typesizes.cc: Same. * testsuite/30_threads/thread/cons/1.cc: Add comments. * testsuite/30_threads/thread/cons/2.cc: Same. * testsuite/30_threads/thread/cons/3.cc: Same. * testsuite/30_threads/thread/cons/4.cc: Same. * testsuite/30_threads/thread/cons/5.cc: Same. * testsuite/30_threads/thread/cons/6.cc: Same. * testsuite/30_threads/thread/cons/7.cc: Same. * testsuite/30_threads/thread/cons/8.cc: Same. * testsuite/30_threads/thread/cons/9.cc: New. * testsuite/30_threads/thread/cons/moveable.cc: New. * src/condition_variable.cc: Clean up whitespace. * include/std/condition_variable: Same. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144142 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/30_threads/condition_variable/native_handle/typesizes.cc2
-rw-r--r--libstdc++-v3/testsuite/30_threads/condition_variable_any/native_handle/typesizes.cc2
-rw-r--r--libstdc++-v3/testsuite/30_threads/mutex/native_handle/typesizes.cc2
-rw-r--r--libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/typesizes.cc2
-rw-r--r--libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/typesizes.cc2
-rw-r--r--libstdc++-v3/testsuite/30_threads/thread/cons/1.cc3
-rw-r--r--libstdc++-v3/testsuite/30_threads/thread/cons/2.cc24
-rw-r--r--libstdc++-v3/testsuite/30_threads/thread/cons/3.cc9
-rw-r--r--libstdc++-v3/testsuite/30_threads/thread/cons/4.cc11
-rw-r--r--libstdc++-v3/testsuite/30_threads/thread/cons/5.cc3
-rw-r--r--libstdc++-v3/testsuite/30_threads/thread/cons/6.cc4
-rw-r--r--libstdc++-v3/testsuite/30_threads/thread/cons/7.cc5
-rw-r--r--libstdc++-v3/testsuite/30_threads/thread/cons/8.cc5
-rw-r--r--libstdc++-v3/testsuite/30_threads/thread/native_handle/typesizes.cc4
-rw-r--r--libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/typesizes.cc2
-rw-r--r--libstdc++-v3/testsuite/util/thread/all.h19
16 files changed, 64 insertions, 35 deletions
diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable/native_handle/typesizes.cc b/libstdc++-v3/testsuite/30_threads/condition_variable/native_handle/typesizes.cc
index 2dbaccc3c45..93968798b67 100644
--- a/libstdc++-v3/testsuite/30_threads/condition_variable/native_handle/typesizes.cc
+++ b/libstdc++-v3/testsuite/30_threads/condition_variable/native_handle/typesizes.cc
@@ -29,6 +29,6 @@
int main()
{
typedef std::condition_variable test_type;
- __gnu_test::compare_type_to_native_type_sizes<test_type>();
+ __gnu_test::compare_type_to_native_type<test_type>();
return 0;
}
diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable_any/native_handle/typesizes.cc b/libstdc++-v3/testsuite/30_threads/condition_variable_any/native_handle/typesizes.cc
index 9d388963b9b..2544291ab13 100644
--- a/libstdc++-v3/testsuite/30_threads/condition_variable_any/native_handle/typesizes.cc
+++ b/libstdc++-v3/testsuite/30_threads/condition_variable_any/native_handle/typesizes.cc
@@ -29,6 +29,6 @@
int main()
{
typedef std::condition_variable_any test_type;
- __gnu_test::compare_type_to_native_type_sizes<test_type>();
+ __gnu_test::compare_type_to_native_type<test_type>();
return 0;
}
diff --git a/libstdc++-v3/testsuite/30_threads/mutex/native_handle/typesizes.cc b/libstdc++-v3/testsuite/30_threads/mutex/native_handle/typesizes.cc
index b293008b975..cda0816cfbe 100644
--- a/libstdc++-v3/testsuite/30_threads/mutex/native_handle/typesizes.cc
+++ b/libstdc++-v3/testsuite/30_threads/mutex/native_handle/typesizes.cc
@@ -29,6 +29,6 @@
int main()
{
typedef std::mutex test_type;
- __gnu_test::compare_type_to_native_type_sizes<test_type>();
+ __gnu_test::compare_type_to_native_type<test_type>();
return 0;
}
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/typesizes.cc b/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/typesizes.cc
index 6d58c1ef90e..8ee1f3895c1 100644
--- a/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/typesizes.cc
+++ b/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/typesizes.cc
@@ -29,6 +29,6 @@
int main()
{
typedef std::recursive_mutex test_type;
- __gnu_test::compare_type_to_native_type_sizes<test_type>();
+ __gnu_test::compare_type_to_native_type<test_type>();
return 0;
}
diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/typesizes.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/typesizes.cc
index b51bdf27a1b..be9dc53e83f 100644
--- a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/typesizes.cc
+++ b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/typesizes.cc
@@ -29,6 +29,6 @@
int main()
{
typedef std::recursive_timed_mutex test_type;
- __gnu_test::compare_type_to_native_type_sizes<test_type>();
+ __gnu_test::compare_type_to_native_type<test_type>();
return 0;
}
diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/1.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/1.cc
index a631e7eabf8..9f5d83fb2c7 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/cons/1.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/cons/1.cc
@@ -36,6 +36,9 @@
#include <system_error>
#include <testsuite_hooks.h>
+// thread default cons works
+// thread default cons no throw
+// thread default cons not joinable
int main()
{
bool test __attribute__((unused)) = true;
diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/2.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/2.cc
index e53b088449a..aeccf79cdb6 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/cons/2.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/cons/2.cc
@@ -32,7 +32,7 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-#include <utility> // std::ref
+#include <functional> // std::ref
#include <thread>
#include <system_error>
#include <testsuite_hooks.h>
@@ -43,19 +43,27 @@ free_function(std::thread::id& id)
id = std::this_thread::get_id();
}
+// thread::id default cons
+// thread::id copy ctor
+// thread variadic cons, c++ function
+// thread variadic cons joinable
+// thread join
+// thread join postcondition not joinable
+// thread join postcondition function called correctly
+// this_thread::get_id
void test02()
{
bool test __attribute__((unused)) = true;
try
{
- std::thread::id t1_id1;
- std::thread t1(free_function, std::ref(t1_id1));
- std::thread::id t1_id2 = t1.get_id();
- VERIFY( t1.joinable() );
- t1.join();
- VERIFY( !t1.joinable() );
- VERIFY( t1_id1 == t1_id2 );
+ std::thread::id id1;
+ std::thread t(free_function, std::ref(id1));
+ std::thread::id id2 = t.get_id();
+ VERIFY( t.joinable() );
+ t.join();
+ VERIFY( !t.joinable() );
+ VERIFY( id1 == id2 );
}
catch (const std::system_error&)
{
diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/3.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/3.cc
index 3df7ad050b9..54526c60346 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/cons/3.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/cons/3.cc
@@ -5,7 +5,7 @@
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
-// Copyright (C) 2008 Free Software Foundation, Inc.
+// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -32,8 +32,7 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-#include <functional> // std::unary_function
-#include <utility> // std::ref
+#include <functional> // std::unary_function, std::ref
#include <thread>
#include <system_error>
#include <testsuite_hooks.h>
@@ -55,6 +54,10 @@ struct copyable : public std::unary_function<std::thread::id&, void>
int copyable::copy_count = 0;
+// same as 2, but function is copyable function object
+// thread variadic cons not copied when std::ref
+// thread variadic cons copied when not std::ref
+// no errors
void test03()
{
bool test __attribute__((unused)) = true;
diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/4.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/4.cc
index 76fc9ec3e45..5fdc8c01598 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/cons/4.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/cons/4.cc
@@ -5,7 +5,7 @@
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
-// Copyright (C) 2008 Free Software Foundation, Inc.
+// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -32,8 +32,7 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-#include <functional> // std::unary_function
-#include <utility> // std::ref, std::cref
+#include <functional> // std::unary_function, std::ref, std::cref
#include <thread>
#include <system_error>
#include <testsuite_hooks.h>
@@ -50,6 +49,12 @@ struct noncopyable : std::unary_function<std::thread::id&, void>
}
};
+// same as 3, but function is noncopyable function object
+// thread variadic cons not copied when std::ref
+// thread variadic cons copied when not std::ref
+// thread variadic cons not copied when std::cref
+// thread variadic cons copied when not std::cref
+// no errors
void test03()
{
bool test __attribute__((unused)) = true;
diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/5.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/5.cc
index 35ea25abeb1..6250c197f5f 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/cons/5.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/cons/5.cc
@@ -32,8 +32,7 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-#include <functional> // std::unary_function
-#include <utility> // std::ref
+#include <functional> // std::unary_function, std::ref
#include <thread>
#include <system_error>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/6.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/6.cc
index 0a6d7470fa9..367d0f603f1 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/cons/6.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/cons/6.cc
@@ -43,6 +43,10 @@ void f()
f_was_called = true;
}
+// thread non-variadic cons, c++ function
+// thread join
+// thread join postcondition function called correctly
+// no errors
void test06()
{
bool test __attribute__((unused)) = true;
diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/7.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/7.cc
index fafa72ac277..62690de60b2 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/cons/7.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/cons/7.cc
@@ -51,6 +51,7 @@ struct copyable
}
};
+// same as 6, but function is copyable function object passed by reference
void test07()
{
bool test __attribute__((unused)) = true;
@@ -59,8 +60,8 @@ void test07()
{
copyable c;
copyable& rc = c;
- std::thread t1(rc);
- t1.join();
+ std::thread t(rc);
+ t.join();
VERIFY( functor_was_called );
}
catch (const std::system_error&)
diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/8.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/8.cc
index 8c6b2e1f921..de8fb873d6c 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/cons/8.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/cons/8.cc
@@ -52,6 +52,7 @@ struct moveable
}
};
+// same as 6, but function object is movable
void test08()
{
bool test __attribute__((unused)) = true;
@@ -59,8 +60,8 @@ void test08()
try
{
moveable m;
- std::thread t1(std::move(m));
- t1.join();
+ std::thread t(std::move(m));
+ t.join();
VERIFY( functor_was_called );
}
catch (const std::system_error&)
diff --git a/libstdc++-v3/testsuite/30_threads/thread/native_handle/typesizes.cc b/libstdc++-v3/testsuite/30_threads/thread/native_handle/typesizes.cc
index b1103d95f22..2af81fb47cf 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/native_handle/typesizes.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/native_handle/typesizes.cc
@@ -29,7 +29,7 @@
int main()
{
typedef std::thread test_type;
- // XXX disable at the moment
- //__gnu_test::compare_type_to_native_type_sizes<test_type>();
+ // XX disable for now
+ //__gnu_test::compare_type_to_native_type<test_type>();
return 0;
}
diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/typesizes.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/typesizes.cc
index 7a59d7da30f..e9debe55e00 100644
--- a/libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/typesizes.cc
+++ b/libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/typesizes.cc
@@ -29,6 +29,6 @@
int main()
{
typedef std::timed_mutex test_type;
- __gnu_test::compare_type_to_native_type_sizes<test_type>();
+ __gnu_test::compare_type_to_native_type<test_type>();
return 0;
}
diff --git a/libstdc++-v3/testsuite/util/thread/all.h b/libstdc++-v3/testsuite/util/thread/all.h
index 39dea5ff606..40002725a9f 100644
--- a/libstdc++-v3/testsuite/util/thread/all.h
+++ b/libstdc++-v3/testsuite/util/thread/all.h
@@ -39,24 +39,29 @@
namespace __gnu_test
{
// Assume _Tp::native_handle_type.
+ // Check C++ to native_handle_type characteristics: size and alignment.
template<typename _Tp>
void
- compare_type_to_native_type_sizes()
+ compare_type_to_native_type()
{
typedef _Tp test_type;
- typedef typename test_type::native_handle_type native_handle_type;
-
- int st = sizeof(test_type);
// Remove possible pointer type.
- int snt = sizeof(typename std::remove_pointer<native_handle_type>::type);
-
- if (st != snt)
+ typedef typename test_type::native_handle_type native_handle;
+ typedef typename std::remove_pointer<native_handle>::type native_type;
+
+ int st = sizeof(test_type);
+ int snt = sizeof(native_type);
+ int at = __alignof__(test_type);
+ int ant = __alignof__(native_type);
+ if (st != snt || at != ant)
{
std::ostringstream s;
s << std::endl;
s << "size of _Tp: " << st << std::endl;
+ s << "alignment of _Tp: " << st << std::endl;
s << "size of *(_Tp::native_handle_type): " << snt << std::endl;
+ s << "alignment of *(_Tp::native_handle_type): " << snt << std::endl;
throw std::runtime_error(s.str());
}
}