Received: from eggs.gnu.org ([208.118.235.92]:56450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6PGd-00037T-PF for qemu-devel@nongnu.org; Sat, 10 Mar 2012 11:35:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S6PGb-0006zo-QO for qemu-devel@nongnu.org; Sat, 10 Mar 2012 11:35:39 -0500 Received: from isrv.corpit.ru ([86.62.121.231]:56195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6PGb-0006zf-IP for qemu-devel@nongnu.org; Sat, 10 Mar 2012 11:35:37 -0500 From: Michael Tokarev Date: Sat, 10 Mar 2012 20:32:28 +0400 Message-Id: <1331397150-25700-4-git-send-email-mjt@msgid.tls.msk.ru> In-Reply-To: <1331397150-25700-1-git-send-email-mjt@tls.msk.ru> References: <1331397150-25700-1-git-send-email-mjt@tls.msk.ru> Subject: [Qemu-devel] [PATCH 3/5] Export qemu_sendv_recvv() and use it in (inlined) qemu_sendv() and qemu_recvv() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Michael Tokarev 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 89305ad..6d9175f 100644 --- a/cutils.c +++ b/cutils.c @@ -426,8 +426,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 bytes, size_t offset, - int do_sendv) +int qemu_sendv_recvv(int sockfd, struct iovec *iov, size_t bytes, size_t offset, + bool do_sendv) { int ret, iovlen; size_t diff; @@ -506,14 +506,3 @@ static int do_sendv_recvv(int sockfd, struct iovec *iov, size_t bytes, size_t of last_iov->iov_len += diff; return ret; } - -int qemu_recvv(int sockfd, struct iovec *iov, size_t bytes, size_t offset) -{ - return do_sendv_recvv(sockfd, iov, bytes, offset, 0); -} - -int qemu_sendv(int sockfd, struct iovec *iov, size_t bytes, size_t offset) -{ - return do_sendv_recvv(sockfd, iov, bytes, offset, 1); -} - diff --git a/qemu-common.h b/qemu-common.h index c0536b3..474cbcc 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 bytes, size_t offset); -int qemu_sendv(int sockfd, struct iovec *iov, size_t bytes, size_t offset); +/** + * 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 bytes, size_t offset, bool do_sendv); +#define qemu_recvv(sockfd, iov, bytes, offset) \ + qemu_sendv_recvv(sockfd, iov, bytes, offset, false) +#define qemu_sendv(sockfd, iov, bytes, offset) \ + qemu_sendv_recvv(sockfd, iov, bytes, offset, true) /* Error handling. */ -- 1.7.9.1