Ticket #8070: gettickcount64.patch
File gettickcount64.patch, 5.1 KB (added by , 9 years ago) |
---|
-
include/boost/thread/win32/gettickcount64.hpp
1 #pragma once 2 3 namespace boost 4 { 5 namespace detail 6 { 7 namespace win32 8 { 9 typedef unsigned long long ticks_type; 10 typedef ticks_type (__stdcall *gettickcount64fn)(); 11 typedef unsigned long (__stdcall *gettickcount32fn)(); 12 ticks_type GetTickCount64(); 13 } 14 } 15 } -
include/boost/thread/win32/thread_data.hpp
10 10 #include <boost/thread/thread_time.hpp> 11 11 #include <boost/thread/win32/thread_primitives.hpp> 12 12 #include <boost/thread/win32/thread_heap_alloc.hpp> 13 #include <boost/thread/win32/gettickcount64.hpp> 13 14 14 15 #include <boost/intrusive_ptr.hpp> 15 16 #ifdef BOOST_THREAD_USES_CHRONO -
include/boost/thread/win32/thread_primitives.hpp
18 18 //#include <boost/detail/win/synchronization.hpp> 19 19 #include <algorithm> 20 20 21 #ifndef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_6422 #if _WIN32_WINNT >= 0x0600 && ! defined _WIN32_WINNT_WS0823 #define BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_6424 #endif25 #endif26 27 21 #if defined( BOOST_USE_WINDOWS_H ) 28 22 # include <windows.h> 29 23 … … 33 27 { 34 28 namespace win32 35 29 { 36 #ifdef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_6437 typedef unsigned long long ticks_type;38 #else39 typedef unsigned long ticks_type;40 #endif41 30 typedef ULONG_PTR ulong_ptr; 42 31 typedef HANDLE handle; 43 32 unsigned const infinite=INFINITE; … … 74 63 using ::SleepEx; 75 64 using ::Sleep; 76 65 using ::QueueUserAPC; 77 using ::GetTickCount;78 #ifdef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_6479 using ::GetTickCount64;80 #else81 inline ticks_type GetTickCount64() { return GetTickCount(); }82 #endif83 66 } 84 67 } 85 68 } … … 114 97 { 115 98 namespace win32 116 99 { 117 #ifdef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64118 typedef unsigned long long ticks_type;119 #else120 typedef unsigned long ticks_type;121 #endif122 100 # ifdef _WIN64 123 101 typedef unsigned __int64 ulong_ptr; 124 102 # else … … 157 135 typedef void (__stdcall *queue_user_apc_callback_function)(ulong_ptr); 158 136 __declspec(dllimport) unsigned long __stdcall QueueUserAPC(queue_user_apc_callback_function,void*,ulong_ptr); 159 137 160 __declspec(dllimport) unsigned long __stdcall GetTickCount();161 # ifdef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64162 __declspec(dllimport) ticks_type __stdcall GetTickCount64();163 # endif164 138 # ifndef UNDER_CE 165 139 __declspec(dllimport) unsigned long __stdcall GetCurrentProcessId(); 166 140 __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(); … … 177 151 using ::ResetEvent; 178 152 # endif 179 153 } 180 # ifndef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64181 inline ticks_type GetTickCount64() { return GetTickCount(); }182 # endif183 154 } 184 155 } 185 156 } -
src/win32/gettickcount64.cpp
1 #include <boost/thread/win32/gettickcount64.hpp> 2 3 #include <boost/thread/once.hpp> 4 5 #ifdef BOOST_USE_WINDOWS_H 6 #include <Windows.h> 7 #else 8 extern "C" 9 { 10 __declspec(dllimport) boost::detail::win32::gettickcount32fn __stdcall GetProcAddress(void *, const char *); 11 __declspec(dllimport) void * __stdcall GetModuleHandleW(const wchar_t *); 12 } 13 #endif 14 15 namespace boost 16 { 17 namespace detail 18 { 19 namespace win32 20 { 21 namespace 22 { 23 gettickcount64fn gettickcount64 = NULL; 24 gettickcount32fn gettickcount32 = NULL; 25 ::boost::once_flag initfnonce = BOOST_ONCE_INIT; 26 27 void init_gettickcount64() 28 { 29 gettickcount64 = reinterpret_cast<gettickcount64fn>(::GetProcAddress(::GetModuleHandleW(L"Kernel32.dll"), "GetTickCount64")); 30 if(!gettickcount64) 31 gettickcount32 = reinterpret_cast<gettickcount32fn>(::GetProcAddress(::GetModuleHandleW(L"Kernel32.dll"), "GetTickCount")); 32 } 33 } 34 35 ticks_type GetTickCount64() 36 { 37 ::boost::call_once(&init_gettickcount64, initfnonce); 38 return gettickcount64 ? gettickcount64() : static_cast<ticks_type>(gettickcount32()); 39 } 40 } 41 } 42 }