From 0324dc371f976bb7dc0a2fbc9d08c97163160f77 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Fri, 7 Jul 2017 17:47:24 -0700 Subject: [PATCH] Use Boost.Config --- CHANGELOG.md | 1 + extras/beast/unit_test/dstream.hpp | 22 +++++++------------ extras/beast/unit_test/main.cpp | 5 +++-- include/beast/config.hpp | 15 ++++++++----- include/beast/core/detail/cpu_info.hpp | 4 ++-- .../beast/core/detail/integer_sequence.hpp | 5 +++-- test/benchmarks/nodejs_parser.cpp | 6 +++-- test/http/doc_snippets.cpp | 5 +++-- test/websocket/doc_snippets.cpp | 2 +- 9 files changed, 34 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1b5bba4..da4c4468 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ Version 76: * Always go through write_some +* Use Boost.Config -------------------------------------------------------------------------------- diff --git a/extras/beast/unit_test/dstream.hpp b/extras/beast/unit_test/dstream.hpp index 44eb599b..0e95a04d 100644 --- a/extras/beast/unit_test/dstream.hpp +++ b/extras/beast/unit_test/dstream.hpp @@ -8,28 +8,22 @@ #ifndef BEAST_UNIT_TEST_DSTREAM_HPP #define BEAST_UNIT_TEST_DSTREAM_HPP +#include #include #include #include #include #include -#ifdef _MSC_VER -# ifndef NOMINMAX -# define NOMINMAX 1 -# endif -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include -# undef WIN32_LEAN_AND_MEAN -# undef NOMINMAX +#ifdef BOOST_WINDOWS +#include +#include #endif namespace beast { namespace unit_test { -#ifdef _MSC_VER +#ifdef BOOST_WINDOWS namespace detail { @@ -48,14 +42,14 @@ class dstream_buf void write(char const* s) { if(dbg_) - OutputDebugStringA(s); + boost::detail::winapi::OutputDebugStringA(s); os_ << s; } void write(wchar_t const* s) { if(dbg_) - OutputDebugStringW(s); + boost::detail::winapi::OutputDebugStringW(s); os_ << s; } @@ -63,7 +57,7 @@ public: explicit dstream_buf(ostream& os) : os_(os) - , dbg_(IsDebuggerPresent() != FALSE) + , dbg_(boost::detail::winapi::IsDebuggerPresent() != 0) { } diff --git a/extras/beast/unit_test/main.cpp b/extras/beast/unit_test/main.cpp index bbdf32ec..e6c1464a 100644 --- a/extras/beast/unit_test/main.cpp +++ b/extras/beast/unit_test/main.cpp @@ -11,12 +11,13 @@ #include #include #include +#include #include #include #include #include -#ifdef _MSC_VER +#ifdef BOOST_MSVC # ifndef WIN32_LEAN_AND_MEAN // VC_EXTRALEAN # define WIN32_LEAN_AND_MEAN # include @@ -78,7 +79,7 @@ int main(int ac, char const* av[]) using namespace std; using namespace beast::unit_test; -#ifdef _MSC_VER +#if BOOST_MSVC { int flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); flags |= _CRTDBG_LEAK_CHECK_DF; diff --git a/include/beast/config.hpp b/include/beast/config.hpp index bec3c7c6..9c92df04 100644 --- a/include/beast/config.hpp +++ b/include/beast/config.hpp @@ -8,20 +8,23 @@ #ifndef BEAST_CONFIG_HPP #define BEAST_CONFIG_HPP +#include + +// Available to every header #include #include /* _MSC_VER and _MSC_FULL_VER by version: - 14.0 (2015) 1900 190023026 - 14.0 (2015 Update 1) 1900 190023506 - 14.0 (2015 Update 2) 1900 190023918 - 14.0 (2015 Update 3) 1900 190024210 + 14.0 (2015) 1900 190023026 + 14.0 (2015 Update 1) 1900 190023506 + 14.0 (2015 Update 2) 1900 190023918 + 14.0 (2015 Update 3) 1900 190024210 */ -#if defined(_MSC_FULL_VER) -#if _MSC_FULL_VER < 190024210 +#ifdef BOOST_MSVC +#if BOOST_MSVC_FULL_VER < 190024210 static_assert(false, "This library requires Visual Studio 2015 Update 3 or later"); #endif diff --git a/include/beast/core/detail/cpu_info.hpp b/include/beast/core/detail/cpu_info.hpp index e03b63b6..3a1e24cb 100644 --- a/include/beast/core/detail/cpu_info.hpp +++ b/include/beast/core/detail/cpu_info.hpp @@ -20,7 +20,7 @@ #if ! BEAST_NO_INTRINSICS -#if defined(BOOST_MSVC) +#ifdef BOOST_MSVC #include // __cpuid #else #include // __get_cpuid @@ -41,7 +41,7 @@ cpuid( std::uint32_t& ecx, std::uint32_t& edx) { -#if defined(BOOST_MSVC) +#ifdef BOOST_MSVC int regs[4]; __cpuid(regs, id); eax = regs[0]; diff --git a/include/beast/core/detail/integer_sequence.hpp b/include/beast/core/detail/integer_sequence.hpp index e82422f2..6d0cc8a7 100644 --- a/include/beast/core/detail/integer_sequence.hpp +++ b/include/beast/core/detail/integer_sequence.hpp @@ -8,6 +8,7 @@ #ifndef BEAST_DETAIL_INTEGER_SEQUENCE_HPP #define BEAST_DETAIL_INTEGER_SEQUENCE_HPP +#include #include #include #include @@ -39,9 +40,9 @@ struct sizeof_workaround static std::size_t constexpr size = sizeof... (Args); }; -#ifdef _MSC_VER +#ifdef BOOST_MSVC -// This implementation compiles on MSVC and clang but not gcc +// This implementation compiles on real MSVC and clang but not gcc template struct make_integer_sequence_unchecked; diff --git a/test/benchmarks/nodejs_parser.cpp b/test/benchmarks/nodejs_parser.cpp index 47397e7b..39bef454 100644 --- a/test/benchmarks/nodejs_parser.cpp +++ b/test/benchmarks/nodejs_parser.cpp @@ -10,7 +10,9 @@ #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" #endif -#ifdef _MSC_VER +#include + +#ifdef BOOST_MSVC # pragma warning (push) # pragma warning (disable: 4127) // conditional expression is constant # pragma warning (disable: 4244) // integer conversion, possible loss of data @@ -18,7 +20,7 @@ #include "nodejs-parser/http_parser.c" -#ifdef _MSC_VER +#ifdef BOOST_MSVC # pragma warning (pop) #endif diff --git a/test/http/doc_snippets.cpp b/test/http/doc_snippets.cpp index 82dd0e05..1fdf10de 100644 --- a/test/http/doc_snippets.cpp +++ b/test/http/doc_snippets.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -191,7 +192,7 @@ print_response(SyncReadStream& stream) //] -#ifdef _MSC_VER +#ifdef BOOST_MSVC //[http_snippet_14 template @@ -257,7 +258,7 @@ print(message const& m) //] -#ifdef _MSC_VER +#if BOOST_MSVC //[http_snippet_16 template diff --git a/test/websocket/doc_snippets.cpp b/test/websocket/doc_snippets.cpp index d3e6c053..654c2ca3 100644 --- a/test/websocket/doc_snippets.cpp +++ b/test/websocket/doc_snippets.cpp @@ -217,7 +217,7 @@ boost::asio::ip::tcp::socket sock{ios}; } // fxx() // workaround for https://github.com/chriskohlhoff/asio/issues/112 -#ifdef _MSC_VER +#ifdef BOOST_MSVC //[ws_snippet_21 void echo(stream& ws, multi_buffer& buffer, boost::asio::yield_context yield)