Mercurial > hg > vamp-build-and-test
comparison 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 |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
9 ////////////////////////////////////////////////////////////////////////////// | 9 ////////////////////////////////////////////////////////////////////////////// |
10 | 10 |
11 #ifndef BOOST_INTERPROCESS_DETAIL_PTIME_TO_TIMESPEC_HPP | 11 #ifndef BOOST_INTERPROCESS_DETAIL_PTIME_TO_TIMESPEC_HPP |
12 #define BOOST_INTERPROCESS_DETAIL_PTIME_TO_TIMESPEC_HPP | 12 #define BOOST_INTERPROCESS_DETAIL_PTIME_TO_TIMESPEC_HPP |
13 | 13 |
14 #ifndef BOOST_CONFIG_HPP | |
15 # include <boost/config.hpp> | |
16 #endif | |
17 # | |
18 #if defined(BOOST_HAS_PRAGMA_ONCE) | |
19 # pragma once | |
20 #endif | |
21 | |
14 #include <boost/interprocess/detail/posix_time_types_wrk.hpp> | 22 #include <boost/interprocess/detail/posix_time_types_wrk.hpp> |
15 | 23 |
16 namespace boost { | 24 namespace boost { |
17 | 25 |
18 namespace interprocess { | 26 namespace interprocess { |
20 namespace ipcdetail { | 28 namespace ipcdetail { |
21 | 29 |
22 inline timespec ptime_to_timespec (const boost::posix_time::ptime &tm) | 30 inline timespec ptime_to_timespec (const boost::posix_time::ptime &tm) |
23 { | 31 { |
24 const boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1)); | 32 const boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1)); |
25 boost::posix_time::time_duration duration (tm - epoch); | 33 //Avoid negative absolute times |
34 boost::posix_time::time_duration duration = (tm <= epoch) ? boost::posix_time::time_duration(epoch - epoch) | |
35 : boost::posix_time::time_duration(tm - epoch); | |
26 timespec ts; | 36 timespec ts; |
27 ts.tv_sec = duration.total_seconds(); | 37 ts.tv_sec = duration.total_seconds(); |
28 ts.tv_nsec = duration.total_nanoseconds() % 1000000000; | 38 ts.tv_nsec = duration.total_nanoseconds() % 1000000000; |
29 return ts; | 39 return ts; |
30 } | 40 } |