2 * Copyright 2010 Vicente J. Botet Escriba
3 * Copyright 2015 Andrey Semashev
5 * Distributed under the Boost Software License, Version 1.0.
6 * See http://www.boost.org/LICENSE_1_0.txt
9 #ifndef BOOST_WINAPI_INIT_ONCE_HPP_INCLUDED_
10 #define BOOST_WINAPI_INIT_ONCE_HPP_INCLUDED_
12 #include <boost/winapi/config.hpp>
14 #ifdef BOOST_HAS_PRAGMA_ONCE
18 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
20 #include <boost/winapi/basic_types.hpp>
22 #if !defined( BOOST_USE_WINDOWS_H )
24 #if defined( BOOST_WINAPI_IS_MINGW_W64 )
30 typedef boost::winapi::BOOL_
31 (WINAPI *PINIT_ONCE_FN) (
32 ::_RTL_RUN_ONCE* InitOnce,
33 boost::winapi::PVOID_ Parameter,
34 boost::winapi::PVOID_ *Context);
36 BOOST_SYMBOL_IMPORT boost::winapi::VOID_ WINAPI
37 InitOnceInitialize(::_RTL_RUN_ONCE* InitOnce);
39 BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ WINAPI
41 ::_RTL_RUN_ONCE* InitOnce,
42 ::PINIT_ONCE_FN InitFn,
43 boost::winapi::PVOID_ Parameter,
44 boost::winapi::LPVOID_ *Context);
46 BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ WINAPI
47 InitOnceBeginInitialize(
48 ::_RTL_RUN_ONCE* lpInitOnce,
49 boost::winapi::DWORD_ dwFlags,
50 boost::winapi::PBOOL_ fPending,
51 boost::winapi::LPVOID_ *lpContext);
53 BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ WINAPI
55 ::_RTL_RUN_ONCE* lpInitOnce,
56 boost::winapi::DWORD_ dwFlags,
57 boost::winapi::LPVOID_ lpContext);
64 typedef union BOOST_MAY_ALIAS _RTL_RUN_ONCE {
66 } INIT_ONCE_, *PINIT_ONCE_, *LPINIT_ONCE_;
69 typedef BOOL_ (WINAPI *PINIT_ONCE_FN_) (PINIT_ONCE_ lpInitOnce, PVOID_ Parameter, PVOID_ *Context);
72 BOOST_FORCEINLINE VOID_ InitOnceInitialize(PINIT_ONCE_ lpInitOnce)
74 ::InitOnceInitialize(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce));
77 BOOST_FORCEINLINE BOOL_ InitOnceExecuteOnce(PINIT_ONCE_ lpInitOnce, PINIT_ONCE_FN_ InitFn, PVOID_ Parameter, LPVOID_ *Context)
79 return ::InitOnceExecuteOnce(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), reinterpret_cast< ::PINIT_ONCE_FN >(InitFn), Parameter, Context);
82 BOOST_FORCEINLINE BOOL_ InitOnceBeginInitialize(PINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, PBOOL_ fPending, LPVOID_ *lpContext)
84 return ::InitOnceBeginInitialize(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), dwFlags, fPending, lpContext);
87 BOOST_FORCEINLINE BOOL_ InitOnceComplete(PINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, LPVOID_ lpContext)
89 return ::InitOnceComplete(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), dwFlags, lpContext);
92 #if defined( BOOST_USE_WINDOWS_H )
94 #define BOOST_WINAPI_INIT_ONCE_STATIC_INIT INIT_ONCE_STATIC_INIT
95 const DWORD_ INIT_ONCE_ASYNC_ = INIT_ONCE_ASYNC;
96 const DWORD_ INIT_ONCE_CHECK_ONLY_ = INIT_ONCE_CHECK_ONLY;
97 const DWORD_ INIT_ONCE_INIT_FAILED_ = INIT_ONCE_INIT_FAILED;
98 const DWORD_ INIT_ONCE_CTX_RESERVED_BITS_ = INIT_ONCE_CTX_RESERVED_BITS;
100 #else // defined( BOOST_USE_WINDOWS_H )
102 #define BOOST_WINAPI_INIT_ONCE_STATIC_INIT {0}
103 const DWORD_ INIT_ONCE_ASYNC_ = 0x00000002UL;
104 const DWORD_ INIT_ONCE_CHECK_ONLY_ = 0x00000001UL;
105 const DWORD_ INIT_ONCE_INIT_FAILED_ = 0x00000004UL;
106 const DWORD_ INIT_ONCE_CTX_RESERVED_BITS_ = 2;
108 #endif // defined( BOOST_USE_WINDOWS_H )
110 const DWORD_ init_once_async = INIT_ONCE_ASYNC_;
111 const DWORD_ init_once_check_only = INIT_ONCE_CHECK_ONLY_;
112 const DWORD_ init_once_init_failed = INIT_ONCE_INIT_FAILED_;
113 const DWORD_ init_once_ctx_reserved_bits = INIT_ONCE_CTX_RESERVED_BITS_;
118 #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
120 #endif // BOOST_WINAPI_INIT_ONCE_HPP_INCLUDED_