Index: include/boost/thread/win32/gettickcount64.hpp =================================================================== --- include/boost/thread/win32/gettickcount64.hpp (revision 0) +++ include/boost/thread/win32/gettickcount64.hpp (working copy) @@ -0,0 +1,15 @@ +#pragma once + +namespace boost +{ + namespace detail + { + namespace win32 + { + typedef unsigned long long ticks_type; + typedef ticks_type (__stdcall *gettickcount64fn)(); + typedef unsigned long (__stdcall *gettickcount32fn)(); + ticks_type GetTickCount64(); + } + } +} Index: include/boost/thread/win32/thread_data.hpp =================================================================== --- include/boost/thread/win32/thread_data.hpp (revision 2125) +++ include/boost/thread/win32/thread_data.hpp (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include #include #ifdef BOOST_THREAD_USES_CHRONO Index: include/boost/thread/win32/thread_primitives.hpp =================================================================== --- include/boost/thread/win32/thread_primitives.hpp (revision 2125) +++ include/boost/thread/win32/thread_primitives.hpp (working copy) @@ -18,12 +18,6 @@ //#include #include -#ifndef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 -#if _WIN32_WINNT >= 0x0600 && ! defined _WIN32_WINNT_WS08 -#define BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 -#endif -#endif - #if defined( BOOST_USE_WINDOWS_H ) # include @@ -33,11 +27,6 @@ { namespace win32 { -#ifdef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 - typedef unsigned long long ticks_type; -#else - typedef unsigned long ticks_type; -#endif typedef ULONG_PTR ulong_ptr; typedef HANDLE handle; unsigned const infinite=INFINITE; @@ -74,12 +63,6 @@ using ::SleepEx; using ::Sleep; using ::QueueUserAPC; - using ::GetTickCount; -#ifdef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 - using ::GetTickCount64; -#else - inline ticks_type GetTickCount64() { return GetTickCount(); } -#endif } } } @@ -114,11 +97,6 @@ { namespace win32 { -#ifdef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 - typedef unsigned long long ticks_type; -#else - typedef unsigned long ticks_type; -#endif # ifdef _WIN64 typedef unsigned __int64 ulong_ptr; # else @@ -157,10 +135,6 @@ typedef void (__stdcall *queue_user_apc_callback_function)(ulong_ptr); __declspec(dllimport) unsigned long __stdcall QueueUserAPC(queue_user_apc_callback_function,void*,ulong_ptr); - __declspec(dllimport) unsigned long __stdcall GetTickCount(); -# ifdef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 - __declspec(dllimport) ticks_type __stdcall GetTickCount64(); -# endif # ifndef UNDER_CE __declspec(dllimport) unsigned long __stdcall GetCurrentProcessId(); __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(); @@ -177,9 +151,6 @@ using ::ResetEvent; # endif } -# ifndef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 - inline ticks_type GetTickCount64() { return GetTickCount(); } -# endif } } } Index: src/win32/gettickcount64.cpp =================================================================== --- src/win32/gettickcount64.cpp (revision 0) +++ src/win32/gettickcount64.cpp (working copy) @@ -0,0 +1,42 @@ +#include + +#include + +#ifdef BOOST_USE_WINDOWS_H +#include +#else +extern "C" +{ + __declspec(dllimport) boost::detail::win32::gettickcount32fn __stdcall GetProcAddress(void *, const char *); + __declspec(dllimport) void * __stdcall GetModuleHandleW(const wchar_t *); +} +#endif + +namespace boost +{ + namespace detail + { + namespace win32 + { + namespace + { + gettickcount64fn gettickcount64 = NULL; + gettickcount32fn gettickcount32 = NULL; + ::boost::once_flag initfnonce = BOOST_ONCE_INIT; + + void init_gettickcount64() + { + gettickcount64 = reinterpret_cast(::GetProcAddress(::GetModuleHandleW(L"Kernel32.dll"), "GetTickCount64")); + if(!gettickcount64) + gettickcount32 = reinterpret_cast(::GetProcAddress(::GetModuleHandleW(L"Kernel32.dll"), "GetTickCount")); + } + } + + ticks_type GetTickCount64() + { + ::boost::call_once(&init_gettickcount64, initfnonce); + return gettickcount64 ? gettickcount64() : static_cast(gettickcount32()); + } + } + } +}