Deprecate error_code returns on synchronous operations.
diff --git a/asio/include/asio/basic_serial_port.hpp b/asio/include/asio/basic_serial_port.hpp
index 994fc82..b6ac51e 100644
--- a/asio/include/asio/basic_serial_port.hpp
+++ b/asio/include/asio/basic_serial_port.hpp
@@ -217,10 +217,11 @@
    *
    * @param ec Set the indicate what error occurred, if any.
    */
-  asio::error_code open(const std::string& device,
+  ASIO_SYNC_OP_VOID open(const std::string& device,
       asio::error_code& ec)
   {
-    return this->get_service().open(this->get_implementation(), device, ec);
+    this->get_service().open(this->get_implementation(), device, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Assign an existing native serial port to the serial port.
@@ -247,11 +248,12 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code assign(const native_handle_type& native_serial_port,
+  ASIO_SYNC_OP_VOID assign(const native_handle_type& native_serial_port,
       asio::error_code& ec)
   {
-    return this->get_service().assign(this->get_implementation(),
+    this->get_service().assign(this->get_implementation(),
         native_serial_port, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the serial port is open.
@@ -283,9 +285,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code close(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID close(asio::error_code& ec)
   {
-    return this->get_service().close(this->get_implementation(), ec);
+    this->get_service().close(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native serial port representation.
@@ -322,9 +325,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code cancel(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
   {
-    return this->get_service().cancel(this->get_implementation(), ec);
+    this->get_service().cancel(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Send a break sequence to the serial port.
@@ -348,9 +352,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code send_break(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID send_break(asio::error_code& ec)
   {
-    return this->get_service().send_break(this->get_implementation(), ec);
+    this->get_service().send_break(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Set an option on the serial port.
@@ -392,11 +397,11 @@
    * asio::serial_port_base::character_size
    */
   template <typename SettableSerialPortOption>
-  asio::error_code set_option(const SettableSerialPortOption& option,
+  ASIO_SYNC_OP_VOID set_option(const SettableSerialPortOption& option,
       asio::error_code& ec)
   {
-    return this->get_service().set_option(
-        this->get_implementation(), option, ec);
+    this->get_service().set_option(this->get_implementation(), option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get an option from the serial port.
@@ -440,11 +445,11 @@
    * asio::serial_port_base::character_size
    */
   template <typename GettableSerialPortOption>
-  asio::error_code get_option(GettableSerialPortOption& option,
+  ASIO_SYNC_OP_VOID get_option(GettableSerialPortOption& option,
       asio::error_code& ec)
   {
-    return this->get_service().get_option(
-        this->get_implementation(), option, ec);
+    this->get_service().get_option(this->get_implementation(), option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Write some data to the serial port.
diff --git a/asio/include/asio/basic_signal_set.hpp b/asio/include/asio/basic_signal_set.hpp
index a8516bf..6f1d07e 100644
--- a/asio/include/asio/basic_signal_set.hpp
+++ b/asio/include/asio/basic_signal_set.hpp
@@ -213,11 +213,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code add(int signal_number,
-      asio::error_code& ec)
+  ASIO_SYNC_OP_VOID add(int signal_number, asio::error_code& ec)
   {
-    return this->get_service().add(
-        this->get_implementation(), signal_number, ec);
+    this->get_service().add(this->get_implementation(), signal_number, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Remove a signal from a signal_set.
@@ -251,11 +250,11 @@
    * @note Removes any notifications that have been queued for the specified
    * signal number.
    */
-  asio::error_code remove(int signal_number,
+  ASIO_SYNC_OP_VOID remove(int signal_number,
       asio::error_code& ec)
   {
-    return this->get_service().remove(
-        this->get_implementation(), signal_number, ec);
+    this->get_service().remove(this->get_implementation(), signal_number, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Remove all signals from a signal_set.
@@ -283,9 +282,10 @@
    *
    * @note Removes all queued notifications.
    */
-  asio::error_code clear(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID clear(asio::error_code& ec)
   {
-    return this->get_service().clear(this->get_implementation(), ec);
+    this->get_service().clear(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Cancel all operations associated with the signal set.
@@ -337,9 +337,10 @@
    * These handlers can no longer be cancelled, and therefore are passed an
    * error code that indicates the successful completion of the wait operation.
    */
-  asio::error_code cancel(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
   {
-    return this->get_service().cancel(this->get_implementation(), ec);
+    this->get_service().cancel(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Start an asynchronous operation to wait for a signal to be delivered.
diff --git a/asio/include/asio/basic_socket.hpp b/asio/include/asio/basic_socket.hpp
index b6f6f6f..eea5586 100644
--- a/asio/include/asio/basic_socket.hpp
+++ b/asio/include/asio/basic_socket.hpp
@@ -350,10 +350,11 @@
    * }
    * @endcode
    */
-  asio::error_code open(const protocol_type& protocol,
+  ASIO_SYNC_OP_VOID open(const protocol_type& protocol,
       asio::error_code& ec)
   {
-    return this->get_service().open(this->get_implementation(), protocol, ec);
+    this->get_service().open(this->get_implementation(), protocol, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Assign an existing native socket to the socket.
@@ -385,11 +386,12 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code assign(const protocol_type& protocol,
+  ASIO_SYNC_OP_VOID assign(const protocol_type& protocol,
       const native_handle_type& native_socket, asio::error_code& ec)
   {
-    return this->get_service().assign(this->get_implementation(),
+    this->get_service().assign(this->get_implementation(),
         protocol, native_socket, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the socket is open.
@@ -441,9 +443,10 @@
    * @note For portable behaviour with respect to graceful closure of a
    * connected socket, call shutdown() before closing the socket.
    */
-  asio::error_code close(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID close(asio::error_code& ec)
   {
-    return this->get_service().close(this->get_implementation(), ec);
+    this->get_service().close(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native socket representation.
@@ -546,9 +549,10 @@
         "operation_not_supported when used on Windows XP, Windows Server 2003, "
         "or earlier. Consult documentation for details."))
 #endif
-  asio::error_code cancel(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
   {
-    return this->get_service().cancel(this->get_implementation(), ec);
+    this->get_service().cancel(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the socket is at the out-of-band data mark.
@@ -666,10 +670,11 @@
    * }
    * @endcode
    */
-  asio::error_code bind(const endpoint_type& endpoint,
+  ASIO_SYNC_OP_VOID bind(const endpoint_type& endpoint,
       asio::error_code& ec)
   {
-    return this->get_service().bind(this->get_implementation(), endpoint, ec);
+    this->get_service().bind(this->get_implementation(), endpoint, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Connect the socket to the specified endpoint.
@@ -736,20 +741,21 @@
    * }
    * @endcode
    */
-  asio::error_code connect(const endpoint_type& peer_endpoint,
+  ASIO_SYNC_OP_VOID connect(const endpoint_type& peer_endpoint,
       asio::error_code& ec)
   {
     if (!is_open())
     {
-      if (this->get_service().open(this->get_implementation(),
-            peer_endpoint.protocol(), ec))
+      this->get_service().open(this->get_implementation(),
+            peer_endpoint.protocol(), ec);
+      if (ec)
       {
-        return ec;
+        ASIO_SYNC_OP_VOID_RETURN(ec);
       }
     }
 
-    return this->get_service().connect(
-        this->get_implementation(), peer_endpoint, ec);
+    this->get_service().connect(this->get_implementation(), peer_endpoint, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Start an asynchronous connect.
@@ -807,7 +813,8 @@
     {
       asio::error_code ec;
       const protocol_type protocol = peer_endpoint.protocol();
-      if (this->get_service().open(this->get_implementation(), protocol, ec))
+      this->get_service().open(this->get_implementation(), protocol, ec);
+      if (ec)
       {
         async_completion<ConnectHandler,
           void (asio::error_code)> init(handler);
@@ -918,11 +925,11 @@
    * @endcode
    */
   template <typename SettableSocketOption>
-  asio::error_code set_option(const SettableSocketOption& option,
+  ASIO_SYNC_OP_VOID set_option(const SettableSocketOption& option,
       asio::error_code& ec)
   {
-    return this->get_service().set_option(
-        this->get_implementation(), option, ec);
+    this->get_service().set_option(this->get_implementation(), option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get an option from the socket.
@@ -1009,11 +1016,11 @@
    * @endcode
    */
   template <typename GettableSocketOption>
-  asio::error_code get_option(GettableSocketOption& option,
+  ASIO_SYNC_OP_VOID get_option(GettableSocketOption& option,
       asio::error_code& ec) const
   {
-    return this->get_service().get_option(
-        this->get_implementation(), option, ec);
+    this->get_service().get_option(this->get_implementation(), option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Perform an IO control command on the socket.
@@ -1074,11 +1081,11 @@
    * @endcode
    */
   template <typename IoControlCommand>
-  asio::error_code io_control(IoControlCommand& command,
+  ASIO_SYNC_OP_VOID io_control(IoControlCommand& command,
       asio::error_code& ec)
   {
-    return this->get_service().io_control(
-        this->get_implementation(), command, ec);
+    this->get_service().io_control(this->get_implementation(), command, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the socket.
@@ -1130,11 +1137,11 @@
    * operations. Asynchronous operations will never fail with the error
    * asio::error::would_block.
    */
-  asio::error_code non_blocking(
+  ASIO_SYNC_OP_VOID non_blocking(
       bool mode, asio::error_code& ec)
   {
-    return this->get_service().non_blocking(
-        this->get_implementation(), mode, ec);
+    this->get_service().non_blocking(this->get_implementation(), mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the native socket implementation.
@@ -1404,11 +1411,12 @@
    *   sock.async_wait(tcp::socket::wait_write, op);
    * } @endcode
    */
-  asio::error_code native_non_blocking(
+  ASIO_SYNC_OP_VOID native_non_blocking(
       bool mode, asio::error_code& ec)
   {
-    return this->get_service().native_non_blocking(
+    this->get_service().native_non_blocking(
         this->get_implementation(), mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the local endpoint of the socket.
@@ -1557,10 +1565,11 @@
    * }
    * @endcode
    */
-  asio::error_code shutdown(shutdown_type what,
+  ASIO_SYNC_OP_VOID shutdown(shutdown_type what,
       asio::error_code& ec)
   {
-    return this->get_service().shutdown(this->get_implementation(), what, ec);
+    this->get_service().shutdown(this->get_implementation(), what, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Wait for the socket to become ready to read, ready to write, or to have
@@ -1605,9 +1614,10 @@
    * socket.wait(asio::ip::tcp::socket::wait_read, ec);
    * @endcode
    */
-  asio::error_code wait(wait_type w, asio::error_code& ec)
+  ASIO_SYNC_OP_VOID wait(wait_type w, asio::error_code& ec)
   {
-    return this->get_service().wait(this->get_implementation(), w, ec);
+    this->get_service().wait(this->get_implementation(), w, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Asynchronously wait for the socket to become ready to read, ready to
diff --git a/asio/include/asio/basic_socket_acceptor.hpp b/asio/include/asio/basic_socket_acceptor.hpp
index d1ace2f..0c7f142 100644
--- a/asio/include/asio/basic_socket_acceptor.hpp
+++ b/asio/include/asio/basic_socket_acceptor.hpp
@@ -370,10 +370,11 @@
    * }
    * @endcode
    */
-  asio::error_code open(const protocol_type& protocol,
+  ASIO_SYNC_OP_VOID open(const protocol_type& protocol,
       asio::error_code& ec)
   {
-    return this->get_service().open(this->get_implementation(), protocol, ec);
+    this->get_service().open(this->get_implementation(), protocol, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Assigns an existing native acceptor to the acceptor.
@@ -405,11 +406,12 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code assign(const protocol_type& protocol,
+  ASIO_SYNC_OP_VOID assign(const protocol_type& protocol,
       const native_handle_type& native_acceptor, asio::error_code& ec)
   {
-    return this->get_service().assign(this->get_implementation(),
+    this->get_service().assign(this->get_implementation(),
         protocol, native_acceptor, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the acceptor is open.
@@ -466,10 +468,11 @@
    * }
    * @endcode
    */
-  asio::error_code bind(const endpoint_type& endpoint,
+  ASIO_SYNC_OP_VOID bind(const endpoint_type& endpoint,
       asio::error_code& ec)
   {
-    return this->get_service().bind(this->get_implementation(), endpoint, ec);
+    this->get_service().bind(this->get_implementation(), endpoint, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Place the acceptor into the state where it will listen for new
@@ -511,9 +514,10 @@
    * }
    * @endcode
    */
-  asio::error_code listen(int backlog, asio::error_code& ec)
+  ASIO_SYNC_OP_VOID listen(int backlog, asio::error_code& ec)
   {
-    return this->get_service().listen(this->get_implementation(), backlog, ec);
+    this->get_service().listen(this->get_implementation(), backlog, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Close the acceptor.
@@ -555,9 +559,10 @@
    * }
    * @endcode
    */
-  asio::error_code close(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID close(asio::error_code& ec)
   {
-    return this->get_service().close(this->get_implementation(), ec);
+    this->get_service().close(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native acceptor representation.
@@ -594,9 +599,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code cancel(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
   {
-    return this->get_service().cancel(this->get_implementation(), ec);
+    this->get_service().cancel(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Set an option on the acceptor.
@@ -655,11 +661,11 @@
    * @endcode
    */
   template <typename SettableSocketOption>
-  asio::error_code set_option(const SettableSocketOption& option,
+  ASIO_SYNC_OP_VOID set_option(const SettableSocketOption& option,
       asio::error_code& ec)
   {
-    return this->get_service().set_option(
-        this->get_implementation(), option, ec);
+    this->get_service().set_option(this->get_implementation(), option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get an option from the acceptor.
@@ -720,11 +726,11 @@
    * @endcode
    */
   template <typename GettableSocketOption>
-  asio::error_code get_option(GettableSocketOption& option,
+  ASIO_SYNC_OP_VOID get_option(GettableSocketOption& option,
       asio::error_code& ec)
   {
-    return this->get_service().get_option(
-        this->get_implementation(), option, ec);
+    this->get_service().get_option(this->get_implementation(), option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Perform an IO control command on the acceptor.
@@ -781,11 +787,11 @@
    * @endcode
    */
   template <typename IoControlCommand>
-  asio::error_code io_control(IoControlCommand& command,
+  ASIO_SYNC_OP_VOID io_control(IoControlCommand& command,
       asio::error_code& ec)
   {
-    return this->get_service().io_control(
-        this->get_implementation(), command, ec);
+    this->get_service().io_control(this->get_implementation(), command, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the acceptor.
@@ -837,11 +843,11 @@
    * operations. Asynchronous operations will never fail with the error
    * asio::error::would_block.
    */
-  asio::error_code non_blocking(
+  ASIO_SYNC_OP_VOID non_blocking(
       bool mode, asio::error_code& ec)
   {
-    return this->get_service().non_blocking(
-        this->get_implementation(), mode, ec);
+    this->get_service().non_blocking(this->get_implementation(), mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the native acceptor implementation.
@@ -901,11 +907,12 @@
    * function fails with asio::error::invalid_argument, as the
    * combination does not make sense.
    */
-  asio::error_code native_non_blocking(
+  ASIO_SYNC_OP_VOID native_non_blocking(
       bool mode, asio::error_code& ec)
   {
-    return this->get_service().native_non_blocking(
+    this->get_service().native_non_blocking(
         this->get_implementation(), mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the local endpoint of the acceptor.
@@ -1001,9 +1008,10 @@
    * acceptor.wait(asio::ip::tcp::acceptor::wait_read, ec);
    * @endcode
    */
-  asio::error_code wait(wait_type w, asio::error_code& ec)
+  ASIO_SYNC_OP_VOID wait(wait_type w, asio::error_code& ec)
   {
-    return this->get_service().wait(this->get_implementation(), w, ec);
+    this->get_service().wait(this->get_implementation(), w, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Asynchronously wait for the acceptor to become ready to read, ready to
@@ -1127,19 +1135,20 @@
    */
 #if defined(ASIO_ENABLE_OLD_SERVICES)
   template <typename Protocol1, typename SocketService>
-  asio::error_code accept(
+  ASIO_SYNC_OP_VOID accept(
       basic_socket<Protocol1, SocketService>& peer,
       asio::error_code& ec,
       typename enable_if<is_convertible<Protocol, Protocol1>::value>::type* = 0)
 #else // defined(ASIO_ENABLE_OLD_SERVICES)
   template <typename Protocol1>
-  asio::error_code accept(
+  ASIO_SYNC_OP_VOID accept(
       basic_socket<Protocol1>& peer, asio::error_code& ec,
       typename enable_if<is_convertible<Protocol, Protocol1>::value>::type* = 0)
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
   {
-    return this->get_service().accept(this->get_implementation(),
+    this->get_service().accept(this->get_implementation(),
         peer, static_cast<endpoint_type*>(0), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Start an asynchronous accept.
@@ -1282,16 +1291,17 @@
    */
 #if defined(ASIO_ENABLE_OLD_SERVICES)
   template <typename SocketService>
-  asio::error_code accept(
+  ASIO_SYNC_OP_VOID accept(
       basic_socket<protocol_type, SocketService>& peer,
       endpoint_type& peer_endpoint, asio::error_code& ec)
 #else // defined(ASIO_ENABLE_OLD_SERVICES)
-  asio::error_code accept(basic_socket<protocol_type>& peer,
+  ASIO_SYNC_OP_VOID accept(basic_socket<protocol_type>& peer,
       endpoint_type& peer_endpoint, asio::error_code& ec)
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
   {
-    return this->get_service().accept(
+    this->get_service().accept(
         this->get_implementation(), peer, &peer_endpoint, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Start an asynchronous accept.
diff --git a/asio/include/asio/buffered_read_stream.hpp b/asio/include/asio/buffered_read_stream.hpp
index 1552045..908dd37 100644
--- a/asio/include/asio/buffered_read_stream.hpp
+++ b/asio/include/asio/buffered_read_stream.hpp
@@ -128,9 +128,10 @@
   }
 
   /// Close the stream.
-  asio::error_code close(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID close(asio::error_code& ec)
   {
-    return next_layer_.close(ec);
+    next_layer_.close(ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Write the given data to the stream. Returns the number of bytes written.
diff --git a/asio/include/asio/buffered_stream.hpp b/asio/include/asio/buffered_stream.hpp
index de5fee8..cabab60 100644
--- a/asio/include/asio/buffered_stream.hpp
+++ b/asio/include/asio/buffered_stream.hpp
@@ -119,9 +119,10 @@
   }
 
   /// Close the stream.
-  asio::error_code close(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID close(asio::error_code& ec)
   {
-    return stream_impl_.close(ec);
+    stream_impl_.close(ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Flush all data from the buffer to the next layer. Returns the number of
diff --git a/asio/include/asio/buffered_write_stream.hpp b/asio/include/asio/buffered_write_stream.hpp
index 8310c16..9cdab8b 100644
--- a/asio/include/asio/buffered_write_stream.hpp
+++ b/asio/include/asio/buffered_write_stream.hpp
@@ -128,9 +128,10 @@
   }
 
   /// Close the stream.
-  asio::error_code close(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID close(asio::error_code& ec)
   {
-    return next_layer_.close(ec);
+    next_layer_.close(ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Flush all data from the buffer to the next layer. Returns the number of
diff --git a/asio/include/asio/datagram_socket_service.hpp b/asio/include/asio/datagram_socket_service.hpp
index e3708f1..4b9047d 100644
--- a/asio/include/asio/datagram_socket_service.hpp
+++ b/asio/include/asio/datagram_socket_service.hpp
@@ -134,22 +134,23 @@
   }
 
   // Open a new datagram socket implementation.
-  asio::error_code open(implementation_type& impl,
+  ASIO_SYNC_OP_VOID open(implementation_type& impl,
       const protocol_type& protocol, asio::error_code& ec)
   {
     if (protocol.type() == ASIO_OS_DEF(SOCK_DGRAM))
       service_impl_.open(impl, protocol, ec);
     else
       ec = asio::error::invalid_argument;
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Assign an existing native socket to a datagram socket.
-  asio::error_code assign(implementation_type& impl,
+  ASIO_SYNC_OP_VOID assign(implementation_type& impl,
       const protocol_type& protocol, const native_handle_type& native_socket,
       asio::error_code& ec)
   {
-    return service_impl_.assign(impl, protocol, native_socket, ec);
+    service_impl_.assign(impl, protocol, native_socket, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the socket is open.
@@ -159,10 +160,11 @@
   }
 
   /// Close a datagram socket implementation.
-  asio::error_code close(implementation_type& impl,
+  ASIO_SYNC_OP_VOID close(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.close(impl, ec);
+    service_impl_.close(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native socket implementation.
@@ -172,10 +174,11 @@
   }
 
   /// Cancel all asynchronous operations associated with the socket.
-  asio::error_code cancel(implementation_type& impl,
+  ASIO_SYNC_OP_VOID cancel(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.cancel(impl, ec);
+    service_impl_.cancel(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the socket is at the out-of-band data mark.
@@ -193,17 +196,19 @@
   }
 
   // Bind the datagram socket to the specified local endpoint.
-  asio::error_code bind(implementation_type& impl,
+  ASIO_SYNC_OP_VOID bind(implementation_type& impl,
       const endpoint_type& endpoint, asio::error_code& ec)
   {
-    return service_impl_.bind(impl, endpoint, ec);
+    service_impl_.bind(impl, endpoint, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Connect the datagram socket to the specified endpoint.
-  asio::error_code connect(implementation_type& impl,
+  ASIO_SYNC_OP_VOID connect(implementation_type& impl,
       const endpoint_type& peer_endpoint, asio::error_code& ec)
   {
-    return service_impl_.connect(impl, peer_endpoint, ec);
+    service_impl_.connect(impl, peer_endpoint, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Start an asynchronous connect.
@@ -224,26 +229,29 @@
 
   /// Set a socket option.
   template <typename SettableSocketOption>
-  asio::error_code set_option(implementation_type& impl,
+  ASIO_SYNC_OP_VOID set_option(implementation_type& impl,
       const SettableSocketOption& option, asio::error_code& ec)
   {
-    return service_impl_.set_option(impl, option, ec);
+    service_impl_.set_option(impl, option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get a socket option.
   template <typename GettableSocketOption>
-  asio::error_code get_option(const implementation_type& impl,
+  ASIO_SYNC_OP_VOID get_option(const implementation_type& impl,
       GettableSocketOption& option, asio::error_code& ec) const
   {
-    return service_impl_.get_option(impl, option, ec);
+    service_impl_.get_option(impl, option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Perform an IO control command on the socket.
   template <typename IoControlCommand>
-  asio::error_code io_control(implementation_type& impl,
+  ASIO_SYNC_OP_VOID io_control(implementation_type& impl,
       IoControlCommand& command, asio::error_code& ec)
   {
-    return service_impl_.io_control(impl, command, ec);
+    service_impl_.io_control(impl, command, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the socket.
@@ -253,10 +261,11 @@
   }
 
   /// Sets the non-blocking mode of the socket.
-  asio::error_code non_blocking(implementation_type& impl,
+  ASIO_SYNC_OP_VOID non_blocking(implementation_type& impl,
       bool mode, asio::error_code& ec)
   {
-    return service_impl_.non_blocking(impl, mode, ec);
+    service_impl_.non_blocking(impl, mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the native socket implementation.
@@ -266,10 +275,11 @@
   }
 
   /// Sets the non-blocking mode of the native socket implementation.
-  asio::error_code native_non_blocking(implementation_type& impl,
+  ASIO_SYNC_OP_VOID native_non_blocking(implementation_type& impl,
       bool mode, asio::error_code& ec)
   {
-    return service_impl_.native_non_blocking(impl, mode, ec);
+    service_impl_.native_non_blocking(impl, mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the local endpoint.
@@ -287,18 +297,20 @@
   }
 
   /// Disable sends or receives on the socket.
-  asio::error_code shutdown(implementation_type& impl,
+  ASIO_SYNC_OP_VOID shutdown(implementation_type& impl,
       socket_base::shutdown_type what, asio::error_code& ec)
   {
-    return service_impl_.shutdown(impl, what, ec);
+    service_impl_.shutdown(impl, what, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Wait for the socket to become ready to read, ready to write, or to have
   /// pending error conditions.
-  asio::error_code wait(implementation_type& impl,
+  ASIO_SYNC_OP_VOID wait(implementation_type& impl,
       socket_base::wait_type w, asio::error_code& ec)
   {
-    return service_impl_.wait(impl, w, ec);
+    service_impl_.wait(impl, w, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Asynchronously wait for the socket to become ready to read, ready to
diff --git a/asio/include/asio/detail/config.hpp b/asio/include/asio/detail/config.hpp
index f3176b1..3666e8a 100644
--- a/asio/include/asio/detail/config.hpp
+++ b/asio/include/asio/detail/config.hpp
@@ -1207,4 +1207,13 @@
 # define ASIO_SVC_ACCESS protected
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
 
+// Helper macros to manage transition away from error_code return values.
+#if defined(ASIO_NO_DEPRECATED)
+# define ASIO_SYNC_OP_VOID void
+# define ASIO_SYNC_OP_VOID_RETURN(e) return
+#else // defined(ASIO_NO_DEPRECATED)
+# define ASIO_SYNC_OP_VOID asio::error_code
+# define ASIO_SYNC_OP_VOID_RETURN(e) return e
+#endif // defined(ASIO_NO_DEPRECATED)
+
 #endif // ASIO_DETAIL_CONFIG_HPP
diff --git a/asio/include/asio/detail/reactive_serial_port_service.hpp b/asio/include/asio/detail/reactive_serial_port_service.hpp
index 93c39df..986e87b 100644
--- a/asio/include/asio/detail/reactive_serial_port_service.hpp
+++ b/asio/include/asio/detail/reactive_serial_port_service.hpp
@@ -190,8 +190,8 @@
   static asio::error_code store_option(const void* option,
       termios& storage, asio::error_code& ec)
   {
-    return static_cast<const SettableSerialPortOption*>(option)->store(
-        storage, ec);
+    static_cast<const SettableSerialPortOption*>(option)->store(storage, ec);
+    return ec;
   }
 
   // Helper function to set a serial port option.
@@ -208,7 +208,8 @@
   static asio::error_code load_option(void* option,
       const termios& storage, asio::error_code& ec)
   {
-    return static_cast<GettableSerialPortOption*>(option)->load(storage, ec);
+    static_cast<GettableSerialPortOption*>(option)->load(storage, ec);
+    return ec;
   }
 
   // Helper function to get a serial port option.
diff --git a/asio/include/asio/detail/reactive_socket_accept_op.hpp b/asio/include/asio/detail/reactive_socket_accept_op.hpp
index cf48149..95f6bf4 100644
--- a/asio/include/asio/detail/reactive_socket_accept_op.hpp
+++ b/asio/include/asio/detail/reactive_socket_accept_op.hpp
@@ -64,7 +64,8 @@
       socket_holder new_socket_holder(new_socket);
       if (o->peer_endpoint_)
         o->peer_endpoint_->resize(addrlen);
-      if (!o->peer_.assign(o->protocol_, new_socket, o->ec_))
+      o->peer_.assign(o->protocol_, new_socket, o->ec_);
+      if (!o->ec_)
         new_socket_holder.release();
     }
 
diff --git a/asio/include/asio/detail/reactive_socket_service.hpp b/asio/include/asio/detail/reactive_socket_service.hpp
index 9aa10a3..e12e835 100644
--- a/asio/include/asio/detail/reactive_socket_service.hpp
+++ b/asio/include/asio/detail/reactive_socket_service.hpp
@@ -398,7 +398,8 @@
     {
       if (peer_endpoint)
         peer_endpoint->resize(addr_len);
-      if (!peer.assign(impl.protocol_, new_socket.get(), ec))
+      peer.assign(impl.protocol_, new_socket.get(), ec);
+      if (!ec)
         new_socket.release();
     }
 
@@ -424,7 +425,8 @@
     {
       if (peer_endpoint)
         peer_endpoint->resize(addr_len);
-      if (!peer.assign(impl.protocol_, new_socket.get(), ec))
+      peer.assign(impl.protocol_, new_socket.get(), ec);
+      if (!ec)
         new_socket.release();
     }
 
diff --git a/asio/include/asio/detail/win_iocp_serial_port_service.hpp b/asio/include/asio/detail/win_iocp_serial_port_service.hpp
index 0e18662..5385646 100644
--- a/asio/include/asio/detail/win_iocp_serial_port_service.hpp
+++ b/asio/include/asio/detail/win_iocp_serial_port_service.hpp
@@ -185,8 +185,8 @@
   static asio::error_code store_option(const void* option,
       ::DCB& storage, asio::error_code& ec)
   {
-    return static_cast<const SettableSerialPortOption*>(option)->store(
-        storage, ec);
+    static_cast<const SettableSerialPortOption*>(option)->store(storage, ec);
+    return ec;
   }
 
   // Helper function to set a serial port option.
@@ -203,7 +203,8 @@
   static asio::error_code load_option(void* option,
       const ::DCB& storage, asio::error_code& ec)
   {
-    return static_cast<GettableSerialPortOption*>(option)->load(storage, ec);
+    static_cast<GettableSerialPortOption*>(option)->load(storage, ec);
+    return ec;
   }
 
   // Helper function to get a serial port option.
diff --git a/asio/include/asio/detail/win_iocp_socket_service.hpp b/asio/include/asio/detail/win_iocp_socket_service.hpp
index 6ea5dac..787267d 100644
--- a/asio/include/asio/detail/win_iocp_socket_service.hpp
+++ b/asio/include/asio/detail/win_iocp_socket_service.hpp
@@ -469,7 +469,8 @@
     {
       if (peer_endpoint)
         peer_endpoint->resize(addr_len);
-      if (!peer.assign(impl.protocol_, new_socket.get(), ec))
+      peer.assign(impl.protocol_, new_socket.get(), ec);
+      if (!ec)
         new_socket.release();
     }
 
@@ -495,7 +496,8 @@
     {
       if (peer_endpoint)
         peer_endpoint->resize(addr_len);
-      if (!peer.assign(impl.protocol_, new_socket.get(), ec))
+      peer.assign(impl.protocol_, new_socket.get(), ec);
+      if (!ec)
         new_socket.release();
     }
 
diff --git a/asio/include/asio/impl/serial_port_base.ipp b/asio/include/asio/impl/serial_port_base.ipp
index f5b4af2..748c8ca 100644
--- a/asio/include/asio/impl/serial_port_base.ipp
+++ b/asio/include/asio/impl/serial_port_base.ipp
@@ -37,7 +37,7 @@
 
 namespace asio {
 
-asio::error_code serial_port_base::baud_rate::store(
+ASIO_SYNC_OP_VOID serial_port_base::baud_rate::store(
     ASIO_OPTION_STORAGE& storage, asio::error_code& ec) const
 {
 #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
@@ -111,7 +111,7 @@
 # endif
   default:
     ec = asio::error::invalid_argument;
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 # if defined(_BSD_SOURCE)
   ::cfsetspeed(&storage, baud);
@@ -121,10 +121,10 @@
 # endif
 #endif
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
-asio::error_code serial_port_base::baud_rate::load(
+ASIO_SYNC_OP_VOID serial_port_base::baud_rate::load(
     const ASIO_OPTION_STORAGE& storage, asio::error_code& ec)
 {
 #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
@@ -199,11 +199,11 @@
   default:
     value_ = 0;
     ec = asio::error::invalid_argument;
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 #endif
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 serial_port_base::flow_control::flow_control(
@@ -217,7 +217,7 @@
   }
 }
 
-asio::error_code serial_port_base::flow_control::store(
+ASIO_SYNC_OP_VOID serial_port_base::flow_control::store(
     ASIO_OPTION_STORAGE& storage, asio::error_code& ec) const
 {
 #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
@@ -274,17 +274,17 @@
     break;
 # else
     ec = asio::error::operation_not_supported;
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
 # endif
   default:
     break;
   }
 #endif
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
-asio::error_code serial_port_base::flow_control::load(
+ASIO_SYNC_OP_VOID serial_port_base::flow_control::load(
     const ASIO_OPTION_STORAGE& storage, asio::error_code& ec)
 {
 #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
@@ -322,7 +322,7 @@
   }
 #endif
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 serial_port_base::parity::parity(serial_port_base::parity::type t)
@@ -335,7 +335,7 @@
   }
 }
 
-asio::error_code serial_port_base::parity::store(
+ASIO_SYNC_OP_VOID serial_port_base::parity::store(
     ASIO_OPTION_STORAGE& storage, asio::error_code& ec) const
 {
 #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
@@ -379,10 +379,10 @@
   }
 #endif
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
-asio::error_code serial_port_base::parity::load(
+ASIO_SYNC_OP_VOID serial_port_base::parity::load(
     const ASIO_OPTION_STORAGE& storage, asio::error_code& ec)
 {
 #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
@@ -416,7 +416,7 @@
   }
 #endif
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 serial_port_base::stop_bits::stop_bits(
@@ -430,7 +430,7 @@
   }
 }
 
-asio::error_code serial_port_base::stop_bits::store(
+ASIO_SYNC_OP_VOID serial_port_base::stop_bits::store(
     ASIO_OPTION_STORAGE& storage, asio::error_code& ec) const
 {
 #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
@@ -459,14 +459,14 @@
     break;
   default:
     ec = asio::error::operation_not_supported;
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 #endif
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
-asio::error_code serial_port_base::stop_bits::load(
+ASIO_SYNC_OP_VOID serial_port_base::stop_bits::load(
     const ASIO_OPTION_STORAGE& storage, asio::error_code& ec)
 {
 #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
@@ -490,7 +490,7 @@
   value_ = (storage.c_cflag & CSTOPB) ? two : one;
 #endif
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 serial_port_base::character_size::character_size(unsigned int t)
@@ -503,7 +503,7 @@
   }
 }
 
-asio::error_code serial_port_base::character_size::store(
+ASIO_SYNC_OP_VOID serial_port_base::character_size::store(
     ASIO_OPTION_STORAGE& storage, asio::error_code& ec) const
 {
 #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
@@ -520,10 +520,10 @@
   }
 #endif
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
-asio::error_code serial_port_base::character_size::load(
+ASIO_SYNC_OP_VOID serial_port_base::character_size::load(
     const ASIO_OPTION_STORAGE& storage, asio::error_code& ec)
 {
 #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
@@ -540,7 +540,7 @@
   }
 #endif
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 } // namespace asio
diff --git a/asio/include/asio/local/connect_pair.hpp b/asio/include/asio/local/connect_pair.hpp
index 40d13b2..3542d9b 100644
--- a/asio/include/asio/local/connect_pair.hpp
+++ b/asio/include/asio/local/connect_pair.hpp
@@ -39,7 +39,7 @@
 
 /// Create a pair of connected sockets.
 template <typename Protocol ASIO_SVC_TPARAM ASIO_SVC_TPARAM1>
-asio::error_code connect_pair(
+ASIO_SYNC_OP_VOID connect_pair(
     basic_socket<Protocol ASIO_SVC_TARG>& socket1,
     basic_socket<Protocol ASIO_SVC_TARG1>& socket2,
     asio::error_code& ec);
@@ -55,7 +55,7 @@
 }
 
 template <typename Protocol ASIO_SVC_TPARAM ASIO_SVC_TPARAM1>
-inline asio::error_code connect_pair(
+inline ASIO_SYNC_OP_VOID connect_pair(
     basic_socket<Protocol ASIO_SVC_TARG>& socket1,
     basic_socket<Protocol ASIO_SVC_TARG1>& socket2,
     asio::error_code& ec)
@@ -70,27 +70,29 @@
   if (asio::detail::socket_ops::socketpair(protocol.family(),
         protocol.type(), protocol.protocol(), sv, ec)
       == asio::detail::socket_error_retval)
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
 
-  if (socket1.assign(protocol, sv[0], ec))
+  socket1.assign(protocol, sv[0], ec);
+  if (ec)
   {
     asio::error_code temp_ec;
     asio::detail::socket_ops::state_type state[2] = { 0, 0 };
     asio::detail::socket_ops::close(sv[0], state[0], true, temp_ec);
     asio::detail::socket_ops::close(sv[1], state[1], true, temp_ec);
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
-  if (socket2.assign(protocol, sv[1], ec))
+  socket2.assign(protocol, sv[1], ec);
+  if (ec)
   {
     asio::error_code temp_ec;
     socket1.close(temp_ec);
     asio::detail::socket_ops::state_type state = 0;
     asio::detail::socket_ops::close(sv[1], state, true, temp_ec);
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 } // namespace local
diff --git a/asio/include/asio/posix/basic_descriptor.hpp b/asio/include/asio/posix/basic_descriptor.hpp
index 32aefbe..27db872 100644
--- a/asio/include/asio/posix/basic_descriptor.hpp
+++ b/asio/include/asio/posix/basic_descriptor.hpp
@@ -176,11 +176,12 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code assign(const native_handle_type& native_descriptor,
+  ASIO_SYNC_OP_VOID assign(const native_handle_type& native_descriptor,
       asio::error_code& ec)
   {
-    return this->get_service().assign(
+    this->get_service().assign(
         this->get_implementation(), native_descriptor, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the descriptor is open.
@@ -214,9 +215,10 @@
    * @param ec Set to indicate what error occurred, if any. Note that, even if
    * the function indicates an error, the underlying descriptor is closed.
    */
-  asio::error_code close(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID close(asio::error_code& ec)
   {
-    return this->get_service().close(this->get_implementation(), ec);
+    this->get_service().close(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native descriptor representation.
@@ -268,9 +270,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code cancel(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
   {
-    return this->get_service().cancel(this->get_implementation(), ec);
+    this->get_service().cancel(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Perform an IO control command on the descriptor.
@@ -331,11 +334,11 @@
    * @endcode
    */
   template <typename IoControlCommand>
-  asio::error_code io_control(IoControlCommand& command,
+  ASIO_SYNC_OP_VOID io_control(IoControlCommand& command,
       asio::error_code& ec)
   {
-    return this->get_service().io_control(
-        this->get_implementation(), command, ec);
+    this->get_service().io_control(this->get_implementation(), command, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the descriptor.
@@ -387,11 +390,11 @@
    * operations. Asynchronous operations will never fail with the error
    * asio::error::would_block.
    */
-  asio::error_code non_blocking(
+  ASIO_SYNC_OP_VOID non_blocking(
       bool mode, asio::error_code& ec)
   {
-    return this->get_service().non_blocking(
-        this->get_implementation(), mode, ec);
+    this->get_service().non_blocking(this->get_implementation(), mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the native descriptor implementation.
@@ -452,11 +455,12 @@
    * function fails with asio::error::invalid_argument, as the
    * combination does not make sense.
    */
-  asio::error_code native_non_blocking(
+  ASIO_SYNC_OP_VOID native_non_blocking(
       bool mode, asio::error_code& ec)
   {
-    return this->get_service().native_non_blocking(
+    this->get_service().native_non_blocking(
         this->get_implementation(), mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Wait for the descriptor to become ready to read, ready to write, or to
@@ -501,9 +505,10 @@
    * descriptor.wait(asio::posix::stream_descriptor::wait_read, ec);
    * @endcode
    */
-  asio::error_code wait(wait_type w, asio::error_code& ec)
+  ASIO_SYNC_OP_VOID wait(wait_type w, asio::error_code& ec)
   {
-    return this->get_service().wait(this->get_implementation(), w, ec);
+    this->get_service().wait(this->get_implementation(), w, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Asynchronously wait for the descriptor to become ready to read, ready to
diff --git a/asio/include/asio/posix/descriptor.hpp b/asio/include/asio/posix/descriptor.hpp
index b02164c..9ab46a5 100644
--- a/asio/include/asio/posix/descriptor.hpp
+++ b/asio/include/asio/posix/descriptor.hpp
@@ -226,11 +226,12 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code assign(const native_handle_type& native_descriptor,
+  ASIO_SYNC_OP_VOID assign(const native_handle_type& native_descriptor,
       asio::error_code& ec)
   {
-    return this->get_service().assign(
+    this->get_service().assign(
         this->get_implementation(), native_descriptor, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the descriptor is open.
@@ -264,9 +265,10 @@
    * @param ec Set to indicate what error occurred, if any. Note that, even if
    * the function indicates an error, the underlying descriptor is closed.
    */
-  asio::error_code close(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID close(asio::error_code& ec)
   {
-    return this->get_service().close(this->get_implementation(), ec);
+    this->get_service().close(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native descriptor representation.
@@ -318,9 +320,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code cancel(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
   {
-    return this->get_service().cancel(this->get_implementation(), ec);
+    this->get_service().cancel(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Perform an IO control command on the descriptor.
@@ -381,11 +384,11 @@
    * @endcode
    */
   template <typename IoControlCommand>
-  asio::error_code io_control(IoControlCommand& command,
+  ASIO_SYNC_OP_VOID io_control(IoControlCommand& command,
       asio::error_code& ec)
   {
-    return this->get_service().io_control(
-        this->get_implementation(), command, ec);
+    this->get_service().io_control(this->get_implementation(), command, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the descriptor.
@@ -437,11 +440,11 @@
    * operations. Asynchronous operations will never fail with the error
    * asio::error::would_block.
    */
-  asio::error_code non_blocking(
+  ASIO_SYNC_OP_VOID non_blocking(
       bool mode, asio::error_code& ec)
   {
-    return this->get_service().non_blocking(
-        this->get_implementation(), mode, ec);
+    this->get_service().non_blocking(this->get_implementation(), mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the native descriptor implementation.
@@ -502,11 +505,12 @@
    * function fails with asio::error::invalid_argument, as the
    * combination does not make sense.
    */
-  asio::error_code native_non_blocking(
+  ASIO_SYNC_OP_VOID native_non_blocking(
       bool mode, asio::error_code& ec)
   {
-    return this->get_service().native_non_blocking(
+    this->get_service().native_non_blocking(
         this->get_implementation(), mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Wait for the descriptor to become ready to read, ready to write, or to
@@ -551,9 +555,10 @@
    * descriptor.wait(asio::posix::stream_descriptor::wait_read, ec);
    * @endcode
    */
-  asio::error_code wait(wait_type w, asio::error_code& ec)
+  ASIO_SYNC_OP_VOID wait(wait_type w, asio::error_code& ec)
   {
-    return this->get_service().wait(this->get_implementation(), w, ec);
+    this->get_service().wait(this->get_implementation(), w, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Asynchronously wait for the descriptor to become ready to read, ready to
diff --git a/asio/include/asio/posix/stream_descriptor_service.hpp b/asio/include/asio/posix/stream_descriptor_service.hpp
index 1fabf23..e7a1b32 100644
--- a/asio/include/asio/posix/stream_descriptor_service.hpp
+++ b/asio/include/asio/posix/stream_descriptor_service.hpp
@@ -103,11 +103,12 @@
   }
 
   /// Assign an existing native descriptor to a stream descriptor.
-  asio::error_code assign(implementation_type& impl,
+  ASIO_SYNC_OP_VOID assign(implementation_type& impl,
       const native_handle_type& native_descriptor,
       asio::error_code& ec)
   {
-    return service_impl_.assign(impl, native_descriptor, ec);
+    service_impl_.assign(impl, native_descriptor, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the descriptor is open.
@@ -117,10 +118,11 @@
   }
 
   /// Close a stream descriptor implementation.
-  asio::error_code close(implementation_type& impl,
+  ASIO_SYNC_OP_VOID close(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.close(impl, ec);
+    service_impl_.close(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native descriptor implementation.
@@ -136,18 +138,20 @@
   }
 
   /// Cancel all asynchronous operations associated with the descriptor.
-  asio::error_code cancel(implementation_type& impl,
+  ASIO_SYNC_OP_VOID cancel(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.cancel(impl, ec);
+    service_impl_.cancel(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Perform an IO control command on the descriptor.
   template <typename IoControlCommand>
-  asio::error_code io_control(implementation_type& impl,
+  ASIO_SYNC_OP_VOID io_control(implementation_type& impl,
       IoControlCommand& command, asio::error_code& ec)
   {
-    return service_impl_.io_control(impl, command, ec);
+    service_impl_.io_control(impl, command, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the descriptor.
@@ -157,10 +161,11 @@
   }
 
   /// Sets the non-blocking mode of the descriptor.
-  asio::error_code non_blocking(implementation_type& impl,
+  ASIO_SYNC_OP_VOID non_blocking(implementation_type& impl,
       bool mode, asio::error_code& ec)
   {
-    return service_impl_.non_blocking(impl, mode, ec);
+    service_impl_.non_blocking(impl, mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the native descriptor implementation.
@@ -170,18 +175,20 @@
   }
 
   /// Sets the non-blocking mode of the native descriptor implementation.
-  asio::error_code native_non_blocking(implementation_type& impl,
+  ASIO_SYNC_OP_VOID native_non_blocking(implementation_type& impl,
       bool mode, asio::error_code& ec)
   {
-    return service_impl_.native_non_blocking(impl, mode, ec);
+    service_impl_.native_non_blocking(impl, mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Wait for the descriptor to become ready to read, ready to write, or to
   /// have pending error conditions.
-  asio::error_code wait(implementation_type& impl,
+  ASIO_SYNC_OP_VOID wait(implementation_type& impl,
       descriptor_base::wait_type w, asio::error_code& ec)
   {
-    return service_impl_.wait(impl, w, ec);
+    service_impl_.wait(impl, w, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Asynchronously wait for the descriptor to become ready to read, ready to
diff --git a/asio/include/asio/raw_socket_service.hpp b/asio/include/asio/raw_socket_service.hpp
index c4de684..f8b183d 100644
--- a/asio/include/asio/raw_socket_service.hpp
+++ b/asio/include/asio/raw_socket_service.hpp
@@ -134,22 +134,23 @@
   }
 
   // Open a new raw socket implementation.
-  asio::error_code open(implementation_type& impl,
+  ASIO_SYNC_OP_VOID open(implementation_type& impl,
       const protocol_type& protocol, asio::error_code& ec)
   {
     if (protocol.type() == ASIO_OS_DEF(SOCK_RAW))
       service_impl_.open(impl, protocol, ec);
     else
       ec = asio::error::invalid_argument;
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Assign an existing native socket to a raw socket.
-  asio::error_code assign(implementation_type& impl,
+  ASIO_SYNC_OP_VOID assign(implementation_type& impl,
       const protocol_type& protocol, const native_handle_type& native_socket,
       asio::error_code& ec)
   {
-    return service_impl_.assign(impl, protocol, native_socket, ec);
+    service_impl_.assign(impl, protocol, native_socket, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the socket is open.
@@ -159,10 +160,11 @@
   }
 
   /// Close a raw socket implementation.
-  asio::error_code close(implementation_type& impl,
+  ASIO_SYNC_OP_VOID close(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.close(impl, ec);
+    service_impl_.close(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native socket implementation.
@@ -172,10 +174,11 @@
   }
 
   /// Cancel all asynchronous operations associated with the socket.
-  asio::error_code cancel(implementation_type& impl,
+  ASIO_SYNC_OP_VOID cancel(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.cancel(impl, ec);
+    service_impl_.cancel(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the socket is at the out-of-band data mark.
@@ -193,17 +196,19 @@
   }
 
   // Bind the raw socket to the specified local endpoint.
-  asio::error_code bind(implementation_type& impl,
+  ASIO_SYNC_OP_VOID bind(implementation_type& impl,
       const endpoint_type& endpoint, asio::error_code& ec)
   {
-    return service_impl_.bind(impl, endpoint, ec);
+    service_impl_.bind(impl, endpoint, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Connect the raw socket to the specified endpoint.
-  asio::error_code connect(implementation_type& impl,
+  ASIO_SYNC_OP_VOID connect(implementation_type& impl,
       const endpoint_type& peer_endpoint, asio::error_code& ec)
   {
-    return service_impl_.connect(impl, peer_endpoint, ec);
+    service_impl_.connect(impl, peer_endpoint, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Start an asynchronous connect.
@@ -224,26 +229,29 @@
 
   /// Set a socket option.
   template <typename SettableSocketOption>
-  asio::error_code set_option(implementation_type& impl,
+  ASIO_SYNC_OP_VOID set_option(implementation_type& impl,
       const SettableSocketOption& option, asio::error_code& ec)
   {
-    return service_impl_.set_option(impl, option, ec);
+    service_impl_.set_option(impl, option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get a socket option.
   template <typename GettableSocketOption>
-  asio::error_code get_option(const implementation_type& impl,
+  ASIO_SYNC_OP_VOID get_option(const implementation_type& impl,
       GettableSocketOption& option, asio::error_code& ec) const
   {
-    return service_impl_.get_option(impl, option, ec);
+    service_impl_.get_option(impl, option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Perform an IO control command on the socket.
   template <typename IoControlCommand>
-  asio::error_code io_control(implementation_type& impl,
+  ASIO_SYNC_OP_VOID io_control(implementation_type& impl,
       IoControlCommand& command, asio::error_code& ec)
   {
-    return service_impl_.io_control(impl, command, ec);
+    service_impl_.io_control(impl, command, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the socket.
@@ -253,10 +261,11 @@
   }
 
   /// Sets the non-blocking mode of the socket.
-  asio::error_code non_blocking(implementation_type& impl,
+  ASIO_SYNC_OP_VOID non_blocking(implementation_type& impl,
       bool mode, asio::error_code& ec)
   {
-    return service_impl_.non_blocking(impl, mode, ec);
+    service_impl_.non_blocking(impl, mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the native socket implementation.
@@ -266,10 +275,11 @@
   }
 
   /// Sets the non-blocking mode of the native socket implementation.
-  asio::error_code native_non_blocking(implementation_type& impl,
+  ASIO_SYNC_OP_VOID native_non_blocking(implementation_type& impl,
       bool mode, asio::error_code& ec)
   {
-    return service_impl_.native_non_blocking(impl, mode, ec);
+    service_impl_.native_non_blocking(impl, mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the local endpoint.
@@ -287,18 +297,20 @@
   }
 
   /// Disable sends or receives on the socket.
-  asio::error_code shutdown(implementation_type& impl,
+  ASIO_SYNC_OP_VOID shutdown(implementation_type& impl,
       socket_base::shutdown_type what, asio::error_code& ec)
   {
-    return service_impl_.shutdown(impl, what, ec);
+    service_impl_.shutdown(impl, what, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Wait for the socket to become ready to read, ready to write, or to have
   /// pending error conditions.
-  asio::error_code wait(implementation_type& impl,
+  ASIO_SYNC_OP_VOID wait(implementation_type& impl,
       socket_base::wait_type w, asio::error_code& ec)
   {
-    return service_impl_.wait(impl, w, ec);
+    service_impl_.wait(impl, w, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Asynchronously wait for the socket to become ready to read, ready to
diff --git a/asio/include/asio/seq_packet_socket_service.hpp b/asio/include/asio/seq_packet_socket_service.hpp
index 1842ac4..d517eeb 100644
--- a/asio/include/asio/seq_packet_socket_service.hpp
+++ b/asio/include/asio/seq_packet_socket_service.hpp
@@ -136,22 +136,23 @@
   }
 
   /// Open a sequenced packet socket.
-  asio::error_code open(implementation_type& impl,
+  ASIO_SYNC_OP_VOID open(implementation_type& impl,
       const protocol_type& protocol, asio::error_code& ec)
   {
     if (protocol.type() == ASIO_OS_DEF(SOCK_SEQPACKET))
       service_impl_.open(impl, protocol, ec);
     else
       ec = asio::error::invalid_argument;
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Assign an existing native socket to a sequenced packet socket.
-  asio::error_code assign(implementation_type& impl,
+  ASIO_SYNC_OP_VOID assign(implementation_type& impl,
       const protocol_type& protocol, const native_handle_type& native_socket,
       asio::error_code& ec)
   {
-    return service_impl_.assign(impl, protocol, native_socket, ec);
+    service_impl_.assign(impl, protocol, native_socket, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the socket is open.
@@ -161,10 +162,11 @@
   }
 
   /// Close a sequenced packet socket implementation.
-  asio::error_code close(implementation_type& impl,
+  ASIO_SYNC_OP_VOID close(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.close(impl, ec);
+    service_impl_.close(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native socket implementation.
@@ -174,10 +176,11 @@
   }
 
   /// Cancel all asynchronous operations associated with the socket.
-  asio::error_code cancel(implementation_type& impl,
+  ASIO_SYNC_OP_VOID cancel(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.cancel(impl, ec);
+    service_impl_.cancel(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the socket is at the out-of-band data mark.
@@ -195,17 +198,19 @@
   }
 
   /// Bind the sequenced packet socket to the specified local endpoint.
-  asio::error_code bind(implementation_type& impl,
+  ASIO_SYNC_OP_VOID bind(implementation_type& impl,
       const endpoint_type& endpoint, asio::error_code& ec)
   {
-    return service_impl_.bind(impl, endpoint, ec);
+    service_impl_.bind(impl, endpoint, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Connect the sequenced packet socket to the specified endpoint.
-  asio::error_code connect(implementation_type& impl,
+  ASIO_SYNC_OP_VOID connect(implementation_type& impl,
       const endpoint_type& peer_endpoint, asio::error_code& ec)
   {
-    return service_impl_.connect(impl, peer_endpoint, ec);
+    service_impl_.connect(impl, peer_endpoint, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Start an asynchronous connect.
@@ -226,26 +231,29 @@
 
   /// Set a socket option.
   template <typename SettableSocketOption>
-  asio::error_code set_option(implementation_type& impl,
+  ASIO_SYNC_OP_VOID set_option(implementation_type& impl,
       const SettableSocketOption& option, asio::error_code& ec)
   {
-    return service_impl_.set_option(impl, option, ec);
+    service_impl_.set_option(impl, option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get a socket option.
   template <typename GettableSocketOption>
-  asio::error_code get_option(const implementation_type& impl,
+  ASIO_SYNC_OP_VOID get_option(const implementation_type& impl,
       GettableSocketOption& option, asio::error_code& ec) const
   {
-    return service_impl_.get_option(impl, option, ec);
+    service_impl_.get_option(impl, option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Perform an IO control command on the socket.
   template <typename IoControlCommand>
-  asio::error_code io_control(implementation_type& impl,
+  ASIO_SYNC_OP_VOID io_control(implementation_type& impl,
       IoControlCommand& command, asio::error_code& ec)
   {
-    return service_impl_.io_control(impl, command, ec);
+    service_impl_.io_control(impl, command, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the socket.
@@ -255,10 +263,11 @@
   }
 
   /// Sets the non-blocking mode of the socket.
-  asio::error_code non_blocking(implementation_type& impl,
+  ASIO_SYNC_OP_VOID non_blocking(implementation_type& impl,
       bool mode, asio::error_code& ec)
   {
-    return service_impl_.non_blocking(impl, mode, ec);
+    service_impl_.non_blocking(impl, mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the native socket implementation.
@@ -268,10 +277,11 @@
   }
 
   /// Sets the non-blocking mode of the native socket implementation.
-  asio::error_code native_non_blocking(implementation_type& impl,
+  ASIO_SYNC_OP_VOID native_non_blocking(implementation_type& impl,
       bool mode, asio::error_code& ec)
   {
-    return service_impl_.native_non_blocking(impl, mode, ec);
+    service_impl_.native_non_blocking(impl, mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the local endpoint.
@@ -289,18 +299,20 @@
   }
 
   /// Disable sends or receives on the socket.
-  asio::error_code shutdown(implementation_type& impl,
+  ASIO_SYNC_OP_VOID shutdown(implementation_type& impl,
       socket_base::shutdown_type what, asio::error_code& ec)
   {
-    return service_impl_.shutdown(impl, what, ec);
+    service_impl_.shutdown(impl, what, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Wait for the socket to become ready to read, ready to write, or to have
   /// pending error conditions.
-  asio::error_code wait(implementation_type& impl,
+  ASIO_SYNC_OP_VOID wait(implementation_type& impl,
       socket_base::wait_type w, asio::error_code& ec)
   {
-    return service_impl_.wait(impl, w, ec);
+    service_impl_.wait(impl, w, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Asynchronously wait for the socket to become ready to read, ready to
diff --git a/asio/include/asio/serial_port.hpp b/asio/include/asio/serial_port.hpp
index aa3eb31..4455a0a 100644
--- a/asio/include/asio/serial_port.hpp
+++ b/asio/include/asio/serial_port.hpp
@@ -285,10 +285,11 @@
    *
    * @param ec Set the indicate what error occurred, if any.
    */
-  asio::error_code open(const std::string& device,
+  ASIO_SYNC_OP_VOID open(const std::string& device,
       asio::error_code& ec)
   {
-    return this->get_service().open(this->get_implementation(), device, ec);
+    this->get_service().open(this->get_implementation(), device, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Assign an existing native serial port to the serial port.
@@ -315,11 +316,12 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code assign(const native_handle_type& native_serial_port,
+  ASIO_SYNC_OP_VOID assign(const native_handle_type& native_serial_port,
       asio::error_code& ec)
   {
-    return this->get_service().assign(this->get_implementation(),
+    this->get_service().assign(this->get_implementation(),
         native_serial_port, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the serial port is open.
@@ -351,9 +353,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code close(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID close(asio::error_code& ec)
   {
-    return this->get_service().close(this->get_implementation(), ec);
+    this->get_service().close(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native serial port representation.
@@ -390,9 +393,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code cancel(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
   {
-    return this->get_service().cancel(this->get_implementation(), ec);
+    this->get_service().cancel(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Send a break sequence to the serial port.
@@ -416,9 +420,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code send_break(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID send_break(asio::error_code& ec)
   {
-    return this->get_service().send_break(this->get_implementation(), ec);
+    this->get_service().send_break(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Set an option on the serial port.
@@ -460,11 +465,11 @@
    * asio::serial_port_base::character_size
    */
   template <typename SettableSerialPortOption>
-  asio::error_code set_option(const SettableSerialPortOption& option,
+  ASIO_SYNC_OP_VOID set_option(const SettableSerialPortOption& option,
       asio::error_code& ec)
   {
-    return this->get_service().set_option(
-        this->get_implementation(), option, ec);
+    this->get_service().set_option(this->get_implementation(), option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get an option from the serial port.
@@ -508,11 +513,11 @@
    * asio::serial_port_base::character_size
    */
   template <typename GettableSerialPortOption>
-  asio::error_code get_option(GettableSerialPortOption& option,
+  ASIO_SYNC_OP_VOID get_option(GettableSerialPortOption& option,
       asio::error_code& ec)
   {
-    return this->get_service().get_option(
-        this->get_implementation(), option, ec);
+    this->get_service().get_option(this->get_implementation(), option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Write some data to the serial port.
diff --git a/asio/include/asio/serial_port_base.hpp b/asio/include/asio/serial_port_base.hpp
index c9fea65..b4ab4f3 100644
--- a/asio/include/asio/serial_port_base.hpp
+++ b/asio/include/asio/serial_port_base.hpp
@@ -54,10 +54,10 @@
   public:
     explicit baud_rate(unsigned int rate = 0);
     unsigned int value() const;
-    ASIO_DECL asio::error_code store(
+    ASIO_DECL ASIO_SYNC_OP_VOID store(
         ASIO_OPTION_STORAGE& storage,
         asio::error_code& ec) const;
-    ASIO_DECL asio::error_code load(
+    ASIO_DECL ASIO_SYNC_OP_VOID load(
         const ASIO_OPTION_STORAGE& storage,
         asio::error_code& ec);
   private:
@@ -74,10 +74,10 @@
     enum type { none, software, hardware };
     ASIO_DECL explicit flow_control(type t = none);
     type value() const;
-    ASIO_DECL asio::error_code store(
+    ASIO_DECL ASIO_SYNC_OP_VOID store(
         ASIO_OPTION_STORAGE& storage,
         asio::error_code& ec) const;
-    ASIO_DECL asio::error_code load(
+    ASIO_DECL ASIO_SYNC_OP_VOID load(
         const ASIO_OPTION_STORAGE& storage,
         asio::error_code& ec);
   private:
@@ -94,10 +94,10 @@
     enum type { none, odd, even };
     ASIO_DECL explicit parity(type t = none);
     type value() const;
-    ASIO_DECL asio::error_code store(
+    ASIO_DECL ASIO_SYNC_OP_VOID store(
         ASIO_OPTION_STORAGE& storage,
         asio::error_code& ec) const;
-    ASIO_DECL asio::error_code load(
+    ASIO_DECL ASIO_SYNC_OP_VOID load(
         const ASIO_OPTION_STORAGE& storage,
         asio::error_code& ec);
   private:
@@ -114,10 +114,10 @@
     enum type { one, onepointfive, two };
     ASIO_DECL explicit stop_bits(type t = one);
     type value() const;
-    ASIO_DECL asio::error_code store(
+    ASIO_DECL ASIO_SYNC_OP_VOID store(
         ASIO_OPTION_STORAGE& storage,
         asio::error_code& ec) const;
-    ASIO_DECL asio::error_code load(
+    ASIO_DECL ASIO_SYNC_OP_VOID load(
         const ASIO_OPTION_STORAGE& storage,
         asio::error_code& ec);
   private:
@@ -133,10 +133,10 @@
   public:
     ASIO_DECL explicit character_size(unsigned int t = 8);
     unsigned int value() const;
-    ASIO_DECL asio::error_code store(
+    ASIO_DECL ASIO_SYNC_OP_VOID store(
         ASIO_OPTION_STORAGE& storage,
         asio::error_code& ec) const;
-    ASIO_DECL asio::error_code load(
+    ASIO_DECL ASIO_SYNC_OP_VOID load(
         const ASIO_OPTION_STORAGE& storage,
         asio::error_code& ec);
   private:
diff --git a/asio/include/asio/serial_port_service.hpp b/asio/include/asio/serial_port_service.hpp
index 4f6658d..4f47e57 100644
--- a/asio/include/asio/serial_port_service.hpp
+++ b/asio/include/asio/serial_port_service.hpp
@@ -109,17 +109,19 @@
   }
 
   /// Open a serial port.
-  asio::error_code open(implementation_type& impl,
+  ASIO_SYNC_OP_VOID open(implementation_type& impl,
       const std::string& device, asio::error_code& ec)
   {
-    return service_impl_.open(impl, device, ec);
+    service_impl_.open(impl, device, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Assign an existing native handle to a serial port.
-  asio::error_code assign(implementation_type& impl,
+  ASIO_SYNC_OP_VOID assign(implementation_type& impl,
       const native_handle_type& handle, asio::error_code& ec)
   {
-    return service_impl_.assign(impl, handle, ec);
+    service_impl_.assign(impl, handle, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the handle is open.
@@ -129,10 +131,11 @@
   }
 
   /// Close a serial port implementation.
-  asio::error_code close(implementation_type& impl,
+  ASIO_SYNC_OP_VOID close(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.close(impl, ec);
+    service_impl_.close(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native handle implementation.
@@ -142,33 +145,37 @@
   }
 
   /// Cancel all asynchronous operations associated with the handle.
-  asio::error_code cancel(implementation_type& impl,
+  ASIO_SYNC_OP_VOID cancel(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.cancel(impl, ec);
+    service_impl_.cancel(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Set a serial port option.
   template <typename SettableSerialPortOption>
-  asio::error_code set_option(implementation_type& impl,
+  ASIO_SYNC_OP_VOID set_option(implementation_type& impl,
       const SettableSerialPortOption& option, asio::error_code& ec)
   {
-    return service_impl_.set_option(impl, option, ec);
+    service_impl_.set_option(impl, option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get a serial port option.
   template <typename GettableSerialPortOption>
-  asio::error_code get_option(const implementation_type& impl,
+  ASIO_SYNC_OP_VOID get_option(const implementation_type& impl,
       GettableSerialPortOption& option, asio::error_code& ec) const
   {
-    return service_impl_.get_option(impl, option, ec);
+    service_impl_.get_option(impl, option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Send a break sequence to the serial port.
-  asio::error_code send_break(implementation_type& impl,
+  ASIO_SYNC_OP_VOID send_break(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.send_break(impl, ec);
+    service_impl_.send_break(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Write the given data to the stream.
diff --git a/asio/include/asio/signal_set.hpp b/asio/include/asio/signal_set.hpp
index 71dcc3c..0850901 100644
--- a/asio/include/asio/signal_set.hpp
+++ b/asio/include/asio/signal_set.hpp
@@ -266,11 +266,11 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code add(int signal_number,
+  ASIO_SYNC_OP_VOID add(int signal_number,
       asio::error_code& ec)
   {
-    return this->get_service().add(
-        this->get_implementation(), signal_number, ec);
+    this->get_service().add(this->get_implementation(), signal_number, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Remove a signal from a signal_set.
@@ -304,11 +304,11 @@
    * @note Removes any notifications that have been queued for the specified
    * signal number.
    */
-  asio::error_code remove(int signal_number,
+  ASIO_SYNC_OP_VOID remove(int signal_number,
       asio::error_code& ec)
   {
-    return this->get_service().remove(
-        this->get_implementation(), signal_number, ec);
+    this->get_service().remove(this->get_implementation(), signal_number, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Remove all signals from a signal_set.
@@ -336,9 +336,10 @@
    *
    * @note Removes all queued notifications.
    */
-  asio::error_code clear(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID clear(asio::error_code& ec)
   {
-    return this->get_service().clear(this->get_implementation(), ec);
+    this->get_service().clear(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Cancel all operations associated with the signal set.
@@ -390,9 +391,10 @@
    * These handlers can no longer be cancelled, and therefore are passed an
    * error code that indicates the successful completion of the wait operation.
    */
-  asio::error_code cancel(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
   {
-    return this->get_service().cancel(this->get_implementation(), ec);
+    this->get_service().cancel(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Start an asynchronous operation to wait for a signal to be delivered.
diff --git a/asio/include/asio/signal_set_service.hpp b/asio/include/asio/signal_set_service.hpp
index 107a2f3..d4c54b8 100644
--- a/asio/include/asio/signal_set_service.hpp
+++ b/asio/include/asio/signal_set_service.hpp
@@ -70,31 +70,35 @@
   }
 
   /// Add a signal to a signal_set.
-  asio::error_code add(implementation_type& impl,
+  ASIO_SYNC_OP_VOID add(implementation_type& impl,
       int signal_number, asio::error_code& ec)
   {
-    return service_impl_.add(impl, signal_number, ec);
+    service_impl_.add(impl, signal_number, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Remove a signal to a signal_set.
-  asio::error_code remove(implementation_type& impl,
+  ASIO_SYNC_OP_VOID remove(implementation_type& impl,
       int signal_number, asio::error_code& ec)
   {
-    return service_impl_.remove(impl, signal_number, ec);
+    service_impl_.remove(impl, signal_number, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Remove all signals from a signal_set.
-  asio::error_code clear(implementation_type& impl,
+  ASIO_SYNC_OP_VOID clear(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.clear(impl, ec);
+    service_impl_.clear(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Cancel all operations associated with the signal set.
-  asio::error_code cancel(implementation_type& impl,
+  ASIO_SYNC_OP_VOID cancel(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.cancel(impl, ec);
+    service_impl_.cancel(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   // Start an asynchronous operation to wait for a signal to be delivered.
diff --git a/asio/include/asio/socket_acceptor_service.hpp b/asio/include/asio/socket_acceptor_service.hpp
index 9ff6dcf..b9c33ff 100644
--- a/asio/include/asio/socket_acceptor_service.hpp
+++ b/asio/include/asio/socket_acceptor_service.hpp
@@ -133,18 +133,20 @@
   }
 
   /// Open a new socket acceptor implementation.
-  asio::error_code open(implementation_type& impl,
+  ASIO_SYNC_OP_VOID open(implementation_type& impl,
       const protocol_type& protocol, asio::error_code& ec)
   {
-    return service_impl_.open(impl, protocol, ec);
+    service_impl_.open(impl, protocol, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Assign an existing native acceptor to a socket acceptor.
-  asio::error_code assign(implementation_type& impl,
+  ASIO_SYNC_OP_VOID assign(implementation_type& impl,
       const protocol_type& protocol, const native_handle_type& native_acceptor,
       asio::error_code& ec)
   {
-    return service_impl_.assign(impl, protocol, native_acceptor, ec);
+    service_impl_.assign(impl, protocol, native_acceptor, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the acceptor is open.
@@ -154,32 +156,36 @@
   }
 
   /// Cancel all asynchronous operations associated with the acceptor.
-  asio::error_code cancel(implementation_type& impl,
+  ASIO_SYNC_OP_VOID cancel(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.cancel(impl, ec);
+    service_impl_.cancel(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Bind the socket acceptor to the specified local endpoint.
-  asio::error_code bind(implementation_type& impl,
+  ASIO_SYNC_OP_VOID bind(implementation_type& impl,
       const endpoint_type& endpoint, asio::error_code& ec)
   {
-    return service_impl_.bind(impl, endpoint, ec);
+    service_impl_.bind(impl, endpoint, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Place the socket acceptor into the state where it will listen for new
   /// connections.
-  asio::error_code listen(implementation_type& impl, int backlog,
+  ASIO_SYNC_OP_VOID listen(implementation_type& impl, int backlog,
       asio::error_code& ec)
   {
-    return service_impl_.listen(impl, backlog, ec);
+    service_impl_.listen(impl, backlog, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Close a socket acceptor implementation.
-  asio::error_code close(implementation_type& impl,
+  ASIO_SYNC_OP_VOID close(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.close(impl, ec);
+    service_impl_.close(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native acceptor implementation.
@@ -190,26 +196,29 @@
 
   /// Set a socket option.
   template <typename SettableSocketOption>
-  asio::error_code set_option(implementation_type& impl,
+  ASIO_SYNC_OP_VOID set_option(implementation_type& impl,
       const SettableSocketOption& option, asio::error_code& ec)
   {
-    return service_impl_.set_option(impl, option, ec);
+    service_impl_.set_option(impl, option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get a socket option.
   template <typename GettableSocketOption>
-  asio::error_code get_option(const implementation_type& impl,
+  ASIO_SYNC_OP_VOID get_option(const implementation_type& impl,
       GettableSocketOption& option, asio::error_code& ec) const
   {
-    return service_impl_.get_option(impl, option, ec);
+    service_impl_.get_option(impl, option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Perform an IO control command on the socket.
   template <typename IoControlCommand>
-  asio::error_code io_control(implementation_type& impl,
+  ASIO_SYNC_OP_VOID io_control(implementation_type& impl,
       IoControlCommand& command, asio::error_code& ec)
   {
-    return service_impl_.io_control(impl, command, ec);
+    service_impl_.io_control(impl, command, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the acceptor.
@@ -219,10 +228,11 @@
   }
 
   /// Sets the non-blocking mode of the acceptor.
-  asio::error_code non_blocking(implementation_type& impl,
+  ASIO_SYNC_OP_VOID non_blocking(implementation_type& impl,
       bool mode, asio::error_code& ec)
   {
-    return service_impl_.non_blocking(impl, mode, ec);
+    service_impl_.non_blocking(impl, mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the native acceptor implementation.
@@ -232,10 +242,11 @@
   }
 
   /// Sets the non-blocking mode of the native acceptor implementation.
-  asio::error_code native_non_blocking(implementation_type& impl,
+  ASIO_SYNC_OP_VOID native_non_blocking(implementation_type& impl,
       bool mode, asio::error_code& ec)
   {
-    return service_impl_.native_non_blocking(impl, mode, ec);
+    service_impl_.native_non_blocking(impl, mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the local endpoint.
@@ -247,10 +258,11 @@
 
   /// Wait for the acceptor to become ready to read, ready to write, or to have
   /// pending error conditions.
-  asio::error_code wait(implementation_type& impl,
+  ASIO_SYNC_OP_VOID wait(implementation_type& impl,
       socket_base::wait_type w, asio::error_code& ec)
   {
-    return service_impl_.wait(impl, w, ec);
+    service_impl_.wait(impl, w, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Asynchronously wait for the acceptor to become ready to read, ready to
@@ -271,12 +283,13 @@
 
   /// Accept a new connection.
   template <typename Protocol1, typename SocketService>
-  asio::error_code accept(implementation_type& impl,
+  ASIO_SYNC_OP_VOID accept(implementation_type& impl,
       basic_socket<Protocol1, SocketService>& peer,
       endpoint_type* peer_endpoint, asio::error_code& ec,
       typename enable_if<is_convertible<Protocol, Protocol1>::value>::type* = 0)
   {
-    return service_impl_.accept(impl, peer, peer_endpoint, ec);
+    service_impl_.accept(impl, peer, peer_endpoint, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
 #if defined(ASIO_HAS_MOVE)
diff --git a/asio/include/asio/ssl/context.hpp b/asio/include/asio/ssl/context.hpp
index 876768f..6e3f2ad 100644
--- a/asio/include/asio/ssl/context.hpp
+++ b/asio/include/asio/ssl/context.hpp
@@ -108,7 +108,7 @@
    *
    * @note Calls @c SSL_CTX_clear_options.
    */
-  ASIO_DECL asio::error_code clear_options(options o,
+  ASIO_DECL ASIO_SYNC_OP_VOID clear_options(options o,
       asio::error_code& ec);
 
   /// Set options on the context.
@@ -137,7 +137,7 @@
    *
    * @note Calls @c SSL_CTX_set_options.
    */
-  ASIO_DECL asio::error_code set_options(options o,
+  ASIO_DECL ASIO_SYNC_OP_VOID set_options(options o,
       asio::error_code& ec);
 
   /// Set the peer verification mode.
@@ -166,7 +166,7 @@
    *
    * @note Calls @c SSL_CTX_set_verify.
    */
-  ASIO_DECL asio::error_code set_verify_mode(
+  ASIO_DECL ASIO_SYNC_OP_VOID set_verify_mode(
       verify_mode v, asio::error_code& ec);
 
   /// Set the peer verification depth.
@@ -195,7 +195,7 @@
    *
    * @note Calls @c SSL_CTX_set_verify_depth.
    */
-  ASIO_DECL asio::error_code set_verify_depth(
+  ASIO_DECL ASIO_SYNC_OP_VOID set_verify_depth(
       int depth, asio::error_code& ec);
 
   /// Set the callback used to verify peer certificates.
@@ -238,7 +238,7 @@
    * @note Calls @c SSL_CTX_set_verify.
    */
   template <typename VerifyCallback>
-  asio::error_code set_verify_callback(VerifyCallback callback,
+  ASIO_SYNC_OP_VOID set_verify_callback(VerifyCallback callback,
       asio::error_code& ec);
 
   /// Load a certification authority file for performing verification.
@@ -267,7 +267,7 @@
    *
    * @note Calls @c SSL_CTX_load_verify_locations.
    */
-  ASIO_DECL asio::error_code load_verify_file(
+  ASIO_DECL ASIO_SYNC_OP_VOID load_verify_file(
       const std::string& filename, asio::error_code& ec);
 
   /// Add certification authority for performing verification.
@@ -296,7 +296,7 @@
    *
    * @note Calls @c SSL_CTX_get_cert_store and @c X509_STORE_add_cert.
    */
-  ASIO_DECL asio::error_code add_certificate_authority(
+  ASIO_DECL ASIO_SYNC_OP_VOID add_certificate_authority(
       const const_buffer& ca, asio::error_code& ec);
 
   /// Configures the context to use the default directories for finding
@@ -323,7 +323,7 @@
    *
    * @note Calls @c SSL_CTX_set_default_verify_paths.
    */
-  ASIO_DECL asio::error_code set_default_verify_paths(
+  ASIO_DECL ASIO_SYNC_OP_VOID set_default_verify_paths(
       asio::error_code& ec);
 
   /// Add a directory containing certificate authority files to be used for
@@ -356,7 +356,7 @@
    *
    * @note Calls @c SSL_CTX_load_verify_locations.
    */
-  ASIO_DECL asio::error_code add_verify_path(
+  ASIO_DECL ASIO_SYNC_OP_VOID add_verify_path(
       const std::string& path, asio::error_code& ec);
 
   /// Use a certificate from a memory buffer.
@@ -386,7 +386,7 @@
    *
    * @note Calls @c SSL_CTX_use_certificate or SSL_CTX_use_certificate_ASN1.
    */
-  ASIO_DECL asio::error_code use_certificate(
+  ASIO_DECL ASIO_SYNC_OP_VOID use_certificate(
       const const_buffer& certificate, file_format format,
       asio::error_code& ec);
 
@@ -417,7 +417,7 @@
    *
    * @note Calls @c SSL_CTX_use_certificate_file.
    */
-  ASIO_DECL asio::error_code use_certificate_file(
+  ASIO_DECL ASIO_SYNC_OP_VOID use_certificate_file(
       const std::string& filename, file_format format,
       asio::error_code& ec);
 
@@ -447,7 +447,7 @@
    *
    * @note Calls @c SSL_CTX_use_certificate and SSL_CTX_add_extra_chain_cert.
    */
-  ASIO_DECL asio::error_code use_certificate_chain(
+  ASIO_DECL ASIO_SYNC_OP_VOID use_certificate_chain(
       const const_buffer& chain, asio::error_code& ec);
 
   /// Use a certificate chain from a file.
@@ -476,7 +476,7 @@
    *
    * @note Calls @c SSL_CTX_use_certificate_chain_file.
    */
-  ASIO_DECL asio::error_code use_certificate_chain_file(
+  ASIO_DECL ASIO_SYNC_OP_VOID use_certificate_chain_file(
       const std::string& filename, asio::error_code& ec);
 
   /// Use a private key from a memory buffer.
@@ -506,7 +506,7 @@
    *
    * @note Calls @c SSL_CTX_use_PrivateKey or SSL_CTX_use_PrivateKey_ASN1.
    */
-  ASIO_DECL asio::error_code use_private_key(
+  ASIO_DECL ASIO_SYNC_OP_VOID use_private_key(
       const const_buffer& private_key, file_format format,
       asio::error_code& ec);
 
@@ -537,7 +537,7 @@
    *
    * @note Calls @c SSL_CTX_use_PrivateKey_file.
    */
-  ASIO_DECL asio::error_code use_private_key_file(
+  ASIO_DECL ASIO_SYNC_OP_VOID use_private_key_file(
       const std::string& filename, file_format format,
       asio::error_code& ec);
 
@@ -570,7 +570,7 @@
    *
    * @note Calls @c SSL_CTX_use_RSAPrivateKey or SSL_CTX_use_RSAPrivateKey_ASN1.
    */
-  ASIO_DECL asio::error_code use_rsa_private_key(
+  ASIO_DECL ASIO_SYNC_OP_VOID use_rsa_private_key(
       const const_buffer& private_key, file_format format,
       asio::error_code& ec);
 
@@ -603,7 +603,7 @@
    *
    * @note Calls @c SSL_CTX_use_RSAPrivateKey_file.
    */
-  ASIO_DECL asio::error_code use_rsa_private_key_file(
+  ASIO_DECL ASIO_SYNC_OP_VOID use_rsa_private_key_file(
       const std::string& filename, file_format format,
       asio::error_code& ec);
 
@@ -635,7 +635,7 @@
    *
    * @note Calls @c SSL_CTX_set_tmp_dh.
    */
-  ASIO_DECL asio::error_code use_tmp_dh(
+  ASIO_DECL ASIO_SYNC_OP_VOID use_tmp_dh(
       const const_buffer& dh, asio::error_code& ec);
 
   /// Use the specified file to obtain the temporary Diffie-Hellman parameters.
@@ -664,7 +664,7 @@
    *
    * @note Calls @c SSL_CTX_set_tmp_dh.
    */
-  ASIO_DECL asio::error_code use_tmp_dh_file(
+  ASIO_DECL ASIO_SYNC_OP_VOID use_tmp_dh_file(
       const std::string& filename, asio::error_code& ec);
 
   /// Set the password callback.
@@ -705,7 +705,7 @@
    * @note Calls @c SSL_CTX_set_default_passwd_cb.
    */
   template <typename PasswordCallback>
-  asio::error_code set_password_callback(PasswordCallback callback,
+  ASIO_SYNC_OP_VOID set_password_callback(PasswordCallback callback,
       asio::error_code& ec);
 
 private:
@@ -716,7 +716,7 @@
   struct dh_cleanup;
 
   // Helper function used to set a peer certificate verification callback.
-  ASIO_DECL asio::error_code do_set_verify_callback(
+  ASIO_DECL ASIO_SYNC_OP_VOID do_set_verify_callback(
       detail::verify_callback_base* callback, asio::error_code& ec);
 
   // Callback used when the SSL implementation wants to verify a certificate.
@@ -724,7 +724,7 @@
       int preverified, X509_STORE_CTX* ctx);
 
   // Helper function used to set a password callback.
-  ASIO_DECL asio::error_code do_set_password_callback(
+  ASIO_DECL ASIO_SYNC_OP_VOID do_set_password_callback(
       detail::password_callback_base* callback, asio::error_code& ec);
 
   // Callback used when the SSL implementation wants a password.
@@ -732,7 +732,7 @@
       char* buf, int size, int purpose, void* data);
 
   // Helper function to set the temporary Diffie-Hellman parameters from a BIO.
-  ASIO_DECL asio::error_code do_use_tmp_dh(
+  ASIO_DECL ASIO_SYNC_OP_VOID do_use_tmp_dh(
       BIO* bio, asio::error_code& ec);
 
   // Helper function to make a BIO from a memory buffer.
diff --git a/asio/include/asio/ssl/impl/context.hpp b/asio/include/asio/ssl/impl/context.hpp
index 6f15225..2b5a161 100644
--- a/asio/include/asio/ssl/impl/context.hpp
+++ b/asio/include/asio/ssl/impl/context.hpp
@@ -34,11 +34,12 @@
 }
 
 template <typename VerifyCallback>
-asio::error_code context::set_verify_callback(
+ASIO_SYNC_OP_VOID context::set_verify_callback(
     VerifyCallback callback, asio::error_code& ec)
 {
-  return do_set_verify_callback(
+  do_set_verify_callback(
       new detail::verify_callback<VerifyCallback>(callback), ec);
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 template <typename PasswordCallback>
@@ -50,11 +51,12 @@
 }
 
 template <typename PasswordCallback>
-asio::error_code context::set_password_callback(
+ASIO_SYNC_OP_VOID context::set_password_callback(
     PasswordCallback callback, asio::error_code& ec)
 {
-  return do_set_password_callback(
+  do_set_password_callback(
       new detail::password_callback<PasswordCallback>(callback), ec);
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 } // namespace ssl
diff --git a/asio/include/asio/ssl/impl/context.ipp b/asio/include/asio/ssl/impl/context.ipp
index 8bf6fe7..02210d9 100644
--- a/asio/include/asio/ssl/impl/context.ipp
+++ b/asio/include/asio/ssl/impl/context.ipp
@@ -226,7 +226,7 @@
   asio::detail::throw_error(ec, "clear_options");
 }
 
-asio::error_code context::clear_options(
+ASIO_SYNC_OP_VOID context::clear_options(
     context::options o, asio::error_code& ec)
 {
 #if (OPENSSL_VERSION_NUMBER >= 0x009080DFL) \
@@ -250,7 +250,7 @@
   ec = asio::error::operation_not_supported;
 #endif // (OPENSSL_VERSION_NUMBER >= 0x009080DFL)
        //   && (OPENSSL_VERSION_NUMBER != 0x00909000L)
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::set_options(context::options o)
@@ -260,7 +260,7 @@
   asio::detail::throw_error(ec, "set_options");
 }
 
-asio::error_code context::set_options(
+ASIO_SYNC_OP_VOID context::set_options(
     context::options o, asio::error_code& ec)
 {
 #if !defined(SSL_OP_NO_COMPRESSION)
@@ -277,7 +277,7 @@
   ::SSL_CTX_set_options(handle_, o);
 
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::set_verify_mode(verify_mode v)
@@ -287,13 +287,13 @@
   asio::detail::throw_error(ec, "set_verify_mode");
 }
 
-asio::error_code context::set_verify_mode(
+ASIO_SYNC_OP_VOID context::set_verify_mode(
     verify_mode v, asio::error_code& ec)
 {
   ::SSL_CTX_set_verify(handle_, v, ::SSL_CTX_get_verify_callback(handle_));
 
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::set_verify_depth(int depth)
@@ -303,13 +303,13 @@
   asio::detail::throw_error(ec, "set_verify_depth");
 }
 
-asio::error_code context::set_verify_depth(
+ASIO_SYNC_OP_VOID context::set_verify_depth(
     int depth, asio::error_code& ec)
 {
   ::SSL_CTX_set_verify_depth(handle_, depth);
 
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::load_verify_file(const std::string& filename)
@@ -319,7 +319,7 @@
   asio::detail::throw_error(ec, "load_verify_file");
 }
 
-asio::error_code context::load_verify_file(
+ASIO_SYNC_OP_VOID context::load_verify_file(
     const std::string& filename, asio::error_code& ec)
 {
   ::ERR_clear_error();
@@ -329,11 +329,11 @@
     ec = asio::error_code(
         static_cast<int>(::ERR_get_error()),
         asio::error::get_ssl_category());
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::add_certificate_authority(const const_buffer& ca)
@@ -343,7 +343,7 @@
   asio::detail::throw_error(ec, "add_certificate_authority");
 }
 
-asio::error_code context::add_certificate_authority(
+ASIO_SYNC_OP_VOID context::add_certificate_authority(
     const const_buffer& ca, asio::error_code& ec)
 {
   ::ERR_clear_error();
@@ -359,7 +359,7 @@
         if (::X509_STORE_add_cert(store, cert.p) == 1)
         {
           ec = asio::error_code();
-          return ec;
+          ASIO_SYNC_OP_VOID_RETURN(ec);
         }
       }
     }
@@ -368,7 +368,7 @@
   ec = asio::error_code(
       static_cast<int>(::ERR_get_error()),
       asio::error::get_ssl_category());
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::set_default_verify_paths()
@@ -378,7 +378,7 @@
   asio::detail::throw_error(ec, "set_default_verify_paths");
 }
 
-asio::error_code context::set_default_verify_paths(
+ASIO_SYNC_OP_VOID context::set_default_verify_paths(
     asio::error_code& ec)
 {
   ::ERR_clear_error();
@@ -388,11 +388,11 @@
     ec = asio::error_code(
         static_cast<int>(::ERR_get_error()),
         asio::error::get_ssl_category());
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::add_verify_path(const std::string& path)
@@ -402,7 +402,7 @@
   asio::detail::throw_error(ec, "add_verify_path");
 }
 
-asio::error_code context::add_verify_path(
+ASIO_SYNC_OP_VOID context::add_verify_path(
     const std::string& path, asio::error_code& ec)
 {
   ::ERR_clear_error();
@@ -412,11 +412,11 @@
     ec = asio::error_code(
         static_cast<int>(::ERR_get_error()),
         asio::error::get_ssl_category());
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::use_certificate(
@@ -427,7 +427,7 @@
   asio::detail::throw_error(ec, "use_certificate");
 }
 
-asio::error_code context::use_certificate(
+ASIO_SYNC_OP_VOID context::use_certificate(
     const const_buffer& certificate, file_format format,
     asio::error_code& ec)
 {
@@ -440,7 +440,7 @@
           static_cast<const unsigned char*>(certificate.data())) == 1)
     {
       ec = asio::error_code();
-      return ec;
+      ASIO_SYNC_OP_VOID_RETURN(ec);
     }
   }
   else if (format == context_base::pem)
@@ -454,7 +454,7 @@
         if (::SSL_CTX_use_certificate(handle_, cert.p) == 1)
         {
           ec = asio::error_code();
-          return ec;
+          ASIO_SYNC_OP_VOID_RETURN(ec);
         }
       }
     }
@@ -462,13 +462,13 @@
   else
   {
     ec = asio::error::invalid_argument;
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   ec = asio::error_code(
       static_cast<int>(::ERR_get_error()),
       asio::error::get_ssl_category());
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::use_certificate_file(
@@ -479,7 +479,7 @@
   asio::detail::throw_error(ec, "use_certificate_file");
 }
 
-asio::error_code context::use_certificate_file(
+ASIO_SYNC_OP_VOID context::use_certificate_file(
     const std::string& filename, file_format format,
     asio::error_code& ec)
 {
@@ -495,7 +495,7 @@
   default:
     {
       ec = asio::error::invalid_argument;
-      return ec;
+      ASIO_SYNC_OP_VOID_RETURN(ec);
     }
   }
 
@@ -506,11 +506,11 @@
     ec = asio::error_code(
         static_cast<int>(::ERR_get_error()),
         asio::error::get_ssl_category());
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::use_certificate_chain(const const_buffer& chain)
@@ -520,7 +520,7 @@
   asio::detail::throw_error(ec, "use_certificate_chain");
 }
 
-asio::error_code context::use_certificate_chain(
+ASIO_SYNC_OP_VOID context::use_certificate_chain(
     const const_buffer& chain, asio::error_code& ec)
 {
   ::ERR_clear_error();
@@ -536,7 +536,7 @@
     {
       ec = asio::error_code(ERR_R_PEM_LIB,
           asio::error::get_ssl_category());
-      return ec;
+      ASIO_SYNC_OP_VOID_RETURN(ec);
     }
 
     int result = ::SSL_CTX_use_certificate(handle_, cert.p);
@@ -545,7 +545,7 @@
       ec = asio::error_code(
           static_cast<int>(::ERR_get_error()),
           asio::error::get_ssl_category());
-      return ec;
+      ASIO_SYNC_OP_VOID_RETURN(ec);
     }
 
 #if (OPENSSL_VERSION_NUMBER >= 0x10002000L)
@@ -567,7 +567,7 @@
         ec = asio::error_code(
             static_cast<int>(::ERR_get_error()),
             asio::error::get_ssl_category());
-        return ec;
+        ASIO_SYNC_OP_VOID_RETURN(ec);
       }
     }
   
@@ -577,14 +577,14 @@
     {
       ::ERR_clear_error();
       ec = asio::error_code();
-      return ec;
+      ASIO_SYNC_OP_VOID_RETURN(ec);
     }
   }
 
   ec = asio::error_code(
       static_cast<int>(::ERR_get_error()),
       asio::error::get_ssl_category());
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::use_certificate_chain_file(const std::string& filename)
@@ -594,7 +594,7 @@
   asio::detail::throw_error(ec, "use_certificate_chain_file");
 }
 
-asio::error_code context::use_certificate_chain_file(
+ASIO_SYNC_OP_VOID context::use_certificate_chain_file(
     const std::string& filename, asio::error_code& ec)
 {
   ::ERR_clear_error();
@@ -604,11 +604,11 @@
     ec = asio::error_code(
         static_cast<int>(::ERR_get_error()),
         asio::error::get_ssl_category());
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::use_private_key(
@@ -619,7 +619,7 @@
   asio::detail::throw_error(ec, "use_private_key");
 }
 
-asio::error_code context::use_private_key(
+ASIO_SYNC_OP_VOID context::use_private_key(
     const const_buffer& private_key, context::file_format format,
     asio::error_code& ec)
 {
@@ -642,7 +642,7 @@
     default:
       {
         ec = asio::error::invalid_argument;
-        return ec;
+        ASIO_SYNC_OP_VOID_RETURN(ec);
       }
     }
 
@@ -651,7 +651,7 @@
       if (::SSL_CTX_use_PrivateKey(handle_, evp_private_key.p) == 1)
       {
         ec = asio::error_code();
-        return ec;
+        ASIO_SYNC_OP_VOID_RETURN(ec);
       }
     }
   }
@@ -659,7 +659,7 @@
   ec = asio::error_code(
       static_cast<int>(::ERR_get_error()),
       asio::error::get_ssl_category());
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::use_private_key_file(
@@ -678,7 +678,7 @@
   asio::detail::throw_error(ec, "use_rsa_private_key");
 }
 
-asio::error_code context::use_rsa_private_key(
+ASIO_SYNC_OP_VOID context::use_rsa_private_key(
     const const_buffer& private_key, context::file_format format,
     asio::error_code& ec)
 {
@@ -701,7 +701,7 @@
     default:
       {
         ec = asio::error::invalid_argument;
-        return ec;
+        ASIO_SYNC_OP_VOID_RETURN(ec);
       }
     }
 
@@ -710,7 +710,7 @@
       if (::SSL_CTX_use_RSAPrivateKey(handle_, rsa_private_key.p) == 1)
       {
         ec = asio::error_code();
-        return ec;
+        ASIO_SYNC_OP_VOID_RETURN(ec);
       }
     }
   }
@@ -718,10 +718,10 @@
   ec = asio::error_code(
       static_cast<int>(::ERR_get_error()),
       asio::error::get_ssl_category());
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
-asio::error_code context::use_private_key_file(
+ASIO_SYNC_OP_VOID context::use_private_key_file(
     const std::string& filename, context::file_format format,
     asio::error_code& ec)
 {
@@ -737,7 +737,7 @@
   default:
     {
       ec = asio::error::invalid_argument;
-      return ec;
+      ASIO_SYNC_OP_VOID_RETURN(ec);
     }
   }
 
@@ -748,11 +748,11 @@
     ec = asio::error_code(
         static_cast<int>(::ERR_get_error()),
         asio::error::get_ssl_category());
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::use_rsa_private_key_file(
@@ -763,7 +763,7 @@
   asio::detail::throw_error(ec, "use_rsa_private_key_file");
 }
 
-asio::error_code context::use_rsa_private_key_file(
+ASIO_SYNC_OP_VOID context::use_rsa_private_key_file(
     const std::string& filename, context::file_format format,
     asio::error_code& ec)
 {
@@ -779,7 +779,7 @@
   default:
     {
       ec = asio::error::invalid_argument;
-      return ec;
+      ASIO_SYNC_OP_VOID_RETURN(ec);
     }
   }
 
@@ -791,11 +791,11 @@
     ec = asio::error_code(
         static_cast<int>(::ERR_get_error()),
         asio::error::get_ssl_category());
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::use_tmp_dh(const const_buffer& dh)
@@ -805,7 +805,7 @@
   asio::detail::throw_error(ec, "use_tmp_dh");
 }
 
-asio::error_code context::use_tmp_dh(
+ASIO_SYNC_OP_VOID context::use_tmp_dh(
     const const_buffer& dh, asio::error_code& ec)
 {
   ::ERR_clear_error();
@@ -819,7 +819,7 @@
   ec = asio::error_code(
       static_cast<int>(::ERR_get_error()),
       asio::error::get_ssl_category());
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 void context::use_tmp_dh_file(const std::string& filename)
@@ -829,7 +829,7 @@
   asio::detail::throw_error(ec, "use_tmp_dh_file");
 }
 
-asio::error_code context::use_tmp_dh_file(
+ASIO_SYNC_OP_VOID context::use_tmp_dh_file(
     const std::string& filename, asio::error_code& ec)
 {
   ::ERR_clear_error();
@@ -843,10 +843,10 @@
   ec = asio::error_code(
       static_cast<int>(::ERR_get_error()),
       asio::error::get_ssl_category());
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
-asio::error_code context::do_use_tmp_dh(
+ASIO_SYNC_OP_VOID context::do_use_tmp_dh(
     BIO* bio, asio::error_code& ec)
 {
   ::ERR_clear_error();
@@ -857,17 +857,17 @@
     if (::SSL_CTX_set_tmp_dh(handle_, dh.p) == 1)
     {
       ec = asio::error_code();
-      return ec;
+      ASIO_SYNC_OP_VOID_RETURN(ec);
     }
   }
 
   ec = asio::error_code(
       static_cast<int>(::ERR_get_error()),
       asio::error::get_ssl_category());
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
-asio::error_code context::do_set_verify_callback(
+ASIO_SYNC_OP_VOID context::do_set_verify_callback(
     detail::verify_callback_base* callback, asio::error_code& ec)
 {
   if (SSL_CTX_get_app_data(handle_))
@@ -883,7 +883,7 @@
       &context::verify_callback_function);
 
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 int context::verify_callback_function(int preverified, X509_STORE_CTX* ctx)
@@ -912,7 +912,7 @@
   return 0;
 }
 
-asio::error_code context::do_set_password_callback(
+ASIO_SYNC_OP_VOID context::do_set_password_callback(
     detail::password_callback_base* callback, asio::error_code& ec)
 {
   if (handle_->default_passwd_callback_userdata)
@@ -924,7 +924,7 @@
   SSL_CTX_set_default_passwd_cb(handle_, &context::password_callback_function);
 
   ec = asio::error_code();
-  return ec;
+  ASIO_SYNC_OP_VOID_RETURN(ec);
 }
 
 int context::password_callback_function(
diff --git a/asio/include/asio/ssl/stream.hpp b/asio/include/asio/ssl/stream.hpp
index 566ba50..bc259b5 100644
--- a/asio/include/asio/ssl/stream.hpp
+++ b/asio/include/asio/ssl/stream.hpp
@@ -259,10 +259,11 @@
    *
    * @note Calls @c SSL_set_verify.
    */
-  asio::error_code set_verify_mode(
+  ASIO_SYNC_OP_VOID set_verify_mode(
       verify_mode v, asio::error_code& ec)
   {
-    return core_.engine_.set_verify_mode(v, ec);
+    core_.engine_.set_verify_mode(v, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Set the peer verification depth.
@@ -296,10 +297,11 @@
    *
    * @note Calls @c SSL_set_verify_depth.
    */
-  asio::error_code set_verify_depth(
+  ASIO_SYNC_OP_VOID set_verify_depth(
       int depth, asio::error_code& ec)
   {
-    return core_.engine_.set_verify_depth(depth, ec);
+    core_.engine_.set_verify_depth(depth, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Set the callback used to verify peer certificates.
@@ -347,11 +349,12 @@
    * @note Calls @c SSL_set_verify.
    */
   template <typename VerifyCallback>
-  asio::error_code set_verify_callback(VerifyCallback callback,
+  ASIO_SYNC_OP_VOID set_verify_callback(VerifyCallback callback,
       asio::error_code& ec)
   {
-    return core_.engine_.set_verify_callback(
+    core_.engine_.set_verify_callback(
         new detail::verify_callback<VerifyCallback>(callback), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Perform SSL handshaking.
@@ -381,11 +384,11 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code handshake(handshake_type type,
+  ASIO_SYNC_OP_VOID handshake(handshake_type type,
       asio::error_code& ec)
   {
     detail::io(next_layer_, core_, detail::handshake_op(type), ec);
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Perform SSL handshaking.
@@ -421,12 +424,12 @@
    * @param ec Set to indicate what error occurred, if any.
    */
   template <typename ConstBufferSequence>
-  asio::error_code handshake(handshake_type type,
+  ASIO_SYNC_OP_VOID handshake(handshake_type type,
       const ConstBufferSequence& buffers, asio::error_code& ec)
   {
     detail::io(next_layer_, core_,
         detail::buffered_handshake_op<ConstBufferSequence>(type, buffers), ec);
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Start an asynchronous SSL handshake.
@@ -526,10 +529,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code shutdown(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID shutdown(asio::error_code& ec)
   {
     detail::io(next_layer_, core_, detail::shutdown_op(), ec);
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Asynchronously shut down SSL on the stream.
diff --git a/asio/include/asio/stream_socket_service.hpp b/asio/include/asio/stream_socket_service.hpp
index 7d057af..5cea565 100644
--- a/asio/include/asio/stream_socket_service.hpp
+++ b/asio/include/asio/stream_socket_service.hpp
@@ -134,22 +134,23 @@
   }
 
   /// Open a stream socket.
-  asio::error_code open(implementation_type& impl,
+  ASIO_SYNC_OP_VOID open(implementation_type& impl,
       const protocol_type& protocol, asio::error_code& ec)
   {
     if (protocol.type() == ASIO_OS_DEF(SOCK_STREAM))
       service_impl_.open(impl, protocol, ec);
     else
       ec = asio::error::invalid_argument;
-    return ec;
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Assign an existing native socket to a stream socket.
-  asio::error_code assign(implementation_type& impl,
+  ASIO_SYNC_OP_VOID assign(implementation_type& impl,
       const protocol_type& protocol, const native_handle_type& native_socket,
       asio::error_code& ec)
   {
-    return service_impl_.assign(impl, protocol, native_socket, ec);
+    service_impl_.assign(impl, protocol, native_socket, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the socket is open.
@@ -159,10 +160,11 @@
   }
 
   /// Close a stream socket implementation.
-  asio::error_code close(implementation_type& impl,
+  ASIO_SYNC_OP_VOID close(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.close(impl, ec);
+    service_impl_.close(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native socket implementation.
@@ -172,10 +174,11 @@
   }
 
   /// Cancel all asynchronous operations associated with the socket.
-  asio::error_code cancel(implementation_type& impl,
+  ASIO_SYNC_OP_VOID cancel(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.cancel(impl, ec);
+    service_impl_.cancel(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the socket is at the out-of-band data mark.
@@ -193,17 +196,19 @@
   }
 
   /// Bind the stream socket to the specified local endpoint.
-  asio::error_code bind(implementation_type& impl,
+  ASIO_SYNC_OP_VOID bind(implementation_type& impl,
       const endpoint_type& endpoint, asio::error_code& ec)
   {
-    return service_impl_.bind(impl, endpoint, ec);
+    service_impl_.bind(impl, endpoint, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Connect the stream socket to the specified endpoint.
-  asio::error_code connect(implementation_type& impl,
+  ASIO_SYNC_OP_VOID connect(implementation_type& impl,
       const endpoint_type& peer_endpoint, asio::error_code& ec)
   {
-    return service_impl_.connect(impl, peer_endpoint, ec);
+    service_impl_.connect(impl, peer_endpoint, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Start an asynchronous connect.
@@ -224,26 +229,29 @@
 
   /// Set a socket option.
   template <typename SettableSocketOption>
-  asio::error_code set_option(implementation_type& impl,
+  ASIO_SYNC_OP_VOID set_option(implementation_type& impl,
       const SettableSocketOption& option, asio::error_code& ec)
   {
-    return service_impl_.set_option(impl, option, ec);
+    service_impl_.set_option(impl, option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get a socket option.
   template <typename GettableSocketOption>
-  asio::error_code get_option(const implementation_type& impl,
+  ASIO_SYNC_OP_VOID get_option(const implementation_type& impl,
       GettableSocketOption& option, asio::error_code& ec) const
   {
-    return service_impl_.get_option(impl, option, ec);
+    service_impl_.get_option(impl, option, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Perform an IO control command on the socket.
   template <typename IoControlCommand>
-  asio::error_code io_control(implementation_type& impl,
+  ASIO_SYNC_OP_VOID io_control(implementation_type& impl,
       IoControlCommand& command, asio::error_code& ec)
   {
-    return service_impl_.io_control(impl, command, ec);
+    service_impl_.io_control(impl, command, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the socket.
@@ -253,10 +261,11 @@
   }
 
   /// Sets the non-blocking mode of the socket.
-  asio::error_code non_blocking(implementation_type& impl,
+  ASIO_SYNC_OP_VOID non_blocking(implementation_type& impl,
       bool mode, asio::error_code& ec)
   {
-    return service_impl_.non_blocking(impl, mode, ec);
+    service_impl_.non_blocking(impl, mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Gets the non-blocking mode of the native socket implementation.
@@ -266,10 +275,11 @@
   }
 
   /// Sets the non-blocking mode of the native socket implementation.
-  asio::error_code native_non_blocking(implementation_type& impl,
+  ASIO_SYNC_OP_VOID native_non_blocking(implementation_type& impl,
       bool mode, asio::error_code& ec)
   {
-    return service_impl_.native_non_blocking(impl, mode, ec);
+    service_impl_.native_non_blocking(impl, mode, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the local endpoint.
@@ -287,18 +297,20 @@
   }
 
   /// Disable sends or receives on the socket.
-  asio::error_code shutdown(implementation_type& impl,
+  ASIO_SYNC_OP_VOID shutdown(implementation_type& impl,
       socket_base::shutdown_type what, asio::error_code& ec)
   {
-    return service_impl_.shutdown(impl, what, ec);
+    service_impl_.shutdown(impl, what, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Wait for the socket to become ready to read, ready to write, or to have
   /// pending error conditions.
-  asio::error_code wait(implementation_type& impl,
+  ASIO_SYNC_OP_VOID wait(implementation_type& impl,
       socket_base::wait_type w, asio::error_code& ec)
   {
-    return service_impl_.wait(impl, w, ec);
+    service_impl_.wait(impl, w, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Asynchronously wait for the socket to become ready to read, ready to
diff --git a/asio/include/asio/windows/basic_handle.hpp b/asio/include/asio/windows/basic_handle.hpp
index f9ec182..3b1ce2c 100644
--- a/asio/include/asio/windows/basic_handle.hpp
+++ b/asio/include/asio/windows/basic_handle.hpp
@@ -169,10 +169,11 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code assign(const native_handle_type& handle,
+  ASIO_SYNC_OP_VOID assign(const native_handle_type& handle,
       asio::error_code& ec)
   {
-    return this->get_service().assign(this->get_implementation(), handle, ec);
+    this->get_service().assign(this->get_implementation(), handle, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the handle is open.
@@ -204,9 +205,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code close(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID close(asio::error_code& ec)
   {
-    return this->get_service().close(this->get_implementation(), ec);
+    this->get_service().close(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native handle representation.
@@ -243,9 +245,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code cancel(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
   {
-    return this->get_service().cancel(this->get_implementation(), ec);
+    this->get_service().cancel(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
 protected:
diff --git a/asio/include/asio/windows/object_handle.hpp b/asio/include/asio/windows/object_handle.hpp
index ec17d5b..6b5ad59 100644
--- a/asio/include/asio/windows/object_handle.hpp
+++ b/asio/include/asio/windows/object_handle.hpp
@@ -226,10 +226,11 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code assign(const native_handle_type& handle,
+  ASIO_SYNC_OP_VOID assign(const native_handle_type& handle,
       asio::error_code& ec)
   {
-    return this->get_service().assign(this->get_implementation(), handle, ec);
+    this->get_service().assign(this->get_implementation(), handle, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the handle is open.
@@ -261,9 +262,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code close(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID close(asio::error_code& ec)
   {
-    return this->get_service().close(this->get_implementation(), ec);
+    this->get_service().close(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native handle representation.
@@ -300,9 +302,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code cancel(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
   {
-    return this->get_service().cancel(this->get_implementation(), ec);
+    this->get_service().cancel(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Perform a blocking wait on the object handle.
diff --git a/asio/include/asio/windows/object_handle_service.hpp b/asio/include/asio/windows/object_handle_service.hpp
index b08df35..524a9f8 100644
--- a/asio/include/asio/windows/object_handle_service.hpp
+++ b/asio/include/asio/windows/object_handle_service.hpp
@@ -103,10 +103,11 @@
   }
 
   /// Assign an existing native handle to an object handle.
-  asio::error_code assign(implementation_type& impl,
+  ASIO_SYNC_OP_VOID assign(implementation_type& impl,
       const native_handle_type& handle, asio::error_code& ec)
   {
-    return service_impl_.assign(impl, handle, ec);
+    service_impl_.assign(impl, handle, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the handle is open.
@@ -116,10 +117,11 @@
   }
 
   /// Close an object handle implementation.
-  asio::error_code close(implementation_type& impl,
+  ASIO_SYNC_OP_VOID close(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.close(impl, ec);
+    service_impl_.close(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native handle implementation.
@@ -129,10 +131,11 @@
   }
 
   /// Cancel all asynchronous operations associated with the handle.
-  asio::error_code cancel(implementation_type& impl,
+  ASIO_SYNC_OP_VOID cancel(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.cancel(impl, ec);
+    service_impl_.cancel(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   // Wait for a signaled state.
diff --git a/asio/include/asio/windows/overlapped_handle.hpp b/asio/include/asio/windows/overlapped_handle.hpp
index 8e31590..3db0f1d 100644
--- a/asio/include/asio/windows/overlapped_handle.hpp
+++ b/asio/include/asio/windows/overlapped_handle.hpp
@@ -222,10 +222,11 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code assign(const native_handle_type& handle,
+  ASIO_SYNC_OP_VOID assign(const native_handle_type& handle,
       asio::error_code& ec)
   {
-    return this->get_service().assign(this->get_implementation(), handle, ec);
+    this->get_service().assign(this->get_implementation(), handle, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the handle is open.
@@ -257,9 +258,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code close(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID close(asio::error_code& ec)
   {
-    return this->get_service().close(this->get_implementation(), ec);
+    this->get_service().close(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native handle representation.
@@ -296,9 +298,10 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
-  asio::error_code cancel(asio::error_code& ec)
+  ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
   {
-    return this->get_service().cancel(this->get_implementation(), ec);
+    this->get_service().cancel(this->get_implementation(), ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
 protected:
diff --git a/asio/include/asio/windows/random_access_handle_service.hpp b/asio/include/asio/windows/random_access_handle_service.hpp
index 959f5fc..b3df24a 100644
--- a/asio/include/asio/windows/random_access_handle_service.hpp
+++ b/asio/include/asio/windows/random_access_handle_service.hpp
@@ -105,10 +105,11 @@
   }
 
   /// Assign an existing native handle to a random-access handle.
-  asio::error_code assign(implementation_type& impl,
+  ASIO_SYNC_OP_VOID assign(implementation_type& impl,
       const native_handle_type& handle, asio::error_code& ec)
   {
-    return service_impl_.assign(impl, handle, ec);
+    service_impl_.assign(impl, handle, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the handle is open.
@@ -118,10 +119,11 @@
   }
 
   /// Close a random-access handle implementation.
-  asio::error_code close(implementation_type& impl,
+  ASIO_SYNC_OP_VOID close(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.close(impl, ec);
+    service_impl_.close(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native handle implementation.
@@ -131,10 +133,11 @@
   }
 
   /// Cancel all asynchronous operations associated with the handle.
-  asio::error_code cancel(implementation_type& impl,
+  ASIO_SYNC_OP_VOID cancel(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.cancel(impl, ec);
+    service_impl_.cancel(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Write the given data at the specified offset.
diff --git a/asio/include/asio/windows/stream_handle_service.hpp b/asio/include/asio/windows/stream_handle_service.hpp
index dbd5df5..5da3dd7 100644
--- a/asio/include/asio/windows/stream_handle_service.hpp
+++ b/asio/include/asio/windows/stream_handle_service.hpp
@@ -103,10 +103,11 @@
   }
 
   /// Assign an existing native handle to a stream handle.
-  asio::error_code assign(implementation_type& impl,
+  ASIO_SYNC_OP_VOID assign(implementation_type& impl,
       const native_handle_type& handle, asio::error_code& ec)
   {
-    return service_impl_.assign(impl, handle, ec);
+    service_impl_.assign(impl, handle, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Determine whether the handle is open.
@@ -116,10 +117,11 @@
   }
 
   /// Close a stream handle implementation.
-  asio::error_code close(implementation_type& impl,
+  ASIO_SYNC_OP_VOID close(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.close(impl, ec);
+    service_impl_.close(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Get the native handle implementation.
@@ -129,10 +131,11 @@
   }
 
   /// Cancel all asynchronous operations associated with the handle.
-  asio::error_code cancel(implementation_type& impl,
+  ASIO_SYNC_OP_VOID cancel(implementation_type& impl,
       asio::error_code& ec)
   {
-    return service_impl_.cancel(impl, ec);
+    service_impl_.cancel(impl, ec);
+    ASIO_SYNC_OP_VOID_RETURN(ec);
   }
 
   /// Write the given data to the stream.
diff --git a/asio/src/doc/reference.dox b/asio/src/doc/reference.dox
index 5a37fa2..4a05a80 100644
--- a/asio/src/doc/reference.dox
+++ b/asio/src/doc/reference.dox
@@ -211,7 +211,8 @@
                          ASIO_SVC_T=asio::detail::service \
                          ASIO_SVC_T1=asio::detail::service \
                          ASIO_CONST_BUFFER=const_buffer \
-                         ASIO_MUTABLE_BUFFER=mutable_buffer
+                         ASIO_MUTABLE_BUFFER=mutable_buffer \
+                         ASIO_SYNC_OP_VOID=void
 EXPAND_AS_DEFINED      = 
 SKIP_FUNCTION_MACROS   = YES
 #---------------------------------------------------------------------------
diff --git a/asio/src/tests/unit/local/connect_pair.cpp b/asio/src/tests/unit/local/connect_pair.cpp
index b7ea41f..31a34af 100644
--- a/asio/src/tests/unit/local/connect_pair.cpp
+++ b/asio/src/tests/unit/local/connect_pair.cpp
@@ -42,7 +42,6 @@
   {
     asio::io_context io_context;
     asio::error_code ec1;
-    asio::error_code ec2;
 
     dp::socket s1(io_context);
     dp::socket s2(io_context);
@@ -50,7 +49,7 @@
 
     dp::socket s3(io_context);
     dp::socket s4(io_context);
-    ec1 = local::connect_pair(s3, s4, ec2);
+    local::connect_pair(s3, s4, ec1);
 
     sp::socket s5(io_context);
     sp::socket s6(io_context);
@@ -58,7 +57,7 @@
 
     sp::socket s7(io_context);
     sp::socket s8(io_context);
-    ec1 = local::connect_pair(s7, s8, ec2);
+    local::connect_pair(s7, s8, ec1);
   }
   catch (std::exception&)
   {