From d9ec475d945d3035377a0d89ed42e382d8988891 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Thu, 6 Oct 2016 10:33:54 +0900 Subject: Imported Upstream version 1.60.0 Change-Id: Ie709530d6d5841088ceaba025cbe175a4ef43050 Signed-off-by: DongHun Kwak --- boost/detail/is_incrementable.hpp | 54 ++- boost/detail/winapi/GetCurrentProcess.hpp | 15 +- boost/detail/winapi/GetCurrentThread.hpp | 22 +- boost/detail/winapi/GetLastError.hpp | 14 +- boost/detail/winapi/GetProcessTimes.hpp | 51 ++- boost/detail/winapi/GetThreadTimes.hpp | 42 ++- boost/detail/winapi/LocalFree.hpp | 33 -- boost/detail/winapi/apc.hpp | 47 +++ boost/detail/winapi/basic_types.hpp | 249 +++++++++----- boost/detail/winapi/condition_variable.hpp | 116 +++++++ boost/detail/winapi/config.hpp | 21 +- boost/detail/winapi/critical_section.hpp | 184 +++++++++++ boost/detail/winapi/crypt.hpp | 223 +++++++++---- boost/detail/winapi/detail/cast_ptr.hpp | 40 +++ boost/detail/winapi/directory_management.hpp | 93 ++++-- boost/detail/winapi/dll.hpp | 230 +++++++++---- boost/detail/winapi/error_handling.hpp | 161 +++++---- boost/detail/winapi/event.hpp | 183 +++++++++++ boost/detail/winapi/file_management.hpp | 471 +++++++++++++++++++++------ boost/detail/winapi/file_mapping.hpp | 170 ++++++++++ boost/detail/winapi/handles.hpp | 59 ++-- boost/detail/winapi/heap_memory.hpp | 72 ++++ boost/detail/winapi/init_once.hpp | 123 +++++++ boost/detail/winapi/local_memory.hpp | 51 +++ boost/detail/winapi/memory.hpp | 46 +-- boost/detail/winapi/mutex.hpp | 181 ++++++++++ boost/detail/winapi/process.hpp | 20 +- boost/detail/winapi/security.hpp | 95 +++--- boost/detail/winapi/semaphore.hpp | 170 ++++++++++ boost/detail/winapi/srw_lock.hpp | 105 ++++++ boost/detail/winapi/synchronization.hpp | 285 +--------------- boost/detail/winapi/system.hpp | 81 +++-- boost/detail/winapi/thread.hpp | 41 ++- boost/detail/winapi/thread_pool.hpp | 130 +++++--- boost/detail/winapi/time.hpp | 170 ++++++---- boost/detail/winapi/timers.hpp | 42 +-- boost/detail/winapi/tls.hpp | 49 +-- boost/detail/winapi/wait.hpp | 84 +++++ boost/detail/winapi/waitable_timer.hpp | 148 +++++---- 39 files changed, 3196 insertions(+), 1175 deletions(-) delete mode 100644 boost/detail/winapi/LocalFree.hpp create mode 100644 boost/detail/winapi/apc.hpp create mode 100644 boost/detail/winapi/condition_variable.hpp create mode 100644 boost/detail/winapi/critical_section.hpp create mode 100644 boost/detail/winapi/detail/cast_ptr.hpp create mode 100644 boost/detail/winapi/event.hpp create mode 100644 boost/detail/winapi/file_mapping.hpp create mode 100644 boost/detail/winapi/heap_memory.hpp create mode 100644 boost/detail/winapi/init_once.hpp create mode 100644 boost/detail/winapi/local_memory.hpp create mode 100644 boost/detail/winapi/mutex.hpp create mode 100644 boost/detail/winapi/semaphore.hpp create mode 100644 boost/detail/winapi/srw_lock.hpp create mode 100644 boost/detail/winapi/wait.hpp (limited to 'boost/detail') diff --git a/boost/detail/is_incrementable.hpp b/boost/detail/is_incrementable.hpp index 88ddb14513..5ebf4b7aca 100644 --- a/boost/detail/is_incrementable.hpp +++ b/boost/detail/is_incrementable.hpp @@ -4,16 +4,13 @@ #ifndef IS_INCREMENTABLE_DWA200415_HPP # define IS_INCREMENTABLE_DWA200415_HPP -# include +# include # include # include # include # include -// Must be the last include -# include - -namespace boost { namespace detail { +namespace boost { namespace detail { // is_incrementable metafunction // @@ -27,7 +24,7 @@ namespace is_incrementable_ // a type returned from operator++ when no increment is found in the // type's own namespace struct tag {}; - + // any soaks up implicit conversions and makes the following // operator++ less-preferred than any other such operator that // might be found via ADL. @@ -35,7 +32,7 @@ namespace is_incrementable_ // This is a last-resort operator++ for when none other is found # if BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2 - + } namespace is_incrementable_2 @@ -47,33 +44,33 @@ using namespace is_incrementable_2; namespace is_incrementable_ { - + # else - + tag operator++(any const&); tag operator++(any const&,int); - -# endif + +# endif # if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) # define BOOST_comma(a,b) (a) -# else +# else // In case an operator++ is found that returns void, we'll use ++x,0 - tag operator,(tag,int); + tag operator,(tag,int); # define BOOST_comma(a,b) (a,b) -# endif +# endif # if defined(BOOST_MSVC) # pragma warning(push) # pragma warning(disable:4913) // Warning about operator, -# endif +# endif // two check overloads help us identify which operator++ was picked char (& check_(tag) )[2]; - + template char check_(T const&); - + template struct impl @@ -99,33 +96,28 @@ namespace is_incrementable_ # if defined(BOOST_MSVC) # pragma warning(pop) -# endif +# endif } # undef BOOST_comma -template -struct is_incrementable -BOOST_TT_AUX_BOOL_C_BASE(::boost::detail::is_incrementable_::impl::value) -{ - BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::detail::is_incrementable_::impl::value) +template +struct is_incrementable : + public boost::integral_constant::value> +{ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_incrementable,(T)) }; -template -struct is_postfix_incrementable -BOOST_TT_AUX_BOOL_C_BASE(::boost::detail::is_incrementable_::postfix_impl::value) -{ - BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::detail::is_incrementable_::postfix_impl::value) +template +struct is_postfix_incrementable : + public boost::integral_constant::value> +{ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_postfix_incrementable,(T)) }; } // namespace detail -BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1, ::boost::detail::is_incrementable) -BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1, ::boost::detail::is_postfix_incrementable) - } // namespace boost # include diff --git a/boost/detail/winapi/GetCurrentProcess.hpp b/boost/detail/winapi/GetCurrentProcess.hpp index 51206bb4e8..431b52fa4c 100644 --- a/boost/detail/winapi/GetCurrentProcess.hpp +++ b/boost/detail/winapi/GetCurrentProcess.hpp @@ -1,6 +1,7 @@ // GetCurrentProcess.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -15,15 +16,19 @@ #pragma once #endif +// Windows CE define GetCurrentProcess as an inline function in kfuncs.h +#if !defined( BOOST_USE_WINDOWS_H ) && !defined( UNDER_CE ) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI GetCurrentProcess(BOOST_DETAIL_WINAPI_VOID); +} +#endif + namespace boost { namespace detail { namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetCurrentProcess; -#else - extern "C" __declspec(dllimport) HANDLE_ WINAPI GetCurrentProcess(); -#endif +using ::GetCurrentProcess; } } } + #endif // BOOST_DETAIL_WINAPI_GETCURRENTPROCESS_HPP diff --git a/boost/detail/winapi/GetCurrentThread.hpp b/boost/detail/winapi/GetCurrentThread.hpp index 595b751d13..cbcdc97bda 100644 --- a/boost/detail/winapi/GetCurrentThread.hpp +++ b/boost/detail/winapi/GetCurrentThread.hpp @@ -1,6 +1,7 @@ // GetCurrentThread.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -15,22 +16,17 @@ #pragma once #endif -namespace boost { -namespace detail { -namespace winapi { -#if defined( UNDER_CE ) // Windows CE define GetCurrentThread as an inline function in kfuncs.h -inline HANDLE_ GetCurrentThread() -{ - return ::GetCurrentThread(); +#if !defined( BOOST_USE_WINDOWS_H ) && !defined( UNDER_CE ) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI GetCurrentThread(BOOST_DETAIL_WINAPI_VOID); } -#else -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetCurrentThread; -#else - extern "C" __declspec(dllimport) HANDLE_ WINAPI GetCurrentThread(); -#endif #endif + +namespace boost { +namespace detail { +namespace winapi { +using ::GetCurrentThread; } } } diff --git a/boost/detail/winapi/GetLastError.hpp b/boost/detail/winapi/GetLastError.hpp index 6e9e2d998a..8874ba853a 100644 --- a/boost/detail/winapi/GetLastError.hpp +++ b/boost/detail/winapi/GetLastError.hpp @@ -1,6 +1,7 @@ // GetLastError.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -15,15 +16,16 @@ #pragma once #endif +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI GetLastError(BOOST_DETAIL_WINAPI_VOID); +} +#endif + namespace boost { namespace detail { namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetLastError; -#else - extern "C" __declspec(dllimport) DWORD_ WINAPI - GetLastError(); -#endif +using ::GetLastError; } } } diff --git a/boost/detail/winapi/GetProcessTimes.hpp b/boost/detail/winapi/GetProcessTimes.hpp index f2860b06bd..41b3f0e493 100644 --- a/boost/detail/winapi/GetProcessTimes.hpp +++ b/boost/detail/winapi/GetProcessTimes.hpp @@ -9,31 +9,52 @@ #ifndef BOOST_DETAIL_WINAPI_GETPROCESSTIMES_HPP #define BOOST_DETAIL_WINAPI_GETPROCESSTIMES_HPP -#include +#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif +// Windows CE does not define GetProcessTimes +#if !defined( UNDER_CE ) + +#include +#include + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +GetProcessTimes( + boost::detail::winapi::HANDLE_ hProcess, + ::_FILETIME* lpCreationTime, + ::_FILETIME* lpExitTime, + ::_FILETIME* lpKernelTime, + ::_FILETIME* lpUserTime); +} +#endif + namespace boost { namespace detail { namespace winapi { -#if !defined(UNDER_CE) // Windows CE does not define GetProcessTimes -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetProcessTimes; -#else - extern "C" __declspec(dllimport) BOOL_ WINAPI - GetProcessTimes( - HANDLE_ hProcess, - LPFILETIME_ lpCreationTime, - LPFILETIME_ lpExitTime, - LPFILETIME_ lpKernelTime, - LPFILETIME_ lpUserTime - ); -#endif -#endif + +BOOST_FORCEINLINE BOOL_ GetProcessTimes( + HANDLE_ hProcess, + LPFILETIME_ lpCreationTime, + LPFILETIME_ lpExitTime, + LPFILETIME_ lpKernelTime, + LPFILETIME_ lpUserTime) +{ + return ::GetProcessTimes( + hProcess, + reinterpret_cast< ::_FILETIME* >(lpCreationTime), + reinterpret_cast< ::_FILETIME* >(lpExitTime), + reinterpret_cast< ::_FILETIME* >(lpKernelTime), + reinterpret_cast< ::_FILETIME* >(lpUserTime)); +} + } } } +#endif // !defined( UNDER_CE ) #endif // BOOST_DETAIL_WINAPI_GETPROCESSTIMES_HPP diff --git a/boost/detail/winapi/GetThreadTimes.hpp b/boost/detail/winapi/GetThreadTimes.hpp index 3428edad22..2e1eb8f45c 100644 --- a/boost/detail/winapi/GetThreadTimes.hpp +++ b/boost/detail/winapi/GetThreadTimes.hpp @@ -1,6 +1,7 @@ // GetThreadTimes.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -9,27 +10,44 @@ #ifndef BOOST_DETAIL_WINAPI_GETTHREADTIMES_HPP #define BOOST_DETAIL_WINAPI_GETTHREADTIMES_HPP +#include #include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +GetThreadTimes( + boost::detail::winapi::HANDLE_ hThread, + ::_FILETIME* lpCreationTime, + ::_FILETIME* lpExitTime, + ::_FILETIME* lpKernelTime, + ::_FILETIME* lpUserTime); +} +#endif + namespace boost { namespace detail { namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetThreadTimes; -#else - extern "C" __declspec(dllimport) BOOL_ WINAPI - GetThreadTimes( - HANDLE_ hThread, - LPFILETIME_ lpCreationTime, - LPFILETIME_ lpExitTime, - LPFILETIME_ lpKernelTime, - LPFILETIME_ lpUserTime - ); -#endif + +BOOST_FORCEINLINE BOOL_ GetThreadTimes( + HANDLE_ hThread, + LPFILETIME_ lpCreationTime, + LPFILETIME_ lpExitTime, + LPFILETIME_ lpKernelTime, + LPFILETIME_ lpUserTime) +{ + return ::GetThreadTimes( + hThread, + reinterpret_cast< ::_FILETIME* >(lpCreationTime), + reinterpret_cast< ::_FILETIME* >(lpExitTime), + reinterpret_cast< ::_FILETIME* >(lpKernelTime), + reinterpret_cast< ::_FILETIME* >(lpUserTime)); +} + } } } diff --git a/boost/detail/winapi/LocalFree.hpp b/boost/detail/winapi/LocalFree.hpp deleted file mode 100644 index 697016c0c6..0000000000 --- a/boost/detail/winapi/LocalFree.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// LocalFree.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_LOCALFREE_HPP -#define BOOST_DETAIL_WINAPI_LOCALFREE_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { -namespace detail { -namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - typedef HANDLE_ HLOCAL_; - - using ::LocalFree; -#else - extern "C" typedef HANDLE_ HLOCAL_; - extern "C" __declspec(dllimport) HLOCAL_ WINAPI - LocalFree(HLOCAL_ hMem); -#endif -} -} -} -#endif // BOOST_DETAIL_WINAPI_LOCALFREE_HPP diff --git a/boost/detail/winapi/apc.hpp b/boost/detail/winapi/apc.hpp new file mode 100644 index 0000000000..6913045bec --- /dev/null +++ b/boost/detail/winapi/apc.hpp @@ -0,0 +1,47 @@ +// apc.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_APC_HPP +#define BOOST_DETAIL_WINAPI_APC_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 + +#include + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +typedef boost::detail::winapi::VOID_ +(NTAPI *PAPCFUNC)(boost::detail::winapi::ULONG_PTR_ Parameter); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +QueueUserAPC( + PAPCFUNC pfnAPC, + boost::detail::winapi::HANDLE_ hThread, + boost::detail::winapi::ULONG_PTR_ dwData); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { +typedef ::PAPCFUNC PAPCFUNC_; +using ::QueueUserAPC; +} +} +} + +#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 + +#endif // BOOST_DETAIL_WINAPI_APC_HPP diff --git a/boost/detail/winapi/basic_types.hpp b/boost/detail/winapi/basic_types.hpp index 09d907bdc2..717e934e42 100644 --- a/boost/detail/winapi/basic_types.hpp +++ b/boost/detail/winapi/basic_types.hpp @@ -1,11 +1,11 @@ // basic_types.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt - #ifndef BOOST_DETAIL_WINAPI_BASIC_TYPES_HPP #define BOOST_DETAIL_WINAPI_BASIC_TYPES_HPP @@ -13,11 +13,14 @@ #include #include +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + #if defined( BOOST_USE_WINDOWS_H ) # include #elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined(__CYGWIN__) # include -// @FIXME Which condition must be tested # ifdef UNDER_CE # ifndef WINAPI # ifndef _WIN32_WCE_EMULATION @@ -26,9 +29,14 @@ # define WINAPI __stdcall # endif # endif +// Windows CE defines a few functions as inline functions in kfuncs.h +typedef int BOOL; +typedef unsigned long DWORD; +typedef void* HANDLE; +# include # else # ifndef WINAPI -# define WINAPI __stdcall +# define WINAPI __stdcall # endif # endif # ifndef NTAPI @@ -38,95 +46,178 @@ # error "Win32 functions not available" #endif -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once +#ifndef NO_STRICT +#ifndef STRICT +#define STRICT 1 +#endif +#endif + +#if defined(STRICT) +#define BOOST_DETAIL_WINAPI_DECLARE_HANDLE(x) struct x##__; typedef struct x##__ *x +#else +#define BOOST_DETAIL_WINAPI_DECLARE_HANDLE(x) typedef void* x +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +union _LARGE_INTEGER; +struct _SECURITY_ATTRIBUTES; +BOOST_DETAIL_WINAPI_DECLARE_HANDLE(HINSTANCE); +typedef HINSTANCE HMODULE; +} +#endif + +#if defined(__GNUC__) +#define BOOST_DETAIL_WINAPI_MAY_ALIAS __attribute__ ((__may_alias__)) +#else +#define BOOST_DETAIL_WINAPI_MAY_ALIAS #endif +// MinGW64 gcc 4.8.2 fails to compile function declarations with boost::detail::winapi::VOID_ arguments even though +// the typedef expands to void. In Windows SDK, VOID is a macro which unfolds to void. We use our own macro in such cases. +#define BOOST_DETAIL_WINAPI_VOID void + namespace boost { namespace detail { namespace winapi { #if defined( BOOST_USE_WINDOWS_H ) - typedef ::BOOL BOOL_; - typedef ::BOOLEAN BOOLEAN_; - typedef ::PBOOLEAN PBOOLEAN_; - typedef ::BYTE BYTE_; - typedef ::WORD WORD_; - typedef ::DWORD DWORD_; - typedef ::HANDLE HANDLE_; - typedef ::HMODULE HMODULE_; - typedef ::LONG LONG_; - typedef ::ULONG ULONG_; - typedef ::LONGLONG LONGLONG_; - typedef ::ULONGLONG ULONGLONG_; - typedef ::INT_PTR INT_PTR_; - typedef ::UINT_PTR UINT_PTR_; - typedef ::LONG_PTR LONG_PTR_; - typedef ::ULONG_PTR ULONG_PTR_; - typedef ::LARGE_INTEGER LARGE_INTEGER_; - typedef ::PLARGE_INTEGER PLARGE_INTEGER_; - typedef ::PVOID PVOID_; - typedef ::LPVOID LPVOID_; - typedef ::CHAR CHAR_; - typedef ::LPSTR LPSTR_; - typedef ::LPCSTR LPCSTR_; - typedef ::WCHAR WCHAR_; - typedef ::LPWSTR LPWSTR_; - typedef ::LPCWSTR LPCWSTR_; -#else -extern "C" { - typedef int BOOL_; - typedef unsigned char BYTE_; - typedef BYTE_ BOOLEAN_; - typedef BOOLEAN_* PBOOLEAN_; - typedef unsigned short WORD_; - typedef unsigned long DWORD_; - typedef void* HANDLE_; - typedef void* HMODULE_; - - typedef long LONG_; - typedef unsigned long ULONG_; - - typedef boost::int64_t LONGLONG_; - typedef boost::uint64_t ULONGLONG_; - -// @FIXME Which condition must be tested + +typedef ::BOOL BOOL_; +typedef ::PBOOL PBOOL_; +typedef ::LPBOOL LPBOOL_; +typedef ::BOOLEAN BOOLEAN_; +typedef ::PBOOLEAN PBOOLEAN_; +typedef ::BYTE BYTE_; +typedef ::PBYTE PBYTE_; +typedef ::LPBYTE LPBYTE_; +typedef ::WORD WORD_; +typedef ::PWORD PWORD_; +typedef ::LPWORD LPWORD_; +typedef ::DWORD DWORD_; +typedef ::PDWORD PDWORD_; +typedef ::LPDWORD LPDWORD_; +typedef ::HANDLE HANDLE_; +typedef ::PHANDLE PHANDLE_; +typedef ::INT INT_; +typedef ::PINT PINT_; +typedef ::LPINT LPINT_; +typedef ::UINT UINT_; +typedef ::PUINT PUINT_; +typedef ::LONG LONG_; +typedef ::PLONG PLONG_; +typedef ::LPLONG LPLONG_; +typedef ::ULONG ULONG_; +typedef ::PULONG PULONG_; +typedef ::LONGLONG LONGLONG_; +typedef ::ULONGLONG ULONGLONG_; +typedef ::INT_PTR INT_PTR_; +typedef ::UINT_PTR UINT_PTR_; +typedef ::LONG_PTR LONG_PTR_; +typedef ::ULONG_PTR ULONG_PTR_; +typedef ::DWORD_PTR DWORD_PTR_; +typedef ::PDWORD_PTR PDWORD_PTR_; +typedef ::SIZE_T SIZE_T_; +typedef ::PSIZE_T PSIZE_T_; +typedef ::SSIZE_T SSIZE_T_; +typedef ::PSSIZE_T PSSIZE_T_; +typedef VOID VOID_; // VOID is a macro +typedef ::PVOID PVOID_; +typedef ::LPVOID LPVOID_; +typedef ::LPCVOID LPCVOID_; +typedef ::CHAR CHAR_; +typedef ::LPSTR LPSTR_; +typedef ::LPCSTR LPCSTR_; +typedef ::WCHAR WCHAR_; +typedef ::LPWSTR LPWSTR_; +typedef ::LPCWSTR LPCWSTR_; + +#else // defined( BOOST_USE_WINDOWS_H ) + +typedef int BOOL_; +typedef BOOL_* PBOOL_; +typedef BOOL_* LPBOOL_; +typedef unsigned char BYTE_; +typedef BYTE_* PBYTE_; +typedef BYTE_* LPBYTE_; +typedef BYTE_ BOOLEAN_; +typedef BOOLEAN_* PBOOLEAN_; +typedef unsigned short WORD_; +typedef WORD_* PWORD_; +typedef WORD_* LPWORD_; +typedef unsigned long DWORD_; +typedef DWORD_* PDWORD_; +typedef DWORD_* LPDWORD_; +typedef void* HANDLE_; +typedef void** PHANDLE_; + +typedef int INT_; +typedef INT_* PINT_; +typedef INT_* LPINT_; +typedef unsigned int UINT_; +typedef UINT_* PUINT_; +typedef long LONG_; +typedef LONG_* PLONG_; +typedef LONG_* LPLONG_; +typedef unsigned long ULONG_; +typedef ULONG_* PULONG_; + +typedef boost::int64_t LONGLONG_; +typedef boost::uint64_t ULONGLONG_; + # ifdef _WIN64 -#if defined(__CYGWIN__) - typedef long INT_PTR_; - typedef unsigned long UINT_PTR_; - typedef long LONG_PTR_; - typedef unsigned long ULONG_PTR_; -#else - typedef __int64 INT_PTR_; - typedef unsigned __int64 UINT_PTR_; - typedef __int64 LONG_PTR_; - typedef unsigned __int64 ULONG_PTR_; -#endif +# if defined(__CYGWIN__) +typedef long INT_PTR_; +typedef unsigned long UINT_PTR_; +typedef long LONG_PTR_; +typedef unsigned long ULONG_PTR_; +# else +typedef __int64 INT_PTR_; +typedef unsigned __int64 UINT_PTR_; +typedef __int64 LONG_PTR_; +typedef unsigned __int64 ULONG_PTR_; +# endif # else - typedef int INT_PTR_; - typedef unsigned int UINT_PTR_; - typedef long LONG_PTR_; - typedef unsigned long ULONG_PTR_; +typedef int INT_PTR_; +typedef unsigned int UINT_PTR_; +typedef long LONG_PTR_; +typedef unsigned long ULONG_PTR_; # endif - typedef struct _LARGE_INTEGER { - LONGLONG_ QuadPart; - } LARGE_INTEGER_; - typedef LARGE_INTEGER_ *PLARGE_INTEGER_; +typedef ULONG_PTR_ DWORD_PTR_, *PDWORD_PTR_; +typedef ULONG_PTR_ SIZE_T_, *PSIZE_T_; +typedef LONG_PTR_ SSIZE_T_, *PSSIZE_T_; - typedef void *PVOID_; - typedef void *LPVOID_; - typedef const void *LPCVOID_; +typedef void VOID_; +typedef void *PVOID_; +typedef void *LPVOID_; +typedef const void *LPCVOID_; - typedef char CHAR_; - typedef CHAR_ *LPSTR_; - typedef const CHAR_ *LPCSTR_; +typedef char CHAR_; +typedef CHAR_ *LPSTR_; +typedef const CHAR_ *LPCSTR_; + +typedef wchar_t WCHAR_; +typedef WCHAR_ *LPWSTR_; +typedef const WCHAR_ *LPCWSTR_; + +#endif // defined( BOOST_USE_WINDOWS_H ) + +typedef ::HMODULE HMODULE_; + +typedef union BOOST_DETAIL_WINAPI_MAY_ALIAS _LARGE_INTEGER { + struct { + DWORD_ LowPart; + LONG_ HighPart; + } u; + LONGLONG_ QuadPart; +} LARGE_INTEGER_, *PLARGE_INTEGER_; + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _SECURITY_ATTRIBUTES { + DWORD_ nLength; + LPVOID_ lpSecurityDescriptor; + BOOL_ bInheritHandle; +} SECURITY_ATTRIBUTES_, *PSECURITY_ATTRIBUTES_, *LPSECURITY_ATTRIBUTES_; - typedef wchar_t WCHAR_; - typedef WCHAR_ *LPWSTR_; - typedef const WCHAR_ *LPCWSTR_; -} -#endif } } } diff --git a/boost/detail/winapi/condition_variable.hpp b/boost/detail/winapi/condition_variable.hpp new file mode 100644 index 0000000000..b47a537158 --- /dev/null +++ b/boost/detail/winapi/condition_variable.hpp @@ -0,0 +1,116 @@ +// condition_variable.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_CONDITION_VARIABLE_HPP +#define BOOST_DETAIL_WINAPI_CONDITION_VARIABLE_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + +#include + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +struct _RTL_CONDITION_VARIABLE; +struct _RTL_CRITICAL_SECTION; +struct _RTL_SRWLOCK; + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +InitializeConditionVariable(::_RTL_CONDITION_VARIABLE* ConditionVariable); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +WakeConditionVariable(::_RTL_CONDITION_VARIABLE* ConditionVariable); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +WakeAllConditionVariable(::_RTL_CONDITION_VARIABLE* ConditionVariable); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SleepConditionVariableCS( + ::_RTL_CONDITION_VARIABLE* ConditionVariable, + ::_RTL_CRITICAL_SECTION* CriticalSection, + boost::detail::winapi::DWORD_ dwMilliseconds); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SleepConditionVariableSRW( + ::_RTL_CONDITION_VARIABLE* ConditionVariable, + ::_RTL_SRWLOCK* SRWLock, + boost::detail::winapi::DWORD_ dwMilliseconds, + boost::detail::winapi::ULONG_ Flags); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _RTL_CONDITION_VARIABLE { + PVOID_ Ptr; +} CONDITION_VARIABLE_, *PCONDITION_VARIABLE_; +struct _RTL_CRITICAL_SECTION; +struct _RTL_SRWLOCK; + +BOOST_FORCEINLINE VOID_ InitializeConditionVariable(PCONDITION_VARIABLE_ ConditionVariable) +{ + ::InitializeConditionVariable(reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable)); +} + +BOOST_FORCEINLINE VOID_ WakeConditionVariable(PCONDITION_VARIABLE_ ConditionVariable) +{ + ::WakeConditionVariable(reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable)); +} + +BOOST_FORCEINLINE VOID_ WakeAllConditionVariable(PCONDITION_VARIABLE_ ConditionVariable) +{ + ::WakeAllConditionVariable(reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable)); +} + +BOOST_FORCEINLINE BOOL_ SleepConditionVariableCS( + PCONDITION_VARIABLE_ ConditionVariable, + _RTL_CRITICAL_SECTION* CriticalSection, + DWORD_ dwMilliseconds) +{ + return ::SleepConditionVariableCS( + reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable), + reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(CriticalSection), + dwMilliseconds); +} + +BOOST_FORCEINLINE BOOL_ SleepConditionVariableSRW( + PCONDITION_VARIABLE_ ConditionVariable, + _RTL_SRWLOCK* SRWLock, + DWORD_ dwMilliseconds, + ULONG_ Flags) +{ + return ::SleepConditionVariableSRW( + reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable), + reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock), + dwMilliseconds, + Flags); +} + +#if defined( BOOST_USE_WINDOWS_H ) +const ULONG_ CONDITION_VARIABLE_LOCKMODE_SHARED_ = CONDITION_VARIABLE_LOCKMODE_SHARED; +#else // defined( BOOST_USE_WINDOWS_H ) +const ULONG_ CONDITION_VARIABLE_LOCKMODE_SHARED_ = 0x00000001; +#endif // defined( BOOST_USE_WINDOWS_H ) + +const ULONG_ condition_variable_lockmode_shared = CONDITION_VARIABLE_LOCKMODE_SHARED_; + +} +} +} + +#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + +#endif // BOOST_DETAIL_WINAPI_CONDITION_VARIABLE_HPP diff --git a/boost/detail/winapi/config.hpp b/boost/detail/winapi/config.hpp index 2b0cdfbada..c67d670dd2 100644 --- a/boost/detail/winapi/config.hpp +++ b/boost/detail/winapi/config.hpp @@ -10,11 +10,24 @@ #define BOOST_DETAIL_WINAPI_CONFIG_HPP_INCLUDED_ #include +#if defined __MINGW32__ +#include <_mingw.h> +#endif #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif +// BOOST_WINAPI_IS_MINGW indicates that the target Windows SDK is provided by MinGW (http://mingw.org/). +// BOOST_WINAPI_IS_MINGW_W64 indicates that the target Windows SDK is provided by MinGW-w64 (http://mingw-w64.org). +#if defined __MINGW32__ +#if defined __MINGW64_VERSION_MAJOR +#define BOOST_WINAPI_IS_MINGW_W64 +#else +#define BOOST_WINAPI_IS_MINGW +#endif +#endif + // These constants reflect _WIN32_WINNT_* macros from sdkddkver.h // See also: http://msdn.microsoft.com/en-us/library/windows/desktop/aa383745%28v=vs.85%29.aspx#setting_winver_or__win32_winnt #define BOOST_WINAPI_VERSION_NT4 0x0400 @@ -28,6 +41,8 @@ #define BOOST_WINAPI_VERSION_WIN7 0x0601 #define BOOST_WINAPI_VERSION_WIN8 0x0602 #define BOOST_WINAPI_VERSION_WINBLUE 0x0603 +#define BOOST_WINAPI_VERSION_WINTHRESHOLD 0x0A00 +#define BOOST_WINAPI_VERSION_WIN10 0x0A00 #if !defined(BOOST_USE_WINAPI_VERSION) #if defined(_WIN32_WINNT) @@ -35,8 +50,12 @@ #elif defined(WINVER) #define BOOST_USE_WINAPI_VERSION WINVER #else -// By default use Windows XP API +// By default use Windows Vista API on compilers that support it and XP on the others +#if (defined(_MSC_VER) && _MSC_VER <= 1400) || defined(BOOST_WINAPI_IS_MINGW) #define BOOST_USE_WINAPI_VERSION BOOST_WINAPI_VERSION_WINXP +#else +#define BOOST_USE_WINAPI_VERSION BOOST_WINAPI_VERSION_WIN6 +#endif #endif #endif diff --git a/boost/detail/winapi/critical_section.hpp b/boost/detail/winapi/critical_section.hpp new file mode 100644 index 0000000000..be1d3472c4 --- /dev/null +++ b/boost/detail/winapi/critical_section.hpp @@ -0,0 +1,184 @@ +// critical_section.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_CRITICAL_SECTION_HPP +#define BOOST_DETAIL_WINAPI_CRITICAL_SECTION_HPP + +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) + +extern "C" { +#if !defined( BOOST_WINAPI_IS_MINGW ) +struct _RTL_CRITICAL_SECTION; + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +InitializeCriticalSection(::_RTL_CRITICAL_SECTION* lpCriticalSection); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +EnterCriticalSection(::_RTL_CRITICAL_SECTION* lpCriticalSection); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +LeaveCriticalSection(::_RTL_CRITICAL_SECTION* lpCriticalSection); + +#if BOOST_USE_WINAPI_VERSION >= 0x0403 +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitializeCriticalSectionAndSpinCount( + ::_RTL_CRITICAL_SECTION* lpCriticalSection, + boost::detail::winapi::DWORD_ dwSpinCount); + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitializeCriticalSectionEx( + ::_RTL_CRITICAL_SECTION* lpCriticalSection, + boost::detail::winapi::DWORD_ dwSpinCount, + boost::detail::winapi::DWORD_ Flags); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +SetCriticalSectionSpinCount( + ::_RTL_CRITICAL_SECTION* lpCriticalSection, + boost::detail::winapi::DWORD_ dwSpinCount); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +TryEnterCriticalSection(::_RTL_CRITICAL_SECTION* lpCriticalSection); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +DeleteCriticalSection(::_RTL_CRITICAL_SECTION* lpCriticalSection); + +#else // defined( BOOST_WINAPI_IS_MINGW ) + +// MinGW uses a different name for the structure +struct _CRITICAL_SECTION; + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +InitializeCriticalSection(::_CRITICAL_SECTION* lpCriticalSection); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +EnterCriticalSection(::_CRITICAL_SECTION* lpCriticalSection); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +LeaveCriticalSection(::_CRITICAL_SECTION* lpCriticalSection); + +#if BOOST_USE_WINAPI_VERSION >= 0x0403 +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitializeCriticalSectionAndSpinCount( + ::_CRITICAL_SECTION* lpCriticalSection, + boost::detail::winapi::DWORD_ dwSpinCount); + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitializeCriticalSectionEx( + ::_CRITICAL_SECTION* lpCriticalSection, + boost::detail::winapi::DWORD_ dwSpinCount, + boost::detail::winapi::DWORD_ Flags); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +SetCriticalSectionSpinCount( + ::_CRITICAL_SECTION* lpCriticalSection, + boost::detail::winapi::DWORD_ dwSpinCount); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +TryEnterCriticalSection(::_CRITICAL_SECTION* lpCriticalSection); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +DeleteCriticalSection(::_CRITICAL_SECTION* lpCriticalSection); + +#endif // defined( BOOST_WINAPI_IS_MINGW ) +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +struct _RTL_CRITICAL_SECTION_DEBUG; + +#pragma pack(push, 8) + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _RTL_CRITICAL_SECTION { + _RTL_CRITICAL_SECTION_DEBUG* DebugInfo; + LONG_ LockCount; + LONG_ RecursionCount; + HANDLE_ OwningThread; + HANDLE_ LockSemaphore; + ULONG_PTR_ SpinCount; +} CRITICAL_SECTION_, *PCRITICAL_SECTION_; + +#pragma pack(pop) + +BOOST_FORCEINLINE VOID_ InitializeCriticalSection(CRITICAL_SECTION_* lpCriticalSection) +{ + ::InitializeCriticalSection(winapi::detail::cast_ptr(lpCriticalSection)); +} + +BOOST_FORCEINLINE VOID_ EnterCriticalSection(CRITICAL_SECTION_* lpCriticalSection) +{ + ::EnterCriticalSection(winapi::detail::cast_ptr(lpCriticalSection)); +} + +BOOST_FORCEINLINE VOID_ LeaveCriticalSection(CRITICAL_SECTION_* lpCriticalSection) +{ + ::LeaveCriticalSection(winapi::detail::cast_ptr(lpCriticalSection)); +} + +#if BOOST_USE_WINAPI_VERSION >= 0x0403 +BOOST_FORCEINLINE BOOL_ InitializeCriticalSectionAndSpinCount(CRITICAL_SECTION_* lpCriticalSection, DWORD_ dwSpinCount) +{ + return ::InitializeCriticalSectionAndSpinCount(winapi::detail::cast_ptr(lpCriticalSection), dwSpinCount); +} + +// CRITICAL_SECTION_NO_DEBUG_INFO is defined for WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) +const DWORD_ CRITICAL_SECTION_NO_DEBUG_INFO_ = 0x01000000; +const DWORD_ CRITICAL_SECTION_FLAG_NO_DEBUG_INFO_ = CRITICAL_SECTION_NO_DEBUG_INFO_; +const DWORD_ CRITICAL_SECTION_FLAG_DYNAMIC_SPIN_ = 0x02000000; // undocumented +const DWORD_ CRITICAL_SECTION_FLAG_STATIC_INIT_ = 0x04000000; // undocumented + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE BOOL_ InitializeCriticalSectionEx(CRITICAL_SECTION_* lpCriticalSection, DWORD_ dwSpinCount, DWORD_ Flags) +{ + return ::InitializeCriticalSectionEx(winapi::detail::cast_ptr(lpCriticalSection), dwSpinCount, Flags); +} +#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + +BOOST_FORCEINLINE DWORD_ SetCriticalSectionSpinCount(CRITICAL_SECTION_* lpCriticalSection, DWORD_ dwSpinCount) +{ + return ::SetCriticalSectionSpinCount(winapi::detail::cast_ptr(lpCriticalSection), dwSpinCount); +} +#endif // BOOST_USE_WINAPI_VERSION >= 0x0403 + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 +BOOST_FORCEINLINE BOOL_ TryEnterCriticalSection(CRITICAL_SECTION_* lpCriticalSection) +{ + return ::TryEnterCriticalSection(winapi::detail::cast_ptr(lpCriticalSection)); +} +#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 + +BOOST_FORCEINLINE VOID_ DeleteCriticalSection(CRITICAL_SECTION_* lpCriticalSection) +{ + ::DeleteCriticalSection(winapi::detail::cast_ptr(lpCriticalSection)); +} + +} +} +} + +#endif // BOOST_DETAIL_WINAPI_CRITICAL_SECTION_HPP diff --git a/boost/detail/winapi/crypt.hpp b/boost/detail/winapi/crypt.hpp index c9108f29bf..4d2ebedb01 100644 --- a/boost/detail/winapi/crypt.hpp +++ b/boost/detail/winapi/crypt.hpp @@ -1,6 +1,7 @@ // crypt.hpp --------------------------------------------------------------// // Copyright 2014 Antony Polukhin +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -10,77 +11,181 @@ #define BOOST_DETAIL_WINAPI_CRYPT_HPP #include +#include +#if defined( BOOST_USE_WINDOWS_H ) && defined( BOOST_WINAPI_IS_MINGW ) +// MinGW does not include this header as part of windows.h +#include +#endif #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif -namespace boost -{ -namespace detail -{ -namespace winapi -{ +#if !defined( BOOST_USE_WINDOWS_H ) +namespace boost { namespace detail { namespace winapi { +typedef ULONG_PTR_ HCRYPTPROV_; +}}} + +// Some versions of MinGW (including the latest ones) contain buggy declarations of CryptEnumProvidersA and CryptEnumProvidersW. +// We cannot detect those broken versions, and we can't include the system header because it's incomplete. +// So below we duplicate the broken declarations here and work around the problem with cast_ptr. These declarations +// will have to be removed when MinGW is fixed. + +extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +#if !defined( BOOST_WINAPI_IS_MINGW ) || !defined( UNICODE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptEnumProvidersA( + boost::detail::winapi::DWORD_ dwIndex, + boost::detail::winapi::DWORD_ *pdwReserved, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ *pdwProvType, + boost::detail::winapi::LPSTR_ szProvName, + boost::detail::winapi::DWORD_ *pcbProvName); +#else +// Broken declaration in MinGW +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptEnumProvidersA( + boost::detail::winapi::DWORD_ dwIndex, + boost::detail::winapi::DWORD_ *pdwReserved, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ *pdwProvType, + boost::detail::winapi::LPWSTR_ szProvName, + boost::detail::winapi::DWORD_ *pcbProvName); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptAcquireContextA( + boost::detail::winapi::HCRYPTPROV_ *phProv, + boost::detail::winapi::LPCSTR_ pszContainer, + boost::detail::winapi::LPCSTR_ pszProvider, + boost::detail::winapi::DWORD_ dwProvType, + boost::detail::winapi::DWORD_ dwFlags); +#endif // !defined( BOOST_NO_ANSI_APIS ) + +#if !defined( BOOST_WINAPI_IS_MINGW ) || defined( UNICODE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptEnumProvidersW( + boost::detail::winapi::DWORD_ dwIndex, + boost::detail::winapi::DWORD_ *pdwReserved, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ *pdwProvType, + boost::detail::winapi::LPWSTR_ szProvName, + boost::detail::winapi::DWORD_ *pcbProvName); +#else +// Broken declaration in MinGW +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptEnumProvidersW( + boost::detail::winapi::DWORD_ dwIndex, + boost::detail::winapi::DWORD_ *pdwReserved, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ *pdwProvType, + boost::detail::winapi::LPSTR_ szProvName, + boost::detail::winapi::DWORD_ *pcbProvName); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptAcquireContextW( + boost::detail::winapi::HCRYPTPROV_ *phProv, + boost::detail::winapi::LPCWSTR_ szContainer, + boost::detail::winapi::LPCWSTR_ szProvider, + boost::detail::winapi::DWORD_ dwProvType, + boost::detail::winapi::DWORD_ dwFlags); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptGenRandom( + boost::detail::winapi::HCRYPTPROV_ hProv, + boost::detail::winapi::DWORD_ dwLen, + boost::detail::winapi::BYTE_ *pbBuffer); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptReleaseContext( + boost::detail::winapi::HCRYPTPROV_ hProv, + boost::detail::winapi::DWORD_ dwFlags); +} +#endif // !defined( BOOST_USE_WINDOWS_H ) + +namespace boost { +namespace detail { +namespace winapi { + #if defined( BOOST_USE_WINDOWS_H ) - typedef HCRYPTPROV HCRYPTPROV_; - using ::CryptEnumProvidersA; - using ::CryptAcquireContextA; - using ::CryptGenRandom; - using ::CryptReleaseContext; +typedef ::HCRYPTPROV HCRYPTPROV_; - const DWORD_ PROV_RSA_FULL_ = PROV_RSA_FULL; +const DWORD_ PROV_RSA_FULL_ = PROV_RSA_FULL; + +const DWORD_ CRYPT_VERIFYCONTEXT_ = CRYPT_VERIFYCONTEXT; +const DWORD_ CRYPT_NEWKEYSET_ = CRYPT_NEWKEYSET; +const DWORD_ CRYPT_DELETEKEYSET_ = CRYPT_DELETEKEYSET; +const DWORD_ CRYPT_MACHINE_KEYSET_ = CRYPT_MACHINE_KEYSET; +const DWORD_ CRYPT_SILENT_ = CRYPT_SILENT; - const DWORD_ CRYPT_VERIFYCONTEXT_ = CRYPT_VERIFYCONTEXT; - const DWORD_ CRYPT_NEWKEYSET_ = CRYPT_NEWKEYSET; - const DWORD_ CRYPT_DELETEKEYSET_ = CRYPT_DELETEKEYSET; - const DWORD_ CRYPT_MACHINE_KEYSET_ = CRYPT_MACHINE_KEYSET; - const DWORD_ CRYPT_SILENT_ = CRYPT_SILENT; #else -extern "C" { - typedef ULONG_PTR_ HCRYPTPROV_; - - __declspec(dllimport) BOOL_ __stdcall - CryptEnumProvidersA( - DWORD_ dwIndex, - DWORD_ *pdwReserved, - DWORD_ dwFlags, - DWORD_ *pdwProvType, - LPSTR_ szProvName, - DWORD_ *pcbProvName - ); - - __declspec(dllimport) BOOL_ __stdcall - CryptAcquireContextA( - HCRYPTPROV_ *phProv, - LPCSTR_ pszContainer, - LPCSTR_ pszProvider, - DWORD_ dwProvType, - DWORD_ dwFlags - ); - - __declspec(dllimport) BOOL_ __stdcall - CryptGenRandom( - HCRYPTPROV_ hProv, - DWORD_ dwLen, - BYTE_ *pbBuffer - ); - - __declspec(dllimport) BOOL_ __stdcall - CryptReleaseContext( - HCRYPTPROV_ hProv, - DWORD_ dwFlags - ); - - const DWORD_ PROV_RSA_FULL_ = 1; - - const DWORD_ CRYPT_VERIFYCONTEXT_ = 0xF0000000; - const DWORD_ CRYPT_NEWKEYSET_ = 8; - const DWORD_ CRYPT_DELETEKEYSET_ = 16; - const DWORD_ CRYPT_MACHINE_KEYSET_ = 32; - const DWORD_ CRYPT_SILENT_ = 64; + +const DWORD_ PROV_RSA_FULL_ = 1; + +const DWORD_ CRYPT_VERIFYCONTEXT_ = 0xF0000000; +const DWORD_ CRYPT_NEWKEYSET_ = 8; +const DWORD_ CRYPT_DELETEKEYSET_ = 16; +const DWORD_ CRYPT_MACHINE_KEYSET_ = 32; +const DWORD_ CRYPT_SILENT_ = 64; + +#endif + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::CryptEnumProvidersA; +using ::CryptAcquireContextA; +#endif +using ::CryptEnumProvidersW; +using ::CryptAcquireContextW; +using ::CryptGenRandom; +using ::CryptReleaseContext; + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE BOOL_ crypt_enum_providers( + DWORD_ dwIndex, + DWORD_ *pdwReserved, + DWORD_ dwFlags, + DWORD_ *pdwProvType, + LPSTR_ szProvName, + DWORD_ *pcbProvName) +{ + return ::CryptEnumProvidersA(dwIndex, pdwReserved, dwFlags, pdwProvType, winapi::detail::cast_ptr(szProvName), pcbProvName); +} + +BOOST_FORCEINLINE BOOL_ crypt_acquire_context( + HCRYPTPROV_ *phProv, + LPCSTR_ pszContainer, + LPCSTR_ pszProvider, + DWORD_ dwProvType, + DWORD_ dwFlags) +{ + return ::CryptAcquireContextA(phProv, pszContainer, pszProvider, dwProvType, dwFlags); } #endif + +BOOST_FORCEINLINE BOOL_ crypt_enum_providers( + DWORD_ dwIndex, + DWORD_ *pdwReserved, + DWORD_ dwFlags, + DWORD_ *pdwProvType, + LPWSTR_ szProvName, + DWORD_ *pcbProvName) +{ + return ::CryptEnumProvidersW(dwIndex, pdwReserved, dwFlags, pdwProvType, winapi::detail::cast_ptr(szProvName), pcbProvName); +} + +BOOST_FORCEINLINE BOOL_ crypt_acquire_context( + HCRYPTPROV_ *phProv, + LPCWSTR_ szContainer, + LPCWSTR_ szProvider, + DWORD_ dwProvType, + DWORD_ dwFlags) +{ + return ::CryptAcquireContextW(phProv, szContainer, szProvider, dwProvType, dwFlags); +} + } } } diff --git a/boost/detail/winapi/detail/cast_ptr.hpp b/boost/detail/winapi/detail/cast_ptr.hpp new file mode 100644 index 0000000000..261007ee7a --- /dev/null +++ b/boost/detail/winapi/detail/cast_ptr.hpp @@ -0,0 +1,40 @@ +// cast_ptr.hpp --------------------------------------------------------------// + +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_DETAIL_CAST_PTR_HPP +#define BOOST_DETAIL_WINAPI_DETAIL_CAST_PTR_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace boost { +namespace detail { +namespace winapi { +namespace detail { + +//! This class is used to automatically cast pointers to the type used in the current Windows SDK function declarations +class cast_ptr +{ +private: + const void* m_p; + +public: + explicit BOOST_FORCEINLINE cast_ptr(const void* p) BOOST_NOEXCEPT : m_p(p) {} + template< typename T > + BOOST_FORCEINLINE operator T* () const BOOST_NOEXCEPT { return (T*)m_p; } +}; + +} +} +} +} + +#endif // BOOST_DETAIL_WINAPI_DETAIL_CAST_PTR_HPP diff --git a/boost/detail/winapi/directory_management.hpp b/boost/detail/winapi/directory_management.hpp index 19af1ee4ea..61e406b02e 100644 --- a/boost/detail/winapi/directory_management.hpp +++ b/boost/detail/winapi/directory_management.hpp @@ -1,6 +1,7 @@ // directory_management.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -10,37 +11,83 @@ #define BOOST_DETAIL_WINAPI_DIRECTORY_MANAGEMENT_HPP #include -#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - using ::CreateDirectory; - using ::CreateDirectoryA; - using ::GetTempPathA; - using ::RemoveDirectoryA; -#else -extern "C" { - __declspec(dllimport) int __stdcall - CreateDirectory(LPCTSTR_, LPSECURITY_ATTRIBUTES_*); - __declspec(dllimport) int __stdcall - CreateDirectoryA(LPCTSTR_, interprocess_security_attributes*); - __declspec(dllimport) int __stdcall - GetTempPathA(unsigned long length, char *buffer); - __declspec(dllimport) int __stdcall - RemoveDirectoryA(LPCTSTR_); +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI + CreateDirectoryA(boost::detail::winapi::LPCSTR_, ::_SECURITY_ATTRIBUTES*); +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI + GetTempPathA(boost::detail::winapi::DWORD_ length, boost::detail::winapi::LPSTR_ buffer); +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI + RemoveDirectoryA(boost::detail::winapi::LPCSTR_); +#endif +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI + CreateDirectoryW(boost::detail::winapi::LPCWSTR_, ::_SECURITY_ATTRIBUTES*); +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI + GetTempPathW(boost::detail::winapi::DWORD_ length, boost::detail::winapi::LPWSTR_ buffer); +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI + RemoveDirectoryW(boost::detail::winapi::LPCWSTR_); } #endif + +namespace boost { +namespace detail { +namespace winapi { + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::GetTempPathA; +using ::RemoveDirectoryA; +#endif +using ::GetTempPathW; +using ::RemoveDirectoryW; + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE BOOL_ CreateDirectoryA(LPCSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes) +{ + return ::CreateDirectoryA(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes)); +} +#endif + +BOOST_FORCEINLINE BOOL_ CreateDirectoryW(LPCWSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes) +{ + return ::CreateDirectoryW(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes)); +} + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE BOOL_ create_directory(LPCSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes) +{ + return ::CreateDirectoryA(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes)); +} +BOOST_FORCEINLINE DWORD_ get_temp_path(DWORD_ length, LPSTR_ buffer) +{ + return ::GetTempPathA(length, buffer); +} +BOOST_FORCEINLINE BOOL_ remove_directory(LPCSTR_ pPathName) +{ + return ::RemoveDirectoryA(pPathName); +} +#endif + +BOOST_FORCEINLINE BOOL_ create_directory(LPCWSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes) +{ + return ::CreateDirectoryW(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes)); } +BOOST_FORCEINLINE DWORD_ get_temp_path(DWORD_ length, LPWSTR_ buffer) +{ + return ::GetTempPathW(length, buffer); } +BOOST_FORCEINLINE BOOL_ remove_directory(LPCWSTR_ pPathName) +{ + return ::RemoveDirectoryW(pPathName); } -#endif // BOOST_DETAIL_WINAPI_THREAD_HPP +} // namespace winapi +} // namespace detail +} // namespace boost + +#endif // BOOST_DETAIL_WINAPI_DIRECTORY_MANAGEMENT_HPP diff --git a/boost/detail/winapi/dll.hpp b/boost/detail/winapi/dll.hpp index 2ec5a73bc9..5172f33880 100644 --- a/boost/detail/winapi/dll.hpp +++ b/boost/detail/winapi/dll.hpp @@ -1,6 +1,9 @@ // dll.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2014 Renato Tegon Forti, Antony Polukhin +// Copyright 2015 Andrey Semashev +// Copyright 2015 Antony Polukhin // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -10,77 +13,184 @@ #define BOOST_DETAIL_WINAPI_DLL_HPP #include -#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif -namespace boost +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +namespace boost { namespace detail { namespace winapi { +#ifdef _WIN64 +typedef INT_PTR_ (WINAPI *FARPROC_)(); +typedef INT_PTR_ (WINAPI *NEARPROC_)(); +typedef INT_PTR_ (WINAPI *PROC_)(); +#else +typedef int (WINAPI *FARPROC_)(); +typedef int (WINAPI *NEARPROC_)(); +typedef int (WINAPI *PROC_)(); +#endif // _WIN64 +}}} // namespace boost::detail::winapi + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI +LoadLibraryA(boost::detail::winapi::LPCSTR_ lpFileName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI +LoadLibraryExA( + boost::detail::winapi::LPCSTR_ lpFileName, + boost::detail::winapi::HANDLE_ hFile, + boost::detail::winapi::DWORD_ dwFlags +); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI +GetModuleHandleA(boost::detail::winapi::LPCSTR_ lpFileName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +GetModuleFileNameA( + boost::detail::winapi::HMODULE_ hModule, + boost::detail::winapi::LPSTR_ lpFilename, + boost::detail::winapi::DWORD_ nSize +); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI +LoadLibraryW(boost::detail::winapi::LPCWSTR_ lpFileName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI +LoadLibraryExW( + boost::detail::winapi::LPCWSTR_ lpFileName, + boost::detail::winapi::HANDLE_ hFile, + boost::detail::winapi::DWORD_ dwFlags +); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI +GetModuleHandleW(boost::detail::winapi::LPCWSTR_ lpFileName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +GetModuleFileNameW( + boost::detail::winapi::HMODULE_ hModule, + boost::detail::winapi::LPWSTR_ lpFilename, + boost::detail::winapi::DWORD_ nSize +); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +FreeLibrary(boost::detail::winapi::HMODULE_ hModule); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::FARPROC_ WINAPI +GetProcAddress(boost::detail::winapi::HMODULE_ hModule, boost::detail::winapi::LPCSTR_ lpProcName); + +struct _MEMORY_BASIC_INFORMATION; + +#if !defined( BOOST_WINAPI_IS_MINGW ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::SIZE_T_ WINAPI +VirtualQuery( + boost::detail::winapi::LPCVOID_ lpAddress, + ::_MEMORY_BASIC_INFORMATION* lpBuffer, + boost::detail::winapi::ULONG_PTR_ dwLength +); +#else // !defined( BOOST_WINAPI_IS_MINGW ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +VirtualQuery( + boost::detail::winapi::LPCVOID_ lpAddress, + ::_MEMORY_BASIC_INFORMATION* lpBuffer, + boost::detail::winapi::DWORD_ dwLength +); +#endif // !defined( BOOST_WINAPI_IS_MINGW ) +} // extern "C" +#endif // #if !defined( BOOST_USE_WINDOWS_H ) + +namespace boost { +namespace detail { +namespace winapi { + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS MEMORY_BASIC_INFORMATION_ { + PVOID_ BaseAddress; + PVOID_ AllocationBase; + DWORD_ AllocationProtect; + SIZE_T_ RegionSize; + DWORD_ State; + DWORD_ Protect; + DWORD_ Type; +} *PMEMORY_BASIC_INFORMATION_; + +#if defined( BOOST_USE_WINDOWS_H ) +typedef ::FARPROC FARPROC_; +typedef ::NEARPROC NEARPROC_; +typedef ::PROC PROC_; + +const DWORD_ DONT_RESOLVE_DLL_REFERENCES_ = DONT_RESOLVE_DLL_REFERENCES; +const DWORD_ LOAD_WITH_ALTERED_SEARCH_PATH_ = LOAD_WITH_ALTERED_SEARCH_PATH; +#else // defined( BOOST_USE_WINDOWS_H ) +const DWORD_ DONT_RESOLVE_DLL_REFERENCES_ = 0x00000001; +const DWORD_ LOAD_WITH_ALTERED_SEARCH_PATH_ = 0x00000008; +#endif // defined( BOOST_USE_WINDOWS_H ) + +// This one is not defined by MinGW +const DWORD_ LOAD_IGNORE_CODE_AUTHZ_LEVEL_ = 0x00000010; + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::LoadLibraryA; +using ::LoadLibraryExA; +using ::GetModuleHandleA; +using ::GetModuleFileNameA; +#endif // !defined( BOOST_NO_ANSI_APIS ) +using ::LoadLibraryW; +using ::LoadLibraryExW; +using ::GetModuleHandleW; +using ::GetModuleFileNameW; +using ::FreeLibrary; +using ::GetProcAddress; + +BOOST_FORCEINLINE SIZE_T_ VirtualQuery(LPCVOID_ lpAddress, MEMORY_BASIC_INFORMATION_* lpBuffer, ULONG_PTR_ dwLength) { -namespace detail + return ::VirtualQuery(lpAddress, reinterpret_cast< ::_MEMORY_BASIC_INFORMATION* >(lpBuffer), dwLength); +} + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HMODULE_ load_library(LPCSTR_ lpFileName) { -namespace winapi + return ::LoadLibraryA(lpFileName); +} + +BOOST_FORCEINLINE HMODULE_ load_library_ex(LPCSTR_ lpFileName, HANDLE_ hFile, DWORD_ dwFlags) { -#if defined( BOOST_USE_WINDOWS_H ) - typedef ::FARPROC FARPROC_; - typedef ::NEARPROC NEARPROC_; - typedef ::PROC PROC_; - -# ifdef BOOST_NO_ANSI_APIS - using ::LoadLibraryW; - using ::GetModuleHandleW; -# else - using ::LoadLibraryA; - using ::GetModuleHandleA; -# endif - using ::FreeLibrary; - using ::GetProcAddress; -#else -extern "C" { -# ifdef _WIN64 - typedef INT_PTR_ (WINAPI *FARPROC_)(); - typedef INT_PTR_ (WINAPI *NEARPROC_)(); - typedef INT_PTR_ (WINAPI *PROC_)(); -# else - typedef int (WINAPI *FARPROC_)(); - typedef int (WINAPI *NEARPROC_)(); - typedef int (WINAPI *PROC_)(); -# endif // _WIN64 - -# ifdef BOOST_NO_ANSI_APIS - __declspec(dllimport) HMODULE_ WINAPI - LoadLibraryW( - LPCWSTR_ lpFileName - ); - __declspec(dllimport) HMODULE_ WINAPI - GetModuleHandleW( - LPCWSTR_ lpFileName - ); -# else - __declspec(dllimport) HMODULE_ WINAPI - LoadLibraryA( - LPCSTR_ lpFileName - ); - __declspec(dllimport) HMODULE_ WINAPI - GetModuleHandleA( - LPCSTR_ lpFileName - ); -# endif - - __declspec(dllimport) BOOL_ WINAPI - FreeLibrary( - HMODULE_ hModule - ); - __declspec(dllimport) FARPROC_ WINAPI - GetProcAddress( - HMODULE_ hModule, - LPCSTR_ lpProcName - ); + return ::LoadLibraryExA(lpFileName, hFile, dwFlags); } -#endif + +BOOST_FORCEINLINE HMODULE_ get_module_handle(LPCSTR_ lpFileName) +{ + return ::GetModuleHandleA(lpFileName); } + +BOOST_FORCEINLINE DWORD_ get_module_file_name(HMODULE_ hModule, LPSTR_ lpFilename, DWORD_ nSize) +{ + return ::GetModuleFileNameA(hModule, lpFilename, nSize); } +#endif // #if !defined( BOOST_NO_ANSI_APIS ) + +BOOST_FORCEINLINE HMODULE_ load_library(LPCWSTR_ lpFileName) +{ + return ::LoadLibraryW(lpFileName); +} + +BOOST_FORCEINLINE HMODULE_ load_library_ex(LPCWSTR_ lpFileName, HANDLE_ hFile, DWORD_ dwFlags) +{ + return ::LoadLibraryExW(lpFileName, hFile, dwFlags); } +BOOST_FORCEINLINE HMODULE_ get_module_handle(LPCWSTR_ lpFileName) +{ + return ::GetModuleHandleW(lpFileName); +} + +BOOST_FORCEINLINE DWORD_ get_module_file_name(HMODULE_ hModule, LPWSTR_ lpFilename, DWORD_ nSize) +{ + return ::GetModuleFileNameW(hModule, lpFilename, nSize); +} + +} // namespace winapi +} // namespace detail +} // namespace boost + #endif // BOOST_DETAIL_WINAPI_DLL_HPP diff --git a/boost/detail/winapi/error_handling.hpp b/boost/detail/winapi/error_handling.hpp index fbe9924b25..cdd759ded5 100644 --- a/boost/detail/winapi/error_handling.hpp +++ b/boost/detail/winapi/error_handling.hpp @@ -1,6 +1,7 @@ // error_handling.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -9,85 +10,119 @@ #ifndef BOOST_DETAIL_WINAPI_ERROR_HANDLING_HPP #define BOOST_DETAIL_WINAPI_ERROR_HANDLING_HPP +#include #include -#include +#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +FormatMessageA( + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::LPCVOID_ lpSource, + boost::detail::winapi::DWORD_ dwMessageId, + boost::detail::winapi::DWORD_ dwLanguageId, + boost::detail::winapi::LPSTR_ lpBuffer, + boost::detail::winapi::DWORD_ nSize, + va_list *Arguments); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +FormatMessageW( + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::LPCVOID_ lpSource, + boost::detail::winapi::DWORD_ dwMessageId, + boost::detail::winapi::DWORD_ dwLanguageId, + boost::detail::winapi::LPWSTR_ lpBuffer, + boost::detail::winapi::DWORD_ nSize, + va_list *Arguments); +} +#endif + namespace boost { namespace detail { namespace winapi { #if defined( BOOST_USE_WINDOWS_H ) - using ::FormatMessageA; - using ::FormatMessageW; - - const int FORMAT_MESSAGE_ALLOCATE_BUFFER_= FORMAT_MESSAGE_ALLOCATE_BUFFER; - const int FORMAT_MESSAGE_IGNORE_INSERTS_= FORMAT_MESSAGE_IGNORE_INSERTS; - const int FORMAT_MESSAGE_FROM_STRING_= FORMAT_MESSAGE_FROM_STRING; - const int FORMAT_MESSAGE_FROM_HMODULE_= FORMAT_MESSAGE_FROM_HMODULE; - const int FORMAT_MESSAGE_FROM_SYSTEM_= FORMAT_MESSAGE_FROM_SYSTEM; - const int FORMAT_MESSAGE_ARGUMENT_ARRAY_= FORMAT_MESSAGE_ARGUMENT_ARRAY; - const int FORMAT_MESSAGE_MAX_WIDTH_MASK_= FORMAT_MESSAGE_MAX_WIDTH_MASK; - - const char LANG_NEUTRAL_= LANG_NEUTRAL; - const char LANG_INVARIANT_= LANG_INVARIANT; - - const char SUBLANG_DEFAULT_= SUBLANG_DEFAULT; // user default - inline WORD_ MAKELANGID_(WORD_ p, WORD_ s) { - return MAKELANGID(p,s); - } + +const DWORD_ FORMAT_MESSAGE_ALLOCATE_BUFFER_= FORMAT_MESSAGE_ALLOCATE_BUFFER; +const DWORD_ FORMAT_MESSAGE_IGNORE_INSERTS_= FORMAT_MESSAGE_IGNORE_INSERTS; +const DWORD_ FORMAT_MESSAGE_FROM_STRING_= FORMAT_MESSAGE_FROM_STRING; +const DWORD_ FORMAT_MESSAGE_FROM_HMODULE_= FORMAT_MESSAGE_FROM_HMODULE; +const DWORD_ FORMAT_MESSAGE_FROM_SYSTEM_= FORMAT_MESSAGE_FROM_SYSTEM; +const DWORD_ FORMAT_MESSAGE_ARGUMENT_ARRAY_= FORMAT_MESSAGE_ARGUMENT_ARRAY; +const DWORD_ FORMAT_MESSAGE_MAX_WIDTH_MASK_= FORMAT_MESSAGE_MAX_WIDTH_MASK; + +const WORD_ LANG_NEUTRAL_= LANG_NEUTRAL; +const WORD_ LANG_INVARIANT_= LANG_INVARIANT; + +const WORD_ SUBLANG_DEFAULT_= SUBLANG_DEFAULT; // user default + +BOOST_FORCEINLINE WORD_ MAKELANGID_(WORD_ p, WORD_ s) +{ + return MAKELANGID(p,s); +} + #else -extern "C" { - // using ::FormatMessageA; - __declspec(dllimport) - DWORD_ - WINAPI - FormatMessageA( - DWORD_ dwFlags, - LPCVOID_ lpSource, - DWORD_ dwMessageId, - DWORD_ dwLanguageId, - LPSTR_ lpBuffer, - DWORD_ nSize, - va_list *Arguments - ); - - // using ::FormatMessageW; - __declspec(dllimport) - DWORD_ - WINAPI - FormatMessageW( - DWORD_ dwFlags, - LPCVOID_ lpSource, - DWORD_ dwMessageId, - DWORD_ dwLanguageId, - LPWSTR_ lpBuffer, - DWORD_ nSize, - va_list *Arguments - ); - - const int FORMAT_MESSAGE_ALLOCATE_BUFFER_= 0x00000100; - const int FORMAT_MESSAGE_IGNORE_INSERTS_= 0x00000200; - const int FORMAT_MESSAGE_FROM_STRING_= 0x00000400; - const int FORMAT_MESSAGE_FROM_HMODULE_= 0x00000800; - const int FORMAT_MESSAGE_FROM_SYSTEM_= 0x00001000; - const int FORMAT_MESSAGE_ARGUMENT_ARRAY_= 0x00002000; - const int FORMAT_MESSAGE_MAX_WIDTH_MASK_= 0x000000FF; - - const char LANG_NEUTRAL_= 0x00; - const char LANG_INVARIANT_= 0x7f; - - const char SUBLANG_DEFAULT_= 0x01; // user default - inline WORD_ MAKELANGID_(WORD_ p, WORD_ s) { - return ((((WORD_ )(s)) << 10) | (WORD_ )(p)); - } +const DWORD_ FORMAT_MESSAGE_ALLOCATE_BUFFER_= 0x00000100; +const DWORD_ FORMAT_MESSAGE_IGNORE_INSERTS_= 0x00000200; +const DWORD_ FORMAT_MESSAGE_FROM_STRING_= 0x00000400; +const DWORD_ FORMAT_MESSAGE_FROM_HMODULE_= 0x00000800; +const DWORD_ FORMAT_MESSAGE_FROM_SYSTEM_= 0x00001000; +const DWORD_ FORMAT_MESSAGE_ARGUMENT_ARRAY_= 0x00002000; +const DWORD_ FORMAT_MESSAGE_MAX_WIDTH_MASK_= 0x000000FF; + +const WORD_ LANG_NEUTRAL_= 0x00; +const WORD_ LANG_INVARIANT_= 0x7f; + +const WORD_ SUBLANG_DEFAULT_= 0x01; // user default + +BOOST_FORCEINLINE WORD_ MAKELANGID_(WORD_ p, WORD_ s) +{ + return ((((WORD_)(s)) << 10) | (WORD_)(p)); +} + +#endif + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::FormatMessageA; +#endif +using ::FormatMessageW; + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE DWORD_ format_message( + DWORD_ dwFlags, + LPCVOID_ lpSource, + DWORD_ dwMessageId, + DWORD_ dwLanguageId, + LPSTR_ lpBuffer, + DWORD_ nSize, + va_list *Arguments) +{ + return ::FormatMessageA(dwFlags, lpSource, dwMessageId, dwLanguageId, lpBuffer, nSize, Arguments); } #endif + +BOOST_FORCEINLINE DWORD_ format_message( + DWORD_ dwFlags, + LPCVOID_ lpSource, + DWORD_ dwMessageId, + DWORD_ dwLanguageId, + LPWSTR_ lpBuffer, + DWORD_ nSize, + va_list *Arguments) +{ + return ::FormatMessageW(dwFlags, lpSource, dwMessageId, dwLanguageId, lpBuffer, nSize, Arguments); +} + } } } + #endif // BOOST_DETAIL_WINAPI_ERROR_HANDLING_HPP diff --git a/boost/detail/winapi/event.hpp b/boost/detail/winapi/event.hpp new file mode 100644 index 0000000000..ec2b096103 --- /dev/null +++ b/boost/detail/winapi/event.hpp @@ -0,0 +1,183 @@ +// event.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_EVENT_HPP +#define BOOST_DETAIL_WINAPI_EVENT_HPP + +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +#if !defined( BOOST_PLAT_WINDOWS_RUNTIME_AVALIABLE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateEventA( + ::_SECURITY_ATTRIBUTES* lpEventAttributes, + boost::detail::winapi::BOOL_ bManualReset, + boost::detail::winapi::BOOL_ bInitialState, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateEventExA( + ::_SECURITY_ATTRIBUTES *lpEventAttributes, + boost::detail::winapi::LPCSTR_ lpName, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwDesiredAccess); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenEventA( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateEventW( + ::_SECURITY_ATTRIBUTES* lpEventAttributes, + boost::detail::winapi::BOOL_ bManualReset, + boost::detail::winapi::BOOL_ bInitialState, + boost::detail::winapi::LPCWSTR_ lpName); + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateEventExW( + ::_SECURITY_ATTRIBUTES *lpEventAttributes, + boost::detail::winapi::LPCWSTR_ lpName, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwDesiredAccess); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenEventW( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCWSTR_ lpName); + +// Windows CE define SetEvent/ResetEvent as inline functions in kfuncs.h +#if !defined( UNDER_CE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SetEvent(boost::detail::winapi::HANDLE_ hEvent); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +ResetEvent(boost::detail::winapi::HANDLE_ hEvent); +#endif +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::OpenEventA; +#endif +using ::OpenEventW; +using ::SetEvent; +using ::ResetEvent; + +#if defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ EVENT_ALL_ACCESS_ = EVENT_ALL_ACCESS; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +const DWORD_ CREATE_EVENT_INITIAL_SET_ = CREATE_EVENT_INITIAL_SET; +const DWORD_ CREATE_EVENT_MANUAL_RESET_ = CREATE_EVENT_MANUAL_RESET; +#endif + +#else // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ EVENT_ALL_ACCESS_ = 0x1F0003; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +const DWORD_ CREATE_EVENT_INITIAL_SET_ = 0x00000002; +const DWORD_ CREATE_EVENT_MANUAL_RESET_ = 0x00000001; +#endif + +#endif // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ event_all_access = EVENT_ALL_ACCESS_; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +const DWORD_ create_event_initial_set = CREATE_EVENT_INITIAL_SET_; +const DWORD_ create_event_manual_reset = CREATE_EVENT_MANUAL_RESET_; +#endif + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ CreateEventA(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCSTR_ lpName) +{ +#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + const DWORD_ flags = (bManualReset ? create_event_manual_reset : 0u) | (bInitialState ? create_event_initial_set : 0u); + return ::CreateEventExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, flags, event_all_access); +#else + return ::CreateEventA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), bManualReset, bInitialState, lpName); +#endif +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE HANDLE_ CreateEventExA(SECURITY_ATTRIBUTES_* lpEventAttributes, LPCSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess) +{ + return ::CreateEventExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, dwFlags, dwDesiredAccess); +} +#endif +#endif + +BOOST_FORCEINLINE HANDLE_ CreateEventW(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCWSTR_ lpName) +{ +#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + const DWORD_ flags = (bManualReset ? create_event_manual_reset : 0u) | (bInitialState ? create_event_initial_set : 0u); + return ::CreateEventExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, flags, event_all_access); +#else + return ::CreateEventW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), bManualReset, bInitialState, lpName); +#endif +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE HANDLE_ CreateEventExW(SECURITY_ATTRIBUTES_* lpEventAttributes, LPCWSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess) +{ + return ::CreateEventExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, dwFlags, dwDesiredAccess); +} +#endif + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ create_event(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCSTR_ lpName) +{ + return winapi::CreateEventA(lpEventAttributes, bManualReset, bInitialState, lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_event(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName) +{ + return ::OpenEventA(dwDesiredAccess, bInheritHandle, lpName); +} +#endif + +BOOST_FORCEINLINE HANDLE_ create_event(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCWSTR_ lpName) +{ + return winapi::CreateEventW(lpEventAttributes, bManualReset, bInitialState, lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_event(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName) +{ + return ::OpenEventW(dwDesiredAccess, bInheritHandle, lpName); +} + +BOOST_FORCEINLINE HANDLE_ create_anonymous_event(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState) +{ + return winapi::CreateEventW(lpEventAttributes, bManualReset, bInitialState, 0); +} + +} +} +} + +#endif // BOOST_DETAIL_WINAPI_EVENT_HPP diff --git a/boost/detail/winapi/file_management.hpp b/boost/detail/winapi/file_management.hpp index c1d5978ba7..c923d8499e 100644 --- a/boost/detail/winapi/file_management.hpp +++ b/boost/detail/winapi/file_management.hpp @@ -1,6 +1,7 @@ -// thread.hpp --------------------------------------------------------------// +// file_management.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -10,121 +11,381 @@ #define BOOST_DETAIL_WINAPI_FILE_MANAGEMENT_HPP #include -#include +#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif -namespace boost +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +struct _OVERLAPPED; + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateFileA( + boost::detail::winapi::LPCSTR_ lpFileName, + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::DWORD_ dwShareMode, + ::_SECURITY_ATTRIBUTES* lpSecurityAttributes, + boost::detail::winapi::DWORD_ dwCreationDisposition, + boost::detail::winapi::DWORD_ dwFlagsAndAttributes, + boost::detail::winapi::HANDLE_ hTemplateFile); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +DeleteFileA(boost::detail::winapi::LPCSTR_ lpFileName); + +struct _WIN32_FIND_DATAA; +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +FindFirstFileA(boost::detail::winapi::LPCSTR_ lpFileName, ::_WIN32_FIND_DATAA* lpFindFileData); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +FindNextFileA(boost::detail::winapi::HANDLE_ hFindFile, ::_WIN32_FIND_DATAA* lpFindFileData); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +MoveFileExA( + boost::detail::winapi::LPCSTR_ lpExistingFileName, + boost::detail::winapi::LPCSTR_ lpNewFileName, + boost::detail::winapi::DWORD_ dwFlags); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateFileW( + boost::detail::winapi::LPCWSTR_ lpFileName, + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::DWORD_ dwShareMode, + ::_SECURITY_ATTRIBUTES* lpSecurityAttributes, + boost::detail::winapi::DWORD_ dwCreationDisposition, + boost::detail::winapi::DWORD_ dwFlagsAndAttributes, + boost::detail::winapi::HANDLE_ hTemplateFile); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +DeleteFileW(boost::detail::winapi::LPCWSTR_ lpFileName); + +struct _WIN32_FIND_DATAW; +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +FindFirstFileW(boost::detail::winapi::LPCWSTR_ lpFileName, ::_WIN32_FIND_DATAW* lpFindFileData); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +FindNextFileW(boost::detail::winapi::HANDLE_ hFindFile, ::_WIN32_FIND_DATAW* lpFindFileData); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +MoveFileExW( + boost::detail::winapi::LPCWSTR_ lpExistingFileName, + boost::detail::winapi::LPCWSTR_ lpNewFileName, + boost::detail::winapi::DWORD_ dwFlags); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +FindClose(boost::detail::winapi::HANDLE_ hFindFile); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +GetFileSizeEx(boost::detail::winapi::HANDLE_ hFile, ::_LARGE_INTEGER* lpFileSize); + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WINXP + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SetFileValidData(boost::detail::winapi::HANDLE_ hFile, boost::detail::winapi::LONGLONG_ ValidDataLength); + +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SetEndOfFile(boost::detail::winapi::HANDLE_ hFile); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +LockFile( + boost::detail::winapi::HANDLE_ hFile, + boost::detail::winapi::DWORD_ dwFileOffsetLow, + boost::detail::winapi::DWORD_ dwFileOffsetHigh, + boost::detail::winapi::DWORD_ nNumberOfBytesToLockLow, + boost::detail::winapi::DWORD_ nNumberOfBytesToLockHigh); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +UnlockFile( + boost::detail::winapi::HANDLE_ hFile, + boost::detail::winapi::DWORD_ dwFileOffsetLow, + boost::detail::winapi::DWORD_ dwFileOffsetHigh, + boost::detail::winapi::DWORD_ nNumberOfBytesToUnlockLow, + boost::detail::winapi::DWORD_ nNumberOfBytesToUnlockHigh); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +LockFileEx( + boost::detail::winapi::HANDLE_ hFile, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwReserved, + boost::detail::winapi::DWORD_ nNumberOfBytesToLockLow, + boost::detail::winapi::DWORD_ nNumberOfBytesToLockHigh, + ::_OVERLAPPED* lpOverlapped); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +UnlockFileEx( + boost::detail::winapi::HANDLE_ hFile, + boost::detail::winapi::DWORD_ dwReserved, + boost::detail::winapi::DWORD_ nNumberOfBytesToUnlockLow, + boost::detail::winapi::DWORD_ nNumberOfBytesToUnlockHigh, + ::_OVERLAPPED* lpOverlapped); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +WriteFile( + boost::detail::winapi::HANDLE_ hFile, + boost::detail::winapi::LPCVOID_ lpBuffer, + boost::detail::winapi::DWORD_ nNumberOfBytesToWrite, + boost::detail::winapi::LPDWORD_ lpNumberOfBytesWritten, + ::_OVERLAPPED* lpOverlapped); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::DeleteFileA; +using ::MoveFileExA; +#endif + +using ::DeleteFileW; +using ::MoveFileExW; + +using ::FindClose; + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WINXP + +using ::SetFileValidData; + +#endif + +using ::SetEndOfFile; +using ::LockFile; +using ::UnlockFile; + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _OVERLAPPED { + ULONG_PTR_ Internal; + ULONG_PTR_ InternalHigh; + union { + struct { + DWORD_ Offset; + DWORD_ OffsetHigh; + }; + PVOID_ Pointer; + }; + HANDLE_ hEvent; +} OVERLAPPED_, *LPOVERLAPPED_; + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ CreateFileA( + LPCSTR_ lpFileName, + DWORD_ dwDesiredAccess, + DWORD_ dwShareMode, + SECURITY_ATTRIBUTES_* lpSecurityAttributes, + DWORD_ dwCreationDisposition, + DWORD_ dwFlagsAndAttributes, + HANDLE_ hTemplateFile) { -namespace detail + return ::CreateFileA( + lpFileName, + dwDesiredAccess, + dwShareMode, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes), + dwCreationDisposition, + dwFlagsAndAttributes, + hTemplateFile); +} + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _WIN32_FIND_DATAA { + DWORD_ dwFileAttributes; + FILETIME_ ftCreationTime; + FILETIME_ ftLastAccessTime; + FILETIME_ ftLastWriteTime; + DWORD_ nFileSizeHigh; + DWORD_ nFileSizeLow; + DWORD_ dwReserved0; + DWORD_ dwReserved1; + CHAR_ cFileName[ 260 ]; // MAX_PATH + CHAR_ cAlternateFileName[ 14 ]; +#ifdef _MAC + DWORD_ dwFileType; + DWORD_ dwCreatorType; + WORD_ wFinderFlags; +#endif +} WIN32_FIND_DATAA_, *PWIN32_FIND_DATAA_, *LPWIN32_FIND_DATAA_; + +BOOST_FORCEINLINE HANDLE_ FindFirstFileA(LPCSTR_ lpFileName, WIN32_FIND_DATAA_* lpFindFileData) +{ + return ::FindFirstFileA(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData)); +} + +BOOST_FORCEINLINE BOOL_ FindNextFileA(HANDLE_ hFindFile, WIN32_FIND_DATAA_* lpFindFileData) { -namespace winapi + return ::FindNextFileA(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData)); +} +#endif + +BOOST_FORCEINLINE HANDLE_ CreateFileW( + LPCWSTR_ lpFileName, + DWORD_ dwDesiredAccess, + DWORD_ dwShareMode, + SECURITY_ATTRIBUTES_* lpSecurityAttributes, + DWORD_ dwCreationDisposition, + DWORD_ dwFlagsAndAttributes, + HANDLE_ hTemplateFile) { -#if defined( BOOST_USE_WINDOWS_H ) - using ::CreateFileA; - using ::DeleteFileA; - using ::FindFirstFileA; - using ::FindNextFileA; - using ::FindClose; - using ::GetFileSizeEx; - using ::MoveFileExA; - using ::SetFileValidData; -#else -extern "C" { - typedef struct _OVERLAPPED { - ULONG_PTR Internal; - ULONG_PTR InternalHigh; - union { - struct { - DWORD Offset; - DWORD OffsetHigh; - } ; - PVOID Pointer; - } ; - HANDLE hEvent; - } OVERLAPPED, *LPOVERLAPPED; - - - __declspec(dllimport) void * __stdcall - CreateFileA (const char *, unsigned long, unsigned long, struct SECURITY_ATTRIBUTES_*, unsigned long, unsigned long, void *); - __declspec(dllimport) int __stdcall - DeleteFileA (const char *); - __declspec(dllimport) void *__stdcall - FindFirstFileA(const char *lpFileName, win32_find_data_t *lpFindFileData); - __declspec(dllimport) int __stdcall - FindNextFileA(void *hFindFile, win32_find_data_t *lpFindFileData); - __declspec(dllimport) int __stdcall - FindClose(void *hFindFile); - __declspec(dllimport) BOOL __stdcall - GetFileSizeEx( - HANDLE_ hFile, - PLARGE_INTEGER_ lpFileSize - ); - __declspec(dllimport) int __stdcall - MoveFileExA (const char *, const char *, unsigned long); - __declspec(dllimport) BOOL_ __stdcall - SetFileValidData( - HANDLE_ hFile, - LONGLONG_ ValidDataLength - ); - __declspec(dllimport) BOOL_ __stdcall - SetEndOfFile( - HANDLE_ hFile - ); - __declspec(dllimport) BOOL_ __stdcall - SetFilePointerEx( - HANDLE_ hFile, - LARGE_INTEGER_ liDistanceToMove, - PLARGE_INTEGER_ lpNewFilePointer, - DWORD_ dwMoveMethod - ); - __declspec(dllimport) BOOL_ __stdcall - LockFile( - HANDLE_ hFile, - DWORD_ dwFileOffsetLow, - DWORD_ dwFileOffsetHigh, - DWORD_ nNumberOfBytesToLockLow, - DWORD_ nNumberOfBytesToLockHigh - ); - __declspec(dllimport) BOOL_ __stdcall - UnlockFile( - HANDLE_ hFile, - DWORD_ dwFileOffsetLow, - DWORD_ dwFileOffsetHigh, - DWORD_ nNumberOfBytesToUnlockLow, - DWORD_ nNumberOfBytesToUnlockHigh - ); - __declspec(dllimport) BOOL_ __stdcall - LockFileEx( - HANDLE_ hFile, - DWORD_ dwFlags, - DWORD_ dwReserved, - DWORD_ nNumberOfBytesToLockLow, - DWORD_ nNumberOfBytesToLockHigh, - LPOVERLAPPED_ lpOverlapped - ); - __declspec(dllimport) BOOL_ __stdcall - UnlockFileEx( - HANDLE_ hFile, - DWORD_ dwReserved, - DWORD_ nNumberOfBytesToUnlockLow, - DWORD_ nNumberOfBytesToUnlockHigh, - LPOVERLAPPED_ lpOverlapped - ); - __declspec(dllimport) BOOL_ __stdcall - WriteFile( - HANDLE_ hFile, - LPCVOID_ lpBuffer, - DWORD_ nNumberOfBytesToWrite, - LPDWORD_ lpNumberOfBytesWritten, - LPOVERLAPPED_ lpOverlapped - ); + return ::CreateFileW( + lpFileName, + dwDesiredAccess, + dwShareMode, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes), + dwCreationDisposition, + dwFlagsAndAttributes, + hTemplateFile); } + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _WIN32_FIND_DATAW { + DWORD_ dwFileAttributes; + FILETIME_ ftCreationTime; + FILETIME_ ftLastAccessTime; + FILETIME_ ftLastWriteTime; + DWORD_ nFileSizeHigh; + DWORD_ nFileSizeLow; + DWORD_ dwReserved0; + DWORD_ dwReserved1; + WCHAR_ cFileName[ 260 ]; // MAX_PATH + WCHAR_ cAlternateFileName[ 14 ]; +#ifdef _MAC + DWORD_ dwFileType; + DWORD_ dwCreatorType; + WORD_ wFinderFlags; #endif +} WIN32_FIND_DATAW_, *PWIN32_FIND_DATAW_, *LPWIN32_FIND_DATAW_; + +BOOST_FORCEINLINE HANDLE_ FindFirstFileW(LPCWSTR_ lpFileName, WIN32_FIND_DATAW_* lpFindFileData) +{ + return ::FindFirstFileW(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData)); +} + +BOOST_FORCEINLINE BOOL_ FindNextFileW(HANDLE_ hFindFile, WIN32_FIND_DATAW_* lpFindFileData) +{ + return ::FindNextFileW(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData)); +} + +BOOST_FORCEINLINE BOOL_ GetFileSizeEx(HANDLE_ hFile, LARGE_INTEGER_* lpFileSize) +{ + return ::GetFileSizeEx(hFile, reinterpret_cast< ::_LARGE_INTEGER* >(lpFileSize)); +} + +BOOST_FORCEINLINE BOOL_ LockFileEx( + HANDLE_ hFile, + DWORD_ dwFlags, + DWORD_ dwReserved, + DWORD_ nNumberOfBytesToLockLow, + DWORD_ nNumberOfBytesToLockHigh, + OVERLAPPED_* lpOverlapped) +{ + return ::LockFileEx(hFile, dwFlags, dwReserved, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, reinterpret_cast< ::_OVERLAPPED* >(lpOverlapped)); +} + +BOOST_FORCEINLINE BOOL_ UnlockFileEx( + HANDLE_ hFile, + DWORD_ dwReserved, + DWORD_ nNumberOfBytesToUnlockLow, + DWORD_ nNumberOfBytesToUnlockHigh, + OVERLAPPED_* lpOverlapped) +{ + return ::UnlockFileEx(hFile, dwReserved, nNumberOfBytesToUnlockLow, nNumberOfBytesToUnlockHigh, reinterpret_cast< ::_OVERLAPPED* >(lpOverlapped)); +} + +BOOST_FORCEINLINE BOOL_ WriteFile( + HANDLE_ hFile, + LPCVOID_ lpBuffer, + DWORD_ nNumberOfBytesToWrite, + LPDWORD_ lpNumberOfBytesWritten, + OVERLAPPED_* lpOverlapped) +{ + return ::WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, reinterpret_cast< ::_OVERLAPPED* >(lpOverlapped)); +}; + + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ create_file( + LPCSTR_ lpFileName, + DWORD_ dwDesiredAccess, + DWORD_ dwShareMode, + SECURITY_ATTRIBUTES_* lpSecurityAttributes, + DWORD_ dwCreationDisposition, + DWORD_ dwFlagsAndAttributes, + HANDLE_ hTemplateFile) +{ + return ::CreateFileA( + lpFileName, + dwDesiredAccess, + dwShareMode, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes), + dwCreationDisposition, + dwFlagsAndAttributes, + hTemplateFile); +} + +BOOST_FORCEINLINE BOOL_ delete_file(LPCSTR_ lpFileName) +{ + return ::DeleteFileA(lpFileName); +} + +BOOST_FORCEINLINE HANDLE_ find_first_file(LPCSTR_ lpFileName, WIN32_FIND_DATAA_* lpFindFileData) +{ + return ::FindFirstFileA(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData)); +} + +BOOST_FORCEINLINE BOOL_ find_next_file(HANDLE_ hFindFile, WIN32_FIND_DATAA_* lpFindFileData) +{ + return ::FindNextFileA(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData)); +} + +BOOST_FORCEINLINE BOOL_ move_file(LPCSTR_ lpExistingFileName, LPCSTR_ lpNewFileName, DWORD_ dwFlags) +{ + return ::MoveFileExA(lpExistingFileName, lpNewFileName, dwFlags); +} +#endif + +BOOST_FORCEINLINE HANDLE_ create_file( + LPCWSTR_ lpFileName, + DWORD_ dwDesiredAccess, + DWORD_ dwShareMode, + SECURITY_ATTRIBUTES_* lpSecurityAttributes, + DWORD_ dwCreationDisposition, + DWORD_ dwFlagsAndAttributes, + HANDLE_ hTemplateFile) +{ + return ::CreateFileW( + lpFileName, + dwDesiredAccess, + dwShareMode, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes), + dwCreationDisposition, + dwFlagsAndAttributes, + hTemplateFile); +} + +BOOST_FORCEINLINE BOOL_ delete_file(LPCWSTR_ lpFileName) +{ + return ::DeleteFileW(lpFileName); +} + +BOOST_FORCEINLINE HANDLE_ find_first_file(LPCWSTR_ lpFileName, WIN32_FIND_DATAW_* lpFindFileData) +{ + return ::FindFirstFileW(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData)); +} + +BOOST_FORCEINLINE BOOL_ find_next_file(HANDLE_ hFindFile, WIN32_FIND_DATAW_* lpFindFileData) +{ + return ::FindNextFileW(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData)); +} + +BOOST_FORCEINLINE BOOL_ move_file(LPCWSTR_ lpExistingFileName, LPCWSTR_ lpNewFileName, DWORD_ dwFlags) +{ + return ::MoveFileExW(lpExistingFileName, lpNewFileName, dwFlags); +} + } } } -#endif // BOOST_DETAIL_WINAPI_THREAD_HPP +#endif // BOOST_DETAIL_WINAPI_FILE_MANAGEMENT_HPP diff --git a/boost/detail/winapi/file_mapping.hpp b/boost/detail/winapi/file_mapping.hpp new file mode 100644 index 0000000000..f3cf794b41 --- /dev/null +++ b/boost/detail/winapi/file_mapping.hpp @@ -0,0 +1,170 @@ +// file_mapping.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_FILE_MAPPING_HPP +#define BOOST_DETAIL_WINAPI_FILE_MAPPING_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateFileMappingA( + boost::detail::winapi::HANDLE_ hFile, + ::_SECURITY_ATTRIBUTES* lpFileMappingAttributes, + boost::detail::winapi::DWORD_ flProtect, + boost::detail::winapi::DWORD_ dwMaximumSizeHigh, + boost::detail::winapi::DWORD_ dwMaximumSizeLow, + boost::detail::winapi::LPCSTR_ lpName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenFileMappingA( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateFileMappingW( + boost::detail::winapi::HANDLE_ hFile, + ::_SECURITY_ATTRIBUTES* lpFileMappingAttributes, + boost::detail::winapi::DWORD_ flProtect, + boost::detail::winapi::DWORD_ dwMaximumSizeHigh, + boost::detail::winapi::DWORD_ dwMaximumSizeLow, + boost::detail::winapi::LPCWSTR_ lpName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenFileMappingW( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCWSTR_ lpName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::LPVOID_ WINAPI +MapViewOfFileEx( + boost::detail::winapi::HANDLE_ hFileMappingObject, + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::DWORD_ dwFileOffsetHigh, + boost::detail::winapi::DWORD_ dwFileOffsetLow, + boost::detail::winapi::SIZE_T_ dwNumberOfBytesToMap, + boost::detail::winapi::LPVOID_ lpBaseAddress); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +FlushViewOfFile( + boost::detail::winapi::LPCVOID_ lpBaseAddress, + boost::detail::winapi::SIZE_T_ dwNumberOfBytesToFlush); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +UnmapViewOfFile(boost::detail::winapi::LPCVOID_ lpBaseAddress); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::OpenFileMappingA; +#endif +using ::OpenFileMappingW; +using ::MapViewOfFileEx; +using ::FlushViewOfFile; +using ::UnmapViewOfFile; + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ CreateFileMappingA( + HANDLE_ hFile, + SECURITY_ATTRIBUTES_* lpFileMappingAttributes, + DWORD_ flProtect, + DWORD_ dwMaximumSizeHigh, + DWORD_ dwMaximumSizeLow, + LPCSTR_ lpName) +{ + return ::CreateFileMappingA( + hFile, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpFileMappingAttributes), + flProtect, + dwMaximumSizeHigh, + dwMaximumSizeLow, + lpName); +} +#endif + +BOOST_FORCEINLINE HANDLE_ CreateFileMappingW( + HANDLE_ hFile, + ::_SECURITY_ATTRIBUTES* lpFileMappingAttributes, + DWORD_ flProtect, + DWORD_ dwMaximumSizeHigh, + DWORD_ dwMaximumSizeLow, + LPCWSTR_ lpName) +{ + return ::CreateFileMappingW( + hFile, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpFileMappingAttributes), + flProtect, + dwMaximumSizeHigh, + dwMaximumSizeLow, + lpName); +} + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ create_file_mapping( + HANDLE_ hFile, + SECURITY_ATTRIBUTES_* lpFileMappingAttributes, + DWORD_ flProtect, + DWORD_ dwMaximumSizeHigh, + DWORD_ dwMaximumSizeLow, + LPCSTR_ lpName) +{ + return ::CreateFileMappingA( + hFile, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpFileMappingAttributes), + flProtect, + dwMaximumSizeHigh, + dwMaximumSizeLow, + lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_file_mapping(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName) +{ + return ::OpenFileMappingA(dwDesiredAccess, bInheritHandle, lpName); +} +#endif + +BOOST_FORCEINLINE HANDLE_ create_file_mapping( + HANDLE_ hFile, + ::_SECURITY_ATTRIBUTES* lpFileMappingAttributes, + DWORD_ flProtect, + DWORD_ dwMaximumSizeHigh, + DWORD_ dwMaximumSizeLow, + LPCWSTR_ lpName) +{ + return ::CreateFileMappingW( + hFile, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpFileMappingAttributes), + flProtect, + dwMaximumSizeHigh, + dwMaximumSizeLow, + lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_file_mapping(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName) +{ + return ::OpenFileMappingW(dwDesiredAccess, bInheritHandle, lpName); +} + +} +} +} + +#endif // BOOST_DETAIL_WINAPI_FILE_MAPPING_HPP diff --git a/boost/detail/winapi/handles.hpp b/boost/detail/winapi/handles.hpp index 7108daa10b..54859f46d9 100644 --- a/boost/detail/winapi/handles.hpp +++ b/boost/detail/winapi/handles.hpp @@ -1,6 +1,7 @@ -// memory.hpp --------------------------------------------------------------// +// handles.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -15,30 +16,44 @@ #pragma once #endif -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - using ::CloseHandle; - using ::DuplicateHandle; - - const DWORD_ duplicate_close_source = DUPLICATE_CLOSE_SOURCE; - const DWORD_ duplicate_same_access = DUPLICATE_SAME_ACCESS; - const HANDLE_ invalid_handle_value = INVALID_HANDLE_VALUE; -#else +#if !defined( BOOST_USE_WINDOWS_H ) extern "C" { - __declspec(dllimport) int __stdcall - CloseHandle(void*); - __declspec(dllimport) int __stdcall - DuplicateHandle(void*,void*,void*,void**,unsigned long,int,unsigned long); +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CloseHandle(boost::detail::winapi::HANDLE_ handle); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +DuplicateHandle( + boost::detail::winapi::HANDLE_ hSourceProcessHandle, + boost::detail::winapi::HANDLE_ hSourceHandle, + boost::detail::winapi::HANDLE_ hTargetProcessHandle, + boost::detail::winapi::HANDLE_* lpTargetHandle, + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::DWORD_ dwOptions); } - const DWORD_ duplicate_close_source = 1; - const DWORD_ duplicate_same_access = 2; - const HANDLE_ invalid_handle_value = (HANDLE_)(-1); #endif + +namespace boost { +namespace detail { +namespace winapi { + +using ::CloseHandle; +using ::DuplicateHandle; + +#if defined( BOOST_USE_WINDOWS_H ) +const DWORD_ DUPLICATE_CLOSE_SOURCE_ = DUPLICATE_CLOSE_SOURCE; +const DWORD_ DUPLICATE_SAME_ACCESS_ = DUPLICATE_SAME_ACCESS; +const HANDLE_ INVALID_HANDLE_VALUE_ = INVALID_HANDLE_VALUE; +#else +const DWORD_ DUPLICATE_CLOSE_SOURCE_ = 1; +const DWORD_ DUPLICATE_SAME_ACCESS_ = 2; +const HANDLE_ INVALID_HANDLE_VALUE_ = (HANDLE_)(-1); +#endif + +const DWORD_ duplicate_close_source = DUPLICATE_CLOSE_SOURCE_; +const DWORD_ duplicate_same_access = DUPLICATE_SAME_ACCESS_; +const HANDLE_ invalid_handle_value = INVALID_HANDLE_VALUE_; + } } } diff --git a/boost/detail/winapi/heap_memory.hpp b/boost/detail/winapi/heap_memory.hpp new file mode 100644 index 0000000000..ae863523e4 --- /dev/null +++ b/boost/detail/winapi/heap_memory.hpp @@ -0,0 +1,72 @@ +// heap_memory.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_HEAP_MEMORY_HPP +#define BOOST_DETAIL_WINAPI_HEAP_MEMORY_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +#undef HeapAlloc +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +GetProcessHeap(BOOST_DETAIL_WINAPI_VOID); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +GetProcessHeaps(boost::detail::winapi::DWORD_ NumberOfHeaps, boost::detail::winapi::PHANDLE_ ProcessHeaps); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +HeapCreate( + boost::detail::winapi::DWORD_ flOptions, + boost::detail::winapi::SIZE_T_ dwInitialSize, + boost::detail::winapi::SIZE_T_ dwMaximumSize); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +HeapDestroy(boost::detail::winapi::HANDLE_ hHeap); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::LPVOID_ WINAPI +HeapAlloc( + boost::detail::winapi::HANDLE_ hHeap, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::SIZE_T_ dwBytes); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::LPVOID_ WINAPI +HeapReAlloc( + boost::detail::winapi::HANDLE_ hHeap, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::LPVOID_ lpMem, + boost::detail::winapi::SIZE_T_ dwBytes); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +HeapFree( + boost::detail::winapi::HANDLE_ hHeap, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::LPVOID_ lpMem); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { +using ::GetProcessHeap; +using ::GetProcessHeaps; +using ::HeapCreate; +using ::HeapDestroy; +using ::HeapAlloc; +using ::HeapReAlloc; +using ::HeapFree; +} +} +} + +#endif // BOOST_DETAIL_WINAPI_HEAP_MEMORY_HPP diff --git a/boost/detail/winapi/init_once.hpp b/boost/detail/winapi/init_once.hpp new file mode 100644 index 0000000000..4c0597961e --- /dev/null +++ b/boost/detail/winapi/init_once.hpp @@ -0,0 +1,123 @@ +// init_once.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_INIT_ONCE_HPP +#define BOOST_DETAIL_WINAPI_INIT_ONCE_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + +#include + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if defined( BOOST_WINAPI_IS_MINGW_W64 ) +struct _RTL_RUN_ONCE; +#else +union _RTL_RUN_ONCE; +#endif + +typedef boost::detail::winapi::BOOL_ +(WINAPI *PINIT_ONCE_FN) ( + ::_RTL_RUN_ONCE* InitOnce, + boost::detail::winapi::PVOID_ Parameter, + boost::detail::winapi::PVOID_ *Context); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +InitOnceInitialize(::_RTL_RUN_ONCE* InitOnce); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitOnceExecuteOnce( + ::_RTL_RUN_ONCE* InitOnce, + ::PINIT_ONCE_FN InitFn, + boost::detail::winapi::PVOID_ Parameter, + boost::detail::winapi::LPVOID_ *Context); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitOnceBeginInitialize( + ::_RTL_RUN_ONCE* lpInitOnce, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::PBOOL_ fPending, + boost::detail::winapi::LPVOID_ *lpContext); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitOnceComplete( + ::_RTL_RUN_ONCE* lpInitOnce, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::LPVOID_ lpContext); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +typedef union BOOST_DETAIL_WINAPI_MAY_ALIAS _RTL_RUN_ONCE { + PVOID_ Ptr; +} INIT_ONCE_, *PINIT_ONCE_, *LPINIT_ONCE_; + +extern "C" { +typedef BOOL_ (WINAPI *PINIT_ONCE_FN_) (PINIT_ONCE_ lpInitOnce, PVOID_ Parameter, PVOID_ *Context); +} + +BOOST_FORCEINLINE VOID_ InitOnceInitialize(PINIT_ONCE_ lpInitOnce) +{ + ::InitOnceInitialize(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce)); +} + +BOOST_FORCEINLINE BOOL_ InitOnceExecuteOnce(PINIT_ONCE_ lpInitOnce, PINIT_ONCE_FN_ InitFn, PVOID_ Parameter, LPVOID_ *Context) +{ + return ::InitOnceExecuteOnce(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), reinterpret_cast< ::PINIT_ONCE_FN >(InitFn), Parameter, Context); +} + +BOOST_FORCEINLINE BOOL_ InitOnceBeginInitialize(PINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, PBOOL_ fPending, LPVOID_ *lpContext) +{ + return ::InitOnceBeginInitialize(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), dwFlags, fPending, lpContext); +} + +BOOST_FORCEINLINE BOOL_ InitOnceComplete(PINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, LPVOID_ lpContext) +{ + return ::InitOnceComplete(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), dwFlags, lpContext); +} + +#if defined( BOOST_USE_WINDOWS_H ) + +#define BOOST_DETAIL_WINAPI_INIT_ONCE_STATIC_INIT INIT_ONCE_STATIC_INIT +const DWORD_ INIT_ONCE_ASYNC_ = INIT_ONCE_ASYNC; +const DWORD_ INIT_ONCE_CHECK_ONLY_ = INIT_ONCE_CHECK_ONLY; +const DWORD_ INIT_ONCE_INIT_FAILED_ = INIT_ONCE_INIT_FAILED; +const DWORD_ INIT_ONCE_CTX_RESERVED_BITS_ = INIT_ONCE_CTX_RESERVED_BITS; + +#else // defined( BOOST_USE_WINDOWS_H ) + +#define BOOST_DETAIL_WINAPI_INIT_ONCE_STATIC_INIT {0} +const DWORD_ INIT_ONCE_ASYNC_ = 0x00000002UL; +const DWORD_ INIT_ONCE_CHECK_ONLY_ = 0x00000001UL; +const DWORD_ INIT_ONCE_INIT_FAILED_ = 0x00000004UL; +const DWORD_ INIT_ONCE_CTX_RESERVED_BITS_ = 2; + +#endif // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ init_once_async = INIT_ONCE_ASYNC_; +const DWORD_ init_once_check_only = INIT_ONCE_CHECK_ONLY_; +const DWORD_ init_once_init_failed = INIT_ONCE_INIT_FAILED_; +const DWORD_ init_once_ctx_reserved_bits = INIT_ONCE_CTX_RESERVED_BITS_; + +} +} +} + +#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + +#endif // BOOST_DETAIL_WINAPI_INIT_ONCE_HPP diff --git a/boost/detail/winapi/local_memory.hpp b/boost/detail/winapi/local_memory.hpp new file mode 100644 index 0000000000..17bc08b1bf --- /dev/null +++ b/boost/detail/winapi/local_memory.hpp @@ -0,0 +1,51 @@ +// local_memory.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_LOCAL_MEMORY_HPP +#define BOOST_DETAIL_WINAPI_LOCAL_MEMORY_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +namespace boost { namespace detail { namespace winapi { +typedef HANDLE_ HLOCAL_; +}}} + +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::HLOCAL_ WINAPI +LocalAlloc( + boost::detail::winapi::UINT_ uFlags, + boost::detail::winapi::SIZE_T_ uBytes); +BOOST_SYMBOL_IMPORT boost::detail::winapi::HLOCAL_ WINAPI +LocalReAlloc( + boost::detail::winapi::HLOCAL_ hMem, + boost::detail::winapi::SIZE_T_ uBytes, + boost::detail::winapi::UINT_ uFlags); +BOOST_SYMBOL_IMPORT boost::detail::winapi::HLOCAL_ WINAPI LocalFree(boost::detail::winapi::HLOCAL_ hMem); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { +#if defined( BOOST_USE_WINDOWS_H ) +typedef ::HLOCAL HLOCAL_; +#endif +using ::LocalAlloc; +using ::LocalReAlloc; +using ::LocalFree; +} +} +} + +#endif // BOOST_DETAIL_WINAPI_LOCAL_MEMORY_HPP diff --git a/boost/detail/winapi/memory.hpp b/boost/detail/winapi/memory.hpp index b5316e09e0..3168e21956 100644 --- a/boost/detail/winapi/memory.hpp +++ b/boost/detail/winapi/memory.hpp @@ -1,6 +1,7 @@ // memory.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -9,52 +10,11 @@ #ifndef BOOST_DETAIL_WINAPI_MEMORY_HPP #define BOOST_DETAIL_WINAPI_MEMORY_HPP -#include -#include -#include +#include +#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - using ::CreateFileMappingA; - using ::FlushViewOfFile; - using ::GetProcessHeap; - using ::HeapAlloc; - using ::HeapFree; - using ::MapViewOfFileEx; - using ::OpenFileMappingA; - using ::UnmapViewOfFile; -#else -#undef HeapAlloc -extern "C" { - __declspec(dllimport) void * __stdcall - CreateFileMappingA (void *, SECURITY_ATTRIBUTES_*, unsigned long, unsigned long, unsigned long, const char *); - __declspec(dllimport) int __stdcall - FlushViewOfFile (void *, std::size_t); - __declspec(dllimport) HANDLE_ __stdcall - GetProcessHeap(); - __declspec(dllimport) void* __stdcall - HeapAlloc(HANDLE_,DWORD_,SIZE_T_); - __declspec(dllimport) BOOL_ __stdcall - HeapFree(HANDLE_,DWORD_,LPVOID_); - __declspec(dllimport) void * __stdcall - MapViewOfFileEx (void *, unsigned long, unsigned long, unsigned long, std::size_t, void*); - __declspec(dllimport) void * __stdcall - OpenFileMappingA (unsigned long, int, const char *); - __declspec(dllimport) int __stdcall - UnmapViewOfFile(void *); -} -#endif -} -} -} - #endif // BOOST_DETAIL_WINAPI_MEMORY_HPP diff --git a/boost/detail/winapi/mutex.hpp b/boost/detail/winapi/mutex.hpp new file mode 100644 index 0000000000..8f1975ca5c --- /dev/null +++ b/boost/detail/winapi/mutex.hpp @@ -0,0 +1,181 @@ +// mutex.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_MUTEX_HPP +#define BOOST_DETAIL_WINAPI_MUTEX_HPP + +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +#if !defined( BOOST_PLAT_WINDOWS_RUNTIME_AVALIABLE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateMutexA( + ::_SECURITY_ATTRIBUTES* lpMutexAttributes, + boost::detail::winapi::BOOL_ bInitialOwner, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateMutexExA( + ::_SECURITY_ATTRIBUTES* lpMutexAttributes, + boost::detail::winapi::LPCSTR_ lpName, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwDesiredAccess); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenMutexA( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +#if !defined( BOOST_PLAT_WINDOWS_RUNTIME_AVALIABLE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateMutexW( + ::_SECURITY_ATTRIBUTES* lpMutexAttributes, + boost::detail::winapi::BOOL_ bInitialOwner, + boost::detail::winapi::LPCWSTR_ lpName); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateMutexExW( + ::_SECURITY_ATTRIBUTES* lpMutexAttributes, + boost::detail::winapi::LPCWSTR_ lpName, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwDesiredAccess); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenMutexW( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCWSTR_ lpName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +ReleaseMutex(boost::detail::winapi::HANDLE_ hMutex); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::OpenMutexA; +#endif +using ::OpenMutexW; +using ::ReleaseMutex; + +#if defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ MUTEX_ALL_ACCESS_ = MUTEX_ALL_ACCESS; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +const DWORD_ CREATE_MUTEX_INITIAL_OWNER_ = CREATE_MUTEX_INITIAL_OWNER; +#endif + +#else // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ MUTEX_ALL_ACCESS_ = 0x1F0001; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +const DWORD_ CREATE_MUTEX_INITIAL_OWNER_ = 0x00000001; +#endif + +#endif // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ mutex_all_access = MUTEX_ALL_ACCESS_; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +const DWORD_ create_mutex_initial_owner = CREATE_MUTEX_INITIAL_OWNER_; +#endif + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ CreateMutexA(SECURITY_ATTRIBUTES_* lpMutexAttributes, BOOL_ bInitialOwner, LPCSTR_ lpName) +{ +#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + const DWORD_ flags = bInitialOwner ? create_mutex_initial_owner : 0u; + return ::CreateMutexExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, flags, mutex_all_access); +#else + return ::CreateMutexA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), bInitialOwner, lpName); +#endif +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE HANDLE_ CreateMutexExA( + SECURITY_ATTRIBUTES_* lpMutexAttributes, + LPCSTR_ lpName, + DWORD_ dwFlags, + DWORD_ dwDesiredAccess) +{ + return ::CreateMutexExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, dwFlags, dwDesiredAccess); +} +#endif +#endif + +BOOST_FORCEINLINE HANDLE_ CreateMutexW(SECURITY_ATTRIBUTES_* lpMutexAttributes, BOOL_ bInitialOwner, LPCWSTR_ lpName) +{ +#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + const DWORD_ flags = bInitialOwner ? create_mutex_initial_owner : 0u; + return ::CreateMutexExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, flags, mutex_all_access); +#else + return ::CreateMutexW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), bInitialOwner, lpName); +#endif +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE HANDLE_ CreateMutexExW( + SECURITY_ATTRIBUTES_* lpMutexAttributes, + LPCWSTR_ lpName, + DWORD_ dwFlags, + DWORD_ dwDesiredAccess) +{ + return ::CreateMutexExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, dwFlags, dwDesiredAccess); +} +#endif + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ create_mutex(SECURITY_ATTRIBUTES_* lpAttributes, BOOL_ bInitialOwner, LPCSTR_ lpName) +{ + return winapi::CreateMutexA(lpAttributes, bInitialOwner, lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_mutex(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName) +{ + return ::OpenMutexA(dwDesiredAccess, bInheritHandle, lpName); +} +#endif + +BOOST_FORCEINLINE HANDLE_ create_mutex(SECURITY_ATTRIBUTES_* lpAttributes, BOOL_ bInitialOwner, LPCWSTR_ lpName) +{ + return winapi::CreateMutexW(lpAttributes, bInitialOwner, lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_mutex(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName) +{ + return ::OpenMutexW(dwDesiredAccess, bInheritHandle, lpName); +} + +BOOST_FORCEINLINE HANDLE_ create_anonymous_mutex(SECURITY_ATTRIBUTES_* lpAttributes, BOOL_ bInitialOwner) +{ + return winapi::CreateMutexW(lpAttributes, bInitialOwner, 0); +} + +} +} +} + +#endif // BOOST_DETAIL_WINAPI_MUTEX_HPP diff --git a/boost/detail/winapi/process.hpp b/boost/detail/winapi/process.hpp index de287b15fc..3c3de56e3e 100644 --- a/boost/detail/winapi/process.hpp +++ b/boost/detail/winapi/process.hpp @@ -16,21 +16,19 @@ #pragma once #endif -namespace boost { -namespace detail { -namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetCurrentProcessId; -#else -# ifndef UNDER_CE +// Windows CE define GetCurrentProcessId as an inline function in kfuncs.h +#if !defined( BOOST_USE_WINDOWS_H ) && !defined( UNDER_CE ) extern "C" { - __declspec(dllimport) DWORD_ WINAPI GetCurrentProcessId(void); +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI GetCurrentProcessId(BOOST_DETAIL_WINAPI_VOID); } -# else - using ::GetCurrentProcessId; -# endif #endif + +namespace boost { +namespace detail { +namespace winapi { +using ::GetCurrentProcessId; } } } + #endif // BOOST_DETAIL_WINAPI_PROCESS_HPP diff --git a/boost/detail/winapi/security.hpp b/boost/detail/winapi/security.hpp index 79925c6c67..4a6544519f 100644 --- a/boost/detail/winapi/security.hpp +++ b/boost/detail/winapi/security.hpp @@ -1,6 +1,7 @@ // security.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -15,49 +16,63 @@ #pragma once #endif -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) -typedef ::SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES_; -typedef ::PSECURITY_ATTRIBUTES PSECURITY_ATTRIBUTES_; -typedef ::LPSECURITY_ATTRIBUTES LPSECURITY_ATTRIBUTES_; - +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +struct _ACL; +struct _SECURITY_DESCRIPTOR; +#if defined( BOOST_WINAPI_IS_MINGW ) +typedef _SECURITY_DESCRIPTOR *PSECURITY_DESCRIPTOR; #else -extern "C" { - struct SECURITY_DESCRIPTOR_; - typedef SECURITY_DESCRIPTOR_* PSECURITY_DESCRIPTOR_; - typedef struct _ACL { - BYTE_ AclRevision; - BYTE_ Sbz1; - WORD_ AclSize; - WORD_ AceCount; - WORD_ Sbz2; - } ACL_, *PACL_; - - typedef struct _SECURITY_ATTRIBUTES { - DWORD_ nLength; - LPVOID_ lpSecurityDescriptor; - BOOL_ bInheritHandle; - } SECURITY_ATTRIBUTES_, *PSECURITY_ATTRIBUTES_, *LPSECURITY_ATTRIBUTES_; - - __declspec(dllimport) BOOL_ __stdcall - InitializeSecurityDescriptor( - PSECURITY_DESCRIPTOR_ pSecurityDescriptor, - DWORD_ dwRevision - ); - __declspec(dllimport) BOOL_ __stdcall - SetSecurityDescriptorDacl( - PSECURITY_DESCRIPTOR_ pSecurityDescriptor, - BOOL_ bDaclPresent, - PACL_ pDacl, - BOOL_ bDaclDefaulted - ); +typedef boost::detail::winapi::PVOID_ PSECURITY_DESCRIPTOR; +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitializeSecurityDescriptor( + PSECURITY_DESCRIPTOR pSecurityDescriptor, + boost::detail::winapi::DWORD_ dwRevision); +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SetSecurityDescriptorDacl( + PSECURITY_DESCRIPTOR pSecurityDescriptor, + boost::detail::winapi::BOOL_ bDaclPresent, + ::_ACL* pDacl, + boost::detail::winapi::BOOL_ bDaclDefaulted); } #endif + +namespace boost { +namespace detail { +namespace winapi { + +typedef PVOID_ PSID_; +typedef WORD_ SECURITY_DESCRIPTOR_CONTROL_, *PSECURITY_DESCRIPTOR_CONTROL_; + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _ACL { + BYTE_ AclRevision; + BYTE_ Sbz1; + WORD_ AclSize; + WORD_ AceCount; + WORD_ Sbz2; +} ACL_, *PACL_; + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _SECURITY_DESCRIPTOR { + BYTE_ Revision; + BYTE_ Sbz1; + SECURITY_DESCRIPTOR_CONTROL_ Control; + PSID_ Owner; + PSID_ Group; + PACL_ Sacl; + PACL_ Dacl; +} SECURITY_DESCRIPTOR_, *PISECURITY_DESCRIPTOR_; + +typedef ::PSECURITY_DESCRIPTOR PSECURITY_DESCRIPTOR_; + +using ::InitializeSecurityDescriptor; + +BOOST_FORCEINLINE BOOL_ SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR_ pSecurityDescriptor, BOOL_ bDaclPresent, PACL_ pDacl, BOOL_ bDaclDefaulted) +{ + return ::SetSecurityDescriptorDacl(pSecurityDescriptor, bDaclPresent, reinterpret_cast< ::_ACL* >(pDacl), bDaclDefaulted); +} + } } } diff --git a/boost/detail/winapi/semaphore.hpp b/boost/detail/winapi/semaphore.hpp new file mode 100644 index 0000000000..ba71aae20b --- /dev/null +++ b/boost/detail/winapi/semaphore.hpp @@ -0,0 +1,170 @@ +// semaphore.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_SEMAPHORE_HPP +#define BOOST_DETAIL_WINAPI_SEMAPHORE_HPP + +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +#if !defined( BOOST_PLAT_WINDOWS_RUNTIME_AVALIABLE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateSemaphoreA( + ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes, + boost::detail::winapi::LONG_ lInitialCount, + boost::detail::winapi::LONG_ lMaximumCount, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateSemaphoreExA( + ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes, + boost::detail::winapi::LONG_ lInitialCount, + boost::detail::winapi::LONG_ lMaximumCount, + boost::detail::winapi::LPCSTR_ lpName, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwDesiredAccess); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenSemaphoreA( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateSemaphoreW( + ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes, + boost::detail::winapi::LONG_ lInitialCount, + boost::detail::winapi::LONG_ lMaximumCount, + boost::detail::winapi::LPCWSTR_ lpName); + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateSemaphoreExW( + ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes, + boost::detail::winapi::LONG_ lInitialCount, + boost::detail::winapi::LONG_ lMaximumCount, + boost::detail::winapi::LPCWSTR_ lpName, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwDesiredAccess); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenSemaphoreW( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCWSTR_ lpName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +ReleaseSemaphore( + boost::detail::winapi::HANDLE_ hSemaphore, + boost::detail::winapi::LONG_ lReleaseCount, + boost::detail::winapi::LPLONG_ lpPreviousCount); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::OpenSemaphoreA; +#endif +using ::OpenSemaphoreW; +using ::ReleaseSemaphore; + +#if defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ SEMAPHORE_ALL_ACCESS_ = SEMAPHORE_ALL_ACCESS; + +#else // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ SEMAPHORE_ALL_ACCESS_ = 0x1F0003; + +#endif // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ semaphore_all_access = SEMAPHORE_ALL_ACCESS_; + + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ CreateSemaphoreA(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCSTR_ lpName) +{ +#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + return ::CreateSemaphoreExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName, 0, semaphore_all_access); +#else + return ::CreateSemaphoreA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName); +#endif +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE HANDLE_ CreateSemaphoreExA(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess) +{ + return ::CreateSemaphoreExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName, dwFlags, dwDesiredAccess); +} +#endif +#endif + +BOOST_FORCEINLINE HANDLE_ CreateSemaphoreW(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCWSTR_ lpName) +{ +#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + return ::CreateSemaphoreExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName, 0, semaphore_all_access); +#else + return ::CreateSemaphoreW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName); +#endif +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE HANDLE_ CreateSemaphoreExW(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCWSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess) +{ + return ::CreateSemaphoreExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName, dwFlags, dwDesiredAccess); +} +#endif + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ create_semaphore(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCSTR_ lpName) +{ + return winapi::CreateSemaphoreA(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_semaphore(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName) +{ + return ::OpenSemaphoreA(dwDesiredAccess, bInheritHandle, lpName); +} +#endif + +BOOST_FORCEINLINE HANDLE_ create_semaphore(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCWSTR_ lpName) +{ + return winapi::CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_semaphore(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName) +{ + return ::OpenSemaphoreW(dwDesiredAccess, bInheritHandle, lpName); +} + +BOOST_FORCEINLINE HANDLE_ create_anonymous_semaphore(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount) +{ + return winapi::CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, 0); +} + +} +} +} + +#endif // BOOST_DETAIL_WINAPI_SEMAPHORE_HPP diff --git a/boost/detail/winapi/srw_lock.hpp b/boost/detail/winapi/srw_lock.hpp new file mode 100644 index 0000000000..c5318f5860 --- /dev/null +++ b/boost/detail/winapi/srw_lock.hpp @@ -0,0 +1,105 @@ +// srw_lock.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_SRW_LOCK_HPP +#define BOOST_DETAIL_WINAPI_SRW_LOCK_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + +#include + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +struct _RTL_SRWLOCK; + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +InitializeSRWLock(::_RTL_SRWLOCK* SRWLock); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +ReleaseSRWLockExclusive(::_RTL_SRWLOCK* SRWLock); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +ReleaseSRWLockShared(::_RTL_SRWLOCK* SRWLock); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +AcquireSRWLockExclusive(::_RTL_SRWLOCK* SRWLock); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +AcquireSRWLockShared(::_RTL_SRWLOCK* SRWLock); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOLEAN_ WINAPI +TryAcquireSRWLockExclusive(::_RTL_SRWLOCK* SRWLock); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOLEAN_ WINAPI +TryAcquireSRWLockShared(::_RTL_SRWLOCK* SRWLock); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _RTL_SRWLOCK { + PVOID_ Ptr; +} SRWLOCK_, *PSRWLOCK_; + +#if defined( BOOST_USE_WINDOWS_H ) +#define BOOST_DETAIL_WINAPI_SRWLOCK_INIT SRWLOCK_INIT +#else +#define BOOST_DETAIL_WINAPI_SRWLOCK_INIT {0} +#endif + +BOOST_FORCEINLINE VOID_ InitializeSRWLock(PSRWLOCK_ SRWLock) +{ + ::InitializeSRWLock(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); +} + +BOOST_FORCEINLINE VOID_ ReleaseSRWLockExclusive(PSRWLOCK_ SRWLock) +{ + ::ReleaseSRWLockExclusive(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); +} + +BOOST_FORCEINLINE VOID_ ReleaseSRWLockShared(PSRWLOCK_ SRWLock) +{ + ::ReleaseSRWLockShared(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); +} + +BOOST_FORCEINLINE VOID_ AcquireSRWLockExclusive(PSRWLOCK_ SRWLock) +{ + ::AcquireSRWLockExclusive(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); +} + +BOOST_FORCEINLINE VOID_ AcquireSRWLockShared(PSRWLOCK_ SRWLock) +{ + ::AcquireSRWLockShared(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); +} + +BOOST_FORCEINLINE BOOLEAN_ TryAcquireSRWLockExclusive(PSRWLOCK_ SRWLock) +{ + return ::TryAcquireSRWLockExclusive(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); +} + +BOOST_FORCEINLINE BOOLEAN_ TryAcquireSRWLockShared(PSRWLOCK_ SRWLock) +{ + return ::TryAcquireSRWLockShared(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); +} + +} +} +} + +#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + +#endif // BOOST_DETAIL_WINAPI_SRW_LOCK_HPP diff --git a/boost/detail/winapi/synchronization.hpp b/boost/detail/winapi/synchronization.hpp index b9497cbf7c..d4f8c04cb6 100644 --- a/boost/detail/winapi/synchronization.hpp +++ b/boost/detail/winapi/synchronization.hpp @@ -1,6 +1,7 @@ // synchronizaion.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -10,284 +11,18 @@ #define BOOST_DETAIL_WINAPI_SYNCHRONIZATION_HPP #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - typedef ::CRITICAL_SECTION CRITICAL_SECTION_; - typedef ::PAPCFUNC PAPCFUNC_; - -#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - typedef ::INIT_ONCE INIT_ONCE_; - typedef ::PINIT_ONCE PINIT_ONCE_; - typedef ::LPINIT_ONCE LPINIT_ONCE_; - #define BOOST_DETAIL_WINAPI_INIT_ONCE_STATIC_INIT INIT_ONCE_STATIC_INIT - typedef ::PINIT_ONCE_FN PINIT_ONCE_FN_; - - typedef ::SRWLOCK SRWLOCK_; - typedef ::PSRWLOCK PSRWLOCK_; - #define BOOST_DETAIL_WINAPI_SRWLOCK_INIT SRWLOCK_INIT - - typedef ::CONDITION_VARIABLE CONDITION_VARIABLE_; - typedef ::PCONDITION_VARIABLE PCONDITION_VARIABLE_; - #define BOOST_DETAIL_WINAPI_CONDITION_VARIABLE_INIT CONDITION_VARIABLE_INIT -#endif - - using ::InitializeCriticalSection; -#if BOOST_USE_WINAPI_VERSION >= 0x0403 - using ::InitializeCriticalSectionAndSpinCount; -#endif - using ::EnterCriticalSection; - using ::TryEnterCriticalSection; - using ::LeaveCriticalSection; - using ::DeleteCriticalSection; - -# ifdef BOOST_NO_ANSI_APIS - using ::CreateMutexW; - using ::OpenMutexW; - using ::CreateEventW; - using ::OpenEventW; - using ::CreateSemaphoreW; - using ::OpenSemaphoreW; -# else - using ::CreateMutexA; - using ::OpenMutexA; - using ::CreateEventA; - using ::OpenEventA; - using ::CreateSemaphoreA; - using ::OpenSemaphoreA; -# endif - using ::ReleaseMutex; - using ::ReleaseSemaphore; - using ::SetEvent; - using ::ResetEvent; - using ::WaitForMultipleObjects; - using ::WaitForSingleObject; - using ::QueueUserAPC; - -#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - using ::InitOnceInitialize; - using ::InitOnceExecuteOnce; - using ::InitOnceBeginInitialize; - using ::InitOnceComplete; - - using ::InitializeSRWLock; - using ::AcquireSRWLockExclusive; - using ::TryAcquireSRWLockExclusive; - using ::ReleaseSRWLockExclusive; - using ::AcquireSRWLockShared; - using ::TryAcquireSRWLockShared; - using ::ReleaseSRWLockShared; - - using ::InitializeConditionVariable; - using ::WakeConditionVariable; - using ::WakeAllConditionVariable; - using ::SleepConditionVariableCS; - using ::SleepConditionVariableSRW; -#endif - - const DWORD_ infinite = INFINITE; - const DWORD_ wait_abandoned = WAIT_ABANDONED; - const DWORD_ wait_object_0 = WAIT_OBJECT_0; - const DWORD_ wait_timeout = WAIT_TIMEOUT; - const DWORD_ wait_failed = WAIT_FAILED; - -#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - const DWORD_ init_once_async = INIT_ONCE_ASYNC; - const DWORD_ init_once_check_only = INIT_ONCE_CHECK_ONLY; - const DWORD_ init_once_init_failed = INIT_ONCE_INIT_FAILED; - const DWORD_ init_once_ctx_reserved_bits = INIT_ONCE_CTX_RESERVED_BITS; - - const ULONG_ condition_variable_lockmode_shared = CONDITION_VARIABLE_LOCKMODE_SHARED; -#endif - -#else // defined( BOOST_USE_WINDOWS_H ) - -extern "C" { - - typedef struct CRITICAL_SECTION_ - { - struct critical_section_debug * DebugInfo; - long LockCount; - long RecursionCount; - void * OwningThread; - void * LockSemaphore; - #if defined(_WIN64) - unsigned __int64 SpinCount; - #else - unsigned long SpinCount; - #endif - } - *PCRITICAL_SECTION_; - -#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - typedef union INIT_ONCE_ - { - PVOID_ Ptr; - } - *PINIT_ONCE_, *LPINIT_ONCE_; - #define BOOST_DETAIL_WINAPI_INIT_ONCE_STATIC_INIT {0} - typedef BOOL_ (WINAPI *PINIT_ONCE_FN_)(PINIT_ONCE_ InitOnce, PVOID_ Parameter, PVOID_ *Context); - - typedef struct SRWLOCK_ - { - PVOID_ Ptr; - } - * PSRWLOCK_; - #define BOOST_DETAIL_WINAPI_SRWLOCK_INIT {0} - - typedef struct CONDITION_VARIABLE_ - { - PVOID_ Ptr; - } - * PCONDITION_VARIABLE_; - #define BOOST_DETAIL_WINAPI_CONDITION_VARIABLE_INIT {0} - -#endif - - __declspec(dllimport) void WINAPI - InitializeCriticalSection(PCRITICAL_SECTION_); -#if BOOST_USE_WINAPI_VERSION >= 0x0403 - __declspec(dllimport) BOOL_ WINAPI - InitializeCriticalSectionAndSpinCount(CRITICAL_SECTION_* lpCS, DWORD_ dwSpinCount); -#endif - __declspec(dllimport) void WINAPI - EnterCriticalSection(PCRITICAL_SECTION_); - __declspec(dllimport) BOOL_ WINAPI - TryEnterCriticalSection(PCRITICAL_SECTION_); - __declspec(dllimport) void WINAPI - LeaveCriticalSection(PCRITICAL_SECTION_); - __declspec(dllimport) void WINAPI - DeleteCriticalSection(PCRITICAL_SECTION_); - - struct _SECURITY_ATTRIBUTES; -# ifdef BOOST_NO_ANSI_APIS - __declspec(dllimport) HANDLE_ WINAPI - CreateMutexW(_SECURITY_ATTRIBUTES*, BOOL_, LPCWSTR_); - __declspec(dllimport) HANDLE_ WINAPI - OpenMutexW(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName); - __declspec(dllimport) HANDLE_ WINAPI - CreateSemaphoreW(_SECURITY_ATTRIBUTES*, LONG_, LONG_, LPCWSTR_); - __declspec(dllimport) HANDLE_ WINAPI - OpenSemaphoreW(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName); - __declspec(dllimport) HANDLE_ WINAPI - CreateEventW(_SECURITY_ATTRIBUTES*, BOOL_, BOOL_, LPCWSTR_); - __declspec(dllimport) HANDLE_ WINAPI - OpenEventW(DWORD_, BOOL_, LPCWSTR_); -# else - __declspec(dllimport) HANDLE_ WINAPI - CreateMutexA(_SECURITY_ATTRIBUTES*, BOOL_, LPCSTR_); - __declspec(dllimport) HANDLE_ WINAPI - OpenMutexA(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName); - __declspec(dllimport) HANDLE_ WINAPI - CreateSemaphoreA(_SECURITY_ATTRIBUTES*, LONG_, LONG_, LPCSTR_); - __declspec(dllimport) HANDLE_ WINAPI - OpenSemaphoreA(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName); - __declspec(dllimport) HANDLE_ WINAPI - CreateEventA(_SECURITY_ATTRIBUTES*, BOOL_, BOOL_, LPCSTR_); - __declspec(dllimport) HANDLE_ WINAPI - OpenEventA(DWORD_, BOOL_, LPCSTR_); -# endif - __declspec(dllimport) BOOL_ WINAPI - ReleaseMutex(HANDLE_); - __declspec(dllimport) DWORD_ WINAPI - WaitForSingleObject(HANDLE_, DWORD_); - __declspec(dllimport) DWORD_ WINAPI - WaitForMultipleObjects(DWORD_ nCount, - HANDLE_ const * lpHandles, - BOOL_ bWaitAll, - DWORD_ dwMilliseconds); - __declspec(dllimport) BOOL_ WINAPI - ReleaseSemaphore(HANDLE_, LONG_, LONG_*); - __declspec(dllimport) BOOL_ WINAPI - SetEvent(HANDLE_); - __declspec(dllimport) BOOL_ WINAPI - ResetEvent(HANDLE_); - - typedef void (__stdcall *PAPCFUNC_)(ULONG_PTR_); - __declspec(dllimport) DWORD_ WINAPI - QueueUserAPC(PAPCFUNC_, HANDLE_, ULONG_PTR_); - -#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - __declspec(dllimport) void WINAPI InitOnceInitialize(PINIT_ONCE_); - __declspec(dllimport) BOOL_ WINAPI InitOnceExecuteOnce(PINIT_ONCE_ InitOnce, PINIT_ONCE_FN_ InitFn, PVOID_ Parameter, LPVOID_* Context); - __declspec(dllimport) BOOL_ WINAPI InitOnceBeginInitialize(LPINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, BOOL_* fPending, LPVOID_* lpContext); - __declspec(dllimport) BOOL_ WINAPI InitOnceComplete(LPINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, LPVOID_* lpContext); - - - __declspec(dllimport) void WINAPI InitializeSRWLock(PSRWLOCK_ SRWLock); - __declspec(dllimport) void WINAPI AcquireSRWLockExclusive(PSRWLOCK_ SRWLock); - __declspec(dllimport) BOOLEAN_ WINAPI TryAcquireSRWLockExclusive(PSRWLOCK_ SRWLock); - __declspec(dllimport) void WINAPI ReleaseSRWLockExclusive(PSRWLOCK_ SRWLock); - __declspec(dllimport) void WINAPI AcquireSRWLockShared(PSRWLOCK_ SRWLock); - __declspec(dllimport) BOOLEAN_ WINAPI TryAcquireSRWLockShared(PSRWLOCK_ SRWLock); - __declspec(dllimport) void WINAPI ReleaseSRWLockShared(PSRWLOCK_ SRWLock); - - __declspec(dllimport) void WINAPI InitializeConditionVariable(PCONDITION_VARIABLE_ ConditionVariable); - __declspec(dllimport) void WINAPI WakeConditionVariable(PCONDITION_VARIABLE_ ConditionVariable); - __declspec(dllimport) void WINAPI WakeAllConditionVariable(PCONDITION_VARIABLE_ ConditionVariable); - __declspec(dllimport) BOOL_ WINAPI SleepConditionVariableCS(PCONDITION_VARIABLE_ ConditionVariable, PCRITICAL_SECTION_ CriticalSection, DWORD_ dwMilliseconds); - __declspec(dllimport) BOOL_ WINAPI SleepConditionVariableSRW(PCONDITION_VARIABLE_ ConditionVariable, PSRWLOCK_ SRWLock, DWORD_ dwMilliseconds, ULONG_ Flags); -#endif - -} // extern "C" - -const DWORD_ infinite = (DWORD_)0xFFFFFFFF; -const DWORD_ wait_abandoned = 0x00000080L; -const DWORD_ wait_object_0 = 0x00000000L; -const DWORD_ wait_timeout = 0x00000102L; -const DWORD_ wait_failed = (DWORD_)0xFFFFFFFF; - -#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 -const DWORD_ init_once_async = 0x00000002UL; -const DWORD_ init_once_check_only = 0x00000001UL; -const DWORD_ init_once_init_failed = 0x00000004UL; -const DWORD_ init_once_ctx_reserved_bits = 2; - -const ULONG_ condition_variable_lockmode_shared = 0x00000001; -#endif - -#endif // defined( BOOST_USE_WINDOWS_H ) - -const DWORD_ max_non_infinite_wait = (DWORD_)0xFFFFFFFE; - -BOOST_FORCEINLINE HANDLE_ create_anonymous_mutex(_SECURITY_ATTRIBUTES* lpAttributes, BOOL_ bInitialOwner) -{ -#ifdef BOOST_NO_ANSI_APIS - return CreateMutexW(lpAttributes, bInitialOwner, 0); -#else - return CreateMutexA(lpAttributes, bInitialOwner, 0); -#endif -} - -BOOST_FORCEINLINE HANDLE_ create_anonymous_semaphore(_SECURITY_ATTRIBUTES* lpAttributes, LONG_ lInitialCount, LONG_ lMaximumCount) -{ -#ifdef BOOST_NO_ANSI_APIS - return CreateSemaphoreW(lpAttributes, lInitialCount, lMaximumCount, 0); -#else - return CreateSemaphoreA(lpAttributes, lInitialCount, lMaximumCount, 0); -#endif -} - -BOOST_FORCEINLINE HANDLE_ create_anonymous_event(_SECURITY_ATTRIBUTES* lpAttributes, BOOL_ bManualReset, BOOL_ bInitialState) -{ -#ifdef BOOST_NO_ANSI_APIS - return CreateEventW(lpAttributes, bManualReset, bInitialState, 0); -#else - return CreateEventA(lpAttributes, bManualReset, bInitialState, 0); -#endif -} - -} -} -} - #endif // BOOST_DETAIL_WINAPI_SYNCHRONIZATION_HPP diff --git a/boost/detail/winapi/system.hpp b/boost/detail/winapi/system.hpp index 2c2d82a8a9..93a5eeb11c 100644 --- a/boost/detail/winapi/system.hpp +++ b/boost/detail/winapi/system.hpp @@ -2,6 +2,7 @@ // Copyright 2010 Vicente J. Botet Escriba // Copyright (c) Microsoft Corporation 2014 +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -16,47 +17,57 @@ #pragma once #endif +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +struct _SYSTEM_INFO; + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +GetSystemInfo(::_SYSTEM_INFO* lpSystemInfo); + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WINXP +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +GetNativeSystemInfo(::_SYSTEM_INFO* lpSystemInfo); +#endif +} +#endif + namespace boost { namespace detail { namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - typedef ::SYSTEM_INFO SYSTEM_INFO_; -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP -extern "C" __declspec(dllimport) void __stdcall GetSystemInfo (struct system_info *); -# else -extern "C" __declspec(dllimport) void __stdcall GetNativeSystemInfo (struct system_info *); -# endif -#else -extern "C" { - typedef struct _SYSTEM_INFO { - union { - DWORD_ dwOemId; + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _SYSTEM_INFO { + union { + DWORD_ dwOemId; struct { - WORD_ wProcessorArchitecture; - WORD_ wReserved; - } dummy; - } ; - DWORD_ dwPageSize; - LPVOID_ lpMinimumApplicationAddress; - LPVOID_ lpMaximumApplicationAddress; - DWORD_PTR_ dwActiveProcessorMask; - DWORD_ dwNumberOfProcessors; - DWORD_ dwProcessorType; - DWORD_ dwAllocationGranularity; - WORD_ wProcessorLevel; - WORD_ wProcessorRevision; - } SYSTEM_INFO_; - -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - __declspec(dllimport) void __stdcall - GetSystemInfo (struct system_info *); -# else - __declspec(dllimport) void __stdcall - GetNativeSystemInfo (struct system_info *); -# endif -} + WORD_ wProcessorArchitecture; + WORD_ wReserved; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + DWORD_ dwPageSize; + LPVOID_ lpMinimumApplicationAddress; + LPVOID_ lpMaximumApplicationAddress; + DWORD_PTR_ dwActiveProcessorMask; + DWORD_ dwNumberOfProcessors; + DWORD_ dwProcessorType; + DWORD_ dwAllocationGranularity; + WORD_ wProcessorLevel; + WORD_ wProcessorRevision; +} SYSTEM_INFO_, *LPSYSTEM_INFO_; + +BOOST_FORCEINLINE VOID_ GetSystemInfo(LPSYSTEM_INFO_ lpSystemInfo) +{ + ::GetSystemInfo(reinterpret_cast< ::_SYSTEM_INFO* >(lpSystemInfo)); +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WINXP +BOOST_FORCEINLINE VOID_ GetNativeSystemInfo(LPSYSTEM_INFO_ lpSystemInfo) +{ + ::GetNativeSystemInfo(reinterpret_cast< ::_SYSTEM_INFO* >(lpSystemInfo)); +} #endif + } } } + #endif // BOOST_DETAIL_WINAPI_SYSTEM_HPP diff --git a/boost/detail/winapi/thread.hpp b/boost/detail/winapi/thread.hpp index ee0dac6242..9367d46bd0 100644 --- a/boost/detail/winapi/thread.hpp +++ b/boost/detail/winapi/thread.hpp @@ -1,6 +1,7 @@ // thread.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -16,32 +17,28 @@ #pragma once #endif -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetCurrentThreadId; - using ::SleepEx; - using ::Sleep; - using ::SwitchToThread; -#else +#if !defined( BOOST_USE_WINDOWS_H ) extern "C" { -# ifndef UNDER_CE - __declspec(dllimport) DWORD_ WINAPI GetCurrentThreadId(void); - __declspec(dllimport) DWORD_ WINAPI SleepEx(DWORD_, BOOL_); - __declspec(dllimport) void WINAPI Sleep(DWORD_); - __declspec(dllimport) BOOL_ WINAPI SwitchToThread(void); -#else - using ::GetCurrentThreadId; - using ::SleepEx; - using ::Sleep; - using ::SwitchToThread; +// Windows CE define GetCurrentThreadId as an inline function in kfuncs.h +#if !defined( UNDER_CE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI GetCurrentThreadId(BOOST_DETAIL_WINAPI_VOID); #endif +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +SleepEx( + boost::detail::winapi::DWORD_ dwMilliseconds, + boost::detail::winapi::BOOL_ bAlertable); +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI Sleep(boost::detail::winapi::DWORD_ dwMilliseconds); +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI SwitchToThread(BOOST_DETAIL_WINAPI_VOID); } #endif + +namespace boost { +namespace detail { +namespace winapi { +using ::GetCurrentThreadId; +using ::SleepEx; +using ::Sleep; +using ::SwitchToThread; } } } diff --git a/boost/detail/winapi/thread_pool.hpp b/boost/detail/winapi/thread_pool.hpp index 57059dc1b2..f81c545961 100644 --- a/boost/detail/winapi/thread_pool.hpp +++ b/boost/detail/winapi/thread_pool.hpp @@ -9,7 +9,7 @@ #ifndef BOOST_DETAIL_WINAPI_THREAD_POOL_HPP #define BOOST_DETAIL_WINAPI_THREAD_POOL_HPP -#include +#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once @@ -17,13 +17,41 @@ #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN2K -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) +#include + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +typedef boost::detail::winapi::VOID_ (NTAPI *WAITORTIMERCALLBACKFUNC) +(boost::detail::winapi::PVOID_, boost::detail::winapi::BOOLEAN_); +typedef WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACK; + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +RegisterWaitForSingleObject( + boost::detail::winapi::PHANDLE_ phNewWaitObject, + boost::detail::winapi::HANDLE_ hObject, + WAITORTIMERCALLBACK Callback, + boost::detail::winapi::PVOID_ Context, + boost::detail::winapi::ULONG_ dwMilliseconds, + boost::detail::winapi::ULONG_ dwFlags); +} +#endif + +// MinGW is buggy - it is missing these function declarations for Win2000 +#if !defined( BOOST_USE_WINDOWS_H ) || (defined(BOOST_WINAPI_IS_MINGW) && BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +UnregisterWait(boost::detail::winapi::HANDLE_ WaitHandle); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +UnregisterWaitEx( + boost::detail::winapi::HANDLE_ WaitHandle, + boost::detail::winapi::HANDLE_ CompletionEvent); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { typedef ::WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACKFUNC_; typedef ::WAITORTIMERCALLBACK WAITORTIMERCALLBACK_; @@ -32,61 +60,63 @@ using ::RegisterWaitForSingleObject; using ::UnregisterWait; using ::UnregisterWaitEx; -const ULONG_ wt_execute_default = WT_EXECUTEDEFAULT; -const ULONG_ wt_execute_in_io_thread = WT_EXECUTEINIOTHREAD; -const ULONG_ wt_execute_in_ui_thread = WT_EXECUTEINUITHREAD; -const ULONG_ wt_execute_in_wait_thread = WT_EXECUTEINWAITTHREAD; -const ULONG_ wt_execute_only_once = WT_EXECUTEONLYONCE; -const ULONG_ wt_execute_in_timer_thread = WT_EXECUTEINTIMERTHREAD; -const ULONG_ wt_execute_long_function = WT_EXECUTELONGFUNCTION; -const ULONG_ wt_execute_in_persistent_io_thread = WT_EXECUTEINPERSISTENTIOTHREAD; -const ULONG_ wt_execute_in_persistent_thread = WT_EXECUTEINPERSISTENTTHREAD; -const ULONG_ wt_transfer_impersonation = WT_TRANSFER_IMPERSONATION; +#if defined( BOOST_USE_WINDOWS_H ) + +const ULONG_ WT_EXECUTEDEFAULT_ = WT_EXECUTEDEFAULT; +const ULONG_ WT_EXECUTEINIOTHREAD_ = WT_EXECUTEINIOTHREAD; +#if defined( BOOST_WINAPI_IS_MINGW ) +const ULONG_ WT_EXECUTEINUITHREAD_ = 0x00000002; +#else +const ULONG_ WT_EXECUTEINUITHREAD_ = WT_EXECUTEINUITHREAD; +#endif +const ULONG_ WT_EXECUTEINWAITTHREAD_ = WT_EXECUTEINWAITTHREAD; +const ULONG_ WT_EXECUTEONLYONCE_ = WT_EXECUTEONLYONCE; +const ULONG_ WT_EXECUTEINTIMERTHREAD_ = WT_EXECUTEINTIMERTHREAD; +const ULONG_ WT_EXECUTELONGFUNCTION_ = WT_EXECUTELONGFUNCTION; +#if defined( BOOST_WINAPI_IS_MINGW ) +const ULONG_ WT_EXECUTEINPERSISTENTIOTHREAD_ = 0x00000040; +#else +const ULONG_ WT_EXECUTEINPERSISTENTIOTHREAD_ = WT_EXECUTEINPERSISTENTIOTHREAD; +#endif +const ULONG_ WT_EXECUTEINPERSISTENTTHREAD_ = WT_EXECUTEINPERSISTENTTHREAD; +const ULONG_ WT_TRANSFER_IMPERSONATION_ = WT_TRANSFER_IMPERSONATION; inline ULONG_ wt_set_max_threadpool_threads(ULONG_ flags, ULONG_ limit) { return WT_SET_MAX_THREADPOOL_THREADS(flags, limit); } -#else - -extern "C" { +#else // defined( BOOST_USE_WINDOWS_H ) -typedef void (NTAPI* WAITORTIMERCALLBACKFUNC_) (PVOID_, BOOLEAN_); -typedef WAITORTIMERCALLBACKFUNC_ WAITORTIMERCALLBACK_; - -__declspec(dllimport) BOOL_ WINAPI RegisterWaitForSingleObject -( - HANDLE_* phNewWaitObject, - HANDLE_ hObject, - WAITORTIMERCALLBACK_ Callback, - PVOID_ Context, - ULONG_ dwMilliseconds, - ULONG_ dwFlags -); - -__declspec(dllimport) BOOL_ WINAPI UnregisterWait(HANDLE_ WaitHandle); -__declspec(dllimport) BOOL_ WINAPI UnregisterWaitEx(HANDLE_ WaitHandle, HANDLE_ CompletionEvent); - -} // extern "C" - -const ULONG_ wt_execute_default = 0x00000000; -const ULONG_ wt_execute_in_io_thread = 0x00000001; -const ULONG_ wt_execute_in_ui_thread = 0x00000002; -const ULONG_ wt_execute_in_wait_thread = 0x00000004; -const ULONG_ wt_execute_only_once = 0x00000008; -const ULONG_ wt_execute_in_timer_thread = 0x00000020; -const ULONG_ wt_execute_long_function = 0x00000010; -const ULONG_ wt_execute_in_persistent_io_thread = 0x00000040; -const ULONG_ wt_execute_in_persistent_thread = 0x00000080; -const ULONG_ wt_transfer_impersonation = 0x00000100; +const ULONG_ WT_EXECUTEDEFAULT_ = 0x00000000; +const ULONG_ WT_EXECUTEINIOTHREAD_ = 0x00000001; +const ULONG_ WT_EXECUTEINUITHREAD_ = 0x00000002; +const ULONG_ WT_EXECUTEINWAITTHREAD_ = 0x00000004; +const ULONG_ WT_EXECUTEONLYONCE_ = 0x00000008; +const ULONG_ WT_EXECUTEINTIMERTHREAD_ = 0x00000020; +const ULONG_ WT_EXECUTELONGFUNCTION_ = 0x00000010; +const ULONG_ WT_EXECUTEINPERSISTENTIOTHREAD_ = 0x00000040; +const ULONG_ WT_EXECUTEINPERSISTENTTHREAD_ = 0x00000080; +const ULONG_ WT_TRANSFER_IMPERSONATION_ = 0x00000100; inline ULONG_ wt_set_max_threadpool_threads(ULONG_ flags, ULONG_ limit) { return flags | (limit << 16); } -#endif +#endif // defined( BOOST_USE_WINDOWS_H ) + +const ULONG_ wt_execute_default = WT_EXECUTEDEFAULT_; +const ULONG_ wt_execute_in_io_thread = WT_EXECUTEINIOTHREAD_; +const ULONG_ wt_execute_in_ui_thread = WT_EXECUTEINUITHREAD_; +const ULONG_ wt_execute_in_wait_thread = WT_EXECUTEINWAITTHREAD_; +const ULONG_ wt_execute_only_once = WT_EXECUTEONLYONCE_; +const ULONG_ wt_execute_in_timer_thread = WT_EXECUTEINTIMERTHREAD_; +const ULONG_ wt_execute_long_function = WT_EXECUTELONGFUNCTION_; +const ULONG_ wt_execute_in_persistent_io_thread = WT_EXECUTEINPERSISTENTIOTHREAD_; +const ULONG_ wt_execute_in_persistent_thread = WT_EXECUTEINPERSISTENTTHREAD_; +const ULONG_ wt_transfer_impersonation = WT_TRANSFER_IMPERSONATION_; + } } } diff --git a/boost/detail/winapi/time.hpp b/boost/detail/winapi/time.hpp index 6a6b447117..0f69f47744 100644 --- a/boost/detail/winapi/time.hpp +++ b/boost/detail/winapi/time.hpp @@ -2,6 +2,7 @@ // Copyright 2010 Vicente J. Botet Escriba // Copyright (c) Microsoft Corporation 2014 +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -11,90 +12,123 @@ #define BOOST_DETAIL_WINAPI_TIME_HPP #include -#include +#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +struct _FILETIME; +struct _SYSTEMTIME; + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +GetSystemTime(::_SYSTEMTIME* lpSystemTime); + +#ifdef BOOST_HAS_GETSYSTEMTIMEASFILETIME // Windows CE does not define GetSystemTimeAsFileTime +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +GetSystemTimeAsFileTime(::_FILETIME* lpSystemTimeAsFileTime); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SystemTimeToFileTime( + const ::_SYSTEMTIME* lpSystemTime, + ::_FILETIME* lpFileTime); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +FileTimeToSystemTime( + const ::_FILETIME* lpFileTime, + ::_SYSTEMTIME* lpSystemTime); + +#if BOOST_PLAT_WINDOWS_DESKTOP +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +FileTimeToLocalFileTime( + const ::_FILETIME* lpFileTime, + ::_FILETIME* lpLocalFileTime); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +LocalFileTimeToFileTime( + const ::_FILETIME* lpLocalFileTime, + ::_FILETIME* lpFileTime); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +GetTickCount(BOOST_DETAIL_WINAPI_VOID); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::ULONGLONG_ WINAPI +GetTickCount64(BOOST_DETAIL_WINAPI_VOID); +#endif +} +#endif + namespace boost { namespace detail { namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - - typedef FILETIME FILETIME_; - typedef PFILETIME PFILETIME_; - typedef LPFILETIME LPFILETIME_; - - typedef SYSTEMTIME SYSTEMTIME_; - typedef SYSTEMTIME* PSYSTEMTIME_; - - #ifdef BOOST_HAS_GETSYSTEMTIMEASFILETIME // Windows CE does not define GetSystemTimeAsFileTime - using ::GetSystemTimeAsFileTime; - #endif - #if BOOST_PLAT_WINDOWS_DESKTOP - using ::FileTimeToLocalFileTime; - #endif - using ::GetSystemTime; - using ::SystemTimeToFileTime; - - #if BOOST_PLAT_WINDOWS_DESKTOP - using ::GetTickCount; - #endif - #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - using ::GetTickCount64; - #endif +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _FILETIME { + DWORD_ dwLowDateTime; + DWORD_ dwHighDateTime; +} FILETIME_, *PFILETIME_, *LPFILETIME_; + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _SYSTEMTIME { + WORD_ wYear; + WORD_ wMonth; + WORD_ wDayOfWeek; + WORD_ wDay; + WORD_ wHour; + WORD_ wMinute; + WORD_ wSecond; + WORD_ wMilliseconds; +} SYSTEMTIME_, *PSYSTEMTIME_, *LPSYSTEMTIME_; + +#if BOOST_PLAT_WINDOWS_DESKTOP +using ::GetTickCount; +#endif +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +using ::GetTickCount64; +#endif +BOOST_FORCEINLINE VOID_ GetSystemTime(LPSYSTEMTIME_ lpSystemTime) +{ + ::GetSystemTime(reinterpret_cast< ::_SYSTEMTIME* >(lpSystemTime)); +} + +#if defined( BOOST_HAS_GETSYSTEMTIMEASFILETIME ) +BOOST_FORCEINLINE VOID_ GetSystemTimeAsFileTime(LPFILETIME_ lpSystemTimeAsFileTime) +{ + ::GetSystemTimeAsFileTime(reinterpret_cast< ::_FILETIME* >(lpSystemTimeAsFileTime)); +} #else +// Windows CE does not define GetSystemTimeAsFileTime +BOOST_FORCEINLINE VOID_ GetSystemTimeAsFileTime(FILETIME_* lpFileTime) +{ + boost::detail::winapi::SYSTEMTIME_ st; + boost::detail::winapi::GetSystemTime(&st); + boost::detail::winapi::SystemTimeToFileTime(&st, lpFileTime); +} +#endif -extern "C" { - typedef struct _FILETIME { - DWORD_ dwLowDateTime; - DWORD_ dwHighDateTime; - } FILETIME_, *PFILETIME_, *LPFILETIME_; - - typedef struct _SYSTEMTIME { - WORD_ wYear; - WORD_ wMonth; - WORD_ wDayOfWeek; - WORD_ wDay; - WORD_ wHour; - WORD_ wMinute; - WORD_ wSecond; - WORD_ wMilliseconds; - } SYSTEMTIME_, *PSYSTEMTIME_; - - #ifdef BOOST_HAS_GETSYSTEMTIMEASFILETIME // Windows CE does not define GetSystemTimeAsFileTime - __declspec(dllimport) void WINAPI - GetSystemTimeAsFileTime(FILETIME_* lpFileTime); - #endif - __declspec(dllimport) int WINAPI - FileTimeToLocalFileTime(const FILETIME_* lpFileTime, - FILETIME_* lpLocalFileTime); - __declspec(dllimport) void WINAPI - GetSystemTime(SYSTEMTIME_* lpSystemTime); - __declspec(dllimport) int WINAPI - SystemTimeToFileTime(const SYSTEMTIME_* lpSystemTime, - FILETIME_* lpFileTime); - #if BOOST_PLAT_WINDOWS_DESKTOP - __declspec(dllimport) DWORD_ WINAPI - GetTickCount(); - #endif - #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - __declspec(dllimport) ULONGLONG_ WINAPI - GetTickCount64(); - #endif +BOOST_FORCEINLINE BOOL_ SystemTimeToFileTime(const SYSTEMTIME_* lpSystemTime, FILETIME_* lpFileTime) +{ + return ::SystemTimeToFileTime(reinterpret_cast< const ::_SYSTEMTIME* >(lpSystemTime), reinterpret_cast< ::_FILETIME* >(lpFileTime)); } -#endif +BOOST_FORCEINLINE BOOL_ FileTimeToSystemTime(const FILETIME_* lpFileTime, SYSTEMTIME_* lpSystemTime) +{ + return ::FileTimeToSystemTime(reinterpret_cast< const ::_FILETIME* >(lpFileTime), reinterpret_cast< ::_SYSTEMTIME* >(lpSystemTime)); +} + +#if BOOST_PLAT_WINDOWS_DESKTOP +BOOST_FORCEINLINE BOOL_ FileTimeToLocalFileTime(const FILETIME_* lpFileTime, FILETIME_* lpLocalFileTime) +{ + return ::FileTimeToLocalFileTime(reinterpret_cast< const ::_FILETIME* >(lpFileTime), reinterpret_cast< ::_FILETIME* >(lpLocalFileTime)); +} -#ifndef BOOST_HAS_GETSYSTEMTIMEASFILETIME -inline void WINAPI GetSystemTimeAsFileTime(FILETIME_* lpFileTime) +BOOST_FORCEINLINE BOOL_ LocalFileTimeToFileTime(const FILETIME_* lpLocalFileTime, FILETIME_* lpFileTime) { - SYSTEMTIME_ st; - GetSystemTime(&st); - SystemTimeToFileTime(&st, lpFileTime); + return ::LocalFileTimeToFileTime(reinterpret_cast< const ::_FILETIME* >(lpLocalFileTime), reinterpret_cast< ::_FILETIME* >(lpFileTime)); } #endif diff --git a/boost/detail/winapi/timers.hpp b/boost/detail/winapi/timers.hpp index 04c6dfbc41..c3bf826100 100644 --- a/boost/detail/winapi/timers.hpp +++ b/boost/detail/winapi/timers.hpp @@ -1,6 +1,7 @@ // timers.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -15,28 +16,31 @@ #pragma once #endif -namespace boost -{ -namespace detail +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +QueryPerformanceCounter(::_LARGE_INTEGER* lpPerformanceCount); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +QueryPerformanceFrequency(::_LARGE_INTEGER* lpFrequency); +} +#endif + + +namespace boost { +namespace detail { +namespace winapi { + +BOOST_FORCEINLINE BOOL_ QueryPerformanceCounter(LARGE_INTEGER_* lpPerformanceCount) { -namespace winapi + return ::QueryPerformanceCounter(reinterpret_cast< ::_LARGE_INTEGER* >(lpPerformanceCount)); +} + +BOOST_FORCEINLINE BOOL_ QueryPerformanceFrequency(LARGE_INTEGER_* lpFrequency) { -#if defined( BOOST_USE_WINDOWS_H ) - using ::QueryPerformanceCounter; - using ::QueryPerformanceFrequency; -#else -extern "C" { - __declspec(dllimport) BOOL_ WINAPI - QueryPerformanceCounter( - LARGE_INTEGER_ *lpPerformanceCount - ); - - __declspec(dllimport) BOOL_ WINAPI - QueryPerformanceFrequency( - LARGE_INTEGER_ *lpFrequency - ); + return ::QueryPerformanceFrequency(reinterpret_cast< ::_LARGE_INTEGER* >(lpFrequency)); } -#endif + } } } diff --git a/boost/detail/winapi/tls.hpp b/boost/detail/winapi/tls.hpp index d948693cc9..bcdd7dc977 100644 --- a/boost/detail/winapi/tls.hpp +++ b/boost/detail/winapi/tls.hpp @@ -15,33 +15,44 @@ #pragma once #endif -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if !defined( UNDER_CE ) +// Windows CE define TlsAlloc and TlsFree as inline functions in kfuncs.h +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +TlsAlloc(BOOST_DETAIL_WINAPI_VOID); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +TlsFree(boost::detail::winapi::DWORD_ dwTlsIndex); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::LPVOID_ WINAPI +TlsGetValue(boost::detail::winapi::DWORD_ dwTlsIndex); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +TlsSetValue( + boost::detail::winapi::DWORD_ dwTlsIndex, + boost::detail::winapi::LPVOID_ lpTlsValue); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { using ::TlsAlloc; +using ::TlsFree; using ::TlsGetValue; using ::TlsSetValue; -using ::TlsFree; - -const DWORD_ tls_out_of_indexes = TLS_OUT_OF_INDEXES; +#if defined( BOOST_USE_WINDOWS_H ) +const DWORD_ TLS_OUT_OF_INDEXES_ = TLS_OUT_OF_INDEXES; #else +const DWORD_ TLS_OUT_OF_INDEXES_ = 0xFFFFFFFF; +#endif -extern "C" { -__declspec(dllimport) DWORD_ WINAPI TlsAlloc(void); -__declspec(dllimport) LPVOID_ WINAPI TlsGetValue(DWORD_ dwTlsIndex); -__declspec(dllimport) BOOL_ WINAPI TlsSetValue(DWORD_ dwTlsIndex, LPVOID_ lpTlsValue); -__declspec(dllimport) BOOL_ WINAPI TlsFree(DWORD_ dwTlsIndex); -} - -const DWORD_ tls_out_of_indexes = 0xFFFFFFFF; +const DWORD_ tls_out_of_indexes = TLS_OUT_OF_INDEXES_; -#endif } } } diff --git a/boost/detail/winapi/wait.hpp b/boost/detail/winapi/wait.hpp new file mode 100644 index 0000000000..bd20d46826 --- /dev/null +++ b/boost/detail/winapi/wait.hpp @@ -0,0 +1,84 @@ +// wait.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_WAIT_HPP +#define BOOST_DETAIL_WINAPI_WAIT_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +WaitForSingleObject( + boost::detail::winapi::HANDLE_ hHandle, + boost::detail::winapi::DWORD_ dwMilliseconds); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +WaitForMultipleObjects( + boost::detail::winapi::DWORD_ nCount, + boost::detail::winapi::HANDLE_ const* lpHandles, + boost::detail::winapi::BOOL_ bWaitAll, + boost::detail::winapi::DWORD_ dwMilliseconds); + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +SignalObjectAndWait( + boost::detail::winapi::HANDLE_ hObjectToSignal, + boost::detail::winapi::HANDLE_ hObjectToWaitOn, + boost::detail::winapi::DWORD_ dwMilliseconds, + boost::detail::winapi::BOOL_ bAlertable); +#endif +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +using ::WaitForMultipleObjects; +using ::WaitForSingleObject; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 +using ::SignalObjectAndWait; +#endif + +#if defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ INFINITE_ = INFINITE; +const DWORD_ WAIT_ABANDONED_ = WAIT_ABANDONED; +const DWORD_ WAIT_OBJECT_0_ = WAIT_OBJECT_0; +const DWORD_ WAIT_TIMEOUT_ = WAIT_TIMEOUT; +const DWORD_ WAIT_FAILED_ = WAIT_FAILED; + +#else // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ INFINITE_ = (DWORD_)0xFFFFFFFF; +const DWORD_ WAIT_ABANDONED_ = 0x00000080L; +const DWORD_ WAIT_OBJECT_0_ = 0x00000000L; +const DWORD_ WAIT_TIMEOUT_ = 0x00000102L; +const DWORD_ WAIT_FAILED_ = (DWORD_)0xFFFFFFFF; + +#endif // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ infinite = INFINITE_; +const DWORD_ wait_abandoned = WAIT_ABANDONED_; +const DWORD_ wait_object_0 = WAIT_OBJECT_0_; +const DWORD_ wait_timeout = WAIT_TIMEOUT_; +const DWORD_ wait_failed = WAIT_FAILED_; + +const DWORD_ max_non_infinite_wait = (DWORD_)0xFFFFFFFE; + +} +} +} + +#endif // BOOST_DETAIL_WINAPI_WAIT_HPP diff --git a/boost/detail/winapi/waitable_timer.hpp b/boost/detail/winapi/waitable_timer.hpp index 52a7338a20..842cb040d4 100644 --- a/boost/detail/winapi/waitable_timer.hpp +++ b/boost/detail/winapi/waitable_timer.hpp @@ -15,91 +15,107 @@ #pragma once #endif -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +typedef boost::detail::winapi::VOID_ +(WINAPI *PTIMERAPCROUTINE)( + boost::detail::winapi::LPVOID_ lpArgToCompletionRoutine, + boost::detail::winapi::DWORD_ dwTimerLowValue, + boost::detail::winapi::DWORD_ dwTimerHighValue); + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateWaitableTimerA( + ::_SECURITY_ATTRIBUTES* lpTimerAttributes, + boost::detail::winapi::BOOL_ bManualReset, + boost::detail::winapi::LPCSTR_ lpTimerName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenWaitableTimerA( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCSTR_ lpTimerName); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateWaitableTimerW( + ::_SECURITY_ATTRIBUTES* lpTimerAttributes, + boost::detail::winapi::BOOL_ bManualReset, + boost::detail::winapi::LPCWSTR_ lpTimerName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenWaitableTimerW( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCWSTR_ lpTimerName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SetWaitableTimer( + boost::detail::winapi::HANDLE_ hTimer, + const ::_LARGE_INTEGER* lpDueTime, + boost::detail::winapi::LONG_ lPeriod, + PTIMERAPCROUTINE pfnCompletionRoutine, + boost::detail::winapi::LPVOID_ lpArgToCompletionRoutine, + boost::detail::winapi::BOOL_ fResume); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CancelWaitableTimer(boost::detail::winapi::HANDLE_ hTimer); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { typedef ::PTIMERAPCROUTINE PTIMERAPCROUTINE_; -# ifdef BOOST_NO_ANSI_APIS -using ::CreateWaitableTimerW; -using ::OpenWaitableTimerW; -# else -using ::CreateWaitableTimerA; +#if !defined( BOOST_NO_ANSI_APIS ) using ::OpenWaitableTimerA; -# endif -using ::SetWaitableTimer; +#endif +using ::OpenWaitableTimerW; using ::CancelWaitableTimer; -#else - -extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ CreateWaitableTimerA(PSECURITY_ATTRIBUTES_ lpTimerAttributes, BOOL_ bManualReset, LPCSTR_ lpTimerName) +{ + return ::CreateWaitableTimerA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, lpTimerName); +} +#endif -struct _SECURITY_ATTRIBUTES; +BOOST_FORCEINLINE HANDLE_ CreateWaitableTimerW(PSECURITY_ATTRIBUTES_ lpTimerAttributes, BOOL_ bManualReset, LPCWSTR_ lpTimerName) +{ + return ::CreateWaitableTimerW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, lpTimerName); +} -typedef void (WINAPI* PTIMERAPCROUTINE_) -( - LPVOID_ lpArgToCompletionRoutine, - DWORD_ dwTimerLowValue, - DWORD_ dwTimerHighValue -); - -# ifdef BOOST_NO_ANSI_APIS -__declspec(dllimport) HANDLE_ WINAPI CreateWaitableTimerW -( - _SECURITY_ATTRIBUTES* lpTimerAttributes, - BOOL_ bManualReset, - LPCWSTR_ lpTimerName -); - -__declspec(dllimport) HANDLE_ WINAPI OpenWaitableTimerW -( - DWORD_ dwDesiredAccess, - BOOL_ bInheritHandle, - LPCWSTR_ lpTimerName -); -# else -__declspec(dllimport) HANDLE_ WINAPI CreateWaitableTimerA -( - _SECURITY_ATTRIBUTES* lpTimerAttributes, - BOOL_ bManualReset, - LPCSTR_ lpTimerName -); - -__declspec(dllimport) HANDLE_ WINAPI OpenWaitableTimerA -( - DWORD_ dwDesiredAccess, - BOOL_ bInheritHandle, - LPCSTR_ lpTimerName -); -# endif - -__declspec(dllimport) BOOL_ WINAPI SetWaitableTimer -( +BOOST_FORCEINLINE BOOL_ SetWaitableTimer( HANDLE_ hTimer, - const LARGE_INTEGER_ *lpDueTime, + const LARGE_INTEGER_* lpDueTime, LONG_ lPeriod, PTIMERAPCROUTINE_ pfnCompletionRoutine, LPVOID_ lpArgToCompletionRoutine, - BOOL_ fResume -); - -__declspec(dllimport) BOOL_ WINAPI CancelWaitableTimer(HANDLE_ hTimer); - + BOOL_ fResume) +{ + return ::SetWaitableTimer(hTimer, reinterpret_cast< const ::_LARGE_INTEGER* >(lpDueTime), lPeriod, pfnCompletionRoutine, lpArgToCompletionRoutine, fResume); } +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ create_waitable_timer(PSECURITY_ATTRIBUTES_ lpTimerAttributes, BOOL_ bManualReset, LPCSTR_ lpTimerName) +{ + return ::CreateWaitableTimerA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, lpTimerName); +} #endif -BOOST_FORCEINLINE HANDLE_ create_anonymous_waitable_timer(_SECURITY_ATTRIBUTES* lpTimerAttributes, BOOL_ bManualReset) +BOOST_FORCEINLINE HANDLE_ create_waitable_timer(PSECURITY_ATTRIBUTES_ lpTimerAttributes, BOOL_ bManualReset, LPCWSTR_ lpTimerName) +{ + return ::CreateWaitableTimerW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, lpTimerName); +} + +BOOST_FORCEINLINE HANDLE_ create_anonymous_waitable_timer(PSECURITY_ATTRIBUTES_ lpTimerAttributes, BOOL_ bManualReset) { #ifdef BOOST_NO_ANSI_APIS - return CreateWaitableTimerW(lpTimerAttributes, bManualReset, 0); + return ::CreateWaitableTimerW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, 0); #else - return CreateWaitableTimerA(lpTimerAttributes, bManualReset, 0); + return ::CreateWaitableTimerA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, 0); #endif } -- cgit v1.2.3