Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:44

0001 /*
0002  * Copyright 2010 Vicente J. Botet Escriba
0003  * Copyright 2015 Andrey Semashev
0004  *
0005  * Distributed under the Boost Software License, Version 1.0.
0006  * See http://www.boost.org/LICENSE_1_0.txt
0007  */
0008 
0009 #ifndef BOOST_WINAPI_CRITICAL_SECTION_HPP_INCLUDED_
0010 #define BOOST_WINAPI_CRITICAL_SECTION_HPP_INCLUDED_
0011 
0012 #include <boost/winapi/basic_types.hpp>
0013 #include <boost/winapi/detail/cast_ptr.hpp>
0014 #include <boost/winapi/detail/header.hpp>
0015 
0016 #ifdef BOOST_HAS_PRAGMA_ONCE
0017 #pragma once
0018 #endif
0019 
0020 #if !defined( BOOST_USE_WINDOWS_H )
0021 
0022 extern "C" {
0023 #if !defined( BOOST_WINAPI_IS_MINGW )
0024 
0025 // Windows CE uses a different name for the structure
0026 #if defined (_WIN32_WCE)
0027 struct CRITICAL_SECTION;
0028 namespace boost {
0029 namespace winapi {
0030 namespace detail {
0031     typedef CRITICAL_SECTION winsdk_critical_section;
0032 }
0033 }
0034 }
0035 #else
0036 struct _RTL_CRITICAL_SECTION;
0037 namespace boost {
0038 namespace winapi {
0039 namespace detail {
0040     typedef _RTL_CRITICAL_SECTION winsdk_critical_section;
0041 }
0042 }
0043 }
0044 #endif
0045 
0046 #else
0047 // MinGW uses a different name for the structure
0048 struct _CRITICAL_SECTION;
0049 
0050 namespace boost {
0051 namespace winapi {
0052 namespace detail {
0053     typedef _CRITICAL_SECTION winapi_critical_section;
0054 }
0055 }
0056 }
0057 #endif
0058 
0059 #if !defined( BOOST_WINAPI_IS_MINGW )
0060 
0061 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
0062 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::VOID_ BOOST_WINAPI_WINAPI_CC
0063 InitializeCriticalSection(boost::winapi::detail::winsdk_critical_section* lpCriticalSection);
0064 #endif
0065 
0066 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::VOID_ BOOST_WINAPI_WINAPI_CC
0067 EnterCriticalSection(boost::winapi::detail::winsdk_critical_section* lpCriticalSection);
0068 
0069 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::VOID_ BOOST_WINAPI_WINAPI_CC
0070 LeaveCriticalSection(boost::winapi::detail::winsdk_critical_section* lpCriticalSection);
0071 
0072 #if BOOST_USE_WINAPI_VERSION >= 0x0403
0073 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
0074 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0075 InitializeCriticalSectionAndSpinCount(
0076     boost::winapi::detail::winsdk_critical_section* lpCriticalSection,
0077     boost::winapi::DWORD_ dwSpinCount);
0078 
0079 BOOST_WINAPI_IMPORT boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC
0080 SetCriticalSectionSpinCount(
0081     boost::winapi::detail::winsdk_critical_section* lpCriticalSection,
0082     boost::winapi::DWORD_ dwSpinCount);
0083 #endif
0084 
0085 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0086 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0087 InitializeCriticalSectionEx(
0088     boost::winapi::detail::winsdk_critical_section* lpCriticalSection,
0089     boost::winapi::DWORD_ dwSpinCount,
0090     boost::winapi::DWORD_ Flags);
0091 #endif
0092 #endif
0093 
0094 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4
0095 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0096 TryEnterCriticalSection(boost::winapi::detail::winsdk_critical_section* lpCriticalSection);
0097 #endif
0098 
0099 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::VOID_ BOOST_WINAPI_WINAPI_CC
0100 DeleteCriticalSection(boost::winapi::detail::winsdk_critical_section* lpCriticalSection);
0101 
0102 #else // defined( BOOST_WINAPI_IS_MINGW )
0103 
0104 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::VOID_ BOOST_WINAPI_WINAPI_CC
0105 InitializeCriticalSection(boost::winapi::detail::winapi_critical_section* lpCriticalSection);
0106 
0107 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::VOID_ BOOST_WINAPI_WINAPI_CC
0108 EnterCriticalSection(boost::winapi::detail::winapi_critical_section* lpCriticalSection);
0109 
0110 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::VOID_ BOOST_WINAPI_WINAPI_CC
0111 LeaveCriticalSection(boost::winapi::detail::winapi_critical_section* lpCriticalSection);
0112 
0113 #if BOOST_USE_WINAPI_VERSION >= 0x0403
0114 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0115 InitializeCriticalSectionAndSpinCount(
0116     boost::winapi::detail::winapi_critical_section* lpCriticalSection,
0117     boost::winapi::DWORD_ dwSpinCount);
0118 
0119 BOOST_WINAPI_IMPORT boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC
0120 SetCriticalSectionSpinCount(
0121     boost::winapi::detail::winapi_critical_section* lpCriticalSection,
0122     boost::winapi::DWORD_ dwSpinCount);
0123 #endif
0124 
0125 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0126 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0127 InitializeCriticalSectionEx(
0128     boost::winapi::detail::winapi_critical_section* lpCriticalSection,
0129     boost::winapi::DWORD_ dwSpinCount,
0130     boost::winapi::DWORD_ Flags);
0131 #endif
0132 
0133 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4
0134 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0135 TryEnterCriticalSection(boost::winapi::detail::winapi_critical_section* lpCriticalSection);
0136 #endif
0137 
0138 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::VOID_ BOOST_WINAPI_WINAPI_CC
0139 DeleteCriticalSection(boost::winapi::detail::winapi_critical_section* lpCriticalSection);
0140 
0141 #endif // defined( BOOST_WINAPI_IS_MINGW )
0142 } // extern "C"
0143 #endif
0144 
0145 namespace boost {
0146 namespace winapi {
0147 
0148 
0149 #pragma pack(push, 8)
0150 
0151 #if !defined(_WIN32_WCE)
0152 
0153 struct _RTL_CRITICAL_SECTION_DEBUG;
0154 
0155 typedef struct BOOST_MAY_ALIAS _RTL_CRITICAL_SECTION {
0156     _RTL_CRITICAL_SECTION_DEBUG* DebugInfo;
0157     LONG_ LockCount;
0158     LONG_ RecursionCount;
0159     HANDLE_ OwningThread;
0160     HANDLE_ LockSemaphore;
0161     ULONG_PTR_ SpinCount;
0162 } CRITICAL_SECTION_, *PCRITICAL_SECTION_;
0163 
0164 #else
0165 
0166 // Windows CE has different layout
0167 typedef struct BOOST_MAY_ALIAS CRITICAL_SECTION {
0168     unsigned int LockCount;
0169     HANDLE OwnerThread;
0170     HANDLE hCrit;
0171     DWORD needtrap;
0172     DWORD dwContentions;
0173 } CRITICAL_SECTION_, *LPCRITICAL_SECTION_;
0174 
0175 #endif
0176 
0177 #pragma pack(pop)
0178 
0179 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
0180 BOOST_FORCEINLINE VOID_ InitializeCriticalSection(CRITICAL_SECTION_* lpCriticalSection)
0181 {
0182     ::InitializeCriticalSection(winapi::detail::cast_ptr(lpCriticalSection));
0183 }
0184 #endif
0185 
0186 BOOST_FORCEINLINE VOID_ EnterCriticalSection(CRITICAL_SECTION_* lpCriticalSection)
0187 {
0188     ::EnterCriticalSection(winapi::detail::cast_ptr(lpCriticalSection));
0189 }
0190 
0191 BOOST_FORCEINLINE VOID_ LeaveCriticalSection(CRITICAL_SECTION_* lpCriticalSection)
0192 {
0193     ::LeaveCriticalSection(winapi::detail::cast_ptr(lpCriticalSection));
0194 }
0195 
0196 #if BOOST_USE_WINAPI_VERSION >= 0x0403
0197 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
0198 BOOST_FORCEINLINE BOOL_ InitializeCriticalSectionAndSpinCount(CRITICAL_SECTION_* lpCriticalSection, DWORD_ dwSpinCount)
0199 {
0200     return ::InitializeCriticalSectionAndSpinCount(winapi::detail::cast_ptr(lpCriticalSection), dwSpinCount);
0201 }
0202 
0203 BOOST_FORCEINLINE DWORD_ SetCriticalSectionSpinCount(CRITICAL_SECTION_* lpCriticalSection, DWORD_ dwSpinCount)
0204 {
0205     return ::SetCriticalSectionSpinCount(winapi::detail::cast_ptr(lpCriticalSection), dwSpinCount);
0206 }
0207 #endif
0208 
0209 // CRITICAL_SECTION_NO_DEBUG_INFO is defined for WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
0210 BOOST_CONSTEXPR_OR_CONST DWORD_ CRITICAL_SECTION_NO_DEBUG_INFO_ = 0x01000000;
0211 BOOST_CONSTEXPR_OR_CONST DWORD_ CRITICAL_SECTION_FLAG_NO_DEBUG_INFO_ = CRITICAL_SECTION_NO_DEBUG_INFO_;
0212 BOOST_CONSTEXPR_OR_CONST DWORD_ CRITICAL_SECTION_FLAG_DYNAMIC_SPIN_ = 0x02000000; // undocumented
0213 BOOST_CONSTEXPR_OR_CONST DWORD_ CRITICAL_SECTION_FLAG_STATIC_INIT_ = 0x04000000; // undocumented
0214 
0215 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0216 BOOST_FORCEINLINE BOOL_ InitializeCriticalSectionEx(CRITICAL_SECTION_* lpCriticalSection, DWORD_ dwSpinCount, DWORD_ Flags)
0217 {
0218     return ::InitializeCriticalSectionEx(winapi::detail::cast_ptr(lpCriticalSection), dwSpinCount, Flags);
0219 }
0220 #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0221 #endif // BOOST_USE_WINAPI_VERSION >= 0x0403
0222 
0223 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4
0224 BOOST_FORCEINLINE BOOL_ TryEnterCriticalSection(CRITICAL_SECTION_* lpCriticalSection)
0225 {
0226     return ::TryEnterCriticalSection(winapi::detail::cast_ptr(lpCriticalSection));
0227 }
0228 #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4
0229 
0230 BOOST_FORCEINLINE VOID_ DeleteCriticalSection(CRITICAL_SECTION_* lpCriticalSection)
0231 {
0232     ::DeleteCriticalSection(winapi::detail::cast_ptr(lpCriticalSection));
0233 }
0234 
0235 }
0236 }
0237 
0238 #include <boost/winapi/detail/footer.hpp>
0239 
0240 #endif // BOOST_WINAPI_CRITICAL_SECTION_HPP_INCLUDED_