diff options
Diffstat (limited to 'boost/chrono/detail/inlined')
4 files changed, 45 insertions, 40 deletions
diff --git a/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp b/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp index d76d9356cf..5d5c4f4806 100644 --- a/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp +++ b/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp @@ -32,8 +32,8 @@ namespace chrono_detail factor = -1; else { - BOOST_ASSERT( factor <= 1000000l ); // doesn't handle large ticks - factor = 1000000l / factor; // compute factor + BOOST_ASSERT( factor <= 1000000000l ); // doesn't handle large ticks + factor = 1000000000l / factor; // compute factor if ( !factor ) factor = -1; } } @@ -54,7 +54,7 @@ process_real_cpu_clock::time_point process_real_cpu_clock::now() BOOST_NOEXCEPT if ( chrono_detail::tick_factor() != -1 ) { return time_point( - microseconds(c*chrono_detail::tick_factor())); + nanoseconds(c*chrono_detail::tick_factor())); } else { @@ -66,9 +66,9 @@ process_real_cpu_clock::time_point process_real_cpu_clock::now() BOOST_NOEXCEPT #if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING process_real_cpu_clock::time_point process_real_cpu_clock::now( - system::error_code & ec) + system::error_code & ec) { - + tms tm; clock_t c = ::times( &tm ); if ( c == clock_t(-1) ) // error @@ -76,9 +76,9 @@ process_real_cpu_clock::time_point process_real_cpu_clock::now( if (BOOST_CHRONO_IS_THROWS(ec)) { boost::throw_exception( - system::system_error( - errno, - BOOST_CHRONO_SYSTEM_CATEGORY, + system::system_error( + errno, + BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_real_cpu_clock" )); } else @@ -91,21 +91,21 @@ process_real_cpu_clock::time_point process_real_cpu_clock::now( { if ( chrono_detail::tick_factor() != -1 ) { - if (!BOOST_CHRONO_IS_THROWS(ec)) + if (!BOOST_CHRONO_IS_THROWS(ec)) { ec.clear(); } return time_point( - microseconds(c*chrono_detail::tick_factor())); + nanoseconds(c*chrono_detail::tick_factor())); } else { if (BOOST_CHRONO_IS_THROWS(ec)) { boost::throw_exception( - system::system_error( - errno, - BOOST_CHRONO_SYSTEM_CATEGORY, + system::system_error( + errno, + BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_real_cpu_clock" )); } else @@ -131,7 +131,7 @@ process_user_cpu_clock::time_point process_user_cpu_clock::now() BOOST_NOEXCEPT if ( chrono_detail::tick_factor() != -1 ) { return time_point( - microseconds((tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor())); + nanoseconds((tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor())); } else { @@ -152,9 +152,9 @@ process_user_cpu_clock::time_point process_user_cpu_clock::now( if (BOOST_CHRONO_IS_THROWS(ec)) { boost::throw_exception( - system::system_error( - errno, - BOOST_CHRONO_SYSTEM_CATEGORY, + system::system_error( + errno, + BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_user_cpu_clock" )); } else @@ -167,21 +167,21 @@ process_user_cpu_clock::time_point process_user_cpu_clock::now( { if ( chrono_detail::tick_factor() != -1 ) { - if (!BOOST_CHRONO_IS_THROWS(ec)) + if (!BOOST_CHRONO_IS_THROWS(ec)) { ec.clear(); } return time_point( - microseconds((tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor())); + nanoseconds((tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor())); } else { if (BOOST_CHRONO_IS_THROWS(ec)) { boost::throw_exception( - system::system_error( - errno, - BOOST_CHRONO_SYSTEM_CATEGORY, + system::system_error( + errno, + BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_user_cpu_clock" )); } else @@ -208,11 +208,12 @@ process_system_cpu_clock::time_point process_system_cpu_clock::now() BOOST_NOEXC if ( chrono_detail::tick_factor() != -1 ) { return time_point( - microseconds((tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor())); + nanoseconds((tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor())); } else { BOOST_ASSERT(0 && "Boost::Chrono - Internal Error"); + return time_point(); } } } @@ -248,7 +249,7 @@ process_system_cpu_clock::time_point process_system_cpu_clock::now( ec.clear(); } return time_point( - microseconds((tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor())); + nanoseconds((tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor())); } else { @@ -297,8 +298,8 @@ process_cpu_clock::time_point process_cpu_clock::now() BOOST_NOEXCEPT } #if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING -process_cpu_clock::time_point process_cpu_clock::now( - system::error_code & ec ) +process_cpu_clock::time_point process_cpu_clock::now( + system::error_code & ec ) { tms tm; clock_t c = ::times( &tm ); @@ -307,9 +308,9 @@ process_cpu_clock::time_point process_cpu_clock::now( if (BOOST_CHRONO_IS_THROWS(ec)) { boost::throw_exception( - system::system_error( - errno, - BOOST_CHRONO_SYSTEM_CATEGORY, + system::system_error( + errno, + BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_clock" )); } else @@ -333,9 +334,9 @@ process_cpu_clock::time_point process_cpu_clock::now( if (BOOST_CHRONO_IS_THROWS(ec)) { boost::throw_exception( - system::system_error( - errno, - BOOST_CHRONO_SYSTEM_CATEGORY, + system::system_error( + errno, + BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_clock" )); } else @@ -345,7 +346,7 @@ process_cpu_clock::time_point process_cpu_clock::now( } } } - + } #endif diff --git a/boost/chrono/detail/inlined/posix/thread_clock.hpp b/boost/chrono/detail/inlined/posix/thread_clock.hpp index 5ad41f84e3..42a544a0d6 100644 --- a/boost/chrono/detail/inlined/posix/thread_clock.hpp +++ b/boost/chrono/detail/inlined/posix/thread_clock.hpp @@ -15,6 +15,7 @@ #include <cassert> # include <sys/times.h> +# include <pthread.h> # include <unistd.h> namespace boost { namespace chrono { @@ -45,7 +46,7 @@ namespace boost { namespace chrono { } #if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING - thread_clock::time_point thread_clock::now( system::error_code & ec ) + thread_clock::time_point thread_clock::now( system::error_code & ec ) { struct timespec ts; #if defined CLOCK_THREAD_CPUTIME_ID @@ -64,9 +65,9 @@ namespace boost { namespace chrono { if (BOOST_CHRONO_IS_THROWS(ec)) { boost::throw_exception( - system::system_error( - errno, - BOOST_CHRONO_SYSTEM_CATEGORY, + system::system_error( + errno, + BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::thread_clock" )); } else @@ -75,7 +76,7 @@ namespace boost { namespace chrono { return time_point(); } } - if (!BOOST_CHRONO_IS_THROWS(ec)) + if (!BOOST_CHRONO_IS_THROWS(ec)) { ec.clear(); } diff --git a/boost/chrono/detail/inlined/win/chrono.hpp b/boost/chrono/detail/inlined/win/chrono.hpp index d953fe4bb4..75160dba97 100644 --- a/boost/chrono/detail/inlined/win/chrono.hpp +++ b/boost/chrono/detail/inlined/win/chrono.hpp @@ -42,6 +42,7 @@ namespace chrono_detail (!boost::detail::win32::QueryPerformanceCounter( &pcount )) ) { BOOST_ASSERT(0 && "Boost::Chrono - Internal Error"); + return steady_clock::time_point(); } return steady_clock::time_point(steady_clock::duration( diff --git a/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp b/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp index 6453aa600a..1b7e67a120 100644 --- a/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp +++ b/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp @@ -34,8 +34,9 @@ process_real_cpu_clock::time_point process_real_cpu_clock::now() BOOST_NOEXCEPT { BOOST_ASSERT(0 && "Boost::Chrono - Internal Error"); } + typedef ratio_divide<giga, ratio<CLOCKS_PER_SEC> >::type R; return time_point( - duration(c*(1000000000l/CLOCKS_PER_SEC)) + duration(static_cast<rep>(c)*R::num/R::den) ); } @@ -56,8 +57,9 @@ process_real_cpu_clock::time_point process_real_cpu_clock::now( { ec.clear(); } + typedef ratio_divide<giga, ratio<CLOCKS_PER_SEC> >::type R; return time_point( - duration(c*(1000000000l/CLOCKS_PER_SEC)) + duration(static_cast<rep>(c)*R::num/R::den) ); } #endif |