Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:33:58

0001 /*
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * Copyright (c) 2021 Andrey Semashev
0007  */
0008 /*!
0009  * \file   atomic/detail/wait_on_address.hpp
0010  *
0011  * This header contains declaration of runtime detection of \c WaitOnAddress and related APIs on Windows.
0012  */
0013 
0014 #ifndef BOOST_ATOMIC_DETAIL_WAIT_ON_ADDRESS_HPP_INCLUDED_
0015 #define BOOST_ATOMIC_DETAIL_WAIT_ON_ADDRESS_HPP_INCLUDED_
0016 
0017 #include <boost/atomic/detail/config.hpp>
0018 #include <boost/memory_order.hpp>
0019 #include <boost/winapi/basic_types.hpp>
0020 #include <boost/atomic/detail/link.hpp>
0021 #include <boost/atomic/detail/once_flag.hpp>
0022 #include <boost/atomic/detail/header.hpp>
0023 
0024 #ifdef BOOST_HAS_PRAGMA_ONCE
0025 #pragma once
0026 #endif
0027 
0028 namespace boost {
0029 namespace atomics {
0030 namespace detail {
0031 
0032 typedef boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0033 wait_on_address_t(
0034     volatile boost::winapi::VOID_* addr,
0035     boost::winapi::PVOID_ compare_addr,
0036     boost::winapi::SIZE_T_ size,
0037     boost::winapi::DWORD_ timeout_ms);
0038 
0039 typedef boost::winapi::VOID_ BOOST_WINAPI_WINAPI_CC
0040 wake_by_address_t(boost::winapi::PVOID_ addr);
0041 
0042 extern BOOST_ATOMIC_DECL wait_on_address_t* wait_on_address;
0043 extern BOOST_ATOMIC_DECL wake_by_address_t* wake_by_address_single;
0044 extern BOOST_ATOMIC_DECL wake_by_address_t* wake_by_address_all;
0045 
0046 extern BOOST_ATOMIC_DECL once_flag wait_functions_once_flag;
0047 BOOST_ATOMIC_DECL void initialize_wait_functions() BOOST_NOEXCEPT;
0048 
0049 BOOST_FORCEINLINE void ensure_wait_functions_initialized() BOOST_NOEXCEPT
0050 {
0051     static_assert(once_flag_operations::is_always_lock_free, "Boost.Atomic unsupported target platform: native atomic operations not implemented for bytes");
0052     if (BOOST_LIKELY(once_flag_operations::load(wait_functions_once_flag.m_flag, boost::memory_order_acquire) == 0u))
0053         return;
0054 
0055     initialize_wait_functions();
0056 }
0057 
0058 } // namespace detail
0059 } // namespace atomics
0060 } // namespace boost
0061 
0062 #include <boost/atomic/detail/footer.hpp>
0063 
0064 #endif // BOOST_ATOMIC_DETAIL_WAIT_ON_ADDRESS_HPP_INCLUDED_