atomic/config/has_synchronization_lib.cpp
Andrey Semashev 805e309a29 Fixed discrepancy between always_has_native_wait_notify and caps macros.
When targeting Windows 8, the always_has_native_wait_notify static constant
would be set to false even though the native implementation of waiting
and notifying operations through WaitOnAddress would always be used.

To fix this, moved direct WaitOnAddress & co. usage to public header. This
also requires users to link with synchronization.lib, which is done
automatically on compilers that support auto-linking.

The compiled library still implements runtime detection of WaitOnAddress,
even when building for Windows 8 and later. This allows user's code to
be later compiled for Windows 7 and older and still work. This code is
not used when user's code targets Windows 8 or later.

As part of this refactoring, renamed has_synchronization test and
related CMake variable to better communicate that we're testing for
a library.
2021-10-09 23:40:42 +03:00

34 lines
964 B
C++

/*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* Copyright (c) 2020 Andrey Semashev
*/
#define BOOST_USE_WINAPI_VERSION 0x0602
// Include Boost.Predef first so that windows.h is guaranteed to be not included
#include <boost/predef/os/windows.h>
#include <boost/predef/os/cygwin.h>
#if !BOOST_OS_WINDOWS && !BOOST_OS_CYGWIN
#error "This config test is for Windows only"
#endif
#include <boost/winapi/config.hpp>
#include <boost/predef/platform.h>
#if !(BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN8 && (BOOST_WINAPI_PARTITION_APP || BOOST_WINAPI_PARTITION_SYSTEM))
#error "No WaitOnAddress API"
#endif
#include <cstddef>
#include <boost/winapi/basic_types.hpp>
#include <boost/winapi/wait_on_address.hpp>
int main()
{
unsigned int n = 0u, compare = 0u;
boost::winapi::WaitOnAddress(&n, &compare, sizeof(n), 0);
return 0;
}