summaryrefslogtreecommitdiff
path: root/src/third_party/boost-1.69.0/boost/chrono/detail/inlined/win
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/boost-1.69.0/boost/chrono/detail/inlined/win')
-rw-r--r--src/third_party/boost-1.69.0/boost/chrono/detail/inlined/win/chrono.hpp150
-rw-r--r--src/third_party/boost-1.69.0/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp281
-rw-r--r--src/third_party/boost-1.69.0/boost/chrono/detail/inlined/win/thread_clock.hpp103
3 files changed, 534 insertions, 0 deletions
diff --git a/src/third_party/boost-1.69.0/boost/chrono/detail/inlined/win/chrono.hpp b/src/third_party/boost-1.69.0/boost/chrono/detail/inlined/win/chrono.hpp
new file mode 100644
index 00000000000..570dc02a15b
--- /dev/null
+++ b/src/third_party/boost-1.69.0/boost/chrono/detail/inlined/win/chrono.hpp
@@ -0,0 +1,150 @@
+// win/chrono.cpp --------------------------------------------------------------//
+
+// Copyright Beman Dawes 2008
+// Copyright 2009-2010 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+//----------------------------------------------------------------------------//
+// Windows //
+//----------------------------------------------------------------------------//
+#ifndef BOOST_CHRONO_DETAIL_INLINED_WIN_CHRONO_HPP
+#define BOOST_CHRONO_DETAIL_INLINED_WIN_CHRONO_HPP
+
+#include <boost/winapi/time.hpp>
+#include <boost/winapi/timers.hpp>
+#include <boost/winapi/get_last_error.hpp>
+#include <boost/assert.hpp>
+
+namespace boost
+{
+namespace chrono
+{
+namespace chrono_detail
+{
+
+ BOOST_CHRONO_INLINE double get_nanosecs_per_tic() BOOST_NOEXCEPT
+ {
+ boost::winapi::LARGE_INTEGER_ freq;
+ if ( !boost::winapi::QueryPerformanceFrequency( &freq ) )
+ return 0.0L;
+ return double(1000000000.0L / freq.QuadPart);
+ }
+
+}
+
+ steady_clock::time_point steady_clock::now() BOOST_NOEXCEPT
+ {
+ double nanosecs_per_tic = chrono_detail::get_nanosecs_per_tic();
+
+ boost::winapi::LARGE_INTEGER_ pcount;
+ if ( nanosecs_per_tic <= 0.0L )
+ {
+ BOOST_ASSERT(0 && "Boost::Chrono - get_nanosecs_per_tic Internal Error");
+ return steady_clock::time_point();
+ }
+ unsigned times=0;
+ while ( ! boost::winapi::QueryPerformanceCounter( &pcount ) )
+ {
+ if ( ++times > 3 )
+ {
+ BOOST_ASSERT(0 && "Boost::Chrono - QueryPerformanceCounter Internal Error");
+ return steady_clock::time_point();
+ }
+ }
+
+ return steady_clock::time_point(steady_clock::duration(
+ static_cast<steady_clock::rep>((nanosecs_per_tic) * pcount.QuadPart)));
+ }
+
+
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ steady_clock::time_point steady_clock::now( system::error_code & ec )
+ {
+ double nanosecs_per_tic = chrono_detail::get_nanosecs_per_tic();
+
+ boost::winapi::LARGE_INTEGER_ pcount;
+ if ( (nanosecs_per_tic <= 0.0L)
+ || (!boost::winapi::QueryPerformanceCounter( &pcount )) )
+ {
+ boost::winapi::DWORD_ cause =
+ ((nanosecs_per_tic <= 0.0L)
+ ? ERROR_NOT_SUPPORTED
+ : boost::winapi::GetLastError());
+ if (::boost::chrono::is_throws(ec)) {
+ boost::throw_exception(
+ system::system_error(
+ cause,
+ ::boost::system::system_category(),
+ "chrono::steady_clock" ));
+ }
+ else
+ {
+ ec.assign( cause, ::boost::system::system_category() );
+ return steady_clock::time_point(duration(0));
+ }
+ }
+
+ if (!::boost::chrono::is_throws(ec))
+ {
+ ec.clear();
+ }
+ return time_point(duration(
+ static_cast<steady_clock::rep>(nanosecs_per_tic * pcount.QuadPart)));
+ }
+#endif
+
+ BOOST_CHRONO_INLINE
+ system_clock::time_point system_clock::now() BOOST_NOEXCEPT
+ {
+ boost::winapi::FILETIME_ ft;
+ boost::winapi::GetSystemTimeAsFileTime( &ft ); // never fails
+ return system_clock::time_point(
+ system_clock::duration(
+ ((static_cast<__int64>( ft.dwHighDateTime ) << 32) | ft.dwLowDateTime)
+ - 116444736000000000LL
+ //- (134775LL*864000000000LL)
+ )
+ );
+ }
+
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ BOOST_CHRONO_INLINE
+ system_clock::time_point system_clock::now( system::error_code & ec )
+ {
+ boost::winapi::FILETIME_ ft;
+ boost::winapi::GetSystemTimeAsFileTime( &ft ); // never fails
+ if (!::boost::chrono::is_throws(ec))
+ {
+ ec.clear();
+ }
+ return system_clock::time_point(
+ system_clock::duration(
+ ((static_cast<__int64>( ft.dwHighDateTime ) << 32) | ft.dwLowDateTime)
+ - 116444736000000000LL
+ //- (134775LL*864000000000LL)
+ ));
+ }
+#endif
+
+ BOOST_CHRONO_INLINE
+ std::time_t system_clock::to_time_t(const system_clock::time_point& t) BOOST_NOEXCEPT
+ {
+ __int64 temp = t.time_since_epoch().count();
+ temp /= 10000000;
+ return static_cast<std::time_t>( temp );
+ }
+
+ BOOST_CHRONO_INLINE
+ system_clock::time_point system_clock::from_time_t(std::time_t t) BOOST_NOEXCEPT
+ {
+ __int64 temp = t;
+ temp *= 10000000;
+ return time_point(duration(temp));
+ }
+
+} // namespace chrono
+} // namespace boost
+
+#endif
diff --git a/src/third_party/boost-1.69.0/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp b/src/third_party/boost-1.69.0/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp
new file mode 100644
index 00000000000..a3a838a5cee
--- /dev/null
+++ b/src/third_party/boost-1.69.0/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp
@@ -0,0 +1,281 @@
+// boost process_timer.cpp -----------------------------------------------------------//
+
+// Copyright Beman Dawes 1994, 2006, 2008
+// Copyright 2009-2010 Vicente J. Botet Escriba
+// Copyright (c) Microsoft Corporation 2014
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/chrono for documentation.
+
+//--------------------------------------------------------------------------------------//
+#ifndef BOOST_CHRONO_DETAIL_INLINED_WIN_PROCESS_CLOCK_HPP
+#define BOOST_CHRONO_DETAIL_INLINED_WIN_PROCESS_CLOCK_HPP
+
+#include <boost/chrono/config.hpp>
+#include <boost/chrono/process_cpu_clocks.hpp>
+#include <cassert>
+#include <time.h>
+#include <boost/assert.hpp>
+
+#include <boost/detail/winapi/get_last_error.hpp>
+#include <boost/detail/winapi/get_current_process.hpp>
+#if BOOST_PLAT_WINDOWS_DESKTOP
+#include <boost/detail/winapi/get_process_times.hpp>
+#endif
+
+namespace boost
+{
+namespace chrono
+{
+
+process_real_cpu_clock::time_point process_real_cpu_clock::now() BOOST_NOEXCEPT
+{
+ clock_t c = ::clock();
+ if ( c == clock_t(-1) ) // error
+ {
+ BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
+ }
+ typedef ratio_divide<giga, ratio<CLOCKS_PER_SEC> >::type R;
+ return time_point(
+ duration(static_cast<rep>(c)*R::num/R::den)
+ );
+}
+
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+process_real_cpu_clock::time_point process_real_cpu_clock::now(
+ system::error_code & ec)
+{
+ clock_t c = ::clock();
+ if ( c == clock_t(-1) ) // error
+ {
+ boost::throw_exception(
+ system::system_error(
+ errno,
+ ::boost::system::system_category(),
+ "chrono::process_real_cpu_clock" ));
+ }
+ if (!::boost::chrono::is_throws(ec))
+ {
+ ec.clear();
+ }
+ typedef ratio_divide<giga, ratio<CLOCKS_PER_SEC> >::type R;
+ return time_point(
+ duration(static_cast<rep>(c)*R::num/R::den)
+ );
+}
+#endif
+
+#if BOOST_PLAT_WINDOWS_DESKTOP
+process_user_cpu_clock::time_point process_user_cpu_clock::now() BOOST_NOEXCEPT
+{
+
+ // note that Windows uses 100 nanosecond ticks for FILETIME
+ boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
+
+ if ( boost::detail::winapi::GetProcessTimes(
+ boost::detail::winapi::GetCurrentProcess(), &creation, &exit,
+ &system_time, &user_time ) )
+ {
+ return time_point(duration(
+ ((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32)
+ | user_time.dwLowDateTime) * 100
+ ));
+ }
+ else
+ {
+ BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
+ return time_point();
+ }
+
+}
+
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+process_user_cpu_clock::time_point process_user_cpu_clock::now(
+ system::error_code & ec)
+{
+
+ // note that Windows uses 100 nanosecond ticks for FILETIME
+ boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
+
+ if ( boost::detail::winapi::GetProcessTimes(
+ boost::detail::winapi::GetCurrentProcess(), &creation, &exit,
+ &system_time, &user_time ) )
+ {
+ if (!::boost::chrono::is_throws(ec))
+ {
+ ec.clear();
+ }
+ return time_point(duration(
+ ((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32)
+ | user_time.dwLowDateTime) * 100
+ ));
+ }
+ else
+ {
+ boost::detail::winapi::DWORD_ cause = boost::detail::winapi::GetLastError();
+ if (::boost::chrono::is_throws(ec))
+ {
+ boost::throw_exception(
+ system::system_error(
+ cause,
+ ::boost::system::system_category(),
+ "chrono::process_user_cpu_clock" ));
+ }
+ else
+ {
+ ec.assign( cause, ::boost::system::system_category() );
+ return time_point();
+ }
+ }
+
+}
+#endif
+
+process_system_cpu_clock::time_point process_system_cpu_clock::now() BOOST_NOEXCEPT
+{
+
+ // note that Windows uses 100 nanosecond ticks for FILETIME
+ boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
+
+ if ( boost::detail::winapi::GetProcessTimes(
+ boost::detail::winapi::GetCurrentProcess(), &creation, &exit,
+ &system_time, &user_time ) )
+ {
+ return time_point(duration(
+ ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32)
+ | system_time.dwLowDateTime) * 100
+ ));
+ }
+ else
+ {
+ BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
+ return time_point();
+ }
+
+}
+
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+process_system_cpu_clock::time_point process_system_cpu_clock::now(
+ system::error_code & ec)
+{
+
+ // note that Windows uses 100 nanosecond ticks for FILETIME
+ boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
+
+ if ( boost::detail::winapi::GetProcessTimes(
+ boost::detail::winapi::GetCurrentProcess(), &creation, &exit,
+ &system_time, &user_time ) )
+ {
+ if (!::boost::chrono::is_throws(ec))
+ {
+ ec.clear();
+ }
+ return time_point(duration(
+ ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32)
+ | system_time.dwLowDateTime) * 100
+ ));
+ }
+ else
+ {
+ boost::detail::winapi::DWORD_ cause = boost::detail::winapi::GetLastError();
+ if (::boost::chrono::is_throws(ec))
+ {
+ boost::throw_exception(
+ system::system_error(
+ cause,
+ ::boost::system::system_category(),
+ "chrono::process_system_cpu_clock" ));
+ }
+ else
+ {
+ ec.assign( cause, ::boost::system::system_category() );
+ return time_point();
+ }
+ }
+
+}
+#endif
+
+process_cpu_clock::time_point process_cpu_clock::now() BOOST_NOEXCEPT
+{
+
+ // note that Windows uses 100 nanosecond ticks for FILETIME
+ boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
+
+ if ( boost::detail::winapi::GetProcessTimes(
+ boost::detail::winapi::GetCurrentProcess(), &creation, &exit,
+ &system_time, &user_time ) )
+ {
+ time_point::rep r(process_real_cpu_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
+ );
+ return time_point(duration(r));
+ }
+ else
+ {
+ BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
+ return time_point();
+ }
+
+}
+
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+process_cpu_clock::time_point process_cpu_clock::now(
+ system::error_code & ec )
+{
+
+ // note that Windows uses 100 nanosecond ticks for FILETIME
+ boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
+
+ if ( boost::detail::winapi::GetProcessTimes(
+ boost::detail::winapi::GetCurrentProcess(), &creation, &exit,
+ &system_time, &user_time ) )
+ {
+ if (!::boost::chrono::is_throws(ec))
+ {
+ ec.clear();
+ }
+ time_point::rep r(process_real_cpu_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
+ );
+ return time_point(duration(r));
+ }
+ else
+ {
+ boost::detail::winapi::DWORD_ cause = boost::detail::winapi::GetLastError();
+ if (::boost::chrono::is_throws(ec))
+ {
+ boost::throw_exception(
+ system::system_error(
+ cause,
+ ::boost::system::system_category(),
+ "chrono::process_cpu_clock" ));
+ }
+ else
+ {
+ ec.assign( cause, ::boost::system::system_category() );
+ return time_point();
+ }
+ }
+
+}
+#endif
+#endif
+} // namespace chrono
+} // namespace boost
+
+#endif
diff --git a/src/third_party/boost-1.69.0/boost/chrono/detail/inlined/win/thread_clock.hpp b/src/third_party/boost-1.69.0/boost/chrono/detail/inlined/win/thread_clock.hpp
new file mode 100644
index 00000000000..776e5b4cd0c
--- /dev/null
+++ b/src/third_party/boost-1.69.0/boost/chrono/detail/inlined/win/thread_clock.hpp
@@ -0,0 +1,103 @@
+// boost thread_clock.cpp -----------------------------------------------------------//
+
+// Copyright 2010 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/chrono for documentation.
+
+//--------------------------------------------------------------------------------------//
+#ifndef BOOST_CHRONO_DETAIL_INLINED_WIN_THREAD_CLOCK_HPP
+#define BOOST_CHRONO_DETAIL_INLINED_WIN_THREAD_CLOCK_HPP
+
+#include <boost/chrono/config.hpp>
+#include <boost/chrono/thread_clock.hpp>
+#include <cassert>
+#include <boost/assert.hpp>
+
+#include <boost/detail/winapi/get_last_error.hpp>
+#include <boost/detail/winapi/get_current_thread.hpp>
+#include <boost/detail/winapi/get_thread_times.hpp>
+
+namespace boost
+{
+namespace chrono
+{
+
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+thread_clock::time_point thread_clock::now( system::error_code & ec )
+{
+ // note that Windows uses 100 nanosecond ticks for FILETIME
+ boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
+
+ if ( boost::detail::winapi::GetThreadTimes(
+ boost::detail::winapi::GetCurrentThread (), &creation, &exit,
+ &system_time, &user_time ) )
+ {
+ duration user = duration(
+ ((static_cast<duration::rep>(user_time.dwHighDateTime) << 32)
+ | user_time.dwLowDateTime) * 100 );
+
+ duration system = duration(
+ ((static_cast<duration::rep>(system_time.dwHighDateTime) << 32)
+ | system_time.dwLowDateTime) * 100 );
+
+ if (!::boost::chrono::is_throws(ec))
+ {
+ ec.clear();
+ }
+ return time_point(system+user);
+
+ }
+ else
+ {
+ if (::boost::chrono::is_throws(ec))
+ {
+ boost::throw_exception(
+ system::system_error(
+ boost::detail::winapi::GetLastError(),
+ ::boost::system::system_category(),
+ "chrono::thread_clock" ));
+ }
+ else
+ {
+ ec.assign( boost::detail::winapi::GetLastError(), ::boost::system::system_category() );
+ return thread_clock::time_point(duration(0));
+ }
+ }
+}
+#endif
+
+thread_clock::time_point thread_clock::now() BOOST_NOEXCEPT
+{
+
+ // note that Windows uses 100 nanosecond ticks for FILETIME
+ boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
+
+ if ( boost::detail::winapi::GetThreadTimes(
+ boost::detail::winapi::GetCurrentThread (), &creation, &exit,
+ &system_time, &user_time ) )
+ {
+ duration user = duration(
+ ((static_cast<duration::rep>(user_time.dwHighDateTime) << 32)
+ | user_time.dwLowDateTime) * 100 );
+
+ duration system = duration(
+ ((static_cast<duration::rep>(system_time.dwHighDateTime) << 32)
+ | system_time.dwLowDateTime) * 100 );
+
+ return time_point(system+user);
+ }
+ else
+ {
+ BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
+ return time_point();
+ }
+
+}
+
+} // namespace chrono
+} // namespace boost
+
+#endif