diff DEPENDENCIES/generic/include/boost/interprocess/sync/posix/ptime_to_timespec.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
line wrap: on
line diff
--- a/DEPENDENCIES/generic/include/boost/interprocess/sync/posix/ptime_to_timespec.hpp	Fri Sep 04 12:01:02 2015 +0100
+++ b/DEPENDENCIES/generic/include/boost/interprocess/sync/posix/ptime_to_timespec.hpp	Mon Sep 07 11:12:49 2015 +0100
@@ -11,6 +11,14 @@
 #ifndef BOOST_INTERPROCESS_DETAIL_PTIME_TO_TIMESPEC_HPP
 #define BOOST_INTERPROCESS_DETAIL_PTIME_TO_TIMESPEC_HPP
 
+#ifndef BOOST_CONFIG_HPP
+#  include <boost/config.hpp>
+#endif
+#
+#if defined(BOOST_HAS_PRAGMA_ONCE)
+#  pragma once
+#endif
+
 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
 
 namespace boost {
@@ -22,7 +30,9 @@
 inline timespec ptime_to_timespec (const boost::posix_time::ptime &tm)
 {
    const boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
-   boost::posix_time::time_duration duration (tm - epoch);
+   //Avoid negative absolute times
+   boost::posix_time::time_duration duration  = (tm <= epoch) ? boost::posix_time::time_duration(epoch - epoch)
+                                                              : boost::posix_time::time_duration(tm - epoch);
    timespec ts;
    ts.tv_sec  = duration.total_seconds();
    ts.tv_nsec = duration.total_nanoseconds() % 1000000000;