From 19973d04882d34b2cfed1a6dd66f8f101a1304a4 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Tue, 24 Oct 2017 22:55:48 +0300 Subject: [PATCH] Updated Boost.WinAPI usage to the new location and namespace. --- include/boost/log/detail/adaptive_mutex.hpp | 6 +- include/boost/log/detail/config.hpp | 2 +- include/boost/log/detail/light_rw_mutex.hpp | 14 +-- include/boost/log/detail/timestamp.hpp | 2 +- src/code_conversion.cpp | 20 ++-- src/dump.cpp | 6 +- src/once_block.cpp | 54 +++++----- src/timestamp.cpp | 12 +-- src/windows/auto_handle.hpp | 16 +-- src/windows/ipc_reliable_message_queue.cpp | 18 ++-- src/windows/ipc_sync_wrappers.cpp | 106 ++++++++++---------- src/windows/ipc_sync_wrappers.hpp | 102 +++++++++---------- src/windows/light_rw_mutex.cpp | 16 +-- src/windows/mapped_shared_memory.cpp | 72 ++++++------- src/windows/mapped_shared_memory.hpp | 13 ++- src/windows/object_name.cpp | 4 +- 16 files changed, 231 insertions(+), 232 deletions(-) diff --git a/include/boost/log/detail/adaptive_mutex.hpp b/include/boost/log/detail/adaptive_mutex.hpp index f9830ef..70efd92 100644 --- a/include/boost/log/detail/adaptive_mutex.hpp +++ b/include/boost/log/detail/adaptive_mutex.hpp @@ -38,8 +38,8 @@ #if defined(BOOST_LOG_ADAPTIVE_MUTEX_USE_WINAPI) #include +#include #include -#include #if defined(__INTEL_COMPILER) || defined(_MSC_VER) # if defined(__INTEL_COMPILER) @@ -103,10 +103,10 @@ public: { // Restart spinning after waking up this thread pause_count = initial_pause; - SwitchToThread(); + boost::winapi::SwitchToThread(); } #else - SwitchToThread(); + boost::winapi::SwitchToThread(); #endif } } diff --git a/include/boost/log/detail/config.hpp b/include/boost/log/detail/config.hpp index a4304ab..5f43443 100644 --- a/include/boost/log/detail/config.hpp +++ b/include/boost/log/detail/config.hpp @@ -27,7 +27,7 @@ // Try including WinAPI config as soon as possible so that any other headers don't include Windows SDK headers #if defined(BOOST_OS_WINDOWS_AVAILABLE) -#include +#include #endif #include // To bring in libc macros diff --git a/include/boost/log/detail/light_rw_mutex.hpp b/include/boost/log/detail/light_rw_mutex.hpp index 39762b3..d7f99cb 100644 --- a/include/boost/log/detail/light_rw_mutex.hpp +++ b/include/boost/log/detail/light_rw_mutex.hpp @@ -36,7 +36,7 @@ #if defined(BOOST_LOG_LWRWMUTEX_USE_SRWLOCK) -#include +#include namespace boost { @@ -47,28 +47,28 @@ namespace aux { //! A light read/write mutex that uses WinNT 6 and later APIs class light_rw_mutex { - boost::detail::winapi::SRWLOCK_ m_Mutex; + boost::winapi::SRWLOCK_ m_Mutex; public: light_rw_mutex() { - boost::detail::winapi::InitializeSRWLock(&m_Mutex); + boost::winapi::InitializeSRWLock(&m_Mutex); } void lock_shared() { - boost::detail::winapi::AcquireSRWLockShared(&m_Mutex); + boost::winapi::AcquireSRWLockShared(&m_Mutex); } void unlock_shared() { - boost::detail::winapi::ReleaseSRWLockShared(&m_Mutex); + boost::winapi::ReleaseSRWLockShared(&m_Mutex); } void lock() { - boost::detail::winapi::AcquireSRWLockExclusive(&m_Mutex); + boost::winapi::AcquireSRWLockExclusive(&m_Mutex); } void unlock() { - boost::detail::winapi::ReleaseSRWLockExclusive(&m_Mutex); + boost::winapi::ReleaseSRWLockExclusive(&m_Mutex); } // Noncopyable diff --git a/include/boost/log/detail/timestamp.hpp b/include/boost/log/detail/timestamp.hpp index 95c1f0a..9bd0061 100644 --- a/include/boost/log/detail/timestamp.hpp +++ b/include/boost/log/detail/timestamp.hpp @@ -19,7 +19,7 @@ #include #include #if defined(BOOST_WINDOWS) && !defined(__CYGWIN__) -#include +#include #endif #include diff --git a/src/code_conversion.cpp b/src/code_conversion.cpp index 3fa9db8..2f253ed 100644 --- a/src/code_conversion.cpp +++ b/src/code_conversion.cpp @@ -24,8 +24,8 @@ #if defined(BOOST_WINDOWS) #include #include -#include -#include +#include +#include #endif #include @@ -236,20 +236,20 @@ std::wstring utf8_to_utf16(const char* str) else if (BOOST_UNLIKELY(utf8_len > static_cast< std::size_t >((std::numeric_limits< int >::max)()))) BOOST_LOG_THROW_DESCR(bad_alloc, "UTF-8 string too long"); - int len = boost::detail::winapi::MultiByteToWideChar(boost::detail::winapi::CP_UTF8_, boost::detail::winapi::MB_ERR_INVALID_CHARS_, str, static_cast< int >(utf8_len), NULL, 0); + int len = boost::winapi::MultiByteToWideChar(boost::winapi::CP_UTF8_, boost::winapi::MB_ERR_INVALID_CHARS_, str, static_cast< int >(utf8_len), NULL, 0); if (BOOST_LIKELY(len > 0)) { std::wstring wstr; wstr.resize(len); - len = boost::detail::winapi::MultiByteToWideChar(boost::detail::winapi::CP_UTF8_, boost::detail::winapi::MB_ERR_INVALID_CHARS_, str, static_cast< int >(utf8_len), &wstr[0], len); + len = boost::winapi::MultiByteToWideChar(boost::winapi::CP_UTF8_, boost::winapi::MB_ERR_INVALID_CHARS_, str, static_cast< int >(utf8_len), &wstr[0], len); if (BOOST_LIKELY(len > 0)) { return wstr; } } - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(system_error, "Failed to convert UTF-8 to UTF-16", (err)); BOOST_LOG_UNREACHABLE_RETURN(std::wstring()); } @@ -263,26 +263,26 @@ std::string utf16_to_utf8(const wchar_t* wstr) else if (BOOST_UNLIKELY(utf16_len > static_cast< std::size_t >((std::numeric_limits< int >::max)()))) BOOST_LOG_THROW_DESCR(bad_alloc, "UTF-16 string too long"); - const boost::detail::winapi::DWORD_ flags = + const boost::winapi::DWORD_ flags = #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - boost::detail::winapi::WC_ERR_INVALID_CHARS_; + boost::winapi::WC_ERR_INVALID_CHARS_; #else 0u; #endif - int len = boost::detail::winapi::WideCharToMultiByte(boost::detail::winapi::CP_UTF8_, flags, wstr, static_cast< int >(utf16_len), NULL, 0, NULL, NULL); + int len = boost::winapi::WideCharToMultiByte(boost::winapi::CP_UTF8_, flags, wstr, static_cast< int >(utf16_len), NULL, 0, NULL, NULL); if (BOOST_LIKELY(len > 0)) { std::string str; str.resize(len); - len = boost::detail::winapi::WideCharToMultiByte(boost::detail::winapi::CP_UTF8_, flags, wstr, static_cast< int >(utf16_len), &str[0], len, NULL, NULL); + len = boost::winapi::WideCharToMultiByte(boost::winapi::CP_UTF8_, flags, wstr, static_cast< int >(utf16_len), &str[0], len, NULL, NULL); if (BOOST_LIKELY(len > 0)) { return str; } } - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(system_error, "Failed to convert UTF-16 to UTF-8", (err)); BOOST_LOG_UNREACHABLE_RETURN(std::string()); } diff --git a/src/dump.cpp b/src/dump.cpp index 4b9ddf4..95b1265 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -18,7 +18,7 @@ #include #include #if defined(_MSC_VER) && (defined(BOOST_LOG_USE_SSSE3) || defined(BOOST_LOG_USE_AVX2)) -#include +#include #include // __cpuid #endif #include @@ -159,11 +159,11 @@ struct function_pointer_initializer mmstate = (eax & 6U) == 6U; #elif defined(BOOST_WINDOWS) // MSVC does not have an intrinsic for xgetbv, we have to query OS - boost::detail::winapi::HMODULE_ hKernel32 = boost::detail::winapi::GetModuleHandleW(L"kernel32.dll"); + boost::winapi::HMODULE_ hKernel32 = boost::winapi::GetModuleHandleW(L"kernel32.dll"); if (hKernel32) { typedef uint64_t (WINAPI* get_enabled_extended_features_t)(uint64_t); - get_enabled_extended_features_t get_enabled_extended_features = (get_enabled_extended_features_t)boost::detail::winapi::get_proc_address(hKernel32, "GetEnabledExtendedFeatures"); + get_enabled_extended_features_t get_enabled_extended_features = (get_enabled_extended_features_t)boost::winapi::get_proc_address(hKernel32, "GetEnabledExtendedFeatures"); if (get_enabled_extended_features) { // XSTATE_MASK_LEGACY_SSE | XSTATE_MASK_GSSE == 6 diff --git a/src/once_block.cpp b/src/once_block.cpp index 088bcc2..8e7d157 100644 --- a/src/once_block.cpp +++ b/src/once_block.cpp @@ -24,12 +24,12 @@ #if defined(BOOST_THREAD_PLATFORM_WIN32) -#include // INFINITE +#include // INFINITE #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 -#include -#include +#include +#include #include namespace boost { @@ -40,14 +40,14 @@ namespace aux { BOOST_LOG_ANONYMOUS_NAMESPACE { -boost::detail::winapi::SRWLOCK_ g_OnceBlockMutex = BOOST_DETAIL_WINAPI_SRWLOCK_INIT; -boost::detail::winapi::CONDITION_VARIABLE_ g_OnceBlockCond = BOOST_DETAIL_WINAPI_CONDITION_VARIABLE_INIT; +boost::winapi::SRWLOCK_ g_OnceBlockMutex = BOOST_WINAPI_SRWLOCK_INIT; +boost::winapi::CONDITION_VARIABLE_ g_OnceBlockCond = BOOST_WINAPI_CONDITION_VARIABLE_INIT; } // namespace BOOST_LOG_API bool once_block_sentry::enter_once_block() const BOOST_NOEXCEPT { - boost::detail::winapi::AcquireSRWLockExclusive(&g_OnceBlockMutex); + boost::winapi::AcquireSRWLockExclusive(&g_OnceBlockMutex); once_block_flag volatile& flag = m_flag; while (flag.status != once_block_flag::initialized) @@ -55,7 +55,7 @@ BOOST_LOG_API bool once_block_sentry::enter_once_block() const BOOST_NOEXCEPT if (flag.status == once_block_flag::uninitialized) { flag.status = once_block_flag::being_initialized; - boost::detail::winapi::ReleaseSRWLockExclusive(&g_OnceBlockMutex); + boost::winapi::ReleaseSRWLockExclusive(&g_OnceBlockMutex); // Invoke the initializer block return false; @@ -64,37 +64,37 @@ BOOST_LOG_API bool once_block_sentry::enter_once_block() const BOOST_NOEXCEPT { while (flag.status == once_block_flag::being_initialized) { - BOOST_VERIFY(boost::detail::winapi::SleepConditionVariableSRW( - &g_OnceBlockCond, &g_OnceBlockMutex, boost::detail::winapi::INFINITE_, 0)); + BOOST_VERIFY(boost::winapi::SleepConditionVariableSRW( + &g_OnceBlockCond, &g_OnceBlockMutex, boost::winapi::INFINITE_, 0)); } } } - boost::detail::winapi::ReleaseSRWLockExclusive(&g_OnceBlockMutex); + boost::winapi::ReleaseSRWLockExclusive(&g_OnceBlockMutex); return true; } BOOST_LOG_API void once_block_sentry::commit() BOOST_NOEXCEPT { - boost::detail::winapi::AcquireSRWLockExclusive(&g_OnceBlockMutex); + boost::winapi::AcquireSRWLockExclusive(&g_OnceBlockMutex); // The initializer executed successfully m_flag.status = once_block_flag::initialized; - boost::detail::winapi::ReleaseSRWLockExclusive(&g_OnceBlockMutex); - boost::detail::winapi::WakeAllConditionVariable(&g_OnceBlockCond); + boost::winapi::ReleaseSRWLockExclusive(&g_OnceBlockMutex); + boost::winapi::WakeAllConditionVariable(&g_OnceBlockCond); } BOOST_LOG_API void once_block_sentry::rollback() BOOST_NOEXCEPT { - boost::detail::winapi::AcquireSRWLockExclusive(&g_OnceBlockMutex); + boost::winapi::AcquireSRWLockExclusive(&g_OnceBlockMutex); // The initializer failed, marking the flag as if it hasn't run at all m_flag.status = once_block_flag::uninitialized; - boost::detail::winapi::ReleaseSRWLockExclusive(&g_OnceBlockMutex); - boost::detail::winapi::WakeAllConditionVariable(&g_OnceBlockCond); + boost::winapi::ReleaseSRWLockExclusive(&g_OnceBlockMutex); + boost::winapi::WakeAllConditionVariable(&g_OnceBlockCond); } } // namespace aux @@ -109,8 +109,8 @@ BOOST_LOG_CLOSE_NAMESPACE // namespace log #include // atexit #include -#include -#include +#include +#include #include #include #include @@ -143,7 +143,7 @@ BOOST_LOG_ANONYMOUS_NAMESPACE { typedef void (WINAPI *AcquireSRWLockExclusive_t)(winapi_srwlock*); typedef void (WINAPI *ReleaseSRWLockExclusive_t)(winapi_srwlock*); typedef void (WINAPI *InitializeConditionVariable_t)(winapi_condition_variable*); - typedef boost::detail::winapi::BOOL_ (WINAPI *SleepConditionVariableSRW_t)(winapi_condition_variable*, winapi_srwlock*, boost::detail::winapi::DWORD_, boost::detail::winapi::ULONG_); + typedef boost::winapi::BOOL_ (WINAPI *SleepConditionVariableSRW_t)(winapi_condition_variable*, winapi_srwlock*, boost::winapi::DWORD_, boost::winapi::ULONG_); typedef void (WINAPI *WakeAllConditionVariable_t)(winapi_condition_variable*); private: @@ -192,7 +192,7 @@ BOOST_LOG_ANONYMOUS_NAMESPACE { while (flag.status == once_block_flag::being_initialized) { BOOST_VERIFY(m_pSleepConditionVariableSRW( - &m_Cond, &m_Mutex, boost::detail::winapi::INFINITE_, 0)); + &m_Cond, &m_Mutex, boost::winapi::INFINITE_, 0)); } } } @@ -279,31 +279,31 @@ BOOST_LOG_ANONYMOUS_NAMESPACE { once_block_impl_base* create_once_block_impl() { - boost::detail::winapi::HMODULE_ hKernel32 = boost::detail::winapi::GetModuleHandleW(L"kernel32.dll"); + boost::winapi::HMODULE_ hKernel32 = boost::winapi::GetModuleHandleW(L"kernel32.dll"); if (hKernel32) { once_block_impl_nt6::InitializeSRWLock_t pInitializeSRWLock = - (once_block_impl_nt6::InitializeSRWLock_t)boost::detail::winapi::get_proc_address(hKernel32, "InitializeSRWLock"); + (once_block_impl_nt6::InitializeSRWLock_t)boost::winapi::get_proc_address(hKernel32, "InitializeSRWLock"); if (pInitializeSRWLock) { once_block_impl_nt6::AcquireSRWLockExclusive_t pAcquireSRWLockExclusive = - (once_block_impl_nt6::AcquireSRWLockExclusive_t)boost::detail::winapi::get_proc_address(hKernel32, "AcquireSRWLockExclusive"); + (once_block_impl_nt6::AcquireSRWLockExclusive_t)boost::winapi::get_proc_address(hKernel32, "AcquireSRWLockExclusive"); if (pAcquireSRWLockExclusive) { once_block_impl_nt6::ReleaseSRWLockExclusive_t pReleaseSRWLockExclusive = - (once_block_impl_nt6::ReleaseSRWLockExclusive_t)boost::detail::winapi::get_proc_address(hKernel32, "ReleaseSRWLockExclusive"); + (once_block_impl_nt6::ReleaseSRWLockExclusive_t)boost::winapi::get_proc_address(hKernel32, "ReleaseSRWLockExclusive"); if (pReleaseSRWLockExclusive) { once_block_impl_nt6::InitializeConditionVariable_t pInitializeConditionVariable = - (once_block_impl_nt6::InitializeConditionVariable_t)boost::detail::winapi::get_proc_address(hKernel32, "InitializeConditionVariable"); + (once_block_impl_nt6::InitializeConditionVariable_t)boost::winapi::get_proc_address(hKernel32, "InitializeConditionVariable"); if (pInitializeConditionVariable) { once_block_impl_nt6::SleepConditionVariableSRW_t pSleepConditionVariableSRW = - (once_block_impl_nt6::SleepConditionVariableSRW_t)boost::detail::winapi::get_proc_address(hKernel32, "SleepConditionVariableSRW"); + (once_block_impl_nt6::SleepConditionVariableSRW_t)boost::winapi::get_proc_address(hKernel32, "SleepConditionVariableSRW"); if (pSleepConditionVariableSRW) { once_block_impl_nt6::WakeAllConditionVariable_t pWakeAllConditionVariable = - (once_block_impl_nt6::WakeAllConditionVariable_t)boost::detail::winapi::get_proc_address(hKernel32, "WakeAllConditionVariable"); + (once_block_impl_nt6::WakeAllConditionVariable_t)boost::winapi::get_proc_address(hKernel32, "WakeAllConditionVariable"); if (pWakeAllConditionVariable) { return new once_block_impl_nt6( diff --git a/src/timestamp.cpp b/src/timestamp.cpp index 51f4868..ff372ea 100644 --- a/src/timestamp.cpp +++ b/src/timestamp.cpp @@ -21,8 +21,8 @@ #include #include #endif -#include -#include +#include +#include #else #include // for config macros #if defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) @@ -49,7 +49,7 @@ namespace aux { #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 // Directly use API from Vista and later -BOOST_LOG_API get_tick_count_t get_tick_count = &boost::detail::winapi::GetTickCount64; +BOOST_LOG_API get_tick_count_t get_tick_count = &boost::winapi::GetTickCount64; #else // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 @@ -71,7 +71,7 @@ uint64_t WINAPI get_tick_count64() uint64_t old_state = g_ticks; #endif - uint32_t new_ticks = boost::detail::winapi::GetTickCount(); + uint32_t new_ticks = boost::winapi::GetTickCount(); uint32_t old_ticks = static_cast< uint32_t >(old_state & UINT64_C(0x00000000ffffffff)); uint64_t new_state = ((old_state & UINT64_C(0xffffffff00000000)) + (static_cast< uint64_t >(new_ticks < old_ticks) << 32)) | static_cast< uint64_t >(new_ticks); @@ -87,10 +87,10 @@ uint64_t WINAPI get_tick_count64() uint64_t WINAPI get_tick_count_init() { - boost::detail::winapi::HMODULE_ hKernel32 = boost::detail::winapi::GetModuleHandleW(L"kernel32.dll"); + boost::winapi::HMODULE_ hKernel32 = boost::winapi::GetModuleHandleW(L"kernel32.dll"); if (hKernel32) { - get_tick_count_t p = (get_tick_count_t)boost::detail::winapi::get_proc_address(hKernel32, "GetTickCount64"); + get_tick_count_t p = (get_tick_count_t)boost::winapi::get_proc_address(hKernel32, "GetTickCount64"); if (p) { // Use native API diff --git a/src/windows/auto_handle.hpp b/src/windows/auto_handle.hpp index c965ee4..ebd01ba 100644 --- a/src/windows/auto_handle.hpp +++ b/src/windows/auto_handle.hpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include namespace boost { @@ -33,31 +33,31 @@ namespace aux { class auto_handle { private: - boost::detail::winapi::HANDLE_ m_handle; + boost::winapi::HANDLE_ m_handle; public: - explicit auto_handle(boost::detail::winapi::HANDLE_ h = NULL) BOOST_NOEXCEPT : m_handle(h) + explicit auto_handle(boost::winapi::HANDLE_ h = NULL) BOOST_NOEXCEPT : m_handle(h) { } ~auto_handle() BOOST_NOEXCEPT { if (m_handle) - BOOST_VERIFY(boost::detail::winapi::CloseHandle(m_handle) != 0); + BOOST_VERIFY(boost::winapi::CloseHandle(m_handle) != 0); } - void init(boost::detail::winapi::HANDLE_ h) BOOST_NOEXCEPT + void init(boost::winapi::HANDLE_ h) BOOST_NOEXCEPT { BOOST_ASSERT(m_handle == NULL); m_handle = h; } - boost::detail::winapi::HANDLE_ get() const BOOST_NOEXCEPT { return m_handle; } - boost::detail::winapi::HANDLE_* get_ptr() BOOST_NOEXCEPT { return &m_handle; } + boost::winapi::HANDLE_ get() const BOOST_NOEXCEPT { return m_handle; } + boost::winapi::HANDLE_* get_ptr() BOOST_NOEXCEPT { return &m_handle; } void swap(auto_handle& that) BOOST_NOEXCEPT { - boost::detail::winapi::HANDLE_ h = m_handle; + boost::winapi::HANDLE_ h = m_handle; m_handle = that.m_handle; that.m_handle = h; } diff --git a/src/windows/ipc_reliable_message_queue.cpp b/src/windows/ipc_reliable_message_queue.cpp index bb5b6db..d99d091 100644 --- a/src/windows/ipc_reliable_message_queue.cpp +++ b/src/windows/ipc_reliable_message_queue.cpp @@ -37,7 +37,7 @@ #include #include #include -#include // SwitchToThread +#include // SwitchToThread #include "windows/ipc_sync_wrappers.hpp" #include "windows/mapped_shared_memory.hpp" #include "windows/utf_code_conversion.hpp" @@ -387,12 +387,12 @@ public: void stop_local() { - BOOST_VERIFY(boost::detail::winapi::SetEvent(m_stop.get()) != 0); + BOOST_VERIFY(boost::winapi::SetEvent(m_stop.get()) != 0); } void reset_local() { - BOOST_VERIFY(boost::detail::winapi::ResetEvent(m_stop.get()) != 0); + BOOST_VERIFY(boost::winapi::ResetEvent(m_stop.get()) != 0); } void clear() @@ -416,15 +416,15 @@ private: void create_stop_event() { #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - boost::detail::winapi::HANDLE_ h = boost::detail::winapi::CreateEventExW + boost::winapi::HANDLE_ h = boost::winapi::CreateEventExW ( NULL, // permissions NULL, // name - boost::detail::winapi::CREATE_EVENT_MANUAL_RESET_, - boost::detail::winapi::SYNCHRONIZE_ | boost::detail::winapi::EVENT_MODIFY_STATE_ + boost::winapi::CREATE_EVENT_MANUAL_RESET_, + boost::winapi::SYNCHRONIZE_ | boost::winapi::EVENT_MODIFY_STATE_ ); #else - boost::detail::winapi::HANDLE_ h = boost::detail::winapi::CreateEventW + boost::winapi::HANDLE_ h = boost::winapi::CreateEventW ( NULL, // permissions true, // manual reset @@ -434,7 +434,7 @@ private: #endif if (BOOST_UNLIKELY(h == NULL)) { - boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to create an stop event object", (err)); } @@ -480,7 +480,7 @@ private: } else { - boost::detail::winapi::SwitchToThread(); + boost::winapi::SwitchToThread(); } } diff --git a/src/windows/ipc_sync_wrappers.cpp b/src/windows/ipc_sync_wrappers.cpp index 5485f19..bd8bfb2 100644 --- a/src/windows/ipc_sync_wrappers.cpp +++ b/src/windows/ipc_sync_wrappers.cpp @@ -14,15 +14,15 @@ */ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include // for error codes #include #include @@ -56,17 +56,17 @@ namespace aux { void interprocess_event::create(const wchar_t* name, bool manual_reset, permissions const& perms) { #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - boost::detail::winapi::HANDLE_ h = boost::detail::winapi::CreateEventExW + boost::winapi::HANDLE_ h = boost::winapi::CreateEventExW ( - reinterpret_cast< boost::detail::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), + reinterpret_cast< boost::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), name, - boost::detail::winapi::CREATE_EVENT_MANUAL_RESET_ * manual_reset, - boost::detail::winapi::SYNCHRONIZE_ | boost::detail::winapi::EVENT_MODIFY_STATE_ + boost::winapi::CREATE_EVENT_MANUAL_RESET_ * manual_reset, + boost::winapi::SYNCHRONIZE_ | boost::winapi::EVENT_MODIFY_STATE_ ); #else - boost::detail::winapi::HANDLE_ h = boost::detail::winapi::CreateEventW + boost::winapi::HANDLE_ h = boost::winapi::CreateEventW ( - reinterpret_cast< boost::detail::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), + reinterpret_cast< boost::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), manual_reset, false, name @@ -74,7 +74,7 @@ void interprocess_event::create(const wchar_t* name, bool manual_reset, permissi #endif if (BOOST_UNLIKELY(h == NULL)) { - boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to create an interprocess event object", (err)); } @@ -84,17 +84,17 @@ void interprocess_event::create(const wchar_t* name, bool manual_reset, permissi void interprocess_event::create_or_open(const wchar_t* name, bool manual_reset, permissions const& perms) { #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - boost::detail::winapi::HANDLE_ h = boost::detail::winapi::CreateEventExW + boost::winapi::HANDLE_ h = boost::winapi::CreateEventExW ( - reinterpret_cast< boost::detail::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), + reinterpret_cast< boost::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), name, - boost::detail::winapi::CREATE_EVENT_MANUAL_RESET_ * manual_reset, - boost::detail::winapi::SYNCHRONIZE_ | boost::detail::winapi::EVENT_MODIFY_STATE_ + boost::winapi::CREATE_EVENT_MANUAL_RESET_ * manual_reset, + boost::winapi::SYNCHRONIZE_ | boost::winapi::EVENT_MODIFY_STATE_ ); #else - boost::detail::winapi::HANDLE_ h = boost::detail::winapi::CreateEventW + boost::winapi::HANDLE_ h = boost::winapi::CreateEventW ( - reinterpret_cast< boost::detail::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), + reinterpret_cast< boost::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), manual_reset, false, name @@ -102,7 +102,7 @@ void interprocess_event::create_or_open(const wchar_t* name, bool manual_reset, #endif if (h == NULL) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); if (BOOST_LIKELY(err == ERROR_ALREADY_EXISTS)) { open(name); @@ -119,10 +119,10 @@ void interprocess_event::create_or_open(const wchar_t* name, bool manual_reset, void interprocess_event::open(const wchar_t* name) { - boost::detail::winapi::HANDLE_ h = boost::detail::winapi::OpenEventW(boost::detail::winapi::SYNCHRONIZE_ | boost::detail::winapi::EVENT_MODIFY_STATE_, false, name); + boost::winapi::HANDLE_ h = boost::winapi::OpenEventW(boost::winapi::SYNCHRONIZE_ | boost::winapi::EVENT_MODIFY_STATE_, false, name); if (BOOST_UNLIKELY(h == NULL)) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to open an interprocess event object", (err)); } @@ -135,27 +135,27 @@ interprocess_semaphore::nt_query_semaphore_t interprocess_semaphore::nt_query_se void interprocess_semaphore::create_or_open(const wchar_t* name, permissions const& perms) { #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - boost::detail::winapi::HANDLE_ h = boost::detail::winapi::CreateSemaphoreExW + boost::winapi::HANDLE_ h = boost::winapi::CreateSemaphoreExW ( - reinterpret_cast< boost::detail::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), + reinterpret_cast< boost::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), 0, // initial count - (std::numeric_limits< boost::detail::winapi::LONG_ >::max)(), // max count + (std::numeric_limits< boost::winapi::LONG_ >::max)(), // max count name, 0u, // flags - boost::detail::winapi::SYNCHRONIZE_ | boost::detail::winapi::SEMAPHORE_MODIFY_STATE_ | boost::detail::winapi::SEMAPHORE_QUERY_STATE_ + boost::winapi::SYNCHRONIZE_ | boost::winapi::SEMAPHORE_MODIFY_STATE_ | boost::winapi::SEMAPHORE_QUERY_STATE_ ); #else - boost::detail::winapi::HANDLE_ h = boost::detail::winapi::CreateSemaphoreW + boost::winapi::HANDLE_ h = boost::winapi::CreateSemaphoreW ( - reinterpret_cast< boost::detail::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), + reinterpret_cast< boost::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), 0, // initial count - (std::numeric_limits< boost::detail::winapi::LONG_ >::max)(), // max count + (std::numeric_limits< boost::winapi::LONG_ >::max)(), // max count name ); #endif if (h == NULL) { - boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + boost::winapi::DWORD_ err = boost::winapi::GetLastError(); if (BOOST_LIKELY(err == ERROR_ALREADY_EXISTS)) { open(name); @@ -172,25 +172,25 @@ void interprocess_semaphore::create_or_open(const wchar_t* name, permissions con void interprocess_semaphore::open(const wchar_t* name) { - boost::detail::winapi::HANDLE_ h = boost::detail::winapi::OpenSemaphoreW(boost::detail::winapi::SYNCHRONIZE_ | boost::detail::winapi::SEMAPHORE_MODIFY_STATE_ | boost::detail::winapi::SEMAPHORE_QUERY_STATE_, false, name); + boost::winapi::HANDLE_ h = boost::winapi::OpenSemaphoreW(boost::winapi::SYNCHRONIZE_ | boost::winapi::SEMAPHORE_MODIFY_STATE_ | boost::winapi::SEMAPHORE_QUERY_STATE_, false, name); if (BOOST_UNLIKELY(h == NULL)) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to open an interprocess semaphore object", (err)); } m_sem.init(h); } -bool interprocess_semaphore::is_semaphore_zero_count_init(boost::detail::winapi::HANDLE_ h) +bool interprocess_semaphore::is_semaphore_zero_count_init(boost::winapi::HANDLE_ h) { is_semaphore_zero_count_t impl = &interprocess_semaphore::is_semaphore_zero_count_emulated; // Check if ntdll.dll provides NtQuerySemaphore, see: http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FNT%20Objects%2FSemaphore%2FNtQuerySemaphore.html - boost::detail::winapi::HMODULE_ ntdll = boost::detail::winapi::GetModuleHandleW(L"ntdll.dll"); + boost::winapi::HMODULE_ ntdll = boost::winapi::GetModuleHandleW(L"ntdll.dll"); if (ntdll) { - nt_query_semaphore_t ntqs = (nt_query_semaphore_t)boost::detail::winapi::get_proc_address(ntdll, "NtQuerySemaphore"); + nt_query_semaphore_t ntqs = (nt_query_semaphore_t)boost::winapi::get_proc_address(ntdll, "NtQuerySemaphore"); if (ntqs) { nt_query_semaphore = ntqs; @@ -203,7 +203,7 @@ bool interprocess_semaphore::is_semaphore_zero_count_init(boost::detail::winapi: return impl(h); } -bool interprocess_semaphore::is_semaphore_zero_count_nt_query_semaphore(boost::detail::winapi::HANDLE_ h) +bool interprocess_semaphore::is_semaphore_zero_count_nt_query_semaphore(boost::winapi::HANDLE_ h) { semaphore_basic_information info = {}; NTSTATUS_ err = nt_query_semaphore @@ -224,21 +224,21 @@ bool interprocess_semaphore::is_semaphore_zero_count_nt_query_semaphore(boost::d return info.current_count == 0u; } -bool interprocess_semaphore::is_semaphore_zero_count_emulated(boost::detail::winapi::HANDLE_ h) +bool interprocess_semaphore::is_semaphore_zero_count_emulated(boost::winapi::HANDLE_ h) { - const boost::detail::winapi::DWORD_ retval = boost::detail::winapi::WaitForSingleObject(h, 0u); - if (retval == boost::detail::winapi::wait_timeout) + const boost::winapi::DWORD_ retval = boost::winapi::WaitForSingleObject(h, 0u); + if (retval == boost::winapi::wait_timeout) { return true; } - else if (BOOST_UNLIKELY(retval != boost::detail::winapi::wait_object_0)) + else if (BOOST_UNLIKELY(retval != boost::winapi::wait_object_0)) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to test an interprocess semaphore object for zero count", (err)); } // Restore the decremented counter - BOOST_VERIFY(!!boost::detail::winapi::ReleaseSemaphore(h, 1, NULL)); + BOOST_VERIFY(!!boost::winapi::ReleaseSemaphore(h, 1, NULL)); return false; } @@ -272,7 +272,7 @@ void interprocess_mutex::lock_slow() } } -bool interprocess_mutex::lock_slow(boost::detail::winapi::HANDLE_ abort_handle) +bool interprocess_mutex::lock_slow(boost::winapi::HANDLE_ abort_handle) { uint32_t old_state = m_shared_state->m_lock_state.load(boost::memory_order_relaxed); mark_waiting_and_try_lock(old_state); @@ -336,7 +336,7 @@ inline void interprocess_mutex::clear_waiting_and_try_lock(uint32_t& old_state) } -bool interprocess_condition_variable::wait(interprocess_mutex::optional_unlock& lock, boost::detail::winapi::HANDLE_ abort_handle) +bool interprocess_condition_variable::wait(interprocess_mutex::optional_unlock& lock, boost::winapi::HANDLE_ abort_handle) { int32_t waiters = m_shared_state->m_waiters; if (waiters < 0) @@ -362,16 +362,16 @@ bool interprocess_condition_variable::wait(interprocess_mutex::optional_unlock& m_shared_state->m_waiters = waiters + 1; const uint32_t generation = m_shared_state->m_generation; - boost::detail::winapi::HANDLE_ handles[2u] = { m_current_semaphore->m_semaphore.get_handle(), abort_handle }; + boost::winapi::HANDLE_ handles[2u] = { m_current_semaphore->m_semaphore.get_handle(), abort_handle }; interprocess_mutex* const mutex = lock.disengage(); mutex->unlock(); - boost::detail::winapi::DWORD_ retval = boost::detail::winapi::WaitForMultipleObjects(2u, handles, false, boost::detail::winapi::INFINITE_); + boost::winapi::DWORD_ retval = boost::winapi::WaitForMultipleObjects(2u, handles, false, boost::winapi::INFINITE_); - if (BOOST_UNLIKELY(retval == boost::detail::winapi::WAIT_FAILED_)) + if (BOOST_UNLIKELY(retval == boost::winapi::WAIT_FAILED_)) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); // Although highly unrealistic, it is possible that it took so long for the current thread to enter WaitForMultipleObjects that // another thread has managed to destroy the semaphore. This can happen if the semaphore remains in a non-zero state @@ -379,7 +379,7 @@ bool interprocess_condition_variable::wait(interprocess_mutex::optional_unlock& // and the non-zero state timeout has passed. In this case the most logical behavior for the wait function is to return as // if because of a wakeup. if (err == ERROR_INVALID_HANDLE) - retval = boost::detail::winapi::WAIT_OBJECT_0_; + retval = boost::winapi::WAIT_OBJECT_0_; else BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to block on an interprocess semaphore object", (err)); } @@ -391,7 +391,7 @@ bool interprocess_condition_variable::wait(interprocess_mutex::optional_unlock& if (generation == m_shared_state->m_generation && m_shared_state->m_waiters > 0) --m_shared_state->m_waiters; - return retval == boost::detail::winapi::WAIT_OBJECT_0_; + return retval == boost::winapi::WAIT_OBJECT_0_; } //! Finds or opens a semaphore with the specified id diff --git a/src/windows/ipc_sync_wrappers.hpp b/src/windows/ipc_sync_wrappers.hpp index 4a614ff..7d1272a 100644 --- a/src/windows/ipc_sync_wrappers.hpp +++ b/src/windows/ipc_sync_wrappers.hpp @@ -17,14 +17,14 @@ #define BOOST_LOG_WINDOWS_IPC_SYNC_WRAPPERS_HPP_INCLUDED_ #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -171,53 +171,53 @@ public: void create_or_open(const wchar_t* name, bool manual_reset, permissions const& perms = permissions()); void open(const wchar_t* name); - boost::detail::winapi::HANDLE_ get_handle() const BOOST_NOEXCEPT { return m_event.get(); } + boost::winapi::HANDLE_ get_handle() const BOOST_NOEXCEPT { return m_event.get(); } void set() { - if (BOOST_UNLIKELY(!boost::detail::winapi::SetEvent(m_event.get()))) + if (BOOST_UNLIKELY(!boost::winapi::SetEvent(m_event.get()))) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to set an interprocess event object", (err)); } } void set_noexcept() BOOST_NOEXCEPT { - BOOST_VERIFY(!!boost::detail::winapi::SetEvent(m_event.get())); + BOOST_VERIFY(!!boost::winapi::SetEvent(m_event.get())); } void reset() { - if (BOOST_UNLIKELY(!boost::detail::winapi::ResetEvent(m_event.get()))) + if (BOOST_UNLIKELY(!boost::winapi::ResetEvent(m_event.get()))) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to reset an interprocess event object", (err)); } } void wait() { - const boost::detail::winapi::DWORD_ retval = boost::detail::winapi::WaitForSingleObject(m_event.get(), boost::detail::winapi::infinite); - if (BOOST_UNLIKELY(retval != boost::detail::winapi::wait_object_0)) + const boost::winapi::DWORD_ retval = boost::winapi::WaitForSingleObject(m_event.get(), boost::winapi::infinite); + if (BOOST_UNLIKELY(retval != boost::winapi::wait_object_0)) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to block on an interprocess event object", (err)); } } - bool wait(boost::detail::winapi::HANDLE_ abort_handle) + bool wait(boost::winapi::HANDLE_ abort_handle) { - boost::detail::winapi::HANDLE_ handles[2u] = { m_event.get(), abort_handle }; - const boost::detail::winapi::DWORD_ retval = boost::detail::winapi::WaitForMultipleObjects(2u, handles, false, boost::detail::winapi::infinite); - if (retval == (boost::detail::winapi::wait_object_0 + 1u)) + boost::winapi::HANDLE_ handles[2u] = { m_event.get(), abort_handle }; + const boost::winapi::DWORD_ retval = boost::winapi::WaitForMultipleObjects(2u, handles, false, boost::winapi::infinite); + if (retval == (boost::winapi::wait_object_0 + 1u)) { // Wait was interrupted return false; } - else if (BOOST_UNLIKELY(retval != boost::detail::winapi::wait_object_0)) + else if (BOOST_UNLIKELY(retval != boost::winapi::wait_object_0)) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to block on an interprocess event object", (err)); } @@ -234,14 +234,14 @@ public: class interprocess_semaphore { private: - typedef boost::detail::winapi::DWORD_ NTSTATUS_; + typedef boost::winapi::DWORD_ NTSTATUS_; struct semaphore_basic_information { - boost::detail::winapi::ULONG_ current_count; // current semaphore count - boost::detail::winapi::ULONG_ maximum_count; // max semaphore count + boost::winapi::ULONG_ current_count; // current semaphore count + boost::winapi::ULONG_ maximum_count; // max semaphore count }; - typedef NTSTATUS_ (__stdcall *nt_query_semaphore_t)(boost::detail::winapi::HANDLE_ h, unsigned int info_class, semaphore_basic_information* pinfo, boost::detail::winapi::ULONG_ info_size, boost::detail::winapi::ULONG_* ret_len); - typedef bool (*is_semaphore_zero_count_t)(boost::detail::winapi::HANDLE_ h); + typedef NTSTATUS_ (__stdcall *nt_query_semaphore_t)(boost::winapi::HANDLE_ h, unsigned int info_class, semaphore_basic_information* pinfo, boost::winapi::ULONG_ info_size, boost::winapi::ULONG_* ret_len); + typedef bool (*is_semaphore_zero_count_t)(boost::winapi::HANDLE_ h); private: auto_handle m_sem; @@ -253,15 +253,15 @@ public: void create_or_open(const wchar_t* name, permissions const& perms = permissions()); void open(const wchar_t* name); - boost::detail::winapi::HANDLE_ get_handle() const BOOST_NOEXCEPT { return m_sem.get(); } + boost::winapi::HANDLE_ get_handle() const BOOST_NOEXCEPT { return m_sem.get(); } void post(uint32_t count) { - BOOST_ASSERT(count <= static_cast< uint32_t >((std::numeric_limits< boost::detail::winapi::LONG_ >::max)())); + BOOST_ASSERT(count <= static_cast< uint32_t >((std::numeric_limits< boost::winapi::LONG_ >::max)())); - if (BOOST_UNLIKELY(!boost::detail::winapi::ReleaseSemaphore(m_sem.get(), static_cast< boost::detail::winapi::LONG_ >(count), NULL))) + if (BOOST_UNLIKELY(!boost::winapi::ReleaseSemaphore(m_sem.get(), static_cast< boost::winapi::LONG_ >(count), NULL))) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to post on an interprocess semaphore object", (err)); } } @@ -273,26 +273,26 @@ public: void wait() { - const boost::detail::winapi::DWORD_ retval = boost::detail::winapi::WaitForSingleObject(m_sem.get(), boost::detail::winapi::infinite); - if (BOOST_UNLIKELY(retval != boost::detail::winapi::wait_object_0)) + const boost::winapi::DWORD_ retval = boost::winapi::WaitForSingleObject(m_sem.get(), boost::winapi::infinite); + if (BOOST_UNLIKELY(retval != boost::winapi::wait_object_0)) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to block on an interprocess semaphore object", (err)); } } - bool wait(boost::detail::winapi::HANDLE_ abort_handle) + bool wait(boost::winapi::HANDLE_ abort_handle) { - boost::detail::winapi::HANDLE_ handles[2u] = { m_sem.get(), abort_handle }; - const boost::detail::winapi::DWORD_ retval = boost::detail::winapi::WaitForMultipleObjects(2u, handles, false, boost::detail::winapi::infinite); - if (retval == (boost::detail::winapi::wait_object_0 + 1u)) + boost::winapi::HANDLE_ handles[2u] = { m_sem.get(), abort_handle }; + const boost::winapi::DWORD_ retval = boost::winapi::WaitForMultipleObjects(2u, handles, false, boost::winapi::infinite); + if (retval == (boost::winapi::wait_object_0 + 1u)) { // Wait was interrupted return false; } - else if (BOOST_UNLIKELY(retval != boost::detail::winapi::wait_object_0)) + else if (BOOST_UNLIKELY(retval != boost::winapi::wait_object_0)) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to block on an interprocess semaphore object", (err)); } @@ -305,9 +305,9 @@ public: } private: - static bool is_semaphore_zero_count_init(boost::detail::winapi::HANDLE_ h); - static bool is_semaphore_zero_count_nt_query_semaphore(boost::detail::winapi::HANDLE_ h); - static bool is_semaphore_zero_count_emulated(boost::detail::winapi::HANDLE_ h); + static bool is_semaphore_zero_count_init(boost::winapi::HANDLE_ h); + static bool is_semaphore_zero_count_nt_query_semaphore(boost::winapi::HANDLE_ h); + static bool is_semaphore_zero_count_emulated(boost::winapi::HANDLE_ h); }; //! Interprocess mutex. Implementation adopted from Boost.Sync. @@ -412,7 +412,7 @@ public: lock_slow(); } - bool lock(boost::detail::winapi::HANDLE_ abort_handle) + bool lock(boost::winapi::HANDLE_ abort_handle) { if (BOOST_LIKELY(try_lock())) return true; @@ -436,7 +436,7 @@ public: private: void lock_slow(); - bool lock_slow(boost::detail::winapi::HANDLE_ abort_handle); + bool lock_slow(boost::winapi::HANDLE_ abort_handle); void mark_waiting_and_try_lock(uint32_t& old_state); void clear_waiting_and_try_lock(uint32_t& old_state); }; @@ -445,17 +445,17 @@ private: struct tick_count_clock { #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - typedef boost::detail::winapi::ULONGLONG_ time_point; + typedef boost::winapi::ULONGLONG_ time_point; #else - typedef boost::detail::winapi::DWORD_ time_point; + typedef boost::winapi::DWORD_ time_point; #endif static time_point now() BOOST_NOEXCEPT { #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - return boost::detail::winapi::GetTickCount64(); + return boost::winapi::GetTickCount64(); #else - return boost::detail::winapi::GetTickCount(); + return boost::winapi::GetTickCount(); #endif } }; @@ -615,7 +615,7 @@ public: } } - bool wait(interprocess_mutex::optional_unlock& lock, boost::detail::winapi::HANDLE_ abort_handle); + bool wait(interprocess_mutex::optional_unlock& lock, boost::winapi::HANDLE_ abort_handle); BOOST_DELETED_FUNCTION(interprocess_condition_variable(interprocess_condition_variable const&)) BOOST_DELETED_FUNCTION(interprocess_condition_variable& operator=(interprocess_condition_variable const&)) diff --git a/src/windows/light_rw_mutex.cpp b/src/windows/light_rw_mutex.cpp index 47d3ebb..010cb55 100644 --- a/src/windows/light_rw_mutex.cpp +++ b/src/windows/light_rw_mutex.cpp @@ -27,8 +27,8 @@ #include #include -#include -#include +#include +#include #include @@ -111,27 +111,27 @@ unlock_shared_fun_t g_pUnlockSharedLWRWMutex = NULL; //! The function dynamically initializes the implementation pointers void init_light_rw_mutex_impl() { - boost::detail::winapi::HMODULE_ hKernel32 = boost::detail::winapi::GetModuleHandleW(L"kernel32.dll"); + boost::winapi::HMODULE_ hKernel32 = boost::winapi::GetModuleHandleW(L"kernel32.dll"); if (hKernel32) { g_pInitializeLWRWMutex = - (init_fun_t)boost::detail::winapi::get_proc_address(hKernel32, "InitializeSRWLock"); + (init_fun_t)boost::winapi::get_proc_address(hKernel32, "InitializeSRWLock"); if (g_pInitializeLWRWMutex) { g_pLockExclusiveLWRWMutex = - (lock_exclusive_fun_t)boost::detail::winapi::get_proc_address(hKernel32, "AcquireSRWLockExclusive"); + (lock_exclusive_fun_t)boost::winapi::get_proc_address(hKernel32, "AcquireSRWLockExclusive"); if (g_pLockExclusiveLWRWMutex) { g_pUnlockExclusiveLWRWMutex = - (unlock_exclusive_fun_t)boost::detail::winapi::get_proc_address(hKernel32, "ReleaseSRWLockExclusive"); + (unlock_exclusive_fun_t)boost::winapi::get_proc_address(hKernel32, "ReleaseSRWLockExclusive"); if (g_pUnlockExclusiveLWRWMutex) { g_pLockSharedLWRWMutex = - (lock_shared_fun_t)boost::detail::winapi::get_proc_address(hKernel32, "AcquireSRWLockShared"); + (lock_shared_fun_t)boost::winapi::get_proc_address(hKernel32, "AcquireSRWLockShared"); if (g_pLockSharedLWRWMutex) { g_pUnlockSharedLWRWMutex = - (unlock_shared_fun_t)boost::detail::winapi::get_proc_address(hKernel32, "ReleaseSRWLockShared"); + (unlock_shared_fun_t)boost::winapi::get_proc_address(hKernel32, "ReleaseSRWLockShared"); if (g_pUnlockSharedLWRWMutex) { g_pDestroyLWRWMutex = &DeinitializeSRWLock; diff --git a/src/windows/mapped_shared_memory.cpp b/src/windows/mapped_shared_memory.cpp index 6f1c9e1..4586c1d 100644 --- a/src/windows/mapped_shared_memory.cpp +++ b/src/windows/mapped_shared_memory.cpp @@ -14,12 +14,12 @@ */ #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include // for error codes #include #include @@ -52,7 +52,7 @@ mapped_shared_memory::~mapped_shared_memory() if (m_handle) { - BOOST_VERIFY(boost::detail::winapi::CloseHandle(m_handle) != 0); + BOOST_VERIFY(boost::winapi::CloseHandle(m_handle) != 0); m_handle = NULL; } } @@ -65,21 +65,21 @@ void mapped_shared_memory::create(const wchar_t* name, std::size_t size, permiss const uint64_t size64 = static_cast< uint64_t >(size); // Unlike other create functions, this function opens the existing mapping, if one already exists - boost::detail::winapi::HANDLE_ h = boost::detail::winapi::CreateFileMappingW + boost::winapi::HANDLE_ h = boost::winapi::CreateFileMappingW ( - boost::detail::winapi::INVALID_HANDLE_VALUE_, - reinterpret_cast< boost::detail::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), - boost::detail::winapi::PAGE_READWRITE_ | boost::detail::winapi::SEC_COMMIT_, - static_cast< boost::detail::winapi::DWORD_ >(size64 >> 32u), - static_cast< boost::detail::winapi::DWORD_ >(size64), + boost::winapi::INVALID_HANDLE_VALUE_, + reinterpret_cast< boost::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), + boost::winapi::PAGE_READWRITE_ | boost::winapi::SEC_COMMIT_, + static_cast< boost::winapi::DWORD_ >(size64 >> 32u), + static_cast< boost::winapi::DWORD_ >(size64), name ); - boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + boost::winapi::DWORD_ err = boost::winapi::GetLastError(); if (BOOST_UNLIKELY(h == NULL || err != ERROR_SUCCESS)) { if (h != NULL) - boost::detail::winapi::CloseHandle(h); + boost::winapi::CloseHandle(h); std::ostringstream strm; strm << "Failed to create a shared memory segment of " << size << " bytes"; BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, strm.str(), (err)); @@ -97,17 +97,17 @@ bool mapped_shared_memory::create_or_open(const wchar_t* name, std::size_t size, const uint64_t size64 = static_cast< uint64_t >(size); // Unlike other create functions, this function opens the existing mapping, if one already exists - boost::detail::winapi::HANDLE_ h = boost::detail::winapi::CreateFileMappingW + boost::winapi::HANDLE_ h = boost::winapi::CreateFileMappingW ( - boost::detail::winapi::INVALID_HANDLE_VALUE_, - reinterpret_cast< boost::detail::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), - boost::detail::winapi::PAGE_READWRITE_ | boost::detail::winapi::SEC_COMMIT_, - static_cast< boost::detail::winapi::DWORD_ >(size64 >> 32u), - static_cast< boost::detail::winapi::DWORD_ >(size64), + boost::winapi::INVALID_HANDLE_VALUE_, + reinterpret_cast< boost::winapi::SECURITY_ATTRIBUTES_* >(perms.get_native()), + boost::winapi::PAGE_READWRITE_ | boost::winapi::SEC_COMMIT_, + static_cast< boost::winapi::DWORD_ >(size64 >> 32u), + static_cast< boost::winapi::DWORD_ >(size64), name ); - boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + boost::winapi::DWORD_ err = boost::winapi::GetLastError(); if (BOOST_UNLIKELY(h == NULL)) { std::ostringstream strm; @@ -130,7 +130,7 @@ bool mapped_shared_memory::create_or_open(const wchar_t* name, std::size_t size, } catch (...) { - boost::detail::winapi::CloseHandle(h); + boost::winapi::CloseHandle(h); throw; } @@ -145,11 +145,11 @@ void mapped_shared_memory::open(const wchar_t* name) BOOST_ASSERT(m_handle == NULL); // Note: FILE_MAP_WRITE implies reading permission as well - boost::detail::winapi::HANDLE_ h = boost::detail::winapi::OpenFileMappingW(boost::detail::winapi::FILE_MAP_WRITE_ | boost::detail::winapi::SECTION_QUERY_, false, name); + boost::winapi::HANDLE_ h = boost::winapi::OpenFileMappingW(boost::winapi::FILE_MAP_WRITE_ | boost::winapi::SECTION_QUERY_, false, name); if (BOOST_UNLIKELY(h == NULL)) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to create a shared memory segment", (err)); } @@ -159,7 +159,7 @@ void mapped_shared_memory::open(const wchar_t* name) } catch (...) { - boost::detail::winapi::CloseHandle(h); + boost::winapi::CloseHandle(h); throw; } @@ -173,10 +173,10 @@ void mapped_shared_memory::map() BOOST_ASSERT(m_mapped_address == NULL); // Note: FILE_MAP_WRITE implies reading permission as well - m_mapped_address = boost::detail::winapi::MapViewOfFile + m_mapped_address = boost::winapi::MapViewOfFile ( m_handle, - boost::detail::winapi::FILE_MAP_WRITE_ | boost::detail::winapi::SECTION_QUERY_, + boost::winapi::FILE_MAP_WRITE_ | boost::winapi::SECTION_QUERY_, 0u, 0u, m_size @@ -184,7 +184,7 @@ void mapped_shared_memory::map() if (BOOST_UNLIKELY(m_mapped_address == NULL)) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to map the shared memory segment into the process address space", (err)); } } @@ -194,29 +194,29 @@ void mapped_shared_memory::unmap() { BOOST_ASSERT(m_mapped_address != NULL); - BOOST_VERIFY(boost::detail::winapi::UnmapViewOfFile(m_mapped_address) != 0); + BOOST_VERIFY(boost::winapi::UnmapViewOfFile(m_mapped_address) != 0); m_mapped_address = NULL; } //! Returns the size of the file mapping identified by the handle -std::size_t mapped_shared_memory::obtain_size(boost::detail::winapi::HANDLE_ h) +std::size_t mapped_shared_memory::obtain_size(boost::winapi::HANDLE_ h) { nt_query_section_t query_section = nt_query_section.load(boost::memory_order_acquire); if (BOOST_UNLIKELY(query_section == NULL)) { // Check if ntdll.dll provides NtQuerySection, see: http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FNT%20Objects%2FSection%2FNtQuerySection.html - boost::detail::winapi::HMODULE_ ntdll = boost::detail::winapi::GetModuleHandleW(L"ntdll.dll"); + boost::winapi::HMODULE_ ntdll = boost::winapi::GetModuleHandleW(L"ntdll.dll"); if (BOOST_UNLIKELY(ntdll == NULL)) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to obtain a handle to ntdll.dll", (err)); } - query_section = (nt_query_section_t)boost::detail::winapi::get_proc_address(ntdll, "NtQuerySection"); + query_section = (nt_query_section_t)boost::winapi::get_proc_address(ntdll, "NtQuerySection"); if (BOOST_UNLIKELY(query_section == NULL)) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to obtain the NtQuerySection function", (err)); } @@ -224,7 +224,7 @@ std::size_t mapped_shared_memory::obtain_size(boost::detail::winapi::HANDLE_ h) } section_basic_information info = {}; - NTSTATUS_ err = query_section + boost::winapi::NTSTATUS_ err = query_section ( h, 0u, // SectionBasicInformation diff --git a/src/windows/mapped_shared_memory.hpp b/src/windows/mapped_shared_memory.hpp index 8caf29f..1b5b85e 100644 --- a/src/windows/mapped_shared_memory.hpp +++ b/src/windows/mapped_shared_memory.hpp @@ -17,7 +17,7 @@ #define BOOST_LOG_WINDOWS_MAPPED_SHARED_MEMORY_HPP_INCLUDED_ #include -#include +#include #include #include #include @@ -40,17 +40,16 @@ namespace aux { class mapped_shared_memory { private: - typedef boost::detail::winapi::DWORD_ NTSTATUS_; struct section_basic_information { void* base_address; - boost::detail::winapi::ULONG_ section_attributes; - boost::detail::winapi::LARGE_INTEGER_ section_size; + boost::winapi::ULONG_ section_attributes; + boost::winapi::LARGE_INTEGER_ section_size; }; - typedef NTSTATUS_ (__stdcall *nt_query_section_t)(boost::detail::winapi::HANDLE_ h, unsigned int info_class, section_basic_information* pinfo, boost::detail::winapi::ULONG_ info_size, boost::detail::winapi::ULONG_* ret_len); + typedef boost::winapi::NTSTATUS_ (__stdcall *nt_query_section_t)(boost::winapi::HANDLE_ h, unsigned int info_class, section_basic_information* pinfo, boost::winapi::ULONG_ info_size, boost::winapi::ULONG_* ret_len); private: - boost::detail::winapi::HANDLE_ m_handle; + boost::winapi::HANDLE_ m_handle; void* m_mapped_address; std::size_t m_size; static boost::atomic< nt_query_section_t > nt_query_section; @@ -87,7 +86,7 @@ public: private: //! Returns the size of the file mapping identified by the handle - static std::size_t obtain_size(boost::detail::winapi::HANDLE_ h); + static std::size_t obtain_size(boost::winapi::HANDLE_ h); }; } // namespace aux diff --git a/src/windows/object_name.cpp b/src/windows/object_name.cpp index e89d100..5b56a03 100644 --- a/src/windows/object_name.cpp +++ b/src/windows/object_name.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -183,7 +183,7 @@ std::string get_scope_prefix(object_name::scope ns) ULONG len = sizeof(buf) / sizeof(*buf); if (BOOST_UNLIKELY(!GetUserNameExW(NameSamCompatible, buf, &len))) { - const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError(); + const boost::winapi::DWORD_ err = boost::winapi::GetLastError(); BOOST_LOG_THROW_DESCR_PARAMS(boost::log::system_error, "Failed to obtain the current user name", (err)); }