Permalink
Browse files

pull patch for #8070.

  • Loading branch information...
viboes committed Feb 27, 2014
1 parent a740006 commit 143adde27d7bf06d972d2ff0c4757f715e6107f2
View
@@ -284,6 +284,7 @@ alias thread_sources
win32/thread.cpp
win32/tss_dll.cpp
win32/tss_pe.cpp
win32/gettickcount64.cpp
future.cpp
: ## requirements ##
<threadapi>win32
@@ -0,0 +1,28 @@
#ifndef BOOST_WIN32_GET_TICK_COUNT_HPP
#define BOOST_WIN32_GET_TICK_COUNT_HPP
// (C) Copyright 2014 Vicente J. Botet Escriba
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config/abi_prefix.hpp>
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();
}
}
}
#include <boost/config/abi_suffix.hpp>
#endif
@@ -10,6 +10,7 @@
#include <boost/thread/thread_time.hpp>
#include <boost/thread/win32/thread_primitives.hpp>
#include <boost/thread/win32/thread_heap_alloc.hpp>
#include <boost/thread/win32/gettickcount64.hpp>
#include <boost/intrusive_ptr.hpp>
#ifdef BOOST_THREAD_USES_CHRONO
@@ -18,11 +18,11 @@
//#include <boost/detail/win/synchronization.hpp>
#include <algorithm>
#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
//#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 <windows.h>
@@ -33,11 +33,11 @@ namespace boost
{
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 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 +74,12 @@ namespace boost
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
// using ::GetTickCount;
//#ifdef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
// using ::GetTickCount64;
//#else
// inline ticks_type GetTickCount64() { return GetTickCount(); }
//#endif
}
}
}
@@ -157,10 +157,10 @@ namespace boost
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
// __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 +177,9 @@ namespace boost
using ::ResetEvent;
# endif
}
# ifndef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
inline ticks_type GetTickCount64() { return GetTickCount(); }
# endif
//# ifndef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
// inline ticks_type GetTickCount64() { return GetTickCount(); }
//# endif
}
}
}
@@ -0,0 +1,48 @@
// (C) Copyright 2014 Vicente J. Botet Escriba
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/thread/win32/gettickcount64.hpp>
#include <boost/thread/once.hpp>
#ifdef BOOST_USE_WINDOWS_H
#include <Windows.h>
#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<gettickcount64fn> (::GetProcAddress(::GetModuleHandleW(L"Kernel32.dll"),
"GetTickCount64"));
if (!gettickcount64) gettickcount32 = reinterpret_cast<gettickcount32fn> (::GetProcAddress(
::GetModuleHandleW(L"Kernel32.dll"), "GetTickCount"));
}
}
ticks_type GetTickCount64()
{
::boost::call_once(&init_gettickcount64, initfnonce);
return gettickcount64 ? gettickcount64() : static_cast<ticks_type> (gettickcount32());
}
}
}
}

0 comments on commit 143adde

Please sign in to comment.