From bea461e692a75405e90d284f9831aae798ce8ef6 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Sun, 21 Jun 2015 18:37:37 +0300 Subject: [PATCH] Compilation fixes. Added tests to verify headers correctness. --- .../boost/detail/winapi/GetCurrentProcess.hpp | 2 +- .../boost/detail/winapi/GetCurrentThread.hpp | 2 +- include/boost/detail/winapi/GetLastError.hpp | 2 +- include/boost/detail/winapi/basic_types.hpp | 61 +++++++++++++++---- .../detail/winapi/condition_variable.hpp | 4 +- .../boost/detail/winapi/critical_section.hpp | 18 +++--- include/boost/detail/winapi/crypt.hpp | 6 +- include/boost/detail/winapi/dll.hpp | 40 ++++++------ .../boost/detail/winapi/file_management.hpp | 6 +- include/boost/detail/winapi/heap_memory.hpp | 2 +- include/boost/detail/winapi/init_once.hpp | 16 ++--- include/boost/detail/winapi/process.hpp | 2 +- include/boost/detail/winapi/security.hpp | 4 +- include/boost/detail/winapi/srw_lock.hpp | 2 +- include/boost/detail/winapi/system.hpp | 2 +- include/boost/detail/winapi/thread.hpp | 4 +- include/boost/detail/winapi/thread_pool.hpp | 9 --- include/boost/detail/winapi/time.hpp | 8 +-- include/boost/detail/winapi/tls.hpp | 2 +- test/Jamfile.v2 | 57 +++++++++++++++++ test/compile/decl_header.cpp | 31 ++++++++++ test/compile/windows_h_header.cpp | 33 ++++++++++ 22 files changed, 236 insertions(+), 77 deletions(-) create mode 100644 test/Jamfile.v2 create mode 100644 test/compile/decl_header.cpp create mode 100644 test/compile/windows_h_header.cpp diff --git a/include/boost/detail/winapi/GetCurrentProcess.hpp b/include/boost/detail/winapi/GetCurrentProcess.hpp index 186caf7..431b52f 100644 --- a/include/boost/detail/winapi/GetCurrentProcess.hpp +++ b/include/boost/detail/winapi/GetCurrentProcess.hpp @@ -19,7 +19,7 @@ // 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_); +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI GetCurrentProcess(BOOST_DETAIL_WINAPI_VOID); } #endif diff --git a/include/boost/detail/winapi/GetCurrentThread.hpp b/include/boost/detail/winapi/GetCurrentThread.hpp index ce6172d..cbcdc97 100644 --- a/include/boost/detail/winapi/GetCurrentThread.hpp +++ b/include/boost/detail/winapi/GetCurrentThread.hpp @@ -19,7 +19,7 @@ // Windows CE define GetCurrentThread 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 GetCurrentThread(boost::detail::winapi::VOID_); +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI GetCurrentThread(BOOST_DETAIL_WINAPI_VOID); } #endif diff --git a/include/boost/detail/winapi/GetLastError.hpp b/include/boost/detail/winapi/GetLastError.hpp index 9c9b57b..8874ba8 100644 --- a/include/boost/detail/winapi/GetLastError.hpp +++ b/include/boost/detail/winapi/GetLastError.hpp @@ -18,7 +18,7 @@ #if !defined( BOOST_USE_WINDOWS_H ) extern "C" { -BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI GetLastError(boost::detail::winapi::VOID_); +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI GetLastError(BOOST_DETAIL_WINAPI_VOID); } #endif diff --git a/include/boost/detail/winapi/basic_types.hpp b/include/boost/detail/winapi/basic_types.hpp index 6aa116c..717e934 100644 --- a/include/boost/detail/winapi/basic_types.hpp +++ b/include/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,6 +13,10 @@ #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__) @@ -42,17 +46,37 @@ typedef void* HANDLE; # 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" { -struct _LARGE_INTEGER; +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 { @@ -74,7 +98,6 @@ typedef ::PDWORD PDWORD_; typedef ::LPDWORD LPDWORD_; typedef ::HANDLE HANDLE_; typedef ::PHANDLE PHANDLE_; -typedef ::HMODULE HMODULE_; typedef ::INT INT_; typedef ::PINT PINT_; typedef ::LPINT LPINT_; @@ -91,9 +114,16 @@ typedef ::INT_PTR INT_PTR_; typedef ::UINT_PTR UINT_PTR_; typedef ::LONG_PTR LONG_PTR_; typedef ::ULONG_PTR ULONG_PTR_; -typedef ::VOID VOID_; +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_; @@ -101,7 +131,7 @@ typedef ::WCHAR WCHAR_; typedef ::LPWSTR LPWSTR_; typedef ::LPCWSTR LPCWSTR_; -#else +#else // defined( BOOST_USE_WINDOWS_H ) typedef int BOOL_; typedef BOOL_* PBOOL_; @@ -119,7 +149,6 @@ typedef DWORD_* PDWORD_; typedef DWORD_* LPDWORD_; typedef void* HANDLE_; typedef void** PHANDLE_; -typedef void* HMODULE_; typedef int INT_; typedef INT_* PINT_; @@ -154,6 +183,10 @@ typedef long LONG_PTR_; typedef unsigned long ULONG_PTR_; # endif +typedef ULONG_PTR_ DWORD_PTR_, *PDWORD_PTR_; +typedef ULONG_PTR_ SIZE_T_, *PSIZE_T_; +typedef LONG_PTR_ SSIZE_T_, *PSSIZE_T_; + typedef void VOID_; typedef void *PVOID_; typedef void *LPVOID_; @@ -167,13 +200,19 @@ typedef wchar_t WCHAR_; typedef WCHAR_ *LPWSTR_; typedef const WCHAR_ *LPCWSTR_; -#endif +#endif // defined( BOOST_USE_WINDOWS_H ) -typedef struct _LARGE_INTEGER { +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 _SECURITY_ATTRIBUTES { +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _SECURITY_ATTRIBUTES { DWORD_ nLength; LPVOID_ lpSecurityDescriptor; BOOL_ bInheritHandle; diff --git a/include/boost/detail/winapi/condition_variable.hpp b/include/boost/detail/winapi/condition_variable.hpp index f3b2148..b47a537 100644 --- a/include/boost/detail/winapi/condition_variable.hpp +++ b/include/boost/detail/winapi/condition_variable.hpp @@ -54,7 +54,7 @@ namespace boost { namespace detail { namespace winapi { -typedef struct _RTL_CONDITION_VARIABLE { +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _RTL_CONDITION_VARIABLE { PVOID_ Ptr; } CONDITION_VARIABLE_, *PCONDITION_VARIABLE_; struct _RTL_CRITICAL_SECTION; @@ -94,7 +94,7 @@ BOOST_FORCEINLINE BOOL_ SleepConditionVariableSRW( { return ::SleepConditionVariableSRW( reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable), - reinterpret_cast< ::_RTL_SRWLOCK* >(CriticalSection), + reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock), dwMilliseconds, Flags); } diff --git a/include/boost/detail/winapi/critical_section.hpp b/include/boost/detail/winapi/critical_section.hpp index 65ce2c1..11b92f7 100644 --- a/include/boost/detail/winapi/critical_section.hpp +++ b/include/boost/detail/winapi/critical_section.hpp @@ -35,11 +35,13 @@ 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( @@ -65,7 +67,7 @@ struct _RTL_CRITICAL_SECTION_DEBUG; #pragma pack(push, 8) -typedef struct _RTL_CRITICAL_SECTION { +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _RTL_CRITICAL_SECTION { _RTL_CRITICAL_SECTION_DEBUG* DebugInfo; LONG_ LockCount; LONG_ RecursionCount; @@ -97,31 +99,31 @@ BOOST_FORCEINLINE BOOL_ InitializeCriticalSectionAndSpinCount(CRITICAL_SECTION_* return ::InitializeCriticalSectionAndSpinCount(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(lpCriticalSection), dwSpinCount); } -#if defined( BOOST_USE_WINDOWS_H ) -const DWORD_ CRITICAL_SECTION_FLAG_NO_DEBUG_INFO_ = CRITICAL_SECTION_NO_DEBUG_INFO; -#else -const DWORD_ CRITICAL_SECTION_FLAG_NO_DEBUG_INFO_ = 0x01000000; -#endif +// MinGW does not define CRITICAL_SECTION_NO_DEBUG_INFO +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(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(lpCriticalSection), dwSpinCount, Flags); } +#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 BOOST_FORCEINLINE DWORD_ SetCriticalSectionSpinCount(CRITICAL_SECTION_* lpCriticalSection, DWORD_ dwSpinCount) { return ::SetCriticalSectionSpinCount(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(lpCriticalSection), dwSpinCount); } -#endif +#endif // BOOST_USE_WINAPI_VERSION >= 0x0403 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 BOOST_FORCEINLINE BOOL_ TryEnterCriticalSection(CRITICAL_SECTION_* lpCriticalSection) { return ::TryEnterCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(lpCriticalSection)); } -#endif +#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 BOOST_FORCEINLINE VOID_ DeleteCriticalSection(CRITICAL_SECTION_* lpCriticalSection) { diff --git a/include/boost/detail/winapi/crypt.hpp b/include/boost/detail/winapi/crypt.hpp index c75f167..67e6842 100644 --- a/include/boost/detail/winapi/crypt.hpp +++ b/include/boost/detail/winapi/crypt.hpp @@ -17,6 +17,10 @@ #endif #if !defined( BOOST_USE_WINDOWS_H ) +namespace boost { namespace detail { namespace winapi { +typedef ULONG_PTR_ HCRYPTPROV_; +}}} + extern "C" { #if !defined( BOOST_NO_ANSI_APIS ) BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI @@ -85,8 +89,6 @@ const DWORD_ CRYPT_SILENT_ = CRYPT_SILENT; #else -typedef ULONG_PTR_ HCRYPTPROV_; - const DWORD_ PROV_RSA_FULL_ = 1; const DWORD_ CRYPT_VERIFYCONTEXT_ = 0xF0000000; diff --git a/include/boost/detail/winapi/dll.hpp b/include/boost/detail/winapi/dll.hpp index 1308251..3674d8b 100644 --- a/include/boost/detail/winapi/dll.hpp +++ b/include/boost/detail/winapi/dll.hpp @@ -18,21 +18,37 @@ #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 +}}} + #if !defined( BOOST_NO_ANSI_APIS ) BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI - LoadLibraryA(boost::detail::winapi::LPCSTR_ lpFileName); +LoadLibraryA(boost::detail::winapi::LPCSTR_ lpFileName); + BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI - GetModuleHandleA(boost::detail::winapi::LPCSTR_ lpFileName); +GetModuleHandleA(boost::detail::winapi::LPCSTR_ lpFileName); #endif + BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI - LoadLibraryW(boost::detail::winapi::LPCWSTR_ lpFileName); +LoadLibraryW(boost::detail::winapi::LPCWSTR_ lpFileName); + BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI - GetModuleHandleW(boost::detail::winapi::LPCWSTR_ lpFileName); +GetModuleHandleW(boost::detail::winapi::LPCWSTR_ lpFileName); BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI - FreeLibrary(boost::detail::winapi::HMODULE_ hModule); +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); +GetProcAddress(boost::detail::winapi::HMODULE_ hModule, boost::detail::winapi::LPCSTR_ lpProcName); } #endif @@ -44,18 +60,6 @@ namespace winapi { typedef ::FARPROC FARPROC_; typedef ::NEARPROC NEARPROC_; typedef ::PROC PROC_; -#else // defined( BOOST_USE_WINDOWS_H ) -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 -} #endif // defined( BOOST_USE_WINDOWS_H ) #if !defined( BOOST_NO_ANSI_APIS ) diff --git a/include/boost/detail/winapi/file_management.hpp b/include/boost/detail/winapi/file_management.hpp index 66a1eca..e2ed682 100644 --- a/include/boost/detail/winapi/file_management.hpp +++ b/include/boost/detail/winapi/file_management.hpp @@ -148,7 +148,7 @@ using ::SetEndOfFile; using ::LockFile; using ::UnlockFile; -typedef struct _OVERLAPPED { +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _OVERLAPPED { ULONG_PTR_ Internal; ULONG_PTR_ InternalHigh; union { @@ -181,7 +181,7 @@ BOOST_FORCEINLINE HANDLE_ CreateFileA( hTemplateFile); } -typedef struct _WIN32_FIND_DATAA { +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _WIN32_FIND_DATAA { DWORD_ dwFileAttributes; FILETIME_ ftCreationTime; FILETIME_ ftLastAccessTime; @@ -229,7 +229,7 @@ BOOST_FORCEINLINE HANDLE_ CreateFileW( hTemplateFile); } -typedef struct _WIN32_FIND_DATAW { +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _WIN32_FIND_DATAW { DWORD_ dwFileAttributes; FILETIME_ ftCreationTime; FILETIME_ ftLastAccessTime; diff --git a/include/boost/detail/winapi/heap_memory.hpp b/include/boost/detail/winapi/heap_memory.hpp index 818b778..ae86352 100644 --- a/include/boost/detail/winapi/heap_memory.hpp +++ b/include/boost/detail/winapi/heap_memory.hpp @@ -20,7 +20,7 @@ #undef HeapAlloc extern "C" { BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI -GetProcessHeap(boost::detail::winapi::VOID_); +GetProcessHeap(BOOST_DETAIL_WINAPI_VOID); BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI GetProcessHeaps(boost::detail::winapi::DWORD_ NumberOfHeaps, boost::detail::winapi::PHANDLE_ ProcessHeaps); diff --git a/include/boost/detail/winapi/init_once.hpp b/include/boost/detail/winapi/init_once.hpp index 33d2cce..0ff3a1e 100644 --- a/include/boost/detail/winapi/init_once.hpp +++ b/include/boost/detail/winapi/init_once.hpp @@ -59,32 +59,32 @@ namespace boost { namespace detail { namespace winapi { -typedef union _RTL_RUN_ONCE { +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_ InitOnce, PVOID_ Parameter, PVOID_ *Context); +typedef BOOL_ (WINAPI *PINIT_ONCE_FN_) (PINIT_ONCE_ lpInitOnce, PVOID_ Parameter, PVOID_ *Context); } -BOOST_FORCEINLINE VOID_ InitOnceInitialize(PINIT_ONCE_ InitOnce) +BOOST_FORCEINLINE VOID_ InitOnceInitialize(PINIT_ONCE_ lpInitOnce) { - ::InitOnceInitialize(reinterpret_cast< ::_RTL_RUN_ONCE* >(InitOnce)); + ::InitOnceInitialize(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce)); } -BOOST_FORCEINLINE BOOL_ InitOnceExecuteOnce(PINIT_ONCE_ InitOnce, PINIT_ONCE_FN_ InitFn, PVOID_ Parameter, LPVOID_ *Context) +BOOST_FORCEINLINE BOOL_ InitOnceExecuteOnce(PINIT_ONCE_ lpInitOnce, PINIT_ONCE_FN_ InitFn, PVOID_ Parameter, LPVOID_ *Context) { - return ::InitOnceExecuteOnce(reinterpret_cast< ::_RTL_RUN_ONCE* >(InitOnce), reinterpret_cast< ::PINIT_ONCE_FN >(InitFn), Parameter, 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* >(InitOnce), dwFlags, fPending, 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* >(InitOnce), dwFlags, lpContext); + return ::InitOnceComplete(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), dwFlags, lpContext); } #if defined( BOOST_USE_WINDOWS_H ) diff --git a/include/boost/detail/winapi/process.hpp b/include/boost/detail/winapi/process.hpp index 5623ba6..3c3de56 100644 --- a/include/boost/detail/winapi/process.hpp +++ b/include/boost/detail/winapi/process.hpp @@ -19,7 +19,7 @@ // Windows CE define GetCurrentProcessId as an inline function in kfuncs.h #if !defined( BOOST_USE_WINDOWS_H ) && !defined( UNDER_CE ) extern "C" { -BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI GetCurrentProcessId(boost::detail::winapi::VOID_); +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI GetCurrentProcessId(BOOST_DETAIL_WINAPI_VOID); } #endif diff --git a/include/boost/detail/winapi/security.hpp b/include/boost/detail/winapi/security.hpp index ff958e4..b0450f5 100644 --- a/include/boost/detail/winapi/security.hpp +++ b/include/boost/detail/winapi/security.hpp @@ -42,7 +42,7 @@ namespace winapi { typedef PVOID_ PSID_; typedef WORD_ SECURITY_DESCRIPTOR_CONTROL_, *PSECURITY_DESCRIPTOR_CONTROL_; -typedef struct _ACL { +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _ACL { BYTE_ AclRevision; BYTE_ Sbz1; WORD_ AclSize; @@ -50,7 +50,7 @@ typedef struct _ACL { WORD_ Sbz2; } ACL_, *PACL_; -typedef struct _SECURITY_DESCRIPTOR { +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _SECURITY_DESCRIPTOR { BYTE_ Revision; BYTE_ Sbz1; SECURITY_DESCRIPTOR_CONTROL_ Control; diff --git a/include/boost/detail/winapi/srw_lock.hpp b/include/boost/detail/winapi/srw_lock.hpp index ff6944f..c5318f5 100644 --- a/include/boost/detail/winapi/srw_lock.hpp +++ b/include/boost/detail/winapi/srw_lock.hpp @@ -51,7 +51,7 @@ namespace boost { namespace detail { namespace winapi { -typedef struct _RTL_SRWLOCK { +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _RTL_SRWLOCK { PVOID_ Ptr; } SRWLOCK_, *PSRWLOCK_; diff --git a/include/boost/detail/winapi/system.hpp b/include/boost/detail/winapi/system.hpp index d3e6758..93a5eeb 100644 --- a/include/boost/detail/winapi/system.hpp +++ b/include/boost/detail/winapi/system.hpp @@ -35,7 +35,7 @@ namespace boost { namespace detail { namespace winapi { -typedef struct _SYSTEM_INFO { +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _SYSTEM_INFO { union { DWORD_ dwOemId; struct { diff --git a/include/boost/detail/winapi/thread.hpp b/include/boost/detail/winapi/thread.hpp index 4cdef69..9367d46 100644 --- a/include/boost/detail/winapi/thread.hpp +++ b/include/boost/detail/winapi/thread.hpp @@ -21,14 +21,14 @@ extern "C" { // 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_); +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_); +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI SwitchToThread(BOOST_DETAIL_WINAPI_VOID); } #endif diff --git a/include/boost/detail/winapi/thread_pool.hpp b/include/boost/detail/winapi/thread_pool.hpp index 91e44c7..a968e00 100644 --- a/include/boost/detail/winapi/thread_pool.hpp +++ b/include/boost/detail/winapi/thread_pool.hpp @@ -34,14 +34,6 @@ RegisterWaitForSingleObject( boost::detail::winapi::ULONG_ dwMilliseconds, boost::detail::winapi::ULONG_ dwFlags); -BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI -RegisterWaitForSingleObjectEx( - boost::detail::winapi::HANDLE_ hObject, - WAITORTIMERCALLBACK Callback, - boost::detail::winapi::PVOID_ Context, - boost::detail::winapi::ULONG_ dwMilliseconds, - boost::detail::winapi::ULONG_ dwFlags); - BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI UnregisterWait(boost::detail::winapi::HANDLE_ WaitHandle); @@ -60,7 +52,6 @@ typedef ::WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACKFUNC_; typedef ::WAITORTIMERCALLBACK WAITORTIMERCALLBACK_; using ::RegisterWaitForSingleObject; -using ::RegisterWaitForSingleObjectEx; using ::UnregisterWait; using ::UnregisterWaitEx; diff --git a/include/boost/detail/winapi/time.hpp b/include/boost/detail/winapi/time.hpp index 87f60a7..0f69f47 100644 --- a/include/boost/detail/winapi/time.hpp +++ b/include/boost/detail/winapi/time.hpp @@ -53,12 +53,12 @@ LocalFileTimeToFileTime( ::_FILETIME* lpFileTime); BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI -GetTickCount(boost::detail::winapi::VOID_); +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_); +GetTickCount64(BOOST_DETAIL_WINAPI_VOID); #endif } #endif @@ -67,12 +67,12 @@ namespace boost { namespace detail { namespace winapi { -typedef struct _FILETIME { +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _FILETIME { DWORD_ dwLowDateTime; DWORD_ dwHighDateTime; } FILETIME_, *PFILETIME_, *LPFILETIME_; -typedef struct _SYSTEMTIME { +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _SYSTEMTIME { WORD_ wYear; WORD_ wMonth; WORD_ wDayOfWeek; diff --git a/include/boost/detail/winapi/tls.hpp b/include/boost/detail/winapi/tls.hpp index f6366da..bcdd7dc 100644 --- a/include/boost/detail/winapi/tls.hpp +++ b/include/boost/detail/winapi/tls.hpp @@ -20,7 +20,7 @@ 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_); +TlsAlloc(BOOST_DETAIL_WINAPI_VOID); BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI TlsFree(boost::detail::winapi::DWORD_ dwTlsIndex); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 new file mode 100644 index 0000000..85a0d8d --- /dev/null +++ b/test/Jamfile.v2 @@ -0,0 +1,57 @@ +# +# Copyright Andrey Semashev 2015. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import testing ; +import path ; +import regex ; + +project + : requirements + + # Disable warnings about using 'insecure' standard C functions + msvc:_SCL_SECURE_NO_WARNINGS + msvc:_SCL_SECURE_NO_DEPRECATE + msvc:_CRT_SECURE_NO_WARNINGS + msvc:_CRT_SECURE_NO_DEPRECATE + intel-win:_SCL_SECURE_NO_WARNINGS + intel-win:_SCL_SECURE_NO_DEPRECATE + intel-win:_CRT_SECURE_NO_WARNINGS + intel-win:_CRT_SECURE_NO_DEPRECATE + + : default-build + # Testers typically don't specify threading environment and the library can be built and tested for single and multi. I'm more interested in multi though. + multi +# static + ; + +# this rule enumerates through all the sources and invokes +# the run rule for each source, the result is a list of all +# the run rules, which we can pass on to the test_suite rule: +rule test_all +{ + local all_rules = ; + local file ; + local headers_path = [ path.make $(BOOST_ROOT)/libs/winapi/include/boost/detail ] ; + for file in [ path.glob-tree $(headers_path) : *.hpp : detail ] + { + local rel_file = [ path.relative-to $(headers_path) $(file) ] ; + # Note: The test name starts with '~' in order to group these tests in the test report table, preferably at the end. + # All '/' are replaced with '-' because apparently test scripts have a problem with test names containing slashes. + local test_name = [ regex.replace $(rel_file) "/" "-" ] ; + local decl_test_name = ~hdr-decl/$(test_name) ; + local winh_test_name = ~hdr-winh/$(test_name) ; + local use_winh_test_name = ~hdr-use-winh/$(test_name) ; + #ECHO $(rel_file) ; + all_rules += [ compile compile/decl_header.cpp : "BOOST_WINAPI_TEST_HEADER=$(rel_file)" $(file) : $(decl_test_name) ] ; + all_rules += [ compile compile/windows_h_header.cpp : "BOOST_WINAPI_TEST_HEADER=$(rel_file)" $(file) : $(winh_test_name) ] ; + all_rules += [ compile compile/decl_header.cpp : "BOOST_WINAPI_TEST_HEADER=$(rel_file)" "BOOST_USE_WINDOWS_H" $(file) : $(use_winh_test_name) ] ; + } + + #ECHO All rules: $(all_rules) ; + return $(all_rules) ; +} + +test-suite winapi : [ test_all r ] ; diff --git a/test/compile/decl_header.cpp b/test/compile/decl_header.cpp new file mode 100644 index 0000000..73f3c6c --- /dev/null +++ b/test/compile/decl_header.cpp @@ -0,0 +1,31 @@ +/* + * Copyright Andrey Semashev 2015. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ +/*! + * \file decl_header.cpp + * \author Andrey Semashev + * \date 21.06.2015 + * + * \brief This file contains a test boilerplate for checking that every public header is self-contained and does not have any missing #includes. + */ + +// NOTE: Use Boost.Predef, the most fine graned header to detect Windows. This header should not include anything +// system- or STL-specific so that the check for Boost.WinAPI header self-sufficiency is not subverted. +// Boost.Config does not satisfy this requirement. +#include + +#if BOOST_OS_WINDOWS + +#define BOOST_WINAPI_TEST_INCLUDE_HEADER() + +#include BOOST_WINAPI_TEST_INCLUDE_HEADER() + +#endif // BOOST_OS_WINDOWS + +int main(int, char*[]) +{ + return 0; +} diff --git a/test/compile/windows_h_header.cpp b/test/compile/windows_h_header.cpp new file mode 100644 index 0000000..9ab2f3a --- /dev/null +++ b/test/compile/windows_h_header.cpp @@ -0,0 +1,33 @@ +/* + * Copyright Andrey Semashev 2015. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ +/*! + * \file windows_h_header.cpp + * \author Andrey Semashev + * \date 21.06.2015 + * + * \brief This file contains a test boilerplate for checking that every public header does not conflict with native windows.h. + */ + +// NOTE: Use Boost.Predef, the most fine graned header to detect Windows. This header should not include anything +// system- or STL-specific so that the check for Boost.WinAPI header self-sufficiency is not subverted. +// Boost.Config does not satisfy this requirement. +#include + +#if BOOST_OS_WINDOWS + +#include + +#define BOOST_WINAPI_TEST_INCLUDE_HEADER() + +#include BOOST_WINAPI_TEST_INCLUDE_HEADER() + +#endif // BOOST_OS_WINDOWS + +int main(int, char*[]) +{ + return 0; +}