ringtest: commonize implementation of poll_avail/poll_used
[cascardo/linux.git] / tools / virtio / ringtest / main.c
index 3a5ff43..b00ecd6 100644 (file)
@@ -96,7 +96,13 @@ void set_affinity(const char *arg)
        assert(!ret);
 }
 
-static void run_guest(void)
+void poll_used(void)
+{
+       while (used_empty())
+               busy_wait();
+}
+
+static void __attribute__((__flatten__)) run_guest(void)
 {
        int completed_before;
        int completed = 0;
@@ -115,7 +121,7 @@ static void run_guest(void)
                do {
                        if (started < bufs &&
                            started - completed < max_outstanding) {
-                               r = add_inbuf(0, NULL, "Hello, world!");
+                               r = add_inbuf(0, "Buffer\n", "Hello, world!");
                                if (__builtin_expect(r == 0, true)) {
                                        ++started;
                                        if (!--tokick) {
@@ -149,7 +155,13 @@ static void run_guest(void)
        }
 }
 
-static void run_host(void)
+void poll_avail(void)
+{
+       while (avail_empty())
+               busy_wait();
+}
+
+static void __attribute__((__flatten__)) run_host(void)
 {
        int completed_before;
        int completed = 0;