diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:33:54 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:36:09 +0900 |
commit | d9ec475d945d3035377a0d89ed42e382d8988891 (patch) | |
tree | 34aff2cee4b209906243ab5499d61f3edee2982f /boost/detail/winapi/mutex.hpp | |
parent | 71d216b90256936a9638f325af9bc69d720e75de (diff) | |
download | boost-d9ec475d945d3035377a0d89ed42e382d8988891.tar.gz boost-d9ec475d945d3035377a0d89ed42e382d8988891.tar.bz2 boost-d9ec475d945d3035377a0d89ed42e382d8988891.zip |
Imported Upstream version 1.60.0
Change-Id: Ie709530d6d5841088ceaba025cbe175a4ef43050
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/detail/winapi/mutex.hpp')
-rw-r--r-- | boost/detail/winapi/mutex.hpp | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/boost/detail/winapi/mutex.hpp b/boost/detail/winapi/mutex.hpp new file mode 100644 index 0000000000..8f1975ca5c --- /dev/null +++ b/boost/detail/winapi/mutex.hpp @@ -0,0 +1,181 @@ +// mutex.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_MUTEX_HPP +#define BOOST_DETAIL_WINAPI_MUTEX_HPP + +#include <boost/detail/winapi/basic_types.hpp> +#include <boost/predef/platform.h> + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +#if !defined( BOOST_PLAT_WINDOWS_RUNTIME_AVALIABLE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateMutexA( + ::_SECURITY_ATTRIBUTES* lpMutexAttributes, + boost::detail::winapi::BOOL_ bInitialOwner, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateMutexExA( + ::_SECURITY_ATTRIBUTES* lpMutexAttributes, + boost::detail::winapi::LPCSTR_ lpName, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwDesiredAccess); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenMutexA( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +#if !defined( BOOST_PLAT_WINDOWS_RUNTIME_AVALIABLE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateMutexW( + ::_SECURITY_ATTRIBUTES* lpMutexAttributes, + boost::detail::winapi::BOOL_ bInitialOwner, + boost::detail::winapi::LPCWSTR_ lpName); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateMutexExW( + ::_SECURITY_ATTRIBUTES* lpMutexAttributes, + boost::detail::winapi::LPCWSTR_ lpName, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwDesiredAccess); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenMutexW( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCWSTR_ lpName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +ReleaseMutex(boost::detail::winapi::HANDLE_ hMutex); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::OpenMutexA; +#endif +using ::OpenMutexW; +using ::ReleaseMutex; + +#if defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ MUTEX_ALL_ACCESS_ = MUTEX_ALL_ACCESS; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +const DWORD_ CREATE_MUTEX_INITIAL_OWNER_ = CREATE_MUTEX_INITIAL_OWNER; +#endif + +#else // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ MUTEX_ALL_ACCESS_ = 0x1F0001; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +const DWORD_ CREATE_MUTEX_INITIAL_OWNER_ = 0x00000001; +#endif + +#endif // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ mutex_all_access = MUTEX_ALL_ACCESS_; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +const DWORD_ create_mutex_initial_owner = CREATE_MUTEX_INITIAL_OWNER_; +#endif + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ CreateMutexA(SECURITY_ATTRIBUTES_* lpMutexAttributes, BOOL_ bInitialOwner, LPCSTR_ lpName) +{ +#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + const DWORD_ flags = bInitialOwner ? create_mutex_initial_owner : 0u; + return ::CreateMutexExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, flags, mutex_all_access); +#else + return ::CreateMutexA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), bInitialOwner, lpName); +#endif +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE HANDLE_ CreateMutexExA( + SECURITY_ATTRIBUTES_* lpMutexAttributes, + LPCSTR_ lpName, + DWORD_ dwFlags, + DWORD_ dwDesiredAccess) +{ + return ::CreateMutexExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, dwFlags, dwDesiredAccess); +} +#endif +#endif + +BOOST_FORCEINLINE HANDLE_ CreateMutexW(SECURITY_ATTRIBUTES_* lpMutexAttributes, BOOL_ bInitialOwner, LPCWSTR_ lpName) +{ +#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + const DWORD_ flags = bInitialOwner ? create_mutex_initial_owner : 0u; + return ::CreateMutexExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, flags, mutex_all_access); +#else + return ::CreateMutexW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), bInitialOwner, lpName); +#endif +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE HANDLE_ CreateMutexExW( + SECURITY_ATTRIBUTES_* lpMutexAttributes, + LPCWSTR_ lpName, + DWORD_ dwFlags, + DWORD_ dwDesiredAccess) +{ + return ::CreateMutexExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, dwFlags, dwDesiredAccess); +} +#endif + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ create_mutex(SECURITY_ATTRIBUTES_* lpAttributes, BOOL_ bInitialOwner, LPCSTR_ lpName) +{ + return winapi::CreateMutexA(lpAttributes, bInitialOwner, lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_mutex(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName) +{ + return ::OpenMutexA(dwDesiredAccess, bInheritHandle, lpName); +} +#endif + +BOOST_FORCEINLINE HANDLE_ create_mutex(SECURITY_ATTRIBUTES_* lpAttributes, BOOL_ bInitialOwner, LPCWSTR_ lpName) +{ + return winapi::CreateMutexW(lpAttributes, bInitialOwner, lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_mutex(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName) +{ + return ::OpenMutexW(dwDesiredAccess, bInheritHandle, lpName); +} + +BOOST_FORCEINLINE HANDLE_ create_anonymous_mutex(SECURITY_ATTRIBUTES_* lpAttributes, BOOL_ bInitialOwner) +{ + return winapi::CreateMutexW(lpAttributes, bInitialOwner, 0); +} + +} +} +} + +#endif // BOOST_DETAIL_WINAPI_MUTEX_HPP |