]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/winapi/include/boost/detail/winapi/init_once.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / winapi / include / boost / detail / winapi / init_once.hpp
1 // init_once.hpp --------------------------------------------------------------//
2
3 // Copyright 2010 Vicente J. Botet Escriba
4 // Copyright 2015 Andrey Semashev
5
6 // Distributed under the Boost Software License, Version 1.0.
7 // See http://www.boost.org/LICENSE_1_0.txt
8
9
10 #ifndef BOOST_DETAIL_WINAPI_INIT_ONCE_HPP
11 #define BOOST_DETAIL_WINAPI_INIT_ONCE_HPP
12
13 #include <boost/detail/winapi/config.hpp>
14
15 #ifdef BOOST_HAS_PRAGMA_ONCE
16 #pragma once
17 #endif
18
19 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
20
21 #include <boost/detail/winapi/basic_types.hpp>
22
23 #if !defined( BOOST_USE_WINDOWS_H )
24 extern "C" {
25 #if defined( BOOST_WINAPI_IS_MINGW_W64 )
26 struct _RTL_RUN_ONCE;
27 #else
28 union _RTL_RUN_ONCE;
29 #endif
30
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);
36
37 BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI
38 InitOnceInitialize(::_RTL_RUN_ONCE* InitOnce);
39
40 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
41 InitOnceExecuteOnce(
42 ::_RTL_RUN_ONCE* InitOnce,
43 ::PINIT_ONCE_FN InitFn,
44 boost::detail::winapi::PVOID_ Parameter,
45 boost::detail::winapi::LPVOID_ *Context);
46
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);
53
54 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
55 InitOnceComplete(
56 ::_RTL_RUN_ONCE* lpInitOnce,
57 boost::detail::winapi::DWORD_ dwFlags,
58 boost::detail::winapi::LPVOID_ lpContext);
59 }
60 #endif
61
62 namespace boost {
63 namespace detail {
64 namespace winapi {
65
66 typedef union BOOST_DETAIL_WINAPI_MAY_ALIAS _RTL_RUN_ONCE {
67 PVOID_ Ptr;
68 } INIT_ONCE_, *PINIT_ONCE_, *LPINIT_ONCE_;
69
70 extern "C" {
71 typedef BOOL_ (WINAPI *PINIT_ONCE_FN_) (PINIT_ONCE_ lpInitOnce, PVOID_ Parameter, PVOID_ *Context);
72 }
73
74 BOOST_FORCEINLINE VOID_ InitOnceInitialize(PINIT_ONCE_ lpInitOnce)
75 {
76 ::InitOnceInitialize(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce));
77 }
78
79 BOOST_FORCEINLINE BOOL_ InitOnceExecuteOnce(PINIT_ONCE_ lpInitOnce, PINIT_ONCE_FN_ InitFn, PVOID_ Parameter, LPVOID_ *Context)
80 {
81 return ::InitOnceExecuteOnce(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), reinterpret_cast< ::PINIT_ONCE_FN >(InitFn), Parameter, Context);
82 }
83
84 BOOST_FORCEINLINE BOOL_ InitOnceBeginInitialize(PINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, PBOOL_ fPending, LPVOID_ *lpContext)
85 {
86 return ::InitOnceBeginInitialize(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), dwFlags, fPending, lpContext);
87 }
88
89 BOOST_FORCEINLINE BOOL_ InitOnceComplete(PINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, LPVOID_ lpContext)
90 {
91 return ::InitOnceComplete(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), dwFlags, lpContext);
92 }
93
94 #if defined( BOOST_USE_WINDOWS_H )
95
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;
101
102 #else // defined( BOOST_USE_WINDOWS_H )
103
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;
109
110 #endif // defined( BOOST_USE_WINDOWS_H )
111
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_;
116
117 }
118 }
119 }
120
121 #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
122
123 #endif // BOOST_DETAIL_WINAPI_INIT_ONCE_HPP