Skip to content

Commit

Permalink
Update vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Jul 5, 2023
1 parent 5926b9a commit f2a0901
Show file tree
Hide file tree
Showing 50 changed files with 796 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ class async_result<detail::async_operation_probe, Sig0, Sig1, Sig2>
#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
#endif // !defined(GENERATING_DOCUMENTATION)

#if defined(GENERATION_DOCUMENTATION)
#if defined(GENERATING_DOCUMENTATION)

/// The is_async_operation trait detects whether a type @c T and arguments
/// @c Args... may be used to initiate an asynchronous operation.
Expand Down Expand Up @@ -1349,7 +1349,10 @@ struct is_async_operation :
template <typename T, typename = void, typename = void, typename = void,
typename = void, typename = void, typename = void, typename = void,
typename = void, typename = void>
struct is_async_operation :
struct is_async_operation;

template <typename T>
struct is_async_operation<T> :
detail::is_async_operation_call<
T(detail::async_operation_probe)>
{
Expand Down Expand Up @@ -1574,7 +1577,10 @@ using completion_signature_of_t =
template <typename T, typename = void, typename = void, typename = void,
typename = void, typename = void, typename = void, typename = void,
typename = void, typename = void>
struct completion_signature_of :
struct completion_signature_of;

template <typename T>
struct completion_signature_of<T> :
result_of<T(detail::completion_signature_probe)>::type
{
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1924,8 +1924,10 @@ class basic_socket_acceptor
template <typename Executor1,
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
typename Protocol::socket::template rebind_executor<
Executor1>::other)) MoveAcceptToken
ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
typename constraint<is_executor<Executor1>::value
|| execution::is_executor<Executor1>::value,
Executor1>::type>::other)) MoveAcceptToken
ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(MoveAcceptToken,
void (asio::error_code,
typename Protocol::socket::template rebind_executor<
Expand Down Expand Up @@ -2486,8 +2488,10 @@ class basic_socket_acceptor
template <typename Executor1,
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
typename Protocol::socket::template rebind_executor<
Executor1>::other)) MoveAcceptToken
ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
typename constraint<is_executor<Executor1>::value
|| execution::is_executor<Executor1>::value,
Executor1>::type>::other)) MoveAcceptToken
ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(MoveAcceptToken,
void (asio::error_code,
typename Protocol::socket::template rebind_executor<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,25 @@ class buffer_debug_check
* bufs2.push_back(asio::buffer(d2));
* bufs2.push_back(asio::buffer(d3));
* bytes_transferred = sock.send(bufs2); @endcode
*
* @par Buffer Literals
*
* The `_buf` literal suffix, defined in namespace
* <tt>asio::buffer_literals</tt>, may be used to create @c const_buffer
* objects from string, binary integer, and hexadecimal integer literals.
* For example:
*
* @code
* using namespace asio::buffer_literals;
*
* asio::const_buffer b1 = "hello"_buf;
* asio::const_buffer b2 = 0xdeadbeef_buf;
* asio::const_buffer b3 = 0x0123456789abcdef0123456789abcdef_buf;
* asio::const_buffer b4 = 0b1010101011001100_buf; @endcode
*
* Note that the memory associated with a buffer literal is valid for the
* lifetime of the program. This means that the buffer can be safely used with
* asynchronous operations.
*/
/*@{*/

Expand Down Expand Up @@ -1567,6 +1586,14 @@ ASIO_NODISCARD inline ASIO_MUTABLE_BUFFER buffer(
is_contiguous_iterator<typename T::iterator>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
!is_convertible<T, const_buffer>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
!is_convertible<T, mutable_buffer>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
!is_const<
typename remove_reference<
Expand Down Expand Up @@ -1597,6 +1624,14 @@ ASIO_NODISCARD inline ASIO_MUTABLE_BUFFER buffer(
is_contiguous_iterator<typename T::iterator>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
!is_convertible<T, const_buffer>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
!is_convertible<T, mutable_buffer>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
!is_const<
typename remove_reference<
Expand Down Expand Up @@ -1626,6 +1661,14 @@ ASIO_NODISCARD inline ASIO_CONST_BUFFER buffer(
is_contiguous_iterator<typename T::iterator>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
!is_convertible<T, const_buffer>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
!is_convertible<T, mutable_buffer>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
is_const<
typename remove_reference<
Expand Down Expand Up @@ -1656,6 +1699,14 @@ ASIO_NODISCARD inline ASIO_CONST_BUFFER buffer(
is_contiguous_iterator<typename T::iterator>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
!is_convertible<T, const_buffer>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
!is_convertible<T, mutable_buffer>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
is_const<
typename remove_reference<
Expand Down Expand Up @@ -1684,6 +1735,14 @@ ASIO_NODISCARD inline ASIO_CONST_BUFFER buffer(
typename constraint<
is_contiguous_iterator<typename T::const_iterator>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
!is_convertible<T, const_buffer>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
!is_convertible<T, mutable_buffer>::value,
defaulted_constraint
>::type = defaulted_constraint()) ASIO_NOEXCEPT
{
return ASIO_CONST_BUFFER(
Expand All @@ -1706,6 +1765,14 @@ ASIO_NODISCARD inline ASIO_CONST_BUFFER buffer(
typename constraint<
is_contiguous_iterator<typename T::const_iterator>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
!is_convertible<T, const_buffer>::value,
defaulted_constraint
>::type = defaulted_constraint(),
typename constraint<
!is_convertible<T, mutable_buffer>::value,
defaulted_constraint
>::type = defaulted_constraint()) ASIO_NOEXCEPT
{
return ASIO_CONST_BUFFER(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,17 @@ class buffered_read_stream

/// Construct, passing the specified argument to initialise the next layer.
template <typename Arg>
explicit buffered_read_stream(Arg& a)
: next_layer_(a),
explicit buffered_read_stream(ASIO_MOVE_OR_LVALUE_ARG(Arg) a)
: next_layer_(ASIO_MOVE_OR_LVALUE(Arg)(a)),
storage_(default_buffer_size)
{
}

/// Construct, passing the specified argument to initialise the next layer.
template <typename Arg>
buffered_read_stream(Arg& a, std::size_t buffer_size)
: next_layer_(a),
buffered_read_stream(ASIO_MOVE_OR_LVALUE_ARG(Arg) a,
std::size_t buffer_size)
: next_layer_(ASIO_MOVE_OR_LVALUE(Arg)(a)),
storage_(buffer_size)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ class buffered_stream

/// Construct, passing the specified argument to initialise the next layer.
template <typename Arg>
explicit buffered_stream(Arg& a)
: inner_stream_impl_(a),
explicit buffered_stream(ASIO_MOVE_OR_LVALUE_ARG(Arg) a)
: inner_stream_impl_(ASIO_MOVE_OR_LVALUE(Arg)(a)),
stream_impl_(inner_stream_impl_)
{
}

/// Construct, passing the specified argument to initialise the next layer.
template <typename Arg>
explicit buffered_stream(Arg& a, std::size_t read_buffer_size,
std::size_t write_buffer_size)
: inner_stream_impl_(a, write_buffer_size),
explicit buffered_stream(ASIO_MOVE_OR_LVALUE_ARG(Arg) a,
std::size_t read_buffer_size, std::size_t write_buffer_size)
: inner_stream_impl_(ASIO_MOVE_OR_LVALUE(Arg)(a), write_buffer_size),
stream_impl_(inner_stream_impl_, read_buffer_size)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,17 @@ class buffered_write_stream

/// Construct, passing the specified argument to initialise the next layer.
template <typename Arg>
explicit buffered_write_stream(Arg& a)
: next_layer_(a),
explicit buffered_write_stream(ASIO_MOVE_OR_LVALUE_ARG(Arg) a)
: next_layer_(ASIO_MOVE_OR_LVALUE(Arg)(a)),
storage_(default_buffer_size)
{
}

/// Construct, passing the specified argument to initialise the next layer.
template <typename Arg>
buffered_write_stream(Arg& a, std::size_t buffer_size)
: next_layer_(a),
buffered_write_stream(ASIO_MOVE_OR_LVALUE_ARG(Arg) a,
std::size_t buffer_size)
: next_layer_(ASIO_MOVE_OR_LVALUE(Arg)(a)),
storage_(buffer_size)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
# define ASIO_MOVE_CAST(type) static_cast<type&&>
# define ASIO_MOVE_CAST2(type1, type2) static_cast<type1, type2&&>
# define ASIO_MOVE_OR_LVALUE(type) static_cast<type&&>
# define ASIO_MOVE_OR_LVALUE_ARG(type) type&&
# define ASIO_MOVE_OR_LVALUE_TYPE(type) type
#endif // defined(ASIO_HAS_MOVE) && !defined(ASIO_MOVE_CAST)

Expand Down Expand Up @@ -188,6 +189,7 @@
# define ASIO_MOVE_CAST(type) static_cast<const type&>
# define ASIO_MOVE_CAST2(type1, type2) static_cast<const type1, type2&>
# define ASIO_MOVE_OR_LVALUE(type)
# define ASIO_MOVE_OR_LVALUE_ARG(type) type&
# define ASIO_MOVE_OR_LVALUE_TYPE(type) type&
#endif // !defined(ASIO_MOVE_CAST)

Expand Down Expand Up @@ -2150,10 +2152,12 @@
# define ASIO_ASSUME(expr) __builtin_assume(expr)
# endif // __has_builtin(__builtin_assume)
#elif defined(__GNUC__)
# define ASIO_ASSUME(expr) if (expr) {} else { __builtin_unreachable(); }
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# define ASIO_ASSUME(expr) if (expr) {} else { __builtin_unreachable(); }
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
#endif // defined(__GNUC__)
#if !defined(ASIO_ASSUME)
# define ASIO_ASSUME (void)0
# define ASIO_ASSUME(expr) (void)0
#endif // !defined(ASIO_ASSUME)

// Support the co_await keyword on compilers known to allow it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ bool set_internal_non_blocking(int d, state_type& state,
# if defined(ENOTTY)
if (ec.value() == ENOTTY)
{
int result = ::fcntl(d, F_GETFL, 0);
result = ::fcntl(d, F_GETFL, 0);
get_last_error(ec, result < 0);
if (result >= 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,21 @@ void io_uring_service::deregister_io_object(
if (!io_obj->shutdown_)
{
op_queue<operation> ops;
do_cancel_ops(io_obj, ops);
bool pending_cancelled_ops = do_cancel_ops(io_obj, ops);
io_obj->shutdown_ = true;
io_object_lock.unlock();
scheduler_.post_deferred_completions(ops);

// Leave io_obj set so that it will be freed by the subsequent
// call to cleanup_io_obj.
if (pending_cancelled_ops)
{
// There are still pending operations. Prevent cleanup_io_object from
// freeing the I/O object and let the last operation to complete free it.
io_obj = 0;
}
else
{
// Leave io_obj set so that it will be freed by the subsequent call to
// cleanup_io_object.
}
}
else
{
Expand Down Expand Up @@ -610,7 +618,7 @@ void io_uring_service::free_io_object(io_uring_service::io_object* io_obj)
registered_io_objects_.free(io_obj);
}

void io_uring_service::do_cancel_ops(
bool io_uring_service::do_cancel_ops(
per_io_object_data& io_obj, op_queue<operation>& ops)
{
bool cancel_op = false;
Expand Down Expand Up @@ -646,6 +654,8 @@ void io_uring_service::do_cancel_ops(
}
submit_sqes();
}

return cancel_op;
}

void io_uring_service::do_add_timer_queue(timer_queue_base& queue)
Expand Down Expand Up @@ -760,12 +770,18 @@ io_uring_service::io_queue::io_queue()
struct io_uring_service::perform_io_cleanup_on_block_exit
{
explicit perform_io_cleanup_on_block_exit(io_uring_service* s)
: service_(s), first_op_(0)
: service_(s), io_object_to_free_(0), first_op_(0)
{
}

~perform_io_cleanup_on_block_exit()
{
if (io_object_to_free_)
{
mutex::scoped_lock lock(service_->mutex_);
service_->free_io_object(io_object_to_free_);
}

if (first_op_)
{
// Post the remaining completed operations for invocation.
Expand All @@ -786,6 +802,7 @@ struct io_uring_service::perform_io_cleanup_on_block_exit
}

io_uring_service* service_;
io_object* io_object_to_free_;
op_queue<operation> ops_;
operation* first_op_;
};
Expand Down Expand Up @@ -847,6 +864,15 @@ operation* io_uring_service::io_queue::perform_io(int result)
}
}

// The last operation to complete on a shut down object must free it.
if (io_object_->shutdown_)
{
io_cleanup.io_object_to_free_ = io_object_;
for (int i = 0; i < max_ops; ++i)
if (!io_object_->queues_[i].op_queue_.empty())
io_cleanup.io_object_to_free_ = 0;
}

// The first operation will be returned for completion now. The others will
// be posted for later by the io_cleanup object's destructor.
io_cleanup.first_op_ = io_cleanup.ops_.front();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ uint64_t win_iocp_file_service::seek(
method = FILE_BEGIN;
break;
case file_base::seek_cur:
method = FILE_CURRENT;
method = FILE_BEGIN;
offset = static_cast<int64_t>(impl.offset_) + offset;
break;
case file_base::seek_end:
method = FILE_END;
Expand Down
Loading

0 comments on commit f2a0901

Please sign in to comment.