mirror of
https://github.com/boostorg/detail.git
synced 2025-07-31 21:04:27 +02:00
Added support for WinAPI version specification.
[SVN r86307]
This commit is contained in:
@@ -9,9 +9,9 @@
|
||||
#ifndef BOOST_DETAIL_WINAPI_BASIC_TYPES_HPP
|
||||
#define BOOST_DETAIL_WINAPI_BASIC_TYPES_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <cstdarg>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/detail/winapi/config.hpp>
|
||||
|
||||
#if defined( BOOST_USE_WINDOWS_H )
|
||||
# include <windows.h>
|
||||
@@ -57,6 +57,7 @@ namespace winapi {
|
||||
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_;
|
||||
@@ -85,17 +86,8 @@ extern "C" {
|
||||
typedef long LONG_;
|
||||
typedef unsigned long ULONG_;
|
||||
|
||||
// @FIXME Which condition must be tested
|
||||
//~ #if !defined(_M_IX86)
|
||||
//~ #if defined(BOOST_NO_INT64_T)
|
||||
//~ typedef double LONGLONG_;
|
||||
//~ #else
|
||||
//~ typedef __int64 LONGLONG_;
|
||||
//~ #endif
|
||||
//~ #else
|
||||
//~ typedef double LONGLONG_;
|
||||
//~ #endif
|
||||
typedef boost::int64_t LONGLONG_;
|
||||
typedef boost::uint64_t ULONGLONG_;
|
||||
|
||||
// @FIXME Which condition must be tested
|
||||
# ifdef _WIN64
|
||||
@@ -138,4 +130,5 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // BOOST_DETAIL_WINAPI_TIME_HPP
|
||||
|
||||
#endif // BOOST_DETAIL_WINAPI_BASIC_TYPES_HPP
|
||||
|
52
include/boost/detail/winapi/config.hpp
Normal file
52
include/boost/detail/winapi/config.hpp
Normal file
@@ -0,0 +1,52 @@
|
||||
// config.hpp --------------------------------------------------------------//
|
||||
|
||||
// Copyright 2013 Andrey Semashev
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
|
||||
#ifndef BOOST_DETAIL_WINAPI_CONFIG_HPP_INCLUDED_
|
||||
#define BOOST_DETAIL_WINAPI_CONFIG_HPP_INCLUDED_
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
#pragma once
|
||||
#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
|
||||
#define BOOST_WINAPI_VERSION_WIN2K 0x0500
|
||||
#define BOOST_WINAPI_VERSION_WINXP 0x0501
|
||||
#define BOOST_WINAPI_VERSION_WS03 0x0502
|
||||
#define BOOST_WINAPI_VERSION_WIN6 0x0600
|
||||
#define BOOST_WINAPI_VERSION_VISTA 0x0600
|
||||
#define BOOST_WINAPI_VERSION_WS08 0x0600
|
||||
#define BOOST_WINAPI_VERSION_LONGHORN 0x0600
|
||||
#define BOOST_WINAPI_VERSION_WIN7 0x0601
|
||||
#define BOOST_WINAPI_VERSION_WIN8 0x0602
|
||||
|
||||
#if !defined(BOOST_USE_WINAPI_VERSION)
|
||||
#if defined(_WIN32_WINNT)
|
||||
#define BOOST_USE_WINAPI_VERSION _WIN32_WINNT
|
||||
#elif defined(WINVER)
|
||||
#define BOOST_USE_WINAPI_VERSION WINVER
|
||||
#else
|
||||
// By default use Windows XP API
|
||||
#define BOOST_USE_WINAPI_VERSION BOOST_WINAPI_VERSION_WINXP
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_USE_WINDOWS_H)
|
||||
// We have to define the version macros so that windows.h provides the necessary symbols
|
||||
#if !defined(_WIN32_WINNT)
|
||||
#define _WIN32_WINNT BOOST_USE_WINAPI_VERSION
|
||||
#endif
|
||||
#if !defined(WINVER)
|
||||
#define WINVER BOOST_USE_WINAPI_VERSION
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // BOOST_DETAIL_WINAPI_CONFIG_HPP_INCLUDED_
|
@@ -25,7 +25,26 @@ namespace winapi
|
||||
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;
|
||||
@@ -50,17 +69,47 @@ namespace winapi
|
||||
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" {
|
||||
|
||||
struct CRITICAL_SECTION_
|
||||
typedef struct CRITICAL_SECTION_
|
||||
{
|
||||
struct critical_section_debug * DebugInfo;
|
||||
long LockCount;
|
||||
@@ -72,20 +121,50 @@ extern "C" {
|
||||
#else
|
||||
unsigned long SpinCount;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
*PCRITICAL_SECTION_;
|
||||
|
||||
__declspec(dllimport) void WINAPI
|
||||
InitializeCriticalSection(CRITICAL_SECTION_ *);
|
||||
__declspec(dllimport) void WINAPI
|
||||
EnterCriticalSection(CRITICAL_SECTION_ *);
|
||||
__declspec(dllimport) bool WINAPI
|
||||
TryEnterCriticalSection(CRITICAL_SECTION_ *);
|
||||
__declspec(dllimport) void WINAPI
|
||||
LeaveCriticalSection(CRITICAL_SECTION_ *);
|
||||
__declspec(dllimport) void WINAPI
|
||||
DeleteCriticalSection(CRITICAL_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);
|
||||
|
||||
struct _SECURITY_ATTRIBUTES;
|
||||
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_);
|
||||
@@ -124,18 +203,36 @@ extern "C" {
|
||||
DWORD_ dwMilliseconds);
|
||||
__declspec(dllimport) BOOL_ WINAPI
|
||||
ReleaseSemaphore(HANDLE_, LONG_, LONG_*);
|
||||
typedef void (__stdcall *PAPCFUNC8)(ULONG_PTR_);
|
||||
__declspec(dllimport) DWORD_ WINAPI
|
||||
QueueUserAPC(PAPCFUNC8, HANDLE_, ULONG_PTR_);
|
||||
# ifndef UNDER_CE
|
||||
__declspec(dllimport) BOOL_ WINAPI
|
||||
SetEvent(HANDLE_);
|
||||
__declspec(dllimport) BOOL_ WINAPI
|
||||
ResetEvent(HANDLE_);
|
||||
# else
|
||||
using ::SetEvent;
|
||||
using ::ResetEvent;
|
||||
# endif
|
||||
|
||||
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"
|
||||
|
||||
@@ -145,6 +242,15 @@ 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;
|
||||
|
@@ -18,7 +18,9 @@
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace winapi {
|
||||
|
||||
#if defined( BOOST_USE_WINDOWS_H )
|
||||
|
||||
typedef FILETIME FILETIME_;
|
||||
typedef PFILETIME PFILETIME_;
|
||||
typedef LPFILETIME LPFILETIME_;
|
||||
@@ -33,8 +35,12 @@ namespace winapi {
|
||||
using ::GetSystemTime;
|
||||
using ::SystemTimeToFileTime;
|
||||
using ::GetTickCount;
|
||||
#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
|
||||
using ::GetTickCount64;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
extern "C" {
|
||||
typedef struct _FILETIME {
|
||||
DWORD_ dwLowDateTime;
|
||||
@@ -66,7 +72,12 @@ extern "C" {
|
||||
FILETIME_* lpFileTime);
|
||||
__declspec(dllimport) DWORD_ WINAPI
|
||||
GetTickCount();
|
||||
#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
|
||||
__declspec(dllimport) ULONGLONG_ WINAPI
|
||||
GetTickCount64();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_HAS_GETSYSTEMTIMEASFILETIME
|
||||
|
Reference in New Issue
Block a user