/* * 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 ACTIV_BOOST_WINAPI_INIT_ONCE_HPP_INCLUDED_ #define ACTIV_BOOST_WINAPI_INIT_ONCE_HPP_INCLUDED_ #include #ifdef ACTIV_BOOST_HAS_PRAGMA_ONCE #pragma once #endif #if ACTIV_BOOST_USE_WINAPI_VERSION >= ACTIV_BOOST_WINAPI_VERSION_WIN6 #include #include #if !defined(ACTIV_BOOST_USE_WINDOWS_H) extern "C" { #if defined(ACTIV_BOOST_WINAPI_IS_CYGWIN) || defined(ACTIV_BOOST_WINAPI_IS_MINGW_W64) struct _RTL_RUN_ONCE; #else union _RTL_RUN_ONCE; #endif typedef Boost::winapi::BOOL_ (ACTIV_BOOST_WINAPI_WINAPI_CC *PINIT_ONCE_FN) ( ::_RTL_RUN_ONCE* InitOnce, Boost::winapi::PVOID_ Parameter, Boost::winapi::PVOID_ *Context); ACTIV_BOOST_WINAPI_IMPORT Boost::winapi::VOID_ ACTIV_BOOST_WINAPI_WINAPI_CC InitOnceInitialize(::_RTL_RUN_ONCE* InitOnce); ACTIV_BOOST_WINAPI_IMPORT Boost::winapi::BOOL_ ACTIV_BOOST_WINAPI_WINAPI_CC InitOnceExecuteOnce( ::_RTL_RUN_ONCE* InitOnce, ::PINIT_ONCE_FN InitFn, Boost::winapi::PVOID_ Parameter, Boost::winapi::LPVOID_ *Context); ACTIV_BOOST_WINAPI_IMPORT Boost::winapi::BOOL_ ACTIV_BOOST_WINAPI_WINAPI_CC InitOnceBeginInitialize( ::_RTL_RUN_ONCE* lpInitOnce, Boost::winapi::DWORD_ dwFlags, Boost::winapi::PBOOL_ fPending, Boost::winapi::LPVOID_ *lpContext); ACTIV_BOOST_WINAPI_IMPORT Boost::winapi::BOOL_ ACTIV_BOOST_WINAPI_WINAPI_CC InitOnceComplete( ::_RTL_RUN_ONCE* lpInitOnce, Boost::winapi::DWORD_ dwFlags, Boost::winapi::LPVOID_ lpContext); } #endif namespace Boost { namespace winapi { typedef union ACTIV_BOOST_MAY_ALIAS _RTL_RUN_ONCE { PVOID_ Ptr; } INIT_ONCE_, *PINIT_ONCE_, *LPINIT_ONCE_; extern "C" { typedef BOOL_ (ACTIV_BOOST_WINAPI_WINAPI_CC *PINIT_ONCE_FN_) (PINIT_ONCE_ lpInitOnce, PVOID_ Parameter, PVOID_ *Context); } ACTIV_BOOST_FORCEINLINE VOID_ InitOnceInitialize(PINIT_ONCE_ lpInitOnce) { ::InitOnceInitialize(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce)); } ACTIV_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); } ACTIV_BOOST_FORCEINLINE BOOL_ InitOnceBeginInitialize(PINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, PBOOL_ fPending, LPVOID_ *lpContext) { return ::InitOnceBeginInitialize(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), dwFlags, fPending, lpContext); } ACTIV_BOOST_FORCEINLINE BOOL_ InitOnceComplete(PINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, LPVOID_ lpContext) { return ::InitOnceComplete(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), dwFlags, lpContext); } #if defined( ACTIV_BOOST_USE_WINDOWS_H ) #define ACTIV_BOOST_WINAPI_INIT_ONCE_STATIC_INIT INIT_ONCE_STATIC_INIT ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ INIT_ONCE_ASYNC_ = INIT_ONCE_ASYNC; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ INIT_ONCE_CHECK_ONLY_ = INIT_ONCE_CHECK_ONLY; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ INIT_ONCE_INIT_FAILED_ = INIT_ONCE_INIT_FAILED; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ INIT_ONCE_CTX_RESERVED_BITS_ = INIT_ONCE_CTX_RESERVED_BITS; #else // defined( ACTIV_BOOST_USE_WINDOWS_H ) #define ACTIV_BOOST_WINAPI_INIT_ONCE_STATIC_INIT {0} ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ INIT_ONCE_ASYNC_ = 0x00000002UL; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ INIT_ONCE_CHECK_ONLY_ = 0x00000001UL; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ INIT_ONCE_INIT_FAILED_ = 0x00000004UL; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ INIT_ONCE_CTX_RESERVED_BITS_ = 2; #endif // defined( ACTIV_BOOST_USE_WINDOWS_H ) ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ init_once_async = INIT_ONCE_ASYNC_; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ init_once_check_only = INIT_ONCE_CHECK_ONLY_; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ init_once_init_failed = INIT_ONCE_INIT_FAILED_; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ init_once_ctx_reserved_bits = INIT_ONCE_CTX_RESERVED_BITS_; } } #include #endif // ACTIV_BOOST_USE_WINAPI_VERSION >= ACTIV_BOOST_WINAPI_VERSION_WIN6 #endif // ACTIV_BOOST_WINAPI_INIT_ONCE_HPP_INCLUDED_