summaryrefslogtreecommitdiffstats
path: root/tools/virtio/ringtest/ptr_ring.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-30 23:21:43 +0100
commitd3c3589b8b3cd4fabf4cd137facb42a7fb36bd7f (patch)
treed71957ed6843a84c8328587604b9bdfe84363094 /tools/virtio/ringtest/ptr_ring.c
parentringtest: use link-time optimization (diff)
downloadlinux-d3c3589b8b3cd4fabf4cd137facb42a7fb36bd7f.tar.xz
linux-d3c3589b8b3cd4fabf4cd137facb42a7fb36bd7f.zip
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/ptr_ring.c')
-rw-r--r--tools/virtio/ringtest/ptr_ring.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/tools/virtio/ringtest/ptr_ring.c b/tools/virtio/ringtest/ptr_ring.c
index bd2ad1d3b7a9..635b07b4fdd3 100644
--- a/tools/virtio/ringtest/ptr_ring.c
+++ b/tools/virtio/ringtest/ptr_ring.c
@@ -133,18 +133,9 @@ void *get_buf(unsigned *lenp, void **bufp)
return datap;
}
-void poll_used(void)
+bool used_empty()
{
- void *b;
-
- do {
- if (tailcnt == headcnt || __ptr_ring_full(&array)) {
- b = NULL;
- barrier();
- } else {
- b = "Buffer\n";
- }
- } while (!b);
+ return (tailcnt == headcnt || __ptr_ring_full(&array));
}
void disable_call()
@@ -173,14 +164,9 @@ bool enable_kick()
assert(0);
}
-void poll_avail(void)
+bool avail_empty()
{
- void *b;
-
- do {
- barrier();
- b = __ptr_ring_peek(&array);
- } while (!b);
+ return !__ptr_ring_peek(&array);
}
bool use_buf(unsigned *lenp, void **bufp)