diff options
author | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2008-05-06 21:11:47 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2008-05-06 21:11:47 +0000 |
commit | 68a97d242cbeacf50a83122b0b7aa32c86cebdc0 (patch) | |
tree | cd392e25499481feab8d9adb71f2fb0e3a793cbe /libstdc++-v3 | |
parent | 006601890b953c9177624f9f533b997f344802ad (diff) | |
download | gcc-68a97d242cbeacf50a83122b0b7aa32c86cebdc0.zip gcc-68a97d242cbeacf50a83122b0b7aa32c86cebdc0.tar.gz gcc-68a97d242cbeacf50a83122b0b7aa32c86cebdc0.tar.bz2 |
condition_variable: New.
2008-05-06 Benjamin Kosnik <bkoz@redhat.com>
* include/std/condition_variable: New.
* include/std/mutex: New.
* src/condition_variable.cc: New.
* src/mutex.cc: New.
* include/bits/functexcept.h: Add __throw_system_error varients.
* src/functexcept.cc: Same.
* config/abi/pre/gnu.ver: Add exports.
* doc/xml/manual/using.xml: Add new includes.
* doc/doxygen/user.cfg.in: Doxygen support.
* doc/doxygen/doxygroups.cc: Same.
* include/Makefile.am: Add mutex, condition_variable.
* include/Makefile.in: Regenerated.
* src/Makefile.am: Add mutex.cc, condition_variable.cc.
* src/Makefile.in: Regenerated.
* testsuite/30_threads: New.
* testsuite/30_threads/lock_error: New.
* testsuite/30_threads/mutex: New.
* testsuite/30_threads/mutex/dest: New.
* testsuite/30_threads/mutex/dest/destructor_locked.cc: New.
* testsuite/30_threads/mutex/native_handle: New.
* testsuite/30_threads/mutex/native_handle/1.cc: New.
* testsuite/30_threads/mutex/cons: New.
* testsuite/30_threads/mutex/cons/assign_neg.cc: New.
* testsuite/30_threads/mutex/cons/1.cc: New.
* testsuite/30_threads/mutex/cons/copy_neg.cc: New.
* testsuite/30_threads/mutex/requirements: New.
* testsuite/30_threads/mutex/requirements/typedefs.cc: New.
* testsuite/30_threads/mutex/try_lock: New.
* testsuite/30_threads/mutex/try_lock/1.cc: New.
* testsuite/30_threads/mutex/try_lock/2.cc: New.
* testsuite/30_threads/mutex/lock: New.
* testsuite/30_threads/mutex/lock/1.cc: New.
* testsuite/30_threads/mutex/unlock: New.
* testsuite/30_threads/mutex/unlock/1.cc: New.
* testsuite/30_threads/recursive_mutex: New.
* testsuite/30_threads/recursive_mutex/dest: New.
* testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc: New.
* testsuite/30_threads/recursive_mutex/native_handle: New.
* testsuite/30_threads/recursive_mutex/native_handle/1.cc: New.
* testsuite/30_threads/recursive_mutex/cons: New.
* testsuite/30_threads/recursive_mutex/cons/assign_neg.cc: New.
* testsuite/30_threads/recursive_mutex/cons/1.cc: New.
* testsuite/30_threads/recursive_mutex/cons/copy_neg.cc: New.
* testsuite/30_threads/recursive_mutex/requirements: New.
* testsuite/30_threads/recursive_mutex/requirements/typedefs.cc: New.
* testsuite/30_threads/lock_guard: New.
* testsuite/30_threads/lock_guard/requirements: New.
* testsuite/30_threads/lock_guard/requirements/typedefs.cc: New.
* testsuite/30_threads/lock_guard/requirements/
explicit_instantiation.cc: New.
* testsuite/30_threads/headers: New.
* testsuite/30_threads/headers/mutex: New.
* testsuite/30_threads/headers/mutex/types_std_c++0x.cc: New.
* testsuite/30_threads/headers/mutex/std_c++0x_neg.cc: New.
* testsuite/30_threads/headers/condition_variable: New.
* testsuite/30_threads/headers/condition_variable/
types_std_c++0x.cc: New.
* testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc: New.
* testsuite/30_threads/once_flag: New.
* testsuite/30_threads/unique_lock: New.
* testsuite/30_threads/unique_lock/requirements: New.
* testsuite/30_threads/unique_lock/requirements/typedefs.cc: New.
* testsuite/30_threads/unique_lock/requirements/
explicit_instantiation.cc: New.
* testsuite/17_intro/headers/c++200x/all.cc: Add new includes.
From-SVN: r135007
Diffstat (limited to 'libstdc++-v3')
40 files changed, 2010 insertions, 72 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f50f917..456be98 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,21 +1,92 @@ 2008-05-06 Benjamin Kosnik <bkoz@redhat.com> + * include/std/condition_variable: New. + * include/std/mutex: New. + * src/condition_variable.cc: New. + * src/mutex.cc: New. + * include/bits/functexcept.h: Add __throw_system_error varients. + * src/functexcept.cc: Same. + * config/abi/pre/gnu.ver: Add exports. + + * doc/xml/manual/using.xml: Add new includes. + * doc/doxygen/user.cfg.in: Doxygen support. + * doc/doxygen/doxygroups.cc: Same. + + * include/Makefile.am: Add mutex, condition_variable. + * include/Makefile.in: Regenerated. + * src/Makefile.am: Add mutex.cc, condition_variable.cc. + * src/Makefile.in: Regenerated. + + * testsuite/30_threads: New. + * testsuite/30_threads/lock_error: New. + * testsuite/30_threads/mutex: New. + * testsuite/30_threads/mutex/dest: New. + * testsuite/30_threads/mutex/dest/destructor_locked.cc: New. + * testsuite/30_threads/mutex/native_handle: New. + * testsuite/30_threads/mutex/native_handle/1.cc: New. + * testsuite/30_threads/mutex/cons: New. + * testsuite/30_threads/mutex/cons/assign_neg.cc: New. + * testsuite/30_threads/mutex/cons/1.cc: New. + * testsuite/30_threads/mutex/cons/copy_neg.cc: New. + * testsuite/30_threads/mutex/requirements: New. + * testsuite/30_threads/mutex/requirements/typedefs.cc: New. + * testsuite/30_threads/mutex/try_lock: New. + * testsuite/30_threads/mutex/try_lock/1.cc: New. + * testsuite/30_threads/mutex/try_lock/2.cc: New. + * testsuite/30_threads/mutex/lock: New. + * testsuite/30_threads/mutex/lock/1.cc: New. + * testsuite/30_threads/mutex/unlock: New. + * testsuite/30_threads/mutex/unlock/1.cc: New. + * testsuite/30_threads/recursive_mutex: New. + * testsuite/30_threads/recursive_mutex/dest: New. + * testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc: New. + * testsuite/30_threads/recursive_mutex/native_handle: New. + * testsuite/30_threads/recursive_mutex/native_handle/1.cc: New. + * testsuite/30_threads/recursive_mutex/cons: New. + * testsuite/30_threads/recursive_mutex/cons/assign_neg.cc: New. + * testsuite/30_threads/recursive_mutex/cons/1.cc: New. + * testsuite/30_threads/recursive_mutex/cons/copy_neg.cc: New. + * testsuite/30_threads/recursive_mutex/requirements: New. + * testsuite/30_threads/recursive_mutex/requirements/typedefs.cc: New. + * testsuite/30_threads/lock_guard: New. + * testsuite/30_threads/lock_guard/requirements: New. + * testsuite/30_threads/lock_guard/requirements/typedefs.cc: New. + * testsuite/30_threads/lock_guard/requirements/ + explicit_instantiation.cc: New. + * testsuite/30_threads/headers: New. + * testsuite/30_threads/headers/mutex: New. + * testsuite/30_threads/headers/mutex/types_std_c++0x.cc: New. + * testsuite/30_threads/headers/mutex/std_c++0x_neg.cc: New. + * testsuite/30_threads/headers/condition_variable: New. + * testsuite/30_threads/headers/condition_variable/ + types_std_c++0x.cc: New. + * testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc: New. + * testsuite/30_threads/once_flag: New. + * testsuite/30_threads/unique_lock: New. + * testsuite/30_threads/unique_lock/requirements: New. + * testsuite/30_threads/unique_lock/requirements/typedefs.cc: New. + * testsuite/30_threads/unique_lock/requirements/ + explicit_instantiation.cc: New. + * testsuite/17_intro/headers/c++200x/all.cc: Add new includes. + +2008-05-06 Benjamin Kosnik <bkoz@redhat.com> + PR libstdc++/36130 * include/bits/c++config: Namespace macros and setup only in C++. * testsuite/29_atomics/headers/stdatomic.h/debug_mode.c: New. - + 2008-05-06 Johannes Singler <singler@ira.uka.de> - * include/parallel/multiway_merge.h: - (multiway_merge_*_unguarded): - Pass sentinel directly, to allow correct determination. - (multiway_merge_loser_tree_unguarded): - Remove over-cautious assertion. - (calls to multiway_merge_*_splitting): - Parametrize with type that is correct in all cases. - * include/parallel/losertree.h: - (delete_min_insert (in many classes)): - Correct and standardize assertions. + * include/parallel/multiway_merge.h: + (multiway_merge_*_unguarded): + Pass sentinel directly, to allow correct determination. + (multiway_merge_loser_tree_unguarded): + Remove over-cautious assertion. + (calls to multiway_merge_*_splitting): + Parametrize with type that is correct in all cases. + * include/parallel/losertree.h: + (delete_min_insert (in many classes)): + Correct and standardize assertions. 2008-05-05 Benjamin Kosnik <bkoz@redhat.com> @@ -42,7 +113,7 @@ * testsuite/29_atomics/atomic/cons/assign_neg.cc: Adjust line numbers. * testsuite/29_atomics/atomic/cons/copy_neg.cc: Same. - + 2008-05-05 Benjamin Kosnik <bkoz@redhat.com> * 20_util/make_signed/requirements/typedefs-1.cc: Correct requirements. @@ -143,36 +214,36 @@ 2008-04-23 Johannes Singler <singler@ira.uka.de> - * include/parallel/quicksort.h: Reformat, - (parallel_sort_qs): Do not pass number of elements. - * include/parallel/balanced_quicksort.h: Reformat, - (parallel_sort_qsb): Do not pass number of elements. - * include/parallel/tags.h: - Introduce new tags for compile-time choice. - * include/parallel/merge.h: - (parallel_merge_advance):Beautified. - * include/parallel/algo.h: Reformatting (spaces for tabs) - New sort and stable_sort variants, corresponding to the tags. - * include/parallel/sort.h: - New sort and stable_sort variants, corresponding to the tags. - Changed determining the desired number of threads. + * include/parallel/quicksort.h: Reformat, + (parallel_sort_qs): Do not pass number of elements. + * include/parallel/balanced_quicksort.h: Reformat, + (parallel_sort_qsb): Do not pass number of elements. + * include/parallel/tags.h: + Introduce new tags for compile-time choice. + * include/parallel/merge.h: + (parallel_merge_advance):Beautified. + * include/parallel/algo.h: Reformatting (spaces for tabs) + New sort and stable_sort variants, corresponding to the tags. + * include/parallel/sort.h: + New sort and stable_sort variants, corresponding to the tags. + Changed determining the desired number of threads. 2008-04-23 Johannes Singler <singler@ira.uka.de> - * include/parallel/multiway_merge.h - (multiway_merge_loser_tree): - Leave checks to callers, add precondition instead. - (multiway_merge_loser_tree_unguarded): Likewise. - (multiway_merge_loser_tree_sentinel): Likewise. - (sequential_multiway_merge): Added checks for total length 0. - (parallel_multiway_merge): Skip empty sequences. - (multiway_merge, all variants): - Remove temporary variable, return directly. - (stable_multiway_merge, all variants): Likewise. - (multiway_merge_sentinels, all variants): Likewise. - (stable_multiway_merge_sentinels, all variants): Likewise. - * include/parallel/multiseq_selection.h - (multiseq_partition): More detailed assertions. + * include/parallel/multiway_merge.h + (multiway_merge_loser_tree): + Leave checks to callers, add precondition instead. + (multiway_merge_loser_tree_unguarded): Likewise. + (multiway_merge_loser_tree_sentinel): Likewise. + (sequential_multiway_merge): Added checks for total length 0. + (parallel_multiway_merge): Skip empty sequences. + (multiway_merge, all variants): + Remove temporary variable, return directly. + (stable_multiway_merge, all variants): Likewise. + (multiway_merge_sentinels, all variants): Likewise. + (stable_multiway_merge_sentinels, all variants): Likewise. + * include/parallel/multiseq_selection.h + (multiseq_partition): More detailed assertions. 2008-04-21 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> @@ -366,7 +437,7 @@ * include/std/regex: Same. * include/std/array: Same. * include/std/system_error: Same, add error_code ctor. - + 2008-04-07 Johannes Singler <singler@ira.uka.de> * include/parallel/multiway_merge.h: Moved decisions to @@ -413,7 +484,7 @@ 2008-03-26 Benjamin Kosnik <bkoz@redhat.com> * testsuite/util/testsuite_abi.h: Remove symbol_objects, - symbol_names typedefs. + symbol_names typedefs. * testsuite/util/testsuite_abi.cc (compare_symbols): Correct check for long double compatiblity symbols, simplify data structures used. @@ -433,13 +504,13 @@ * doc/doxygen/Intro.3: Correct typo. * doc/xml/api.xml: Add gcc-4.3 links. - * doc/html/api.html: Regenerate. - + * doc/html/api.html: Regenerate. + * include/debug/debug.h: Document namepaces here. * include/parallel/base.h: Same. * include/ext/typelist.h: Same. * include/ext/pb_ds/tag_and_trait.hpp: Same. - + * include/tr1_impl/random: Adjust line break. * include/tr1_impl/unordered_map: Correct and or add markup. * include/tr1_impl/boost_shared_ptr.h: Correct and or add markup. @@ -516,7 +587,7 @@ 2008-03-20 Johannes Singler <singler@ira.uka.de> - * include/parallel/set_operations.h (set_intersection): Remove. + * include/parallel/set_operations.h (set_intersection): Remove. 2008-03-19 Benjamin Kosnik <bkoz@redhat.com> @@ -541,8 +612,8 @@ * include/std/date_time: New file. * src/date_time.cc: New file. - * config/abi/pre/gnu.ver: Added <date_time> symbols in version - GLIBCXX_3.4.11 and changed two patterns in version GLIBCXX_3.4 + * config/abi/pre/gnu.ver: Added <date_time> symbols in version + GLIBCXX_3.4.11 and changed two patterns in version GLIBCXX_3.4 that matched new symbols. * include/Makefile.am: Add date_time in std headers. * src/Makefile.am: Add date_time.cc to source files. @@ -558,7 +629,7 @@ * testsuite/31_date_time/nanoseconds/requirements/traits.cc: Likewise. * testsuite/31_date_time/nanoseconds/requirements/duration.cc: Likewise. * testsuite/31_date_time/system_time/requirements: Likewise. - * testsuite/31_date_time/system_time/requirements/traits.cc: Likewise. + * testsuite/31_date_time/system_time/requirements/traits.cc: Likewise. 2008-03-16 Paolo Carlini <pcarlini@suse.de> @@ -643,7 +714,7 @@ (_GLIBCXX_LONG_DOUBLE_COMPAT_IMPL): Define. (_ZNKSt4hashIeEclEe): New alias. * testsuite/util/testsuite_abi.cc (check_version): Support - GLIBCXX_LDBL_3.4.10. + GLIBCXX_LDBL_3.4.10. 2008-02-25 Jan Beulich <jbeulich@novell.com> @@ -656,7 +727,7 @@ 2008-02-20 Jason Merrill <jason@redhat.com> - * include/bits/c++config: Use 'inline namespace' instead of + * include/bits/c++config: Use 'inline namespace' instead of strong using. 2008-02-18 Pedro Lamarao <pedro.lamarao@mndfck.org> @@ -674,16 +745,16 @@ * include/tr1/exp_integral.tcc: Same. * include/tr1/gamma.tcc: Same. * include/tr1/hypergeometric.tcc: Same. - + 2008-02-17 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/34797 * include/parallel/settings.h (_Settings): Reconstruct Settings class here, uglify, remove anonymous namespace and static - members. Convert to datum. + members. Convert to datum. * include/parallel/types.h: Move Settings:: enumerations here, uglify. * src/parallel_settings.cc: New, definition for _Settings member - functions. + functions. * include/parallel/multiway_merge.h: Same. * include/parallel/for_each.h: Same. * include/parallel/workstealing.h: Same. @@ -708,7 +779,7 @@ * src/Makefile.am (parallel_sources): Add parallel_settings.cc. * src/Makefile.in: Regenerate. - + * config/abi/pre/gnu.ver: Export _Settings::get and _Settings::set. 2008-02-17 Paolo Carlini <pcarlini@suse.de> @@ -727,22 +798,22 @@ * config/abi/pre/gnu.ver: Export stdio_sync_filebuf symbols. * testsuite/ext/stdio_sync_filebuf/char/35209.cc: New. * testsuite/ext/stdio_sync_filebuf/wchar_t/35209.cc: Likewise. - + 2008-02-16 Benjamin Kosnik <bkoz@redhat.com> * include/parallel/random_number.h: Use TR1's mersenne_twister. (random_number::genrand_bits()): Remove. (random_number::set_seed): Remove. - + 2008-02-15 Benjamin Kosnik <bkoz@redhat.com> - + * include/parallel/types.h: Remove enum parallelism. - + 2008-02-15 Benjamin Kosnik <bkoz@redhat.com> * include/parallel/types.h: Move enum parallelism here. Use tr1/cstdint's int16_t, uint16_t, int32_t, uint32_t, int64_t, - uint64_t. + uint64_t. * include/parallel/multiseq_selection.h: Adjust for cstdint. * include/parallel/compatibility.h: Same. * include/parallel/tags.h: Just compile-time tags. @@ -981,7 +1052,7 @@ * testsuite/tr1/6_containers/tuple/cons/constructor.cc: Likewise. * testsuite/tr1/6_containers/array/cons/aggregate_initialization.cc: Likewise. - * testsuite/tr1/6_containers/array/requirements/contiguous.cc: + * testsuite/tr1/6_containers/array/requirements/contiguous.cc: Likewise. * testsuite/tr1/6_containers/array/requirements/member_swap.cc: Likewise. @@ -1182,7 +1253,7 @@ __glibcxx_requires_sorted_set_pred): Add. * include/bits/stl_algo.h (merge, includes, set_union, set_intersection, set_difference, set_symmetric_difference): - Adjust, use __glibcxx_requires_sorted_set* instead. + Adjust, use __glibcxx_requires_sorted_set* instead. * testsuite/25_algorithms/set_intersection/34730.cc: New. 2008-01-09 Paolo Carlini <pcarlini@suse.de> @@ -1240,7 +1311,7 @@ * include/parallel/algobase.h: Likewise. * include/parallel/find.h: Likewise. * include/parallel/algo.h: Likewise. - * include/parallel/checkers.h: Likewise. + * include/parallel/checkers.h: Likewise. 2008-01-09 Francesco Biscani <bluescarni@gmail.com> @@ -1304,7 +1375,7 @@ * include/parallel/multiway_mergesort.h (parallel_sort_mwms_pu, parallel_sort_mwms): Likewise. * include/parallel/partial_sum.h (parallel_partial_sum_linear): - Likewise. + Likewise. * testsuite/25_algorithms/sort/34095.cc: New. 2008-01-01 Paolo Carlini <pcarlini@suse.de> diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index 3e5a924..48b8cfd 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -62,7 +62,10 @@ GLIBCXX_3.4 { std::c[a-g]*; # std::char_traits; # std::c[i-z]*; - std::c[i-s]*; + std::c[i-n]*; +# std::condition_variable; + std::co[^n]*; + std::c[p-s]*; std::c[u-z]*; # std::[d-g]*; std::d[a-d]*; @@ -831,6 +834,24 @@ GLIBCXX_3.4.11 { atomic_flag_test_and_set; atomic_flag_test_and_set_explicit; atomic_global_fence_compatibility; + + # mutex + _ZSt10adopt_lock; + _ZSt10defer_lock; + _ZSt11try_to_lock; + + _ZTISt10lock_error; + _ZTVSt10lock_error; + _ZTSSt10lock_error; + _ZNKSt10lock_error4whatEv; + + # condition_variable + _ZNSt18condition_variable10notify_allEv; + _ZNSt18condition_variable10notify_oneEv; + _ZNSt18condition_variableC1Ev; + _ZNSt18condition_variableC2Ev; + _ZNSt18condition_variableD1Ev; + _ZNSt18condition_variableD2Ev; # system_error _ZSt15system_category; @@ -847,6 +868,9 @@ GLIBCXX_3.4.11 { _ZNKSt4hashISt10error_codeEclES0_; + _ZSt20__throw_system_errorPKc; + _ZSt20__throw_system_errori; + # date_time _ZSt15get_system_timev; diff --git a/libstdc++-v3/doc/doxygen/doxygroups.cc b/libstdc++-v3/doc/doxygen/doxygroups.cc index f051a7e..d0adec9 100644 --- a/libstdc++-v3/doc/doxygen/doxygroups.cc +++ b/libstdc++-v3/doc/doxygen/doxygroups.cc @@ -34,6 +34,9 @@ /** @namespace std::placeholders * @brief ISO C++ 0x entities sub namespace for functional. */ +/** @namespace std::this_thread + * @brief ISO C++ 0x entities sub namespace for thread. +*/ /** @namespace __gnu_cxx * @brief GNU extensions for public use. */ diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in b/libstdc++-v3/doc/doxygen/user.cfg.in index 059d95d..fdb1ea1 100644 --- a/libstdc++-v3/doc/doxygen/user.cfg.in +++ b/libstdc++-v3/doc/doxygen/user.cfg.in @@ -468,6 +468,7 @@ INPUT = @srcdir@/libsupc++/cxxabi.h \ include/algorithm \ include/array \ include/bitset \ + include/condition_variable \ include/date_time \ include/deque \ include/fstream \ @@ -483,6 +484,7 @@ INPUT = @srcdir@/libsupc++/cxxabi.h \ include/locale \ include/map \ include/memory \ + include/mutex \ include/numeric \ include/ostream \ include/queue \ @@ -495,6 +497,7 @@ INPUT = @srcdir@/libsupc++/cxxabi.h \ include/streambuf \ include/string \ include/system_error \ + include/thread \ include/tuple \ include/type_traits \ include/unordered_map \ @@ -516,6 +519,7 @@ INPUT = @srcdir@/libsupc++/cxxabi.h \ include/csetjmp \ include/csignal \ include/cstdarg \ + include/cstdatomic \ include/cstdbool \ include/cstddef \ include/cstdint \ @@ -1162,7 +1166,8 @@ INCLUDE_FILE_PATTERNS = # undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = __GTHREADS \ +PREDEFINED = __cplusplus \ + __GTHREADS \ "_GLIBCXX_STD_P= " \ "_GLIBCXX_STD_D= " \ _GLIBCXX_STD=std \ diff --git a/libstdc++-v3/doc/xml/manual/using.xml b/libstdc++-v3/doc/xml/manual/using.xml index 67086833..fc3c97a 100644 --- a/libstdc++-v3/doc/xml/manual/using.xml +++ b/libstdc++-v3/doc/xml/manual/using.xml @@ -169,6 +169,7 @@ <row><entry><filename class="headerfile">exception</filename></entry><entry><filename class="headerfile">iterator</filename></entry><entry><filename class="headerfile">ostream</filename></entry><entry><filename class="headerfile">streambuf</filename></entry><entry><filename class="headerfile">utility</filename></entry></row> <row><entry><filename class="headerfile">fstream</filename></entry><entry><filename class="headerfile">limits</filename></entry><entry><filename class="headerfile">queue</filename></entry><entry><filename class="headerfile">string</filename></entry><entry><filename class="headerfile">valarray</filename></entry></row> <row><entry><filename class="headerfile">functional</filename></entry><entry><filename class="headerfile">list</filename></entry><entry><filename class="headerfile">random</filename></entry><entry><filename class="headerfile">system_error</filename></entry><entry><filename class="headerfile">vector</filename></entry></row> +<row><entry><filename class="headerfile">condition_variable</filename></entry><entry><filename class="headerfile">mutex</filename></entry><entry><filename class="headerfile">thread</filename></entry><entry></entry><entry></entry></row> </tbody> </tgroup> </table> @@ -189,6 +190,7 @@ <row><entry><filename class="headerfile">cctype</filename></entry><entry><filename class="headerfile">ciso646</filename></entry><entry><filename class="headerfile">csignal</filename></entry><entry><filename class="headerfile">cstdio</filename></entry><entry><filename class="headerfile">cuchar</filename></entry></row> <row><entry><filename class="headerfile">cerrno</filename></entry><entry><filename class="headerfile">climits</filename></entry><entry><filename class="headerfile">cstdarg</filename></entry><entry><filename class="headerfile">cstdlib</filename></entry><entry><filename class="headerfile">cwchar</filename></entry></row> <row><entry><filename class="headerfile">cfenv</filename></entry><entry><filename class="headerfile">clocale</filename></entry><entry><filename class="headerfile">cstdbool</filename></entry><entry><filename class="headerfile">cstring</filename></entry><entry><filename class="headerfile">cwctype</filename></entry></row> +<row><entry><filename class="headerfile">cstdatomic</filename></entry><entry></entry><entry></entry><entry></entry><entry></entry></row> </tbody> </tgroup> </table> diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index a867f00..9b950b58 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -33,6 +33,7 @@ std_headers = \ ${std_srcdir}/bitset \ ${std_srcdir}/c++0x_warning.h \ ${std_srcdir}/complex \ + ${std_srcdir}/condition_variable \ ${std_srcdir}/date_time \ ${std_srcdir}/deque \ ${std_srcdir}/fstream \ @@ -48,6 +49,7 @@ std_headers = \ ${std_srcdir}/locale \ ${std_srcdir}/map \ ${std_srcdir}/memory \ + ${std_srcdir}/mutex \ ${std_srcdir}/numeric \ ${std_srcdir}/ostream \ ${std_srcdir}/queue \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index f2ab8fa..b94c0cd 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -286,6 +286,7 @@ std_headers = \ ${std_srcdir}/bitset \ ${std_srcdir}/c++0x_warning.h \ ${std_srcdir}/complex \ + ${std_srcdir}/condition_variable \ ${std_srcdir}/date_time \ ${std_srcdir}/deque \ ${std_srcdir}/fstream \ @@ -301,6 +302,7 @@ std_headers = \ ${std_srcdir}/locale \ ${std_srcdir}/map \ ${std_srcdir}/memory \ + ${std_srcdir}/mutex \ ${std_srcdir}/numeric \ ${std_srcdir}/ostream \ ${std_srcdir}/queue \ diff --git a/libstdc++-v3/include/bits/functexcept.h b/libstdc++-v3/include/bits/functexcept.h index 59358c4..241384f 100644 --- a/libstdc++-v3/include/bits/functexcept.h +++ b/libstdc++-v3/include/bits/functexcept.h @@ -1,6 +1,6 @@ // Function-Based Exception Support -*- C++ -*- -// Copyright (C) 2001, 2004, 2005 Free Software Foundation, Inc. +// Copyright (C) 2001, 2004, 2005, 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 @@ -86,6 +86,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std) void __throw_underflow_error(const char*) __attribute__((__noreturn__)); + void + __throw_system_error(const char*) __attribute__((__noreturn__)); + + void + __throw_system_error(int) __attribute__((__noreturn__)); + // Helpers for exception objects in basic_ios void __throw_ios_failure(const char*) __attribute__((__noreturn__)); diff --git a/libstdc++-v3/include/std/condition_variable b/libstdc++-v3/include/std/condition_variable new file mode 100644 index 0000000..c8d8f78 --- /dev/null +++ b/libstdc++-v3/include/std/condition_variable @@ -0,0 +1,162 @@ +// <condition_variable> -*- C++ -*- + +// 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. + +/** @file condition_variable + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_CONDITION_VARIABLE +#define _GLIBCXX_CONDITION_VARIABLE 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#endif + +#include <mutex> // unique_lock + +namespace std +{ + // XXX + class system_time; + + /// condition_variable + class condition_variable + { + public: + +#if __GTHREAD_HAS_COND + typedef __gthread_cond_t native_handle_type; +#else + typedef int native_handle_type; +#endif + + condition_variable(); + ~condition_variable(); + + void + notify_one(); + + void + notify_all(); + + void + wait(unique_lock<mutex>& __lock); + + template<typename _Predicate> + void + wait(unique_lock<mutex>& __lock, _Predicate __p) + { + while (!__p()) + wait(__lock); + } + + template<typename _Duration> + bool + timed_wait(unique_lock<mutex>& __lock, const _Duration& __rtime); + + bool + timed_wait(unique_lock<mutex>& __lock, const system_time& __atime); + + template<typename _Predicate> + bool + timed_wait(unique_lock<mutex>& __lock, const system_time& __atime, + _Predicate pred); + + template<typename _Duration, typename _Predicate> + bool + timed_wait(unique_lock<mutex>& __lock, const _Duration& __rtime, + _Predicate pred); + + native_handle_type + native_handle() { return _M_cond; } + + private: + native_handle_type _M_cond; + condition_variable(const condition_variable&); + condition_variable& operator=(const condition_variable&); + }; + + /// condition_variable_any + // Like above, only mutex may not have try_lock. + class condition_variable_any + { + public: +#if __GTHREAD_HAS_COND + typedef __gthread_cond_t native_handle_type; +#else + typedef int native_handle_type; +#endif + + condition_variable_any(); + ~condition_variable_any(); + + void + notify_one(); + + void + notify_all(); + + template<typename _Lock> + void + wait(_Lock& __lock); + + template<typename _Lock, typename _Predicate> + void + wait(_Lock& __lock, _Predicate __p); + + template<typename _Lock> + bool + timed_wait(_Lock& __lock, const system_time& __atime); + + template<typename _Lock, typename _Duration> + bool + timed_wait(_Lock& __lock, const _Duration& __rtime); + + template<typename _Lock, typename _Predicate> + bool + timed_wait(_Lock& __lock, const system_time& __atime, _Predicate __p); + + template<typename _Lock, typename _Duration, typename _Predicate> + bool + timed_wait(_Lock& __lock, const _Duration& __rtime, _Predicate __p); + + native_handle_type + 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&); + }; + +} + +#endif diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex new file mode 100644 index 0000000..57e817f --- /dev/null +++ b/libstdc++-v3/include/std/mutex @@ -0,0 +1,385 @@ +// <mutex> -*- C++ -*- + +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 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. + +/** @file mutex + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_MUTEX +#define _GLIBCXX_MUTEX 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#endif + +#include <exception> +#include <cstddef> +#include <bits/functexcept.h> +#include <bits/gthr.h> + +namespace std +{ + // XXX + class system_time; + + /// mutex + class mutex + { + public: + typedef __gthread_mutex_t native_handle_type; + + mutex() + { +#if defined __GTHREAD_MUTEX_INIT + native_handle_type __tmp = __GTHREAD_MUTEX_INIT; + _M_mutex = __tmp; +#else + int __e = __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex); + + // EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may) + if ( __e) + __throw_system_error(__e); +#endif + } + + void + lock() + { + int __e = __gthread_mutex_lock(&_M_mutex); + + // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) + if ( __e) + __throw_system_error(__e); + } + + bool + try_lock() + { + int __e = __gthread_mutex_trylock(&_M_mutex); + + // EINVAL, EAGAIN, EBUSY + if ( __e) + __throw_system_error(__e); + else + return true; + } + + void + unlock() + { + int __e = __gthread_mutex_unlock(&_M_mutex); + + // EINVAL, EAGAIN, EPERM + if ( __e) + __throw_system_error(__e); + } + + native_handle_type + native_handle() + { return _M_mutex; } + + private: + native_handle_type _M_mutex; + mutex(const mutex&); + mutex& operator=(const mutex&); + }; + + + /// recursive_mutex + class recursive_mutex + { + public: + typedef __gthread_recursive_mutex_t native_handle_type; + + recursive_mutex() + { +#if defined __GTHREAD_RECURSIVE_MUTEX_INIT + native_handle_type __tmp = __GTHREAD_RECURSIVE_MUTEX_INIT; + _M_mutex = __tmp; +#else + int __e = __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex); + + // EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may) + if ( __e) + __throw_system_error(__e); +#endif + } + + + void + lock() + { + int __e = __gthread_recursive_mutex_lock(&_M_mutex); + + // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) + if ( __e) + __throw_system_error(__e); + } + + bool + try_lock() + { + int __e = __gthread_recursive_mutex_trylock(&_M_mutex); + + // EINVAL, EAGAIN, EBUSY + if ( __e) + __throw_system_error(__e); + else + return true; + } + + void + unlock() + { + int __e = __gthread_recursive_mutex_unlock(&_M_mutex); + + // EINVAL, EAGAIN, EBUSY + if ( __e) + __throw_system_error(__e); + } + + native_handle_type + native_handle() { return _M_mutex; } + + private: + native_handle_type _M_mutex; + + recursive_mutex(const recursive_mutex&); + recursive_mutex& operator=(const recursive_mutex&); + }; + + + // class timed_mutex; + // class recursive_timed_mutex; + + /// Do not acquire ownership of the mutex. + struct defer_lock_t { }; + + /// Try to acquire ownership of the mutex without blocking. + struct try_to_lock_t { }; + + /// Assume the calling thread has already obtained mutex ownership + /// and manage it. + struct adopt_lock_t { }; + + extern const defer_lock_t defer_lock; + extern const try_to_lock_t try_to_lock; + extern const adopt_lock_t adopt_lock; + + /// Thrown to indicate errors with lock operations. + class lock_error : public exception + { + public: + virtual const char* + what() const throw(); + }; + + /// @brief Scoped lock idiom. + // Acquire the mutex here with a constructor call, then release with + // the destructor call in accordance with RAII style. + template<typename _Mutex> + class lock_guard + { + public: + typedef _Mutex mutex_type; + + explicit lock_guard(mutex_type& __m) : _M_device(__m) + { _M_device.lock(); } + + lock_guard(mutex_type& __m, adopt_lock_t __a) : _M_device(__m) + { _M_device.lock(); } + + ~lock_guard() + { _M_device.unlock(); } + + private: + mutex_type& _M_device; + lock_guard(lock_guard const&); + lock_guard& operator=(lock_guard const&); + }; + + /// unique_lock + template<typename _Mutex> + class unique_lock + { + public: + typedef _Mutex mutex_type; + + unique_lock() : _M_device(NULL), _M_owns(false) { } + + explicit unique_lock(mutex_type& __m) : _M_device(&__m) + { + lock(); + _M_owns = true; + } + + unique_lock(mutex_type& __m, defer_lock_t) + : _M_device(&__m), _M_owns(false) { } + + unique_lock(mutex_type& __m, try_to_lock_t) + : _M_device(&__m), _M_owns(_M_device->try_lock()) { } + + unique_lock(mutex_type& __m, adopt_lock_t) + : _M_device(&__m), _M_owns(true) + { + // XXX calling thread owns mutex + } + + unique_lock(mutex_type& __m, const system_time& abs_time); + + template<typename _Duration> + unique_lock(mutex_type& __m, const _Duration& rel_time); + + ~unique_lock() + { + if (_M_owns) + unlock(); + } + + unique_lock(unique_lock&&); + + unique_lock& operator=(unique_lock&&); + + + void + lock() + { + if (_M_device && !_M_owns) + _M_device->lock(); + else + throw lock_error(); + } + + bool + try_lock() + { + bool __ret = false; + if (_M_device && !_M_owns) + __ret = _M_device->try_lock(); + else + throw lock_error(); + return __ret; + } + + void + unlock() + { + if (_M_device && _M_owns) + _M_device->unlock(); + else + throw lock_error(); + } + + + template<typename _Duration> + bool timed_lock(const _Duration& rel_time); + + bool + timed_lock(const system_time& abs_time); + + void + swap(unique_lock&& __u); + + mutex_type* + release() + { + mutex_type* __ret = _M_device; + _M_device = NULL; + _M_owns = false; + return __ret; + } + + bool + owns_lock() const { return _M_owns; } + + operator bool () const { return owns_lock(); } + + mutex_type* + mutex() const + { 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); + + template<typename _Mutex> + void + swap(unique_lock<_Mutex>&& __x, unique_lock<_Mutex>& __y); + + template<typename _Mutex> + void + swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>&& __y); + + template<typename _L1, typename _L2, typename ..._L3> + int + try_lock(_L1&, _L2&, _L3&...); + + template<typename _L1, typename _L2, typename ..._L3> + void + lock(_L1&, _L2&, _L3&...); + + /// once_flag + struct once_flag + { + typedef __gthread_once_t __native_type; + + once_flag() : _M_once(__GTHREAD_ONCE_INIT) { } + + __native_type& + _M_get() { return _M_once; } + + private: + __native_type _M_once; + once_flag(const once_flag&); + once_flag& operator=(const once_flag&); + }; + + template<typename _Callable, typename... _Args> + void + call_once(once_flag& __once, _Callable __f, _Args&&... __args) + { + int __e = __gthread_once(&(__once._M_get()), __f(__args...)); + if ( __e) + __throw_system_error(__e); + } +} + + +#endif diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am index e6c0aad..0b5f2a7 100644 --- a/libstdc++-v3/src/Makefile.am +++ b/libstdc++-v3/src/Makefile.am @@ -183,6 +183,8 @@ sources = \ valarray-inst.cc \ wlocale-inst.cc \ wstring-inst.cc \ + mutex.cc \ + condition_variable.cc \ ${host_sources} \ ${host_sources_extra} @@ -229,11 +231,26 @@ parallel_settings.o: parallel_settings.cc $(CXXCOMPILE) $(PARALLEL_FLAGS) -c $< # Use special rules for the C++0x sources so that the proper flags are passed. +functexcept.lo: functexcept.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +functexcept.o: functexcept.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + system_error.lo: system_error.cc $(LTCXXCOMPILE) -std=gnu++0x -c $< system_error.o: system_error.cc $(CXXCOMPILE) -std=gnu++0x -c $< +mutex.lo: mutex.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +mutex.o: mutex.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + +condition_variable.lo: condition_variable.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +condition_variable.o: condition_variable.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + hash_c++0x.lo: hash_c++0x.cc $(LTCXXCOMPILE) -std=gnu++0x -c $< hash_c++0x.o: hash_c++0x.cc diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in index 492c890..c1e56fb 100644 --- a/libstdc++-v3/src/Makefile.in +++ b/libstdc++-v3/src/Makefile.in @@ -84,11 +84,11 @@ am__libstdc___la_SOURCES_DIST = atomic.cc bitmap_allocator.cc \ iostream-inst.cc istream-inst.cc istream.cc locale-inst.cc \ misc-inst.cc ostream-inst.cc sstream-inst.cc streambuf-inst.cc \ streambuf.cc string-inst.cc valarray-inst.cc wlocale-inst.cc \ - wstring-inst.cc atomicity.cc codecvt_members.cc \ - collate_members.cc ctype_members.cc messages_members.cc \ - monetary_members.cc numeric_members.cc time_members.cc \ - basic_file.cc c++locale.cc compatibility-ldbl.cc \ - parallel_list.cc parallel_settings.cc + wstring-inst.cc mutex.cc condition_variable.cc atomicity.cc \ + codecvt_members.cc collate_members.cc ctype_members.cc \ + messages_members.cc monetary_members.cc numeric_members.cc \ + time_members.cc basic_file.cc c++locale.cc \ + compatibility-ldbl.cc parallel_list.cc parallel_settings.cc am__objects_1 = atomicity.lo codecvt_members.lo collate_members.lo \ ctype_members.lo messages_members.lo monetary_members.lo \ numeric_members.lo time_members.lo @@ -109,7 +109,8 @@ am__objects_5 = atomic.lo bitmap_allocator.lo pool_allocator.lo \ istream-inst.lo istream.lo locale-inst.lo misc-inst.lo \ ostream-inst.lo sstream-inst.lo streambuf-inst.lo streambuf.lo \ string-inst.lo valarray-inst.lo wlocale-inst.lo \ - wstring-inst.lo $(am__objects_1) $(am__objects_4) + wstring-inst.lo mutex.lo condition_variable.lo \ + $(am__objects_1) $(am__objects_4) am_libstdc___la_OBJECTS = $(am__objects_5) libstdc___la_OBJECTS = $(am_libstdc___la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) @@ -419,6 +420,8 @@ sources = \ valarray-inst.cc \ wlocale-inst.cc \ wstring-inst.cc \ + mutex.cc \ + condition_variable.cc \ ${host_sources} \ ${host_sources_extra} @@ -823,11 +826,26 @@ parallel_settings.o: parallel_settings.cc $(CXXCOMPILE) $(PARALLEL_FLAGS) -c $< # Use special rules for the C++0x sources so that the proper flags are passed. +functexcept.lo: functexcept.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +functexcept.o: functexcept.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + system_error.lo: system_error.cc $(LTCXXCOMPILE) -std=gnu++0x -c $< system_error.o: system_error.cc $(CXXCOMPILE) -std=gnu++0x -c $< +mutex.lo: mutex.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +mutex.o: mutex.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + +condition_variable.lo: condition_variable.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +condition_variable.o: condition_variable.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + hash_c++0x.lo: hash_c++0x.cc $(LTCXXCOMPILE) -std=gnu++0x -c $< hash_c++0x.o: hash_c++0x.cc diff --git a/libstdc++-v3/src/condition_variable.cc b/libstdc++-v3/src/condition_variable.cc new file mode 100644 index 0000000..74541e9 --- /dev/null +++ b/libstdc++-v3/src/condition_variable.cc @@ -0,0 +1,84 @@ +// mutex -*- C++ -*- + +// 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> + +namespace std +{ + condition_variable::condition_variable() + { +#if __GTHREAD_HAS_COND +# if defined __GTHREAD_COND_INIT + native_handle_type __tmp = __GTHREAD_COND_INIT; + _M_cond = __tmp; +# else + int __e = __gthread_cond_init(&_M_cond, NULL); + 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); + // if __e == EBUSY then blocked +#endif + } + + void + condition_variable::notify_one() + { +#if __GTHREAD_HAS_COND + int __e = pthread_cond_signal(&_M_cond); + + // XXX not in spec + // EINVAL + if ( __e) + __throw_system_error(__e); +#endif + } + + void + condition_variable::notify_all() + { +#if __GTHREAD_HAS_COND + int __e = pthread_cond_broadcast(&_M_cond); + + // XXX not in spec + // EINVAL + if ( __e) + __throw_system_error(__e); +#endif + } + +} + diff --git a/libstdc++-v3/src/functexcept.cc b/libstdc++-v3/src/functexcept.cc index 5e53f05..f77bb0d 100644 --- a/libstdc++-v3/src/functexcept.cc +++ b/libstdc++-v3/src/functexcept.cc @@ -29,6 +29,7 @@ #include <cstdlib> #include <exception> #include <stdexcept> +#include <system_error> #include <new> #include <typeinfo> #include <ios> @@ -96,6 +97,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { throw underflow_error(_(__s)); } void + __throw_system_error(const char* __s) + { throw system_error(_(__s)); } + + void + __throw_system_error(int __i) + { throw system_error(error_code(__i, system_category)); } + + void __throw_ios_failure(const char* __s) { throw ios_base::failure(_(__s)); } #else @@ -152,6 +161,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { std::abort(); } void + __throw_system_error(const char* __s) + { std::abort(); } + + void + __throw_system_error(int __i) + { std::abort(); } + + void __throw_ios_failure(const char*) { std::abort(); } #endif //__EXCEPTIONS diff --git a/libstdc++-v3/src/mutex.cc b/libstdc++-v3/src/mutex.cc new file mode 100644 index 0000000..a1c74aa --- /dev/null +++ b/libstdc++-v3/src/mutex.cc @@ -0,0 +1,42 @@ +// mutex -*- C++ -*- + +// 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> + +namespace std +{ + const defer_lock_t defer_lock = defer_lock_t(); + const try_to_lock_t try_to_lock = try_to_lock_t(); + const adopt_lock_t adopt_lock = adopt_lock_t(); + + const char* + lock_error::what() const throw() + { return "std::lock_error"; } +} + diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++200x/all.cc b/libstdc++-v3/testsuite/17_intro/headers/c++200x/all.cc index 6c30410..049f420 100644 --- a/libstdc++-v3/testsuite/17_intro/headers/c++200x/all.cc +++ b/libstdc++-v3/testsuite/17_intro/headers/c++200x/all.cc @@ -95,6 +95,7 @@ #include <algorithm> #include <array> #include <bitset> +#include <condition_variable> #include <complex> #include <date_time> #include <deque> @@ -112,6 +113,7 @@ #include <locale> #include <map> #include <memory> +#include <mutex> #include <new> #include <numeric> #include <ostream> diff --git a/libstdc++-v3/testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc b/libstdc++-v3/testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc new file mode 100644 index 0000000..3638ec7 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// 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. + +#include <condition_variable> // { dg-excess-errors "In file included from" } + +// { dg-error "upcoming ISO" "" { target *-*-* } 36 } + + + diff --git a/libstdc++-v3/testsuite/30_threads/headers/condition_variable/types_std_c++0x.cc b/libstdc++-v3/testsuite/30_threads/headers/condition_variable/types_std_c++0x.cc new file mode 100644 index 0000000..8c15bb5 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/headers/condition_variable/types_std_c++0x.cc @@ -0,0 +1,28 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 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. + +#include <condition_variable> + +void test01() +{ + typedef std::condition_variable c_t; + typedef std::condition_variable_any ca_t; +} diff --git a/libstdc++-v3/testsuite/30_threads/headers/mutex/std_c++0x_neg.cc b/libstdc++-v3/testsuite/30_threads/headers/mutex/std_c++0x_neg.cc new file mode 100644 index 0000000..d6f7dca --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/headers/mutex/std_c++0x_neg.cc @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// 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. + +#include <mutex> // { dg-excess-errors "In file included from" } + +// { dg-error "upcoming ISO" "" { target *-*-* } 36 } + + + diff --git a/libstdc++-v3/testsuite/30_threads/headers/mutex/types_std_c++0x.cc b/libstdc++-v3/testsuite/30_threads/headers/mutex/types_std_c++0x.cc new file mode 100644 index 0000000..6296f92 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/headers/mutex/types_std_c++0x.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 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. + +#include <mutex> + +void test01() +{ + typedef std::mutex mutext_t; + typedef std::recursive_mutex rmutext_t; + + typedef std::defer_lock_t dl_t; + typedef std::try_to_lock_t ttl_t; + typedef std::adopt_lock_t al_t; + + using std::defer_lock; + using std::try_to_lock; + using std::adopt_lock; + + typedef std::lock_error error_t; + + typedef std::once_flag once_t; +} diff --git a/libstdc++-v3/testsuite/30_threads/lock_guard/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/30_threads/lock_guard/requirements/explicit_instantiation.cc new file mode 100644 index 0000000..51bee1b --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/lock_guard/requirements/explicit_instantiation.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2008-03-14 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. + +// NB: This file is for testing with NO OTHER INCLUDES. + +#include <mutex> + +namespace std +{ + template class lock_guard<mutex>; +} diff --git a/libstdc++-v3/testsuite/30_threads/lock_guard/requirements/typedefs.cc b/libstdc++-v3/testsuite/30_threads/lock_guard/requirements/typedefs.cc new file mode 100644 index 0000000..f38ee5d --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/lock_guard/requirements/typedefs.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2008-03-14 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. + +// NB: This file is for testing with NO OTHER INCLUDES. + +#include <mutex> + +void test01() +{ + // Check for required typedefs + typedef std::lock_guard<std::mutex> test_type; + typedef test_type::mutex_type mutex_type; +} diff --git a/libstdc++-v3/testsuite/30_threads/mutex/cons/1.cc b/libstdc++-v3/testsuite/30_threads/mutex/cons/1.cc new file mode 100644 index 0000000..fca1ffa --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/mutex/cons/1.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++0x" } + +// 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::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/mutex/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc new file mode 100644 index 0000000..650dc96 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 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::mutex mutex_type; + mutex_type m1; + mutex_type m2; + m1 = m2; +} +// { dg-error "within this context" "" { target *-*-* } 39 } +// { dg-error "is private" "" { target *-*-* } 113 } diff --git a/libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc new file mode 100644 index 0000000..82d5e5e --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 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::mutex mutex_type; + mutex_type m1; + mutex_type m2(m1); +} +// { dg-error "within this context" "" { target *-*-* } 38 } +// { dg-error "is private" "" { target *-*-* } 112 } diff --git a/libstdc++-v3/testsuite/30_threads/mutex/dest/destructor_locked.cc b/libstdc++-v3/testsuite/30_threads/mutex/dest/destructor_locked.cc new file mode 100644 index 0000000..6fad4b5 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/mutex/dest/destructor_locked.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } + +// 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::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/mutex/lock/1.cc b/libstdc++-v3/testsuite/30_threads/mutex/lock/1.cc new file mode 100644 index 0000000..3ca6b4a --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/mutex/lock/1.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } + +// 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::mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + + // Lock already locked mutex, should be ok. + // XXX + try + { + 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/mutex/native_handle/1.cc b/libstdc++-v3/testsuite/30_threads/mutex/native_handle/1.cc new file mode 100644 index 0000000..8f3034a --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/mutex/native_handle/1.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } + +// 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::mutex mutex_type; + + try + { + mutex_type m; + mutex_type::native_handle_type n = m.native_handle(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/mutex/requirements/typedefs.cc b/libstdc++-v3/testsuite/30_threads/mutex/requirements/typedefs.cc new file mode 100644 index 0000000..2255399 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/mutex/requirements/typedefs.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 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::mutex test_type; + typedef test_type::native_handle_type type; +} diff --git a/libstdc++-v3/testsuite/30_threads/mutex/try_lock/1.cc b/libstdc++-v3/testsuite/30_threads/mutex/try_lock/1.cc new file mode 100644 index 0000000..20a3caa --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/mutex/try_lock/1.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=gnu++0x" } + +// 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::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/mutex/try_lock/2.cc b/libstdc++-v3/testsuite/30_threads/mutex/try_lock/2.cc new file mode 100644 index 0000000..617a652 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/mutex/try_lock/2.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } + +// 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::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/mutex/unlock/1.cc b/libstdc++-v3/testsuite/30_threads/mutex/unlock/1.cc new file mode 100644 index 0000000..1a15729 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/mutex/unlock/1.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=gnu++0x" } + +// 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::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/recursive_mutex/cons/1.cc b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/1.cc new file mode 100644 index 0000000..eb76d11 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/1.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++0x" } + +// 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_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_mutex/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc new file mode 100644 index 0000000..5d83a70 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 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_mutex mutex_type; + mutex_type m1; + mutex_type m2; + m1 = m2; +} +// { dg-error "within this context" "" { target *-*-* } 39 } +// { dg-error "is private" "" { target *-*-* } 177 } diff --git a/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc new file mode 100644 index 0000000..b0d0b9d --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 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_mutex mutex_type; + mutex_type m1; + mutex_type m2(m1); +} +// { dg-error "within this context" "" { target *-*-* } 38 } +// { dg-error "is private" "" { target *-*-* } 176 } diff --git a/libstdc++-v3/testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc b/libstdc++-v3/testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc new file mode 100644 index 0000000..3586cfa --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } + +// 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_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_mutex/native_handle/1.cc b/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/1.cc new file mode 100644 index 0000000..d28513f --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/1.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } + +// 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_mutex mutex_type; + + try + { + mutex_type m; + mutex_type::native_handle_type n = m.native_handle(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/recursive_mutex/requirements/typedefs.cc b/libstdc++-v3/testsuite/30_threads/recursive_mutex/requirements/typedefs.cc new file mode 100644 index 0000000..6b7c3cf --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/recursive_mutex/requirements/typedefs.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 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_mutex test_type; + typedef test_type::native_handle_type type; +} diff --git a/libstdc++-v3/testsuite/30_threads/unique_lock/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/30_threads/unique_lock/requirements/explicit_instantiation.cc new file mode 100644 index 0000000..594d829 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/unique_lock/requirements/explicit_instantiation.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2008-03-14 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. + +// NB: This file is for testing with NO OTHER INCLUDES. + +#include <mutex> + +namespace std +{ + template class unique_lock<mutex>; +} diff --git a/libstdc++-v3/testsuite/30_threads/unique_lock/requirements/typedefs.cc b/libstdc++-v3/testsuite/30_threads/unique_lock/requirements/typedefs.cc new file mode 100644 index 0000000..5933afe --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/unique_lock/requirements/typedefs.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2008-03-14 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. + +// NB: This file is for testing with NO OTHER INCLUDES. + +#include <mutex> + +void test01() +{ + // Check for required typedefs + typedef std::unique_lock<std::mutex> test_type; + typedef test_type::mutex_type mutex_type; +} |