summaryrefslogtreecommitdiff
path: root/boost/chrono/detail
diff options
context:
space:
mode:
Diffstat (limited to 'boost/chrono/detail')
-rw-r--r--boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp67
-rw-r--r--boost/chrono/detail/inlined/posix/thread_clock.hpp11
-rw-r--r--boost/chrono/detail/inlined/win/chrono.hpp1
-rw-r--r--boost/chrono/detail/inlined/win/process_cpu_clocks.hpp6
-rw-r--r--boost/chrono/detail/no_warning/signed_unsigned_cmp.hpp2
-rw-r--r--boost/chrono/detail/scan_keyword.hpp7
-rw-r--r--boost/chrono/detail/system.hpp5
7 files changed, 54 insertions, 45 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
diff --git a/boost/chrono/detail/no_warning/signed_unsigned_cmp.hpp b/boost/chrono/detail/no_warning/signed_unsigned_cmp.hpp
index 78a0ce13e7..491c1d64a0 100644
--- a/boost/chrono/detail/no_warning/signed_unsigned_cmp.hpp
+++ b/boost/chrono/detail/no_warning/signed_unsigned_cmp.hpp
@@ -41,4 +41,4 @@ namespace detail {
} // namespace detail
} // namespace chrono
-#endif // BOOST_CHRONO_DETAIL_IS_EVENLY_DIVISIBLE_BY_HPP
+#endif // BOOST_CHRONO_DETAIL_NO_WARNING_SIGNED_UNSIGNED_CMP_HPP
diff --git a/boost/chrono/detail/scan_keyword.hpp b/boost/chrono/detail/scan_keyword.hpp
index 13ad0ca8c8..7c3ba6e2af 100644
--- a/boost/chrono/detail/scan_keyword.hpp
+++ b/boost/chrono/detail/scan_keyword.hpp
@@ -23,10 +23,11 @@
#include <ios>
#include <exception>
#include <stdlib.h>
+#include <boost/throw_exception.hpp>
namespace boost {
using interprocess::unique_ptr;
-
+
namespace chrono {
namespace chrono_detail {
@@ -65,13 +66,13 @@ scan_keyword(InputIterator& b, InputIterator e,
unsigned char statbuf[100];
unsigned char* status = statbuf;
// Change free by free_aux to avoid
- // Error: Could not find a match for boost::interprocess::unique_ptr<unsigned char, void(*)(void*)>::unique_ptr(int, extern "C" void(void*))
+ // Error: Could not find a match for boost::interprocess::unique_ptr<unsigned char, void(*)(void*)>::unique_ptr(int, extern "C" void(void*))
unique_ptr<unsigned char, void(*)(void*)> stat_hold(0, free_aux);
if (nkw > sizeof(statbuf))
{
status = (unsigned char*)malloc(nkw);
if (status == 0)
- throw std::bad_alloc();
+ throw_exception(std::bad_alloc());
stat_hold.reset(status);
}
size_t n_might_match = nkw; // At this point, any keyword might match
diff --git a/boost/chrono/detail/system.hpp b/boost/chrono/detail/system.hpp
index f8a40f12a8..0dcffe8521 100644
--- a/boost/chrono/detail/system.hpp
+++ b/boost/chrono/detail/system.hpp
@@ -6,6 +6,8 @@
#ifndef BOOST_CHRONO_DETAIL_SYSTEM_HPP
#define BOOST_CHRONO_DETAIL_SYSTEM_HPP
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+
#include <boost/version.hpp>
#include <boost/system/error_code.hpp>
@@ -15,7 +17,7 @@
#define BOOST_CHRONO_SYSTEM_CATEGORY boost::system::system_category()
#endif
-#ifdef BOOST_SYSTEM_NO_DEPRECATED
+#ifdef BOOST_SYSTEM_NO_DEPRECATED
#define BOOST_CHRONO_THROWS boost::throws()
#define BOOST_CHRONO_IS_THROWS(EC) (&EC==&boost::throws())
#else
@@ -24,3 +26,4 @@
#endif
#endif
+#endif