annotate DEPENDENCIES/generic/include/boost/interprocess/sync/posix/ptime_to_timespec.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 //////////////////////////////////////////////////////////////////////////////
Chris@16 2 //
Chris@16 3 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
Chris@16 4 // Software License, Version 1.0. (See accompanying file
Chris@16 5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 //
Chris@16 7 // See http://www.boost.org/libs/interprocess for documentation.
Chris@16 8 //
Chris@16 9 //////////////////////////////////////////////////////////////////////////////
Chris@16 10
Chris@16 11 #ifndef BOOST_INTERPROCESS_DETAIL_PTIME_TO_TIMESPEC_HPP
Chris@16 12 #define BOOST_INTERPROCESS_DETAIL_PTIME_TO_TIMESPEC_HPP
Chris@16 13
Chris@101 14 #ifndef BOOST_CONFIG_HPP
Chris@101 15 # include <boost/config.hpp>
Chris@101 16 #endif
Chris@101 17 #
Chris@101 18 #if defined(BOOST_HAS_PRAGMA_ONCE)
Chris@101 19 # pragma once
Chris@101 20 #endif
Chris@101 21
Chris@16 22 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
Chris@16 23
Chris@16 24 namespace boost {
Chris@16 25
Chris@16 26 namespace interprocess {
Chris@16 27
Chris@16 28 namespace ipcdetail {
Chris@16 29
Chris@16 30 inline timespec ptime_to_timespec (const boost::posix_time::ptime &tm)
Chris@16 31 {
Chris@16 32 const boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
Chris@101 33 //Avoid negative absolute times
Chris@101 34 boost::posix_time::time_duration duration = (tm <= epoch) ? boost::posix_time::time_duration(epoch - epoch)
Chris@101 35 : boost::posix_time::time_duration(tm - epoch);
Chris@16 36 timespec ts;
Chris@16 37 ts.tv_sec = duration.total_seconds();
Chris@16 38 ts.tv_nsec = duration.total_nanoseconds() % 1000000000;
Chris@16 39 return ts;
Chris@16 40 }
Chris@16 41
Chris@16 42 } //namespace ipcdetail {
Chris@16 43
Chris@16 44 } //namespace interprocess {
Chris@16 45
Chris@16 46 } //namespace boost {
Chris@16 47
Chris@16 48 #endif //ifndef BOOST_INTERPROCESS_DETAIL_PTIME_TO_TIMESPEC_HPP