summaryrefslogtreecommitdiff
path: root/boost/chrono/detail/inlined/mac/process_cpu_clocks.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/chrono/detail/inlined/mac/process_cpu_clocks.hpp')
-rw-r--r--boost/chrono/detail/inlined/mac/process_cpu_clocks.hpp43
1 files changed, 34 insertions, 9 deletions
diff --git a/boost/chrono/detail/inlined/mac/process_cpu_clocks.hpp b/boost/chrono/detail/inlined/mac/process_cpu_clocks.hpp
index 48753bdfc7..6d09e2cb3a 100644
--- a/boost/chrono/detail/inlined/mac/process_cpu_clocks.hpp
+++ b/boost/chrono/detail/inlined/mac/process_cpu_clocks.hpp
@@ -48,7 +48,7 @@ namespace boost
process_real_cpu_clock::time_point process_real_cpu_clock::now() BOOST_NOEXCEPT
{
-#if 0
+#if 1
tms tm;
clock_t c = ::times(&tm);
if (c == clock_t(-1)) // error
@@ -71,10 +71,18 @@ namespace boost
if (c == clock_t(-1)) // error
{
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
+ } else
+ {
+ long factor = chrono_detail::tick_factor();
+ if (factor != -1)
+ {
+ return time_point(nanoseconds(c * factor));
+ } else
+ {
+ BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
+ }
}
- return time_point(
- duration(c*(1000000000l/CLOCKS_PER_SEC))
- );
+ return time_point();
#endif
}
@@ -82,7 +90,7 @@ namespace boost
process_real_cpu_clock::time_point process_real_cpu_clock::now(system::error_code & ec)
{
-#if 0
+#if 1
tms tm;
clock_t c = ::times(&tm);
if (c == clock_t(-1)) // error
@@ -129,11 +137,28 @@ namespace boost
ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
return time_point();
}
+ } else
+ {
+ long factor = chrono_detail::tick_factor();
+ if (factor != -1)
+ {
+ if (!BOOST_CHRONO_IS_THROWS(ec))
+ {
+ ec.clear();
+ }
+ return time_point(nanoseconds(c * factor));
+ } else
+ {
+ if (BOOST_CHRONO_IS_THROWS(ec))
+ {
+ boost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_real_cpu_clock"));
+ } else
+ {
+ ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
+ return time_point();
+ }
+ }
}
- return time_point(
- duration(c*(1000000000l/CLOCKS_PER_SEC))
- );
-
#endif
}