|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r74453 - in trunk/boost/chrono/detail/inlined: posix win
From: vicente.botet_at_[hidden]
Date: 2011-09-18 13:58:28
Author: viboes
Date: 2011-09-18 13:58:27 EDT (Sun, 18 Sep 2011)
New Revision: 74453
URL: http://svn.boost.org/trac/boost/changeset/74453
Log:
Chrono: Fiw some error on cygwin and windows related to process clocks
Text files modified:
trunk/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp | 77 ++++++++++++++-------------------------
trunk/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp | 36 ++++++++++++++++--
2 files changed, 58 insertions(+), 55 deletions(-)
Modified: trunk/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp
==============================================================================
--- trunk/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp (original)
+++ trunk/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp 2011-09-18 13:58:27 EDT (Sun, 18 Sep 2011)
@@ -54,7 +54,7 @@
if ( chrono_detail::tick_factor() != -1 )
{
return time_point(
- microseconds(c)*chrono_detail::tick_factor());
+ microseconds(c*chrono_detail::tick_factor()));
}
else
{
@@ -94,7 +94,7 @@
ec.clear();
}
return time_point(
- microseconds(c)*chrono_detail::tick_factor());
+ microseconds(c*chrono_detail::tick_factor()));
}
else
{
@@ -128,7 +128,7 @@
if ( chrono_detail::tick_factor() != -1 )
{
return time_point(
- microseconds(tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor());
+ microseconds((tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor()));
}
else
{
@@ -168,7 +168,7 @@
ec.clear();
}
return time_point(
- microseconds(tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor());
+ microseconds((tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor()));
}
else
{
@@ -189,30 +189,6 @@
}
}
-process_user_cpu_clock::time_point process_user_cpu_clock::now() BOOST_CHRONO_NOEXCEPT
-{
- tms tm;
- clock_t c = ::times( &tm );
- if ( c == clock_t(-1) ) // error
- {
- BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
- }
- else
- {
- if ( chrono_detail::tick_factor() != -1 )
- {
- return time_point(
- microseconds(tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor());
- }
- else
- {
- BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
- }
- }
- return time_point();
-}
-
-
process_system_cpu_clock::time_point process_system_cpu_clock::now() BOOST_CHRONO_NOEXCEPT
{
tms tm;
@@ -227,7 +203,7 @@
if ( chrono_detail::tick_factor() != -1 )
{
return time_point(
- microseconds(tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor());
+ microseconds((tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor()));
}
else
{
@@ -236,8 +212,8 @@
}
}
-process_cpu_clock::time_point process_cpu_clock::now(
- system::error_code & ec )
+process_system_cpu_clock::time_point process_system_cpu_clock::now(
+ system::error_code & ec)
{
tms tm;
clock_t c = ::times( &tm );
@@ -246,10 +222,10 @@
if (BOOST_CHRONO_IS_THROWS(ec))
{
boost::throw_exception(
- system::system_error(
- errno,
- BOOST_CHRONO_SYSTEM_CATEGORY,
- "chrono::process_clock" ));
+ system::system_error(
+ errno,
+ BOOST_CHRONO_SYSTEM_CATEGORY,
+ "chrono::process_system_cpu_clock" ));
}
else
{
@@ -261,21 +237,22 @@
{
if ( chrono_detail::tick_factor() != -1 )
{
- time_point::rep r(
- c*chrono_detail::tick_factor(),
- (tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor(),
- (tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor());
- return time_point(duration(r));
+ if (!BOOST_CHRONO_IS_THROWS(ec))
+ {
+ ec.clear();
+ }
+ return time_point(
+ microseconds((tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor()));
}
else
{
if (BOOST_CHRONO_IS_THROWS(ec))
{
boost::throw_exception(
- system::system_error(
- errno,
- BOOST_CHRONO_SYSTEM_CATEGORY,
- "chrono::process_clock" ));
+ system::system_error(
+ errno,
+ BOOST_CHRONO_SYSTEM_CATEGORY,
+ "chrono::process_system_cpu_clock" ));
}
else
{
@@ -299,9 +276,9 @@
if ( chrono_detail::tick_factor() != -1 )
{
time_point::rep r(
- c*chrono_detail::tick_factor(),
- (tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor(),
- (tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor());
+ 1000*c*chrono_detail::tick_factor(),
+ 1000*(tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor(),
+ 1000*(tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor());
return time_point(duration(r));
}
else
@@ -337,9 +314,9 @@
if ( chrono_detail::tick_factor() != -1 )
{
time_point::rep r(
- c*chrono_detail::tick_factor(),
- (tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor(),
- (tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor());
+ 1000*c*chrono_detail::tick_factor(),
+ 1000*(tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor(),
+ 1000*(tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor());
return time_point(duration(r));
}
else
Modified: trunk/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp
==============================================================================
--- trunk/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp (original)
+++ trunk/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp 2011-09-18 13:58:27 EDT (Sun, 18 Sep 2011)
@@ -13,7 +13,7 @@
#define BOOST_CHRONO_DETAIL_INLINED_WIN_PROCESS_CLOCK_HPP
#include <boost/chrono/config.hpp>
-#include <boost/chrono/system_clocks.hpp>
+//#include <boost/chrono/system_clocks.hpp>
#include <boost/chrono/process_cpu_clocks.hpp>
#include <cassert>
@@ -36,7 +36,13 @@
boost::detail::win32::GetCurrentProcess(), &creation, &exit,
&system_time, &user_time ) )
{
- return time_point(steady_clock::now().time_since_epoch());
+ return time_point(duration(
+ ((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32)
+ | user_time.dwLowDateTime) * 100
+ +
+ ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32)
+ | system_time.dwLowDateTime) * 100
+ ));
}
else
{
@@ -60,7 +66,13 @@
{
ec.clear();
}
- return time_point(steady_clock::now().time_since_epoch());
+ return time_point(duration(
+ ((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32)
+ | user_time.dwLowDateTime) * 100
+ +
+ ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32)
+ | system_time.dwLowDateTime) * 100
+ ));
}
else
{
@@ -218,7 +230,14 @@
&system_time, &user_time ) )
{
time_point::rep r(
- steady_clock::now().time_since_epoch().count(),
+ ((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32)
+ | user_time.dwLowDateTime
+ ) * 100
+ +
+ ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32)
+ | system_time.dwLowDateTime
+ ) * 100
+ ,
((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32)
| user_time.dwLowDateTime
) * 100,
@@ -252,7 +271,14 @@
ec.clear();
}
time_point::rep r(
- steady_clock::now().time_since_epoch().count(),
+ ((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32)
+ | user_time.dwLowDateTime
+ ) * 100
+ +
+ ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32)
+ | system_time.dwLowDateTime
+ ) * 100
+ ,
((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32)
| user_time.dwLowDateTime
) * 100,
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk