summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2011-07-21 03:27:51 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2011-07-21 03:27:51 +0000
commitcd9f496fd38314abcc660f35881b6658843706f0 (patch)
treef3fdc8718eaf6ac83f14016d727102242e79634b /libstdc++-v3
parentdadb7e26dde7fe1fdd7d2a304db52986d92a6ca9 (diff)
downloadgcc-cd9f496fd38314abcc660f35881b6658843706f0.tar.gz
2011-07-20 Benjamin Kosnik <bkoz@redhat.com>
Daniel Krugler <daniel.kruegler@googlemail.com> * include/std/chrono: (system_clock::is_steady): Update to N3291 from is_monotonic. (time_point): Add constexpr to nonmember arithmetic operators. * src/chrono.cc: Modify for above. * src/compatibility-c++0x.cc: Same. * testsuite/20_util/time_point/nonmember/constexpr.cc: New. * testsuite/20_util/time_point/1.cc: Modify. * testsuite/20_util/system_clock/constexpr_data.cc: Modify. * testsuite/20_util/system_clock/1.cc: Modify. * testsuite/20_util/monotonic_clock/constexpr_data.cc: Move to... * testsuite/20_util/steady_clock/constexpr_data.cc: ...here. * testsuite/30_threads/condition_variable/members/2.cc: Modify. * testsuite/30_threads/condition_variable_any/members/2.cc: Modify. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176549 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog23
-rw-r--r--libstdc++-v3/include/std/chrono36
-rw-r--r--libstdc++-v3/src/chrono.cc8
-rw-r--r--libstdc++-v3/src/compatibility-c++0x.cc15
-rw-r--r--libstdc++-v3/testsuite/20_util/steady_clock/constexpr_data.cc (renamed from libstdc++-v3/testsuite/20_util/monotonic_clock/constexpr_data.cc)4
-rw-r--r--libstdc++-v3/testsuite/20_util/system_clock/1.cc6
-rw-r--r--libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc4
-rw-r--r--libstdc++-v3/testsuite/20_util/time_point/1.cc6
-rw-r--r--libstdc++-v3/testsuite/20_util/time_point/nonmember/constexpr.cc45
-rw-r--r--libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc6
-rw-r--r--libstdc++-v3/testsuite/30_threads/condition_variable_any/members/2.cc6
11 files changed, 122 insertions, 37 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 62d15117c4f..ec1897ca4cd 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,20 @@
+2011-07-20 Benjamin Kosnik <bkoz@redhat.com>
+ Daniel Krugler <daniel.kruegler@googlemail.com>
+
+ * include/std/chrono: (system_clock::is_steady): Update to N3291
+ from is_monotonic.
+ (time_point): Add constexpr to nonmember arithmetic operators.
+ * src/chrono.cc: Modify for above.
+ * src/compatibility-c++0x.cc: Same.
+ * testsuite/20_util/time_point/nonmember/constexpr.cc: New.
+ * testsuite/20_util/time_point/1.cc: Modify.
+ * testsuite/20_util/system_clock/constexpr_data.cc: Modify.
+ * testsuite/20_util/system_clock/1.cc: Modify.
+ * testsuite/20_util/monotonic_clock/constexpr_data.cc: Move to...
+ * testsuite/20_util/steady_clock/constexpr_data.cc: ...here.
+ * testsuite/30_threads/condition_variable/members/2.cc: Modify.
+ * testsuite/30_threads/condition_variable_any/members/2.cc: Modify.
+
2011-07-20 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/system_error: Use noexcept.
@@ -1544,7 +1561,7 @@
2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/tuple (tuple<>::operator=(tuple&&)): Specify as
- noexcept.
+ noexcept.
(__get_helper): Likewise.
(_Head_base<>::_M_head, _Tuple_impl<>::_M_head, _M_tail): Likewise.
* include/bits/move.h (swap): Likewise.
@@ -2237,8 +2254,8 @@
2011-03-31 Jeffrey Yasskin <jyasskin@google.com>
- * libsupc++/exception_ptr.h: Forward-declare std::type_info.
- * libsupc++/nested_exception.h (__throw_with_nested): Remove a
+ * libsupc++/exception_ptr.h: Forward-declare std::type_info.
+ * libsupc++/nested_exception.h (__throw_with_nested): Remove a
redundant default argument from std::__throw_with_nested.
2011-03-31 Paolo Carlini <paolo.carlini@oracle.com>
diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono
index ed8fc303306..f64fd6e1e7b 100644
--- a/libstdc++-v3/include/std/chrono
+++ b/libstdc++-v3/include/std/chrono
@@ -585,7 +585,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
template<typename _Clock, typename _Dur1,
typename _Rep2, typename _Period2>
- inline time_point<_Clock,
+ inline constexpr time_point<_Clock,
typename common_type<_Dur1, duration<_Rep2, _Period2>>::type>
operator+(const time_point<_Clock, _Dur1>& __lhs,
const duration<_Rep2, _Period2>& __rhs)
@@ -593,27 +593,37 @@ _GLIBCXX_END_NAMESPACE_VERSION
typedef duration<_Rep2, _Period2> __dur2;
typedef typename common_type<_Dur1,__dur2>::type __ct;
typedef time_point<_Clock, __ct> __time_point;
- return __time_point(__lhs) += __rhs;
+ return __time_point(__lhs.time_since_epoch() + __rhs);
}
template<typename _Rep1, typename _Period1,
typename _Clock, typename _Dur2>
- inline time_point<_Clock,
+ inline constexpr time_point<_Clock,
typename common_type<duration<_Rep1, _Period1>, _Dur2>::type>
operator+(const duration<_Rep1, _Period1>& __lhs,
const time_point<_Clock, _Dur2>& __rhs)
- { return __rhs + __lhs; }
+ {
+ typedef duration<_Rep1, _Period1> __dur1;
+ typedef typename common_type<__dur1,_Dur2>::type __ct;
+ typedef time_point<_Clock, __ct> __time_point;
+ return __time_point(__rhs.time_since_epoch() + __lhs);
+ }
template<typename _Clock, typename _Dur1,
typename _Rep2, typename _Period2>
- inline time_point<_Clock,
+ inline constexpr time_point<_Clock,
typename common_type<_Dur1, duration<_Rep2, _Period2>>::type>
operator-(const time_point<_Clock, _Dur1>& __lhs,
const duration<_Rep2, _Period2>& __rhs)
- { return __lhs + (-__rhs); }
+ {
+ typedef duration<_Rep2, _Period2> __dur2;
+ typedef typename common_type<_Dur1,__dur2>::type __ct;
+ typedef time_point<_Clock, __ct> __time_point;
+ return __time_point(__lhs.time_since_epoch() -__rhs);
+ }
template<typename _Clock, typename _Dur1, typename _Dur2>
- inline typename common_type<_Dur1, _Dur2>::type
+ inline constexpr typename common_type<_Dur1, _Dur2>::type
operator-(const time_point<_Clock, _Dur1>& __lhs,
const time_point<_Clock, _Dur2>& __rhs)
{ return __lhs.time_since_epoch() - __rhs.time_since_epoch(); }
@@ -673,7 +683,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
< system_clock::duration::zero(),
"a clock's minimum duration cannot be less than its epoch");
- static constexpr bool is_monotonic = false;
+ static constexpr bool is_steady = false;
static time_point
now() throw ();
@@ -696,21 +706,21 @@ _GLIBCXX_END_NAMESPACE_VERSION
};
#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
- /// monotonic_clock
- struct monotonic_clock
+ /// steady_clock
+ struct steady_clock
{
typedef chrono::nanoseconds duration;
typedef duration::rep rep;
typedef duration::period period;
- typedef chrono::time_point<monotonic_clock, duration> time_point;
+ typedef chrono::time_point<steady_clock, duration> time_point;
- static constexpr bool is_monotonic = true;
+ static constexpr bool is_steady = true;
static time_point
now();
};
#else
- typedef system_clock monotonic_clock;
+ typedef system_clock steady_clock;
#endif
typedef system_clock high_resolution_clock;
diff --git a/libstdc++-v3/src/chrono.cc b/libstdc++-v3/src/chrono.cc
index 6b5e669a7dc..07c932a1ad8 100644
--- a/libstdc++-v3/src/chrono.cc
+++ b/libstdc++-v3/src/chrono.cc
@@ -39,7 +39,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
- constexpr bool system_clock::is_monotonic;
+ constexpr bool system_clock::is_steady;
system_clock::time_point
system_clock::now() throw ()
@@ -63,10 +63,10 @@ namespace std _GLIBCXX_VISIBILITY(default)
}
#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
- constexpr bool monotonic_clock::is_monotonic;
+ constexpr bool steady_clock::is_steady;
- monotonic_clock::time_point
- monotonic_clock::now()
+ steady_clock::time_point
+ steady_clock::now()
{
timespec tp;
// -EINVAL, -EFAULT
diff --git a/libstdc++-v3/src/compatibility-c++0x.cc b/libstdc++-v3/src/compatibility-c++0x.cc
index 08a572761f9..c5e1db092a5 100644
--- a/libstdc++-v3/src/compatibility-c++0x.cc
+++ b/libstdc++-v3/src/compatibility-c++0x.cc
@@ -1,6 +1,6 @@
// Compatibility symbols for previous versions, C++0x bits -*- C++ -*-
-// Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2010, 2011 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
@@ -81,4 +81,17 @@ namespace std _GLIBCXX_VISIBILITY(default)
const size_t __tmp = std::_Hash_impl::hash(__e._M_value);
return std::_Hash_impl::__hash_combine(__e._M_cat, __tmp);
}
+
+
+ // gcc-4.7.0
+ // <chrono> changes is_monotonic to is_steady.
+ namespace chrono
+ {
+ struct system_clock
+ {
+ static constexpr bool is_monotonic = false;
+ };
+ constexpr bool system_clock::is_monotonic;
+ } // namespace chrono
}
+
diff --git a/libstdc++-v3/testsuite/20_util/monotonic_clock/constexpr_data.cc b/libstdc++-v3/testsuite/20_util/steady_clock/constexpr_data.cc
index 34477ea1838..2b497cfa35b 100644
--- a/libstdc++-v3/testsuite/20_util/monotonic_clock/constexpr_data.cc
+++ b/libstdc++-v3/testsuite/20_util/steady_clock/constexpr_data.cc
@@ -34,7 +34,7 @@ namespace __gnu_test
void __constraint()
{
constexpr auto v1 __attribute__((unused))
- = _Ttesttype::is_monotonic;
+ = _Ttesttype::is_steady;
}
};
@@ -47,6 +47,6 @@ namespace __gnu_test
int main()
{
__gnu_test::constexpr_member_data test;
- test.operator()<std::chrono::monotonic_clock>();
+ test.operator()<std::chrono::steady_clock>();
return 0;
}
diff --git a/libstdc++-v3/testsuite/20_util/system_clock/1.cc b/libstdc++-v3/testsuite/20_util/system_clock/1.cc
index ead20873c7b..77426e90ce1 100644
--- a/libstdc++-v3/testsuite/20_util/system_clock/1.cc
+++ b/libstdc++-v3/testsuite/20_util/system_clock/1.cc
@@ -1,7 +1,7 @@
// { dg-options "-std=gnu++0x" }
// { dg-require-cstdint "" }
-// Copyright (C) 2008, 2009, 2010 Free Software Foundation
+// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation
//
// 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
@@ -29,8 +29,8 @@ main()
using namespace std::chrono;
system_clock::time_point t1 = system_clock::now();
- bool is_monotonic = system_clock::is_monotonic;
- is_monotonic = is_monotonic; // suppress unused warning
+ bool is_steady = system_clock::is_steady;
+ is_steady = is_steady; // suppress unused warning
std::time_t t2 = system_clock::to_time_t(t1);
system_clock::time_point t3 = system_clock::from_time_t(t2);
t3 = t3; // suppress unused warning
diff --git a/libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc b/libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc
index 2407ef16a71..8312f536592 100644
--- a/libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc
+++ b/libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc
@@ -1,7 +1,7 @@
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
-// Copyright (C) 2010 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2011 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
@@ -34,7 +34,7 @@ namespace __gnu_test
void __constraint()
{
constexpr auto v1 __attribute__((unused))
- = _Ttesttype::is_monotonic;
+ = _Ttesttype::is_steady;
}
};
diff --git a/libstdc++-v3/testsuite/20_util/time_point/1.cc b/libstdc++-v3/testsuite/20_util/time_point/1.cc
index e18c6e58cf0..11a6ac49525 100644
--- a/libstdc++-v3/testsuite/20_util/time_point/1.cc
+++ b/libstdc++-v3/testsuite/20_util/time_point/1.cc
@@ -1,7 +1,7 @@
// { dg-options "-std=gnu++0x" }
// { dg-require-cstdint "" }
-// Copyright (C) 2008, 2009 Free Software Foundation
+// Copyright (C) 2008, 2009, 2011 Free Software Foundation
//
// 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
@@ -33,8 +33,8 @@ test01()
time_point<system_clock> t1;
VERIFY(t1.time_since_epoch() == system_clock::duration::zero());
- time_point<monotonic_clock> t2;
- VERIFY(t2.time_since_epoch() == monotonic_clock::duration::zero());
+ time_point<steady_clock> t2;
+ VERIFY(t2.time_since_epoch() == steady_clock::duration::zero());
time_point<high_resolution_clock> t3;
VERIFY(t3.time_since_epoch() == high_resolution_clock::duration::zero());
diff --git a/libstdc++-v3/testsuite/20_util/time_point/nonmember/constexpr.cc b/libstdc++-v3/testsuite/20_util/time_point/nonmember/constexpr.cc
new file mode 100644
index 00000000000..37b39f43133
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/time_point/nonmember/constexpr.cc
@@ -0,0 +1,45 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <chrono>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std::chrono;
+
+ typedef time_point<system_clock> time_type;
+
+ constexpr time_type t1(seconds(1));
+ constexpr time_type t2(seconds(30));
+ constexpr time_type t3(seconds(60));
+
+ constexpr duration<int> d0(12);
+ constexpr duration<int> d1(3);
+
+ constexpr auto r1 = t1 + d0;
+ constexpr auto r2 = d1 + t2;
+
+ constexpr auto r3 = t1 - d0;
+ constexpr auto r4 = t2 - t3;
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc b/libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc
index f4904ada547..0938bc46328 100644
--- a/libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc
+++ b/libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc
@@ -5,7 +5,7 @@
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
-// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2008, 2009, 2010, 2011 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
@@ -38,10 +38,10 @@ void test01()
std::mutex m;
std::unique_lock<std::mutex> l(m);
- auto then = std::chrono::monotonic_clock::now();
+ auto then = std::chrono::steady_clock::now();
std::cv_status result = c1.wait_until(l, then + ms);
VERIFY( result == std::cv_status::timeout );
- VERIFY( (std::chrono::monotonic_clock::now() - then) >= ms );
+ VERIFY( (std::chrono::steady_clock::now() - then) >= ms );
VERIFY( l.owns_lock() );
}
catch (const std::system_error& e)
diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable_any/members/2.cc b/libstdc++-v3/testsuite/30_threads/condition_variable_any/members/2.cc
index 8e58dce818b..3ad13a37928 100644
--- a/libstdc++-v3/testsuite/30_threads/condition_variable_any/members/2.cc
+++ b/libstdc++-v3/testsuite/30_threads/condition_variable_any/members/2.cc
@@ -5,7 +5,7 @@
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
-// Copyright (C) 2010 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2011 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
@@ -63,10 +63,10 @@ void test01()
Mutex m;
m.lock();
- auto then = std::chrono::monotonic_clock::now();
+ auto then = std::chrono::steady_clock::now();
std::cv_status result = c1.wait_until(m, then + ms);
VERIFY( result == std::cv_status::timeout );
- VERIFY( (std::chrono::monotonic_clock::now() - then) >= ms );
+ VERIFY( (std::chrono::steady_clock::now() - then) >= ms );
VERIFY( m.locked );
}
catch (const std::system_error& e)