1 // init_once.hpp --------------------------------------------------------------//
3 // Copyright 2010 Vicente J. Botet Escriba
4 // Copyright 2015 Andrey Semashev
6 // Distributed under the Boost Software License, Version 1.0.
7 // See http://www.boost.org/LICENSE_1_0.txt
10 #ifndef BOOST_DETAIL_WINAPI_INIT_ONCE_HPP
11 #define BOOST_DETAIL_WINAPI_INIT_ONCE_HPP
13 #include <boost/detail/winapi/config.hpp>
15 #ifdef BOOST_HAS_PRAGMA_ONCE
19 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
21 #include <boost/detail/winapi/basic_types.hpp>
23 #if !defined( BOOST_USE_WINDOWS_H )
25 #if defined( BOOST_WINAPI_IS_MINGW_W64 )
31 typedef boost::detail::winapi::BOOL_
32 (WINAPI *PINIT_ONCE_FN) (
33 ::_RTL_RUN_ONCE* InitOnce,
34 boost::detail::winapi::PVOID_ Parameter,
35 boost::detail::winapi::PVOID_ *Context);
37 BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI
38 InitOnceInitialize(::_RTL_RUN_ONCE* InitOnce);
40 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
42 ::_RTL_RUN_ONCE* InitOnce,
43 ::PINIT_ONCE_FN InitFn,
44 boost::detail::winapi::PVOID_ Parameter,
45 boost::detail::winapi::LPVOID_ *Context);
47 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
48 InitOnceBeginInitialize(
49 ::_RTL_RUN_ONCE* lpInitOnce,
50 boost::detail::winapi::DWORD_ dwFlags,
51 boost::detail::winapi::PBOOL_ fPending,
52 boost::detail::winapi::LPVOID_ *lpContext);
54 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
56 ::_RTL_RUN_ONCE* lpInitOnce,
57 boost::detail::winapi::DWORD_ dwFlags,
58 boost::detail::winapi::LPVOID_ lpContext);
66 typedef union BOOST_DETAIL_WINAPI_MAY_ALIAS _RTL_RUN_ONCE {
68 } INIT_ONCE_, *PINIT_ONCE_, *LPINIT_ONCE_;
71 typedef BOOL_ (WINAPI *PINIT_ONCE_FN_) (PINIT_ONCE_ lpInitOnce, PVOID_ Parameter, PVOID_ *Context);
74 BOOST_FORCEINLINE VOID_ InitOnceInitialize(PINIT_ONCE_ lpInitOnce)
76 ::InitOnceInitialize(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce));
79 BOOST_FORCEINLINE BOOL_ InitOnceExecuteOnce(PINIT_ONCE_ lpInitOnce, PINIT_ONCE_FN_ InitFn, PVOID_ Parameter, LPVOID_ *Context)
81 return ::InitOnceExecuteOnce(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), reinterpret_cast< ::PINIT_ONCE_FN >(InitFn), Parameter, Context);
84 BOOST_FORCEINLINE BOOL_ InitOnceBeginInitialize(PINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, PBOOL_ fPending, LPVOID_ *lpContext)
86 return ::InitOnceBeginInitialize(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), dwFlags, fPending, lpContext);
89 BOOST_FORCEINLINE BOOL_ InitOnceComplete(PINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, LPVOID_ lpContext)
91 return ::InitOnceComplete(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), dwFlags, lpContext);
94 #if defined( BOOST_USE_WINDOWS_H )
96 #define BOOST_DETAIL_WINAPI_INIT_ONCE_STATIC_INIT INIT_ONCE_STATIC_INIT
97 const DWORD_ INIT_ONCE_ASYNC_ = INIT_ONCE_ASYNC;
98 const DWORD_ INIT_ONCE_CHECK_ONLY_ = INIT_ONCE_CHECK_ONLY;
99 const DWORD_ INIT_ONCE_INIT_FAILED_ = INIT_ONCE_INIT_FAILED;
100 const DWORD_ INIT_ONCE_CTX_RESERVED_BITS_ = INIT_ONCE_CTX_RESERVED_BITS;
102 #else // defined( BOOST_USE_WINDOWS_H )
104 #define BOOST_DETAIL_WINAPI_INIT_ONCE_STATIC_INIT {0}
105 const DWORD_ INIT_ONCE_ASYNC_ = 0x00000002UL;
106 const DWORD_ INIT_ONCE_CHECK_ONLY_ = 0x00000001UL;
107 const DWORD_ INIT_ONCE_INIT_FAILED_ = 0x00000004UL;
108 const DWORD_ INIT_ONCE_CTX_RESERVED_BITS_ = 2;
110 #endif // defined( BOOST_USE_WINDOWS_H )
112 const DWORD_ init_once_async = INIT_ONCE_ASYNC_;
113 const DWORD_ init_once_check_only = INIT_ONCE_CHECK_ONLY_;
114 const DWORD_ init_once_init_failed = INIT_ONCE_INIT_FAILED_;
115 const DWORD_ init_once_ctx_reserved_bits = INIT_ONCE_CTX_RESERVED_BITS_;
121 #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
123 #endif // BOOST_DETAIL_WINAPI_INIT_ONCE_HPP