All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, Michael Tokarev <mjt@tls.msk.ru>
Subject: [Qemu-devel] [PATCHv3 7/9] export qemu_sendv_recvv() and use it in qemu_sendv() and qemu_recvv()
Date: Mon, 12 Mar 2012 23:14:21 +0400	[thread overview]
Message-ID: <1331579663-29950-8-git-send-email-mjt@msgid.tls.msk.ru> (raw)
In-Reply-To: <1331579663-29950-1-git-send-email-mjt@msgid.tls.msk.ru>

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 <mjt@tls.msk.ru>
---
 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

  parent reply	other threads:[~2012-03-12 19:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-12 19:14 [Qemu-devel] [PATCHv3 0/9] cleanup/consolidate some iovec functions Michael Tokarev
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 1/9] refresh iov_* functions Michael Tokarev
2012-03-13 17:44   ` Paolo Bonzini
2012-03-13 18:28     ` Michael Tokarev
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 2/9] consolidate qemu_iovec_memset{, _skip}() into single function and use existing iov_memset() Michael Tokarev
2012-03-13 17:46   ` Paolo Bonzini
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 3/9] allow qemu_iovec_from_buffer() to specify offset from which to start copying Michael Tokarev
2012-03-13 11:10   ` Kevin Wolf
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 4/9] consolidate qemu_iovec_copy() and qemu_iovec_concat() and make them consistent Michael Tokarev
2012-03-13 18:02   ` Paolo Bonzini
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 5/9] change qemu_iovec_to_buf() to match other to, from_buf functions Michael Tokarev
2012-03-13 18:02   ` Paolo Bonzini
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 6/9] change prototypes of qemu_sendv() and qemu_recvv() Michael Tokarev
2012-03-12 19:14 ` Michael Tokarev [this message]
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 8/9] cleanup qemu_co_sendv(), qemu_co_recvv() and friends Michael Tokarev
2012-03-13 17:52   ` Paolo Bonzini
2012-03-13 18:01     ` Paolo Bonzini
2012-03-13 19:35       ` Michael Tokarev
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 9/9] rewrite and comment qemu_sendv_recvv() Michael Tokarev
2012-03-13 16:09 ` [Qemu-devel] [PATCHv3 0/9] cleanup/consolidate some iovec functions Michael Tokarev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1331579663-29950-8-git-send-email-mjt@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.