Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:02:28

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_SEMAPHORE_HPP_INCLUDED_
0010 #define BOOST_WINAPI_SEMAPHORE_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 )
0020 extern "C" {
0021 
0022 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
0023 #if !defined( BOOST_NO_ANSI_APIS )
0024 
0025 BOOST_WINAPI_IMPORT boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
0026 CreateSemaphoreA(
0027     ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes,
0028     boost::winapi::LONG_ lInitialCount,
0029     boost::winapi::LONG_ lMaximumCount,
0030     boost::winapi::LPCSTR_ lpName);
0031 
0032 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0033 BOOST_WINAPI_IMPORT boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
0034 CreateSemaphoreExA(
0035     ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes,
0036     boost::winapi::LONG_ lInitialCount,
0037     boost::winapi::LONG_ lMaximumCount,
0038     boost::winapi::LPCSTR_ lpName,
0039     boost::winapi::DWORD_ dwFlags,
0040     boost::winapi::DWORD_ dwDesiredAccess);
0041 #endif
0042 
0043 #endif // !defined( BOOST_NO_ANSI_APIS )
0044 
0045 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
0046 CreateSemaphoreW(
0047     ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes,
0048     boost::winapi::LONG_ lInitialCount,
0049     boost::winapi::LONG_ lMaximumCount,
0050     boost::winapi::LPCWSTR_ lpName);
0051 
0052 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0053 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
0054 CreateSemaphoreExW(
0055     ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes,
0056     boost::winapi::LONG_ lInitialCount,
0057     boost::winapi::LONG_ lMaximumCount,
0058     boost::winapi::LPCWSTR_ lpName,
0059     boost::winapi::DWORD_ dwFlags,
0060     boost::winapi::DWORD_ dwDesiredAccess);
0061 #endif
0062 
0063 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0064 ReleaseSemaphore(
0065     boost::winapi::HANDLE_ hSemaphore,
0066     boost::winapi::LONG_ lReleaseCount,
0067     boost::winapi::LPLONG_ lpPreviousCount);
0068 
0069 #endif // BOOST_WINAPI_PARTITION_APP_SYSTEM
0070 
0071 #if BOOST_WINAPI_PARTITION_DESKTOP_SYSTEM
0072 
0073 #if !defined( BOOST_NO_ANSI_APIS )
0074 BOOST_WINAPI_IMPORT boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
0075 OpenSemaphoreA(
0076     boost::winapi::DWORD_ dwDesiredAccess,
0077     boost::winapi::BOOL_ bInheritHandle,
0078     boost::winapi::LPCSTR_ lpName);
0079 #endif // !defined( BOOST_NO_ANSI_APIS )
0080 
0081 BOOST_WINAPI_IMPORT boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
0082 OpenSemaphoreW(
0083     boost::winapi::DWORD_ dwDesiredAccess,
0084     boost::winapi::BOOL_ bInheritHandle,
0085     boost::winapi::LPCWSTR_ lpName);
0086 
0087 #endif // BOOST_WINAPI_PARTITION_DESKTOP_SYSTEM
0088 
0089 } // extern "C"
0090 #endif // !defined( BOOST_USE_WINDOWS_H )
0091 
0092 namespace boost {
0093 namespace winapi {
0094 
0095 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
0096 
0097 using ::ReleaseSemaphore;
0098 
0099 #if defined( BOOST_USE_WINDOWS_H )
0100 
0101 BOOST_CONSTEXPR_OR_CONST DWORD_ SEMAPHORE_ALL_ACCESS_ = SEMAPHORE_ALL_ACCESS;
0102 BOOST_CONSTEXPR_OR_CONST DWORD_ SEMAPHORE_MODIFY_STATE_ = SEMAPHORE_MODIFY_STATE;
0103 
0104 #else // defined( BOOST_USE_WINDOWS_H )
0105 
0106 BOOST_CONSTEXPR_OR_CONST DWORD_ SEMAPHORE_ALL_ACCESS_ = 0x001F0003;
0107 BOOST_CONSTEXPR_OR_CONST DWORD_ SEMAPHORE_MODIFY_STATE_ = 0x00000002;
0108 
0109 #endif // defined( BOOST_USE_WINDOWS_H )
0110 
0111 // Undocumented and not present in Windows SDK. Enables NtQuerySemaphore.
0112 // http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FNT%20Objects%2FEvent%2FNtQueryEvent.html
0113 BOOST_CONSTEXPR_OR_CONST DWORD_ SEMAPHORE_QUERY_STATE_ = 0x00000001;
0114 
0115 BOOST_CONSTEXPR_OR_CONST DWORD_ semaphore_all_access = SEMAPHORE_ALL_ACCESS_;
0116 BOOST_CONSTEXPR_OR_CONST DWORD_ semaphore_modify_state = SEMAPHORE_MODIFY_STATE_;
0117 
0118 
0119 #if !defined( BOOST_NO_ANSI_APIS )
0120 BOOST_FORCEINLINE HANDLE_ CreateSemaphoreA(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCSTR_ lpName)
0121 {
0122     return ::CreateSemaphoreA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName);
0123 }
0124 
0125 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0126 BOOST_FORCEINLINE HANDLE_ CreateSemaphoreExA(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess)
0127 {
0128     return ::CreateSemaphoreExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName, dwFlags, dwDesiredAccess);
0129 }
0130 #endif
0131 #endif // !defined( BOOST_NO_ANSI_APIS )
0132 
0133 BOOST_FORCEINLINE HANDLE_ CreateSemaphoreW(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCWSTR_ lpName)
0134 {
0135     return ::CreateSemaphoreW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName);
0136 }
0137 
0138 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
0139 BOOST_FORCEINLINE HANDLE_ CreateSemaphoreExW(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCWSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess)
0140 {
0141     return ::CreateSemaphoreExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName, dwFlags, dwDesiredAccess);
0142 }
0143 #endif
0144 
0145 #if !defined( BOOST_NO_ANSI_APIS )
0146 BOOST_FORCEINLINE HANDLE_ create_semaphore(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCSTR_ lpName)
0147 {
0148     return winapi::CreateSemaphoreA(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName);
0149 }
0150 #endif
0151 
0152 BOOST_FORCEINLINE HANDLE_ create_semaphore(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCWSTR_ lpName)
0153 {
0154     return winapi::CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName);
0155 }
0156 
0157 BOOST_FORCEINLINE HANDLE_ create_anonymous_semaphore(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount)
0158 {
0159     return winapi::CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, 0);
0160 }
0161 
0162 #endif // BOOST_WINAPI_PARTITION_APP_SYSTEM
0163 
0164 #if BOOST_WINAPI_PARTITION_DESKTOP_SYSTEM
0165 
0166 #if !defined( BOOST_NO_ANSI_APIS )
0167 using ::OpenSemaphoreA;
0168 
0169 BOOST_FORCEINLINE HANDLE_ open_semaphore(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName)
0170 {
0171     return ::OpenSemaphoreA(dwDesiredAccess, bInheritHandle, lpName);
0172 }
0173 #endif // !defined( BOOST_NO_ANSI_APIS )
0174 
0175 using ::OpenSemaphoreW;
0176 
0177 BOOST_FORCEINLINE HANDLE_ open_semaphore(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName)
0178 {
0179     return ::OpenSemaphoreW(dwDesiredAccess, bInheritHandle, lpName);
0180 }
0181 
0182 #endif // BOOST_WINAPI_PARTITION_DESKTOP_SYSTEM
0183 
0184 }
0185 }
0186 
0187 #include <boost/winapi/detail/footer.hpp>
0188 
0189 #endif // BOOST_WINAPI_SEMAPHORE_HPP_INCLUDED_