diff options
Diffstat (limited to 'src/third_party/asio-master/asio/include')
36 files changed, 784 insertions, 101 deletions
diff --git a/src/third_party/asio-master/asio/include/Makefile.am b/src/third_party/asio-master/asio/include/Makefile.am index 8832c40c4f0..e1c0e1fa635 100644 --- a/src/third_party/asio-master/asio/include/Makefile.am +++ b/src/third_party/asio-master/asio/include/Makefile.am @@ -322,6 +322,7 @@ nobase_include_HEADERS = \ asio/impl/spawn.hpp \ asio/impl/src.cpp \ asio/impl/src.hpp \ + asio/impl/system_context.hpp \ asio/impl/system_context.ipp \ asio/impl/system_executor.hpp \ asio/impl/thread_pool.hpp \ diff --git a/src/third_party/asio-master/asio/include/asio.hpp b/src/third_party/asio-master/asio/include/asio.hpp index f2da0efc783..fafb8381ba3 100644 --- a/src/third_party/asio-master/asio/include/asio.hpp +++ b/src/third_party/asio-master/asio/include/asio.hpp @@ -62,6 +62,7 @@ #include "asio/handler_continuation_hook.hpp" #include "asio/handler_invoke_hook.hpp" #include "asio/handler_type.hpp" +#include "asio/high_resolution_timer.hpp" #include "asio/io_context.hpp" #include "asio/io_context_strand.hpp" #include "asio/io_service.hpp" @@ -117,12 +118,14 @@ #include "asio/signal_set_service.hpp" #include "asio/socket_acceptor_service.hpp" #include "asio/socket_base.hpp" +#include "asio/steady_timer.hpp" #include "asio/strand.hpp" #include "asio/stream_socket_service.hpp" #include "asio/streambuf.hpp" #include "asio/system_context.hpp" #include "asio/system_error.hpp" #include "asio/system_executor.hpp" +#include "asio/system_timer.hpp" #include "asio/thread.hpp" #include "asio/thread_pool.hpp" #include "asio/time_traits.hpp" diff --git a/src/third_party/asio-master/asio/include/asio/buffer.hpp b/src/third_party/asio-master/asio/include/asio/buffer.hpp index 14d5ca0e404..a7c9b8a92a6 100644 --- a/src/third_party/asio-master/asio/include/asio/buffer.hpp +++ b/src/third_party/asio-master/asio/include/asio/buffer.hpp @@ -28,13 +28,13 @@ #include "asio/detail/throw_exception.hpp" #include "asio/detail/type_traits.hpp" -#if defined(ASIO_MSVC) +#if defined(ASIO_MSVC) && (ASIO_MSVC >= 1700) # if defined(_HAS_ITERATOR_DEBUGGING) && (_HAS_ITERATOR_DEBUGGING != 0) # if !defined(ASIO_DISABLE_BUFFER_DEBUGGING) # define ASIO_ENABLE_BUFFER_DEBUGGING # endif // !defined(ASIO_DISABLE_BUFFER_DEBUGGING) # endif // defined(_HAS_ITERATOR_DEBUGGING) -#endif // defined(ASIO_MSVC) +#endif // defined(ASIO_MSVC) && (ASIO_MSVC >= 1700) #if defined(__GNUC__) # if defined(_GLIBCXX_DEBUG) @@ -1920,7 +1920,8 @@ inline std::size_t buffer_copy_1(const mutable_buffer& target, std::size_t target_size = target.size(); std::size_t source_size = source.size(); std::size_t n = target_size < source_size ? target_size : source_size; - memcpy(target.data(), source.data(), n); + if (n > 0) + memcpy(target.data(), source.data(), n); return n; } diff --git a/src/third_party/asio-master/asio/include/asio/coroutine.hpp b/src/third_party/asio-master/asio/include/asio/coroutine.hpp index 13e296563f4..102cefba18d 100644 --- a/src/third_party/asio-master/asio/include/asio/coroutine.hpp +++ b/src/third_party/asio-master/asio/include/asio/coroutine.hpp @@ -289,7 +289,7 @@ private: bail_out_of_coroutine: \ break; \ } \ - else case 0: + else /* fall-through */ case 0: #define ASIO_CORO_YIELD_IMPL(n) \ for (_coro_value = (n);;) \ @@ -301,12 +301,12 @@ private: else \ switch (_coro_value ? 0 : 1) \ for (;;) \ - case -1: if (_coro_value) \ + /* fall-through */ case -1: if (_coro_value) \ goto terminate_coroutine; \ else for (;;) \ - case 1: if (_coro_value) \ + /* fall-through */ case 1: if (_coro_value) \ goto bail_out_of_coroutine; \ - else case 0: + else /* fall-through */ case 0: #define ASIO_CORO_FORK_IMPL(n) \ for (_coro_value = -(n);; _coro_value = (n)) \ diff --git a/src/third_party/asio-master/asio/include/asio/detail/bind_handler.hpp b/src/third_party/asio-master/asio/include/asio/detail/bind_handler.hpp index 55c46a0707c..b16edda23c7 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/bind_handler.hpp +++ b/src/third_party/asio-master/asio/include/asio/detail/bind_handler.hpp @@ -223,6 +223,363 @@ inline binder2<typename decay<Handler>::type, Arg1, Arg2> bind_handler( ASIO_MOVE_CAST(Handler)(handler), arg1, arg2); } +template <typename Handler, typename Arg1, typename Arg2, typename Arg3> +class binder3 +{ +public: + template <typename T> + binder3(int, ASIO_MOVE_ARG(T) handler, const Arg1& arg1, + const Arg2& arg2, const Arg3& arg3) + : handler_(ASIO_MOVE_CAST(T)(handler)), + arg1_(arg1), + arg2_(arg2), + arg3_(arg3) + { + } + + binder3(Handler& handler, const Arg1& arg1, + const Arg2& arg2, const Arg3& arg3) + : handler_(ASIO_MOVE_CAST(Handler)(handler)), + arg1_(arg1), + arg2_(arg2), + arg3_(arg3) + { + } + +#if defined(ASIO_HAS_MOVE) + binder3(const binder3& other) + : handler_(other.handler_), + arg1_(other.arg1_), + arg2_(other.arg2_), + arg3_(other.arg3_) + { + } + + binder3(binder3&& other) + : handler_(ASIO_MOVE_CAST(Handler)(other.handler_)), + arg1_(ASIO_MOVE_CAST(Arg1)(other.arg1_)), + arg2_(ASIO_MOVE_CAST(Arg2)(other.arg2_)), + arg3_(ASIO_MOVE_CAST(Arg3)(other.arg3_)) + { + } +#endif // defined(ASIO_HAS_MOVE) + + void operator()() + { + handler_(static_cast<const Arg1&>(arg1_), + static_cast<const Arg2&>(arg2_), static_cast<const Arg3&>(arg3_)); + } + + void operator()() const + { + handler_(arg1_, arg2_, arg3_); + } + +//private: + Handler handler_; + Arg1 arg1_; + Arg2 arg2_; + Arg3 arg3_; +}; + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3> +inline void* asio_handler_allocate(std::size_t size, + binder3<Handler, Arg1, Arg2, Arg3>* this_handler) +{ + return asio_handler_alloc_helpers::allocate( + size, this_handler->handler_); +} + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3> +inline void asio_handler_deallocate(void* pointer, std::size_t size, + binder3<Handler, Arg1, Arg2, Arg3>* this_handler) +{ + asio_handler_alloc_helpers::deallocate( + pointer, size, this_handler->handler_); +} + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3> +inline bool asio_handler_is_continuation( + binder3<Handler, Arg1, Arg2, Arg3>* this_handler) +{ + return asio_handler_cont_helpers::is_continuation( + this_handler->handler_); +} + +template <typename Function, typename Handler, + typename Arg1, typename Arg2, typename Arg3> +inline void asio_handler_invoke(Function& function, + binder3<Handler, Arg1, Arg2, Arg3>* this_handler) +{ + asio_handler_invoke_helpers::invoke( + function, this_handler->handler_); +} + +template <typename Function, typename Handler, + typename Arg1, typename Arg2, typename Arg3> +inline void asio_handler_invoke(const Function& function, + binder3<Handler, Arg1, Arg2, Arg3>* this_handler) +{ + asio_handler_invoke_helpers::invoke( + function, this_handler->handler_); +} + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3> +inline binder3<typename decay<Handler>::type, Arg1, Arg2, Arg3> bind_handler( + ASIO_MOVE_ARG(Handler) handler, const Arg1& arg1, const Arg2& arg2, + const Arg3& arg3) +{ + return binder3<typename decay<Handler>::type, Arg1, Arg2, Arg3>(0, + ASIO_MOVE_CAST(Handler)(handler), arg1, arg2, arg3); +} + +template <typename Handler, typename Arg1, + typename Arg2, typename Arg3, typename Arg4> +class binder4 +{ +public: + template <typename T> + binder4(int, ASIO_MOVE_ARG(T) handler, const Arg1& arg1, + const Arg2& arg2, const Arg3& arg3, const Arg4& arg4) + : handler_(ASIO_MOVE_CAST(T)(handler)), + arg1_(arg1), + arg2_(arg2), + arg3_(arg3), + arg4_(arg4) + { + } + + binder4(Handler& handler, const Arg1& arg1, + const Arg2& arg2, const Arg3& arg3, const Arg4& arg4) + : handler_(ASIO_MOVE_CAST(Handler)(handler)), + arg1_(arg1), + arg2_(arg2), + arg3_(arg3), + arg4_(arg4) + { + } + +#if defined(ASIO_HAS_MOVE) + binder4(const binder4& other) + : handler_(other.handler_), + arg1_(other.arg1_), + arg2_(other.arg2_), + arg3_(other.arg3_), + arg4_(other.arg4_) + { + } + + binder4(binder4&& other) + : handler_(ASIO_MOVE_CAST(Handler)(other.handler_)), + arg1_(ASIO_MOVE_CAST(Arg1)(other.arg1_)), + arg2_(ASIO_MOVE_CAST(Arg2)(other.arg2_)), + arg3_(ASIO_MOVE_CAST(Arg3)(other.arg3_)), + arg4_(ASIO_MOVE_CAST(Arg4)(other.arg4_)) + { + } +#endif // defined(ASIO_HAS_MOVE) + + void operator()() + { + handler_(static_cast<const Arg1&>(arg1_), + static_cast<const Arg2&>(arg2_), static_cast<const Arg3&>(arg3_), + static_cast<const Arg4&>(arg4_)); + } + + void operator()() const + { + handler_(arg1_, arg2_, arg3_, arg4_); + } + +//private: + Handler handler_; + Arg1 arg1_; + Arg2 arg2_; + Arg3 arg3_; + Arg4 arg4_; +}; + +template <typename Handler, typename Arg1, + typename Arg2, typename Arg3, typename Arg4> +inline void* asio_handler_allocate(std::size_t size, + binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler) +{ + return asio_handler_alloc_helpers::allocate( + size, this_handler->handler_); +} + +template <typename Handler, typename Arg1, + typename Arg2, typename Arg3, typename Arg4> +inline void asio_handler_deallocate(void* pointer, std::size_t size, + binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler) +{ + asio_handler_alloc_helpers::deallocate( + pointer, size, this_handler->handler_); +} + +template <typename Handler, typename Arg1, + typename Arg2, typename Arg3, typename Arg4> +inline bool asio_handler_is_continuation( + binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler) +{ + return asio_handler_cont_helpers::is_continuation( + this_handler->handler_); +} + +template <typename Function, typename Handler, typename Arg1, + typename Arg2, typename Arg3, typename Arg4> +inline void asio_handler_invoke(Function& function, + binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler) +{ + asio_handler_invoke_helpers::invoke( + function, this_handler->handler_); +} + +template <typename Function, typename Handler, typename Arg1, + typename Arg2, typename Arg3, typename Arg4> +inline void asio_handler_invoke(const Function& function, + binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler) +{ + asio_handler_invoke_helpers::invoke( + function, this_handler->handler_); +} + +template <typename Handler, typename Arg1, + typename Arg2, typename Arg3, typename Arg4> +inline binder4<typename decay<Handler>::type, Arg1, Arg2, Arg3, Arg4> +bind_handler(ASIO_MOVE_ARG(Handler) handler, const Arg1& arg1, + const Arg2& arg2, const Arg3& arg3, const Arg4& arg4) +{ + return binder4<typename decay<Handler>::type, Arg1, Arg2, Arg3, Arg4>(0, + ASIO_MOVE_CAST(Handler)(handler), arg1, arg2, arg3, arg4); +} + +template <typename Handler, typename Arg1, typename Arg2, + typename Arg3, typename Arg4, typename Arg5> +class binder5 +{ +public: + template <typename T> + binder5(int, ASIO_MOVE_ARG(T) handler, const Arg1& arg1, + const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, const Arg5& arg5) + : handler_(ASIO_MOVE_CAST(T)(handler)), + arg1_(arg1), + arg2_(arg2), + arg3_(arg3), + arg4_(arg4), + arg5_(arg5) + { + } + + binder5(Handler& handler, const Arg1& arg1, const Arg2& arg2, + const Arg3& arg3, const Arg4& arg4, const Arg5& arg5) + : handler_(ASIO_MOVE_CAST(Handler)(handler)), + arg1_(arg1), + arg2_(arg2), + arg3_(arg3), + arg4_(arg4), + arg5_(arg5) + { + } + +#if defined(ASIO_HAS_MOVE) + binder5(const binder5& other) + : handler_(other.handler_), + arg1_(other.arg1_), + arg2_(other.arg2_), + arg3_(other.arg3_), + arg4_(other.arg4_), + arg5_(other.arg5_) + { + } + + binder5(binder5&& other) + : handler_(ASIO_MOVE_CAST(Handler)(other.handler_)), + arg1_(ASIO_MOVE_CAST(Arg1)(other.arg1_)), + arg2_(ASIO_MOVE_CAST(Arg2)(other.arg2_)), + arg3_(ASIO_MOVE_CAST(Arg3)(other.arg3_)), + arg4_(ASIO_MOVE_CAST(Arg4)(other.arg4_)), + arg5_(ASIO_MOVE_CAST(Arg5)(other.arg5_)) + { + } +#endif // defined(ASIO_HAS_MOVE) + + void operator()() + { + handler_(static_cast<const Arg1&>(arg1_), + static_cast<const Arg2&>(arg2_), static_cast<const Arg3&>(arg3_), + static_cast<const Arg4&>(arg4_), static_cast<const Arg5&>(arg5_)); + } + + void operator()() const + { + handler_(arg1_, arg2_, arg3_, arg4_, arg5_); + } + +//private: + Handler handler_; + Arg1 arg1_; + Arg2 arg2_; + Arg3 arg3_; + Arg4 arg4_; + Arg5 arg5_; +}; + +template <typename Handler, typename Arg1, typename Arg2, + typename Arg3, typename Arg4, typename Arg5> +inline void* asio_handler_allocate(std::size_t size, + binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler) +{ + return asio_handler_alloc_helpers::allocate( + size, this_handler->handler_); +} + +template <typename Handler, typename Arg1, typename Arg2, + typename Arg3, typename Arg4, typename Arg5> +inline void asio_handler_deallocate(void* pointer, std::size_t size, + binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler) +{ + asio_handler_alloc_helpers::deallocate( + pointer, size, this_handler->handler_); +} + +template <typename Handler, typename Arg1, typename Arg2, + typename Arg3, typename Arg4, typename Arg5> +inline bool asio_handler_is_continuation( + binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler) +{ + return asio_handler_cont_helpers::is_continuation( + this_handler->handler_); +} + +template <typename Function, typename Handler, typename Arg1, + typename Arg2, typename Arg3, typename Arg4, typename Arg5> +inline void asio_handler_invoke(Function& function, + binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler) +{ + asio_handler_invoke_helpers::invoke( + function, this_handler->handler_); +} + +template <typename Function, typename Handler, typename Arg1, + typename Arg2, typename Arg3, typename Arg4, typename Arg5> +inline void asio_handler_invoke(const Function& function, + binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler) +{ + asio_handler_invoke_helpers::invoke( + function, this_handler->handler_); +} + +template <typename Handler, typename Arg1, typename Arg2, + typename Arg3, typename Arg4, typename Arg5> +inline binder5<typename decay<Handler>::type, Arg1, Arg2, Arg3, Arg4, Arg5> +bind_handler(ASIO_MOVE_ARG(Handler) handler, const Arg1& arg1, + const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, const Arg5& arg5) +{ + return binder5<typename decay<Handler>::type, Arg1, Arg2, Arg3, Arg4, Arg5>(0, + ASIO_MOVE_CAST(Handler)(handler), arg1, arg2, arg3, arg4, arg5); +} + #if defined(ASIO_HAS_MOVE) template <typename Handler, typename Arg1> diff --git a/src/third_party/asio-master/asio/include/asio/detail/config.hpp b/src/third_party/asio-master/asio/include/asio/detail/config.hpp index 7fe6a95a1b0..ffe94aacc1b 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/config.hpp +++ b/src/third_party/asio-master/asio/include/asio/detail/config.hpp @@ -632,16 +632,16 @@ # define ASIO_HAS_CXX11_ALLOCATORS 1 # endif // (__cplusplus >= 201103) # elif defined(__GNUC__) -# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4) +# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4) # if defined(__GXX_EXPERIMENTAL_CXX0X__) # define ASIO_HAS_CXX11_ALLOCATORS 1 # endif // defined(__GXX_EXPERIMENTAL_CXX0X__) -# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4) +# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4) # endif // defined(__GNUC__) # if defined(ASIO_MSVC) -# if (_MSC_VER >= 1700) +# if (_MSC_VER >= 1800) # define ASIO_HAS_CXX11_ALLOCATORS 1 -# endif // (_MSC_VER >= 1700) +# endif // (_MSC_VER >= 1800) # endif // defined(ASIO_MSVC) # endif // !defined(ASIO_DISABLE_CXX11_ALLOCATORS) #endif // !defined(ASIO_HAS_CXX11_ALLOCATORS) @@ -1349,8 +1349,16 @@ #endif // defined(ASIO_NO_DEPRECATED) // Newer gcc, clang need special treatment to suppress unused typedef warnings. -#if defined(__clang__) && (__clang_major__ >= 7) -# define ASIO_UNUSED_TYPEDEF __attribute__((__unused__)) +#if defined(__clang__) +# if defined(__apple_build_version__) +# if (__clang_major__ >= 7) +# define ASIO_UNUSED_TYPEDEF __attribute__((__unused__)) +# endif // (__clang_major__ >= 7) +# elif ((__clang_major__ == 3) && (__clang_minor__ >= 6)) \ + || (__clang_major__ > 3) +# define ASIO_UNUSED_TYPEDEF __attribute__((__unused__)) +# endif // ((__clang_major__ == 3) && (__clang_minor__ >= 6)) + // || (__clang_major__ > 3) #elif defined(__GNUC__) # if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4) # define ASIO_UNUSED_TYPEDEF __attribute__((__unused__)) diff --git a/src/third_party/asio-master/asio/include/asio/detail/consuming_buffers.hpp b/src/third_party/asio-master/asio/include/asio/detail/consuming_buffers.hpp index 8ae6b45f974..ccdc86b067d 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/consuming_buffers.hpp +++ b/src/third_party/asio-master/asio/include/asio/detail/consuming_buffers.hpp @@ -26,19 +26,37 @@ namespace asio { namespace detail { +// Helper template to determine the maximum number of prepared buffers. +template <typename Buffers> +struct prepared_buffers_max +{ + enum { value = buffer_sequence_adapter_base::max_buffers }; +}; + +template <typename Elem, std::size_t N> +struct prepared_buffers_max<boost::array<Elem, N> > +{ + enum { value = N }; +}; + +#if defined(ASIO_HAS_STD_ARRAY) + +template <typename Elem, std::size_t N> +struct prepared_buffers_max<std::array<Elem, N> > +{ + enum { value = N }; +}; + +#endif // defined(ASIO_HAS_STD_ARRAY) // A buffer sequence used to represent a subsequence of the buffers. -template <typename Buffer> +template <typename Buffer, std::size_t MaxBuffers> struct prepared_buffers { typedef Buffer value_type; typedef const Buffer* const_iterator; - enum - { - max_buffers = buffer_sequence_adapter_base::max_buffers < 8 - ? buffer_sequence_adapter_base::max_buffers : 8 - }; + enum { max_buffers = MaxBuffers < 16 ? MaxBuffers : 16 }; prepared_buffers() : count(0) {} const_iterator begin() const { return elems; } @@ -53,6 +71,9 @@ template <typename Buffer, typename Buffers, typename Buffer_Iterator> class consuming_buffers { public: + typedef prepared_buffers<Buffer, prepared_buffers_max<Buffers>::value> + prepared_buffers_type; + // Construct to represent the entire list of buffers. explicit consuming_buffers(const Buffers& buffers) : buffers_(buffers), @@ -71,9 +92,9 @@ public: } // Get the buffer for a single transfer, with a size. - prepared_buffers<Buffer> prepare(std::size_t max_size) + prepared_buffers_type prepare(std::size_t max_size) { - prepared_buffers<Buffer> result; + prepared_buffers_type result; Buffer_Iterator next = asio::buffer_sequence_begin(buffers_); Buffer_Iterator end = asio::buffer_sequence_end(buffers_); diff --git a/src/third_party/asio-master/asio/include/asio/detail/handler_alloc_helpers.hpp b/src/third_party/asio-master/asio/include/asio/detail/handler_alloc_helpers.hpp index 3b72e33345a..558793d819a 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/handler_alloc_helpers.hpp +++ b/src/third_party/asio-master/asio/include/asio/detail/handler_alloc_helpers.hpp @@ -170,14 +170,6 @@ struct get_hook_allocator<Handler, std::allocator<T> > } \ void reset() \ { \ - typedef typename ::asio::associated_allocator< \ - Handler>::type associated_allocator_type; \ - typedef typename ::asio::detail::get_hook_allocator< \ - Handler, associated_allocator_type>::type hook_allocator_type; \ - ASIO_REBIND_ALLOC(hook_allocator_type, op) a( \ - ::asio::detail::get_hook_allocator< \ - Handler, associated_allocator_type>::get( \ - *h, ::asio::get_associated_allocator(*h))); \ if (p) \ { \ p->~op(); \ @@ -185,6 +177,14 @@ struct get_hook_allocator<Handler, std::allocator<T> > } \ if (v) \ { \ + typedef typename ::asio::associated_allocator< \ + Handler>::type associated_allocator_type; \ + typedef typename ::asio::detail::get_hook_allocator< \ + Handler, associated_allocator_type>::type hook_allocator_type; \ + ASIO_REBIND_ALLOC(hook_allocator_type, op) a( \ + ::asio::detail::get_hook_allocator< \ + Handler, associated_allocator_type>::get( \ + *h, ::asio::get_associated_allocator(*h))); \ a.deallocate(static_cast<op*>(v), 1); \ v = 0; \ } \ @@ -212,10 +212,6 @@ struct get_hook_allocator<Handler, std::allocator<T> > } \ void reset() \ { \ - typedef typename ::asio::detail::get_recycling_allocator< \ - Alloc>::type recycling_allocator_type; \ - ASIO_REBIND_ALLOC(recycling_allocator_type, op) a1( \ - ::asio::detail::get_recycling_allocator<Alloc>::get(*a)); \ if (p) \ { \ p->~op(); \ @@ -223,6 +219,10 @@ struct get_hook_allocator<Handler, std::allocator<T> > } \ if (v) \ { \ + typedef typename ::asio::detail::get_recycling_allocator< \ + Alloc>::type recycling_allocator_type; \ + ASIO_REBIND_ALLOC(recycling_allocator_type, op) a1( \ + ::asio::detail::get_recycling_allocator<Alloc>::get(*a)); \ a1.deallocate(static_cast<op*>(v), 1); \ v = 0; \ } \ diff --git a/src/third_party/asio-master/asio/include/asio/detail/handler_type_requirements.hpp b/src/third_party/asio-master/asio/include/asio/detail/handler_type_requirements.hpp index c06468b8f5a..2bff91a587c 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/handler_type_requirements.hpp +++ b/src/third_party/asio-master/asio/include/asio/detail/handler_type_requirements.hpp @@ -508,6 +508,10 @@ struct handler_type_requirements handler_type, handler) \ typedef int ASIO_UNUSED_TYPEDEF +#define ASIO_MOVE_ACCEPT_HANDLER_CHECK( \ + handler_type, handler, socket_type) \ + typedef int ASIO_UNUSED_TYPEDEF + #define ASIO_CONNECT_HANDLER_CHECK( \ handler_type, handler) \ typedef int ASIO_UNUSED_TYPEDEF diff --git a/src/third_party/asio-master/asio/include/asio/detail/impl/epoll_reactor.ipp b/src/third_party/asio-master/asio/include/asio/detail/impl/epoll_reactor.ipp index 45682de06ee..7ffcf3fa107 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/impl/epoll_reactor.ipp +++ b/src/third_party/asio-master/asio/include/asio/detail/impl/epoll_reactor.ipp @@ -384,6 +384,15 @@ void epoll_reactor::deregister_descriptor(socket_type descriptor, reinterpret_cast<uintmax_t>(descriptor_data))); scheduler_.post_deferred_completions(ops); + + // Leave descriptor_data set so that it will be freed by the subsequent + // call to cleanup_descriptor_data. + } + else + { + // We are shutting down, so prevent cleanup_descriptor_data from freeing + // the descriptor_data object and let the destructor free it instead. + descriptor_data = 0; } } @@ -412,6 +421,15 @@ void epoll_reactor::deregister_internal_descriptor(socket_type descriptor, ASIO_HANDLER_REACTOR_DEREGISTRATION(( context(), static_cast<uintmax_t>(descriptor), reinterpret_cast<uintmax_t>(descriptor_data))); + + // Leave descriptor_data set so that it will be freed by the subsequent + // call to cleanup_descriptor_data. + } + else + { + // We are shutting down, so prevent cleanup_descriptor_data from freeing + // the descriptor_data object and let the destructor free it instead. + descriptor_data = 0; } } diff --git a/src/third_party/asio-master/asio/include/asio/detail/impl/kqueue_reactor.ipp b/src/third_party/asio-master/asio/include/asio/detail/impl/kqueue_reactor.ipp index 24599ad115e..617c44f65d9 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/impl/kqueue_reactor.ipp +++ b/src/third_party/asio-master/asio/include/asio/detail/impl/kqueue_reactor.ipp @@ -328,6 +328,15 @@ void kqueue_reactor::deregister_descriptor(socket_type descriptor, reinterpret_cast<uintmax_t>(descriptor_data))); scheduler_.post_deferred_completions(ops); + + // Leave descriptor_data set so that it will be freed by the subsequent + // call to cleanup_descriptor_data. + } + else + { + // We are shutting down, so prevent cleanup_descriptor_data from freeing + // the descriptor_data object and let the destructor free it instead. + descriptor_data = 0; } } @@ -360,6 +369,15 @@ void kqueue_reactor::deregister_internal_descriptor(socket_type descriptor, ASIO_HANDLER_REACTOR_DEREGISTRATION(( context(), static_cast<uintmax_t>(descriptor), reinterpret_cast<uintmax_t>(descriptor_data))); + + // Leave descriptor_data set so that it will be freed by the subsequent + // call to cleanup_descriptor_data. + } + else + { + // We are shutting down, so prevent cleanup_descriptor_data from freeing + // the descriptor_data object and let the destructor free it instead. + descriptor_data = 0; } } diff --git a/src/third_party/asio-master/asio/include/asio/detail/impl/reactive_serial_port_service.ipp b/src/third_party/asio-master/asio/include/asio/detail/impl/reactive_serial_port_service.ipp index 6f57b7b224c..2456ca9ba51 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/impl/reactive_serial_port_service.ipp +++ b/src/third_party/asio-master/asio/include/asio/detail/impl/reactive_serial_port_service.ipp @@ -73,7 +73,7 @@ asio::error_code reactive_serial_port_service::open( s = descriptor_ops::error_wrapper(::tcgetattr(fd, &ios), ec); if (s >= 0) { -#if defined(_BSD_SOURCE) +#if defined(_BSD_SOURCE) || defined(_DEFAULT_SOURCE) ::cfmakeraw(&ios); #else ios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK diff --git a/src/third_party/asio-master/asio/include/asio/detail/impl/socket_ops.ipp b/src/third_party/asio-master/asio/include/asio/detail/impl/socket_ops.ipp index d8b457b1dd0..b3b1a0cf811 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/impl/socket_ops.ipp +++ b/src/third_party/asio-master/asio/include/asio/detail/impl/socket_ops.ipp @@ -770,6 +770,8 @@ signed_size_type recv(socket_type s, buf* bufs, size_t count, ec = asio::error::connection_reset; else if (ec.value() == ERROR_PORT_UNREACHABLE) ec = asio::error::connection_refused; + else if (ec.value() == WSAEMSGSIZE || ec.value() == ERROR_MORE_DATA) + ec.assign(0, ec.category()); if (result != 0) return socket_error_retval; ec = asio::error_code(); @@ -848,6 +850,10 @@ void complete_iocp_recv(state_type state, { ec = asio::error::connection_refused; } + else if (ec.value() == WSAEMSGSIZE || ec.value() == ERROR_MORE_DATA) + { + ec.assign(0, ec.category()); + } // Check for connection closed. else if (!ec && bytes_transferred == 0 @@ -918,6 +924,8 @@ signed_size_type recvfrom(socket_type s, buf* bufs, size_t count, ec = asio::error::connection_reset; else if (ec.value() == ERROR_PORT_UNREACHABLE) ec = asio::error::connection_refused; + else if (ec.value() == WSAEMSGSIZE || ec.value() == ERROR_MORE_DATA) + ec.assign(0, ec.category()); if (result != 0) return socket_error_retval; ec = asio::error_code(); @@ -987,6 +995,10 @@ void complete_iocp_recvfrom( { ec = asio::error::connection_refused; } + else if (ec.value() == WSAEMSGSIZE || ec.value() == ERROR_MORE_DATA) + { + ec.assign(0, ec.category()); + } } #else // defined(ASIO_HAS_IOCP) @@ -1100,6 +1112,10 @@ void complete_iocp_recvmsg( { ec = asio::error::connection_refused; } + else if (ec.value() == WSAEMSGSIZE || ec.value() == ERROR_MORE_DATA) + { + ec.assign(0, ec.category()); + } } #else // defined(ASIO_HAS_IOCP) diff --git a/src/third_party/asio-master/asio/include/asio/detail/impl/win_event.ipp b/src/third_party/asio-master/asio/include/asio/detail/impl/win_event.ipp index 4c63fd5f0d9..3e4edaaf773 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/impl/win_event.ipp +++ b/src/third_party/asio-master/asio/include/asio/detail/impl/win_event.ipp @@ -32,7 +32,8 @@ win_event::win_event() : state_(0) { #if defined(ASIO_WINDOWS_APP) - events_[0] = ::CreateEventExW(0, 0, CREATE_EVENT_MANUAL_RESET, 0); + events_[0] = ::CreateEventExW(0, 0, + CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS); #else // defined(ASIO_WINDOWS_APP) events_[0] = ::CreateEventW(0, true, false, 0); #endif // defined(ASIO_WINDOWS_APP) @@ -45,7 +46,7 @@ win_event::win_event() } #if defined(ASIO_WINDOWS_APP) - events_[1] = ::CreateEventExW(0, 0, 0, 0); + events_[1] = ::CreateEventExW(0, 0, 0, EVENT_ALL_ACCESS); #else // defined(ASIO_WINDOWS_APP) events_[1] = ::CreateEventW(0, false, false, 0); #endif // defined(ASIO_WINDOWS_APP) diff --git a/src/third_party/asio-master/asio/include/asio/detail/impl/win_tss_ptr.ipp b/src/third_party/asio-master/asio/include/asio/detail/impl/win_tss_ptr.ipp index 7f50fd3f164..16e25d3814f 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/impl/win_tss_ptr.ipp +++ b/src/third_party/asio-master/asio/include/asio/detail/impl/win_tss_ptr.ipp @@ -31,9 +31,9 @@ namespace detail { DWORD win_tss_ptr_create() { #if defined(UNDER_CE) - enum { out_of_indexes = 0xFFFFFFFF }; + const DWORD out_of_indexes = 0xFFFFFFFF; #else - enum { out_of_indexes = TLS_OUT_OF_INDEXES }; + const DWORD out_of_indexes = TLS_OUT_OF_INDEXES; #endif DWORD tss_key = ::TlsAlloc(); diff --git a/src/third_party/asio-master/asio/include/asio/detail/pop_options.hpp b/src/third_party/asio-master/asio/include/asio/detail/pop_options.hpp index 51e826de35f..2cf2b6c2130 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/pop_options.hpp +++ b/src/third_party/asio-master/asio/include/asio/detail/pop_options.hpp @@ -67,6 +67,10 @@ # pragma GCC visibility pop # endif // (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) +# if (__GNUC__ >= 7) +# pragma GCC diagnostic pop +# endif // (__GNUC__ >= 7) + #elif defined(__KCC) // Kai C++ diff --git a/src/third_party/asio-master/asio/include/asio/detail/push_options.hpp b/src/third_party/asio-master/asio/include/asio/detail/push_options.hpp index ecdcb7c4f85..a1c811fc3bf 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/push_options.hpp +++ b/src/third_party/asio-master/asio/include/asio/detail/push_options.hpp @@ -71,6 +71,11 @@ # pragma GCC visibility push (default) # endif // (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) +# if (__GNUC__ >= 7) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wimplicit-fallthrough" +# endif // (__GNUC__ >= 7) + #elif defined(__KCC) // Kai C++ diff --git a/src/third_party/asio-master/asio/include/asio/detail/socket_types.hpp b/src/third_party/asio-master/asio/include/asio/detail/socket_types.hpp index e97dfc13c69..6aab43326e5 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/socket_types.hpp +++ b/src/third_party/asio-master/asio/include/asio/detail/socket_types.hpp @@ -59,7 +59,8 @@ # include <sys/ioctl.h> # if (defined(__MACH__) && defined(__APPLE__)) \ || defined(__FreeBSD__) || defined(__NetBSD__) \ - || defined(__OpenBSD__) || defined(__linux__) + || defined(__OpenBSD__) || defined(__linux__) \ + || defined(__EMSCRIPTEN__) # include <poll.h> # elif !defined(__SYMBIAN32__) # include <sys/poll.h> diff --git a/src/third_party/asio-master/asio/include/asio/detail/thread_info_base.hpp b/src/third_party/asio-master/asio/include/asio/detail/thread_info_base.hpp index ce1b61c2f74..4ae8d927038 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/thread_info_base.hpp +++ b/src/third_party/asio-master/asio/include/asio/detail/thread_info_base.hpp @@ -41,13 +41,15 @@ public: static void* allocate(thread_info_base* this_thread, std::size_t size) { + std::size_t chunks = (size + chunk_size - 1) / chunk_size; + if (this_thread && this_thread->reusable_memory_) { void* const pointer = this_thread->reusable_memory_; this_thread->reusable_memory_ = 0; unsigned char* const mem = static_cast<unsigned char*>(pointer); - if (static_cast<std::size_t>(mem[0]) >= size) + if (static_cast<std::size_t>(mem[0]) >= chunks) { mem[size] = mem[0]; return pointer; @@ -56,16 +58,16 @@ public: ::operator delete(pointer); } - void* const pointer = ::operator new(size + 1); + void* const pointer = ::operator new(chunks * chunk_size + 1); unsigned char* const mem = static_cast<unsigned char*>(pointer); - mem[size] = (size <= UCHAR_MAX) ? static_cast<unsigned char>(size) : 0; + mem[size] = (chunks <= UCHAR_MAX) ? static_cast<unsigned char>(chunks) : 0; return pointer; } static void deallocate(thread_info_base* this_thread, void* pointer, std::size_t size) { - if (size <= UCHAR_MAX) + if (size <= chunk_size * UCHAR_MAX) { if (this_thread && this_thread->reusable_memory_ == 0) { @@ -80,6 +82,7 @@ public: } private: + enum { chunk_size = 4 }; void* reusable_memory_; }; diff --git a/src/third_party/asio-master/asio/include/asio/detail/wince_thread.hpp b/src/third_party/asio-master/asio/include/asio/detail/wince_thread.hpp index 18b5209106f..691050dfebc 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/wince_thread.hpp +++ b/src/third_party/asio-master/asio/include/asio/detail/wince_thread.hpp @@ -19,8 +19,8 @@ #if defined(ASIO_WINDOWS) && defined(UNDER_CE) -#include "asio/detail/memory.hpp" #include "asio/detail/noncopyable.hpp" +#include "asio/detail/scoped_ptr.hpp" #include "asio/detail/socket_types.hpp" #include "asio/detail/throw_error.hpp" #include "asio/error.hpp" @@ -40,7 +40,7 @@ public: template <typename Function> wince_thread(Function f, unsigned int = 0) { - std::auto_ptr<func_base> arg(new func<Function>(f)); + scoped_ptr<func_base> arg(new func<Function>(f)); DWORD thread_id = 0; thread_ = ::CreateThread(0, 0, wince_thread_function, arg.get(), 0, &thread_id); @@ -108,7 +108,7 @@ private: inline DWORD WINAPI wince_thread_function(LPVOID arg) { - std::auto_ptr<wince_thread::func_base> func( + scoped_ptr<wince_thread::func_base> func( static_cast<wince_thread::func_base*>(arg)); func->run(); return 0; diff --git a/src/third_party/asio-master/asio/include/asio/error_code.hpp b/src/third_party/asio-master/asio/include/asio/error_code.hpp index 73fbb742223..6a8d29c6113 100644 --- a/src/third_party/asio-master/asio/include/asio/error_code.hpp +++ b/src/third_party/asio-master/asio/include/asio/error_code.hpp @@ -101,6 +101,20 @@ public: *this = make_error_code(e); } + /// Clear the error value to the default. + void clear() + { + value_ = 0; + category_ = &system_category(); + } + + /// Assign a new error value. + void assign(int v, const error_category& c) + { + value_ = v; + category_ = &c; + } + /// Get the error value. int value() const { diff --git a/src/third_party/asio-master/asio/include/asio/generic/detail/impl/endpoint.ipp b/src/third_party/asio-master/asio/include/asio/generic/detail/impl/endpoint.ipp index cfdfbbffa22..112c1b2b68e 100644 --- a/src/third_party/asio-master/asio/include/asio/generic/detail/impl/endpoint.ipp +++ b/src/third_party/asio-master/asio/include/asio/generic/detail/impl/endpoint.ipp @@ -94,7 +94,8 @@ void endpoint::init(const void* sock_addr, using namespace std; // For memset and memcpy. memset(&data_.generic, 0, sizeof(asio::detail::sockaddr_storage_type)); - memcpy(&data_.generic, sock_addr, sock_addr_size); + if (sock_addr_size > 0) + memcpy(&data_.generic, sock_addr, sock_addr_size); size_ = sock_addr_size; protocol_ = sock_protocol; diff --git a/src/third_party/asio-master/asio/include/asio/impl/connect.hpp b/src/third_party/asio-master/asio/include/asio/impl/connect.hpp index b41f88427d1..73770a3eed9 100644 --- a/src/third_party/asio-master/asio/include/asio/impl/connect.hpp +++ b/src/third_party/asio-master/asio/include/asio/impl/connect.hpp @@ -41,6 +41,63 @@ namespace detail return true; } }; + + template <typename Protocol, typename Iterator> + inline typename Protocol::endpoint deref_connect_result( + Iterator iter, asio::error_code& ec) + { + return ec ? typename Protocol::endpoint() : *iter; + } + + template <typename T, typename Iterator> + struct legacy_connect_condition_helper : T + { + typedef char (*fallback_func_type)(...); + operator fallback_func_type() const; + }; + + template <typename R, typename Arg1, typename Arg2, typename Iterator> + struct legacy_connect_condition_helper<R (*)(Arg1, Arg2), Iterator> + { + R operator()(Arg1, Arg2) const; + char operator()(...) const; + }; + + template <typename T, typename Iterator> + struct is_legacy_connect_condition + { + static char asio_connect_condition_check(char); + static char (&asio_connect_condition_check(Iterator))[2]; + + static const bool value = + sizeof(asio_connect_condition_check( + (*static_cast<legacy_connect_condition_helper<T, Iterator>*>(0))( + *static_cast<const asio::error_code*>(0), + *static_cast<const Iterator*>(0)))) != 1; + }; + + template <typename ConnectCondition, typename Iterator> + inline Iterator call_connect_condition(ConnectCondition& connect_condition, + const asio::error_code& ec, Iterator next, Iterator end, + typename enable_if<is_legacy_connect_condition< + ConnectCondition, Iterator>::value>::type* = 0) + { + if (next != end) + return connect_condition(ec, next); + return end; + } + + template <typename ConnectCondition, typename Iterator> + inline Iterator call_connect_condition(ConnectCondition& connect_condition, + const asio::error_code& ec, Iterator next, Iterator end, + typename enable_if<!is_legacy_connect_condition< + ConnectCondition, Iterator>::value>::type* = 0) + { + for (;next != end; ++next) + if (connect_condition(ec, *next)) + return next; + return end; + } } template <typename Protocol ASIO_SVC_TPARAM, typename EndpointSequence> @@ -63,10 +120,9 @@ typename Protocol::endpoint connect( typename enable_if<is_endpoint_sequence< EndpointSequence>::value>::type*) { - typename EndpointSequence::iterator iter = connect( - s, endpoints.begin(), endpoints.end(), - detail::default_connect_condition(), ec); - return ec ? typename Protocol::endpoint() : *iter; + return detail::deref_connect_result<Protocol>( + connect(s, endpoints.begin(), endpoints.end(), + detail::default_connect_condition(), ec), ec); } #if !defined(ASIO_NO_DEPRECATED) @@ -130,9 +186,9 @@ typename Protocol::endpoint connect( typename enable_if<is_endpoint_sequence< EndpointSequence>::value>::type*) { - typename EndpointSequence::iterator iter = connect( - s, endpoints.begin(), endpoints.end(), connect_condition, ec); - return ec ? typename Protocol::endpoint() : *iter; + return detail::deref_connect_result<Protocol>( + connect(s, endpoints.begin(), endpoints.end(), + connect_condition, ec), ec); } #if !defined(ASIO_NO_DEPRECATED) @@ -180,13 +236,16 @@ Iterator connect(basic_socket<Protocol ASIO_SVC_TARG>& s, for (Iterator iter = begin; iter != end; ++iter) { - if (connect_condition(ec, iter)) + iter = (detail::call_connect_condition(connect_condition, ec, iter, end)); + if (iter != end) { s.close(ec); s.connect(*iter, ec); if (!ec) return iter; } + else + break; } if (!ec) @@ -208,11 +267,11 @@ namespace detail { } - template <typename Endpoint> - bool check_condition(const asio::error_code& ec, - const Endpoint& endpoint) + template <typename Iterator> + void check_condition(const asio::error_code& ec, + Iterator& iter, Iterator& end) { - return connect_condition_(ec, endpoint); + iter = detail::call_connect_condition(connect_condition_, ec, iter, end); } private: @@ -229,10 +288,9 @@ namespace detail { } - template <typename Endpoint> - bool check_condition(const asio::error_code&, const Endpoint&) + template <typename Iterator> + void check_condition(const asio::error_code&, Iterator&, Iterator&) { - return true; } }; @@ -279,18 +337,18 @@ namespace detail void operator()(asio::error_code ec, int start = 0) { - typename EndpointSequence::iterator iter = endpoints_.begin(); + typename EndpointSequence::const_iterator begin = endpoints_.begin(); + typename EndpointSequence::const_iterator iter = begin; std::advance(iter, index_); - typename EndpointSequence::iterator end = endpoints_.end(); + typename EndpointSequence::const_iterator end = endpoints_.end(); switch (start_ = start) { case 1: for (;;) { - for (; iter != end; ++iter, ++index_) - if (this->check_condition(ec, *iter)) - break; + this->check_condition(ec, iter, end); + index_ = std::distance(begin, iter); if (iter != end) { @@ -443,9 +501,7 @@ namespace detail case 1: for (;;) { - for (; iter_ != end_; ++iter_) - if (this->check_condition(ec, *iter_)) - break; + this->check_condition(ec, iter_, end_); if (iter_ != end_) { diff --git a/src/third_party/asio-master/asio/include/asio/impl/serial_port_base.ipp b/src/third_party/asio-master/asio/include/asio/impl/serial_port_base.ipp index 0ebba098fc7..bad1fe31165 100644 --- a/src/third_party/asio-master/asio/include/asio/impl/serial_port_base.ipp +++ b/src/third_party/asio-master/asio/include/asio/impl/serial_port_base.ipp @@ -113,7 +113,7 @@ ASIO_SYNC_OP_VOID serial_port_base::baud_rate::store( ec = asio::error::invalid_argument; ASIO_SYNC_OP_VOID_RETURN(ec); } -# if defined(_BSD_SOURCE) +# if defined(_BSD_SOURCE) || defined(_DEFAULT_SOURCE) ::cfsetspeed(&storage, baud); # else ::cfsetispeed(&storage, baud); @@ -249,7 +249,7 @@ ASIO_SYNC_OP_VOID serial_port_base::flow_control::store( { case none: storage.c_iflag &= ~(IXOFF | IXON); -# if defined(_BSD_SOURCE) +# if defined(_BSD_SOURCE) || defined(_DEFAULT_SOURCE) storage.c_cflag &= ~CRTSCTS; # elif defined(__QNXNTO__) storage.c_cflag &= ~(IHFLOW | OHFLOW); @@ -257,14 +257,14 @@ ASIO_SYNC_OP_VOID serial_port_base::flow_control::store( break; case software: storage.c_iflag |= IXOFF | IXON; -# if defined(_BSD_SOURCE) +# if defined(_BSD_SOURCE) || defined(_DEFAULT_SOURCE) storage.c_cflag &= ~CRTSCTS; # elif defined(__QNXNTO__) storage.c_cflag &= ~(IHFLOW | OHFLOW); # endif break; case hardware: -# if defined(_BSD_SOURCE) +# if defined(_BSD_SOURCE) || defined(_DEFAULT_SOURCE) storage.c_iflag &= ~(IXOFF | IXON); storage.c_cflag |= CRTSCTS; break; @@ -305,7 +305,7 @@ ASIO_SYNC_OP_VOID serial_port_base::flow_control::load( { value_ = software; } -# if defined(_BSD_SOURCE) +# if defined(_BSD_SOURCE) || defined(_DEFAULT_SOURCE) else if (storage.c_cflag & CRTSCTS) { value_ = hardware; diff --git a/src/third_party/asio-master/asio/include/asio/impl/system_context.hpp b/src/third_party/asio-master/asio/include/asio/impl/system_context.hpp new file mode 100644 index 00000000000..e7cce6e9202 --- /dev/null +++ b/src/third_party/asio-master/asio/include/asio/impl/system_context.hpp @@ -0,0 +1,34 @@ +// +// impl/system_context.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// 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) +// + +#ifndef ASIO_IMPL_SYSTEM_CONTEXT_HPP +#define ASIO_IMPL_SYSTEM_CONTEXT_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include "asio/system_executor.hpp" + +#include "asio/detail/push_options.hpp" + +namespace asio { + +inline system_context::executor_type +system_context::get_executor() ASIO_NOEXCEPT +{ + return system_executor(); +} + +} // namespace asio + +#include "asio/detail/pop_options.hpp" + +#endif // ASIO_IMPL_SYSTEM_CONTEXT_HPP diff --git a/src/third_party/asio-master/asio/include/asio/impl/use_future.hpp b/src/third_party/asio-master/asio/include/asio/impl/use_future.hpp index b743166543f..67b329d1849 100644 --- a/src/third_party/asio-master/asio/include/asio/impl/use_future.hpp +++ b/src/third_party/asio-master/asio/include/asio/impl/use_future.hpp @@ -543,6 +543,8 @@ template <typename Arg> class promise_handler_selector<void(std::exception_ptr, Arg)> : public promise_handler_ex_1<Arg> {}; +#if defined(ASIO_HAS_VARIADIC_TEMPLATES) + template <typename... Arg> class promise_handler_selector<void(Arg...)> : public promise_handler_n<std::tuple<Arg...> > {}; @@ -555,6 +557,32 @@ template <typename... Arg> class promise_handler_selector<void(std::exception_ptr, Arg...)> : public promise_handler_ex_n<std::tuple<Arg...> > {}; +#else // defined(ASIO_HAS_VARIADIC_TEMPLATES) + +#define ASIO_PRIVATE_PROMISE_SELECTOR_DEF(n) \ + template <typename Arg, ASIO_VARIADIC_TPARAMS(n)> \ + class promise_handler_selector< \ + void(Arg, ASIO_VARIADIC_TARGS(n))> \ + : public promise_handler_n< \ + std::tuple<Arg, ASIO_VARIADIC_TARGS(n)> > {}; \ + \ + template <typename Arg, ASIO_VARIADIC_TPARAMS(n)> \ + class promise_handler_selector< \ + void(asio::error_code, Arg, ASIO_VARIADIC_TARGS(n))> \ + : public promise_handler_ec_n< \ + std::tuple<Arg, ASIO_VARIADIC_TARGS(n)> > {}; \ + \ + template <typename Arg, ASIO_VARIADIC_TPARAMS(n)> \ + class promise_handler_selector< \ + void(std::exception_ptr, Arg, ASIO_VARIADIC_TARGS(n))> \ + : public promise_handler_ex_n< \ + std::tuple<Arg, ASIO_VARIADIC_TARGS(n)> > {}; \ + /**/ + ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_PROMISE_SELECTOR_DEF) +#undef ASIO_PRIVATE_PROMISE_SELECTOR_DEF + +#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) + // Completion handlers produced from the use_future completion token, when not // using use_future::operator(). template <typename Signature, typename Allocator> diff --git a/src/third_party/asio-master/asio/include/asio/io_context.hpp b/src/third_party/asio-master/asio/include/asio/io_context.hpp index 73212f197b5..6f1c0b47f26 100644 --- a/src/third_party/asio-master/asio/include/asio/io_context.hpp +++ b/src/third_party/asio-master/asio/include/asio/io_context.hpp @@ -118,6 +118,35 @@ namespace detail { * } * @endcode * + * @par Submitting arbitrary tasks to the io_context + * + * To submit functions to the io_context, use the @ref asio::dispatch, + * @ref asio::post or @ref asio::defer free functions. + * + * For example: + * + * @code void my_task() + * { + * ... + * } + * + * ... + * + * asio::io_context io_context; + * + * // Submit a function to the io_context. + * asio::post(io_context, my_task); + * + * // Submit a lambda object to the io_context. + * asio::post(io_context, + * []() + * { + * ... + * }); + * + * // Run the io_context until it runs out of work. + * io_context.run(); @endcode + * * @par Stopping the io_context from running out of work * * Some applications may need to prevent an io_context object's run() call from diff --git a/src/third_party/asio-master/asio/include/asio/ip/impl/network_v4.ipp b/src/third_party/asio-master/asio/include/asio/ip/impl/network_v4.ipp index 52eecdafcd9..58a6a340b2b 100644 --- a/src/third_party/asio-master/asio/include/asio/ip/impl/network_v4.ipp +++ b/src/third_party/asio-master/asio/include/asio/ip/impl/network_v4.ipp @@ -182,7 +182,14 @@ network_v4 make_network_v4(const std::string& str, if (ec) return network_v4(); - return network_v4(addr, std::atoi(str.substr(pos + 1).c_str())); + const int prefix_len = std::atoi(str.substr(pos + 1).c_str()); + if (prefix_len < 0 || prefix_len > 32) + { + ec = asio::error::invalid_argument; + return network_v4(); + } + + return network_v4(addr, static_cast<unsigned short>(prefix_len)); } #if defined(ASIO_HAS_STD_STRING_VIEW) diff --git a/src/third_party/asio-master/asio/include/asio/ip/impl/network_v6.ipp b/src/third_party/asio-master/asio/include/asio/ip/impl/network_v6.ipp index c4845c31a93..648af8a7f73 100644 --- a/src/third_party/asio-master/asio/include/asio/ip/impl/network_v6.ipp +++ b/src/third_party/asio-master/asio/include/asio/ip/impl/network_v6.ipp @@ -151,7 +151,14 @@ network_v6 make_network_v6(const std::string& str, if (ec) return network_v6(); - return network_v6(addr, std::atoi(str.substr(pos + 1).c_str())); + const int prefix_len = std::atoi(str.substr(pos + 1).c_str()); + if (prefix_len < 0 || prefix_len > 128) + { + ec = asio::error::invalid_argument; + return network_v6(); + } + + return network_v6(addr, static_cast<unsigned short>(prefix_len)); } #if defined(ASIO_HAS_STD_STRING_VIEW) diff --git a/src/third_party/asio-master/asio/include/asio/local/detail/impl/endpoint.ipp b/src/third_party/asio-master/asio/include/asio/local/detail/impl/endpoint.ipp index 5b06a5e8241..af02feada17 100644 --- a/src/third_party/asio-master/asio/include/asio/local/detail/impl/endpoint.ipp +++ b/src/third_party/asio-master/asio/include/asio/local/detail/impl/endpoint.ipp @@ -108,7 +108,8 @@ void endpoint::init(const char* path_name, std::size_t path_length) using namespace std; // For memcpy. data_.local = asio::detail::sockaddr_un_type(); data_.local.sun_family = AF_UNIX; - memcpy(data_.local.sun_path, path_name, path_length); + if (path_length > 0) + memcpy(data_.local.sun_path, path_name, path_length); path_length_ = path_length; // NUL-terminate normal path names. Names that start with a NUL are in the diff --git a/src/third_party/asio-master/asio/include/asio/read_until.hpp b/src/third_party/asio-master/asio/include/asio/read_until.hpp index 764e408fd5f..fd7d45a8385 100644 --- a/src/third_party/asio-master/asio/include/asio/read_until.hpp +++ b/src/third_party/asio-master/asio/include/asio/read_until.hpp @@ -584,8 +584,8 @@ std::size_t read_until(SyncReadStream& s, * contains the delimiter: * @code { 'a', 'b', ..., 'c', '\n', 'd', 'e', ... } @endcode * The call to @c std::getline then extracts the data up to and including the - * delimiter, so that the string @c line contains: - * @code { 'a', 'b', ..., 'c', '\n' } @endcode + * newline (which is discarded), so that the string @c line contains: + * @code { 'a', 'b', ..., 'c' } @endcode * The remaining data is left in the buffer @c b as follows: * @code { 'd', 'e', ... } @endcode * This data may be the start of a new line, to be extracted by a subsequent @@ -671,8 +671,8 @@ std::size_t read_until(SyncReadStream& s, * contains the delimiter: * @code { 'a', 'b', ..., 'c', '\r', '\n', 'd', 'e', ... } @endcode * The call to @c std::getline then extracts the data up to and including the - * delimiter, so that the string @c line contains: - * @code { 'a', 'b', ..., 'c', '\r', '\n' } @endcode + * newline (which is discarded), so that the string @c line contains: + * @code { 'a', 'b', ..., 'c', '\r' } @endcode * The remaining data is left in the buffer @c b as follows: * @code { 'd', 'e', ... } @endcode * This data may be the start of a new line, to be extracted by a subsequent @@ -764,8 +764,8 @@ std::size_t read_until(SyncReadStream& s, * contains the data which matched the regular expression: * @code { 'a', 'b', ..., 'c', '\r', '\n', 'd', 'e', ... } @endcode * The call to @c std::getline then extracts the data up to and including the - * match, so that the string @c line contains: - * @code { 'a', 'b', ..., 'c', '\r', '\n' } @endcode + * newline (which is discarded), so that the string @c line contains: + * @code { 'a', 'b', ..., 'c', '\r' } @endcode * The remaining data is left in the buffer @c b as follows: * @code { 'd', 'e', ... } @endcode * This data may be the start of a new line, to be extracted by a subsequent @@ -1483,8 +1483,8 @@ async_read_until(AsyncReadStream& s, * @c b contains the delimiter: * @code { 'a', 'b', ..., 'c', '\n', 'd', 'e', ... } @endcode * The call to @c std::getline then extracts the data up to and including the - * delimiter, so that the string @c line contains: - * @code { 'a', 'b', ..., 'c', '\n' } @endcode + * newline (which is discarded), so that the string @c line contains: + * @code { 'a', 'b', ..., 'c' } @endcode * The remaining data is left in the buffer @c b as follows: * @code { 'd', 'e', ... } @endcode * This data may be the start of a new line, to be extracted by a subsequent @@ -1568,8 +1568,8 @@ async_read_until(AsyncReadStream& s, * @c b contains the delimiter: * @code { 'a', 'b', ..., 'c', '\r', '\n', 'd', 'e', ... } @endcode * The call to @c std::getline then extracts the data up to and including the - * delimiter, so that the string @c line contains: - * @code { 'a', 'b', ..., 'c', '\r', '\n' } @endcode + * newline (which is discarded), so that the string @c line contains: + * @code { 'a', 'b', ..., 'c', '\r' } @endcode * The remaining data is left in the buffer @c b as follows: * @code { 'd', 'e', ... } @endcode * This data may be the start of a new line, to be extracted by a subsequent @@ -1661,8 +1661,8 @@ async_read_until(AsyncReadStream& s, * @c b contains the data which matched the regular expression: * @code { 'a', 'b', ..., 'c', '\r', '\n', 'd', 'e', ... } @endcode * The call to @c std::getline then extracts the data up to and including the - * match, so that the string @c line contains: - * @code { 'a', 'b', ..., 'c', '\r', '\n' } @endcode + * newline (which is discarded), so that the string @c line contains: + * @code { 'a', 'b', ..., 'c', '\r' } @endcode * The remaining data is left in the buffer @c b as follows: * @code { 'd', 'e', ... } @endcode * This data may be the start of a new line, to be extracted by a subsequent diff --git a/src/third_party/asio-master/asio/include/asio/ssl/detail/impl/engine.ipp b/src/third_party/asio-master/asio/include/asio/ssl/detail/impl/engine.ipp index 345461b13e0..ca0a1ffad8d 100644 --- a/src/third_party/asio-master/asio/include/asio/ssl/detail/impl/engine.ipp +++ b/src/third_party/asio-master/asio/include/asio/ssl/detail/impl/engine.ipp @@ -204,7 +204,7 @@ const asio::error_code& engine::map_error_code( // SSL v2 doesn't provide a protocol-level shutdown, so an eof on the // underlying transport is passed through. #if (OPENSSL_VERSION_NUMBER < 0x10100000L) - if (ssl_->version == SSL2_VERSION) + if (SSL_version(ssl_) == SSL2_VERSION) return ec; #endif // (OPENSSL_VERSION_NUMBER < 0x10100000L) diff --git a/src/third_party/asio-master/asio/include/asio/system_context.hpp b/src/third_party/asio-master/asio/include/asio/system_context.hpp index 6c833e2b18f..5762fca8cd4 100644 --- a/src/third_party/asio-master/asio/include/asio/system_context.hpp +++ b/src/third_party/asio-master/asio/include/asio/system_context.hpp @@ -19,12 +19,13 @@ #include "asio/detail/scheduler.hpp" #include "asio/detail/thread_group.hpp" #include "asio/execution_context.hpp" -#include "asio/system_executor.hpp" #include "asio/detail/push_options.hpp" namespace asio { +class system_executor; + /// The executor context for the system executor. class system_context : public execution_context { @@ -36,10 +37,7 @@ public: ASIO_DECL ~system_context(); /// Obtain an executor for the context. - executor_type get_executor() ASIO_NOEXCEPT - { - return system_executor(); - } + executor_type get_executor() ASIO_NOEXCEPT; /// Signal all threads in the system thread pool to stop. ASIO_DECL void stop(); @@ -72,6 +70,7 @@ private: #include "asio/detail/pop_options.hpp" +#include "asio/impl/system_context.hpp" #if defined(ASIO_HEADER_ONLY) # include "asio/impl/system_context.ipp" #endif // defined(ASIO_HEADER_ONLY) diff --git a/src/third_party/asio-master/asio/include/asio/thread_pool.hpp b/src/third_party/asio-master/asio/include/asio/thread_pool.hpp index ae915b3ec72..f12126a8010 100644 --- a/src/third_party/asio-master/asio/include/asio/thread_pool.hpp +++ b/src/third_party/asio-master/asio/include/asio/thread_pool.hpp @@ -29,6 +29,36 @@ namespace asio { /** * The thread pool class is an execution context where functions are permitted * to run on one of a fixed number of threads. + * + * @par Submitting tasks to the pool + * + * To submit functions to the io_context, use the @ref asio::dispatch, + * @ref asio::post or @ref asio::defer free functions. + * + * For example: + * + * @code void my_task() + * { + * ... + * } + * + * ... + * + * // Launch the pool with four threads. + * asio::thread_pool pool(4); + * + * // Submit a function to the pool. + * asio::post(pool, my_task); + * + * // Submit a lambda object to the pool. + * asio::post(pool, + * []() + * { + * ... + * }); + * + * // Wait for all tasks in the pool to complete. + * pool.join(); @endcode */ class thread_pool : public execution_context diff --git a/src/third_party/asio-master/asio/include/asio/ts/timer.hpp b/src/third_party/asio-master/asio/include/asio/ts/timer.hpp index c760efca0e1..487422e7f9e 100644 --- a/src/third_party/asio-master/asio/include/asio/ts/timer.hpp +++ b/src/third_party/asio-master/asio/include/asio/ts/timer.hpp @@ -15,7 +15,7 @@ # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) -#include <chrono> +#include "asio/detail/chrono.hpp" #include "asio/wait_traits.hpp" #include "asio/basic_waitable_timer.hpp" diff --git a/src/third_party/asio-master/asio/include/asio/use_future.hpp b/src/third_party/asio-master/asio/include/asio/use_future.hpp index b1d65b3c28a..42e33e43beb 100644 --- a/src/third_party/asio-master/asio/include/asio/use_future.hpp +++ b/src/third_party/asio-master/asio/include/asio/use_future.hpp @@ -118,17 +118,33 @@ public: operator()(ASIO_MOVE_ARG(Function) f) const; private: - Allocator allocator_; + // Helper type to ensure that use_future can be constexpr default-constructed + // even when std::allocator<void> can't be. + struct std_allocator_void + { + ASIO_CONSTEXPR std_allocator_void() + { + } + + operator std::allocator<void>() const + { + return std::allocator<void>(); + } + }; + + typename conditional< + is_same<std::allocator<void>, Allocator>::value, + std_allocator_void, Allocator>::type allocator_; }; /// A special value, similar to std::nothrow. /** * See the documentation for asio::use_future_t for a usage example. */ -#if defined(ASIO_MSVC) -__declspec(selectany) use_future_t<> use_future; -#elif defined(ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION) +#if defined(ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION) constexpr use_future_t<> use_future; +#elif defined(ASIO_MSVC) +__declspec(selectany) use_future_t<> use_future; #endif } // namespace asio |