summaryrefslogtreecommitdiff
path: root/tools/virtio/ringtest/main.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2016-10-06 11:39:11 +0200
committerMichael S. Tsirkin <mst@redhat.com>2016-10-31 00:21:43 +0200
commitd3c3589b8b3cd4fabf4cd137facb42a7fb36bd7f (patch)
treed71957ed6843a84c8328587604b9bdfe84363094 /tools/virtio/ringtest/main.c
parent44d65ea1615099ae252407f2554338d450cfdb1c (diff)
ringtest: commonize implementation of poll_avail/poll_used
Provide new primitives used_empty/avail_empty and build poll_avail/poll_used on top of it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'tools/virtio/ringtest/main.c')
-rw-r--r--tools/virtio/ringtest/main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/virtio/ringtest/main.c b/tools/virtio/ringtest/main.c
index bda7f0dad981..b00ecd619969 100644
--- a/tools/virtio/ringtest/main.c
+++ b/tools/virtio/ringtest/main.c
@@ -96,6 +96,12 @@ void set_affinity(const char *arg)
assert(!ret);
}
+void poll_used(void)
+{
+ while (used_empty())
+ busy_wait();
+}
+
static void __attribute__((__flatten__)) run_guest(void)
{
int completed_before;
@@ -149,6 +155,12 @@ static void __attribute__((__flatten__)) run_guest(void)
}
}
+void poll_avail(void)
+{
+ while (avail_empty())
+ busy_wait();
+}
+
static void __attribute__((__flatten__)) run_host(void)
{
int completed_before;