Imported Upstream version 1.64.0
[platform/upstream/boost.git] / boost / thread / pthread / timespec.hpp
index 82f50f6..74583ed 100644 (file)
@@ -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