Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*
0002  * Copyright 2010 Vicente J. Botet Escriba
0003  * Copyright 2015, 2017 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_MUTEX_HPP_INCLUDED_
0010 #define BOOST_WINAPI_MUTEX_HPP_INCLUDED_
0011 
0012 #include <boost/winapi/basic_types.hpp>
0013 #include <boost/winapi/detail/header.hpp>
0014 
0015 #ifdef BOOST_HAS_PRAGMA_ONCE
0016 #pragma once
0017 #endif
0018 
0019 #if !defined( BOOST_USE_WINDOWS_H ) && BOOST_WINAPI_PARTITION_APP_SYSTEM
0020 extern "C" {
0021 #if !defined( BOOST_NO_ANSI_APIS )
0022 BOOST_WINAPI_IMPORT boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
0023 CreateMutexA(
0024     ::_SECURITY_ATTRIBUTES* lpMutexAttributes,
0025     boost::winapi::BOOL_ bInitialOwner,
0026     boost::winapi::LPCSTR_ lpName);
0027 #endif
0028 
0029 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
0030 CreateMutexW(
0031     ::_SECURITY_ATTRIBUTES* lpMutexAttributes,
0032     boost::winapi::BOOL_ bInitialOwner,
0033     boost::winapi::LPCWSTR_ lpName);
0034 } // extern "C"
0035 #endif // !defined( BOOST_USE_WINDOWS_H ) && BOOST_WINAPI_PARTITION_APP_SYSTEM
0036 
0037 #if !defined( BOOST_USE_WINDOWS_H )
0038 extern "C" {
0039 #if !defined( BOOST_NO_ANSI_APIS )
0040 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0041 BOOST_WINAPI_IMPORT boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
0042 CreateMutexExA(
0043     ::_SECURITY_ATTRIBUTES* lpMutexAttributes,
0044     boost::winapi::LPCSTR_ lpName,
0045     boost::winapi::DWORD_ dwFlags,
0046     boost::winapi::DWORD_ dwDesiredAccess);
0047 #endif
0048 
0049 BOOST_WINAPI_IMPORT boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
0050 OpenMutexA(
0051     boost::winapi::DWORD_ dwDesiredAccess,
0052     boost::winapi::BOOL_ bInheritHandle,
0053     boost::winapi::LPCSTR_ lpName);
0054 #endif // !defined( BOOST_NO_ANSI_APIS )
0055 
0056 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0057 BOOST_WINAPI_IMPORT boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
0058 CreateMutexExW(
0059     ::_SECURITY_ATTRIBUTES* lpMutexAttributes,
0060     boost::winapi::LPCWSTR_ lpName,
0061     boost::winapi::DWORD_ dwFlags,
0062     boost::winapi::DWORD_ dwDesiredAccess);
0063 #endif
0064 
0065 BOOST_WINAPI_IMPORT boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
0066 OpenMutexW(
0067     boost::winapi::DWORD_ dwDesiredAccess,
0068     boost::winapi::BOOL_ bInheritHandle,
0069     boost::winapi::LPCWSTR_ lpName);
0070 
0071 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0072 ReleaseMutex(boost::winapi::HANDLE_ hMutex);
0073 } // extern "C"
0074 #endif
0075 
0076 namespace boost {
0077 namespace winapi {
0078 
0079 #if !defined( BOOST_NO_ANSI_APIS )
0080 using ::OpenMutexA;
0081 #endif
0082 using ::OpenMutexW;
0083 using ::ReleaseMutex;
0084 
0085 #if defined( BOOST_USE_WINDOWS_H )
0086 
0087 BOOST_CONSTEXPR_OR_CONST DWORD_ MUTEX_ALL_ACCESS_ = MUTEX_ALL_ACCESS;
0088 BOOST_CONSTEXPR_OR_CONST DWORD_ MUTEX_MODIFY_STATE_ = MUTEX_MODIFY_STATE;
0089 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0090 BOOST_CONSTEXPR_OR_CONST DWORD_ CREATE_MUTEX_INITIAL_OWNER_ = CREATE_MUTEX_INITIAL_OWNER;
0091 #endif
0092 
0093 #else // defined( BOOST_USE_WINDOWS_H )
0094 
0095 BOOST_CONSTEXPR_OR_CONST DWORD_ MUTEX_ALL_ACCESS_ = 0x001F0001;
0096 BOOST_CONSTEXPR_OR_CONST DWORD_ MUTEX_MODIFY_STATE_ = 0x00000001;
0097 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0098 BOOST_CONSTEXPR_OR_CONST DWORD_ CREATE_MUTEX_INITIAL_OWNER_ = 0x00000001;
0099 #endif
0100 
0101 #endif // defined( BOOST_USE_WINDOWS_H )
0102 
0103 BOOST_CONSTEXPR_OR_CONST DWORD_ mutex_all_access = MUTEX_ALL_ACCESS_;
0104 BOOST_CONSTEXPR_OR_CONST DWORD_ mutex_modify_state = MUTEX_MODIFY_STATE_;
0105 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0106 BOOST_CONSTEXPR_OR_CONST DWORD_ create_mutex_initial_owner = CREATE_MUTEX_INITIAL_OWNER_;
0107 #endif
0108 
0109 #if !defined( BOOST_NO_ANSI_APIS )
0110 BOOST_FORCEINLINE HANDLE_ CreateMutexA(SECURITY_ATTRIBUTES_* lpMutexAttributes, BOOL_ bInitialOwner, LPCSTR_ lpName)
0111 {
0112 #if !BOOST_WINAPI_PARTITION_APP_SYSTEM && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0113     const DWORD_ flags = bInitialOwner ? create_mutex_initial_owner : 0u;
0114     return ::CreateMutexExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, flags, mutex_all_access);
0115 #else
0116     return ::CreateMutexA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), bInitialOwner, lpName);
0117 #endif
0118 }
0119 
0120 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0121 BOOST_FORCEINLINE HANDLE_ CreateMutexExA(
0122     SECURITY_ATTRIBUTES_* lpMutexAttributes,
0123     LPCSTR_ lpName,
0124     DWORD_ dwFlags,
0125     DWORD_ dwDesiredAccess)
0126 {
0127     return ::CreateMutexExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, dwFlags, dwDesiredAccess);
0128 }
0129 #endif
0130 #endif
0131 
0132 BOOST_FORCEINLINE HANDLE_ CreateMutexW(SECURITY_ATTRIBUTES_* lpMutexAttributes, BOOL_ bInitialOwner, LPCWSTR_ lpName)
0133 {
0134 #if !BOOST_WINAPI_PARTITION_APP_SYSTEM && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0135     const DWORD_ flags = bInitialOwner ? create_mutex_initial_owner : 0u;
0136     return ::CreateMutexExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, flags, mutex_all_access);
0137 #else
0138     return ::CreateMutexW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), bInitialOwner, lpName);
0139 #endif
0140 }
0141 
0142 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0143 BOOST_FORCEINLINE HANDLE_ CreateMutexExW(
0144     SECURITY_ATTRIBUTES_* lpMutexAttributes,
0145     LPCWSTR_ lpName,
0146     DWORD_ dwFlags,
0147     DWORD_ dwDesiredAccess)
0148 {
0149     return ::CreateMutexExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, dwFlags, dwDesiredAccess);
0150 }
0151 #endif
0152 
0153 #if !defined( BOOST_NO_ANSI_APIS )
0154 BOOST_FORCEINLINE HANDLE_ create_mutex(SECURITY_ATTRIBUTES_* lpAttributes, BOOL_ bInitialOwner, LPCSTR_ lpName)
0155 {
0156     return winapi::CreateMutexA(lpAttributes, bInitialOwner, lpName);
0157 }
0158 
0159 BOOST_FORCEINLINE HANDLE_ open_mutex(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName)
0160 {
0161     return ::OpenMutexA(dwDesiredAccess, bInheritHandle, lpName);
0162 }
0163 #endif
0164 
0165 BOOST_FORCEINLINE HANDLE_ create_mutex(SECURITY_ATTRIBUTES_* lpAttributes, BOOL_ bInitialOwner, LPCWSTR_ lpName)
0166 {
0167     return winapi::CreateMutexW(lpAttributes, bInitialOwner, lpName);
0168 }
0169 
0170 BOOST_FORCEINLINE HANDLE_ open_mutex(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName)
0171 {
0172     return ::OpenMutexW(dwDesiredAccess, bInheritHandle, lpName);
0173 }
0174 
0175 BOOST_FORCEINLINE HANDLE_ create_anonymous_mutex(SECURITY_ATTRIBUTES_* lpAttributes, BOOL_ bInitialOwner)
0176 {
0177     return winapi::CreateMutexW(lpAttributes, bInitialOwner, 0);
0178 }
0179 
0180 }
0181 }
0182 
0183 #include <boost/winapi/detail/footer.hpp>
0184 
0185 #endif // BOOST_WINAPI_MUTEX_HPP_INCLUDED_