File indexing completed on 2025-12-15 10:09:32
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_XTIME_WEK070601_HPP
0009 #define BOOST_XTIME_WEK070601_HPP
0010
0011 #include <boost/thread/detail/config.hpp>
0012 #if defined BOOST_THREAD_USES_DATETIME
0013
0014 #include <boost/cstdint.hpp>
0015 #include <boost/thread/thread_time.hpp>
0016 #include <boost/date_time/posix_time/conversion.hpp>
0017
0018 #include <boost/config/abi_prefix.hpp>
0019
0020 namespace boost {
0021
0022 enum xtime_clock_types
0023 {
0024 TIME_UTC_=1
0025
0026
0027
0028
0029
0030
0031
0032 };
0033
0034 struct xtime
0035 {
0036 #if defined(BOOST_NO_INT64_T)
0037 typedef int_fast32_t xtime_sec_t;
0038 #else
0039 typedef int_fast64_t xtime_sec_t;
0040 #endif
0041
0042 typedef int_fast32_t xtime_nsec_t;
0043
0044 xtime_sec_t sec;
0045 xtime_nsec_t nsec;
0046
0047 operator system_time() const
0048 {
0049 return boost::posix_time::from_time_t(0)+
0050 boost::posix_time::seconds(static_cast<long>(sec))+
0051 #ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
0052 boost::posix_time::nanoseconds(nsec);
0053 #else
0054 boost::posix_time::microseconds((nsec+500)/1000);
0055 #endif
0056 }
0057
0058 };
0059
0060 inline ::boost::xtime get_xtime(boost::system_time const& abs_time)
0061 {
0062 ::boost::xtime res;
0063 boost::posix_time::time_duration const time_since_epoch=abs_time-boost::posix_time::from_time_t(0);
0064
0065 res.sec=static_cast< ::boost::xtime::xtime_sec_t>(time_since_epoch.total_seconds());
0066 res.nsec=static_cast< ::boost::xtime::xtime_nsec_t>(time_since_epoch.fractional_seconds()*(1000000000/time_since_epoch.ticks_per_second()));
0067 return res;
0068 }
0069
0070 inline int xtime_get(struct ::boost::xtime* xtp, int clock_type)
0071 {
0072 if (clock_type == TIME_UTC_)
0073 {
0074 *xtp=get_xtime(get_system_time());
0075 return clock_type;
0076 }
0077 return 0;
0078 }
0079
0080
0081 inline int xtime_cmp(const ::boost::xtime& xt1, const ::boost::xtime& xt2)
0082 {
0083 if (xt1.sec == xt2.sec)
0084 return (int)(xt1.nsec - xt2.nsec);
0085 else
0086 return (xt1.sec > xt2.sec) ? 1 : -1;
0087 }
0088
0089 }
0090
0091 #include <boost/config/abi_suffix.hpp>
0092 #endif
0093 #endif