From patchwork Sun Mar 11 01:49:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 145926 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 361EAB6FA7 for ; Sun, 11 Mar 2012 12:49:52 +1100 (EST) Received: from localhost ([::1]:49450 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6Xuw-0003Am-Nl for incoming@patchwork.ozlabs.org; Sat, 10 Mar 2012 20:49:50 -0500 Received: from eggs.gnu.org ([208.118.235.92]:53592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6Xup-0003AS-5d for qemu-devel@nongnu.org; Sat, 10 Mar 2012 20:49:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S6Xum-0002mJ-OV for qemu-devel@nongnu.org; Sat, 10 Mar 2012 20:49:42 -0500 Received: from isrv.corpit.ru ([86.62.121.231]:33343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6Xum-0002m3-Gr for qemu-devel@nongnu.org; Sat, 10 Mar 2012 20:49:40 -0500 Received: from gandalf.tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by isrv.corpit.ru (Postfix) with ESMTP id 268F6A0788; Sun, 11 Mar 2012 05:49:38 +0400 (MSK) Received: by gandalf.tls.msk.ru (Postfix, from userid 1000) id 9BCE965E9; Sun, 11 Mar 2012 05:49:37 +0400 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Date: Sun, 11 Mar 2012 05:49:22 +0400 Message-Id: <1331430564-32745-6-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1331430564-32745-1-git-send-email-mjt@msgid.tls.msk.ru> References: <1331430564-32745-1-git-send-email-mjt@msgid.tls.msk.ru> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 86.62.121.231 Cc: Michael Tokarev Subject: [Qemu-devel] [PATCHv2 5/7] Export qemu_sendv_recvv() and use it in qemu_sendv() and qemu_recvv() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Rename do_sendv_recvv() to qemu_sendv_recvv(), change its last arg (do_send) from int to bool, export it in qemu-common.h, and made the two callers of it (qemu_sendv() and qemu_recvv()) to be trivial #defines just adding 5th arg. qemu_sendv_recvv() will be used later. Signed-off-by: Michael Tokarev --- cutils.c | 15 ++------------- qemu-common.h | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/cutils.c b/cutils.c index b3b9cfb..b6f8eb8 100644 --- a/cutils.c +++ b/cutils.c @@ -419,8 +419,8 @@ int qemu_parse_fd(const char *param) * The first `offset' bytes in the iovec buffer are skipped and next * `bytes' bytes are used. */ -static int do_sendv_recvv(int sockfd, struct iovec *iov, size_t offset, size_t bytes, - int do_sendv) +int qemu_sendv_recvv(int sockfd, struct iovec *iov, size_t offset, size_t bytes, + bool do_sendv) { int ret, iovlen; size_t diff; @@ -499,14 +499,3 @@ static int do_sendv_recvv(int sockfd, struct iovec *iov, size_t offset, size_t b last_iov->iov_len += diff; return ret; } - -int qemu_recvv(int sockfd, struct iovec *iov, size_t offset, size_t bytes) -{ - return do_sendv_recvv(sockfd, iov, offset, bytes, 0); -} - -int qemu_sendv(int sockfd, struct iovec *iov, size_t offset, size_t bytes) -{ - return do_sendv_recvv(sockfd, iov, offset, bytes, 1); -} - diff --git a/qemu-common.h b/qemu-common.h index bb75dd3..b8190e9 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -199,8 +199,18 @@ int qemu_pipe(int pipefd[2]); #define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags) #endif -int qemu_recvv(int sockfd, struct iovec *iov, size_t offset, size_t bytes); -int qemu_sendv(int sockfd, struct iovec *iov, size_t offset, size_t bytes); +/** + * Send or receive data from/to an (optionally partial) iovec. + * Instead of processing whole iovector, this routine can process + * not more than a specified number of bytes, and start not at + * the beginning of iovec but at byte position `offset'. + */ +int qemu_sendv_recvv(int sockfd, struct iovec *iov, + size_t offset, size_t bytes, bool do_sendv); +#define qemu_recvv(sockfd, iov, offset, bytes) \ + qemu_sendv_recvv(sockfd, iov, offset, bytes, false) +#define qemu_sendv(sockfd, iov, offset, bytes) \ + qemu_sendv_recvv(sockfd, iov, offset, bytes, true) /* Error handling. */