wait_caps_windows.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_DETAIL_WINDOWS_HAS_WAIT_ON_ADDRESS
  27. #define BOOST_ATOMIC_HAS_NATIVE_INT8_WAIT_NOTIFY BOOST_ATOMIC_INT8_LOCK_FREE
  28. #define BOOST_ATOMIC_HAS_NATIVE_INT16_WAIT_NOTIFY BOOST_ATOMIC_INT16_LOCK_FREE
  29. #define BOOST_ATOMIC_HAS_NATIVE_INT32_WAIT_NOTIFY BOOST_ATOMIC_INT32_LOCK_FREE
  30. #define BOOST_ATOMIC_HAS_NATIVE_INT64_WAIT_NOTIFY BOOST_ATOMIC_INT64_LOCK_FREE
  31. #else // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN8 && (BOOST_WINAPI_PARTITION_APP || BOOST_WINAPI_PARTITION_SYSTEM)
  32. // Since we'll detect availability of WaitOnAddress etc. at run time, we have to define capability macros to 1 instead of 2
  33. #if BOOST_ATOMIC_INT8_LOCK_FREE > 0
  34. #define BOOST_ATOMIC_HAS_NATIVE_INT8_WAIT_NOTIFY 1
  35. #endif
  36. #if BOOST_ATOMIC_INT16_LOCK_FREE > 0
  37. #define BOOST_ATOMIC_HAS_NATIVE_INT16_WAIT_NOTIFY 1
  38. #endif
  39. #if BOOST_ATOMIC_INT32_LOCK_FREE > 0
  40. #define BOOST_ATOMIC_HAS_NATIVE_INT32_WAIT_NOTIFY 1
  41. #endif
  42. #if BOOST_ATOMIC_INT64_LOCK_FREE > 0
  43. #define BOOST_ATOMIC_HAS_NATIVE_INT64_WAIT_NOTIFY 1
  44. #endif
  45. #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN8 && (BOOST_WINAPI_PARTITION_APP || BOOST_WINAPI_PARTITION_SYSTEM)
  46. #endif // BOOST_ATOMIC_DETAIL_WAIT_CAPS_WINDOWS_HPP_INCLUDED_