From: Benjamin Kosnik Date: Tue, 6 May 2008 21:11:47 +0000 (+0000) Subject: condition_variable: New. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=68a97d242cbeacf50a83122b0b7aa32c86cebdc0;p=gcc.git condition_variable: New. 2008-05-06 Benjamin Kosnik * 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 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f50f917c4f2..456be98f38d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,21 +1,92 @@ +2008-05-06 Benjamin Kosnik + + * 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 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 - * 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 @@ -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 * 20_util/make_signed/requirements/typedefs-1.cc: Correct requirements. @@ -143,36 +214,36 @@ 2008-04-23 Johannes Singler - * 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 - * 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 @@ -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 * include/parallel/multiway_merge.h: Moved decisions to @@ -413,7 +484,7 @@ 2008-03-26 Benjamin Kosnik * 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 - * include/parallel/set_operations.h (set_intersection): Remove. + * include/parallel/set_operations.h (set_intersection): Remove. 2008-03-19 Benjamin Kosnik @@ -541,8 +612,8 @@ * include/std/date_time: New file. * src/date_time.cc: New file. - * config/abi/pre/gnu.ver: Added symbols in version - GLIBCXX_3.4.11 and changed two patterns in version GLIBCXX_3.4 + * config/abi/pre/gnu.ver: Added 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 @@ -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 @@ -656,7 +727,7 @@ 2008-02-20 Jason Merrill - * 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 @@ -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 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 @@ -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 * 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 - + * include/parallel/types.h: Remove enum parallelism. - + 2008-02-15 Benjamin Kosnik * 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 @@ -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 @@ -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 diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index 3e5a9240513..48b8cfd0aae 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 f051a7e7b55..d0adec9e5fb 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 059d95da229..fdb1ea1e5f8 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 67086833a75..fc3c97a49ca 100644 --- a/libstdc++-v3/doc/xml/manual/using.xml +++ b/libstdc++-v3/doc/xml/manual/using.xml @@ -169,6 +169,7 @@ exceptioniteratorostreamstreambufutility fstreamlimitsqueuestringvalarray functionallistrandomsystem_errorvector +condition_variablemutexthread @@ -189,6 +190,7 @@ cctypeciso646csignalcstdiocuchar cerrnoclimitscstdargcstdlibcwchar cfenvclocalecstdboolcstringcwctype +cstdatomic diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index a867f009c3a..9b950b58e28 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 f2ab8fa2046..b94c0cd632e 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 59358c4060e..241384f0730 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 00000000000..c8d8f7845e4 --- /dev/null +++ b/libstdc++-v3/include/std/condition_variable @@ -0,0 +1,162 @@ +// -*- 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 +#endif + +#include // 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& __lock); + + template + void + wait(unique_lock& __lock, _Predicate __p) + { + while (!__p()) + wait(__lock); + } + + template + bool + timed_wait(unique_lock& __lock, const _Duration& __rtime); + + bool + timed_wait(unique_lock& __lock, const system_time& __atime); + + template + bool + timed_wait(unique_lock& __lock, const system_time& __atime, + _Predicate pred); + + template + bool + timed_wait(unique_lock& __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 + void + wait(_Lock& __lock); + + template + void + wait(_Lock& __lock, _Predicate __p); + + template + bool + timed_wait(_Lock& __lock, const system_time& __atime); + + template + bool + timed_wait(_Lock& __lock, const _Duration& __rtime); + + template + bool + timed_wait(_Lock& __lock, const system_time& __atime, _Predicate __p); + + template + 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 00000000000..57e817fcc79 --- /dev/null +++ b/libstdc++-v3/include/std/mutex @@ -0,0 +1,385 @@ +// -*- 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 +#endif + +#include +#include +#include +#include + +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 + 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 + 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 + 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 + 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 + void + swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y); + + template + void + swap(unique_lock<_Mutex>&& __x, unique_lock<_Mutex>& __y); + + template + void + swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>&& __y); + + template + int + try_lock(_L1&, _L2&, _L3&...); + + template + 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 + 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 e6c0aad184a..0b5f2a70885 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 492c8907ced..c1e56fb4071 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 00000000000..74541e9f34b --- /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 + +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 5e53f052d84..f77bb0d29cd 100644 --- a/libstdc++-v3/src/functexcept.cc +++ b/libstdc++-v3/src/functexcept.cc @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -95,6 +96,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __throw_underflow_error(const char* __s) { 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)); } @@ -151,6 +160,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __throw_underflow_error(const char*) { 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(); } diff --git a/libstdc++-v3/src/mutex.cc b/libstdc++-v3/src/mutex.cc new file mode 100644 index 00000000000..a1c74aab101 --- /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 + +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 6c30410bb6f..049f42096d0 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 #include #include +#include #include #include #include @@ -112,6 +113,7 @@ #include #include #include +#include #include #include #include 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 00000000000..3638ec70b02 --- /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 // { 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 00000000000..8c15bb57e7d --- /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 + +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 00000000000..d6f7dca5b8b --- /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 // { 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 00000000000..6296f92d116 --- /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 + +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 00000000000..51bee1b2ac9 --- /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 + +// 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 + +namespace std +{ + template class lock_guard; +} 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 00000000000..f38ee5dc771 --- /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 + +// 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 + +void test01() +{ + // Check for required typedefs + typedef std::lock_guard 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 00000000000..fca1ffa4740 --- /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 +#include +#include + +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 00000000000..650dc967195 --- /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 + +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 00000000000..82d5e5eb4e7 --- /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 + +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 00000000000..6fad4b5a694 --- /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 +#include +#include + +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 00000000000..3ca6b4af880 --- /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 +#include +#include + +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 00000000000..8f3034a291d --- /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 +#include +#include + +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 00000000000..225539958de --- /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 + +// 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 + +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 00000000000..20a3caa39e3 --- /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 +#include +#include + +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 00000000000..617a6525615 --- /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 +#include +#include + +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 00000000000..1a157290ee7 --- /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 +#include +#include + +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 00000000000..eb76d11a329 --- /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 +#include +#include + +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 00000000000..5d83a708e58 --- /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 + +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 00000000000..b0d0b9d4a1a --- /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 + +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 00000000000..3586cfa5398 --- /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 +#include +#include + +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 00000000000..d28513fc628 --- /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 +#include +#include + +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 00000000000..6b7c3cf724c --- /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 + +// 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 + +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 00000000000..594d8291a09 --- /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 + +// 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 + +namespace std +{ + template class unique_lock; +} 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 00000000000..5933afe8d0d --- /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 + +// 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 + +void test01() +{ + // Check for required typedefs + typedef std::unique_lock test_type; + typedef test_type::mutex_type mutex_type; +}