From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55650) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7Aiv-00087q-Be for qemu-devel@nongnu.org; Mon, 12 Mar 2012 15:16:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S7Ait-0005rn-5w for qemu-devel@nongnu.org; Mon, 12 Mar 2012 15:16:00 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:38451) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7Ais-0005r8-Uz for qemu-devel@nongnu.org; Mon, 12 Mar 2012 15:15:59 -0400 From: Michael Tokarev Date: Mon, 12 Mar 2012 23:14:21 +0400 Message-Id: <1331579663-29950-8-git-send-email-mjt@msgid.tls.msk.ru> In-Reply-To: <1331579663-29950-1-git-send-email-mjt@msgid.tls.msk.ru> References: <1331579663-29950-1-git-send-email-mjt@msgid.tls.msk.ru> Subject: [Qemu-devel] [PATCHv3 7/9] export qemu_sendv_recvv() and use it in qemu_sendv() and qemu_recvv() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Michael Tokarev Rename do_sendv_recvv() to qemu_sendv_recvv(), change its last arg (do_sendv) 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 | 19 ++++--------------- qemu-common.h | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/cutils.c b/cutils.c index e9052fc..be2173f 100644 --- a/cutils.c +++ b/cutils.c @@ -383,7 +383,7 @@ int qemu_parse_fd(const char *param) * The first `offset' bytes in the iovec buffer are skipped and next * `bytes' bytes are used, which must be within data of iovec. * - * r = do_sendv_recvv(sockfd, iov, offset, bytes, 1); + * r = qemu_sendv_recvv(sockfd, iov, offset, butes, true); * * is logically equivalent to * @@ -392,9 +392,9 @@ int qemu_parse_fd(const char *param) * r = send(sockfd, buf, size, 0); * free(buf); */ -static ssize_t do_sendv_recvv(int sockfd, struct iovec *iov, - size_t offset, size_t bytes, - int do_sendv) +ssize_t qemu_sendv_recvv(int sockfd, struct iovec *iov, + size_t offset, size_t bytes, + bool do_sendv) { int iovlen; ssize_t ret; @@ -474,14 +474,3 @@ static ssize_t do_sendv_recvv(int sockfd, struct iovec *iov, last_iov->iov_len += diff; return ret; } - -ssize_t qemu_recvv(int sockfd, struct iovec *iov, size_t offset, size_t bytes) -{ - return do_sendv_recvv(sockfd, iov, offset, bytes, 0); -} - -ssize_t 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 8d12fca..b01d84c 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 -ssize_t qemu_recvv(int sockfd, struct iovec *iov, size_t offset, size_t bytes); -ssize_t 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'. + */ +ssize_t 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. */ -- 1.7.9.1