summaryrefslogtreecommitdiff
path: root/libstdc++-v3/src/c++11/chrono.cc
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2013-06-26 18:39:06 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2013-06-26 18:39:06 +0000
commit21543d4cd558cada630271a0cf3075ad7ce94cbf (patch)
tree08bdb3f3e0a9d0f71e72bb56d9ddb7b916e7dfeb /libstdc++-v3/src/c++11/chrono.cc
parented0bc1ffb674fe93d0df68654b5bb76869f0bc8c (diff)
downloadgcc-21543d4cd558cada630271a0cf3075ad7ce94cbf.tar.gz
2013-06-26 Basile Starynkevitch <basile@starynkevitch.net>
{{merged with trunk [4.9] svn rev. 196654-200426}} MELT branch merged with trunk rev. 200426 using svnmerge.py [gcc/] 2013-06-26 Basile Starynkevitch <basile@starynkevitch.net> {{merge with trunk [4.9] svn rev. 196654-200426}} * melt-runtime.c (melt_val2passflag): TODO_ggc_collect & TODO_do_not_ggc_collect are conditionalized. * melt/generated/warmelt-first+03.cc: Manually remove calls to MELT_TRACE_EXIT_LOCATION macro. * melt/generated/warmelt-base+03.cc: Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@200430 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/src/c++11/chrono.cc')
-rw-r--r--libstdc++-v3/src/c++11/chrono.cc30
1 files changed, 26 insertions, 4 deletions
diff --git a/libstdc++-v3/src/c++11/chrono.cc b/libstdc++-v3/src/c++11/chrono.cc
index b45825ee9ad..ca10fb36881 100644
--- a/libstdc++-v3/src/c++11/chrono.cc
+++ b/libstdc++-v3/src/c++11/chrono.cc
@@ -22,23 +22,32 @@
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
+#include <bits/c++config.h>
#include <chrono>
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
-// conditional inclusion of sys/time.h for gettimeofday
+// Conditional inclusion of sys/time.h for gettimeofday
#if !defined(_GLIBCXX_USE_CLOCK_MONOTONIC) && \
!defined(_GLIBCXX_USE_CLOCK_REALTIME) && \
defined(_GLIBCXX_USE_GETTIMEOFDAY)
#include <sys/time.h>
#endif
+#ifdef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL
+#include <unistd.h>
+#include <sys/syscall.h>
+#endif
+
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace chrono
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
+
+ // XXX GLIBCXX_ABI Deprecated
+ inline namespace _V2 {
+
constexpr bool system_clock::is_steady;
system_clock::time_point
@@ -47,7 +56,11 @@ namespace std _GLIBCXX_VISIBILITY(default)
#ifdef _GLIBCXX_USE_CLOCK_REALTIME
timespec tp;
// -EINVAL, -EFAULT
+#ifdef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL
+ syscall(SYS_clock_gettime, CLOCK_REALTIME, &tp);
+#else
clock_gettime(CLOCK_REALTIME, &tp);
+#endif
return time_point(duration(chrono::seconds(tp.tv_sec)
+ chrono::nanoseconds(tp.tv_nsec)));
#elif defined(_GLIBCXX_USE_GETTIMEOFDAY)
@@ -61,20 +74,29 @@ namespace std _GLIBCXX_VISIBILITY(default)
return system_clock::from_time_t(__sec);
#endif
}
+
-#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
constexpr bool steady_clock::is_steady;
steady_clock::time_point
steady_clock::now() noexcept
{
+#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
timespec tp;
// -EINVAL, -EFAULT
+#ifdef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL
+ syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &tp);
+#else
clock_gettime(CLOCK_MONOTONIC, &tp);
+#endif
return time_point(duration(chrono::seconds(tp.tv_sec)
+ chrono::nanoseconds(tp.tv_nsec)));
- }
+#else
+ return time_point(system_clock::now().time_since_epoch());
#endif
+ }
+
+ } // end inline namespace _V2
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace chrono