wait_caps_windows.hpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * Copyright (c) 2020 Andrey Semashev
  7. */
  8. /*!
  9. * \file atomic/detail/wait_caps_windows.hpp
  10. *
  11. * This header defines waiting/notifying operations capabilities macros.
  12. */
  13. #ifndef BOOST_ATOMIC_DETAIL_WAIT_CAPS_WINDOWS_HPP_INCLUDED_
  14. #define BOOST_ATOMIC_DETAIL_WAIT_CAPS_WINDOWS_HPP_INCLUDED_
  15. #include <boost/winapi/config.hpp>
  16. #include <boost/atomic/detail/config.hpp>
  17. #include <boost/atomic/detail/capabilities.hpp>
  18. #ifdef BOOST_HAS_PRAGMA_ONCE
  19. #pragma once
  20. #endif
  21. // MSDN says WaitOnAddress, WakeByAddressSingle and WakeByAddressAll only support notifications between threads of the same process, so no address-free operations.
  22. // https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitonaddress
  23. // https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-wakebyaddresssingle
  24. // https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-wakebyaddressall
  25. #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN8 && (BOOST_WINAPI_PARTITION_APP || BOOST_WINAPI_PARTITION_SYSTEM)
  26. #define BOOST_ATOMIC_HAS_NATIVE_INT8_WAIT_NOTIFY BOOST_ATOMIC_INT8_LOCK_FREE
  27. #define BOOST_ATOMIC_HAS_NATIVE_INT16_WAIT_NOTIFY BOOST_ATOMIC_INT16_LOCK_FREE
  28. #define BOOST_ATOMIC_HAS_NATIVE_INT32_WAIT_NOTIFY BOOST_ATOMIC_INT32_LOCK_FREE
  29. #define BOOST_ATOMIC_HAS_NATIVE_INT64_WAIT_NOTIFY BOOST_ATOMIC_INT64_LOCK_FREE
  30. #else // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN8 && (BOOST_WINAPI_PARTITION_APP || BOOST_WINAPI_PARTITION_SYSTEM)
  31. // Since will detect availability of WaitOnAddress etc. at run time, we have to define capability macros to 1 instead of 2
  32. #if BOOST_ATOMIC_INT8_LOCK_FREE > 0
  33. #define BOOST_ATOMIC_HAS_NATIVE_INT8_WAIT_NOTIFY 1
  34. #endif
  35. #if BOOST_ATOMIC_INT16_LOCK_FREE > 0
  36. #define BOOST_ATOMIC_HAS_NATIVE_INT16_WAIT_NOTIFY 1
  37. #endif
  38. #if BOOST_ATOMIC_INT32_LOCK_FREE > 0
  39. #define BOOST_ATOMIC_HAS_NATIVE_INT32_WAIT_NOTIFY 1
  40. #endif
  41. #if BOOST_ATOMIC_INT64_LOCK_FREE > 0
  42. #define BOOST_ATOMIC_HAS_NATIVE_INT64_WAIT_NOTIFY 1
  43. #endif
  44. #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN8 && (BOOST_WINAPI_PARTITION_APP || BOOST_WINAPI_PARTITION_SYSTEM)
  45. #endif // BOOST_ATOMIC_DETAIL_WAIT_CAPS_WINDOWS_HPP_INCLUDED_