summaryrefslogtreecommitdiff
path: root/boost/thread/pthread/timespec.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/thread/pthread/timespec.hpp')
-rw-r--r--boost/thread/pthread/timespec.hpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/boost/thread/pthread/timespec.hpp b/boost/thread/pthread/timespec.hpp
index 82f50f6ca7..74583ed0eb 100644
--- a/boost/thread/pthread/timespec.hpp
+++ b/boost/thread/pthread/timespec.hpp
@@ -75,6 +75,33 @@ namespace boost
{
timespec ts;
+#if defined CLOCK_MONOTONIC && defined BOOST_THREAD_USEFIXES_TIMESPEC
+ if ( ::clock_gettime( CLOCK_MONOTONIC, &ts ) )
+ {
+ ts.tv_sec = 0;
+ ts.tv_nsec = 0;
+ BOOST_ASSERT(0 && "Boost::Thread - Internal Error");
+ }
+#elif defined(BOOST_THREAD_TIMESPEC_MAC_API)
+ timeval tv;
+ ::gettimeofday(&tv, 0);
+ ts.tv_sec = tv.tv_sec;
+ ts.tv_nsec = tv.tv_usec * 1000;
+#else
+ if ( ::clock_gettime( CLOCK_REALTIME, &ts ) )
+ {
+ ts.tv_sec = 0;
+ ts.tv_nsec = 0;
+ BOOST_ASSERT(0 && "Boost::Thread - Internal Error");
+ }
+#endif
+ return ts;
+ }
+
+ inline timespec timespec_now_realtime()
+ {
+ timespec ts;
+
#if defined(BOOST_THREAD_TIMESPEC_MAC_API)
timeval tv;
::gettimeofday(&tv, 0);
@@ -83,6 +110,8 @@ namespace boost
#else
if ( ::clock_gettime( CLOCK_REALTIME, &ts ) )
{
+ ts.tv_sec = 0;
+ ts.tv_nsec = 0;
BOOST_ASSERT(0 && "Boost::Thread - Internal Error");
}
#endif